dsh-game-material-master 0.3.0 → 0.4.0
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 +21 -1
- package/README.md +17 -1
- package/lib/client.js +301 -16
- package/lib/config.js +20 -1
- package/lib/index.js +4 -1
- package/lib/tools.js +218 -12
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -18,6 +18,10 @@ no system image libraries required, and your assets are never uploaded to a thir
|
|
|
18
18
|
> upload your character sheet → click "Generate turn video" (the default path: the character rotates steadily
|
|
19
19
|
> in place for one full turn, then the eight directions are cut out automatically; switch the method in
|
|
20
20
|
> stage ① if you'd rather generate each direction separately).
|
|
21
|
+
>
|
|
22
|
+
> The sidebar entry also carries a **small chevron menu button**: click it to pop up the five features and
|
|
23
|
+
> jump straight into the one you want. Features you do not use can be turned off in settings (see
|
|
24
|
+
> "Feature management").
|
|
21
25
|
|
|
22
26
|
All four modules share the same "generate → review → re-run" workbench. Every stage can be **redone on its
|
|
23
27
|
own**, and every asset can be **approved item by item**. The "review mode" lets an agent approve each step
|
|
@@ -238,16 +242,32 @@ point `FFMPEG_PATH` / `FFPROBE_PATH` at absolute paths. The package has **no run
|
|
|
238
242
|
| Item | Description |
|
|
239
243
|
|---|---|
|
|
240
244
|
| Volcengine Ark API Key | "Test connection" really generates a 1K thumbnail (a small charge) and validates both the key and the model |
|
|
241
|
-
| Image model | Defaults to `doubao-seedream-
|
|
245
|
+
| Image model | Defaults to `doubao-seedream-5-0-flash-260915`; switchable to 5.0 Pro / Lite / 4.5 |
|
|
242
246
|
| MiniMax API Key | "Test connection" is free and can tell an invalid key apart from other errors |
|
|
243
247
|
| Video model | Defaults to `MiniMax-H3` (v2 protocol); Hailuo / I2V use v1; the UCloud version of H3 is selected explicitly |
|
|
244
248
|
| Base URL | Host root, without `/v1` or `/v2`. `api.minimax.cn` in mainland China, `api.minimaxi.com` internationally |
|
|
245
249
|
| Default parameters | Cell width and height, frame count, pixel block size, keying threshold, and so on |
|
|
250
|
+
| Feature management | Per-module switches: a disabled module disappears from the UI **and the agent cannot call it either** (see below) |
|
|
246
251
|
|
|
247
252
|
Keys are written only to `<DSH_HOME>/game-material-master/config.json` on your machine, and the UI always
|
|
248
253
|
masks them when displaying them back. **The model is a plugin-level setting shared by all three modules**;
|
|
249
254
|
after you switch models, tasks align to the new tier automatically.
|
|
250
255
|
|
|
256
|
+
### Feature management (hiding modules you do not use)
|
|
257
|
+
|
|
258
|
+
Turn a module off under **Settings → Game Material Master → Feature management**; turn it back on any time.
|
|
259
|
+
Existing project data is never deleted.
|
|
260
|
+
|
|
261
|
+
- **UI**: the module disappears from the workbench tabs and from the sidebar shortcut menu. If you were
|
|
262
|
+
sitting on that module, the workbench falls back to the first visible one.
|
|
263
|
+
- **Chat**: `game_material_call` / `status` / `intake` / `upload` / `wait` / `review` / `approve` all refuse,
|
|
264
|
+
and the error says where to turn the feature back on. Hiding only the UI would not be hiding at all: the
|
|
265
|
+
agent cannot see the tab but could still call generation methods and spend real money, so the host half
|
|
266
|
+
re-checks the current setting on every call.
|
|
267
|
+
- Visibility is **user-only**: the tool surface rejects `saveConfig({hiddenModules})`, otherwise the model
|
|
268
|
+
could simply unhide a feature by itself.
|
|
269
|
+
- Hiding everything is allowed; the workbench then says every feature is hidden.
|
|
270
|
+
|
|
251
271
|
## UI language
|
|
252
272
|
|
|
253
273
|
**The plugin UI follows DSH's own language setting** (Settings → General → Language). Chinese and English are
|
package/README.md
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
> **30 秒上手**:`dsh plugin --profile web add dsh-game-material-master` → 重启 DSH →
|
|
16
16
|
> 侧栏点「游戏素材大师」→ 设置里填两个 API Key → 新建项目、上传设定图 → 点「生成转圈视频」
|
|
17
17
|
>(默认路径:角色原地匀速转一圈,再自动截出八个方向;要逐方向生图就在阶段①切一下方式)。
|
|
18
|
+
>
|
|
19
|
+
> 侧栏那个入口上还有一个**小折角菜单按钮**:点它直接弹出五个功能,一步跳进要用的那个;
|
|
20
|
+
> 不用的功能可以在设置里关掉(见「功能管理」)。
|
|
18
21
|
|
|
19
22
|
四个模块共用同一套「生成 → 验收 → 重跑」工作台。每个阶段都能**单独重做**,每份产物都能
|
|
20
23
|
**逐项打「通过」**;「审核模式」可以选 agent 自动审完就往下走,也可以选每一步停下来等你点头。
|
|
@@ -207,15 +210,28 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
|
|
|
207
210
|
| 项 | 说明 |
|
|
208
211
|
|---|---|
|
|
209
212
|
| 火山方舟 API Key | 「测试连接」会真实生成一张 1K 小图(少量费用),同时验证 Key 与模型 |
|
|
210
|
-
| 生图模型 | 默认 `doubao-seedream-
|
|
213
|
+
| 生图模型 | 默认 `doubao-seedream-5-0-flash-260915`,可切 5.0 Pro / Lite / 4.5 |
|
|
211
214
|
| MiniMax API Key | 「测试连接」免费,能区分 Key 无效与其它错误 |
|
|
212
215
|
| 视频模型 | 默认 `MiniMax-H3`(v2 协议);Hailuo / I2V 走 v1;优云智算版 H3 显式选择 |
|
|
213
216
|
| Base URL | 主机根,不含 `/v1` `/v2`。国内 `api.minimax.cn`,国际 `api.minimaxi.com` |
|
|
214
217
|
| 默认参数 | 单格宽高、抽帧张数、像素块边长、抠像阈值等 |
|
|
218
|
+
| 功能管理 | 逐个开关五个模块:关掉的模块界面上不再出现,**对话里的 AI 也调不到**(见下) |
|
|
215
219
|
|
|
216
220
|
Key 只写入本机 `<DSH_HOME>/game-material-master/config.json`,界面回显始终脱敏。
|
|
217
221
|
**模型是插件级设置,三个模块共用**,切换模型后任务自动对齐新档位。
|
|
218
222
|
|
|
223
|
+
### 功能管理(隐藏不用的模块)
|
|
224
|
+
|
|
225
|
+
不用的模块可以在**设置 → 游戏素材大师 → 功能管理**里关掉,随时再打开,已有项目数据不会删:
|
|
226
|
+
|
|
227
|
+
- **界面**:工作台页签、侧栏快捷菜单里都不再出现它;如果当时正停在这个模块,会自动落到第一个可见模块。
|
|
228
|
+
- **对话**:`game_material_call` / `status` / `intake` / `upload` / `wait` / `review` / `approve`
|
|
229
|
+
一律拒绝,报错里说明去哪里打开。只藏界面不拦工具等于没藏——模型看不见页签,
|
|
230
|
+
照样能调生成类方法真实计费,所以宿主半区每次都按最新配置再拦一次。
|
|
231
|
+
- 可见性**只能由用户在设置页里改**:工具面拒绝 `saveConfig({hiddenModules})`,
|
|
232
|
+
否则模型能自己把隐藏的功能放出来。
|
|
233
|
+
- 全部关掉也是允许的,工作台会提示「所有功能都已被隐藏」。
|
|
234
|
+
|
|
219
235
|
## 界面语言
|
|
220
236
|
|
|
221
237
|
**插件界面跟随 DSH 自身的语言设置**(设置 → 通用 → 语言),中文 / 英文都是一等公民,
|
package/lib/client.js
CHANGED
|
@@ -1025,7 +1025,19 @@ window.__ModuleLoader__.load({
|
|
|
1025
1025
|
"放弃修改": "Discard changes",
|
|
1026
1026
|
"共 {n0} 行 × {n1} 列": "{n0} rows x {n1} cols",
|
|
1027
1027
|
"正在编辑 {n0} · 当前是「{n1}」": "Editing {n0} · currently '{n1}'",
|
|
1028
|
-
"涂改只改草稿,点「保存布局」才写回项目;之后再点「铺成地图」出图。手动改布局不会作废已生成的地块。": "Painting only changes a draft; click 'Save layout' to write it back, then 'Assemble map' to render. Editing the layout never discards generated tiles."
|
|
1028
|
+
"涂改只改草稿,点「保存布局」才写回项目;之后再点「铺成地图」出图。手动改布局不会作废已生成的地块。": "Painting only changes a draft; click 'Save layout' to write it back, then 'Assemble map' to render. Editing the layout never discards generated tiles.",
|
|
1029
|
+
// ── 功能管理 / 侧栏快捷菜单 ──
|
|
1030
|
+
"功能菜单": "Feature menu",
|
|
1031
|
+
"快捷进入功能": "Jump to a feature",
|
|
1032
|
+
"功能管理": "Feature management",
|
|
1033
|
+
"隐藏不用的功能。隐藏后界面里不再出现它的页签与侧栏菜单项,对话里的 AI 也无法调用它(工具会直接报错)。随时可以再打开,已有的项目数据不会被删除。": "Hide the features you do not use. A hidden feature disappears from the workbench tabs and the sidebar menu, and the agent cannot call it either (its tools fail loudly). You can turn it back on at any time, and existing project data is never deleted.",
|
|
1034
|
+
"已隐藏": "Hidden",
|
|
1035
|
+
"显示中": "Visible",
|
|
1036
|
+
"当前五个功能全部可见。": "All five features are currently visible.",
|
|
1037
|
+
"已隐藏 {n0} 个功能:{n1}。隐藏的模块在对话里同样不可调用。": "{n0} feature(s) hidden: {n1}. Hidden modules cannot be called from chat either.",
|
|
1038
|
+
"已隐藏 {n0} 个功能(设置 → 游戏素材大师 → 功能管理)": "{n0} feature(s) hidden (Settings → Game Material Master → Feature management)",
|
|
1039
|
+
"所有功能都已被隐藏,请到「设置 → 游戏素材大师 → 功能管理」里打开至少一个。": "Every feature is hidden. Turn at least one back on in \"Settings → Game Material Master → Feature management\".",
|
|
1040
|
+
"所有功能都已被隐藏。请到「设置 → 游戏素材大师 → 功能管理」里打开至少一个。": "Every feature is hidden. Turn at least one back on in \"Settings → Game Material Master → Feature management\"."
|
|
1029
1041
|
};
|
|
1030
1042
|
/* i18n-ignore-end */
|
|
1031
1043
|
/**
|
|
@@ -1445,6 +1457,72 @@ window.__ModuleLoader__.load({
|
|
|
1445
1457
|
];
|
|
1446
1458
|
}
|
|
1447
1459
|
let STAGES = make_STAGES();
|
|
1460
|
+
// ── 功能管理(被隐藏的模块)──────────────────────────────────────────
|
|
1461
|
+
//
|
|
1462
|
+
// 设置页「功能管理」写、工作台页签与侧栏菜单读,所以状态放在工厂闭包里共享
|
|
1463
|
+
// 一份,而不是各自去 `getConfig()`。
|
|
1464
|
+
//
|
|
1465
|
+
// 「隐藏」是**双向**的:这里只管界面,对话工具面由宿主 `src/tools.ts` 再拦
|
|
1466
|
+
// 一次(`hiddenModules` 存在宿主配置里,两侧读的是同一份)。只藏界面不拦
|
|
1467
|
+
// 工具等于没藏——模型照样能调生成类方法,真实计费。
|
|
1468
|
+
const hiddenModulesState = { keys: [], listeners: new Set() };
|
|
1469
|
+
/** 收敛成合法且顺序固定的 key 数组(与宿主 `normalizeHiddenModules` 同口径)。 */
|
|
1470
|
+
function normalizeHiddenKeys(value) {
|
|
1471
|
+
if (!Array.isArray(value))
|
|
1472
|
+
return [];
|
|
1473
|
+
return MODULES.map((entry) => entry.key).filter((key) => value.includes(key));
|
|
1474
|
+
}
|
|
1475
|
+
/** 写入并通知订阅者;内容没变就不通知(避免无谓重渲染)。 */
|
|
1476
|
+
function publishHiddenModules(value) {
|
|
1477
|
+
const next = normalizeHiddenKeys(value);
|
|
1478
|
+
if (next.length === hiddenModulesState.keys.length && next.every((key, index) => key === hiddenModulesState.keys[index]))
|
|
1479
|
+
return;
|
|
1480
|
+
hiddenModulesState.keys = next;
|
|
1481
|
+
for (const listener of [...hiddenModulesState.listeners]) {
|
|
1482
|
+
try {
|
|
1483
|
+
listener(next);
|
|
1484
|
+
}
|
|
1485
|
+
catch {
|
|
1486
|
+
// 单个订阅者出错不该拖垮别的。
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
/** 从宿主读一次当前可见性。读失败就当作「全部可见」,不要因此白屏。 */
|
|
1491
|
+
async function refreshHiddenModules(api) {
|
|
1492
|
+
if (api === undefined)
|
|
1493
|
+
return;
|
|
1494
|
+
try {
|
|
1495
|
+
const config = await api.getConfig();
|
|
1496
|
+
publishHiddenModules(config?.hiddenModules);
|
|
1497
|
+
}
|
|
1498
|
+
catch {
|
|
1499
|
+
// 配置读不到不是致命错误:界面照常,工具面仍然会拦。
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* 组件里用:当前被隐藏的模块 key 数组。
|
|
1504
|
+
*
|
|
1505
|
+
* `api` 可省略(那时只订阅、不主动拉取)——设置页自己会 `load()` 并 publish。
|
|
1506
|
+
*/
|
|
1507
|
+
function useHiddenModules(api) {
|
|
1508
|
+
const [hidden, setHidden] = React.useState(hiddenModulesState.keys);
|
|
1509
|
+
React.useEffect(() => {
|
|
1510
|
+
hiddenModulesState.listeners.add(setHidden);
|
|
1511
|
+
// 订阅之前可能已经有值了(设置页先加载完),补一次对齐。
|
|
1512
|
+
setHidden(hiddenModulesState.keys);
|
|
1513
|
+
return () => {
|
|
1514
|
+
hiddenModulesState.listeners.delete(setHidden);
|
|
1515
|
+
};
|
|
1516
|
+
}, []);
|
|
1517
|
+
React.useEffect(() => {
|
|
1518
|
+
void refreshHiddenModules(api);
|
|
1519
|
+
}, [api]);
|
|
1520
|
+
return hidden;
|
|
1521
|
+
}
|
|
1522
|
+
/** 可见的模块(页签、侧栏菜单都按它渲染)。 */
|
|
1523
|
+
function visibleModulesOf(hidden) {
|
|
1524
|
+
return MODULES.filter((entry) => !hidden.includes(entry.key));
|
|
1525
|
+
}
|
|
1448
1526
|
// ── 深链接:从会话里点一下链接就切到插件对应页面 ─────────────────────
|
|
1449
1527
|
//
|
|
1450
1528
|
// 宿主 src/links.ts 是这套约定的唯一真源;这里只能复制常量(浏览器半区是
|
|
@@ -1781,6 +1859,15 @@ window.__ModuleLoader__.load({
|
|
|
1781
1859
|
.SPR_settingsGroup{border:1px solid var(--dsw-alias-border-l2);border-radius:12px;padding:14px;background:var(--dsw-alias-bg-layer-3)}
|
|
1782
1860
|
.SPR_settingsGroup h3{margin:0 0 4px;font-size:13px;font-weight:600}
|
|
1783
1861
|
.SPR_settingsGroup p{margin:0 0 10px;color:var(--dsw-alias-label-tertiary);font-size:12px}
|
|
1862
|
+
/* 功能管理:一行一个模块,勾选框在左、说明在中间、状态在右。 */
|
|
1863
|
+
.SPR_featureList{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}
|
|
1864
|
+
.SPR_featureRow{display:flex;align-items:flex-start;gap:10px;padding:8px 10px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);cursor:pointer}
|
|
1865
|
+
.SPR_featureRow[data-hidden=true]{opacity:.62}
|
|
1866
|
+
.SPR_featureCheck{margin:2px 0 0;width:15px;height:15px;flex:none;accent-color:var(--dsw-alias-state-business-primary);cursor:pointer}
|
|
1867
|
+
.SPR_featureText{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1}
|
|
1868
|
+
.SPR_featureTitle{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary)}
|
|
1869
|
+
.SPR_featureHint{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
|
|
1870
|
+
.SPR_featureState{font-size:11px;line-height:18px;flex:none;padding:0 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary)}
|
|
1784
1871
|
.SPR_keyRow{display:flex;gap:8px;align-items:flex-end}
|
|
1785
1872
|
.SPR_keyRow .SPR_field{flex:1}
|
|
1786
1873
|
.SPR_badge{font-size:11px;padding:1px 7px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-tertiary)}
|
|
@@ -1819,7 +1906,8 @@ window.__ModuleLoader__.load({
|
|
|
1819
1906
|
.SPR_axisRulerMid{text-align:center}
|
|
1820
1907
|
.SPR_pickPanel{grid-column:1 / -1;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;padding:12px;background:var(--dsw-alias-bg-layer-1)}
|
|
1821
1908
|
.SPR_pickHead{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;flex-wrap:wrap}
|
|
1822
|
-
.SPR_modules{display:flex;gap:8px;padding:10px 18px;border-bottom:1px solid var(--dsw-alias-border-l2);flex:none;flex-wrap:wrap}
|
|
1909
|
+
.SPR_modules{display:flex;gap:8px;padding:10px 18px;border-bottom:1px solid var(--dsw-alias-border-l2);flex:none;flex-wrap:wrap;align-items:center}
|
|
1910
|
+
.SPR_modulesHiddenNote{font-size:11px;color:var(--dsw-alias-label-tertiary);margin-left:auto}
|
|
1823
1911
|
.SPR_module{font:inherit;cursor:pointer;text-align:left;display:flex;flex-direction:column;gap:1px;padding:6px 12px;border-radius:10px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary)}
|
|
1824
1912
|
.SPR_module:hover{background:var(--dsw-alias-interactive-bg-hover-solid)}
|
|
1825
1913
|
.SPR_module[data-active=true]{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);box-shadow:0 0 0 1px color-mix(in srgb, var(--dsw-alias-state-business-primary) 30%, transparent)}
|
|
@@ -1977,6 +2065,25 @@ window.__ModuleLoader__.load({
|
|
|
1977
2065
|
.SPR_gateMute{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--dsw-alias-label-tertiary);cursor:pointer;margin-right:auto}
|
|
1978
2066
|
.SPR_gate a.SPR_btn{text-decoration:none;display:inline-flex;align-items:center}
|
|
1979
2067
|
.SPR_gate .SPR_link{align-self:flex-start}
|
|
2068
|
+
|
|
2069
|
+
/* ── 侧栏入口上的菜单按钮 ───────────────────────────────────────────────
|
|
2070
|
+
宿主把这一坨渲染在它自己的 <button class=…panelRow> 里面,所以:
|
|
2071
|
+
· 图标本体保持原尺寸,右下角叠一个 14px 的折角触发器(命中区靠 padding 撑);
|
|
2072
|
+
· 菜单用 position:fixed —— 祖先里有 overflow:hidden 的容器,
|
|
2073
|
+
absolute 定位在某些窗口布局下会被裁掉。 */
|
|
2074
|
+
.SPR_railGlyph{position:relative;display:inline-flex;align-items:center;justify-content:center}
|
|
2075
|
+
.SPR_railMenuBtn{position:absolute;right:-9px;bottom:-7px;width:14px;height:14px;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;cursor:pointer;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l3);box-shadow:0 1px 3px rgba(0,0,0,.18)}
|
|
2076
|
+
.SPR_railMenuBtn:hover{background:var(--dsw-alias-interactive-bg-hover-solid);color:var(--dsw-alias-label-primary)}
|
|
2077
|
+
.SPR_railMenuBtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
2078
|
+
.SPR_railMenu{position:fixed;z-index:70;width:264px;max-height:min(70vh,420px);overflow:auto;box-sizing:border-box;display:flex;flex-direction:column;gap:2px;padding:8px;border-radius:12px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);box-shadow:0 16px 40px rgba(0,0,0,.28);font-size:13px;line-height:20px;color:var(--dsw-alias-label-primary)}
|
|
2079
|
+
.SPR_railMenuHead{font-size:11px;color:var(--dsw-alias-label-tertiary);padding:2px 8px 6px}
|
|
2080
|
+
.SPR_railMenuEmpty{margin:0;padding:2px 8px 6px;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
2081
|
+
.SPR_railMenuItem{font:inherit;text-align:left;cursor:pointer;display:flex;flex-direction:column;gap:1px;padding:6px 8px;border-radius:8px;border:none;background:transparent;color:inherit}
|
|
2082
|
+
.SPR_railMenuItem:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2083
|
+
.SPR_railMenuItem:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}
|
|
2084
|
+
.SPR_railMenuItemTitle{display:flex;align-items:center;gap:6px;font-size:13px;font-weight:600}
|
|
2085
|
+
.SPR_railMenuItemHint{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
|
|
2086
|
+
.SPR_railMenuFoot{margin-top:4px;padding:6px 8px 2px;border-top:1px solid var(--dsw-alias-border-l2);font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary)}
|
|
1980
2087
|
`;
|
|
1981
2088
|
// ── 小工具 ───────────────────────────────────────────────────────────
|
|
1982
2089
|
function cls(...parts) {
|
|
@@ -2513,11 +2620,130 @@ window.__ModuleLoader__.load({
|
|
|
2513
2620
|
const { approved, disabled, onToggle, idleText } = props;
|
|
2514
2621
|
return h(Btn, { on: approved === true, disabled: disabled === true, onClick: onToggle }, approved === true ? T("已通过") : idleText ?? T("通过"));
|
|
2515
2622
|
}
|
|
2516
|
-
// ──
|
|
2517
|
-
|
|
2623
|
+
// ── 侧栏图标(入口按钮 + 快捷菜单)───────────────────────────────────
|
|
2624
|
+
/**
|
|
2625
|
+
* 图标本体。抽出来是因为 `StudioGlyph` 现在还要在旁边挂一个菜单按钮,
|
|
2626
|
+
* 而自检脚本会单独拿这个纯图形做断言。
|
|
2627
|
+
*/
|
|
2628
|
+
function StudioGlyphIcon(props) {
|
|
2518
2629
|
const size = props?.size ?? 18;
|
|
2519
2630
|
return h("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true" }, h("rect", { x: 3.2, y: 3.2, width: 17.6, height: 17.6, rx: 3, stroke: "currentColor", strokeWidth: 1.6 }), h("rect", { x: 5.6, y: 5.6, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.9 }), h("rect", { x: 10.2, y: 5.6, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.55 }), h("rect", { x: 14.8, y: 5.6, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.9 }), h("rect", { x: 5.6, y: 10.2, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.55 }), h("rect", { x: 10.2, y: 10.2, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.28 }), h("rect", { x: 14.8, y: 10.2, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.55 }), h("rect", { x: 5.6, y: 14.8, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.9 }), h("rect", { x: 10.2, y: 14.8, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.55 }), h("rect", { x: 14.8, y: 14.8, width: 3.6, height: 3.6, rx: 1, fill: "currentColor", opacity: 0.9 }));
|
|
2520
2631
|
}
|
|
2632
|
+
/** 菜单按钮上的小折角箭头。 */
|
|
2633
|
+
function ChevronGlyph() {
|
|
2634
|
+
return h("svg", { width: 8, height: 8, viewBox: "0 0 8 8", fill: "none", "aria-hidden": "true" }, h("path", { d: "M1.4 2.6 L4 5.4 L6.6 2.6", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round" }));
|
|
2635
|
+
}
|
|
2636
|
+
/**
|
|
2637
|
+
* 侧栏「游戏素材大师」入口。
|
|
2638
|
+
*
|
|
2639
|
+
* 宿主把这一坨渲染在**它自己的 `<button class=…panelRow>` 里面**(见
|
|
2640
|
+
* dsh-client-ui-sidebar 的 `PanelRow`),所以我们没法在旁边加一个平级的
|
|
2641
|
+
* `<button>`——那会变成嵌套按钮。做法是:图标右下角挂一个
|
|
2642
|
+
* `span[role=button]` 的小折角,点击时 `stopPropagation` 掉宿主那一下
|
|
2643
|
+
* (否则会顺带切面板),然后在它旁边弹出功能菜单。
|
|
2644
|
+
*
|
|
2645
|
+
* 菜单用 `position:fixed` 渲染:侧栏面板列本身不裁剪,但祖先里有
|
|
2646
|
+
* `overflow:hidden` 的容器,`absolute` 会在某些窗口布局下被切掉。
|
|
2647
|
+
*/
|
|
2648
|
+
function StudioGlyph(props) {
|
|
2649
|
+
const size = props?.size ?? 18;
|
|
2650
|
+
const api = props?.api;
|
|
2651
|
+
const studioCtx = props?.studioCtx;
|
|
2652
|
+
const hidden = useHiddenModules(api);
|
|
2653
|
+
const [open, setOpen] = React.useState(false);
|
|
2654
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
2655
|
+
const rootRef = React.useRef(null);
|
|
2656
|
+
const menuRef = React.useRef(null);
|
|
2657
|
+
const entries = visibleModulesOf(hidden);
|
|
2658
|
+
// 菜单开着时:点外面 / 按 Esc 关掉。监听挂在 document 上,
|
|
2659
|
+
// 用捕获阶段,避免被宿主自己的处理吞掉。
|
|
2660
|
+
React.useEffect(() => {
|
|
2661
|
+
if (!open)
|
|
2662
|
+
return undefined;
|
|
2663
|
+
const onPointerDown = (event) => {
|
|
2664
|
+
const root = rootRef.current;
|
|
2665
|
+
if (root !== null && root !== undefined && typeof root.contains === "function" && root.contains(event.target))
|
|
2666
|
+
return;
|
|
2667
|
+
setOpen(false);
|
|
2668
|
+
};
|
|
2669
|
+
const onKeyDown = (event) => {
|
|
2670
|
+
if (event.key === "Escape")
|
|
2671
|
+
setOpen(false);
|
|
2672
|
+
};
|
|
2673
|
+
document.addEventListener("mousedown", onPointerDown, true);
|
|
2674
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2675
|
+
return () => {
|
|
2676
|
+
document.removeEventListener("mousedown", onPointerDown, true);
|
|
2677
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
2678
|
+
};
|
|
2679
|
+
}, [open]);
|
|
2680
|
+
const toggle = (event) => {
|
|
2681
|
+
// 两下都要拦:宿主 `<button>` 的 onClick 也在这条冒泡路径上。
|
|
2682
|
+
event.preventDefault();
|
|
2683
|
+
event.stopPropagation();
|
|
2684
|
+
if (open) {
|
|
2685
|
+
setOpen(false);
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
const target = event.currentTarget;
|
|
2689
|
+
if (target !== null && target !== undefined && typeof target.getBoundingClientRect === "function") {
|
|
2690
|
+
const rect = target.getBoundingClientRect();
|
|
2691
|
+
setAnchor({ left: rect.right + 8, top: rect.top - 4, bottom: rect.bottom });
|
|
2692
|
+
}
|
|
2693
|
+
else {
|
|
2694
|
+
setAnchor(null);
|
|
2695
|
+
}
|
|
2696
|
+
setOpen(true);
|
|
2697
|
+
};
|
|
2698
|
+
const pick = (key) => {
|
|
2699
|
+
setOpen(false);
|
|
2700
|
+
openStudioIntent(studioCtx, { module: key });
|
|
2701
|
+
};
|
|
2702
|
+
// 菜单从按钮右上角展开;超出视口下沿时整体上移,别让它跑到屏幕外。
|
|
2703
|
+
let menuStyle = { left: 0, top: 0 };
|
|
2704
|
+
if (anchor !== null) {
|
|
2705
|
+
const viewportHeight = typeof window !== "undefined" && Number.isFinite(window.innerHeight) ? window.innerHeight : 0;
|
|
2706
|
+
const estimated = 96 + entries.length * 52;
|
|
2707
|
+
const top = viewportHeight > 0 ? Math.max(8, Math.min(anchor.top, viewportHeight - estimated - 12)) : anchor.top;
|
|
2708
|
+
menuStyle = { left: anchor.left, top };
|
|
2709
|
+
}
|
|
2710
|
+
return h("span", { className: "SPR_railGlyph", ref: rootRef }, h(StudioGlyphIcon, { size }), h("span", {
|
|
2711
|
+
className: "SPR_railMenuBtn",
|
|
2712
|
+
role: "button",
|
|
2713
|
+
tabIndex: 0,
|
|
2714
|
+
"aria-haspopup": "menu",
|
|
2715
|
+
"aria-expanded": open ? "true" : "false",
|
|
2716
|
+
"aria-label": T("功能菜单"),
|
|
2717
|
+
title: T("功能菜单"),
|
|
2718
|
+
"data-testid": "gmm-rail-menu-btn",
|
|
2719
|
+
onClick: toggle,
|
|
2720
|
+
onKeyDown: (event) => {
|
|
2721
|
+
if (event.key === "Enter" || event.key === " " || event.key === "Spacebar")
|
|
2722
|
+
toggle(event);
|
|
2723
|
+
}
|
|
2724
|
+
}, h(ChevronGlyph, null)), open
|
|
2725
|
+
? h("div", {
|
|
2726
|
+
className: "SPR_railMenu",
|
|
2727
|
+
role: "menu",
|
|
2728
|
+
ref: menuRef,
|
|
2729
|
+
style: menuStyle,
|
|
2730
|
+
"data-testid": "gmm-rail-menu",
|
|
2731
|
+
onClick: (event) => event.stopPropagation(),
|
|
2732
|
+
onMouseDown: (event) => event.stopPropagation()
|
|
2733
|
+
}, h("div", { className: "SPR_railMenuHead" }, T("快捷进入功能")), entries.length === 0
|
|
2734
|
+
? h("p", { className: "SPR_railMenuEmpty" }, T("所有功能都已被隐藏,请到「设置 → 游戏素材大师 → 功能管理」里打开至少一个。"))
|
|
2735
|
+
: entries.map((entry) => h("button", {
|
|
2736
|
+
key: entry.key,
|
|
2737
|
+
type: "button",
|
|
2738
|
+
role: "menuitem",
|
|
2739
|
+
className: "SPR_railMenuItem",
|
|
2740
|
+
"data-module": entry.key,
|
|
2741
|
+
onClick: () => pick(entry.key)
|
|
2742
|
+
}, h("span", { className: "SPR_railMenuItemTitle" }, entry.title, entry.experimental === true ? h("span", { className: "SPR_expTag" }, T("实验性")) : null), h("span", { className: "SPR_railMenuItemHint" }, entry.hint))), hidden.length > 0
|
|
2743
|
+
? h("div", { className: "SPR_railMenuFoot" }, T("已隐藏 {n0} 个功能(设置 → 游戏素材大师 → 功能管理)", { n0: hidden.length }))
|
|
2744
|
+
: null)
|
|
2745
|
+
: null);
|
|
2746
|
+
}
|
|
2521
2747
|
// ── 主体工作台 ───────────────────────────────────────────────────────
|
|
2522
2748
|
function StudioPanel(props) {
|
|
2523
2749
|
const localeTick = useLocaleTick();
|
|
@@ -2540,6 +2766,20 @@ window.__ModuleLoader__.load({
|
|
|
2540
2766
|
const tasks = usePendingTasks();
|
|
2541
2767
|
// 深链接意图:会话里点「查看验收」时落到对应模块 / 项目 / 阶段。
|
|
2542
2768
|
const intent = useStudioIntent();
|
|
2769
|
+
// 功能管理:被隐藏的模块既不在页签里,也不该在别处被切进来(深链接也会被挡)。
|
|
2770
|
+
const hidden = useHiddenModules(api);
|
|
2771
|
+
const visibleModules = visibleModulesOf(hidden);
|
|
2772
|
+
/**
|
|
2773
|
+
* 真正渲染的模块:当前选中项被隐藏(或压根不存在)时落到第一个可见模块。
|
|
2774
|
+
*
|
|
2775
|
+
* 不用等 `useEffect` 把 state 改回来——那样会先渲染一帧隐藏模块,
|
|
2776
|
+
* 深链接进被隐藏的模块时就会闪一下它的界面。
|
|
2777
|
+
*/
|
|
2778
|
+
const activeModule = visibleModules.some((entry) => entry.key === module) ? module : visibleModules.length > 0 ? visibleModules[0].key : null;
|
|
2779
|
+
React.useEffect(() => {
|
|
2780
|
+
if (activeModule !== null && activeModule !== module)
|
|
2781
|
+
setModule(activeModule);
|
|
2782
|
+
}, [activeModule, module]);
|
|
2543
2783
|
React.useEffect(() => {
|
|
2544
2784
|
if (intent === null)
|
|
2545
2785
|
return;
|
|
@@ -2740,15 +2980,20 @@ window.__ModuleLoader__.load({
|
|
|
2740
2980
|
}
|
|
2741
2981
|
const activeStageIndex = STAGES.findIndex((s) => s.key === stage);
|
|
2742
2982
|
const activeStage = STAGES[activeStageIndex < 0 ? 0 : activeStageIndex];
|
|
2743
|
-
return h("div", { className: "SPR_root" }, h("div", { className: "SPR_head" }, h("h2", null, T("游戏素材大师")), h("span", { className: "SPR_headSub" }, T("火山方舟 Seedream 生图 · MiniMax 图生视频 · 本地抠绿幕合成")), h("span", { className: "SPR_spacer" }),
|
|
2983
|
+
return h("div", { className: "SPR_root" }, h("div", { className: "SPR_head" }, h("h2", null, T("游戏素材大师")), h("span", { className: "SPR_headSub" }, T("火山方舟 Seedream 生图 · MiniMax 图生视频 · 本地抠绿幕合成")), h("span", { className: "SPR_spacer" }), activeModule === "sprite"
|
|
2744
2984
|
? 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("新建项目")))
|
|
2745
|
-
: null), h("div", { className: "SPR_modules" },
|
|
2985
|
+
: null), h("div", { className: "SPR_modules", "data-hidden-count": String(hidden.length) }, visibleModules.map((entry) => h("button", {
|
|
2746
2986
|
key: entry.key,
|
|
2747
2987
|
type: "button",
|
|
2748
2988
|
className: "SPR_module",
|
|
2749
|
-
"data-
|
|
2989
|
+
"data-module": entry.key,
|
|
2990
|
+
"data-active": activeModule === entry.key ? "true" : "false",
|
|
2750
2991
|
onClick: () => setModule(entry.key)
|
|
2751
|
-
}, h("span", { className: "SPR_moduleTitleRow" }, h("span", { className: "SPR_moduleTitle" }, entry.title), entry.experimental === true ? h("span", { className: "SPR_expTag" }, T("实验性")) : null), h("span", { className: "SPR_moduleHint" }, entry.hint)))
|
|
2992
|
+
}, h("span", { className: "SPR_moduleTitleRow" }, h("span", { className: "SPR_moduleTitle" }, entry.title), entry.experimental === true ? h("span", { className: "SPR_expTag" }, T("实验性")) : null), h("span", { className: "SPR_moduleHint" }, entry.hint))), hidden.length > 0
|
|
2993
|
+
? h("span", { className: "SPR_modulesHiddenNote" }, T("已隐藏 {n0} 个功能(设置 → 游戏素材大师 → 功能管理)", { n0: hidden.length }))
|
|
2994
|
+
: null), activeModule === null
|
|
2995
|
+
? h("div", { className: "SPR_body" }, h("p", { className: "SPR_empty" }, T("所有功能都已被隐藏。请到「设置 → 游戏素材大师 → 功能管理」里打开至少一个。")))
|
|
2996
|
+
: null, activeModule === "sprite"
|
|
2752
2997
|
? h("div", { className: "SPR_body" }, h("div", { className: "SPR_side" }, h("div", { className: "SPR_sideTitle" }, T("项目({n0})", { n0: projects.length })), projects.length === 0
|
|
2753
2998
|
? h("p", { className: "SPR_hint" }, T("还没有项目,点右上角「新建项目」开始。"))
|
|
2754
2999
|
: projects.map((summary) => h("button", {
|
|
@@ -2852,13 +3097,15 @@ window.__ModuleLoader__.load({
|
|
|
2852
3097
|
event.target.value = "";
|
|
2853
3098
|
}
|
|
2854
3099
|
})))), renderLog(project), h("div", { className: "SPR_toolbar" }, h(Btn, { onClick: () => void loadProject(project.id) }, T("刷新状态")), h(Btn, { onClick: () => void withApi(() => api.revealProject({ projectId: project.id })) }, T("在访达中打开项目目录"))))))
|
|
2855
|
-
:
|
|
3100
|
+
: activeModule === "image"
|
|
2856
3101
|
? h(ImageModule, { api })
|
|
2857
|
-
:
|
|
3102
|
+
: activeModule === "sequence"
|
|
2858
3103
|
? h(SequenceModule, { api })
|
|
2859
|
-
:
|
|
3104
|
+
: activeModule === "tile"
|
|
2860
3105
|
? h(TileModule, { api })
|
|
2861
|
-
:
|
|
3106
|
+
: activeModule === "rig"
|
|
3107
|
+
? h(RigModule, { api })
|
|
3108
|
+
: null);
|
|
2862
3109
|
}
|
|
2863
3110
|
/** 阶段卡片下方的说明文字(阶段①有两种生成方式,各说各的)。 */
|
|
2864
3111
|
function stageHint(project, stage, activeStage) {
|
|
@@ -8738,7 +8985,11 @@ window.__ModuleLoader__.load({
|
|
|
8738
8985
|
if (api === undefined)
|
|
8739
8986
|
return;
|
|
8740
8987
|
try {
|
|
8741
|
-
|
|
8988
|
+
const next = await api.getConfig();
|
|
8989
|
+
setConfig(next);
|
|
8990
|
+
// 可见性是全插件共享的状态(侧栏菜单 / 工作台页签都订阅它),
|
|
8991
|
+
// 每次读到配置就广播一次——包括保存后的重读。
|
|
8992
|
+
publishHiddenModules(next?.hiddenModules);
|
|
8742
8993
|
}
|
|
8743
8994
|
catch (error) {
|
|
8744
8995
|
setNotice({ kind: "error", text: msg(error) });
|
|
@@ -8763,6 +9014,18 @@ window.__ModuleLoader__.load({
|
|
|
8763
9014
|
return h("section", { className: "SPR_settings" }, h("p", { className: "SPR_hint" }, T("正在载入配置…")));
|
|
8764
9015
|
}
|
|
8765
9016
|
const patch = (values) => run(() => api.saveConfig(values), T("配置已保存"));
|
|
9017
|
+
/**
|
|
9018
|
+
* 功能管理:`hiddenModules` 的当前值(以宿主返回的为准)。
|
|
9019
|
+
*
|
|
9020
|
+
* 勾选立刻**乐观广播**一次,再落盘——工作台页签与侧栏菜单是另一个组件,
|
|
9021
|
+
* 等一个来回才变的话,用户会看到「勾了但菜单里还在」。
|
|
9022
|
+
*/
|
|
9023
|
+
const hiddenNow = normalizeHiddenKeys(config.hiddenModules);
|
|
9024
|
+
const toggleFeature = (key, visible) => {
|
|
9025
|
+
const next = MODULES.map((entry) => entry.key).filter((item) => (item === key ? !visible : hiddenNow.includes(item)));
|
|
9026
|
+
publishHiddenModules(next);
|
|
9027
|
+
void patch({ hiddenModules: next });
|
|
9028
|
+
};
|
|
8766
9029
|
// 模型能力决定分辨率档位与时长控件形态;切换模型后宿主会重新收敛,
|
|
8767
9030
|
// 这里始终以「当前模型」的能力为准,避免下拉里出现非法档位。
|
|
8768
9031
|
const minimaxCaps = config.minimaxCapabilitiesByModel?.[config.minimaxModel] ??
|
|
@@ -8959,7 +9222,26 @@ window.__ModuleLoader__.load({
|
|
|
8959
9222
|
min: 0,
|
|
8960
9223
|
max: 64,
|
|
8961
9224
|
onChange: (value) => void patch({ bottomMargin: value })
|
|
8962
|
-
}))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("
|
|
9225
|
+
}))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("功能管理")), h("p", null, T("隐藏不用的功能。隐藏后界面里不再出现它的页签与侧栏菜单项,对话里的 AI 也无法调用它(工具会直接报错)。随时可以再打开,已有的项目数据不会被删除。")), h("div", { className: "SPR_featureList" }, MODULES.map((entry) => {
|
|
9226
|
+
const isHidden = hiddenNow.includes(entry.key);
|
|
9227
|
+
return h("label", {
|
|
9228
|
+
key: entry.key,
|
|
9229
|
+
className: "SPR_featureRow",
|
|
9230
|
+
"data-hidden": isHidden ? "true" : "false",
|
|
9231
|
+
"data-feature": entry.key
|
|
9232
|
+
}, h("input", {
|
|
9233
|
+
type: "checkbox",
|
|
9234
|
+
className: "SPR_featureCheck",
|
|
9235
|
+
"data-testid": `cfg-feature-${entry.key}`,
|
|
9236
|
+
checked: !isHidden,
|
|
9237
|
+
onChange: (event) => toggleFeature(entry.key, event.target.checked)
|
|
9238
|
+
}), h("span", { className: "SPR_featureText" }, h("span", { className: "SPR_featureTitle" }, entry.title, entry.experimental === true ? h("span", { className: "SPR_expTag" }, T("实验性")) : null), h("span", { className: "SPR_featureHint" }, entry.hint)), h("span", { className: "SPR_featureState" }, isHidden ? T("已隐藏") : T("显示中")));
|
|
9239
|
+
})), hiddenNow.length === 0
|
|
9240
|
+
? h("p", { className: "SPR_hint" }, T("当前五个功能全部可见。"))
|
|
9241
|
+
: h("p", { className: "SPR_hint" }, T("已隐藏 {n0} 个功能:{n1}。隐藏的模块在对话里同样不可调用。", {
|
|
9242
|
+
n0: hiddenNow.length,
|
|
9243
|
+
n1: MODULES.filter((entry) => hiddenNow.includes(entry.key)).map((entry) => entry.title).join("、")
|
|
9244
|
+
}))), h("div", { className: "SPR_settingsGroup" }, h("h3", null, T("数据位置")), h("p", null, T("所有项目(源图、绿幕图、视频、序列帧、整图)都保存在:"), h("code", null, config.dataRoot)), h("div", { className: "SPR_toolbar" }, h(Btn, { onClick: () => void run(() => api.saveConfig({}), T("已刷新")) }, T("重新读取配置")))));
|
|
8963
9245
|
}
|
|
8964
9246
|
// ── cordis 插件体 ────────────────────────────────────────────────────
|
|
8965
9247
|
const inject = ["slots", "remote"];
|
|
@@ -9130,11 +9412,14 @@ window.__ModuleLoader__.load({
|
|
|
9130
9412
|
return () => { };
|
|
9131
9413
|
}, T("{n0}: 深链接引导", { n0: PACKAGE }));
|
|
9132
9414
|
// 侧栏全局面板图标;id 与 main 的 key 必须一致,点击即切到工作台。
|
|
9415
|
+
// 额外注入 api / studioCtx:图标右下角的菜单按钮要靠它们读可见性、
|
|
9416
|
+
// 并在选中某一项时切到对应模块(`openStudioIntent`)。
|
|
9133
9417
|
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
|
9134
9418
|
name: "sidebar.panellist",
|
|
9135
9419
|
id: GAME_STUDIO_PANEL_ID,
|
|
9136
9420
|
order: 40,
|
|
9137
|
-
label: () => T("游戏素材大师")
|
|
9421
|
+
label: () => T("游戏素材大师"),
|
|
9422
|
+
inject: () => ({ api, studioCtx: ctx })
|
|
9138
9423
|
}, StudioGlyph));
|
|
9139
9424
|
ctx.slots.inject("main", () => ctx.slots.register({
|
|
9140
9425
|
name: "main",
|
|
@@ -9154,7 +9439,7 @@ window.__ModuleLoader__.load({
|
|
|
9154
9439
|
bundleModule.exports.GAME_STUDIO_PANEL_ID = GAME_STUDIO_PANEL_ID;
|
|
9155
9440
|
// 仅测试用把手:三个模块组件在工厂闭包里,脚本要能拿出来单独渲染
|
|
9156
9441
|
// (见 scripts/verify-feedback.mjs)。运行时没有任何调用点。
|
|
9157
|
-
bundleModule.exports.__test = { StudioPanel, TileModule, ImageModule, SequenceModule, usePendingTasks, LoadingOverlay, MediaBox, BusyBtn, BusyBadge, NumField, ZoomableImage, CSS, subscribeIntent, parseIntents, openStudioIntent, OPEN_QUERY_KEY };
|
|
9442
|
+
bundleModule.exports.__test = { StudioPanel, TileModule, ImageModule, SequenceModule, usePendingTasks, LoadingOverlay, MediaBox, BusyBtn, BusyBadge, NumField, ZoomableImage, CSS, subscribeIntent, parseIntents, openStudioIntent, OPEN_QUERY_KEY, StudioGlyph, StudioGlyphIcon, publishHiddenModules, useHiddenModules, visibleModulesOf, normalizeHiddenKeys, ConfigSection };
|
|
9158
9443
|
return bundleModule.exports;
|
|
9159
9444
|
}
|
|
9160
9445
|
});
|
package/lib/config.js
CHANGED
|
@@ -8,6 +8,7 @@ import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { DEFAULT_ROW_ORDER } from "./directions.js";
|
|
11
|
+
import { STUDIO_MODULES } from "./links.js";
|
|
11
12
|
/**
|
|
12
13
|
* 上一版的默认行序(按生成依赖顺序)。方位语义修正后,默认改成罗盘顺时针;
|
|
13
14
|
* 配置里还留着旧默认值的用户应当自动迁过去,而不是被卡在旧顺序上。
|
|
@@ -131,6 +132,7 @@ export const DEFAULT_CONFIG = {
|
|
|
131
132
|
edgeShrink: 0,
|
|
132
133
|
rowOrder: [...DEFAULT_ROW_ORDER],
|
|
133
134
|
rowOrderVersion: ROW_ORDER_VERSION,
|
|
135
|
+
hiddenModules: [],
|
|
134
136
|
concurrency: 3
|
|
135
137
|
};
|
|
136
138
|
export const ARK_MODEL_PRESETS = [
|
|
@@ -177,6 +179,20 @@ function asNumber(value, fallback, min, max) {
|
|
|
177
179
|
return fallback;
|
|
178
180
|
return Math.min(max, Math.max(min, n));
|
|
179
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* 收敛「被隐藏的功能模块」:只留合法 key、去重,并按 `STUDIO_MODULES` 的固定
|
|
184
|
+
* 顺序排列。
|
|
185
|
+
*
|
|
186
|
+
* 排序不是为了好看:它让「同一组勾选」永远序列化成同一份 JSON,于是界面可以
|
|
187
|
+
* 用字符串比较判断「有没有变」,自检里也能直接对整份数组断言。
|
|
188
|
+
* 不认识的 key 一律丢掉——旧版本配置里留着的模块名不该让整个设置页起不来。
|
|
189
|
+
*/
|
|
190
|
+
export function normalizeHiddenModules(value) {
|
|
191
|
+
if (!Array.isArray(value))
|
|
192
|
+
return [];
|
|
193
|
+
const wanted = new Set(value.filter((key) => typeof key === "string"));
|
|
194
|
+
return STUDIO_MODULES.filter((key) => wanted.has(key));
|
|
195
|
+
}
|
|
180
196
|
/** 把任意读入的 JSON 收敛成一份合法配置,缺项一律回落默认值。 */
|
|
181
197
|
export function normalizeConfig(input) {
|
|
182
198
|
const raw = (input ?? {});
|
|
@@ -225,6 +241,7 @@ export function normalizeConfig(input) {
|
|
|
225
241
|
edgeShrink: asInt(raw.edgeShrink, DEFAULT_CONFIG.edgeShrink, 0, 8),
|
|
226
242
|
rowOrder,
|
|
227
243
|
rowOrderVersion: ROW_ORDER_VERSION,
|
|
244
|
+
hiddenModules: normalizeHiddenModules(raw.hiddenModules),
|
|
228
245
|
concurrency: asInt(raw.concurrency, DEFAULT_CONFIG.concurrency, 1, 8)
|
|
229
246
|
};
|
|
230
247
|
}
|
|
@@ -237,7 +254,7 @@ export async function loadConfig() {
|
|
|
237
254
|
cache = normalizeConfig(JSON.parse(text));
|
|
238
255
|
}
|
|
239
256
|
catch {
|
|
240
|
-
cache = { ...DEFAULT_CONFIG, rowOrder: [...DEFAULT_ROW_ORDER] };
|
|
257
|
+
cache = { ...DEFAULT_CONFIG, rowOrder: [...DEFAULT_ROW_ORDER], hiddenModules: [] };
|
|
241
258
|
}
|
|
242
259
|
return cache;
|
|
243
260
|
}
|
|
@@ -257,6 +274,8 @@ export function maskConfig(config) {
|
|
|
257
274
|
return {
|
|
258
275
|
...rest,
|
|
259
276
|
rowOrder: [...config.rowOrder],
|
|
277
|
+
// 复制一份再回传:界面改勾选后会把它当草稿改,共享同一个数组会互相写花。
|
|
278
|
+
hiddenModules: [...config.hiddenModules],
|
|
260
279
|
arkApiKeySet: arkApiKey.trim() !== "",
|
|
261
280
|
arkApiKeyHint: hintOf(arkApiKey),
|
|
262
281
|
minimaxApiKeySet: minimaxApiKey.trim() !== "",
|
package/lib/index.js
CHANGED
|
@@ -299,7 +299,10 @@ export class GameStudioGateway extends TypertRemoteService {
|
|
|
299
299
|
"bgTolerance",
|
|
300
300
|
"edgeShrink",
|
|
301
301
|
"rowOrder",
|
|
302
|
-
"concurrency"
|
|
302
|
+
"concurrency",
|
|
303
|
+
// 功能可见性:设置页的「功能管理」写它,`normalizeConfig` 会收敛成合法子集。
|
|
304
|
+
// 对话工具面**不允许**改它(见 tools.ts),否则模型可以自己把隐藏的功能放出来。
|
|
305
|
+
"hiddenModules"
|
|
303
306
|
];
|
|
304
307
|
for (const key of directKeys) {
|
|
305
308
|
if (input[key] !== undefined)
|
package/lib/tools.js
CHANGED
|
@@ -33,9 +33,184 @@ import { listSequenceJobs, readSequenceJob, listSequenceTasks } from "./seqgen.j
|
|
|
33
33
|
import { listRigJobs, readRigJob, rigSnapshot } from "./riggen.js";
|
|
34
34
|
import { listTileProjects, readTileProject, tileSnapshot } from "./tilegen.js";
|
|
35
35
|
import { TOOL_METHODS } from "./wire.js";
|
|
36
|
-
import { PANEL_KEY, buildOpenLink, originForLinks } from "./links.js";
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
import { PANEL_KEY, STUDIO_MODULES, buildOpenLink, originForLinks } from "./links.js";
|
|
37
|
+
import { loadConfig } from "./config.js";
|
|
38
|
+
/**
|
|
39
|
+
* 五个模块的 key 与界面里的模块 key 完全一致。
|
|
40
|
+
*
|
|
41
|
+
* 真源是 `links.ts` 的 `STUDIO_MODULES`(配置层的 `hiddenModules` 也按它收敛),
|
|
42
|
+
* 这里只是换个短名字。
|
|
43
|
+
*/
|
|
44
|
+
const MODULES = STUDIO_MODULES;
|
|
45
|
+
/** 模块的中文名,与界面页签的 title 逐字一致(报错信息里直接引用)。 */
|
|
46
|
+
export const MODULE_LABELS = {
|
|
47
|
+
sprite: "八方向图生成",
|
|
48
|
+
image: "图片生成",
|
|
49
|
+
sequence: "序列帧生成",
|
|
50
|
+
rig: "骨骼动画生成",
|
|
51
|
+
tile: "45°地图地块生成"
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 远程方法 → 它属于哪个模块。
|
|
55
|
+
*
|
|
56
|
+
* 这张表是「隐藏了功能,AI 也调不到」的落点:`game_material_call` 每次调用都
|
|
57
|
+
* 按它查一次模块再拦。`scripts/verify-tools.mjs` 有一条契约要求
|
|
58
|
+
* **每个** `TOOL_METHODS` 方法要么在这里、要么在 `SHARED_TOOL_METHODS` 里——
|
|
59
|
+
* 新加方法忘了归类会直接红,不会静默漏过。
|
|
60
|
+
*/
|
|
61
|
+
export const METHOD_MODULE = {
|
|
62
|
+
// 模块一 八方向图
|
|
63
|
+
listProjects: "sprite",
|
|
64
|
+
createProject: "sprite",
|
|
65
|
+
getProject: "sprite",
|
|
66
|
+
deleteProject: "sprite",
|
|
67
|
+
renameProject: "sprite",
|
|
68
|
+
uploadSource: "sprite",
|
|
69
|
+
savePrompts: "sprite",
|
|
70
|
+
saveSettings: "sprite",
|
|
71
|
+
setApproved: "sprite",
|
|
72
|
+
revealProject: "sprite",
|
|
73
|
+
runImage: "sprite",
|
|
74
|
+
runImages: "sprite",
|
|
75
|
+
setImageMode: "sprite",
|
|
76
|
+
runTurnVideo: "sprite",
|
|
77
|
+
runTurnFrames: "sprite",
|
|
78
|
+
setTurnPick: "sprite",
|
|
79
|
+
setTurnPicks: "sprite",
|
|
80
|
+
resetTurnPicks: "sprite",
|
|
81
|
+
cutTurnFrames: "sprite",
|
|
82
|
+
runVideos: "sprite",
|
|
83
|
+
pollVideos: "sprite",
|
|
84
|
+
clearVideos: "sprite",
|
|
85
|
+
runFrames: "sprite",
|
|
86
|
+
prepareFramePick: "sprite",
|
|
87
|
+
setFramePick: "sprite",
|
|
88
|
+
setFramePicks: "sprite",
|
|
89
|
+
resetFramePicks: "sprite",
|
|
90
|
+
rekey: "sprite",
|
|
91
|
+
compose: "sprite",
|
|
92
|
+
// 模块二 图片生成
|
|
93
|
+
listImageJobs: "image",
|
|
94
|
+
createImageJob: "image",
|
|
95
|
+
getImageJob: "image",
|
|
96
|
+
deleteImageJob: "image",
|
|
97
|
+
saveImageJob: "image",
|
|
98
|
+
uploadImageRef: "image",
|
|
99
|
+
removeImageRef: "image",
|
|
100
|
+
addImageItem: "image",
|
|
101
|
+
removeImageItem: "image",
|
|
102
|
+
runImageJob: "image",
|
|
103
|
+
keyImageJob: "image",
|
|
104
|
+
// 模块三 序列帧生成
|
|
105
|
+
listSequenceJobs: "sequence",
|
|
106
|
+
createSequenceJob: "sequence",
|
|
107
|
+
getSequenceJob: "sequence",
|
|
108
|
+
deleteSequenceJob: "sequence",
|
|
109
|
+
saveSequenceJob: "sequence",
|
|
110
|
+
uploadSequenceRef: "sequence",
|
|
111
|
+
removeSequenceRef: "sequence",
|
|
112
|
+
runSequenceVideo: "sequence",
|
|
113
|
+
pollSequenceVideo: "sequence",
|
|
114
|
+
clearSequenceVideo: "sequence",
|
|
115
|
+
runSequenceFrames: "sequence",
|
|
116
|
+
keySequenceFrames: "sequence",
|
|
117
|
+
composeSequence: "sequence",
|
|
118
|
+
// 模块四 骨骼动画生成
|
|
119
|
+
listRigJobs: "rig",
|
|
120
|
+
createRigJob: "rig",
|
|
121
|
+
getRigJob: "rig",
|
|
122
|
+
deleteRigJob: "rig",
|
|
123
|
+
saveRigJob: "rig",
|
|
124
|
+
uploadRigSource: "rig",
|
|
125
|
+
uploadRigPart: "rig",
|
|
126
|
+
removeRigPart: "rig",
|
|
127
|
+
renameRigPart: "rig",
|
|
128
|
+
setRigPartVisibility: "rig",
|
|
129
|
+
saveRigLayoutItem: "rig",
|
|
130
|
+
saveRigLayoutItems: "rig",
|
|
131
|
+
setRigLayoutHints: "rig",
|
|
132
|
+
setRigSemantics: "rig",
|
|
133
|
+
setRigBoneOffsets: "rig",
|
|
134
|
+
resetRigBoneOffsets: "rig",
|
|
135
|
+
setRigAnimationSettings: "rig",
|
|
136
|
+
resetRigAnimationSettings: "rig",
|
|
137
|
+
getRigAnimation: "rig",
|
|
138
|
+
saveRigAnimation: "rig",
|
|
139
|
+
resetRigAnimation: "rig",
|
|
140
|
+
runRigQa: "rig",
|
|
141
|
+
setRigConstraints: "rig",
|
|
142
|
+
resetRigConstraints: "rig",
|
|
143
|
+
setRigMesh: "rig",
|
|
144
|
+
resetRigMesh: "rig",
|
|
145
|
+
setRigPath: "rig",
|
|
146
|
+
resetRigPath: "rig",
|
|
147
|
+
tintRigParts: "rig",
|
|
148
|
+
uploadRigTexture: "rig",
|
|
149
|
+
setRigTextureVersion: "rig",
|
|
150
|
+
removeRigTextureVersion: "rig",
|
|
151
|
+
runRigRedraw: "rig",
|
|
152
|
+
runRigSheet: "rig",
|
|
153
|
+
runRigSegment: "rig",
|
|
154
|
+
runRigLayout: "rig",
|
|
155
|
+
runRigBones: "rig",
|
|
156
|
+
runRigAtlas: "rig",
|
|
157
|
+
// 模块五 45°地图地块
|
|
158
|
+
listTileProjects: "tile",
|
|
159
|
+
createTileProject: "tile",
|
|
160
|
+
getTileProject: "tile",
|
|
161
|
+
deleteTileProject: "tile",
|
|
162
|
+
saveTileProject: "tile",
|
|
163
|
+
runTileItems: "tile",
|
|
164
|
+
runTileItem: "tile",
|
|
165
|
+
setTileApproved: "tile",
|
|
166
|
+
runTileMap: "tile",
|
|
167
|
+
saveTileMapCells: "tile",
|
|
168
|
+
runTileExport: "tile",
|
|
169
|
+
cancelTileJob: "tile",
|
|
170
|
+
revealTileProject: "tile"
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* 不隶属于任何模块的方法:配置类 + 跨模块的审核模式
|
|
174
|
+
* (`setReviewMode` 的模块在 payload 里,另外判)。
|
|
175
|
+
*/
|
|
176
|
+
export const SHARED_TOOL_METHODS = new Set([
|
|
177
|
+
"getConfig",
|
|
178
|
+
"saveConfig",
|
|
179
|
+
"testArk",
|
|
180
|
+
"testMinimax",
|
|
181
|
+
"setReviewMode"
|
|
182
|
+
]);
|
|
183
|
+
/**
|
|
184
|
+
* 当前被隐藏的模块集合。
|
|
185
|
+
*
|
|
186
|
+
* 直接读配置缓存(`loadConfig` 命中内存缓存,不打盘),所以每次工具调用都能
|
|
187
|
+
* 拿到**最新**的勾选:用户在设置里取消隐藏后,下一次调用立刻可用,不需要重启。
|
|
188
|
+
*/
|
|
189
|
+
async function hiddenModulesNow() {
|
|
190
|
+
const config = await loadConfig();
|
|
191
|
+
return new Set(config.hiddenModules);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 【功能管理】被隐藏的模块对模型一律不可用。
|
|
195
|
+
*
|
|
196
|
+
* 只在界面上藏起来是不够的:模型看不见页签,照样能调 `runTileItems` 真实计费。
|
|
197
|
+
* 所以工具面必须自己再拦一次,并且报错里告诉用户去哪里打开。
|
|
198
|
+
*/
|
|
199
|
+
async function assertModuleVisible(module) {
|
|
200
|
+
if (module === undefined)
|
|
201
|
+
return;
|
|
202
|
+
const hidden = await hiddenModulesNow();
|
|
203
|
+
if (hidden.has(module)) {
|
|
204
|
+
throw new Error(`功能「${MODULE_LABELS[module]}」已被用户在「设置 → 游戏素材大师 → 功能管理」里隐藏,不能调用。` +
|
|
205
|
+
`请让用户先在那里把它打开;不要绕过这一限制。`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/** 方法属于哪个模块(共享方法返回 undefined)。 */
|
|
209
|
+
export function moduleOfMethod(method, payload) {
|
|
210
|
+
if (method === "setReviewMode")
|
|
211
|
+
return moduleOf(payload?.module);
|
|
212
|
+
return METHOD_MODULE[method];
|
|
213
|
+
}
|
|
39
214
|
/** 工具名统一前缀,避免和别家插件撞名。 */
|
|
40
215
|
const PREFIX = "game_material_";
|
|
41
216
|
/** 远程资源路由前缀,与 index.ts 的 ROUTE_PREFIX 一致。 */
|
|
@@ -384,6 +559,8 @@ function intentFromCall(method, payload) {
|
|
|
384
559
|
const CALL_DESCRIPTION = [
|
|
385
560
|
"调用「游戏素材大师」插件的任意远程方法——插件界面上的每个功能都能在这里调用。",
|
|
386
561
|
"配置:getConfig() / saveConfig(payload: 任意配置字段,如 arkApiKey、arkModel、minimaxModel、cellWidth…) / testArk() / testMinimax()",
|
|
562
|
+
" ⚠️ 用户可以在「设置 → 游戏素材大师 → 功能管理」里隐藏某些功能模块。被隐藏的模块**工具面一律拒绝**(界面也看不到),",
|
|
563
|
+
" 调用会直接报错并说明去哪里打开;不要试图绕过。hiddenModules 本身只能由用户在设置界面里改,工具面不允许写。",
|
|
387
564
|
"八方向图:listProjects() / createProject({name}) / getProject({projectId}) / deleteProject({projectId}) / renameProject({projectId,name}) /",
|
|
388
565
|
" uploadSource({projectId,name,data:base64}) / savePrompts({projectId,images?,video?,turn?,videoPerDirection?,suffix?,resetImagesToDefault?,resetVideoToDefault?,resetTurnToDefault?}) /",
|
|
389
566
|
" saveSettings({projectId,settings}) / setApproved({projectId,stage:images|videos|frames|sheet,key?,approved}) / revealProject({projectId}) /",
|
|
@@ -492,6 +669,11 @@ export function registerStudioTools(host, gateway) {
|
|
|
492
669
|
if (!spec.payload && payload !== undefined && Object.keys(payload).length > 0) {
|
|
493
670
|
throw new Error(`${method} 不接受 payload`);
|
|
494
671
|
}
|
|
672
|
+
// 「功能管理」的两道闸:被隐藏的模块整体拒掉;可见性本身只许用户在设置页里改。
|
|
673
|
+
await assertModuleVisible(moduleOfMethod(method, payload));
|
|
674
|
+
if (method === "saveConfig" && payload?.hiddenModules !== undefined) {
|
|
675
|
+
throw new Error("hiddenModules(功能可见性)只能由用户在「设置 → 游戏素材大师 → 功能管理」里修改,工具面不允许改动。");
|
|
676
|
+
}
|
|
495
677
|
const fn = gateway[method];
|
|
496
678
|
if (typeof fn !== "function")
|
|
497
679
|
throw new Error(`方法未实现:${method}`);
|
|
@@ -527,24 +709,30 @@ export function registerStudioTools(host, gateway) {
|
|
|
527
709
|
output: { schema: OBJECT_SCHEMA, render: (_args, value) => textBlocks(renderStatus(value)) },
|
|
528
710
|
async execute(args) {
|
|
529
711
|
const id = asString(args?.id);
|
|
712
|
+
const hidden = await hiddenModulesNow();
|
|
530
713
|
if (id === "") {
|
|
714
|
+
// 只列可见模块的清单:隐藏的模块连「有哪些项目」都不给模型看一眼。
|
|
715
|
+
await assertModuleVisible(moduleOf(args?.module));
|
|
531
716
|
const [projects, images, sequences, rigs, tiles] = await Promise.all([
|
|
532
|
-
|
|
717
|
+
hidden.has("sprite") ? [] : listProjects(),
|
|
718
|
+
hidden.has("image") ? [] : listImageJobs(),
|
|
719
|
+
hidden.has("sequence") ? [] : listSequenceJobs(),
|
|
720
|
+
hidden.has("rig") ? [] : listRigJobs(),
|
|
721
|
+
hidden.has("tile") ? [] : listTileProjects()
|
|
533
722
|
]);
|
|
723
|
+
const links = {};
|
|
724
|
+
for (const key of MODULES)
|
|
725
|
+
if (!hidden.has(key))
|
|
726
|
+
links[key] = buildOpenLink({ module: key });
|
|
534
727
|
return {
|
|
535
728
|
module: moduleOf(args?.module) ?? null,
|
|
729
|
+
hiddenModules: [...hidden],
|
|
536
730
|
projects,
|
|
537
731
|
imageJobs: images,
|
|
538
732
|
sequenceJobs: sequences,
|
|
539
733
|
rigJobs: rigs,
|
|
540
734
|
tileProjects: tiles,
|
|
541
|
-
links
|
|
542
|
-
sprite: buildOpenLink({ module: "sprite" }),
|
|
543
|
-
image: buildOpenLink({ module: "image" }),
|
|
544
|
-
sequence: buildOpenLink({ module: "sequence" }),
|
|
545
|
-
rig: buildOpenLink({ module: "rig" }),
|
|
546
|
-
tile: buildOpenLink({ module: "tile" })
|
|
547
|
-
},
|
|
735
|
+
links,
|
|
548
736
|
hint: "用 game_material_status({module,id}) 看某个目标的细节;八方向图的四步是 images → videos → frames → sheet,45°地图地块是 generate → review → map → export。"
|
|
549
737
|
};
|
|
550
738
|
}
|
|
@@ -552,6 +740,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
552
740
|
// 短路会把「带 id 的查询」变成「列清单」,assetBase / 几何报告全丢。
|
|
553
741
|
// 只给了 module、没给 id 的情况,上面的 `id === ""` 分支已经覆盖了。
|
|
554
742
|
const module = resolveTarget(args?.module, id);
|
|
743
|
+
await assertModuleVisible(module);
|
|
555
744
|
const snapshot = await snapshotOf(module, id);
|
|
556
745
|
const stage = typeof args?.stage === "string" ? args.stage : undefined;
|
|
557
746
|
return { ...snapshot, ...openInfo(intentOf(module, id, { stage }), "点开可以看到产物并打「通过」") };
|
|
@@ -586,6 +775,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
586
775
|
const module = moduleOf(args?.module);
|
|
587
776
|
if (module === undefined)
|
|
588
777
|
throw new Error(`未知模块:${String(args?.module)}`);
|
|
778
|
+
await assertModuleVisible(module);
|
|
589
779
|
const id = asString(args?.id);
|
|
590
780
|
const told = new Set(Array.isArray(args?.told) ? args.told.map((entry) => String(entry)) : []);
|
|
591
781
|
const config = await gateway.getConfig();
|
|
@@ -624,6 +814,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
624
814
|
const module = moduleOf(args?.module);
|
|
625
815
|
if (module === undefined)
|
|
626
816
|
throw new Error(`未知模块:${String(args?.module)}`);
|
|
817
|
+
await assertModuleVisible(module);
|
|
627
818
|
const id = asString(args?.id);
|
|
628
819
|
const kind = asString(args?.kind);
|
|
629
820
|
const path = asString(args?.path);
|
|
@@ -654,6 +845,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
654
845
|
const module = moduleOf(args?.module);
|
|
655
846
|
if (module === undefined)
|
|
656
847
|
throw new Error(`未知模块:${String(args?.module)}`);
|
|
848
|
+
await assertModuleVisible(module);
|
|
657
849
|
const result = await gateway.setReviewMode({
|
|
658
850
|
module,
|
|
659
851
|
id: asString(args?.id),
|
|
@@ -687,6 +879,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
687
879
|
if (id === "")
|
|
688
880
|
throw new Error("id 不能为空");
|
|
689
881
|
const module = resolveTarget(args?.module, id);
|
|
882
|
+
await assertModuleVisible(module);
|
|
690
883
|
const timeoutMs = clampInt(args?.timeoutSeconds, 120, 1, 900) * 1000;
|
|
691
884
|
const startedAt = Date.now();
|
|
692
885
|
let snapshot = await snapshotOf(module, id);
|
|
@@ -732,6 +925,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
732
925
|
if (id === "")
|
|
733
926
|
throw new Error("id 不能为空");
|
|
734
927
|
const module = resolveTarget(args?.module, id);
|
|
928
|
+
await assertModuleVisible(module);
|
|
735
929
|
const snapshot = await snapshotOf(module, id);
|
|
736
930
|
const stage = typeof args?.stage === "string" ? args.stage : undefined;
|
|
737
931
|
const direction = typeof args?.direction === "string" ? args.direction : undefined;
|
|
@@ -854,6 +1048,7 @@ export function registerStudioTools(host, gateway) {
|
|
|
854
1048
|
if (typeof args?.approved !== "boolean")
|
|
855
1049
|
throw new Error("approved 必须是布尔值");
|
|
856
1050
|
const module = resolveTarget(args?.module, id);
|
|
1051
|
+
await assertModuleVisible(module);
|
|
857
1052
|
const approved = args.approved === true;
|
|
858
1053
|
if (module === "sprite") {
|
|
859
1054
|
const stage = asString(args?.stage, "images");
|
|
@@ -992,7 +1187,15 @@ const PROMPT_SECTION = [
|
|
|
992
1187
|
"`manual` 模式下每完成一步都要贴一次;`auto` 模式下至少在全部完成或需要用户决策时贴。",
|
|
993
1188
|
"",
|
|
994
1189
|
"### 计费与重复提交",
|
|
995
|
-
"生图与生视频都真实计费:不要为了确认状态而重复提交同一个目标;提交类调用返回后一律先 `game_material_wait`。"
|
|
1190
|
+
"生图与生视频都真实计费:不要为了确认状态而重复提交同一个目标;提交类调用返回后一律先 `game_material_wait`。",
|
|
1191
|
+
"",
|
|
1192
|
+
"### 被用户隐藏的功能(功能管理)",
|
|
1193
|
+
"用户可以在「设置 → 游戏素材大师 → 功能管理」里把某个模块隐藏起来。被隐藏的模块:",
|
|
1194
|
+
" · 插件界面里不再出现它的页签与侧栏菜单项;",
|
|
1195
|
+
" · 工具面**同样不可用**——`game_material_call` / `status` / `intake` / `upload` / `wait` / `review` / `approve` 都会明确报错。",
|
|
1196
|
+
"`game_material_status`(不带 id)返回的 `hiddenModules` 是当前被隐藏的模块 key 列表。",
|
|
1197
|
+
"遇到这类报错时**不要重试、也不要绕过**(例如直接改配置文件):告诉用户这个功能被隐藏了,请他在设置里打开。",
|
|
1198
|
+
"`hiddenModules` 也不能通过 `game_material_call({method:\"saveConfig\"})` 修改——工具面会拒绝。"
|
|
996
1199
|
].join("\n");
|
|
997
1200
|
function sleep(ms, signal) {
|
|
998
1201
|
return new Promise((resolve, reject) => {
|
|
@@ -1358,6 +1561,9 @@ function renderStatus(value) {
|
|
|
1358
1561
|
...value.imageJobs.map((j) => ` - ${j.id} ${j.name} — ${j.ready}/${j.total} 张(抠像 ${j.keyed})`),
|
|
1359
1562
|
`序列帧任务(${value.sequenceJobs.length}):`,
|
|
1360
1563
|
...value.sequenceJobs.map((j) => ` - ${j.id} ${j.name} — 视频${j.videoReady ? "✓" : "✗"} 帧${j.frameReady ? "✓" : "✗"} 条图${j.sheetReady ? "✓" : "✗"}`),
|
|
1564
|
+
...(Array.isArray(value.hiddenModules) && value.hiddenModules.length > 0
|
|
1565
|
+
? [`已隐藏的功能(工具面同样不可调用):${value.hiddenModules.map((key) => MODULE_LABELS[key] ?? key).join("、")}`]
|
|
1566
|
+
: []),
|
|
1361
1567
|
value.hint
|
|
1362
1568
|
];
|
|
1363
1569
|
return lines.join("\n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-game-material-master",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "游戏素材大师:DSH 插件,包含八方向图生成、图片生成、序列帧生成三个正式模块,以及实验性的 45° 地图地块生成与骨骼动画生成模块。界面与内置提示词跟随 DSH 语言设置(中 / 英)。八方向图默认「转圈截帧」(一段原地匀速转一圈的绿幕视频 → 按时间轴截出八个方向),也可逐方向生图;45° 地图地块用「几何交给代码、内容交给 AI」的方式拼成整张地图。火山方舟 Seedream 生图 + MiniMax 图生视频 + 本地抠绿幕合成。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|