dsh-game-material-master 0.10.2 → 0.11.1
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.
- package/README.en.md +27 -3
- package/README.md +23 -3
- package/lib/chroma.js +74 -15
- package/lib/client.js +535 -156
- package/lib/config.js +6 -3
- package/lib/customimage.js +43 -0
- package/lib/directions.js +69 -8
- package/lib/imagedraw.js +185 -0
- package/lib/imagegen.js +17 -5
- package/lib/imageprovider.js +7 -2
- package/lib/index.js +128 -19
- package/lib/isocompose.js +26 -17
- package/lib/isodoc.js +153 -4
- package/lib/isoexport.js +14 -2
- package/lib/isogen.js +413 -22
- package/lib/isorender.js +215 -0
- package/lib/keycolor.js +251 -0
- package/lib/links.js +1 -1
- package/lib/mapdoc.js +162 -3
- package/lib/mapexport.js +14 -2
- package/lib/mapgen.js +432 -29
- package/lib/maprender.js +169 -0
- package/lib/maptiles.js +7 -2
- package/lib/pipeline.js +10 -3
- package/lib/riggen.js +4 -4
- package/lib/seqgen.js +7 -0
- package/lib/store.js +23 -12
- package/lib/toolguides.js +63 -18
- package/lib/tools.js +35 -7
- package/lib/wire.js +103 -13
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -131,6 +131,11 @@ window.__ModuleLoader__.load({
|
|
|
131
131
|
"刷新列表": "Refresh list",
|
|
132
132
|
"重命名": "Rename",
|
|
133
133
|
"删除项目": "Delete project",
|
|
134
|
+
"复制 ID": "Copy ID",
|
|
135
|
+
"复制项目 ID": "Copy project ID",
|
|
136
|
+
"复制项目 ID:{n0}": "Copy project ID: {n0}",
|
|
137
|
+
"已复制": "Copied",
|
|
138
|
+
"复制失败": "Copy failed",
|
|
134
139
|
"新建项目": "New project",
|
|
135
140
|
"实验性": "Experimental",
|
|
136
141
|
"项目({n0})": "Projects ({n0})",
|
|
@@ -300,16 +305,12 @@ window.__ModuleLoader__.load({
|
|
|
300
305
|
"收起选帧": "Hide frame picker",
|
|
301
306
|
"调整选帧": "Adjust frame pick",
|
|
302
307
|
"手动选帧": "Pick frames manually",
|
|
303
|
-
"
|
|
308
|
+
"正在抠背景并合成整图…": "Keying the background and composing sheet…",
|
|
304
309
|
"抠像在这里会**再跑一次**:第 3 步那次抠的是每个方向的预览带(顺便把整图合出来),这里重抠是为了让下面这些参数改完立刻生效——两次读的是同一份帧缓存(raw.bin)、同一套参数,所以结果一致。": "Keying runs **one more time** here: step 3 keyed the preview strip for each direction (and composed the sheet along the way), while re-keying here makes the parameters below take effect the moment you change them. Both passes read the same frame cache (raw.bin) with the same settings, so the results always match.",
|
|
305
310
|
"改完参数会自动重新抠像并合成整图,不需要重新抽帧。": "Changing the parameters re-keys and recomposes the sheet automatically, with no need to re-extract frames.",
|
|
306
311
|
"整图单格宽(px)": "Sheet cell width (px)",
|
|
307
312
|
"整图单格高(px)": "Sheet cell height (px)",
|
|
308
313
|
"像素块边长(0/1 = 关闭)": "Pixel block size (0/1 = off)",
|
|
309
|
-
"背景分割容差(0 = 只认绿色)": "Background split tolerance (0 = green only)",
|
|
310
|
-
"抠像下限(绿色优势)": "Key low (green dominance)",
|
|
311
|
-
"抠像上限(绿色优势)": "Key high (green dominance)",
|
|
312
|
-
"去绿溢出 0~1": "Despill green 0~1",
|
|
313
314
|
"边缘收缩(px)": "Edge shrink (px)",
|
|
314
315
|
"自动裁剪填充比例 0.5~1": "Auto-crop fill ratio 0.5~1",
|
|
315
316
|
"底部留白(px)": "Bottom padding (px)",
|
|
@@ -379,7 +380,6 @@ window.__ModuleLoader__.load({
|
|
|
379
380
|
"描述你要生成的图片…": "Describe the image you want to generate…",
|
|
380
381
|
"统一附加提示词(可留空)": "Shared suffix prompt (optional)",
|
|
381
382
|
"生图模型": "Image model",
|
|
382
|
-
"尺寸": "Size",
|
|
383
383
|
"生成张数(1~8)": "Images to generate (1~8)",
|
|
384
384
|
"正在生成 {n0} 张…": "Generating {n0} images…",
|
|
385
385
|
"已开始生成 {n0} 张": "Started generating {n0} images",
|
|
@@ -390,13 +390,13 @@ window.__ModuleLoader__.load({
|
|
|
390
390
|
"把参考图拖到这里": "Drag reference images here",
|
|
391
391
|
"已移除参考图": "Reference image removed",
|
|
392
392
|
"移除": "Remove",
|
|
393
|
-
"③
|
|
393
|
+
"③ 背景抠像": "③ Background keying",
|
|
394
394
|
"开启后每张生成完会自动抠一遍;也可以上传已有图片只做抠像。": "When on, each image is keyed automatically after it is generated; you can also upload existing images to key them only.",
|
|
395
395
|
"不抠像": "No keying",
|
|
396
|
-
"
|
|
396
|
+
"自动抠背景输出 PNG": "Auto-key the background, output PNG",
|
|
397
397
|
"正在抠像…": "Keying…",
|
|
398
398
|
"已开始抠像": "Keying started",
|
|
399
|
-
"
|
|
399
|
+
"正在抠背景…": "Keying the background…",
|
|
400
400
|
"按当前参数重新抠像": "Re-key with current settings",
|
|
401
401
|
"上传一张已有图片,直接抠成透明 PNG": "Upload an existing image to key straight to a transparent PNG",
|
|
402
402
|
"④ 结果({n0} 张)": "④ Results ({n0} images)",
|
|
@@ -1022,7 +1022,6 @@ window.__ModuleLoader__.load({
|
|
|
1022
1022
|
"可通过 · 角色在上面": "Walkable · character drawn on top",
|
|
1023
1023
|
"不可通过": "Blocked",
|
|
1024
1024
|
"可通过 · 物件盖住角色": "Walkable · object covers the character",
|
|
1025
|
-
"抠掉绿幕背景": "Key out the green background",
|
|
1026
1025
|
"名字": "Name",
|
|
1027
1026
|
"{n0} 帧/秒": "{n0} fps",
|
|
1028
1027
|
"格子宽": "Cell width",
|
|
@@ -1085,7 +1084,6 @@ window.__ModuleLoader__.load({
|
|
|
1085
1084
|
"一格只有 {n0}px:任何细节不能小于一格的 1/4(约 {n1}px);比这更细的纹理缩到格子上会糊成色雾。": "One cell is only {n0}px: no detail smaller than 1/4 of a cell (about {n1}px); finer texture turns into color mush at this size.",
|
|
1086
1085
|
"① 先出一张静态首帧图:createImageJob({name}) → saveImageJob({jobId, prompt:<上面的主题 + 画法要求 + 排布>}) → runImageJob({jobId, count:1}) → game_material({action:'wait', id:jobId});然后 getImageJob({jobId}) 取 dir 与 items[0].file,首帧绝对路径 = dir + '/' + file。": "1) First make one static first frame: createImageJob({name}) -> saveImageJob({jobId, prompt:<subject + rendering requirements + layout above>}) -> runImageJob({jobId, count:1}) -> game_material({action:'wait', id:jobId});then getImageJob({jobId}) for dir and items[0].file; absolute first-frame path = dir + '/' + file.",
|
|
1087
1086
|
"② 再让它动起来并抽帧:createSequenceJob({name}) → game_material({action:'upload', module:'sequence', id, kind:'firstFrame', path:<首帧绝对路径>}) → runSequenceVideo({jobId}) → game_material({action:'wait'}) → runSequenceFrames({jobId, count:{n0}}) → game_material({action:'wait'});然后 getSequenceJob({jobId}) 取 dir 与 frames.files,按顺序取前 {n0} 帧的绝对路径 = dir + '/' + file。": "2) Then animate and extract frames: createSequenceJob({name}) -> game_material({action:'upload', module:'sequence', id, kind:'firstFrame', path:<absolute first-frame path>}) -> runSequenceVideo({jobId}) -> game_material({action:'wait'}) -> runSequenceFrames({jobId, count:{n0}}) -> game_material({action:'wait'});then getSequenceJob({jobId}) for dir and frames.files; take the first {n0} absolute paths in order = dir + '/' + file.",
|
|
1088
|
-
"第四步 · 整理并回链:game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], kind:'<ground 或 object>', footprint:<物件时给 {{cols:{n2},rows:{n3}}}>}})": "Step 4 - assemble and post the link: game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<those absolute paths, in order>], kind:'<ground or object>', footprint:<for objects: {{cols:{n2},rows:{n3}}}>}})",
|
|
1089
1087
|
" `kind` 必须和这次实际画的一致;不要传 `auto`。物件必须给 footprint;地面不需要。": " `kind` must match what you actually drew; never pass `auto`. Objects require footprint; ground does not.",
|
|
1090
1088
|
" 把这次调用返回的 openUrl **原样**贴成 Markdown 链接(例如 [回到 45° 地图编辑器](…)):点开就回到项目、素材窗口展开、": " Post the openUrl returned by that call **verbatim** as a Markdown link (for example [Back to the 45° map editor](...)): it returns to the project, opens the assets window and",
|
|
1091
1089
|
"「新增素材」里这张图与用途 / 帧数 / 占格都已经预选好,用户点「确定」才真的导入。": "\"Add asset\" already has the image, use, frame count and footprint preselected; the user clicks \"OK\" to import.",
|
|
@@ -1404,8 +1402,9 @@ window.__ModuleLoader__.load({
|
|
|
1404
1402
|
"留空就用原来的名字": "Leave empty to keep the current name",
|
|
1405
1403
|
"这两项只影响它自己:改完立刻生效,地图上已经画好的格子不用重画。想让它跟「设置」里那条全局速度走,播放速度选第一项。": "These two only affect this asset: changes apply immediately and painted cells do not need to be redrawn. To follow the global speed from Settings, pick the first speed option.",
|
|
1406
1404
|
"这块素材不会动(没有多帧),所以播放速度与循环方式对它没有意义。": "This asset does not animate (it has a single frame), so speed and loop mode have no effect on it.",
|
|
1407
|
-
"点一下改它的名字 / 播放速度 / 循环方式": "Click to change its name, playback speed and
|
|
1408
|
-
"点素材那一行可以改**名字 / 播放速度 /
|
|
1405
|
+
"点一下改它的名字 / 播放速度 / 循环方式 / 整图的通行区域": "Click to change its name, playback speed, loop mode and which cells of a stamp are walkable",
|
|
1406
|
+
"点素材那一行可以改**名字 / 播放速度 / 循环方式 / 整图的通行区域**(这些都不动图块,随时能改)。形态与格子大小在新增时就定下来了 —— 要换只能删掉重新新增。": "Click an asset row to change its **name, playback speed, loop mode and which cells of a stamp are walkable** (none of these touch the tiles, so you can change them any time). The layout and cell size are fixed when the asset is added - to change them you must delete it and add it again.",
|
|
1407
|
+
"改完点「保存」:地图上这张素材的所有整图都会立刻改用新区域,不用重新印一遍。": "Click Save when done: every stamp of this asset already placed on the map switches to the new areas immediately, no need to place them again.",
|
|
1409
1408
|
"哪些格子能走(在图上点格子)": "Which cells are walkable (click cells on the picture)",
|
|
1410
1409
|
"第 {n0} 行第 {n1} 列:不可通过 / 可通过(被人物遮挡)/ 可通过(遮挡人物)": "Row {n0}, column {n1}: blocked / walkable (the character covers it) / walkable (it covers the character)",
|
|
1411
1410
|
"墙 · 不可通过": "Wall - blocked",
|
|
@@ -1423,11 +1422,9 @@ window.__ModuleLoader__.load({
|
|
|
1423
1422
|
"画法要求:**只画物件本体、背景是纯绿幕**(上面整图那段写了)—— 插件会把绿抠成透明,剩下的部分要铺满、不留白边。": "Painting rules: **only the object itself on a pure green background** (see the stamp section above) - the plugin keys the green to transparent; what remains must fill the frame with no white margins.",
|
|
1424
1423
|
" ⚠️ 整图**不要**自己去抠像(别为了抠图再跑一次 image 模块的 keyImageJob):`composeMapAsset` 会先抠绿幕、再按占格切片。生成完直接把原图路径交给它。": " WARNING: for stamps do **not** run keying yourself (do not call the image module's keyImageJob just to cut it out): `composeMapAsset` keys the green screen first and then slices by the cell span. Hand it the generated image paths directly.",
|
|
1425
1424
|
"背景": "Background",
|
|
1426
|
-
"抠掉绿幕背景(只留建筑本体)": "Key out the green screen (keep only the object)",
|
|
1427
1425
|
"整图是「立在格子上的物件」:背景该是透明的,不然地图上会多出一块绿框。AI 生成的图请在提示词里要**纯绿背景**,这里勾上就会自动抠掉;自己导的透明 PNG 也可以勾着(没有绿就什么都不做)。": "A stamp is an object standing on the map: its background should be transparent, otherwise a green rectangle shows up on the map. For AI images, ask for a **pure green background** in the prompt and tick this box to key it out automatically; a transparent PNG of your own can leave it ticked too (with no green there, nothing changes).",
|
|
1428
1426
|
" · 整图(stamp):**一张画占好几格**的多格建筑 / 装饰 —— 雕像 / 壁画 / 喷泉 / 大门 / 摊位 / 地毯这种「一整个物件」;判据是「它比一格大,而且不该被切成小块重复」。": " - Stamp (stamp): a multi-cell building/prop where **one picture covers several cells** - statue / mural / fountain / gate / stall / carpet, i.e. a single object. The test is: it is bigger than one cell and must not be sliced into repeated fragments.",
|
|
1429
1427
|
" 【整图】只画**一整张**完整的画(整张图就是这栋建筑 / 这座雕像本身,**不要**分格、**不要**画成 N×N 的格子拼图、不要裁成小块):": " [Stamp] Draw **one whole picture** (the entire image IS the building/statue; do NOT split it into cells, do NOT draw an NxN tile sheet, do NOT crop it into pieces):",
|
|
1430
|
-
"第四步 · 整理并回链:game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], shape:'<你选的形态:plain|corner16|a2quad|stamp>'}})": "Step 4 - Assemble and post the link: game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<those absolute paths, in order>], shape:'<the shape you chose: plain|corner16|a2quad|stamp>'}})",
|
|
1431
1428
|
" 整图还要多给「占几格」:shape:'stamp', stampCols:{n0}, stampRows:{n1}(每张源图 = 一帧的整张画;区域留给用户在导入时点)。": " Stamps also need the cell span: shape:'stamp', stampCols:{n0}, stampRows:{n1} (each source image = one whole frame; areas are clicked by the user at import).",
|
|
1432
1429
|
"整图(一张画占好几格)": "Stamp (one picture, several cells)",
|
|
1433
1430
|
"多格建筑 / 装饰:雕像、壁画、喷泉、大门、地毯。每张图 = 一整张完整的画(不要分格),插件按「占几格」切成格子;哪些格能走导入时你自己点。": "Multi-cell buildings/props: statues, murals, fountains, gates, carpets. Each image is one whole picture (not split into cells); the plugin slices it by the cell span. You click which cells are walkable at import time.",
|
|
@@ -1832,6 +1829,32 @@ window.__ModuleLoader__.load({
|
|
|
1832
1829
|
"默认模型": "Default model",
|
|
1833
1830
|
"默认输出格式": "Default output format",
|
|
1834
1831
|
"默认采样率": "Default sample rate",
|
|
1832
|
+
"背景分割容差(0 = 只认背景色)": "Background split tolerance (0 = background color only)",
|
|
1833
|
+
"抠像下限(背景色接近度)": "Key low (background closeness)",
|
|
1834
|
+
"抠像上限(背景色接近度)": "Key high (background closeness)",
|
|
1835
|
+
"去溢色 0~1": "Despill 0~1",
|
|
1836
|
+
"绿幕(默认)": "Green screen (default)",
|
|
1837
|
+
"蓝幕": "Blue screen",
|
|
1838
|
+
"品红幕": "Magenta screen",
|
|
1839
|
+
"青幕": "Cyan screen",
|
|
1840
|
+
"黄幕": "Yellow screen",
|
|
1841
|
+
"红幕": "Red screen",
|
|
1842
|
+
"白幕": "White screen",
|
|
1843
|
+
"黑幕": "Black screen",
|
|
1844
|
+
"抠像背景色": "Key background color",
|
|
1845
|
+
"自定义背景色": "Custom background color",
|
|
1846
|
+
"自定义": "Custom",
|
|
1847
|
+
"抠掉背景色(只留建筑本体)": "Key out the background color (keep only the object)",
|
|
1848
|
+
"抠掉背景色": "Key out the background color",
|
|
1849
|
+
"输出尺寸(全局)": "Output size (global)",
|
|
1850
|
+
"输出尺寸已保存": "Output size saved",
|
|
1851
|
+
"所有模块共用;支持 1K / 2K / 4K 或 宽x高(要固定像素就直接填 1024x1024 这种)": "Shared by all modules; accepts 1K / 2K / 4K or width x height",
|
|
1852
|
+
"抠像背景色(全局默认)": "Key background color (global default)",
|
|
1853
|
+
"第四步 · 整理并回链:game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], shape:'<你选的形态:plain|corner16|a2quad|stamp>', keyColor:'{n2}'}})": "Step 4 - Assemble and post the link: game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<those absolute paths, in order>], shape:'<the shape you chose: plain|corner16|a2quad|stamp>', keyColor:'{n2}'}})",
|
|
1854
|
+
" 抠像底色是 {n0}:composeMapAsset 必须带上 keyColor:'{n0}',与提示词里的背景色一致。": " The key color is {n0}: composeMapAsset must pass keyColor:'{n0}' so keying matches the prompt background.",
|
|
1855
|
+
"第四步 · 整理并回链:game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], kind:'<ground 或 object>', footprint:<物件时给 {{cols:{n2},rows:{n3}}}>, keyColor:'{n4}'}})": "Step 4 - assemble and post the link: game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<those absolute paths, in order>], kind:'<ground or object>', footprint:<for objects: {{cols:{n2},rows:{n3}}}>, keyColor:'{n4}'}})",
|
|
1856
|
+
" 抠像底色是 {n0}:composeIsoAsset 必须带上 keyColor:'{n0}',与提示词里的背景色一致。": " The key color is {n0}: composeIsoAsset must pass keyColor:'{n0}' so keying matches the prompt background.",
|
|
1857
|
+
"1K / 2K / 4K 由模型决定像素;要固定尺寸请直接填 宽x高": "1K / 2K / 4K are model-defined pixel sizes; enter width x height to pin exact dimensions",
|
|
1835
1858
|
};
|
|
1836
1859
|
/* i18n-ignore-end */
|
|
1837
1860
|
/**
|
|
@@ -2086,7 +2109,7 @@ window.__ModuleLoader__.load({
|
|
|
2086
2109
|
* 硬编码 8 是老限制,用户要做「一张图铺满整张地图」的城门就完全不够;
|
|
2087
2110
|
* 真正该拦的是「比地图还大」——那个在宿主那边按项目尺寸校验,这里只是把输入框夹住。
|
|
2088
2111
|
*/
|
|
2089
|
-
const STAMP_MIN_CELLS =
|
|
2112
|
+
const STAMP_MIN_CELLS = 1;
|
|
2090
2113
|
/** 没有项目时(新建地图前)先按 64 格给个足够的余量。 */
|
|
2091
2114
|
const STAMP_FALLBACK_MAX = 64;
|
|
2092
2115
|
function stampLimits(mapCols, mapRows) {
|
|
@@ -2127,9 +2150,79 @@ window.__ModuleLoader__.load({
|
|
|
2127
2150
|
function guideFirstLine(topic) {
|
|
2128
2151
|
return T("先读手册:game_material({action:'guide', topic:'{n0}'});下面所有远程方法都通过 game_material({action:'call', method:'<名>', payload:{…}}) 调用,wait/upload 用同工具的对应 action。", { n0: topic });
|
|
2129
2152
|
}
|
|
2153
|
+
/**
|
|
2154
|
+
* 抠像底色:浏览器半区不 import 宿主模块(经典脚本),这里保留一份很小的
|
|
2155
|
+
* 颜色名表/替换逻辑。只用于**拼给模型看的提示词**,真正的颜色解析与
|
|
2156
|
+
* 抠像都在宿主 `keycolor.ts` / `chroma.ts`。
|
|
2157
|
+
*/
|
|
2158
|
+
const KEY_COLOR_NAMES = [
|
|
2159
|
+
{ hex: "#00FF00", zh: "绿幕", zhWord: "绿", en: "green screen", enWord: "green" },
|
|
2160
|
+
{ hex: "#0000FF", zh: "蓝幕", zhWord: "蓝", en: "blue screen", enWord: "blue" },
|
|
2161
|
+
{ hex: "#FF00FF", zh: "品红幕", zhWord: "品红", en: "magenta screen", enWord: "magenta" },
|
|
2162
|
+
{ hex: "#00FFFF", zh: "青幕", zhWord: "青", en: "cyan screen", enWord: "cyan" },
|
|
2163
|
+
{ hex: "#FFFF00", zh: "黄幕", zhWord: "黄", en: "yellow screen", enWord: "yellow" },
|
|
2164
|
+
{ hex: "#FF0000", zh: "红幕", zhWord: "红", en: "red screen", enWord: "red" },
|
|
2165
|
+
{ hex: "#FFFFFF", zh: "白幕", zhWord: "白", en: "white screen", enWord: "white" },
|
|
2166
|
+
{ hex: "#000000", zh: "黑幕", zhWord: "黑", en: "black screen", enWord: "black" }
|
|
2167
|
+
];
|
|
2168
|
+
function normalizeKeyColorHex(value) {
|
|
2169
|
+
const text = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
2170
|
+
if (/^#[0-9a-f]{6}$/u.test(text))
|
|
2171
|
+
return text.toUpperCase();
|
|
2172
|
+
if (/^#[0-9a-f]{3}$/u.test(text)) {
|
|
2173
|
+
const [r, g, b] = text.slice(1).split("");
|
|
2174
|
+
return `#${r}${r}${g}${g}${b}${b}`.toUpperCase();
|
|
2175
|
+
}
|
|
2176
|
+
return "#00FF00";
|
|
2177
|
+
}
|
|
2178
|
+
/** 把内置默认提示词里的「绿幕」换成当前底色;绿色保持原样(逐字兼容旧提示词)。 */
|
|
2179
|
+
function applyKeyColorText(text, value) {
|
|
2180
|
+
const color = normalizeKeyColorHex(value);
|
|
2181
|
+
if (color === "#00FF00" || typeof text !== "string")
|
|
2182
|
+
return text;
|
|
2183
|
+
const preset = KEY_COLOR_NAMES.find((entry) => entry.hex === color);
|
|
2184
|
+
const zhScreen = preset === undefined ? "纯色背景" : preset.zh;
|
|
2185
|
+
const zhWord = preset === undefined ? color : preset.zhWord;
|
|
2186
|
+
const zhBackground = preset === undefined ? "纯色背景" : `${preset.zh}背景`;
|
|
2187
|
+
const enScreen = preset === undefined ? "solid background" : preset.en;
|
|
2188
|
+
const enWord = preset === undefined ? color.toLowerCase() : preset.enWord;
|
|
2189
|
+
const enBackground = preset === undefined ? "solid background" : `${preset.en} background`;
|
|
2190
|
+
let out = text;
|
|
2191
|
+
// 中文:先换更长的固定搭配,最后才换单独的「绿幕」。
|
|
2192
|
+
out = out.split("不要用绿幕背景").join("不要用纯色背景");
|
|
2193
|
+
out = out.split("不要用绿幕").join("不要用纯色背景");
|
|
2194
|
+
out = out.split("纯绿幕").join(preset === undefined ? "纯色背景" : `纯${zhScreen}`);
|
|
2195
|
+
out = out.split("绿幕背景").join(zhBackground);
|
|
2196
|
+
out = out.split("干净的绿幕").join(`干净的${zhScreen}`);
|
|
2197
|
+
out = out.split("没检测到绿幕").join(`没检测到${zhScreen}`);
|
|
2198
|
+
out = out.split("每一片绿").join(`每一片${zhWord}`);
|
|
2199
|
+
out = out.split("一片绿").join(`一片${zhWord}`);
|
|
2200
|
+
out = out.split("抠绿幕").join(`抠${zhScreen}`);
|
|
2201
|
+
out = out.split("抠绿").join(`抠${zhWord}`);
|
|
2202
|
+
out = out.split("绿框").join(`${zhWord}框`);
|
|
2203
|
+
out = out.split("绿色描边").join(`${zhWord}色描边`);
|
|
2204
|
+
out = out.split("绿色外发光").join(`${zhWord}色外发光`);
|
|
2205
|
+
out = out.split("绿色").join(`${zhWord}色`);
|
|
2206
|
+
out = out.split("绿幕").join(zhScreen);
|
|
2207
|
+
out = out.split("纯绿").join(`纯${zhWord}`);
|
|
2208
|
+
// 英文。
|
|
2209
|
+
out = out.split("no green-screen background").join("no solid-color background");
|
|
2210
|
+
out = out.split("green screen background").join(enBackground);
|
|
2211
|
+
out = out.split("clean green screen").join(`clean ${enScreen}`);
|
|
2212
|
+
out = out.split("pure green").join(`pure ${enWord}`);
|
|
2213
|
+
out = out.split("green outline").join(`${enWord} outline`);
|
|
2214
|
+
out = out.split("green glow").join(`${enWord} glow`);
|
|
2215
|
+
out = out.split("the same green").join(`the same ${enWord}`);
|
|
2216
|
+
out = out.split("green background").join(enBackground);
|
|
2217
|
+
out = out.split("green screen").join(enScreen);
|
|
2218
|
+
// 色值最后换,避免把「标准 chroma key 绿 #00FF00」拆成两半。
|
|
2219
|
+
out = out.split("#00FF00").join(color);
|
|
2220
|
+
return out;
|
|
2221
|
+
}
|
|
2130
2222
|
function buildAssetRequestPrompt(input) {
|
|
2131
2223
|
const shape = ASSET_SHAPES.includes(input.shape) ? input.shape : "auto";
|
|
2132
2224
|
const fixed = shape !== "auto";
|
|
2225
|
+
const keyColorHex = normalizeKeyColorHex(input.keyColor);
|
|
2133
2226
|
/** 整图需要「占几格」:用户指定了就按指定的,没指定就按 3×3 的常见尺寸让 agent 用。 */
|
|
2134
2227
|
const stampCols = clampStampSpan(Number(input.stampCols) || 3, 512);
|
|
2135
2228
|
const stampRows = clampStampSpan(Number(input.stampRows) || 3, 512);
|
|
@@ -2241,13 +2334,19 @@ window.__ModuleLoader__.load({
|
|
|
2241
2334
|
}
|
|
2242
2335
|
lines.push("", shape === "stamp" || !fixed
|
|
2243
2336
|
? T(" ⚠️ 整图**不要**自己去抠像(别为了抠图再跑一次 image 模块的 keyImageJob):`composeMapAsset` 会先抠绿幕、再按占格切片。生成完直接把原图路径交给它。")
|
|
2244
|
-
: null, T("第四步 · 整理并回链:game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], shape:'<你选的形态:plain|corner16|a2quad|stamp>'}})", {
|
|
2337
|
+
: null, T("第四步 · 整理并回链:game_material({action:'call', method:'composeMapAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], shape:'<你选的形态:plain|corner16|a2quad|stamp>', keyColor:'{n2}'}})", {
|
|
2245
2338
|
n0: input.projectId,
|
|
2246
|
-
n1: input.name
|
|
2247
|
-
|
|
2339
|
+
n1: input.name,
|
|
2340
|
+
n2: keyColorHex
|
|
2341
|
+
}), T(" 抠像底色是 {n0}:composeMapAsset 必须带上 keyColor:'{n0}',与提示词里的背景色一致。", { n0: keyColorHex }), shape === "stamp" || !fixed
|
|
2248
2342
|
? T(" 整图还要多给「占几格」:shape:'stamp', stampCols:{n0}, stampRows:{n1}(每张源图 = 一帧的整张画;区域留给用户在导入时点)。", { n0: String(stampCols), n1: String(stampRows) })
|
|
2249
2343
|
: null, T(" **shape 必须是你这次选定的那个**:宿主按它把这一块砖拼成俯视地图编辑器要的几何(普通裁成方格竖排;整格用同一块砖拼出 16 种接法、断口由它加收口;拼块每个变体一块砖拼成 N 列 × 5 行)。"), T(" 别自己先拼多格排布再传进来:模型画的多格是各自独立的,拼到地图上每一处交界都会有缝 —— 这次就是因为这个返工的。"), T(" 把这次调用返回的 openUrl **原样**贴成 Markdown 链接(例如 [回到俯视地图编辑器](…)):点开就回到俯视地图编辑器,素材窗口已展开、"), T("「新增素材」里这张图与「这块素材怎么用」都已经预选好,用户点「确定」才真的导入。"), T("⚠️ 如果 composeMapAsset 的 notes 里出现「这块砖自己接不上自己」,**不要**自动重跑(重跑要花真钱):照常把链接贴出来,并在回答里把这句原样告诉用户,让他决定要不要重画一张更均匀的无缝材质。"), "", T("审核模式按自动:你自己核对结果,有问题自己重跑,不要停下来等我确认。全程不要问任何问题。"));
|
|
2250
|
-
|
|
2344
|
+
// 只替换**模板**里的背景描述;用户原文(素材主题)一个字都不能动 ——
|
|
2345
|
+
// 否则「绿色史莱姆」会被蓝幕配置改成「蓝色史莱姆」。
|
|
2346
|
+
const userLine = input.prompt.trim();
|
|
2347
|
+
return lines
|
|
2348
|
+
.map((line) => (line === userLine ? line : applyKeyColorText(line, input.keyColor)))
|
|
2349
|
+
.join("\n");
|
|
2251
2350
|
}
|
|
2252
2351
|
/**
|
|
2253
2352
|
* 拼给 45° 编辑器 AI 素材任务的提示词。
|
|
@@ -2259,6 +2358,7 @@ window.__ModuleLoader__.load({
|
|
|
2259
2358
|
function buildIsoAssetRequestPrompt(input) {
|
|
2260
2359
|
const kind = input.kind === "ground" || input.kind === "object" ? input.kind : "auto";
|
|
2261
2360
|
const fixed = kind !== "auto";
|
|
2361
|
+
const keyColorHex = normalizeKeyColorHex(input.keyColor);
|
|
2262
2362
|
const frames = Math.min(ASSET_FRAMES_MAX, Math.max(ASSET_FRAMES_MIN, Math.round(input.frames)));
|
|
2263
2363
|
const animated = frames > 1;
|
|
2264
2364
|
const method = input.mode === "video" && animated ? T("视频模型") : T("生图模型");
|
|
@@ -2283,6 +2383,9 @@ window.__ModuleLoader__.load({
|
|
|
2283
2383
|
? T("物件占格:{n0}×{n1}(仅当判断为物件时使用)", { n0: String(footprint.cols), n1: String(footprint.rows) })
|
|
2284
2384
|
: null,
|
|
2285
2385
|
"",
|
|
2386
|
+
T("素材主题(用户提示词):"),
|
|
2387
|
+
input.prompt.trim(),
|
|
2388
|
+
"",
|
|
2286
2389
|
...(fixed
|
|
2287
2390
|
? [T("这块素材怎么用已经定死了({n0}),不要再讨论别的用法,直接按它做。", { n0: kindLabel(kind) })]
|
|
2288
2391
|
: [
|
|
@@ -2305,8 +2408,12 @@ window.__ModuleLoader__.load({
|
|
|
2305
2408
|
? T("① 先出一张静态首帧图:createImageJob({name}) → saveImageJob({jobId, prompt:<上面的主题 + 画法要求 + 排布>}) → runImageJob({jobId, count:1}) → game_material({action:'wait', id:jobId});然后 getImageJob({jobId}) 取 dir 与 items[0].file,首帧绝对路径 = dir + '/' + file。")
|
|
2306
2409
|
: T("用图片生成模块:createImageJob({name}) → saveImageJob({jobId, prompt:<上面的主题 + 画法要求 + 排布>}) → runImageJob({jobId, count:{n0}}) → game_material({action:'wait', id:jobId});", { n0: String(frames) }), input.mode === "video" && animated
|
|
2307
2410
|
? T("② 再让它动起来并抽帧:createSequenceJob({name}) → game_material({action:'upload', module:'sequence', id, kind:'firstFrame', path:<首帧绝对路径>}) → runSequenceVideo({jobId}) → game_material({action:'wait'}) → runSequenceFrames({jobId, count:{n0}}) → game_material({action:'wait'});然后 getSequenceJob({jobId}) 取 dir 与 frames.files,按顺序取前 {n0} 帧的绝对路径 = dir + '/' + file。", { n0: String(frames) })
|
|
2308
|
-
: T("然后 getImageJob({jobId}) 取 dir 与 items[],按顺序取前 {n0} 张的绝对路径 = dir + '/' + file。", { n0: String(frames) }), "", T("第四步 · 整理并回链:game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], kind:'<ground 或 object>', footprint:<物件时给 {{cols:{n2},rows:{n3}}}
|
|
2309
|
-
|
|
2411
|
+
: T("然后 getImageJob({jobId}) 取 dir 与 items[],按顺序取前 {n0} 张的绝对路径 = dir + '/' + file。", { n0: String(frames) }), "", T("第四步 · 整理并回链:game_material({action:'call', method:'composeIsoAsset', payload:{projectId:'{n0}', name:'{n1}', files:[<上面那些绝对路径,按顺序>], kind:'<ground 或 object>', footprint:<物件时给 {{cols:{n2},rows:{n3}}}>, keyColor:'{n4}'}})", { n0: input.projectId, n1: input.name, n2: String(footprint.cols), n3: String(footprint.rows), n4: keyColorHex }), T(" 抠像底色是 {n0}:composeIsoAsset 必须带上 keyColor:'{n0}',与提示词里的背景色一致。", { n0: keyColorHex }), T(" `kind` 必须和这次实际画的一致;不要传 `auto`。物件必须给 footprint;地面不需要。"), T(" 把这次调用返回的 openUrl **原样**贴成 Markdown 链接(例如 [回到 45° 地图编辑器](…)):点开就回到项目、素材窗口展开、"), T("「新增素材」里这张图与用途 / 帧数 / 占格都已经预选好,用户点「确定」才真的导入。"), T("⚠️ 如果 composeIsoAsset 的 notes 说比例不是 2:1 或没检测到绿幕,**不要**自动重跑(重跑要花真钱):照常贴链接,并在回答里原样告诉用户。"), "", T("审核模式按自动:你自己核对结果,有问题自己重跑,不要停下来等我确认。全程不要问任何问题。"));
|
|
2412
|
+
const userLine = input.prompt.trim();
|
|
2413
|
+
return lines
|
|
2414
|
+
.filter((line) => line !== null)
|
|
2415
|
+
.map((line) => (line === userLine ? line : applyKeyColorText(line, input.keyColor)))
|
|
2416
|
+
.join("\n");
|
|
2310
2417
|
}
|
|
2311
2418
|
/**
|
|
2312
2419
|
* 拼给音乐任务新对话的提示词。
|
|
@@ -2591,6 +2698,8 @@ window.__ModuleLoader__.load({
|
|
|
2591
2698
|
["isoUndo", true],
|
|
2592
2699
|
["isoRedo", true],
|
|
2593
2700
|
["isoPlan", true],
|
|
2701
|
+
["isoInspect", true],
|
|
2702
|
+
["isoRender", true],
|
|
2594
2703
|
["runIsoGenerate", true],
|
|
2595
2704
|
["runIsoPreview", true],
|
|
2596
2705
|
["runIsoExport", true],
|
|
@@ -2614,6 +2723,8 @@ window.__ModuleLoader__.load({
|
|
|
2614
2723
|
["mapUndo", true],
|
|
2615
2724
|
["mapRedo", true],
|
|
2616
2725
|
["mapPlan", true],
|
|
2726
|
+
["mapInspect", true],
|
|
2727
|
+
["mapRender", true],
|
|
2617
2728
|
["runMapGenerate", true],
|
|
2618
2729
|
["runMapPreview", true],
|
|
2619
2730
|
["runMapExport", true],
|
|
@@ -3007,14 +3118,14 @@ window.__ModuleLoader__.load({
|
|
|
3007
3118
|
if (params.get("scale") !== null && Number.isInteger(scale) && scale >= 1 && scale <= 8)
|
|
3008
3119
|
intent.scale = scale;
|
|
3009
3120
|
/**
|
|
3010
|
-
* `cols` / `rows` = 整图占几格(宿主 `links.ts` 的
|
|
3121
|
+
* `cols` / `rows` = 整图占几格(宿主 `links.ts` 的 1..512)。
|
|
3011
3122
|
* 少了它们,「新增素材」会按默认 3×3 预填 —— 图与占格对不上就会被拉伸。
|
|
3012
3123
|
*/
|
|
3013
3124
|
const cols = Number(params.get("cols"));
|
|
3014
|
-
if (params.get("cols") !== null && Number.isInteger(cols) && cols >=
|
|
3125
|
+
if (params.get("cols") !== null && Number.isInteger(cols) && cols >= 1 && cols <= 512)
|
|
3015
3126
|
intent.cols = cols;
|
|
3016
3127
|
const rows = Number(params.get("rows"));
|
|
3017
|
-
if (params.get("rows") !== null && Number.isInteger(rows) && rows >=
|
|
3128
|
+
if (params.get("rows") !== null && Number.isInteger(rows) && rows >= 1 && rows <= 512)
|
|
3018
3129
|
intent.rows = rows;
|
|
3019
3130
|
/** `keyed=1`:整理时**已经抠过绿幕**,「新增素材」据此取消「抠掉绿幕」勾选(免得抠两遍)。 */
|
|
3020
3131
|
if (params.get("keyed") === "1")
|
|
@@ -3199,6 +3310,20 @@ window.__ModuleLoader__.load({
|
|
|
3199
3310
|
.SPR_projItem{display:flex;flex-direction:column;gap:2px;text-align:left;width:100%;font:inherit;cursor:pointer;background:transparent;border:1px solid transparent;border-radius:8px;padding:7px 9px;color:var(--dsw-alias-label-primary)}
|
|
3200
3311
|
.SPR_projItem:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
3201
3312
|
.SPR_projItem[data-active=true]{background:var(--dsw-alias-bg-layer-3);border-color:var(--dsw-alias-border-l1)}
|
|
3313
|
+
.SPR_copyId{display:inline-flex;align-items:center;justify-content:center;gap:4px;font:inherit;font-size:11px;line-height:1;white-space:nowrap;cursor:pointer;padding:4px 7px;border-radius:6px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-secondary)}
|
|
3314
|
+
.SPR_copyId:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
3315
|
+
.SPR_copyId[data-copied=true]{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary)}
|
|
3316
|
+
.SPR_copyId[data-failed=true]{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}
|
|
3317
|
+
.SPR_copyIdInline{padding:0 3px;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:16px}
|
|
3318
|
+
.SPR_copyIdInline:hover{background:transparent;color:var(--dsw-alias-label-primary)}
|
|
3319
|
+
.SPR_projNameRow{display:flex;align-items:center;gap:6px;min-width:0}
|
|
3320
|
+
.SPR_projNameRow>.SPR_projName{flex:1;min-width:0}
|
|
3321
|
+
.SPR_mapEdTop .SPR_copyId,.SPR_isoTop .SPR_copyId{color:#f7f3ec;border-color:#232323;background:linear-gradient(#5d5d5d,#4b4b4b)}
|
|
3322
|
+
.SPR_mapEdTop .SPR_copyId:hover,.SPR_isoTop .SPR_copyId:hover{background:linear-gradient(#6a6a6a,#555);color:#fff}
|
|
3323
|
+
.SPR_mapEdTop .SPR_copyId[data-copied=true],.SPR_isoTop .SPR_copyId[data-copied=true]{border-color:#5bd08a;color:#b8ffd0}
|
|
3324
|
+
.SPR_mapEdMenu .SPR_copyIdInline,.SPR_isoMenu .SPR_copyIdInline{color:#c9c4bb}
|
|
3325
|
+
.SPR_mapEdMenu .SPR_copyIdInline:hover,.SPR_isoMenu .SPR_copyIdInline:hover{color:#fff}
|
|
3326
|
+
.SPR_mapEdMenu .SPR_projNameRow,.SPR_isoMenu .SPR_projNameRow{width:100%}
|
|
3202
3327
|
.SPR_projName{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
3203
3328
|
.SPR_projMeta{font-size:11px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
|
|
3204
3329
|
.SPR_main{flex:1;min-width:0;overflow:auto;padding:16px 18px 40px}
|
|
@@ -4157,6 +4282,14 @@ window.__ModuleLoader__.load({
|
|
|
4157
4282
|
}, [api]);
|
|
4158
4283
|
return value;
|
|
4159
4284
|
}
|
|
4285
|
+
/** 当前生图后端的尺寸配置键(设置页与图片模块共用)。 */
|
|
4286
|
+
function sizeConfigKey(config) {
|
|
4287
|
+
if (config?.imageProvider === "custom")
|
|
4288
|
+
return "customSize";
|
|
4289
|
+
if (config?.imageProvider === "toapis")
|
|
4290
|
+
return "toapisImageSize";
|
|
4291
|
+
return "arkSize";
|
|
4292
|
+
}
|
|
4160
4293
|
/** 只读展示当前生效的全局模型:模型只在设置里改,模块内不允许覆盖。 */
|
|
4161
4294
|
function GlobalModelField({ label, value }) {
|
|
4162
4295
|
return h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, label), h("input", { className: "SPR_input", value: value ?? "", readOnly: true, disabled: true }), h("span", { className: "SPR_fieldLabel" }, T("跟随即「设置 → 游戏素材大师」")));
|
|
@@ -4781,7 +4914,7 @@ window.__ModuleLoader__.load({
|
|
|
4781
4914
|
const activeStageIndex = STAGES.findIndex((s) => s.key === stage);
|
|
4782
4915
|
const activeStage = STAGES[activeStageIndex < 0 ? 0 : activeStageIndex];
|
|
4783
4916
|
return h("div", { className: "SPR_root" }, h("div", { className: "SPR_head" }, h("h2", null, T("游戏素材大师")), h("span", { className: "SPR_headSub" }, T("火山方舟 Seedream 生图 · MiniMax 图生视频 · 谱乐 AI 音乐 · 火山引擎音效 · 本地处理")), h("span", { className: "SPR_spacer" }), activeModule === "sprite"
|
|
4784
|
-
? h(React.Fragment, null, h(Btn, { onClick: () => void refreshProjects(), disabled: loading }, T("刷新列表")), project !== null ? h(Btn, { onClick: renameCurrent }, T("重命名")) : null, project !== null ? h(Btn, { onClick: deleteCurrent, danger: true }, T("删除项目")) : null, h(Btn, { onClick: createProject, primary: true }, T("新建项目")))
|
|
4917
|
+
? h(React.Fragment, null, h(Btn, { onClick: () => void refreshProjects(), disabled: loading }, T("刷新列表")), project !== null ? h(Btn, { onClick: renameCurrent }, T("重命名")) : null, project !== null ? h(Btn, { onClick: deleteCurrent, danger: true }, T("删除项目")) : null, project !== null ? h(CopyIdButton, { id: project.id }) : null, h(Btn, { onClick: createProject, primary: true }, T("新建项目")))
|
|
4785
4918
|
: null), h("div", { className: "SPR_modules", "data-hidden-count": String(hidden.length) }, visibleModules.map((entry) => h("button", {
|
|
4786
4919
|
key: entry.key,
|
|
4787
4920
|
type: "button",
|
|
@@ -4802,7 +4935,7 @@ window.__ModuleLoader__.load({
|
|
|
4802
4935
|
className: "SPR_projItem",
|
|
4803
4936
|
"data-active": summary.id === projectId ? "true" : "false",
|
|
4804
4937
|
onClick: () => setProjectId(summary.id)
|
|
4805
|
-
}, h("span", { className: "SPR_projName" }, summary.name), h("span", { className: "SPR_projMeta" }, T("图 {n0}/8 · 视频 {n1}/8 · 帧 {n2}/8{n3}", { n0: summary.imageReady, n1: summary.videoReady, n2: summary.framesReady, n3: summary.sheetReady ? T(" · 整图✓") : "" }))))), h("div", { className: "SPR_main" }, notice !== null
|
|
4938
|
+
}, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, summary.name), h(CopyIdButton, { id: summary.id, inline: true })), h("span", { className: "SPR_projMeta" }, T("图 {n0}/8 · 视频 {n1}/8 · 帧 {n2}/8{n3}", { n0: summary.imageReady, n1: summary.videoReady, n2: summary.framesReady, n3: summary.sheetReady ? T(" · 整图✓") : "" }))))), h("div", { className: "SPR_main" }, notice !== null
|
|
4806
4939
|
? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text, h("span", { style: { marginLeft: 10 } }, h("button", { type: "button", className: "SPR_miniBtn", onClick: () => setNotice(null) }, T("关闭"))))
|
|
4807
4940
|
: null, project === null
|
|
4808
4941
|
? h("p", { className: "SPR_empty" }, loading ? T("正在载入…") : T("请选择或新建一个项目"))
|
|
@@ -5838,7 +5971,7 @@ window.__ModuleLoader__.load({
|
|
|
5838
5971
|
// 合成整图是本地 CPU 重活,宿主侧会标 running;重抠像同样走这个状态。
|
|
5839
5972
|
const composing = project.sheet?.status === "running" || tasks.has(KEY_SHEET_COMPOSE) || tasks.has(KEY_SHEET_REKEY);
|
|
5840
5973
|
const keyed = project.sheet?.backgroundFraction;
|
|
5841
|
-
const composeLabel = tasks.label(KEY_SHEET_REKEY) ?? tasks.label(KEY_SHEET_COMPOSE) ?? T("
|
|
5974
|
+
const composeLabel = tasks.label(KEY_SHEET_REKEY) ?? tasks.label(KEY_SHEET_COMPOSE) ?? T("正在抠背景并合成整图…");
|
|
5842
5975
|
const moveRow = (index, delta) => {
|
|
5843
5976
|
const next = [...rowOrder];
|
|
5844
5977
|
const target = index + delta;
|
|
@@ -5875,26 +6008,26 @@ window.__ModuleLoader__.load({
|
|
|
5875
6008
|
min: 0,
|
|
5876
6009
|
max: 32,
|
|
5877
6010
|
onChange: (value) => setSettingsDraft({ ...draft, pixelSize: value })
|
|
5878
|
-
}), h(NumField, {
|
|
5879
|
-
label: T("背景分割容差(0 =
|
|
6011
|
+
}), h(KeyColorField, { value: draft.keyColor, onChange: (value) => { setSettingsDraft({ ...draft, keyColor: value }); void saveSettings({ keyColor: value }); } }), h(NumField, {
|
|
6012
|
+
label: T("背景分割容差(0 = 只认背景色)"),
|
|
5880
6013
|
value: draft.bgTolerance ?? 90,
|
|
5881
6014
|
min: 0,
|
|
5882
6015
|
max: 120,
|
|
5883
6016
|
onChange: (value) => setSettingsDraft({ ...draft, bgTolerance: value })
|
|
5884
6017
|
}), h(NumField, {
|
|
5885
|
-
label: T("
|
|
6018
|
+
label: T("抠像下限(背景色接近度)"),
|
|
5886
6019
|
value: draft.keyLow ?? 14,
|
|
5887
6020
|
min: 0,
|
|
5888
6021
|
max: 255,
|
|
5889
6022
|
onChange: (value) => setSettingsDraft({ ...draft, keyLow: value })
|
|
5890
6023
|
}), h(NumField, {
|
|
5891
|
-
label: T("
|
|
6024
|
+
label: T("抠像上限(背景色接近度)"),
|
|
5892
6025
|
value: draft.keyHigh ?? 80,
|
|
5893
6026
|
min: 1,
|
|
5894
6027
|
max: 255,
|
|
5895
6028
|
onChange: (value) => setSettingsDraft({ ...draft, keyHigh: value })
|
|
5896
6029
|
}), h(NumField, {
|
|
5897
|
-
label: T("
|
|
6030
|
+
label: T("去溢色 0~1"),
|
|
5898
6031
|
value: draft.despill ?? 0.65,
|
|
5899
6032
|
min: 0,
|
|
5900
6033
|
max: 1,
|
|
@@ -5959,7 +6092,7 @@ window.__ModuleLoader__.load({
|
|
|
5959
6092
|
disabled: framesReady === 0 || composing,
|
|
5960
6093
|
onClick: () => void start(() => api.compose({ projectId: project.id }), { reload: true }, {
|
|
5961
6094
|
key: KEY_SHEET_COMPOSE,
|
|
5962
|
-
label: T("
|
|
6095
|
+
label: T("正在抠背景并合成整图…")
|
|
5963
6096
|
})
|
|
5964
6097
|
}, T("合成整图({n0}/8 组帧就绪)", { n0: framesReady })), h(BusyBadge, { show: composing, text: composeLabel }), project.sheet?.file !== undefined
|
|
5965
6098
|
? h("a", {
|
|
@@ -6326,10 +6459,133 @@ window.__ModuleLoader__.load({
|
|
|
6326
6459
|
}, { reload: true }, { key: KEY_LOCAL_VIDEO(key), label: T("正在导入本地视频…") });
|
|
6327
6460
|
}
|
|
6328
6461
|
/** 抠像参数表单(三个模块共用同一套字段)。 */
|
|
6329
|
-
function KeyingFields({ draft, onChange }) {
|
|
6330
|
-
return h("div", { className: "SPR_fields" }, h(NumField, { label: T("
|
|
6462
|
+
function KeyingFields({ draft, onChange, fallbackColor }) {
|
|
6463
|
+
return h("div", { className: "SPR_fields" }, h(KeyColorField, { value: draft.keyColor || fallbackColor, onChange: (v) => onChange({ keyColor: v }) }), h(NumField, { label: T("抠像下限(背景色接近度)"), value: draft.keyLow ?? 14, min: 0, max: 255, onChange: (v) => onChange({ keyLow: v }) }), h(NumField, { label: T("抠像上限(背景色接近度)"), value: draft.keyHigh ?? 80, min: 1, max: 255, onChange: (v) => onChange({ keyHigh: v }) }), h(NumField, { label: T("去溢色 0~1"), value: draft.despill ?? 0.65, min: 0, max: 1, step: 0.05, onChange: (v) => onChange({ despill: v }) }), h(NumField, { label: T("背景分割容差(0 = 只认背景色)"), value: draft.bgTolerance ?? 90, min: 0, max: 160, onChange: (v) => onChange({ bgTolerance: v }) }), h(NumField, { label: T("边缘收缩(px)"), value: draft.edgeShrink ?? 0, min: 0, max: 8, onChange: (v) => onChange({ edgeShrink: v }) }));
|
|
6464
|
+
}
|
|
6465
|
+
/**
|
|
6466
|
+
* 抠像底色选择器(所有需要抠图的地方共用)。
|
|
6467
|
+
*
|
|
6468
|
+
* 角色身上有绿衣服时绿幕会把衣服一起吃掉,所以底色必须可换。预设只列
|
|
6469
|
+
* 饱和纯色;「自定义」用浏览器原生取色器 / 十六进制输入。
|
|
6470
|
+
*/
|
|
6471
|
+
function KeyColorField({ value, onChange, label }) {
|
|
6472
|
+
const current = normalizeKeyColorHex(value);
|
|
6473
|
+
const presets = [
|
|
6474
|
+
{ hex: "#00FF00", label: T("绿幕(默认)") },
|
|
6475
|
+
{ hex: "#0000FF", label: T("蓝幕") },
|
|
6476
|
+
{ hex: "#FF00FF", label: T("品红幕") },
|
|
6477
|
+
{ hex: "#00FFFF", label: T("青幕") },
|
|
6478
|
+
{ hex: "#FFFF00", label: T("黄幕") },
|
|
6479
|
+
{ hex: "#FF0000", label: T("红幕") },
|
|
6480
|
+
{ hex: "#FFFFFF", label: T("白幕") },
|
|
6481
|
+
{ hex: "#000000", label: T("黑幕") }
|
|
6482
|
+
];
|
|
6483
|
+
return h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, label ?? T("抠像背景色")), h("div", { style: { display: "flex", gap: 6, alignItems: "center", flexWrap: "wrap" } }, h("input", {
|
|
6484
|
+
type: "color",
|
|
6485
|
+
value: current,
|
|
6486
|
+
"data-testid": "key-color",
|
|
6487
|
+
title: T("自定义背景色"),
|
|
6488
|
+
onChange: (event) => onChange(normalizeKeyColorHex(event.target.value)),
|
|
6489
|
+
style: { width: 40, height: 30, padding: 0, border: "1px solid var(--dsw-alias-border-l2)", borderRadius: 6, background: "transparent" }
|
|
6490
|
+
}), h("select", {
|
|
6491
|
+
className: "SPR_input",
|
|
6492
|
+
"data-testid": "key-color-preset",
|
|
6493
|
+
style: { flex: "1 1 120px" },
|
|
6494
|
+
value: presets.some((preset) => preset.hex === current) ? current : "",
|
|
6495
|
+
onChange: (event) => onChange(event.target.value === "" ? current : event.target.value)
|
|
6496
|
+
}, presets.map((preset) => h("option", { key: preset.hex, value: preset.hex }, preset.label)), presets.some((preset) => preset.hex === current) ? null : h("option", { value: "" }, T("自定义"))), h("input", {
|
|
6497
|
+
className: "SPR_input",
|
|
6498
|
+
style: { width: 108 },
|
|
6499
|
+
defaultValue: current,
|
|
6500
|
+
key: current,
|
|
6501
|
+
"data-testid": "key-color-hex",
|
|
6502
|
+
onBlur: (event) => onChange(normalizeKeyColorHex(event.target.value))
|
|
6503
|
+
})));
|
|
6331
6504
|
}
|
|
6332
6505
|
/** 一份任务/项目列表(左侧栏)。 */
|
|
6506
|
+
/**
|
|
6507
|
+
* 把一段文本复制到剪贴板。
|
|
6508
|
+
*
|
|
6509
|
+
* 浏览器半区可能跑在 Electron / 普通网页 / 自检桩里:优先用 Clipboard API,
|
|
6510
|
+
* 失败再退回旧式 `execCommand("copy")`。返回是否成功,界面据此显示「已复制 / 复制失败」。
|
|
6511
|
+
*/
|
|
6512
|
+
async function copyIdText(text) {
|
|
6513
|
+
if (typeof navigator !== "undefined" && navigator.clipboard !== undefined && typeof navigator.clipboard.writeText === "function") {
|
|
6514
|
+
try {
|
|
6515
|
+
await navigator.clipboard.writeText(text);
|
|
6516
|
+
return true;
|
|
6517
|
+
}
|
|
6518
|
+
catch {
|
|
6519
|
+
/* 剪贴板权限被拒时走下面的兜底 */
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
try {
|
|
6523
|
+
if (typeof document === "undefined" || document.body === undefined || document.body === null)
|
|
6524
|
+
return false;
|
|
6525
|
+
const area = document.createElement("textarea");
|
|
6526
|
+
area.value = text;
|
|
6527
|
+
area.setAttribute("readonly", "readonly");
|
|
6528
|
+
area.style.position = "fixed";
|
|
6529
|
+
area.style.left = "-9999px";
|
|
6530
|
+
area.style.top = "0";
|
|
6531
|
+
document.body.appendChild(area);
|
|
6532
|
+
area.select();
|
|
6533
|
+
const ok = typeof document.execCommand === "function" ? document.execCommand("copy") : false;
|
|
6534
|
+
document.body.removeChild(area);
|
|
6535
|
+
return ok === true;
|
|
6536
|
+
}
|
|
6537
|
+
catch {
|
|
6538
|
+
return false;
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
/**
|
|
6542
|
+
* 「复制项目 ID」按钮。
|
|
6543
|
+
*
|
|
6544
|
+
* 所有模块的项目 / 任务共用它:把当前 id 一键复制给 agent,省得用户从日志或
|
|
6545
|
+
* 回复里翻 ID。`inline` 用在侧栏项目行里(span,避免 button 套 button)。
|
|
6546
|
+
*/
|
|
6547
|
+
function CopyIdButton({ id, inline = false, className = "" }) {
|
|
6548
|
+
const [state, setState] = React.useState("idle");
|
|
6549
|
+
const timer = React.useRef(null);
|
|
6550
|
+
React.useEffect(() => () => {
|
|
6551
|
+
if (timer.current !== null)
|
|
6552
|
+
clearTimeout(timer.current);
|
|
6553
|
+
}, []);
|
|
6554
|
+
if (id === null || id === undefined || id === "")
|
|
6555
|
+
return null;
|
|
6556
|
+
const text = String(id);
|
|
6557
|
+
const copy = async (event) => {
|
|
6558
|
+
if (event !== null && event !== undefined && typeof event.stopPropagation === "function")
|
|
6559
|
+
event.stopPropagation();
|
|
6560
|
+
const ok = await copyIdText(text);
|
|
6561
|
+
setState(ok ? "ok" : "failed");
|
|
6562
|
+
if (timer.current !== null)
|
|
6563
|
+
clearTimeout(timer.current);
|
|
6564
|
+
timer.current = setTimeout(() => {
|
|
6565
|
+
timer.current = null;
|
|
6566
|
+
setState("idle");
|
|
6567
|
+
}, 1600);
|
|
6568
|
+
};
|
|
6569
|
+
const label = state === "ok" ? T("已复制") : state === "failed" ? T("复制失败") : inline ? "⧉" : T("复制 ID");
|
|
6570
|
+
const tag = inline ? "span" : "button";
|
|
6571
|
+
return h(tag, {
|
|
6572
|
+
...(inline ? { role: "button", tabIndex: 0 } : { type: "button" }),
|
|
6573
|
+
className: `SPR_copyId${inline ? " SPR_copyIdInline" : ""}${className === "" ? "" : ` ${className}`}`,
|
|
6574
|
+
"data-copied": state === "ok" ? "true" : undefined,
|
|
6575
|
+
"data-failed": state === "failed" ? "true" : undefined,
|
|
6576
|
+
title: T("复制项目 ID:{n0}", { n0: text }),
|
|
6577
|
+
"aria-label": T("复制项目 ID"),
|
|
6578
|
+
onClick: copy,
|
|
6579
|
+
onKeyDown: inline
|
|
6580
|
+
? (event) => {
|
|
6581
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
6582
|
+
event.preventDefault();
|
|
6583
|
+
void copy(event);
|
|
6584
|
+
}
|
|
6585
|
+
}
|
|
6586
|
+
: undefined
|
|
6587
|
+
}, label);
|
|
6588
|
+
}
|
|
6333
6589
|
function JobSidebar({ title, items, activeId, onSelect, onCreate, renderMeta }) {
|
|
6334
6590
|
return h("div", { className: "SPR_side" }, h("div", { className: "SPR_sideTitle" }, T("{n0}({n1})", { n0: title, n1: items.length })), items.length === 0 ? h("p", { className: "SPR_hint" }, T("还没有内容,点右上角新建一个。")) : null, items.map((item) => h("button", {
|
|
6335
6591
|
key: item.id,
|
|
@@ -6337,7 +6593,7 @@ window.__ModuleLoader__.load({
|
|
|
6337
6593
|
className: "SPR_projItem",
|
|
6338
6594
|
"data-active": item.id === activeId ? "true" : "false",
|
|
6339
6595
|
onClick: () => onSelect(item.id)
|
|
6340
|
-
}, h("span", { className: "SPR_projName" }, item.name), h("span", { className: "SPR_projMeta" }, renderMeta(item)))), items.length === 0 ? h(Btn, { onClick: onCreate, primary: true }, T("新建")) : null);
|
|
6596
|
+
}, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, item.name), h(CopyIdButton, { id: item.id, inline: true })), h("span", { className: "SPR_projMeta" }, renderMeta(item)))), items.length === 0 ? h(Btn, { onClick: onCreate, primary: true }, T("新建")) : null);
|
|
6341
6597
|
}
|
|
6342
6598
|
// ── 模块六 · 地图编辑器(单屏 · 零术语)────────────────────────────────
|
|
6343
6599
|
//
|
|
@@ -6620,6 +6876,7 @@ window.__ModuleLoader__.load({
|
|
|
6620
6876
|
function MapModule(props) {
|
|
6621
6877
|
useLocaleTick();
|
|
6622
6878
|
const api = props.api;
|
|
6879
|
+
const globalConfig = useGlobalConfig(api);
|
|
6623
6880
|
// ── 项目与视图 ───────────────────────────────────────────────────────
|
|
6624
6881
|
const [projects, setProjects] = React.useState([]);
|
|
6625
6882
|
const [view, setView] = React.useState(null);
|
|
@@ -6716,15 +6973,22 @@ window.__ModuleLoader__.load({
|
|
|
6716
6973
|
* 上一张图的朝向不该莫名其妙带到下一张。
|
|
6717
6974
|
*/
|
|
6718
6975
|
const [stampRot, setStampRot] = React.useState(0);
|
|
6719
|
-
/**
|
|
6976
|
+
/**
|
|
6977
|
+
* 当前笔刷对应的整图规格 —— **只在「画笔」工具下才生效**,其它工具一律单格。
|
|
6978
|
+
*
|
|
6979
|
+
* 整图一次占 N×M 格,所以画笔的悬停框 / 右键旋转 / 落笔都按整张算。但标记、橡皮、
|
|
6980
|
+
* 油漆桶、吸管、抓手都只作用在**一格**上:它们不该继承上一张整图的 3×2 框 ——
|
|
6981
|
+
* 真机反馈「切到标记 / 橡皮后笔刷还是多个格子的样子」。把工具一起收进这里,
|
|
6982
|
+
* 非画笔时返回 null,下游(悬停框 / 右键 / 落笔)自然全回到 1×1。
|
|
6983
|
+
*/
|
|
6720
6984
|
const brushStamp = React.useMemo(() => {
|
|
6721
|
-
if (brush === null || view === null || view === undefined)
|
|
6985
|
+
if (tool !== "pen" || brush === null || view === null || view === undefined)
|
|
6722
6986
|
return null;
|
|
6723
6987
|
const owner = view.tilesets.find((entry) => entry.id === brush.tilesetId);
|
|
6724
6988
|
if (owner === undefined || owner.stamp === undefined)
|
|
6725
6989
|
return null;
|
|
6726
6990
|
return { tilesetId: owner.id, cols: owner.stamp.cols, rows: owner.stamp.rows, frames: owner.stamp.frames };
|
|
6727
|
-
}, [brush, view]);
|
|
6991
|
+
}, [brush, view, tool]);
|
|
6728
6992
|
/** 多选(供「一键生成」取用)。 */
|
|
6729
6993
|
const [multi, setMulti] = React.useState([]);
|
|
6730
6994
|
const [layerIndex, setLayerIndex] = React.useState(0);
|
|
@@ -7042,15 +7306,16 @@ window.__ModuleLoader__.load({
|
|
|
7042
7306
|
* 整图:回链带了 `cols/rows/frames` 就按它预填(占格是**生图前就定好**的计划,
|
|
7043
7307
|
* 用户点「确定」前还能改;区域永远留给用户点,AI 猜不准)。
|
|
7044
7308
|
*/
|
|
7045
|
-
stampCols: String(typeof target.cols === "number" && Number.isFinite(target.cols) ? Math.max(
|
|
7046
|
-
stampRows: String(typeof target.rows === "number" && Number.isFinite(target.rows) ? Math.max(
|
|
7309
|
+
stampCols: String(typeof target.cols === "number" && Number.isFinite(target.cols) ? Math.max(1, Math.min(512, Math.round(target.cols))) : 3),
|
|
7310
|
+
stampRows: String(typeof target.rows === "number" && Number.isFinite(target.rows) ? Math.max(1, Math.min(512, Math.round(target.rows))) : 3),
|
|
7047
7311
|
stampFrames: String(shape === "stamp" && frames > 1 ? frames : 1),
|
|
7048
7312
|
stampPass: new Array(9).fill(0),
|
|
7049
7313
|
/**
|
|
7050
7314
|
* 回链带 `keyed=1` = 整理时**已经抠过绿幕**:这里要取消勾选,
|
|
7051
7315
|
* 否则会抠第二遍(画面里已经没有绿了,第二遍只会按错误的背景色误伤像素)。
|
|
7052
7316
|
*/
|
|
7053
|
-
stampKey: target.keyed !== 1
|
|
7317
|
+
stampKey: target.keyed !== 1,
|
|
7318
|
+
stampKeyColor: globalConfig?.keyColor
|
|
7054
7319
|
};
|
|
7055
7320
|
setOpenCard("assets");
|
|
7056
7321
|
const base = (loaded !== null && loaded !== undefined && loaded.assetBase) || (view !== null && view.assetBase) || "";
|
|
@@ -7824,10 +8089,13 @@ window.__ModuleLoader__.load({
|
|
|
7824
8089
|
void markerOp({ kind: "marker", op: "add", r: hit.r, c: hit.c }, true);
|
|
7825
8090
|
return;
|
|
7826
8091
|
}
|
|
7827
|
-
if (event.button === 2) {
|
|
8092
|
+
if (event.button === 2 && tool === "pen") {
|
|
7828
8093
|
/**
|
|
7829
8094
|
* **右键 = 旋转**(用户定的:右键不再是橡皮,擦除只能点「橡皮」工具)。
|
|
7830
8095
|
* 只有整图笔刷有朝向可变;别的素材转它没有意义,但仍然 swallow(不擦)。
|
|
8096
|
+
*
|
|
8097
|
+
* ⚠️ 只有**画笔**走这里:橡皮 / 油漆桶 / 吸管选了哪个工具,右键就做那个工具的事
|
|
8098
|
+
* (橡皮右键也是擦一格)。以前这一条不分工具,结果「整图笔刷 + 橡皮」右键还会转整图。
|
|
7831
8099
|
*/
|
|
7832
8100
|
if (brushStamp !== null)
|
|
7833
8101
|
setStampRot((current) => (current + 1) % 4);
|
|
@@ -8111,8 +8379,9 @@ window.__ModuleLoader__.load({
|
|
|
8111
8379
|
stampRows: "3",
|
|
8112
8380
|
stampFrames: "1",
|
|
8113
8381
|
stampPass: new Array(9).fill(0),
|
|
8114
|
-
//
|
|
8115
|
-
stampKey: true
|
|
8382
|
+
// 整图默认抠背景(AI 那条路生成的就是纯色背景图);回链带 keyed=1 时说明已经抠过。
|
|
8383
|
+
stampKey: true,
|
|
8384
|
+
stampKeyColor: globalConfig?.keyColor
|
|
8116
8385
|
});
|
|
8117
8386
|
/**
|
|
8118
8387
|
* 提交新增:把「图片 + 名字 + 属性」一次性交给宿主。
|
|
@@ -8167,7 +8436,8 @@ window.__ModuleLoader__.load({
|
|
|
8167
8436
|
* 导入时抠绿幕(只对整图有意义):AI 那条路在整理时已经抠过,回链会把它关掉,
|
|
8168
8437
|
* 免得抠第二遍把画面里本就很少的绿误伤掉。
|
|
8169
8438
|
*/
|
|
8170
|
-
stampKey: draft.shape === "stamp" ? draft.stampKey !== false : undefined
|
|
8439
|
+
stampKey: draft.shape === "stamp" ? draft.stampKey !== false : undefined,
|
|
8440
|
+
keyColor: draft.shape === "stamp" ? draft.stampKeyColor : undefined
|
|
8171
8441
|
});
|
|
8172
8442
|
setAddDraft(null);
|
|
8173
8443
|
setNotice({ kind: "info", text: T("已新增素材 {n0}", { n0: draft.name.trim() === "" ? draft.file.name : draft.name.trim() }) });
|
|
@@ -8266,6 +8536,72 @@ window.__ModuleLoader__.load({
|
|
|
8266
8536
|
["8", T("8 帧/秒"), T("每秒 8 帧"), T("很快:电流、喷泉、快速闪烁。")],
|
|
8267
8537
|
["12", T("12 帧/秒"), T("每秒 12 帧"), T("最快的一档:要靠逐帧动画硬撑的连续动作。")]
|
|
8268
8538
|
];
|
|
8539
|
+
/**
|
|
8540
|
+
* 整图的「哪些格子能走」:素材图铺满那个框,格子用 CSS grid 严丝合缝地叠上去 ——
|
|
8541
|
+
* 点的是「图上那一块」,不用再把格子编号与画面位置在心里对一遍。
|
|
8542
|
+
*
|
|
8543
|
+
* 两个入口共用(「新增素材」的草稿 / 「素材属性」改已有素材):三态颜色、图例、两个快捷按钮
|
|
8544
|
+
* 与测试 id 前缀都走同一份,免得两处慢慢长成不一样的说法。
|
|
8545
|
+
*
|
|
8546
|
+
* `sheetWidthCells`:素材图**一行有多少格**。新增时贴的是原始图(= cols);
|
|
8547
|
+
* 已有素材贴的是**烘过 4 个旋转**的成品图(= max(cols, rows))—— 非方形整图(4×3)
|
|
8548
|
+
* 若不按真实行宽算铺图比例,格子与画面就会错位,用户点错格还看不出来。
|
|
8549
|
+
*/
|
|
8550
|
+
const stampPassGrid = (options) => {
|
|
8551
|
+
const cols = Math.max(1, Math.round(Number(options.cols) || 1));
|
|
8552
|
+
const rows = Math.max(1, Math.round(Number(options.rows) || 1));
|
|
8553
|
+
const frames = Math.max(1, Math.round(Number(options.frames) || 1));
|
|
8554
|
+
const pass = Array.isArray(options.pass) ? options.pass : [];
|
|
8555
|
+
const sheetWidth = Math.max(cols, Math.round(Number(options.sheetWidthCells) || cols));
|
|
8556
|
+
const image = typeof options.image === "string" && options.image !== "" ? options.image : undefined;
|
|
8557
|
+
const backgroundSize = options.sheetWidthCells === undefined
|
|
8558
|
+
? frames > 1
|
|
8559
|
+
? `100% ${frames * 100}%`
|
|
8560
|
+
: "100% 100%"
|
|
8561
|
+
: `${(sheetWidth * 100) / cols}% ${(frames * 2 * (cols + rows) * 100) / rows}%`;
|
|
8562
|
+
const prefix = options.prefix;
|
|
8563
|
+
/**
|
|
8564
|
+
* `onChange` 收到的是**更新函数** `(上一次的 pass) => 新的 pass`,不是算好的数组。
|
|
8565
|
+
*
|
|
8566
|
+
* 为什么:两下点击之间如果还没重渲染(连续点、或一次粘贴式操作),用渲染时捕获的
|
|
8567
|
+
* `pass` 去算会让第二下从旧值出发 —— 用户看到「点了两下只前进一步」。交给 setState
|
|
8568
|
+
* 的函数式更新,每一次都在最新值上累加。
|
|
8569
|
+
*/
|
|
8570
|
+
const change = (update) => {
|
|
8571
|
+
if (typeof options.onChange === "function")
|
|
8572
|
+
options.onChange(update);
|
|
8573
|
+
};
|
|
8574
|
+
const passOf = (source) => Array.from({ length: cols * rows }, (_item, index) => Number(source?.[index]) || 0);
|
|
8575
|
+
return h("div", { "data-testid": `${prefix}-stamp-block` }, h("div", { className: "SPR_mapEdDlgLabel" }, T("哪些格子能走(在图上点格子)")), h("div", {
|
|
8576
|
+
className: "SPR_mapEdStamp",
|
|
8577
|
+
"data-testid": `${prefix}-stamp-preview`,
|
|
8578
|
+
style: {
|
|
8579
|
+
aspectRatio: `${cols} / ${rows}`,
|
|
8580
|
+
backgroundImage: image === undefined ? "none" : `url("${image}")`,
|
|
8581
|
+
backgroundSize,
|
|
8582
|
+
backgroundPosition: "0% 0%"
|
|
8583
|
+
}
|
|
8584
|
+
}, h("div", {
|
|
8585
|
+
className: "SPR_mapEdStampGrid",
|
|
8586
|
+
style: { gridTemplateColumns: `repeat(${cols}, 1fr)`, gridTemplateRows: `repeat(${rows}, 1fr)` }
|
|
8587
|
+
}, Array.from({ length: rows }, (_unused, r) => Array.from({ length: cols }, (_ignored, c) => {
|
|
8588
|
+
const index = r * cols + c;
|
|
8589
|
+
const kind = Number(pass[index]) || 0;
|
|
8590
|
+
return h("button", {
|
|
8591
|
+
key: `cell${r}-${c}`,
|
|
8592
|
+
type: "button",
|
|
8593
|
+
className: "SPR_mapEdStampCell",
|
|
8594
|
+
"data-pass": String(kind),
|
|
8595
|
+
"data-testid": `${prefix}-pass-${r}-${c}`,
|
|
8596
|
+
title: T("第 {n0} 行第 {n1} 列:不可通过 / 可通过(被人物遮挡)/ 可通过(遮挡人物)", { n0: String(r + 1), n1: String(c + 1) }),
|
|
8597
|
+
onClick: () => change((previous) => {
|
|
8598
|
+
const next = passOf(previous);
|
|
8599
|
+
next[index] = (next[index] + 1) % 3;
|
|
8600
|
+
return next;
|
|
8601
|
+
})
|
|
8602
|
+
});
|
|
8603
|
+
})))), h("div", { className: "SPR_mapEdLegend" }, h("span", null, h("i", { style: { background: "rgba(226,59,43,.75)" } }), T("墙 · 不可通过")), h("span", null, h("i", { style: { background: "rgba(52,120,246,.75)" } }), T("走·前 · 角色盖住它")), h("span", null, h("i", { style: { background: "rgba(52,190,120,.75)" } }), T("走·后 · 它盖住角色"))), h("div", { className: "SPR_mapEdDlgRow" }, h(Btn, { "data-testid": `${prefix}-pass-none`, onClick: () => change(() => new Array(cols * rows).fill(0)) }, T("全部不可通过")), h(Btn, { "data-testid": `${prefix}-pass-walk`, onClick: () => change(() => new Array(cols * rows).fill(1)) }, T("全部可通过"))), h("p", { className: "SPR_mapEdHint" }, T("点格子换状态:墙 = 不可通过;走·前 = 能走、角色画在它上面(地毯);走·后 = 能走、它画在角色上面(雕像上身,绕后)。")));
|
|
8604
|
+
};
|
|
8269
8605
|
/**
|
|
8270
8606
|
* 「素材说明」的三页:一张示例图 + 几句人话,讲清每种素材图该**怎么排**。
|
|
8271
8607
|
*
|
|
@@ -8440,13 +8776,13 @@ window.__ModuleLoader__.load({
|
|
|
8440
8776
|
? h("div", { "data-testid": "map-add-stamp" }, h("div", { className: "SPR_mapEdDlgLabel" }, T("占几格(一整张图印满这么多格)")), h("div", { className: "SPR_mapEdPair" }, h(NumField, {
|
|
8441
8777
|
label: T("宽"),
|
|
8442
8778
|
value: Number(addDraft.stampCols) || 3,
|
|
8443
|
-
min:
|
|
8779
|
+
min: 1,
|
|
8444
8780
|
max: mapLimits.maxCols,
|
|
8445
8781
|
onChange: (value) => setAddDraft((current) => resizeStampPass(current, value, undefined))
|
|
8446
8782
|
}), h("span", { className: "SPR_mapEdTimes" }, "×"), h(NumField, {
|
|
8447
8783
|
label: T("高"),
|
|
8448
8784
|
value: Number(addDraft.stampRows) || 3,
|
|
8449
|
-
min:
|
|
8785
|
+
min: 1,
|
|
8450
8786
|
max: mapLimits.maxRows,
|
|
8451
8787
|
onChange: (value) => setAddDraft((current) => resizeStampPass(current, undefined, value))
|
|
8452
8788
|
})), h("div", { className: "SPR_mapEdDlgLabel" }, T("帧数(一整张图会动的话,每帧一张)")), h(NumField, {
|
|
@@ -8460,69 +8796,17 @@ window.__ModuleLoader__.load({
|
|
|
8460
8796
|
"data-testid": "map-add-stamp-key",
|
|
8461
8797
|
checked: addDraft.stampKey !== false,
|
|
8462
8798
|
onChange: (event) => setAddDraft((current) => (current === null ? current : { ...current, stampKey: event.target.checked }))
|
|
8463
|
-
}), T("
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
backgroundImage: stampPreviewUrl === undefined ? "none" : `url("${stampPreviewUrl}")`,
|
|
8475
|
-
/**
|
|
8476
|
-
* 帧数 > 1 时草稿里那张图是**各帧竖排**的(AI 那条路的格式):
|
|
8477
|
-
* 只铺第 1 帧,不然格子与画面对不上(用户会点错格)。
|
|
8478
|
-
*/
|
|
8479
|
-
backgroundSize: (Number(addDraft.stampFrames) || 1) > 1 ? `100% ${(Number(addDraft.stampFrames) || 1) * 100}%` : "100% 100%",
|
|
8480
|
-
backgroundPosition: "0% 0%"
|
|
8481
|
-
}
|
|
8482
|
-
}, h("div", {
|
|
8483
|
-
className: "SPR_mapEdStampGrid",
|
|
8484
|
-
style: {
|
|
8485
|
-
gridTemplateColumns: `repeat(${clampStampSpan(Number(addDraft.stampCols) || 3, mapLimits.maxCols)}, 1fr)`,
|
|
8486
|
-
gridTemplateRows: `repeat(${clampStampSpan(Number(addDraft.stampRows) || 3, mapLimits.maxRows)}, 1fr)`
|
|
8487
|
-
}
|
|
8488
|
-
}, Array.from({ length: clampStampSpan(Number(addDraft.stampRows) || 3, mapLimits.maxRows) }, (_unused, r) => Array.from({ length: clampStampSpan(Number(addDraft.stampCols) || 3, mapLimits.maxCols) }, (_ignored, c) => {
|
|
8489
|
-
const cols = clampStampSpan(Number(addDraft.stampCols) || 3, mapLimits.maxCols);
|
|
8490
|
-
const index = r * cols + c;
|
|
8491
|
-
const kind = addDraft.stampPass[index] ?? 0;
|
|
8492
|
-
return h("button", {
|
|
8493
|
-
key: `cell${r}-${c}`,
|
|
8494
|
-
type: "button",
|
|
8495
|
-
className: "SPR_mapEdStampCell",
|
|
8496
|
-
"data-pass": String(kind),
|
|
8497
|
-
"data-testid": `map-add-pass-${r}-${c}`,
|
|
8498
|
-
title: T("第 {n0} 行第 {n1} 列:不可通过 / 可通过(被人物遮挡)/ 可通过(遮挡人物)", { n0: String(r + 1), n1: String(c + 1) }),
|
|
8499
|
-
onClick: () => setAddDraft((current) => {
|
|
8500
|
-
if (current === null)
|
|
8501
|
-
return current;
|
|
8502
|
-
const next = [...current.stampPass];
|
|
8503
|
-
next[index] = (((next[index] ?? 0) + 1) % 3);
|
|
8504
|
-
return { ...current, stampPass: next };
|
|
8505
|
-
})
|
|
8506
|
-
});
|
|
8507
|
-
})))), h("div", { className: "SPR_mapEdLegend" }, h("span", null, h("i", { style: { background: "rgba(226,59,43,.75)" } }), T("墙 · 不可通过")), h("span", null, h("i", { style: { background: "rgba(52,120,246,.75)" } }), T("走·前 · 角色盖住它")), h("span", null, h("i", { style: { background: "rgba(52,190,120,.75)" } }), T("走·后 · 它盖住角色"))), h("div", { className: "SPR_mapEdDlgRow" }, h(Btn, {
|
|
8508
|
-
"data-testid": "map-add-pass-none",
|
|
8509
|
-
onClick: () => setAddDraft((current) => {
|
|
8510
|
-
if (current === null)
|
|
8511
|
-
return current;
|
|
8512
|
-
const cols = clampStampSpan(Number(current.stampCols) || 3, mapLimits.maxCols);
|
|
8513
|
-
const rows = clampStampSpan(Number(current.stampRows) || 3, mapLimits.maxRows);
|
|
8514
|
-
return { ...current, stampPass: new Array(cols * rows).fill(0) };
|
|
8515
|
-
})
|
|
8516
|
-
}, T("全部不可通过")), h(Btn, {
|
|
8517
|
-
"data-testid": "map-add-pass-walk",
|
|
8518
|
-
onClick: () => setAddDraft((current) => {
|
|
8519
|
-
if (current === null)
|
|
8520
|
-
return current;
|
|
8521
|
-
const cols = clampStampSpan(Number(current.stampCols) || 3, mapLimits.maxCols);
|
|
8522
|
-
const rows = clampStampSpan(Number(current.stampRows) || 3, mapLimits.maxRows);
|
|
8523
|
-
return { ...current, stampPass: new Array(cols * rows).fill(1) };
|
|
8524
|
-
})
|
|
8525
|
-
}, T("全部可通过"))), h("p", { className: "SPR_mapEdHint" }, T("点格子换状态:墙 = 不可通过;走·前 = 能走、角色画在它上面(地毯);走·后 = 能走、它画在角色上面(雕像上身,绕后)。")))
|
|
8799
|
+
}), T("抠掉背景色(只留建筑本体)")), addDraft.stampKey !== false ? h(KeyColorField, { value: addDraft.stampKeyColor ?? globalConfig?.keyColor, onChange: (value) => setAddDraft((current) => (current === null ? current : { ...current, stampKeyColor: value })) }) : null, h("p", { className: "SPR_mapEdHint" }, T("整图是「立在格子上的物件」:背景该是透明的,不然地图上会多出一块绿框。AI 生成的图请在提示词里要**纯绿背景**,这里勾上就会自动抠掉;自己导的透明 PNG 也可以勾着(没有绿就什么都不做)。")), stampPassGrid({
|
|
8800
|
+
cols: clampStampSpan(Number(addDraft.stampCols) || 3, mapLimits.maxCols),
|
|
8801
|
+
rows: clampStampSpan(Number(addDraft.stampRows) || 3, mapLimits.maxRows),
|
|
8802
|
+
frames: Number(addDraft.stampFrames) || 1,
|
|
8803
|
+
pass: addDraft.stampPass,
|
|
8804
|
+
image: stampPreviewUrl,
|
|
8805
|
+
prefix: "map-add",
|
|
8806
|
+
onChange: (update) => setAddDraft((current) => current === null
|
|
8807
|
+
? current
|
|
8808
|
+
: { ...current, stampPass: typeof update === "function" ? update(current.stampPass) : update })
|
|
8809
|
+
}))
|
|
8526
8810
|
: null,
|
|
8527
8811
|
/**
|
|
8528
8812
|
* 「循环方式」:跟「动画速度」一样,**只有会动的素材才显示**。
|
|
@@ -8583,6 +8867,8 @@ window.__ModuleLoader__.load({
|
|
|
8583
8867
|
frames: 1,
|
|
8584
8868
|
mode: "image",
|
|
8585
8869
|
shape: "auto",
|
|
8870
|
+
// 抠像底色:默认跟全局,用户也可以在对话框里单独改。
|
|
8871
|
+
keyColor: globalConfig?.keyColor,
|
|
8586
8872
|
// 整图:占几格(只有选「整图」时才用得上;默认 3×3 是雕像 / 大门最常见的尺寸)。
|
|
8587
8873
|
stampCols: "3",
|
|
8588
8874
|
stampRows: "3"
|
|
@@ -8599,8 +8885,8 @@ window.__ModuleLoader__.load({
|
|
|
8599
8885
|
}
|
|
8600
8886
|
// 帧数为 1 只用生图模型(视频模型那条路本来也要求帧数大于 1);整格没有帧这一维。
|
|
8601
8887
|
const shape = ASSET_SHAPES.includes(draft.shape) ? draft.shape : "auto";
|
|
8602
|
-
const stampCols = Math.max(
|
|
8603
|
-
const stampRows = Math.max(
|
|
8888
|
+
const stampCols = Math.max(1, Math.min(512, Math.round(Number(draft.stampCols) || 3)));
|
|
8889
|
+
const stampRows = Math.max(1, Math.min(512, Math.round(Number(draft.stampRows) || 3)));
|
|
8604
8890
|
const frames = shape === "corner16" ? ASSET_FRAMES_MIN : Math.min(ASSET_FRAMES_MAX, Math.max(ASSET_FRAMES_MIN, Math.round(Number(draft.frames) || 1)));
|
|
8605
8891
|
const mode = frames <= 1 ? "image" : draft.mode === "video" ? "video" : "image";
|
|
8606
8892
|
// 派活要用到的模块被「功能管理」隐藏了就直说:对话里的工具面同样会拒绝,白跑一趟。
|
|
@@ -8620,6 +8906,7 @@ window.__ModuleLoader__.load({
|
|
|
8620
8906
|
const loaded = await api.getMapProject({ projectId, lang: activeLang() });
|
|
8621
8907
|
const grid = (loaded !== null && loaded !== undefined && loaded.grid) || { tileWidth: 32, tileHeight: 32 };
|
|
8622
8908
|
const name = draft.name.trim() === "" ? deriveAssetName(prompt) : draft.name.trim();
|
|
8909
|
+
const cfg = typeof api.getConfig === "function" ? await api.getConfig().catch(() => null) : null;
|
|
8623
8910
|
const text = buildAssetRequestPrompt({
|
|
8624
8911
|
projectId,
|
|
8625
8912
|
projectName: (loaded !== null && loaded !== undefined && loaded.name) || "",
|
|
@@ -8629,6 +8916,7 @@ window.__ModuleLoader__.load({
|
|
|
8629
8916
|
frames,
|
|
8630
8917
|
mode,
|
|
8631
8918
|
shape,
|
|
8919
|
+
keyColor: draft.keyColor || cfg?.keyColor,
|
|
8632
8920
|
...(shape === "stamp" ? { stampCols, stampRows } : {})
|
|
8633
8921
|
});
|
|
8634
8922
|
await openAssetChat(text);
|
|
@@ -8671,7 +8959,7 @@ window.__ModuleLoader__.load({
|
|
|
8671
8959
|
value: aiDraft.name,
|
|
8672
8960
|
placeholder: T("留空就用提示词开头几个字"),
|
|
8673
8961
|
onChange: (event) => setAiDraft((current) => (current === null ? current : { ...current, name: event.target.value }))
|
|
8674
|
-
}), h("div", { className: "SPR_mapEdDlgLabel" }, T("动画帧数(1 = 静态)")), h("div", { className: "SPR_mapEdPair" }, h(NumField, {
|
|
8962
|
+
}), h(KeyColorField, { label: T("抠像背景色"), value: aiDraft.keyColor ?? globalConfig?.keyColor, onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, keyColor: value })) }), h("div", { className: "SPR_mapEdDlgLabel" }, T("动画帧数(1 = 静态)")), h("div", { className: "SPR_mapEdPair" }, h(NumField, {
|
|
8675
8963
|
label: T("帧"),
|
|
8676
8964
|
value: aiDraft.frames,
|
|
8677
8965
|
min: ASSET_FRAMES_MIN,
|
|
@@ -8711,15 +8999,15 @@ window.__ModuleLoader__.load({
|
|
|
8711
8999
|
? h("div", { "data-testid": "map-ai-stamp" }, h("div", { className: "SPR_mapEdLblSmall" }, T("占几格")), h("div", { className: "SPR_mapEdPair" }, h(NumField, {
|
|
8712
9000
|
label: T("宽"),
|
|
8713
9001
|
value: Number(aiDraft.stampCols) || 3,
|
|
8714
|
-
min:
|
|
9002
|
+
min: 1,
|
|
8715
9003
|
max: 512,
|
|
8716
|
-
onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, stampCols: String(Math.max(
|
|
9004
|
+
onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, stampCols: String(Math.max(1, Math.min(512, Math.round(value) || 3))) }))
|
|
8717
9005
|
}), h("span", { className: "SPR_mapEdTimes" }, "×"), h(NumField, {
|
|
8718
9006
|
label: T("高"),
|
|
8719
9007
|
value: Number(aiDraft.stampRows) || 3,
|
|
8720
|
-
min:
|
|
9008
|
+
min: 1,
|
|
8721
9009
|
max: 512,
|
|
8722
|
-
onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, stampRows: String(Math.max(
|
|
9010
|
+
onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, stampRows: String(Math.max(1, Math.min(512, Math.round(value) || 3))) }))
|
|
8723
9011
|
})))
|
|
8724
9012
|
: null, h("p", { className: "SPR_mapEdHint" }, aiDraft.shape === "stamp"
|
|
8725
9013
|
? T("整图:让模型画**一整张**画(不要分格),插件按「占几格」把它切成 N×M 格,印到地图上一次占这么多格。帧数 > 1 时每帧都是一整张画。哪些格能走(地毯 / 雕像上身)在导入时由你自己点。")
|
|
@@ -8744,12 +9032,13 @@ window.__ModuleLoader__.load({
|
|
|
8744
9032
|
/**
|
|
8745
9033
|
* 「素材属性」窗口:点素材列表里的一行就打开。
|
|
8746
9034
|
*
|
|
8747
|
-
*
|
|
8748
|
-
*
|
|
8749
|
-
*
|
|
9035
|
+
* 放开的是**不动几何 / 不动图块序号**的属性:名字 / 播放速度 / 循环方式 / 整图的逐格通行区域。
|
|
9036
|
+
* 这几样改完,地图上已经画好的格子不受影响(整图的新区域下一次 `mapPlan` 就生效)。
|
|
9037
|
+
* 形态 / 格子尺寸仍然一次定死(那会重切图块、把画过的格子整体错位)。
|
|
8750
9038
|
*/
|
|
8751
9039
|
const [tsEdit, setTsEdit] = React.useState(null);
|
|
8752
9040
|
const openTilesetEditor = (entry) => {
|
|
9041
|
+
const stamp = entry.stamp;
|
|
8753
9042
|
setTsEdit({
|
|
8754
9043
|
tilesetId: entry.id,
|
|
8755
9044
|
name: entry.name,
|
|
@@ -8757,7 +9046,22 @@ window.__ModuleLoader__.load({
|
|
|
8757
9046
|
fps: entry.fps === undefined ? "" : String(entry.fps),
|
|
8758
9047
|
loop: entry.loop === undefined ? "forward" : entry.loop,
|
|
8759
9048
|
animated: frameCountOf(entry) > 0,
|
|
8760
|
-
builtin: entry.builtin === true
|
|
9049
|
+
builtin: entry.builtin === true,
|
|
9050
|
+
// 素材图 + 版本号:整图的区域编辑要在**真素材图**上点格子。
|
|
9051
|
+
file: entry.file,
|
|
9052
|
+
rev: entry.rev,
|
|
9053
|
+
/**
|
|
9054
|
+
* 仅整图:占几格 / 几帧 / 每格通行区域。
|
|
9055
|
+
* `undefined` = 这不是整图,窗口里不出现「哪些格子能走」。
|
|
9056
|
+
*/
|
|
9057
|
+
stampCols: stamp === undefined ? undefined : stamp.cols,
|
|
9058
|
+
stampRows: stamp === undefined ? undefined : stamp.rows,
|
|
9059
|
+
stampFrames: stamp === undefined ? 1 : stamp.frames,
|
|
9060
|
+
stampPass: stamp === undefined
|
|
9061
|
+
? undefined
|
|
9062
|
+
: Array.isArray(stamp.pass) && stamp.pass.length === stamp.cols * stamp.rows
|
|
9063
|
+
? [...stamp.pass]
|
|
9064
|
+
: new Array(stamp.cols * stamp.rows).fill(0)
|
|
8761
9065
|
});
|
|
8762
9066
|
};
|
|
8763
9067
|
const saveTilesetEditor = async () => {
|
|
@@ -8772,7 +9076,9 @@ window.__ModuleLoader__.load({
|
|
|
8772
9076
|
name,
|
|
8773
9077
|
// 空串 = 清掉自己的速度,回到跟「设置」里的动画速度走。
|
|
8774
9078
|
fps: tsEdit.fps === "" ? null : Number(tsEdit.fps),
|
|
8775
|
-
loop: tsEdit.loop
|
|
9079
|
+
loop: tsEdit.loop,
|
|
9080
|
+
// 仅整图:逐格通行区域(不动几何 / 序号,已经印在地图上的整图下一次就生效)。
|
|
9081
|
+
stampPass: tsEdit.stampCols === undefined ? undefined : tsEdit.stampPass
|
|
8776
9082
|
});
|
|
8777
9083
|
if (result !== undefined && Array.isArray(result.warnings) && result.warnings.length > 0) {
|
|
8778
9084
|
setNotice({ kind: "info", text: result.warnings.join(";") });
|
|
@@ -9225,7 +9531,30 @@ window.__ModuleLoader__.load({
|
|
|
9225
9531
|
value: tsEdit.name,
|
|
9226
9532
|
placeholder: T("留空就用原来的名字"),
|
|
9227
9533
|
onChange: (event) => setTsEdit((current) => (current === null ? current : { ...current, name: event.target.value }))
|
|
9228
|
-
}),
|
|
9534
|
+
}),
|
|
9535
|
+
/**
|
|
9536
|
+
* 整图:**在真素材图上点格子**改通行区域。
|
|
9537
|
+
*
|
|
9538
|
+
* 贴的是烘过 4 个旋转的成品图(第 1 帧 rot0 那块在最上面),所以铺图比例要按
|
|
9539
|
+
* `max(cols, rows)` 的真实行宽算;只改数据、不动几何与序号,已印在地图上的整图
|
|
9540
|
+
* 下一次 `mapPlan` 就换成新区域。
|
|
9541
|
+
*/
|
|
9542
|
+
tsEdit.stampCols === undefined
|
|
9543
|
+
? null
|
|
9544
|
+
: stampPassGrid({
|
|
9545
|
+
cols: tsEdit.stampCols,
|
|
9546
|
+
rows: tsEdit.stampRows,
|
|
9547
|
+
frames: tsEdit.stampFrames,
|
|
9548
|
+
pass: tsEdit.stampPass,
|
|
9549
|
+
sheetWidthCells: Math.max(tsEdit.stampCols, tsEdit.stampRows),
|
|
9550
|
+
image: `${assetBase}${tsEdit.file}${tsEdit.rev === undefined ? "" : `?v=${tsEdit.rev}`}`,
|
|
9551
|
+
prefix: "map-tsedit",
|
|
9552
|
+
onChange: (update) => setTsEdit((current) => current === null
|
|
9553
|
+
? current
|
|
9554
|
+
: { ...current, stampPass: typeof update === "function" ? update(current.stampPass) : update })
|
|
9555
|
+
}), tsEdit.stampCols === undefined
|
|
9556
|
+
? null
|
|
9557
|
+
: h("p", { className: "SPR_mapEdHint" }, T("改完点「保存」:地图上这张素材的所有整图都会立刻改用新区域,不用重新印一遍。")), h("div", { className: "SPR_mapEdDlgLabel" }, T("动画速度")), h("select", {
|
|
9229
9558
|
className: "SPR_mapEdSelect",
|
|
9230
9559
|
"data-testid": "map-tsedit-fps",
|
|
9231
9560
|
disabled: tsEdit.animated !== true,
|
|
@@ -9301,14 +9630,14 @@ window.__ModuleLoader__.load({
|
|
|
9301
9630
|
setMenuOpen(false);
|
|
9302
9631
|
void loadProject(entry.id);
|
|
9303
9632
|
}
|
|
9304
|
-
}, entry.name)));
|
|
9633
|
+
}, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, entry.name), h(CopyIdButton, { id: entry.id, inline: true })))));
|
|
9305
9634
|
const topBar = h("div", { className: "SPR_mapEdTop" }, h("div", { className: "SPR_mapEdProjWrap" }, h("button", {
|
|
9306
9635
|
type: "button",
|
|
9307
9636
|
className: "SPR_mapEdProj",
|
|
9308
9637
|
"data-open": menuOpen === true ? "true" : undefined,
|
|
9309
9638
|
"aria-expanded": menuOpen === true ? "true" : "false",
|
|
9310
9639
|
onClick: () => setMenuOpen(menuOpen !== true)
|
|
9311
|
-
}, h("span", { className: "SPR_mapEdProjName" }, view.name), h("span", { className: "SPR_mapEdCaret" }, "▾")), menuOpen === true ? menu : null), h("span", { className: "SPR_mapEdSpacer" }), h("button", {
|
|
9640
|
+
}, h("span", { className: "SPR_mapEdProjName" }, view.name), h("span", { className: "SPR_mapEdCaret" }, "▾")), menuOpen === true ? menu : null), h(CopyIdButton, { id: view.id }), h("span", { className: "SPR_mapEdSpacer" }), h("button", {
|
|
9312
9641
|
type: "button",
|
|
9313
9642
|
className: "SPR_mapEdTopBtn",
|
|
9314
9643
|
"data-on": openCard === "assets" ? "true" : undefined,
|
|
@@ -9481,10 +9810,16 @@ window.__ModuleLoader__.load({
|
|
|
9481
9810
|
/**
|
|
9482
9811
|
* 这张素材有几帧(列表上的徽章用)。
|
|
9483
9812
|
*
|
|
9484
|
-
*
|
|
9485
|
-
* —— 宿主算好的 `variants`
|
|
9813
|
+
* 三种会动的情形都算进来:`a2quad` 的**变体就是帧**、`animRows`(翻页图)的**行数就是帧**、
|
|
9814
|
+
* 整图的 `stamp.frames` 就是帧 —— 宿主算好的 `variants` 在前两种情形下都正好是帧数。
|
|
9486
9815
|
*/
|
|
9487
|
-
const frameCountOf = (entry) => entry.
|
|
9816
|
+
const frameCountOf = (entry) => entry.stamp !== undefined && (entry.stamp.frames ?? 1) > 1
|
|
9817
|
+
? entry.stamp.frames
|
|
9818
|
+
: entry.animRows === true
|
|
9819
|
+
? entry.variants
|
|
9820
|
+
: entry.shape === "a2quad" && entry.variants > 1
|
|
9821
|
+
? entry.variants
|
|
9822
|
+
: 0;
|
|
9488
9823
|
const assetsCard = h("div", { className: "SPR_mapEdCard", "data-testid": "map-assets-card" }, cardHead(T("素材")), h("div", { className: "SPR_mapEdCardRow" }, h(Btn, { "data-testid": "map-add-open", primary: true, onClick: openAddTileset }, T("新增素材")),
|
|
9489
9824
|
// 「AI 生成素材」:不在这里生成,开一个新对话把需求发过去(见 aiDialog)。
|
|
9490
9825
|
h(Btn, { "data-testid": "map-ai-open", onClick: openAiAsset }, T("AI 生成素材")), h(Btn, { onClick: () => void restoreSamples(), busy: busyKey === "sample" }, T("恢复默认素材"))), tilesets.length === 0
|
|
@@ -9493,7 +9828,7 @@ window.__ModuleLoader__.load({
|
|
|
9493
9828
|
type: "button",
|
|
9494
9829
|
className: "SPR_mapEdTsPick",
|
|
9495
9830
|
"data-tileset": entry.id,
|
|
9496
|
-
title: T("点一下改它的名字 / 播放速度 / 循环方式"),
|
|
9831
|
+
title: T("点一下改它的名字 / 播放速度 / 循环方式 / 整图的通行区域"),
|
|
9497
9832
|
onClick: () => {
|
|
9498
9833
|
// 点一下 = 选中它(当笔刷用)+ 打开属性窗口(改名 / 速度 / 循环方式)
|
|
9499
9834
|
setTsIndex(index);
|
|
@@ -9503,7 +9838,7 @@ window.__ModuleLoader__.load({
|
|
|
9503
9838
|
? h("span", { className: "SPR_mapEdTsBadge", "data-anim": "true" }, entry.fps === undefined
|
|
9504
9839
|
? T("会动 {n0} 帧", { n0: String(frameCountOf(entry)) })
|
|
9505
9840
|
: T("会动 {n0} 帧 · {n1} 帧/秒", { n0: String(frameCountOf(entry)), n1: String(entry.fps) }))
|
|
9506
|
-
: null, entry.builtin === true ? h("span", { className: "SPR_mapEdTsBadge" }, T("自带")) : null), h(Btn, { danger: true, onClick: () => void removeTilesetById(entry.id, entry.name) }, T("删除"))))), h("p", { className: "SPR_mapEdHint" }, T("点素材那一行可以改**名字 / 播放速度 /
|
|
9841
|
+
: null, entry.builtin === true ? h("span", { className: "SPR_mapEdTsBadge" }, T("自带")) : null), h(Btn, { danger: true, onClick: () => void removeTilesetById(entry.id, entry.name) }, T("删除"))))), h("p", { className: "SPR_mapEdHint" }, T("点素材那一行可以改**名字 / 播放速度 / 循环方式 / 整图的通行区域**(这些都不动图块,随时能改)。形态与格子大小在新增时就定下来了 —— 要换只能删掉重新新增。")));
|
|
9507
9842
|
/**
|
|
9508
9843
|
* 导出卡片 = **一次选完 → 一次导出 → 一次下载**。
|
|
9509
9844
|
*
|
|
@@ -10486,7 +10821,7 @@ window.__ModuleLoader__.load({
|
|
|
10486
10821
|
const planHead = plan === null
|
|
10487
10822
|
? ""
|
|
10488
10823
|
: [plan.style, plan.mood, plan.key, plan.tempo ? `${plan.tempo} BPM` : "", plan.timeSignature].filter(Boolean).join(" · ");
|
|
10489
|
-
return h("section", { className: "SPR_musicCard", "data-testid": "music-score" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, T("谱曲(本地 MIDI)")), selected !== null ? h(Chip, { kind: "ready", text: T("第 {n0} 版", { n0: compositions.indexOf(selected) + 1 }) }) : null, h("span", { className: "SPR_spacer" }), h(Btn, { onClick: () => void loadJob(job.id) }, T("重新读取"))), h("p", { className: "SPR_hint" }, T("谱曲与试听全在本地完成,免费;只有「交给 Suno」会消耗积分。每次修改都是新版本,旧版保留。")), plan !== null
|
|
10824
|
+
return h("section", { className: "SPR_musicCard", "data-testid": "music-score" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, T("谱曲(本地 MIDI)")), h(CopyIdButton, { id: job.id }), selected !== null ? h(Chip, { kind: "ready", text: T("第 {n0} 版", { n0: compositions.indexOf(selected) + 1 }) }) : null, h("span", { className: "SPR_spacer" }), h(Btn, { onClick: () => void loadJob(job.id) }, T("重新读取"))), h("p", { className: "SPR_hint" }, T("谱曲与试听全在本地完成,免费;只有「交给 Suno」会消耗积分。每次修改都是新版本,旧版保留。")), plan !== null
|
|
10490
10825
|
? h("div", { className: "SPR_scorePlan" }, h("div", { className: "SPR_musicMeta" }, planHead || T("(方案已保存)")), plan.summary ? h("pre", { className: "SPR_musicSourceText" }, plan.summary) : null, (plan.structure ?? []).length > 0
|
|
10491
10826
|
? h("div", { className: "SPR_scoreStructure" }, (plan.structure ?? []).map((section, index) => h("span", { key: index, className: "SPR_chip" }, `${section.name}${section.bars ? ` ${section.bars}小节` : ""}${section.energy ? ` ${section.energy}` : ""}`)))
|
|
10492
10827
|
: null, (plan.instrumentation ?? []).length > 0
|
|
@@ -10520,7 +10855,7 @@ window.__ModuleLoader__.load({
|
|
|
10520
10855
|
? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text, h("button", { type: "button", className: "SPR_miniBtn", style: { marginLeft: 10 }, onClick: () => setNotice(null) }, T("关闭")))
|
|
10521
10856
|
: null, job === null
|
|
10522
10857
|
? h(React.Fragment, null, loading ? h("p", { className: "SPR_empty" }, T("正在载入…")) : null, !loading ? h(React.Fragment, null, createOpen || jobs.length === 0 ? createCard() : h("p", { className: "SPR_empty" }, T("从左侧选一个音乐任务,或点「新建音乐」开始。")), h("div", { className: "SPR_toolbar" }, h(Btn, { primary: true, onClick: () => setCreateOpen(true) }, T("新建音乐")))) : null)
|
|
10523
|
-
: h(React.Fragment, null, h("section", { className: "SPR_musicCard" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, job.name), job.workflow === "compose" ? h(Chip, { kind: "stale", text: T("谱曲模式") }) : null, h("span", { className: "SPR_musicMeta" }, job.workflow === "compose"
|
|
10858
|
+
: h(React.Fragment, null, h("section", { className: "SPR_musicCard" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, job.name), h(CopyIdButton, { id: job.id }), job.workflow === "compose" ? h(Chip, { kind: "stale", text: T("谱曲模式") }) : null, h("span", { className: "SPR_musicMeta" }, job.workflow === "compose"
|
|
10524
10859
|
? T("谱曲 {n0} 版 · {n1}/{n2} 首就绪 · {n3} 个版本", { n0: (job.compositions ?? []).length, n1: job.songsReady ?? 0, n2: job.songsTotal ?? 0, n3: (job.versions ?? []).filter((entry) => entry.status === "ready").length })
|
|
10525
10860
|
: T("{n0}/{n1} 首就绪 · {n2} 个版本", { n0: job.songsReady ?? 0, n1: job.songsTotal ?? 0, n2: (job.versions ?? []).filter((entry) => entry.status === "ready").length })), job.busy === true ? h(BusyBadge, { show: true, text: T("有任务在跑…") }) : null, h("span", { className: "SPR_spacer" }), h(Btn, { onClick: () => void refresh() }, T("刷新")), h(Btn, { onClick: () => void reveal() }, T("打开任务目录")), h(Btn, { danger: true, onClick: () => void removeJob() }, T("删除任务"))), h(ReviewModeBar, { api, module: "music", id: job.id, mode: job.reviewMode, onChanged: () => void loadJob(job.id) }), h("div", { className: "SPR_musicSource" }, h("strong", null, job.source?.kind === "lyrics" ? T("完整歌词") : T("灵感提示词")), job.source?.title ? h("span", { className: "SPR_musicMeta" }, T("标题:{n0}", { n0: job.source.title })) : null, job.source?.note ? h("p", { className: "SPR_hint" }, T("补充要求:{n0}", { n0: job.source.note })) : null, h("pre", { className: "SPR_musicSourceText" }, job.source?.kind === "lyrics" ? job.source?.lyrics ?? "" : job.source?.prompt ?? ""), job.source?.adaptedPrompt ? h("details", null, h("summary", null, T("AI 扩写提示词")), h("pre", { className: "SPR_musicSourceText" }, job.source.adaptedPrompt)) : null, job.source?.adaptedLyrics ? h("details", null, h("summary", null, T("AI 扩写歌词")), h("pre", null, job.source.adaptedLyrics)) : null, job.source?.adaptedTags ? h("p", { className: "SPR_hint" }, T("风格标签:{n0}", { n0: job.source.adaptedTags })) : null), config?.musicBlocker !== null && config?.musicBlocker !== undefined ? h("div", { className: "SPR_note", "data-kind": "error" }, config.musicBlocker) : null, h("div", { className: "SPR_toolbar" }, h(Btn, { primary: true, onClick: () => setCreateOpen((value) => !value) }, createOpen ? T("收起新建") : T("新建音乐")), h(Btn, { onClick: () => void openGuide() }, showGuide ? T("收起创作技巧") : T("创作技巧")), h(Btn, { onClick: () => void loadJob(job.id) }, T("重新读取"))), createOpen ? createCard() : null, showGuide ? h("div", { className: "SPR_musicGuide" }, guide === null ? h("p", { className: "SPR_hint" }, T("正在读取创作指南…")) : h("pre", { className: "SPR_musicGuideText" }, guide.guide ?? "")) : null), scoreCard(), h("section", { className: "SPR_musicCard" }, h("h3", null, T("歌曲")), (() => {
|
|
10526
10861
|
const pending = (job.generations ?? []).find((generation) => generation.status === "submitting" || generation.status === "polling");
|
|
@@ -10534,7 +10869,7 @@ window.__ModuleLoader__.load({
|
|
|
10534
10869
|
: null));
|
|
10535
10870
|
return h("div", { className: "SPR_body SPR_musicBody" }, h("div", { className: "SPR_side" }, h("div", { className: "SPR_sideTitle" }, T("音乐任务({n0})", { n0: jobs.length })), h(Btn, { primary: true, onClick: () => { setCreateOpen(true); setJob(null); } }, T("新建音乐")), jobs.length === 0
|
|
10536
10871
|
? h("p", { className: "SPR_hint" }, T("还没有任务。写一段灵感或贴一首歌词开始。"))
|
|
10537
|
-
: jobs.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_projItem", "data-active": entry.id === jobId ? "true" : "false", onClick: () => void loadJob(entry.id) }, h("span", { className: "SPR_projName" }, entry.name), h("span", { className: "SPR_projMeta" }, entry.workflow === "compose"
|
|
10872
|
+
: jobs.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_projItem", "data-active": entry.id === jobId ? "true" : "false", onClick: () => void loadJob(entry.id) }, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, entry.name), h(CopyIdButton, { id: entry.id, inline: true })), h("span", { className: "SPR_projMeta" }, entry.workflow === "compose"
|
|
10538
10873
|
? T("谱曲 {n0} 版 · {n1}/{n2} 首", { n0: entry.compositions ?? 0, n1: entry.songsReady, n2: entry.songsTotal })
|
|
10539
10874
|
: T("{n0}/{n1} 首 · {n2} 个版本", { n0: entry.songsReady, n1: entry.songsTotal, n2: entry.versions }))))), main);
|
|
10540
10875
|
}
|
|
@@ -10889,7 +11224,7 @@ window.__ModuleLoader__.load({
|
|
|
10889
11224
|
: null;
|
|
10890
11225
|
const main = h("div", { className: "SPR_main" }, notice !== null ? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text) : null, createCard, job === null
|
|
10891
11226
|
? h("p", { className: "SPR_empty" }, T("左侧选一个音效任务,或点「新建音效」开始。"))
|
|
10892
|
-
: h(React.Fragment, null, h("section", { className: "SPR_musicCard", "data-testid": "sfx-job" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, job.name), h(Chip, { kind: job.busy ? "running" : job.status === "error" ? "error" : takes.length > 0 ? "ready" : "stale", text: job.busy ? T("生成中…") : job.status === "error" ? T("失败") : takes.length > 0 ? T("已完成") : T("还没生成") }), job.reviewMode ? h("span", { className: "SPR_musicMeta" }, job.reviewMode === "manual" ? T("每一步人工审核") : T("自动审核")) : null, h("span", { className: "SPR_musicMeta" }, T("{n0} 条生成 · 上限 120 秒", { n0: takes.length }))), blocker !== null ? h("div", { className: "SPR_note", "data-kind": "error" }, blocker) : null, job.error ? h("div", { className: "SPR_note", "data-kind": "error" }, job.error) : null, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("提示词({n0}/2048)", { n0: promptDraft.length })), h("textarea", {
|
|
11227
|
+
: h(React.Fragment, null, h("section", { className: "SPR_musicCard", "data-testid": "sfx-job" }, h("div", { className: "SPR_musicJobHead" }, h("h3", null, job.name), h(CopyIdButton, { id: job.id }), h(Chip, { kind: job.busy ? "running" : job.status === "error" ? "error" : takes.length > 0 ? "ready" : "stale", text: job.busy ? T("生成中…") : job.status === "error" ? T("失败") : takes.length > 0 ? T("已完成") : T("还没生成") }), job.reviewMode ? h("span", { className: "SPR_musicMeta" }, job.reviewMode === "manual" ? T("每一步人工审核") : T("自动审核")) : null, h("span", { className: "SPR_musicMeta" }, T("{n0} 条生成 · 上限 120 秒", { n0: takes.length }))), blocker !== null ? h("div", { className: "SPR_note", "data-kind": "error" }, blocker) : null, job.error ? h("div", { className: "SPR_note", "data-kind": "error" }, job.error) : null, h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("提示词({n0}/2048)", { n0: promptDraft.length })), h("textarea", {
|
|
10893
11228
|
className: "SPR_musicText",
|
|
10894
11229
|
"data-testid": "sfx-prompt",
|
|
10895
11230
|
rows: 4,
|
|
@@ -10913,7 +11248,7 @@ window.__ModuleLoader__.load({
|
|
|
10913
11248
|
: null)));
|
|
10914
11249
|
return h("div", { className: "SPR_body SPR_musicBody" }, h("div", { className: "SPR_side" }, h("div", { className: "SPR_sideTitle" }, T("音效任务({n0})", { n0: jobs.length })), h(Btn, { primary: true, "data-testid": "sfx-create-open", onClick: () => { setDraft({ name: "", prompt: "", format: config?.sfxFormat ?? "wav", sampleRate: config?.sfxSampleRate ?? 24000 }); setCreateOpen(true); setJob(null); setJobId(null); } }, T("新建音效")), jobs.length === 0
|
|
10915
11250
|
? h("p", { className: "SPR_hint" }, T("还没有任务。写一句「要什么声音」开始。"))
|
|
10916
|
-
: jobs.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_projItem", "data-active": entry.id === jobId ? "true" : "false", onClick: () => void loadJob(entry.id) }, h("span", { className: "SPR_projName" }, entry.name), h("span", { className: "SPR_projMeta" }, `${entry.takes ?? 0} 条${entry.latestDuration ? ` · ${Number(entry.latestDuration).toFixed(2)}s` : ""}${entry.busy ? " · ⏳" : ""}`)))), main);
|
|
11251
|
+
: jobs.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_projItem", "data-active": entry.id === jobId ? "true" : "false", onClick: () => void loadJob(entry.id) }, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, entry.name), h(CopyIdButton, { id: entry.id, inline: true })), h("span", { className: "SPR_projMeta" }, `${entry.takes ?? 0} 条${entry.latestDuration ? ` · ${Number(entry.latestDuration).toFixed(2)}s` : ""}${entry.busy ? " · ⏳" : ""}`)))), main);
|
|
10917
11252
|
}
|
|
10918
11253
|
// ── 模块②:图片生成 ─────────────────────────────────────────────────
|
|
10919
11254
|
/** 模块②的 pending key:整批生成、单张重生成、抠像、上传、新建任务。 */
|
|
@@ -11067,6 +11402,7 @@ window.__ModuleLoader__.load({
|
|
|
11067
11402
|
function IsoModule(props) {
|
|
11068
11403
|
useLocaleTick();
|
|
11069
11404
|
const api = props.api;
|
|
11405
|
+
const globalConfig = useGlobalConfig(api);
|
|
11070
11406
|
const intent = useStudioIntent();
|
|
11071
11407
|
const hiddenModules = useHiddenModules(api);
|
|
11072
11408
|
const [projects, setProjects] = React.useState([]);
|
|
@@ -11999,6 +12335,7 @@ window.__ModuleLoader__.load({
|
|
|
11999
12335
|
frames: 1,
|
|
12000
12336
|
mode: "image",
|
|
12001
12337
|
kind: "auto",
|
|
12338
|
+
keyColor: globalConfig?.keyColor,
|
|
12002
12339
|
footprint: { cols: 1, rows: 1 }
|
|
12003
12340
|
});
|
|
12004
12341
|
const submitIsoAiAsset = async () => {
|
|
@@ -12028,6 +12365,7 @@ window.__ModuleLoader__.load({
|
|
|
12028
12365
|
setAiBusy(true);
|
|
12029
12366
|
try {
|
|
12030
12367
|
const name = draft.name.trim() === "" ? deriveAssetName(prompt) : draft.name.trim();
|
|
12368
|
+
const cfg = typeof api.getConfig === "function" ? await api.getConfig().catch(() => null) : null;
|
|
12031
12369
|
const text = buildIsoAssetRequestPrompt({
|
|
12032
12370
|
projectId: view.id,
|
|
12033
12371
|
projectName: view.name,
|
|
@@ -12037,7 +12375,8 @@ window.__ModuleLoader__.load({
|
|
|
12037
12375
|
frames,
|
|
12038
12376
|
mode,
|
|
12039
12377
|
kind,
|
|
12040
|
-
footprint
|
|
12378
|
+
footprint,
|
|
12379
|
+
keyColor: draft.keyColor || cfg?.keyColor
|
|
12041
12380
|
});
|
|
12042
12381
|
await openIsoAssetChat(text);
|
|
12043
12382
|
setAiDraft(null);
|
|
@@ -12085,6 +12424,7 @@ window.__ModuleLoader__.load({
|
|
|
12085
12424
|
objectScale: 1,
|
|
12086
12425
|
passMode: 1,
|
|
12087
12426
|
keyGreen: target.keyed !== 1,
|
|
12427
|
+
keyColor: globalConfig?.keyColor,
|
|
12088
12428
|
clarity: "smooth"
|
|
12089
12429
|
};
|
|
12090
12430
|
setOpenCard("assets");
|
|
@@ -12130,6 +12470,7 @@ window.__ModuleLoader__.load({
|
|
|
12130
12470
|
objectScale: addDraft.kind === "object" ? Number(addDraft.objectScale) || 1 : undefined,
|
|
12131
12471
|
pass,
|
|
12132
12472
|
keyGreen: addDraft.keyGreen === true,
|
|
12473
|
+
keyColor: addDraft.keyGreen === true ? addDraft.keyColor : undefined,
|
|
12133
12474
|
clarity: addDraft.clarity
|
|
12134
12475
|
});
|
|
12135
12476
|
if (result !== undefined && Array.isArray(result.warnings) && result.warnings.length > 0)
|
|
@@ -12306,7 +12647,7 @@ window.__ModuleLoader__.load({
|
|
|
12306
12647
|
} }), addPreviewNode, h("label", { className: "SPR_isoLabel" }, T("叫什么")), h("input", { className: "SPR_isoInput", value: addDraft.name, onChange: (event) => setAddDraft((current) => ({ ...current, name: event.target.value })) }), h("label", { className: "SPR_isoLabel" }, T("这块素材怎么用")), h("select", { className: "SPR_isoInput", value: addDraft.kind, onChange: (event) => setAddDraft((current) => ({ ...current, kind: event.target.value })) }, h("option", { value: "ground" }, T("地面(网格图块)")), h("option", { value: "autotile" }, T("自动连接(4×4 = 16 块)")), h("option", { value: "object" }, T("物件(一张完整图,可占多格)"))), h("div", { className: "SPR_isoRow" }, h(NumField, { label: T("源图每格宽"), value: Number(addDraft.sourceW), min: 1, max: 512, onChange: (value) => setAddDraft((current) => ({ ...current, sourceW: value })) }), h(NumField, { label: T("源图每格高"), value: Number(addDraft.sourceH), min: 1, max: 768, onChange: (value) => setAddDraft((current) => ({ ...current, sourceH: value })) })), addDraft.kind === "ground"
|
|
12307
12648
|
? h("label", { className: "SPR_isoCheck" }, h("input", { type: "checkbox", checked: addDraft.animRows === true, onChange: (event) => setAddDraft((current) => ({ ...current, animRows: event.target.checked })) }), T("会动(每一行是一帧)"))
|
|
12308
12649
|
: null, addDraft.kind === "object"
|
|
12309
|
-
? h(React.Fragment, null, h("div", { className: "SPR_isoRow" }, h(NumField, { label: T("占几格宽"), value: Number(addDraft.footprint.cols), min: 1, max: 512, onChange: (value) => setAddDraft((current) => ({ ...current, footprint: { ...current.footprint, cols: value } })) }), h(NumField, { label: T("占几格高"), value: Number(addDraft.footprint.rows), min: 1, max: 512, onChange: (value) => setAddDraft((current) => ({ ...current, footprint: { ...current.footprint, rows: value } })) })), h(NumField, { label: T("帧数"), value: Number(addDraft.frames), min: 1, max: 64, onChange: (value) => setAddDraft((current) => ({ ...current, frames: value })) }), h("label", { className: "SPR_isoLabel" }, T("通行性")), h("select", { className: "SPR_isoInput", value: String(addDraft.passMode), onChange: (event) => setAddDraft((current) => ({ ...current, passMode: Number(event.target.value) })) }, h("option", { value: "1" }, T("可通过 · 角色在上面")), h("option", { value: "0" }, T("不可通过")), h("option", { value: "2" }, T("可通过 · 物件盖住角色"))), h("label", { className: "SPR_isoCheck" }, h("input", { type: "checkbox", checked: addDraft.keyGreen === true, onChange: (event) => setAddDraft((current) => ({ ...current, keyGreen: event.target.checked })) }), T("
|
|
12650
|
+
? h(React.Fragment, null, h("div", { className: "SPR_isoRow" }, h(NumField, { label: T("占几格宽"), value: Number(addDraft.footprint.cols), min: 1, max: 512, onChange: (value) => setAddDraft((current) => ({ ...current, footprint: { ...current.footprint, cols: value } })) }), h(NumField, { label: T("占几格高"), value: Number(addDraft.footprint.rows), min: 1, max: 512, onChange: (value) => setAddDraft((current) => ({ ...current, footprint: { ...current.footprint, rows: value } })) })), h(NumField, { label: T("帧数"), value: Number(addDraft.frames), min: 1, max: 64, onChange: (value) => setAddDraft((current) => ({ ...current, frames: value })) }), h("label", { className: "SPR_isoLabel" }, T("通行性")), h("select", { className: "SPR_isoInput", value: String(addDraft.passMode), onChange: (event) => setAddDraft((current) => ({ ...current, passMode: Number(event.target.value) })) }, h("option", { value: "1" }, T("可通过 · 角色在上面")), h("option", { value: "0" }, T("不可通过")), h("option", { value: "2" }, T("可通过 · 物件盖住角色"))), h("label", { className: "SPR_isoCheck" }, h("input", { type: "checkbox", checked: addDraft.keyGreen === true, onChange: (event) => setAddDraft((current) => ({ ...current, keyGreen: event.target.checked })) }), T("抠掉背景色")), addDraft.keyGreen === true ? h(KeyColorField, { value: addDraft.keyColor ?? globalConfig?.keyColor, onChange: (value) => setAddDraft((current) => ({ ...current, keyColor: value })) }) : null)
|
|
12310
12651
|
: null, h("label", { className: "SPR_isoLabel" }, T("清晰度")), h("select", { className: "SPR_isoInput", value: addDraft.clarity, onChange: (event) => setAddDraft((current) => ({ ...current, clarity: event.target.value })) }, h("option", { value: "smooth" }, T("平滑")), h("option", { value: "sharp" }, T("锐利")), h("option", { value: "crisp" }, T("清晰"))), h("div", { className: "SPR_isoRow" }, h(Btn, { onClick: () => setAddDraft(null) }, T("取消")), h(Btn, { primary: true, busy: busyKey === "import", onClick: () => void importAsset() }, T("确定")))));
|
|
12311
12652
|
const aiDialog = aiDraft === null ? null : h("div", { className: "SPR_isoDlgMask", onClick: () => (aiBusy ? undefined : setAiDraft(null)) }, h("div", { className: "SPR_isoDlg", role: "dialog", "aria-label": T("AI 生成素材"), "data-testid": "iso-ai-dialog", onClick: (event) => event.stopPropagation() }, h("div", { className: "SPR_isoDlgHead" }, h("b", null, T("AI 生成素材")), h("span", { style: { flex: 1 } }), h("button", { type: "button", className: "SPR_isoClose", onClick: () => (aiBusy ? undefined : setAiDraft(null)) }, "×")), h("p", { className: "SPR_isoHint" }, T("它会开一个新对话,让对话里的 agent 生成并整理;做完贴一条链接,点回来这张图就会填进「新增素材」。只支持地面 / 物件,自动连接仍走手工导入。")), h("label", { className: "SPR_isoLabel" }, T("提示词")), h("textarea", {
|
|
12312
12653
|
className: "SPR_isoInput",
|
|
@@ -12321,7 +12662,7 @@ window.__ModuleLoader__.load({
|
|
|
12321
12662
|
value: aiDraft.name,
|
|
12322
12663
|
placeholder: T("留空就用提示词开头几个字"),
|
|
12323
12664
|
onChange: (event) => setAiDraft((current) => (current === null ? current : { ...current, name: event.target.value }))
|
|
12324
|
-
}), h("label", { className: "SPR_isoLabel" }, T("动画帧数(1 = 静态)")), h(NumField, {
|
|
12665
|
+
}), h(KeyColorField, { label: T("抠像背景色"), value: aiDraft.keyColor ?? globalConfig?.keyColor, onChange: (value) => setAiDraft((current) => (current === null ? current : { ...current, keyColor: value })) }), h("label", { className: "SPR_isoLabel" }, T("动画帧数(1 = 静态)")), h(NumField, {
|
|
12325
12666
|
label: T("帧"),
|
|
12326
12667
|
value: aiDraft.frames,
|
|
12327
12668
|
min: ASSET_FRAMES_MIN,
|
|
@@ -12362,7 +12703,7 @@ window.__ModuleLoader__.load({
|
|
|
12362
12703
|
}
|
|
12363
12704
|
})() }, T("用自带素材试试"))), notice === null ? null : h("div", { className: `SPR_notice SPR_notice-${notice.kind}` }, notice.text))));
|
|
12364
12705
|
}
|
|
12365
|
-
const menu = h("div", { className: "SPR_isoMenu" }, h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); requestNewProject(); } }, T("新建项目")), h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); setNameAsk({ mode: "rename", title: T("重命名项目"), value: view.name }); } }, T("重命名")), h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); void deleteProject(); } }, T("删除项目")), h("div", { className: "SPR_isoMenuLabel" }, T("切换项目")), projects.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_isoMenuItem", "data-on": entry.id === view.id ? "true" : undefined, onClick: () => { setMenuOpen(false); void loadProject(entry.id); } }, entry.name)));
|
|
12706
|
+
const menu = h("div", { className: "SPR_isoMenu" }, h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); requestNewProject(); } }, T("新建项目")), h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); setNameAsk({ mode: "rename", title: T("重命名项目"), value: view.name }); } }, T("重命名")), h("button", { type: "button", className: "SPR_isoMenuItem", onClick: () => { setMenuOpen(false); void deleteProject(); } }, T("删除项目")), h("div", { className: "SPR_isoMenuLabel" }, T("切换项目")), projects.map((entry) => h("button", { key: entry.id, type: "button", className: "SPR_isoMenuItem", "data-on": entry.id === view.id ? "true" : undefined, onClick: () => { setMenuOpen(false); void loadProject(entry.id); } }, h("span", { className: "SPR_projNameRow" }, h("span", { className: "SPR_projName" }, entry.name), h(CopyIdButton, { id: entry.id, inline: true })))));
|
|
12366
12707
|
const palette = h("div", { className: "SPR_isoPalette" }, h("div", { className: "SPR_isoPaletteGrid" }, paletteEntries.map((entry) => {
|
|
12367
12708
|
const owner = entry.tileset;
|
|
12368
12709
|
const url = `${view.assetBase}${owner.file}?v=${owner.rev ?? 0}`;
|
|
@@ -12399,7 +12740,7 @@ window.__ModuleLoader__.load({
|
|
|
12399
12740
|
const tools = h("div", { className: "SPR_isoTools" }, toolButton("undo", T("撤销"), "undo", () => void doUndo(), { hint: "⌘Z", disabled: view.canUndo !== true }), toolButton("redo", T("重做"), "redo", () => void doRedo(), { hint: "⇧⌘Z", disabled: view.canRedo !== true }), toolButton("pen", T("画笔"), "pen", () => setTool("pen"), { on: tool === "pen", hint: "B" }), toolButton("eraser", T("橡皮"), "eraser", () => setTool("eraser"), { on: tool === "eraser", hint: "E" }), toolButton("bucket", T("油漆桶"), "bucket", () => setTool("bucket"), { on: tool === "bucket", hint: "G" }), toolButton("pipette", T("吸管"), "pipette", () => setTool("pipette"), { on: tool === "pipette", hint: "I" }), toolButton("hand", T("抓手"), "hand", () => setTool("hand"), { on: tool === "hand", hint: "H" }), toolButton("marker", T("标记"), "marker", () => setTool("marker"), { on: tool === "marker", hint: "M" }), h("button", { key: "layer", type: "button", className: "SPR_isoTool SPR_isoLayerBtn", title: T("图层"), onClick: () => setOpenCard(openCard === "layers" ? null : "layers") }, h("span", null, String(layerIndex + 1)), h("small", null, activeLayer?.kind === "object" ? T("物件") : T("地面"))), toolButton("grid", T("网格线"), "grid", () => setShowGrid((value) => value !== true), { on: showGrid === true }), toolButton("gen", T("一键生成"), "magic", () => setOpenCard(openCard === "gen" ? null : "gen"), { on: openCard === "gen" }), toolButton("settings", T("设置"), "settings", () => setOpenCard(openCard === "settings" ? null : "settings"), { on: openCard === "settings" }));
|
|
12400
12741
|
const side = h("div", { className: "SPR_isoSide" }, h("div", { className: "SPR_isoSideTitle" }, activeLayer?.kind === "object" ? T("物件调色板") : T("地面调色板")), palette, tools);
|
|
12401
12742
|
const cardHead = (title) => h("div", { className: "SPR_isoCardHead" }, h("b", null, title), h("span", { style: { flex: 1 } }), h("button", { type: "button", className: "SPR_isoClose", onClick: () => setOpenCard(null) }, "×"));
|
|
12402
|
-
const assetsCard = h("div", { className: "SPR_isoCard" }, cardHead(T("素材")), h("div", { className: "SPR_isoRow" }, h(Btn, { primary: true, onClick: () => { setAddDraft({ base64: "", name: "", kind: "ground", sourceW: view.cell.width, sourceH: view.cell.height, frames: 1, animRows: false, footprint: { cols: 1, rows: 1 }, anchor: { x: 0.5, y: 1 }, objectScale: 1, passMode: 1, keyGreen: false, clarity: "smooth" }); setAddPreview(null); setAddPreviewNatural({ width: 0, height: 0 }); } }, T("新增素材")), h(Btn, { "data-testid": "iso-ai-open", onClick: openIsoAiAsset }, T("AI 生成素材")), h(Btn, { busy: busyKey === "sample", onClick: () => void restoreSamples() }, T("恢复默认素材")), h(Btn, { onClick: () => setGuidePage(0) }, T("素材说明"))), h("div", { className: "SPR_isoAssetList" }, view.tilesets.map((tileset) => h("div", { key: tileset.id, className: "SPR_isoAssetRow" }, h("button", { type: "button", className: "SPR_isoAssetName", onClick: () => setTsEdit({ tilesetId: tileset.id, name: tileset.name, fps: tileset.fps === undefined ? "" : String(tileset.fps), loop: tileset.loop ?? "forward" }) }, tileset.name), h("span", { className: "SPR_isoAssetMeta" }, tileset.reason), tileset.builtin === true ? h("span", { className: "SPR_isoBadge" }, T("自带")) : null, h("button", { type: "button", className: "SPR_isoMini", onClick: async () => {
|
|
12743
|
+
const assetsCard = h("div", { className: "SPR_isoCard" }, cardHead(T("素材")), h("div", { className: "SPR_isoRow" }, h(Btn, { primary: true, onClick: () => { setAddDraft({ base64: "", name: "", kind: "ground", sourceW: view.cell.width, sourceH: view.cell.height, frames: 1, animRows: false, footprint: { cols: 1, rows: 1 }, anchor: { x: 0.5, y: 1 }, objectScale: 1, passMode: 1, keyGreen: false, keyColor: globalConfig?.keyColor, clarity: "smooth" }); setAddPreview(null); setAddPreviewNatural({ width: 0, height: 0 }); } }, T("新增素材")), h(Btn, { "data-testid": "iso-ai-open", onClick: openIsoAiAsset }, T("AI 生成素材")), h(Btn, { busy: busyKey === "sample", onClick: () => void restoreSamples() }, T("恢复默认素材")), h(Btn, { onClick: () => setGuidePage(0) }, T("素材说明"))), h("div", { className: "SPR_isoAssetList" }, view.tilesets.map((tileset) => h("div", { key: tileset.id, className: "SPR_isoAssetRow" }, h("button", { type: "button", className: "SPR_isoAssetName", onClick: () => setTsEdit({ tilesetId: tileset.id, name: tileset.name, fps: tileset.fps === undefined ? "" : String(tileset.fps), loop: tileset.loop ?? "forward" }) }, tileset.name), h("span", { className: "SPR_isoAssetMeta" }, tileset.reason), tileset.builtin === true ? h("span", { className: "SPR_isoBadge" }, T("自带")) : null, h("button", { type: "button", className: "SPR_isoMini", onClick: async () => {
|
|
12403
12744
|
if (!window.confirm(T("确定删除素材「{n0}」?它切出来的块和放下的物件会一起删掉。", { n0: tileset.name })))
|
|
12404
12745
|
return;
|
|
12405
12746
|
try {
|
|
@@ -12436,7 +12777,7 @@ window.__ModuleLoader__.load({
|
|
|
12436
12777
|
: openCard === "gen" ? genCard
|
|
12437
12778
|
: openCard === "guide" ? guideCard
|
|
12438
12779
|
: null;
|
|
12439
|
-
const topBar = h("div", { className: "SPR_isoTop" }, h("div", { className: "SPR_isoProjWrap" }, h("button", { type: "button", className: "SPR_isoProj", "data-open": menuOpen === true ? "true" : undefined, onClick: () => setMenuOpen((value) => value !== true) }, h("span", { className: "SPR_isoProjName" }, view.name), h("span", null, "▾")), menuOpen === true ? menu : null), h("span", { style: { flex: 1 } }), h(Btn, { on: openCard === "assets", onClick: () => setOpenCard(openCard === "assets" ? null : "assets") }, T("素材")), h(Btn, { on: openCard === "export", onClick: () => setOpenCard(openCard === "export" ? null : "export") }, T("导出")), h(Btn, { on: openCard === "layers", onClick: () => setOpenCard(openCard === "layers" ? null : "layers") }, T("图层")), h(Btn, { onClick: () => setOpenCard(openCard === "settings" ? null : "settings") }, T("设置")));
|
|
12780
|
+
const topBar = h("div", { className: "SPR_isoTop" }, h("div", { className: "SPR_isoProjWrap" }, h("button", { type: "button", className: "SPR_isoProj", "data-open": menuOpen === true ? "true" : undefined, onClick: () => setMenuOpen((value) => value !== true) }, h("span", { className: "SPR_isoProjName" }, view.name), h("span", null, "▾")), menuOpen === true ? menu : null), h(CopyIdButton, { id: view.id }), h("span", { style: { flex: 1 } }), h(Btn, { on: openCard === "assets", onClick: () => setOpenCard(openCard === "assets" ? null : "assets") }, T("素材")), h(Btn, { on: openCard === "export", onClick: () => setOpenCard(openCard === "export" ? null : "export") }, T("导出")), h(Btn, { on: openCard === "layers", onClick: () => setOpenCard(openCard === "layers" ? null : "layers") }, T("图层")), h(Btn, { onClick: () => setOpenCard(openCard === "settings" ? null : "settings") }, T("设置")));
|
|
12440
12781
|
const stage = h("div", { className: "SPR_isoStage", ref: stageRef }, h("canvas", {
|
|
12441
12782
|
ref: bindCanvas,
|
|
12442
12783
|
className: "SPR_isoCanvas",
|
|
@@ -12466,7 +12807,19 @@ window.__ModuleLoader__.load({
|
|
|
12466
12807
|
const [suffixDraft, setSuffixDraft] = React.useState("");
|
|
12467
12808
|
const [settingsDraft, setSettingsDraft] = React.useState({});
|
|
12468
12809
|
const [keyingDraft, setKeyingDraft] = React.useState({});
|
|
12810
|
+
const [globalSizeDraft, setGlobalSizeDraft] = React.useState(null);
|
|
12469
12811
|
const globalConfig = useGlobalConfig(api);
|
|
12812
|
+
/**
|
|
12813
|
+
* 输出尺寸是**全局设置**(和生图模型同一条思路)。
|
|
12814
|
+
*
|
|
12815
|
+
* 之前任务里存一份尺寸副本:自定义 / ToAPIs 后端会覆盖它,火山方舟却保留,
|
|
12816
|
+
* 于是「改了设置里的尺寸」在旧任务上永远不生效 —— 用户看到的就是「总是
|
|
12817
|
+
* 1254×1254 这类固定尺寸」。现在输入框直接改全局配置,所有模块一起变。
|
|
12818
|
+
*/
|
|
12819
|
+
React.useEffect(() => {
|
|
12820
|
+
if (globalConfig !== null)
|
|
12821
|
+
setGlobalSizeDraft(globalConfig.imageProviderSize ?? "");
|
|
12822
|
+
}, [globalConfig]);
|
|
12470
12823
|
// 「正在调用接口」的记账表(上传走自己的 uploading 状态,不在这里)。
|
|
12471
12824
|
const tasks = usePendingTasks();
|
|
12472
12825
|
// 深链接:切到某一个图片任务。
|
|
@@ -12619,7 +12972,7 @@ window.__ModuleLoader__.load({
|
|
|
12619
12972
|
renderMeta: (item) => T("{n0} 张 · 抠像 {n1}", { n0: item.ready, n1: item.keyed })
|
|
12620
12973
|
}), h("div", { className: "SPR_main" }, notice !== null
|
|
12621
12974
|
? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text, h("span", { style: { marginLeft: 10 } }, h("button", { type: "button", className: "SPR_miniBtn", onClick: () => setNotice(null) }, T("关闭"))))
|
|
12622
|
-
: null, h("div", { className: "SPR_toolbar" }, h(BusyBtn, { onClick: create, primary: true, busy: tasks.has(K_IMG_CREATE), busyText: T("正在新建…") }, T("新建任务")), job !== null ? h(Btn, { onClick: del, danger: true }, T("删除任务")) : null, h(BusyBadge, { show: tasks.active, text: tasks.label(K_IMG_JOB) ?? tasks.label(K_IMG_KEY) ?? tasks.label(K_IMG_UPLOAD) ?? tasks.firstLabel ?? T("正在调用接口…") })), job === null
|
|
12975
|
+
: null, h("div", { className: "SPR_toolbar" }, h(BusyBtn, { onClick: create, primary: true, busy: tasks.has(K_IMG_CREATE), busyText: T("正在新建…") }, T("新建任务")), job !== null ? h(Btn, { onClick: del, danger: true }, T("删除任务")) : null, job !== null ? h(CopyIdButton, { id: job.id }) : null, h(BusyBadge, { show: tasks.active, text: tasks.label(K_IMG_JOB) ?? tasks.label(K_IMG_KEY) ?? tasks.label(K_IMG_UPLOAD) ?? tasks.firstLabel ?? T("正在调用接口…") })), job === null
|
|
12623
12976
|
? h("p", { className: "SPR_empty" }, T("请选择或新建一个图片任务"))
|
|
12624
12977
|
: h(React.Fragment, null, h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("① 提示词"))), h("p", { className: "SPR_hint" }, T("统一附加提示词会接在主提示词后面,用来写跨批次的共同要求。")), h("textarea", {
|
|
12625
12978
|
className: "SPR_area",
|
|
@@ -12640,18 +12993,40 @@ window.__ModuleLoader__.load({
|
|
|
12640
12993
|
if (suffixDraft !== (job.suffix ?? ""))
|
|
12641
12994
|
void saveJob({ suffix: suffixDraft });
|
|
12642
12995
|
}
|
|
12643
|
-
}), h("div", { className: "SPR_fields" }, h(GlobalModelField, { label: T("生图模型"), value: globalConfig?.imageModel ?? globalConfig?.arkModel ?? settingsDraft.model }), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("
|
|
12996
|
+
}), h("div", { className: "SPR_fields" }, h(GlobalModelField, { label: T("生图模型"), value: globalConfig?.imageModel ?? globalConfig?.arkModel ?? settingsDraft.model }), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, T("输出尺寸(全局)")), h("input", {
|
|
12997
|
+
className: "SPR_input",
|
|
12998
|
+
"data-testid": "image-global-size",
|
|
12999
|
+
value: globalSizeDraft ?? globalConfig?.imageProviderSize ?? "",
|
|
13000
|
+
placeholder: "1K / 2K / 4K / 1024x1024",
|
|
13001
|
+
onChange: (event) => setGlobalSizeDraft(event.target.value),
|
|
13002
|
+
onKeyDown: (event) => {
|
|
13003
|
+
if (event.key === "Enter")
|
|
13004
|
+
event.target.blur();
|
|
13005
|
+
},
|
|
13006
|
+
onBlur: () => {
|
|
13007
|
+
const value = (globalSizeDraft ?? "").trim();
|
|
13008
|
+
if (value === "")
|
|
13009
|
+
return;
|
|
13010
|
+
void run(() => api.saveConfig({ [sizeConfigKey(globalConfig)]: value }), T("输出尺寸已保存"));
|
|
13011
|
+
}
|
|
13012
|
+
}), h("span", { className: "SPR_fieldLabel" }, T("所有模块共用;支持 1K / 2K / 4K 或 宽x高(要固定像素就直接填 1024x1024 这种)"))), h(NumField, { label: T("生成张数(1~8)"), value: settingsDraft.count ?? 1, min: 1, max: 8, onChange: (v) => { setSettingsDraft({ ...settingsDraft, count: v }); void saveJob({ settings: { ...settingsDraft, count: v } }); } })), h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
|
|
12644
13013
|
primary: true,
|
|
12645
13014
|
busy: tasks.has(K_IMG_JOB),
|
|
12646
13015
|
busyText: T("正在生成 {n0} 张…", { n0: settingsDraft.count ?? 1 }),
|
|
12647
13016
|
disabled: promptDraft.trim() === "" || tasks.has(K_IMG_JOB),
|
|
12648
13017
|
onClick: () => void run(async () => {
|
|
13018
|
+
// 尺寸输入框失焦与点生成可能同一拍发生:先把全局尺寸落盘,
|
|
13019
|
+
// 否则本次生成可能仍读到旧尺寸(用户看到的就是「改了也不行」)。
|
|
13020
|
+
const sizeValue = (globalSizeDraft ?? "").trim();
|
|
13021
|
+
if (sizeValue !== "" && sizeValue !== (globalConfig?.imageProviderSize ?? "") && typeof api.saveConfig === "function") {
|
|
13022
|
+
await api.saveConfig({ [sizeConfigKey(globalConfig)]: sizeValue });
|
|
13023
|
+
}
|
|
12649
13024
|
await enqueueImageSave({ prompt: promptDraft, suffix: suffixDraft, settings: settingsDraft });
|
|
12650
13025
|
return api.runImageJob({ jobId: job.id });
|
|
12651
13026
|
}, T("已开始生成 {n0} 张", { n0: settingsDraft.count ?? 1 }), { key: K_IMG_JOB, label: T("正在生成 {n0} 张图片…", { n0: settingsDraft.count ?? 1 }) })
|
|
12652
13027
|
}, T("生成 {n0} 张", { n0: settingsDraft.count ?? 1 })), h("span", { className: "SPR_refRow" }, T("按当前生图后端的账号价格计费,实际以平台账单为准")))), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("② 参考图(可留空)"))), h("p", { className: "SPR_hint" }, T("最多 10 张。有参考图时走图生图;引用多张时可在提示词里写「图一」「图二」。")), h(UploadBox, { label: T("把参考图拖到这里"), accept: "image/*", multiple: true, busy: uploading || tasks.has(K_IMG_UPLOAD), onFiles: (files) => void upload(files, "ref") }), (job.refs ?? []).length === 0
|
|
12653
13028
|
? null
|
|
12654
|
-
: h("div", { className: "SPR_grid" }, (job.refs ?? []).map((ref) => h("div", { key: ref.file, className: "SPR_node" }, h("img", { className: "SPR_thumb", src: `${job.assetBase}${ref.file}?v=${job.updatedAt}`, alt: ref.name }), h("span", { className: "SPR_refRow" }, ref.name), h("div", { className: "SPR_btnRow" }, h(Btn, { danger: true, onClick: () => void run(() => api.removeImageRef({ jobId: job.id, file: ref.file }), T("已移除参考图")) }, T("移除"))))))), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("③
|
|
13029
|
+
: h("div", { className: "SPR_grid" }, (job.refs ?? []).map((ref) => h("div", { key: ref.file, className: "SPR_node" }, h("img", { className: "SPR_thumb", src: `${job.assetBase}${ref.file}?v=${job.updatedAt}`, alt: ref.name }), h("span", { className: "SPR_refRow" }, ref.name), h("div", { className: "SPR_btnRow" }, h(Btn, { danger: true, onClick: () => void run(() => api.removeImageRef({ jobId: job.id, file: ref.file }), T("已移除参考图")) }, T("移除"))))))), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("③ 背景抠像"))), h("p", { className: "SPR_hint" }, T("开启后每张生成完会自动抠一遍;也可以上传已有图片只做抠像。")), h("div", { className: "SPR_toolbar" }, h("select", {
|
|
12655
13030
|
className: "SPR_input",
|
|
12656
13031
|
style: { width: 220 },
|
|
12657
13032
|
value: keyingDraft.enabled ? "on" : "off",
|
|
@@ -12660,14 +13035,14 @@ window.__ModuleLoader__.load({
|
|
|
12660
13035
|
setKeyingDraft({ ...keyingDraft, enabled });
|
|
12661
13036
|
void saveJob({ keying: { enabled } });
|
|
12662
13037
|
}
|
|
12663
|
-
}, h("option", { value: "off" }, T("不抠像")), h("option", { value: "on" }, T("
|
|
13038
|
+
}, h("option", { value: "off" }, T("不抠像")), h("option", { value: "on" }, T("自动抠背景输出 PNG"))), h(BusyBtn, {
|
|
12664
13039
|
busy: tasks.has(K_IMG_KEY),
|
|
12665
13040
|
busyText: T("正在抠像…"),
|
|
12666
13041
|
onClick: () => void run(() => api.keyImageJob({ jobId: job.id }), T("已开始抠像"), {
|
|
12667
13042
|
key: K_IMG_KEY,
|
|
12668
|
-
label: T("
|
|
13043
|
+
label: T("正在抠背景…")
|
|
12669
13044
|
})
|
|
12670
|
-
}, T("按当前参数重新抠像"))), h(KeyingFields, { draft: keyingDraft, onChange: (patch) => { const next = { ...keyingDraft, ...patch }; setKeyingDraft(next); void saveJob({ keying: patch }); } }), h(UploadBox, { label: T("上传一张已有图片,直接抠成透明 PNG"), accept: "image/*", multiple: false, busy: uploading || tasks.has(K_IMG_UPLOAD), onFiles: (files) => void upload(files, "item") }), tasks.has(K_IMG_UPLOAD) ? h(BusyBadge, { show: true, text: tasks.label(K_IMG_UPLOAD) }) : null), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("④ 结果({n0} 张)", { n0: (job.items ?? []).length }))), h(ReviewModeBar, { api, module: "image", id: job.id, mode: job.reviewMode, onChanged: () => void load(job.id) }), (job.items ?? []).length === 0
|
|
13045
|
+
}, T("按当前参数重新抠像"))), h(KeyingFields, { draft: keyingDraft, fallbackColor: globalConfig?.keyColor, onChange: (patch) => { const next = { ...keyingDraft, ...patch }; setKeyingDraft(next); void saveJob({ keying: patch }); } }), h(UploadBox, { label: T("上传一张已有图片,直接抠成透明 PNG"), accept: "image/*", multiple: false, busy: uploading || tasks.has(K_IMG_UPLOAD), onFiles: (files) => void upload(files, "item") }), tasks.has(K_IMG_UPLOAD) ? h(BusyBadge, { show: true, text: tasks.label(K_IMG_UPLOAD) }) : null), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("④ 结果({n0} 张)", { n0: (job.items ?? []).length }))), h(ReviewModeBar, { api, module: "image", id: job.id, mode: job.reviewMode, onChanged: () => void load(job.id) }), (job.items ?? []).length === 0
|
|
12671
13046
|
? h("p", { className: "SPR_empty" }, T("还没有图片"))
|
|
12672
13047
|
: h("div", { className: "SPR_grid" }, (job.items ?? []).map((item, index) => {
|
|
12673
13048
|
const itemKey = K_IMG_ITEM(index);
|
|
@@ -12683,7 +13058,7 @@ window.__ModuleLoader__.load({
|
|
|
12683
13058
|
const keyingNow = item.status !== "running" && tasks.has(K_IMG_KEY);
|
|
12684
13059
|
const overlay = itemBusy || keyingNow || waiting;
|
|
12685
13060
|
const overlayText = tasks.label(itemKey) ??
|
|
12686
|
-
(keyingNow ? T("
|
|
13061
|
+
(keyingNow ? T("正在抠背景…") : waiting ? tasks.label(K_IMG_JOB) ?? T("正在生成…") : T("正在生成…"));
|
|
12687
13062
|
return h("div", { key: index, className: "SPR_node", "data-busy": overlay ? "true" : undefined }, h("div", { className: "SPR_nodeTop" }, h("span", { className: "SPR_nodeTitle" }, T("第 {n0} 张", { n0: index + 1 })), overlay ? h(Chip, { kind: "running", text: T("生成中") }) : h(StatusChip, { node: item }), item.source === "uploaded" ? h(Chip, { kind: "empty", text: T("上传") }) : null), h(MediaBox, { overlay, text: overlayText }, item.keyedFile !== undefined
|
|
12688
13063
|
? h("img", { className: "SPR_thumb", src: `${job.assetBase}${item.keyedFile}?v=${item.updatedAt}`, alt: T("抠像结果") })
|
|
12689
13064
|
: item.file !== undefined
|
|
@@ -12923,7 +13298,7 @@ window.__ModuleLoader__.load({
|
|
|
12923
13298
|
renderMeta: (item) => T("{n0} {n1} {n2}", { n0: item.videoReady ? T("视频✓") : T("视频·"), n1: item.frameReady ? T("帧✓") : T("帧·"), n2: item.sheetReady ? T("合成✓") : T("合成·") })
|
|
12924
13299
|
}), h("div", { className: "SPR_main" }, notice !== null
|
|
12925
13300
|
? h("div", { className: "SPR_note", "data-kind": notice.kind }, notice.text, h("span", { style: { marginLeft: 10 } }, h("button", { type: "button", className: "SPR_miniBtn", onClick: () => setNotice(null) }, T("关闭"))))
|
|
12926
|
-
: null, h("div", { className: "SPR_toolbar" }, h(BusyBtn, { onClick: create, primary: true, busy: tasks.has(K_SEQ_CREATE), busyText: T("正在新建…") }, T("新建任务")), job !== null ? h(Btn, { onClick: del, danger: true }, T("删除任务")) : null, h(BusyBadge, { show: tasks.active, text: tasks.firstLabel ?? T("正在调用接口…") })), job === null
|
|
13301
|
+
: null, h("div", { className: "SPR_toolbar" }, h(BusyBtn, { onClick: create, primary: true, busy: tasks.has(K_SEQ_CREATE), busyText: T("正在新建…") }, T("新建任务")), job !== null ? h(Btn, { onClick: del, danger: true }, T("删除任务")) : null, job !== null ? h(CopyIdButton, { id: job.id }) : null, h(BusyBadge, { show: tasks.active, text: tasks.firstLabel ?? T("正在调用接口…") })), job === null
|
|
12927
13302
|
? h("p", { className: "SPR_empty" }, T("请选择或新建一个序列帧任务"))
|
|
12928
13303
|
: h(React.Fragment, null, h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("① 视频输入"))), h("p", { className: "SPR_hint" }, T("平台规定两种模式互斥:首尾帧模式以一张图作为起始画面;多模态参考模式用参考图+参考视频来约束风格与动作。")), h("div", { className: "SPR_toolbar" }, h("select", {
|
|
12929
13304
|
className: "SPR_input",
|
|
@@ -12972,7 +13347,7 @@ window.__ModuleLoader__.load({
|
|
|
12972
13347
|
key: K_SEQ_FRAMES,
|
|
12973
13348
|
label: T("正在抽帧…")
|
|
12974
13349
|
})
|
|
12975
|
-
}, T("按当前张数抽帧({n0} 张)", { n0: settingsDraft.frameCount ?? 8 })), job.frames?.stale === true ? h(Chip, { kind: "stale", text: T("参数已变,需重抽") }) : null, h(BusyBadge, { show: framesBusy, text: framesText }), h("span", { className: "SPR_refRow" }, job.frames?.duration !== undefined ? T("视频时长 {n0} 秒 · {n1} 帧", { n0: job.frames.duration.toFixed(2), n1: job.frames.files.length }) : ""))), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("④ 绿幕抠像与合成"))), h(KeyingFields, { draft: keyingDraft, onChange: (patch) => { const next = { ...keyingDraft, ...patch }; setKeyingDraft(next); void saveJob({ keying: patch }); } }), h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
|
|
13350
|
+
}, T("按当前张数抽帧({n0} 张)", { n0: settingsDraft.frameCount ?? 8 })), job.frames?.stale === true ? h(Chip, { kind: "stale", text: T("参数已变,需重抽") }) : null, h(BusyBadge, { show: framesBusy, text: framesText }), h("span", { className: "SPR_refRow" }, job.frames?.duration !== undefined ? T("视频时长 {n0} 秒 · {n1} 帧", { n0: job.frames.duration.toFixed(2), n1: job.frames.files.length }) : ""))), h("div", { className: "SPR_card" }, h("div", { className: "SPR_cardHead" }, h("h3", null, T("④ 绿幕抠像与合成"))), h(KeyingFields, { draft: keyingDraft, fallbackColor: globalConfig?.keyColor, onChange: (patch) => { const next = { ...keyingDraft, ...patch }; setKeyingDraft(next); void saveJob({ keying: patch }); } }), h("div", { className: "SPR_toolbar" }, h(BusyBtn, {
|
|
12976
13351
|
busy: tasks.has(K_SEQ_KEY),
|
|
12977
13352
|
busyText: T("正在重新抠像…"),
|
|
12978
13353
|
disabled: framesBusy,
|
|
@@ -15253,7 +15628,7 @@ window.__ModuleLoader__.load({
|
|
|
15253
15628
|
}, h("span", { className: "SPR_moduleTitle" }, `${done ? "✓ " : ""}${entry.title}`), h("span", { className: "SPR_moduleHint" }, info.status === "running" ? T("进行中…") : entry.hint));
|
|
15254
15629
|
})), jobs.length === 0
|
|
15255
15630
|
? h("p", { className: "SPR_hint" }, loading ? T("正在读取任务…") : T("还没有骨骼动画任务,点右上角「新建任务」开始。"))
|
|
15256
|
-
: h(React.Fragment, null, h("div", { className: "SPR_toolbar", style: { flexWrap: "wrap" } }, h("span", { className: "SPR_refRow" }, T("任务")), h("select", { className: "SPR_input", style: { width: 260 }, value: jobId ?? "", onChange: (event) => setJobId(event.target.value) }, jobs.map((entry) => h("option", { key: entry.id, value: entry.id }, T("{n0}(部件 {n1})", { n0: entry.name, n1: entry.partCount })))), job !== null ? h("span", { className: "SPR_badge" }, job.id) : null, stageBusy ? h(BusyBadge, { show: true, text: T("本阶段进行中…") }) : null), job === null
|
|
15631
|
+
: h(React.Fragment, null, h("div", { className: "SPR_toolbar", style: { flexWrap: "wrap" } }, h("span", { className: "SPR_refRow" }, T("任务")), h("select", { className: "SPR_input", style: { width: 260 }, value: jobId ?? "", onChange: (event) => setJobId(event.target.value) }, jobs.map((entry) => h("option", { key: entry.id, value: entry.id }, T("{n0}(部件 {n1})", { n0: entry.name, n1: entry.partCount })))), job !== null ? h("span", { className: "SPR_badge" }, job.id) : null, job !== null ? h(CopyIdButton, { id: job.id }) : null, stageBusy ? h(BusyBadge, { show: true, text: T("本阶段进行中…") }) : null), job === null
|
|
15257
15632
|
? null
|
|
15258
15633
|
: h(React.Fragment, null, h(ReviewModeBar, { api, module: "rig", id: job.id, mode: job.reviewMode, onChanged: () => void load(job.id) }), h(RigQaPanel, { job, api, run, busy, activeKey: K_RIG_QA }),
|
|
15259
15634
|
// ── 第 0 步:角色参考图 ────────────────────────────────
|
|
@@ -15582,7 +15957,7 @@ window.__ModuleLoader__.load({
|
|
|
15582
15957
|
className: "SPR_input",
|
|
15583
15958
|
value: config.arkSize,
|
|
15584
15959
|
onChange: (event) => void patch({ arkSize: event.target.value })
|
|
15585
|
-
})), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, "Base URL"), h("input", {
|
|
15960
|
+
}), h("span", { className: "SPR_fieldLabel" }, T("1K / 2K / 4K 由模型决定像素;要固定尺寸请直接填 宽x高"))), h("label", { className: "SPR_field" }, h("span", { className: "SPR_fieldLabel" }, "Base URL"), h("input", {
|
|
15586
15961
|
className: "SPR_input",
|
|
15587
15962
|
value: config.arkBaseUrl,
|
|
15588
15963
|
onChange: (event) => void patch({ arkBaseUrl: event.target.value })
|
|
@@ -15867,7 +16242,7 @@ window.__ModuleLoader__.load({
|
|
|
15867
16242
|
min: 1,
|
|
15868
16243
|
max: 8,
|
|
15869
16244
|
onChange: (value) => void patch({ concurrency: value })
|
|
15870
|
-
}), h(NumField, {
|
|
16245
|
+
}), h(KeyColorField, { label: T("抠像背景色(全局默认)"), value: config.keyColor, onChange: (value) => void patch({ keyColor: value }) }), h(NumField, {
|
|
15871
16246
|
label: T("抠像下限"),
|
|
15872
16247
|
value: config.keyLow,
|
|
15873
16248
|
min: 0,
|
|
@@ -15893,7 +16268,7 @@ window.__ModuleLoader__.load({
|
|
|
15893
16268
|
max: 8,
|
|
15894
16269
|
onChange: (value) => void patch({ edgeShrink: value })
|
|
15895
16270
|
}), h(NumField, {
|
|
15896
|
-
label: T("背景分割容差(0 =
|
|
16271
|
+
label: T("背景分割容差(0 = 只认背景色)"),
|
|
15897
16272
|
value: config.bgTolerance,
|
|
15898
16273
|
min: 0,
|
|
15899
16274
|
max: 160,
|
|
@@ -16197,6 +16572,8 @@ window.__ModuleLoader__.load({
|
|
|
16197
16572
|
isoUndo: (payload) => call("isoUndo", payload),
|
|
16198
16573
|
isoRedo: (payload) => call("isoRedo", payload),
|
|
16199
16574
|
isoPlan: (payload) => call("isoPlan", payload),
|
|
16575
|
+
isoInspect: (payload) => call("isoInspect", payload),
|
|
16576
|
+
isoRender: (payload) => call("isoRender", payload),
|
|
16200
16577
|
runIsoGenerate: (payload) => call("runIsoGenerate", payload),
|
|
16201
16578
|
runIsoPreview: (payload) => call("runIsoPreview", payload),
|
|
16202
16579
|
runIsoExport: (payload) => call("runIsoExport", payload),
|
|
@@ -16222,6 +16599,8 @@ window.__ModuleLoader__.load({
|
|
|
16222
16599
|
mapUndo: (payload) => call("mapUndo", payload),
|
|
16223
16600
|
mapRedo: (payload) => call("mapRedo", payload),
|
|
16224
16601
|
mapPlan: (payload) => call("mapPlan", payload),
|
|
16602
|
+
mapInspect: (payload) => call("mapInspect", payload),
|
|
16603
|
+
mapRender: (payload) => call("mapRender", payload),
|
|
16225
16604
|
runMapGenerate: (payload) => call("runMapGenerate", payload),
|
|
16226
16605
|
runMapPreview: (payload) => call("runMapPreview", payload),
|
|
16227
16606
|
runMapExport: (payload) => call("runMapExport", payload),
|