@taptap/maker 0.0.37-beta.2 → 0.0.37-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ # 检查与预览排错
2
+
3
+ ## 检查范围
4
+
5
+ 从 skill 目录运行(替换游戏路径):
6
+
7
+ ```bash
8
+ node scripts/check-ui.cjs --project "/path/to/game" --format json
9
+ node scripts/check-ui.cjs --project "/path/to/game" --file assets/ui/settings.ui.json
10
+ ```
11
+
12
+ 扫描 `assets/` 内 `.ui.json`,不处理 `.ui.json.meta`;不会写任何项目文件。
13
+ 文件上限 4 MiB,单文档最多 10000 节点、深度 128;超过限制不是通过。
14
+ 目录符号链接不递归,报告警告。显式文件和资源不能越出 assets。
15
+
16
+ 退出码:`0` 执行的规则无错误,`1` 有文档错误或无 UI,`2` 参数/环境失败。
17
+ 使用 `--format json` 时,成功扫描后的结果输出到 stdout;环境失败信息在 stderr。
18
+ 一个 JSON 解析失败不会阻止检查其他可读文件。
19
+
20
+ 已检查:
21
+
22
+ - JSON 可解析、节点对象、type 非空、children 为数组。
23
+ - 同文档静态 ID 重复、内部字段、回调字段。
24
+ - 部分布局数值与枚举、显隐布尔值、透明度、九宫格数组。
25
+ - 图片与 `$repeat.template` 路径安全和文件存在。
26
+ - `.project/project.json` 的屏幕方向;页面根宽高与项目方向一致性。
27
+ - `assets/ui/ui-export-manifest.ui.json` 的页面、组件、模板清单覆盖;目录中未登记文件会提示清单可能过期,清单登记的缺失文件会报错。
28
+
29
+ 未全面检查:引擎字段全集、主题默认值、布局/字体度量、图片解码、meta/字体索引、组件/Slot 展开、
30
+ Lua 行为绑定、源页面覆盖、JSON 重复键以及引擎画面等价。
31
+ 模板参数、编辑器专属 `$repeat` 和非基础控件会提示人工核对。
32
+ 未知字段不等于受支持字段,不报错不表示语义正确。
33
+
34
+ 浏览器“检查 UI”使用相同规则,但只检查**当前内存文档**,资源存在性依据项目资源索引。
35
+ 点击问题可定位源节点;复制诊断报告给 AI。它不替代全项目检查,也不会自动保存修改。
36
+
37
+ ## 报告如何处理
38
+
39
+ 诊断包含 `code`、`severity`、`file`、`pointer`、`message`。
40
+ 例如 `/children/2/backgroundImage` 是 JSON Pointer,不是第 2 行代码。
41
+ 修复时根据文件与指针定位,再核对源 Lua;不要只按错误码批量替换。
42
+
43
+ | 现象 / 代码 | 先检查 | 修复边界 |
44
+ |---|---|---|
45
+ | UI_NO_FILES | 选的是包含 assets 的游戏根目录吗? | 无文件才走提取;不要扫描 meta 当 UI |
46
+ | UI_JSON_PARSE | 编码、尾逗号、文件截断、大小 | 修复合法 JSON,保留用户原修改 |
47
+ | UI_RESOURCE_MISSING/PATH | assets 相对路径、大小写、文件是否随项目存在 | 不改为网站路径或复制别的项目图片凑数 |
48
+ | `UI_COMPONENT_MISSING/TYPE` | `component` 相对路径、组件文件是否存在、根 props 覆盖规则 | 先修引用或核对组件注册;不要把组件静默降级成 Panel |
49
+ | UI_DUPLICATE_ID | 同一实例的行为绑定目标 | 修改 ID 同时对照调用方;跨实例不盲目改名 |
50
+ | UI_LENGTH/ENUM | 源布局和目标加载器支持 | 不随意把百分比改成固定像素 |
51
+ | UI_TEMPLATE_CONTEXT | 调用 props、默认值、实际加载模式 | 编辑器默认值显示正常不代表 Lua 正常 |
52
+ | UI_PREVIEW_TYPE | 组件注册、模板、Slot 和引擎版本 | 预览不支持与引擎不支持分开报告 |
53
+ | UI_EDITOR_REPEAT | 是否已有运行时循环实例化 | 保留 Lua 数据驱动,不把预览列表当引擎能力 |
54
+ | 无报错但画面空 | 根尺寸、祖先显隐/裁切、opacity、动态内容 | 先判断预期状态,再修确定的错误 |
55
+ | `UI_PROJECT_CONFIG_MISSING/PARSE` | 项目根目录、`.project/project.json` 编码和 JSON 结构 | 补齐或修复配置后重跑;未确认方向时不要交付视觉结论 |
56
+ | `UI_DESIGN_ORIENTATION` | 页面根 `width/height` 与 `screen_orientation` | 回到源布局确认设计尺寸;不要只交换宽高掩盖坐标语义 |
57
+ | `UI_MANIFEST_STALE/MISSING_FILE/PARSE` | 导出 manifest 与 `assets/ui` 实际文件 | 先确认是否为旧导出或有意未发布;不要为了消除警告删除模板 |
58
+ | 页面缺部分控件 | 工厂默认值、初始化后的 AddChild/SetStyle | 补遗漏的静态结构,不展开业务运行态 |
59
+ | 文字换行/大小差异 | 字体资源、主题、字号单位、父容器约束 | 保留字体度量差异说明,需运行时对照 |
60
+ | 改 JSON 不影响游戏 | 活动入口是否仍创建旧 Lua 树 | 明确尚未接入,取得授权后迁移 |
61
+ | 图片索引存在但画布裂图 | 图片解码、格式、预览控制台 | 归类资源解码或编辑器问题,不伪造路径 |
62
+
63
+ ## 最小交付报告
64
+
65
+ ```text
66
+ 模式:仅提取 / 检查 / 诊断 / 已接入
67
+ 活动页面及输出:源文件 -> UI 文件(含未覆盖的页面及原因)
68
+ 静态检查:检查 N 文件,E 错误,W 警告;附命令及原始报告位置
69
+ 警告处理:每类问题的判断,不能直接删除警告
70
+ 编辑器:实际打开哪些页面/模板,检查哪些状态
71
+ 引擎:实际运行哪些状态;未运行明确说明
72
+ 仍留 Lua:行为、动画、动态节点和自绘
73
+ 下一步:需要用户操作或尚未验证的范围
74
+ ```
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { checkDocument } = require("./ui-json-check.cjs");
6
+
7
+ function inside(root, file) {
8
+ const rel = path.relative(root, file);
9
+ return rel === "" || (!rel.startsWith(".." + path.sep) && rel !== ".." && !path.isAbsolute(rel));
10
+ }
11
+ function readProjectConfig(root) {
12
+ const source = ".project/project.json";
13
+ const file = path.join(root, source);
14
+ try {
15
+ const raw = JSON.parse(fs.readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
16
+ const publish = raw && typeof raw.taptap_publish === "object" ? raw.taptap_publish : raw;
17
+ const orientation = publish && (publish.screen_orientation || publish.orientation);
18
+ return { orientation: orientation === "landscape" || orientation === "portrait" ? orientation : null, source };
19
+ } catch (error) {
20
+ if (error.code === "ENOENT") return { orientation: null, source, missing: true };
21
+ return { orientation: null, source, error: error.message };
22
+ }
23
+ }
24
+ function checkExportManifest(root, assets, files, diagnostics) {
25
+ const relative = "assets/ui/ui-export-manifest.ui.json";
26
+ const file = path.join(assets, "ui", "ui-export-manifest.ui.json");
27
+ if (!fs.existsSync(file)) return;
28
+ let manifest;
29
+ try {
30
+ manifest = JSON.parse(fs.readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
31
+ } catch (error) {
32
+ diagnostics.push({ code: "UI_MANIFEST_PARSE", severity: "error", file: relative, pointer: "",
33
+ message: error.message });
34
+ return;
35
+ }
36
+ const categories = ["pages", "components", "templates"];
37
+ const actual = new Set(files.map(item => path.relative(assets, item).split(path.sep).join("/")));
38
+ categories.forEach(kind => {
39
+ const listed = Array.isArray(manifest[kind]) ? manifest[kind].filter(item => typeof item === "string") : [];
40
+ const listedSet = new Set(listed);
41
+ const actualFiles = [...actual].filter(item => item.startsWith("ui/" + kind + "/"));
42
+ const missing = listed.filter(item => !actual.has(item));
43
+ const unlisted = actualFiles.filter(item => !listedSet.has(item));
44
+ if (missing.length) diagnostics.push({ code: "UI_MANIFEST_MISSING_FILE", severity: "error",
45
+ file: relative, pointer: "/" + kind, message: "导出清单登记了不存在的文件:" + missing.join(", ") });
46
+ if (unlisted.length) diagnostics.push({ code: "UI_MANIFEST_STALE", severity: "warning",
47
+ file: relative, pointer: "/" + kind, message: "目录中有 " + unlisted.length +
48
+ " 个 " + kind + " 文件未登记,清单可能来自旧导出:" + unlisted.slice(0, 5).join(", ") +
49
+ (unlisted.length > 5 ? " …" : "") });
50
+ });
51
+ }
52
+ function main(argv) {
53
+ if (argv.includes("--help")) {
54
+ console.log("node check-ui.cjs --project <game-root> [--file assets/ui/page.ui.json] [--format json|text]");
55
+ return 0;
56
+ }
57
+ const args = {};
58
+ for (let i = 0; i < argv.length; i += 2) {
59
+ if (!["--project", "--file", "--format"].includes(argv[i]) || !argv[i + 1] || argv[i + 1].startsWith("--")) {
60
+ throw new Error("Unknown or incomplete argument: " + argv[i]);
61
+ }
62
+ args[argv[i]] = argv[i + 1];
63
+ }
64
+ if (!args["--project"]) throw new Error("--project is required");
65
+ const format = args["--format"] || "text";
66
+ if (!["json", "text"].includes(format)) throw new Error("--format must be json or text");
67
+ const root = fs.realpathSync(args["--project"]);
68
+ const assets = fs.realpathSync(path.join(root, "assets"));
69
+ if (!inside(root, assets)) throw new Error("assets must be inside the project");
70
+ const files = [], scanDiagnostics = [];
71
+ function scan(dir) {
72
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
73
+ if ([".git", "node_modules"].includes(entry.name)) continue;
74
+ const file = path.join(dir, entry.name);
75
+ if (entry.isSymbolicLink()) {
76
+ scanDiagnostics.push({ code: "UI_SCAN_SYMLINK", severity: "warning",
77
+ file: path.relative(root, file), pointer: "", message: "未递归扫描符号链接,请检查其目标。" });
78
+ } else if (entry.isDirectory()) scan(file);
79
+ else if (/\.ui\.json$/i.test(entry.name)) files.push(file);
80
+ }
81
+ }
82
+ if (args["--file"]) {
83
+ const target = path.resolve(root, args["--file"]);
84
+ if (!inside(assets, target) || !/\.ui\.json$/i.test(target)) throw new Error("--file must be a .ui.json inside assets");
85
+ const real = fs.realpathSync(target);
86
+ if (!inside(assets, real)) throw new Error("--file symlink escapes assets");
87
+ files.push(real);
88
+ } else scan(assets);
89
+ const projectConfig = readProjectConfig(root);
90
+ const report = { version: 1, files: files.length, errors: 0, warnings: 0,
91
+ projectConfig,
92
+ diagnostics: scanDiagnostics, skipped: [] };
93
+ checkExportManifest(root, assets, files, report.diagnostics);
94
+ if (projectConfig.error) report.diagnostics.push({ code: "UI_PROJECT_CONFIG_PARSE", severity: "error",
95
+ file: projectConfig.source, pointer: "", message: projectConfig.error });
96
+ else if (projectConfig.missing) report.diagnostics.push({ code: "UI_PROJECT_CONFIG_MISSING", severity: "warning",
97
+ file: projectConfig.source, pointer: "", message: "未找到项目屏幕方向配置;页面预览可能使用错误的横竖屏设备。" });
98
+ const skipped = new Set();
99
+ function resourceExists(ref) {
100
+ const file = path.resolve(assets, ref);
101
+ if (!inside(assets, file)) return false;
102
+ try {
103
+ const real = fs.realpathSync(file);
104
+ if (!inside(assets, real)) return false;
105
+ fs.accessSync(real, fs.constants.R_OK);
106
+ return fs.statSync(real).isFile();
107
+ } catch (_) { return false; }
108
+ }
109
+ for (const file of files) {
110
+ const relative = path.relative(root, file).split(path.sep).join("/");
111
+ let tree;
112
+ try {
113
+ if (fs.statSync(file).size > 4 * 1024 * 1024) throw new Error("File exceeds 4 MiB");
114
+ tree = JSON.parse(fs.readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
115
+ } catch (error) {
116
+ report.diagnostics.push({ code: "UI_JSON_PARSE", severity: "error",
117
+ file: relative, pointer: "", message: error.message });
118
+ continue;
119
+ }
120
+ const result = checkDocument({ file: relative, tree, resourceExists });
121
+ report.diagnostics.push(...result.diagnostics);
122
+ if (projectConfig.orientation && /assets\/ui\/pages\//i.test(relative) &&
123
+ typeof tree.width === "number" && typeof tree.height === "number") {
124
+ const landscape = tree.width >= tree.height;
125
+ if ((projectConfig.orientation === "landscape") !== landscape) {
126
+ report.diagnostics.push({ code: "UI_DESIGN_ORIENTATION", severity: "error", file: relative,
127
+ pointer: "/width", message: "页面根尺寸 " + tree.width + "×" + tree.height +
128
+ " 与项目配置的 " + projectConfig.orientation + " 方向不一致。" });
129
+ }
130
+ }
131
+ result.skipped.forEach(item => skipped.add(item));
132
+ }
133
+ if (!files.length) report.diagnostics.push({ code: "UI_NO_FILES", severity: "error",
134
+ file: "assets", pointer: "", message: "未找到 .ui.json;先确认项目根目录,或使用 lua-ui-to-json 提取。" });
135
+ report.errors = report.diagnostics.filter(d => d.severity === "error").length;
136
+ report.warnings = report.diagnostics.filter(d => d.severity === "warning").length;
137
+ report.skipped = [...skipped];
138
+ if (format === "json") console.log(JSON.stringify(report, null, 2));
139
+ else {
140
+ console.log(`${report.files} files, ${report.errors} errors, ${report.warnings} warnings`);
141
+ for (const d of report.diagnostics) console.log(`[${d.severity}] ${d.code} ${d.file}${d.pointer}: ${d.message}`);
142
+ console.log("Not verified: " + (report.skipped.join(", ") || "No documents checked"));
143
+ console.log("Static checks do not prove runtime or visual equivalence.");
144
+ }
145
+ return report.errors ? 1 : 0;
146
+ }
147
+ try { process.exitCode = main(process.argv.slice(2)); }
148
+ catch (error) { console.error(error.message); process.exitCode = 2; }
@@ -0,0 +1,134 @@
1
+ (function (root) {
2
+ "use strict";
3
+ var previewTypes = new Set(["Panel", "Label", "Button"]);
4
+ var lengths = ["width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight",
5
+ "left", "right", "top", "bottom", "padding", "paddingLeft", "paddingRight",
6
+ "paddingTop", "paddingBottom", "paddingHorizontal", "paddingVertical",
7
+ "margin", "marginLeft", "marginRight", "marginTop", "marginBottom",
8
+ "marginHorizontal", "marginVertical", "gap", "flexBasis"];
9
+ var enums = {
10
+ position: ["relative", "absolute"],
11
+ backgroundFit: ["fill", "contain", "cover", "sliced"],
12
+ overflow: ["visible", "hidden", "scroll"],
13
+ flexDirection: ["row", "column", "row-reverse", "column-reverse"],
14
+ textAlign: ["left", "center", "right"],
15
+ verticalAlign: ["top", "middle", "bottom"],
16
+ };
17
+ function token(value) { return typeof value === "string" && value.charAt(0) === "$"; }
18
+ function length(value) {
19
+ return typeof value === "number" && Number.isFinite(value) ||
20
+ typeof value === "string" && /^(auto|-?\d+(?:\.\d+)?%?)$/.test(value);
21
+ }
22
+ function checkDocument(options) {
23
+ var diagnostics = [], ids = new Map(), count = 0, limited = false, parameterized = false;
24
+ function issue(code, severity, pointer, message) {
25
+ diagnostics.push({ code: code, severity: severity, file: options.file || "",
26
+ pointer: pointer, message: message });
27
+ }
28
+ function resource(value, pointer) {
29
+ if (value == null || value === "" || token(value)) return;
30
+ if (typeof value !== "string") {
31
+ issue("UI_RESOURCE_TYPE", "error", pointer, "资源引用必须是字符串。"); return;
32
+ }
33
+ if (/^uuid:\/\//.test(value)) {
34
+ issue("UI_RESOURCE_UNRESOLVED", "warning", pointer, "UUID 引用需要引擎资源索引,尚未验证。"); return;
35
+ }
36
+ if (/^(\/|\\|[a-z]+:)/i.test(value) || value.includes("\\") || value.split("/").includes("..")) {
37
+ issue("UI_RESOURCE_PATH", "error", pointer, "使用 assets 内相对资源路径,不允许绝对路径或越界引用。"); return;
38
+ }
39
+ if (value.startsWith("assets/")) {
40
+ issue("UI_RESOURCE_PREFIX", "warning", pointer, "游戏资源通常相对 assets 根,请核对是否多写了 assets/。");
41
+ }
42
+ if (options.resourceExists && !options.resourceExists(value)) {
43
+ issue("UI_RESOURCE_MISSING", "error", pointer, "找不到或无法读取资源:" + value);
44
+ }
45
+ }
46
+ function visit(node, pointer, depth) {
47
+ if (++count > 10000 || depth > 128) {
48
+ if (!limited) issue("UI_LIMIT", "error", pointer, "节点数量或深度超过检查上限。");
49
+ limited = true; return;
50
+ }
51
+ if (!node || typeof node !== "object" || Array.isArray(node)) {
52
+ issue("UI_NODE", "error", pointer, "节点必须是对象。"); return;
53
+ }
54
+ if (typeof node.type !== "string" || !node.type.trim()) {
55
+ issue("UI_NODE_TYPE", "error", pointer + "/type", "每个节点都需要非空 type。");
56
+ } else if (!previewTypes.has(node.type)) {
57
+ issue("UI_PREVIEW_TYPE", "warning", pointer + "/type",
58
+ "此类型需要核对引擎注册及编辑器预览支持:" + node.type + ";不应自动改成 Panel。");
59
+ }
60
+ if (node.id != null && !token(node.id)) {
61
+ if (typeof node.id !== "string" || !node.id.trim()) {
62
+ issue("UI_ID_TYPE", "error", pointer + "/id", "id 必须是非空字符串。");
63
+ } else if (ids.has(node.id)) {
64
+ issue("UI_DUPLICATE_ID", "error", pointer + "/id", "同一文档的 id 重复:" + node.id +
65
+ ";首次出现于 " + ids.get(node.id));
66
+ } else ids.set(node.id, pointer + "/id");
67
+ }
68
+ Object.keys(node).forEach(function (key) {
69
+ var value = node[key], at = pointer + "/" + key.replace(/~/g, "~0").replace(/\//g, "~1");
70
+ if (key.charAt(0) === "_") issue("UI_INTERNAL_FIELD", "error", at, "导出含编辑器内部字段。");
71
+ if (/^on[A-Z]/.test(key)) issue("UI_CALLBACK", "error", at, "回调保留在 Lua 中,不写入 UI JSON。");
72
+ if (token(value)) { parameterized = true; return; }
73
+ if (typeof value === "number" && !Number.isFinite(value)) {
74
+ issue("UI_NUMBER", "error", at, "数值必须有限。"); return;
75
+ }
76
+ if (lengths.includes(key) && !length(value)) {
77
+ issue("UI_LENGTH", "error", at, "尺寸/位置必须是有限数值、百分比或受支持的 auto。");
78
+ }
79
+ if (["width", "height"].includes(key) && typeof value === "number" && value <= 0) {
80
+ issue("UI_ZERO_SIZE", "warning", at, "非正尺寸可能不可见;动态尺寸需在运行时确认。");
81
+ }
82
+ if (enums[key] && !enums[key].includes(value)) {
83
+ issue("UI_ENUM", "error", at, "不支持的枚举值:" + String(value));
84
+ }
85
+ if (["visible", "disabled", "locked"].includes(key) && typeof value !== "boolean") {
86
+ issue("UI_BOOLEAN", "error", at, "此字段必须是布尔值。");
87
+ }
88
+ if (key === "opacity" && (typeof value !== "number" || value < 0 || value > 1)) {
89
+ issue("UI_OPACITY", "error", at, "透明度应为 0 到 1 的数值。");
90
+ }
91
+ if (key === "backgroundSlice" && (!Array.isArray(value) || value.length !== 4 ||
92
+ value.some(function (n) { return typeof n !== "number" || !Number.isFinite(n) || n < 0; }))) {
93
+ issue("UI_SLICE", "error", at, "九宫格切边使用四个非负数:[上, 右, 下, 左]。");
94
+ }
95
+ });
96
+ resource(node.backgroundImage, pointer + "/backgroundImage");
97
+ if (node.component != null) {
98
+ if (token(node.component)) {
99
+ parameterized = true;
100
+ } else if (typeof node.component !== "string" || !node.component.trim()) {
101
+ issue("UI_COMPONENT_TYPE", "error", pointer + "/component", "组件引用必须是非空字符串。");
102
+ } else if (options.resourceExists && !options.resourceExists(node.component)) {
103
+ issue("UI_COMPONENT_MISSING", "error", pointer + "/component", "找不到组件文件:" + node.component);
104
+ }
105
+ }
106
+ if (node.$repeat) {
107
+ issue("UI_EDITOR_REPEAT", "warning", pointer + "/$repeat",
108
+ "$repeat 是编辑器扩展,不证明引擎会生成列表;运行时应核对模板实例化。");
109
+ resource(node.$repeat.template, pointer + "/$repeat/template");
110
+ }
111
+ if (node.children != null && !Array.isArray(node.children)) {
112
+ issue("UI_CHILDREN", "error", pointer + "/children", "children 必须是数组。");
113
+ } else (node.children || []).some(function (child, i) {
114
+ visit(child, pointer + "/children/" + i, depth + 1);
115
+ return limited;
116
+ });
117
+ }
118
+ visit(options.tree, "", 0);
119
+ if (parameterized) issue("UI_TEMPLATE_CONTEXT", "warning", "",
120
+ "含模板参数。请验证调用方 props、默认值及模板加载模式;此检查没有展开模板。");
121
+ return {
122
+ version: 1, nodes: count,
123
+ errors: diagnostics.filter(function (d) { return d.severity === "error"; }).length,
124
+ warnings: diagnostics.filter(function (d) { return d.severity === "warning"; }).length,
125
+ diagnostics: diagnostics,
126
+ skipped: ["runtime-equivalence", "layout-and-fonts", "component-expansion", "lua-bindings",
127
+ "image-decoding", "meta-and-font-resources", "source-coverage", "duplicate-json-keys"]
128
+ .concat(options.resourceExists ? [] : ["resource-existence"]),
129
+ };
130
+ }
131
+ var api = { checkDocument: checkDocument };
132
+ if (typeof module !== "undefined" && module.exports) module.exports = api;
133
+ else root.UrhoxUICheck = api;
134
+ })(typeof window !== "undefined" ? window : globalThis);
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: maker-ui-workflow
3
+ description: 'TapTap Maker 游戏 UI 设计稿拆解、按钮/图标/背景切图、已有素材组装 UI.json,以及在控制台 UI 编辑器中对照还原。适用于‘照这张图做游戏 UI’‘拆这个界面’‘把切图拼回 UI’‘生成 UI.json’‘和设计稿对比调整’;按用户目的进入相应阶段,普通单个 UI 属性修改不重跑拆图。'
4
+ ---
5
+
6
+ # Maker UI 设计稿拆解与还原
7
+
8
+ Maker 是流程入口;自由画布展示分析与切图,脚本按显式布局组装,控制台 UI 编辑器负责对照和调整。
9
+ 本 Skill 不新增 MCP tool,不执行游戏构建、提交或更换游戏加载入口。
10
+
11
+ ## 从用户需要的阶段开始
12
+
13
+ - 有设计稿,要做成可编辑 UI:识别布局 → 分层切图 → 资源入项目 → 组装 → 编辑器对照。
14
+ - 只要按钮、图标、背景等切图:在资源导出结束,不自动扩展为整屏 UI 重建。
15
+ - 已有切图,要拼回界面:先找布局清单和素材绑定;缺失时对照原稿补录并说明来源,不能猜配相似素材。
16
+ - 已有 UI.json,要调位置或对照:直接打开编辑器,不重新生图或覆盖现有文档。
17
+ - 只说“做个背包/商店界面”:从上下文找原稿及风格要求;缺少会改变结果的设计意图时再询问。
18
+
19
+ ## 准备
20
+
21
+ 读取 Maker 状态并绑定明确的项目目录;沿用对话中已选项目。控制台打开、画布 CLI 和付费生成遵循
22
+ 同包 taptap-maker-local 与工具实际 schema。保持同一 target-dir,不凭全局当前项目推断。
23
+ 打开控制台后用 canvas pages / snapshot 读取当前页面、画布和 revision;通过页面桥接操作和保存,
24
+ 不能直接覆写打开中的画布文件。命令参数先读当前 CLI 的 canvas 帮助。
25
+
26
+ 有完整 UI 拆解用户模板时优先复用,在新画布替换原稿;没有时用现有图片和资源卡建立同样的流程。
27
+ 旧示例结果只供参考。换原稿后重做识别、布局、素材绑定与网格核对,不能只换首图就沿用旧结果。
28
+
29
+ ## 执行
30
+
31
+ 布局字段、坐标依据、冗余资源和双重对位契约见 [workflow.md](references/workflow.md)。
32
+
33
+ 1. 在原设计稿上记录稳定元素 ID、绝对像素位置、类型、父级及同级绘制顺序。相似按钮是不同实例,
34
+ 可共用同一素材;普通文字保留为 Label,美术字独立提取。先保存布局记录,再生成标框图和切图。
35
+ 2. 延续已验证的分层流程:去文字稿;分别标注按钮、图标;美术字仍参考原稿;背景在去文字后再去除前景。
36
+ 提取提示词分开写“参考与目标”“保留”“移除”“输出”。按钮默认/按下态分别生成、统一画布与锚点,
37
+ 图标与按钮底板分离;美术字只保留字形及字效,不带后方底框。
38
+ 3. 查看真实结果。透明处理、必要的重新排版要明确使用已有能力或可重复的本地处理,不能把人工修图冒充模板自动能力。
39
+ 用图集预览核对完整边界后确认,再导出独立 PNG;未知远端任务只查原任务,不自动重提。
40
+ 4. 正式素材按 assets/ui/<界面>/images/ 归档;备用图同目录 reserve/ 保留但不入布局。
41
+ 过程文件、layout.json、corrections.json 留在项目 .maker/ui-workflows/<界面>/,不混入正式 PNG。
42
+ 明确绑定资源 ID 与元素 ID、默认/按下态,记录图片尺寸与哈希;显式调用 generate_resource_meta。
43
+ 5. 使用本 Skill 的 scripts/assemble-ui.mjs 组装到新的目录,例如 assets/ui/<界面>/assembled-v1/。
44
+ 输出目录必须不存在,保护手工编辑;多轮用新目录。脚本验证绑定、哈希、尺寸与层级,不做视觉自动匹配。
45
+ 6. 在控制台「UI 编辑器」打开 assembled.ui.json,同名 assembled.reference.png 会自动作为设计稿。
46
+ 左右检查完整性、层级、资源选择,再重叠检查位置/尺寸;必要时按同一元素 ID 记录纠偏重新组装。
47
+ 用户已经手工编辑的文件继续在编辑器调整,不能无条件重新生成覆盖。
48
+
49
+ ## 组装和打开
50
+
51
+ 在已安装的 Skill 目录运行(正式分发的脚本已打包依赖,无需 npm install):
52
+
53
+ node scripts/assemble-ui.mjs <项目绝对路径> <layout.json> <新输出目录> [corrections.json]
54
+
55
+ 输出 assembled.ui.json、assembled.reference.png、assembly-map.json。将新资源纳入 meta 生成后,
56
+ 用当前分发的 CLI 执行 console open --target-dir <项目> --no-open --json,取得真实地址;
57
+ 保留其项目参数,追加 &page=ui-editor&ui=<URL编码的 assets/ 相对 UI 路径>,即可直达文档。
58
+ 控制台已打开时也可进入「UI 编辑器」并刷新文件列表。不要启动独立 UrhoxUIEditor 或 Python 服务。
59
+
60
+ ## 完成检查
61
+
62
+ 检查正式文件和素材引用,查看真实左右/重叠效果,并确认保存后重新打开仍正确。
63
+ 保留冗余资源,报告缺件、形变、未验证项和实际修整;静态检查通过不代表像素级一致。
64
+ 交付目标是可在编辑器继续编辑的静态 UI;点击逻辑、动态列表和游戏运行时接入只有用户要求才做。
@@ -0,0 +1,85 @@
1
+ # Maker UI 设计稿到游戏素材工作流
2
+
3
+ ## 当前流程:保留位置、冗余切图、两次对位
4
+
5
+ 识别阶段先记录原设计稿中的元素身份和位置,再开始生图式切图。红框图只是可视化,
6
+ 不能替代机器可读的布局清单。所有坐标采用原始设计稿像素,不从生成图集的位置倒推。
7
+ 本流程复用现有画布图片和资源卡、UI 编辑器对照功能,不新增画布按钮或生成任务系统。
8
+
9
+ 1. **识别并保存布局**:原图尺寸、文件哈希,以及每个元素的稳定 ID、矩形、父元素、类型和
10
+ 同级绘制顺序写入布局 JSON。普通文字也保留为 Label;美术字记录为图片元素。
11
+ 图中相似元素逐个编号,素材相同不代表元素相同。修正框的位置时保留 ID,不因排序重新编号。
12
+ 2. **生成并绑定素材**:生成任务或图集槽位与元素/素材编号显式对应。图集网格坐标只用于裁图。
13
+ 导出后记录 PNG 的路径、哈希和尺寸;同一素材可以绑定多个元素,默认/按下状态绑定同一按钮。
14
+ 生图结果顺序仍需核对,不能只凭模型承诺或文件名猜测对应关系。
15
+ 3. **保留冗余**:允许同一对象的多种候选、备用状态和多切的底框,作为 reserve 素材保留。
16
+ 不因为没用于本次布局就删除,不把备用素材自动变成 UI 节点。原稿漏项仍应补识别,
17
+ 不能把“多切了素材”当成“原稿内容完整”。选择备用素材时显式改变绑定。
18
+ 4. **第一次组装**:程序按布局记录及绑定生成 UI JSON;父子相对坐标由全图坐标换算,
19
+ 同级层级按 elements 内的先后顺序,背景、图标、文字各自保留。缺少绑定则停止,禁止视觉猜配。
20
+ 5. **第二次对照纠偏**:Agent 在 UI 编辑器中打开组装结果,查看左右/重叠截图,对照同一份原稿,
21
+ 按已有 ID 检查偏移、尺寸、层级、遗漏和状态对齐。几何偏差写入独立 corrections JSON,
22
+ 保留 before、after、reason 和截图证据路径;重新组装并再次看图。层级或素材绑定错误需修正
23
+ 布局清单,再重新复核,不能用移动坐标掩盖。复核过程不重新匹配相似对象、不删除冗余资源。
24
+
25
+ “第二次对照”目前由 Agent 看图完成,工具不自动进行图像识别或判断视觉通过。
26
+ 纠偏记录绑定完整布局哈希、设计稿哈希及调整前坐标,旧版本记录不能套用到新布局。
27
+ 没有纠偏记录的输出明确为待视觉复核;有记录只表示已记录复核,不表示像素级自动验收通过。
28
+ 历史结果回填位置时,provenance 使用 reconstruction-backfill,不能把它说成切图时已记录。
29
+ 新设计稿在识别时记录则使用 recognition。
30
+
31
+ ### 布局文件与组装工具
32
+
33
+ 组装脚本 <本 Skill 目录>/scripts/assemble-ui.mjs 不调用付费模型、不写 meta、不修改已打开画布。
34
+ 随 Maker 的 npm 包和客户端插件分发;使用安装位置下的 Skill 脚本,不依赖开发仓库。
35
+ 布局文件放项目开发资源目录,UI 和正式 PNG 放 assets。命令输出目录必须不存在,避免覆盖手工编辑。
36
+
37
+ node <本 Skill 目录>/scripts/assemble-ui.mjs <项目根目录> <layout.json> <新输出目录> [corrections.json]
38
+
39
+ 输出 assembled.ui.json、assembled.reference.png 和 assembly-map.json。后者记录最终位置、
40
+ 原始位置、素材引用次数与备用清单。资源仍引用原项目 assets,不重复复制全部切图。
41
+ 把 UI 导入项目后显式调用 generate_resource_meta,再用 Maker 控制台「UI 编辑器」检查和对照。
42
+
43
+ 布局 JSON 的 version=1,coordinateSpace=design-pixels,rectBasis=asset-canvas。
44
+ design 包含 path(assets/ 相对路径)、sha256、width、height;assets 列表的每项具有这些
45
+ 图片字段及 id、role(bound 或 reserve)。素材可选 contentBounds 记录透明通道内容边界,
46
+ 只用于复核,不隐式改变放置坐标。elements 中每项包含:
47
+
48
+ - id、parentId(唯一根为 null)、type(Panel/Button/Label/Image)。
49
+ - render 区分 container、image、text;image 在切图绑定完成前不能组装,防止漏图静默变为空面板。
50
+ - rect=[x,y,width,height],全部是设计稿绝对像素坐标;根矩形与设计稿一致。
51
+ - props 存储颜色、文本等编辑器属性,不允许偷偷覆盖位置、尺寸、图片引用或添加整体变换。
52
+ - assetId 可绑定默认图片;Button 的 pressedAssetId 可绑定按下图片;Label 无需切图。
53
+
54
+ rect 表示整个 PNG 画布的放置范围,不能混用按钮主体边界与含阴影/透明边距的画布边界。
55
+ 先裁透明留白或统一状态画布,再记录资源尺寸和哈希;默认/按下态要检查主体锚点是否一致。
56
+ 切图若发生形变,坐标记录不会自动修复形变,应选择备用或在编辑器调整,不宣称完全无误差。
57
+ 当前工具只组装固定坐标的静态 UI,不处理旋转/缩放节点、动态列表、百分比和响应式布局。
58
+
59
+ 纠偏 JSON 的 version=1,layoutSha256 为解析后 layout 对象 JSON.stringify 的 SHA-256;
60
+ review 包含 designSha256 与 evidence(实际对照截图路径),adjustments 每项为
61
+ {id,before:[x,y,w,h],after:[x,y,w,h],reason}。没有偏差时可以记录空 adjustments。
62
+ 移动父节点时未单独纠偏的子节点一起移动;对子节点显式纠偏使用新的全图坐标。
63
+ 修改父节点宽高不会隐式缩放子节点。原始布局不被覆写,纠偏只作用于本次输出。
64
+
65
+ ## 复用已保存的 UI 拆解模板
66
+
67
+ 在画布的「添加模板 → 我的模板」中添加已保存流程,再替换实例的原设计稿。模板保存卡片、
68
+ 连线、提示词和示例结果,但不会把旧设计稿的元素清单、标框、网格和布局坐标自动适配到新图。
69
+ 旧结果只供参考,不能在替换首图后直接当作新设计稿的交付物。
70
+
71
+ 复用时由 Agent 跟随以下步骤,继续使用现有画布操作,不新增自动工作流引擎:
72
+
73
+ 1. 在新原稿上重新记录元素 ID、位置和状态。重复的奖励格保留不同实例 ID,可以共用素材;
74
+ 开关的开/关状态与按下反馈分别处理,不能仅把关闭底图当成开启按钮的按下态。
75
+ 2. 更新去文字、按钮标注、图标标注、背景准备和美术字的输入及清单。美术字识别仍引用原稿,
76
+ 不能只看已经去掉文字的图片。每条提取提示词分清保留、移除和输出要求。
77
+ 3. 查看真实生成结果,只返修缺件、图层混入或形状错误的组件。纯色底先处理为透明,再展示
78
+ 最终素材卡。清理几乎不可见的孤立像素后再确定透明边界,避免它们撑大尺寸、使主体显示偏小。
79
+ 4. 不假设模型严格遵守规则网格。主体跨格时先按完整边界重新排版,再查看网格预览、确认和导出。
80
+ 默认/按下态统一图片画布与锚点,备用资源保留但不自动放入 UI。
81
+ 5. 导出 PNG,按新布局记录组装 UI JSON,显式生成 meta,并在 UI 编辑器中做左右和重叠对照。
82
+ 保存画布后重新打开,确认展示的是新结果、资源可下载且文件引用有效。
83
+
84
+ 目前可以复用流程结构,再由 Agent 分阶段接续与复核;不能承诺只换首图、无人检查就自动生成
85
+ 全部可用素材和 UI。Agent 的透明处理、重新排版及视觉纠偏也不能表述成模板已有的一键能力。