fix(ui-migration): 拉伸解耦背景判定 + objectIndex 内容级校验 + 缺图抛错回归
评审 Important 修复: 1. spec §2.4: flags.stretch/拉伸widget 适用于全部满屏对象(52个),不只是层内首个 的 backgroundNodeId(40个,判定规则不变)。此前实现把两者绑死,导致12个非首位 满屏遮罩(如"创建房间遮罩")套用三区锚点几何,进 Cocos 后会错位。 2. 真实数据护栏补内容级校验: 遍历 manifest.objectIndex 全部991条,核对每条 layerId 与源数据 BelongLayerID 一致——杀掉"全部条目指向同一层"这类只查条数 查不出的变异,这是子系统 C 定位 1773 处 set_self 的承重字段。 3. 补"引用不存在的图显式抛错"的回归用例——此前只有代码审查保护,真实数据恰好 不触发,没有测试防线;错误信息须可定位对象ID与图ID。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -55,7 +55,10 @@ function spriteBlock(obj, image, bucket, warnings) {
|
||||
return { block, outOfRange };
|
||||
}
|
||||
|
||||
function toNode(obj, source, imageBucketMap, isBackground, warnings) {
|
||||
function toNode(obj, source, imageBucketMap, warnings) {
|
||||
// 拉伸(四边置0)适用于全部满屏对象(spec §2.4: 实测 52 个),不论是否层内首个。
|
||||
// backgroundNodeId(层内唯一)是另一件事:仅用于"首个+满屏"的背景判定,与此处解耦。
|
||||
const stretch = isFullScreen(obj.Width, obj.Height);
|
||||
const node = {
|
||||
id: obj.ObjectID,
|
||||
name: obj.ObjectName,
|
||||
@@ -63,9 +66,9 @@ function toNode(obj, source, imageBucketMap, isBackground, warnings) {
|
||||
position: toCocosPosition(obj.Left, obj.Top, obj.Width, obj.Height),
|
||||
size: { width: obj.Width, height: obj.Height },
|
||||
siblingIndex: obj.IndexOfLayer,
|
||||
widget: isBackground ? stretchWidget() : inferWidget(obj.Left, obj.Width),
|
||||
widget: stretch ? stretchWidget() : inferWidget(obj.Left, obj.Width),
|
||||
flags: {
|
||||
stretch: isBackground,
|
||||
stretch,
|
||||
offscreen: isOffscreen(obj.Left, obj.Top, obj.Width, obj.Height),
|
||||
animation: obj.FrameStyle === 1,
|
||||
frameIndexOutOfRange: false,
|
||||
@@ -111,7 +114,7 @@ export function convertLayer(source, layer, imageBucketMap) {
|
||||
|
||||
const warnings = [];
|
||||
const nodes = objs
|
||||
.map((o) => toNode(o, source, imageBucketMap, o.ObjectID === backgroundNodeId, warnings))
|
||||
.map((o) => toNode(o, source, imageBucketMap, warnings))
|
||||
.sort((a, b) => a.siblingIndex - b.siblingIndex);
|
||||
|
||||
const nodeIdSet = new Set(nodes.map((n) => n.id));
|
||||
|
||||
Reference in New Issue
Block a user