校准素材切分概览的资源绑定统计
图片与字体槽位仅在引用的项目资源存在时计为已绑定。 概览组件接入字体资源表并保留无资源参数时的旧调用语义。
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
type UiTreeNodeTarget,
|
||||
} from './stageStatusOverview';
|
||||
import type { Component } from './types/Component';
|
||||
import type { FontAsset } from './types/FontAsset';
|
||||
import type { SpriteAsset } from './types/SpriteAsset';
|
||||
import type { UITree } from './types/UITree';
|
||||
|
||||
@@ -39,12 +40,17 @@ function countRequiredAssetSlot(isBound: boolean): ComponentSeparationCounts {
|
||||
|
||||
export function getImageSeparationCounts(
|
||||
component: Extract<Component, { Image: unknown }>['Image'],
|
||||
spriteAssets?: Record<string, SpriteAsset>,
|
||||
): ComponentSeparationCounts {
|
||||
return countRequiredAssetSlot(component.target_graphic !== null);
|
||||
return countRequiredAssetSlot(
|
||||
component.target_graphic !== null &&
|
||||
(spriteAssets === undefined || component.target_graphic in spriteAssets),
|
||||
);
|
||||
}
|
||||
|
||||
export function getTextSeparationCounts(
|
||||
component: Extract<Component, { Text: unknown }>['Text'],
|
||||
fontAssets?: Record<string, FontAsset>,
|
||||
): ComponentSeparationCounts {
|
||||
if (
|
||||
typeof component.font !== 'object' ||
|
||||
@@ -53,17 +59,21 @@ export function getTextSeparationCounts(
|
||||
) {
|
||||
return EMPTY_COMPONENT_SEPARATION_COUNTS;
|
||||
}
|
||||
return countRequiredAssetSlot(true);
|
||||
return countRequiredAssetSlot(
|
||||
fontAssets === undefined || component.font.Bound in fontAssets,
|
||||
);
|
||||
}
|
||||
|
||||
export function getComponentSeparationCounts(
|
||||
component: Component,
|
||||
spriteAssets?: Record<string, SpriteAsset>,
|
||||
fontAssets?: Record<string, FontAsset>,
|
||||
): ComponentSeparationCounts {
|
||||
if ('Image' in component) {
|
||||
return getImageSeparationCounts(component.Image);
|
||||
return getImageSeparationCounts(component.Image, spriteAssets);
|
||||
}
|
||||
if ('Text' in component) {
|
||||
return getTextSeparationCounts(component.Text);
|
||||
return getTextSeparationCounts(component.Text, fontAssets);
|
||||
}
|
||||
return EMPTY_COMPONENT_SEPARATION_COUNTS;
|
||||
}
|
||||
@@ -81,6 +91,7 @@ function addSeparationCounts(
|
||||
export function getSeparationOverview(
|
||||
uiTrees: UITree[],
|
||||
spriteAssets: Record<string, SpriteAsset>,
|
||||
fontAssets: Record<string, FontAsset> = {},
|
||||
): SeparationOverview {
|
||||
const overview: SeparationOverview = {
|
||||
...EMPTY_COMPONENT_SEPARATION_COUNTS,
|
||||
@@ -98,7 +109,7 @@ export function getSeparationOverview(
|
||||
if (node.component) {
|
||||
addSeparationCounts(
|
||||
overview,
|
||||
getComponentSeparationCounts(node.component),
|
||||
getComponentSeparationCounts(node.component, spriteAssets, fontAssets),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
nodeHasBlockedComponents,
|
||||
nodeNeedsComponentReview,
|
||||
} from '../../../features/ui-editor/separationOverview';
|
||||
import type { FontAsset } from '../../../features/ui-editor/types/FontAsset';
|
||||
import type { NodeId } from '../../../features/ui-editor/types/NodeId';
|
||||
import type { SpriteAsset } from '../../../features/ui-editor/types/SpriteAsset';
|
||||
import type { UIDesignImageId } from '../../../features/ui-editor/types/UIDesignImageId';
|
||||
@@ -14,15 +15,17 @@ import { useUiTreeNodeCycle } from '../useUiTreeNodeCycle';
|
||||
export function SeparationOverview({
|
||||
uiTrees,
|
||||
sprites,
|
||||
fonts,
|
||||
onFocusStatusNode,
|
||||
}: {
|
||||
uiTrees: UITree[];
|
||||
sprites: Record<string, SpriteAsset>;
|
||||
fonts: Record<string, FontAsset>;
|
||||
onFocusStatusNode: (treeId: UIDesignImageId, nodeId: NodeId) => void;
|
||||
}) {
|
||||
const overview = useMemo(
|
||||
() => getSeparationOverview(uiTrees, sprites),
|
||||
[sprites, uiTrees],
|
||||
() => getSeparationOverview(uiTrees, sprites, fonts),
|
||||
[fonts, sprites, uiTrees],
|
||||
);
|
||||
const attentionCycle = useUiTreeNodeCycle({
|
||||
uiTrees,
|
||||
|
||||
@@ -269,6 +269,7 @@ export default function UiEditorPage({
|
||||
<SeparationOverview
|
||||
uiTrees={session.input.uiTrees}
|
||||
sprites={session.input.sprites}
|
||||
fonts={session.input.fonts}
|
||||
onFocusStatusNode={(treeId, nodeId) => {
|
||||
session.input.focusNode(treeId, nodeId);
|
||||
session.input.highlightStatusField(nodeId, 'component_status');
|
||||
|
||||
Reference in New Issue
Block a user