Compare commits

...
7 Commits
Author SHA1 Message Date
ketle-manandClaude Opus 5.5 98d30db04e release: v0.10.2 — Game tab Settings pane, help for Prompt Typer and Sky Heart (game pack v0.3.0)
- Help: Prompt Typer (helpGame10) and Sky Heart (helpGame11) in en/ja/zh;
  helpGame2 now explains the right pane's Result / Settings tabs.
- README: Game tab section lists games 3 and 4 and the Settings tab.
- Version 0.10.2, DEVLOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 15:34:24 +09:00
ketle-manandClaude Opus 5.5 65c1351a83 feat: Game tab right pane split into Result / Settings tabs
Left pane now lists games only. Play settings and image generation
settings move to a Settings tab in the right pane; the Result tab
keeps the status and image cards and opens automatically when a new
image card is added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:51:16 +09:00
ketle-manandClaude Opus 5.5 8ce74d761e release: v0.10.1 — Game tab help for Turbo Heart (game pack v0.2.0)
- Help: Turbo Heart entry (controls, 5 races, top 3 to advance, hearts,
  obstacles, images) in en / ja / zh
- README: Turbo Heart in the Game tab section
- No code changes needed on the Workflow Studio side

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 12:01:48 +09:00
ketle-manandClaude Opus 5.5 1888dd0698 chore: stop tracking PLAN_GAME_TAB.md
- Keep the Game tab planning doc local (added to .gitignore like the
  other *_PLAN.md files); the file itself stays in the working folder
- README / DEVLOG / game-tab.js no longer point to it (README links the
  game pack's README instead)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:52:05 +09:00
ketle-manandClaude Opus 5.5 b6778560b0 docs: Game tab help for Turbo Heart, plan notes for game 2
- Help page: Turbo Heart entry (controls, 5 races, top 3 to advance,
  images) in en / ja / zh
- PLAN_GAME_TAB.md: section 13 (Turbo Heart design, scenery, thrill,
  image prompts, shared code) and notes on clouds, city-pop BGM and
  tire squeal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:43:17 +09:00
ketle-manandClaude Opus 5.5 0830a3f372 release: v0.10.0 — Game tab (experimental, needs ComfyUI-WFS-Games)
- Game tab: shown only when the ComfyUI-WFS-Games pack answers
  /wfs_games/manifest; games are ES modules mounted with
  mount(container, host) and report through runStart / stageClear /
  finish
- Result panel: one card per image (each stage clear, ending, game
  over, private photo), generated one at a time in the background while
  playing; prompts listed by kind, editable, Regenerate / Open in
  GenerateUI; the game's negative tags are added
- Settings: generation workflow (default ws_game_sdxl_t2i.json, now in
  workflows/), base / negative prompt, auto-generate per stage / ending
  / game over, difficulty, music, sound effects
- VRAM Management: prepareVramForGeneration({ quiet }) and
  comfyUI.generate(..., { quietVram }); no toast while the Game tab is
  open or for Game tab generations
- en / ja / zh strings, help page, README, DEVLOG, PLAN_GAME_TAB.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 17:21:03 +09:00
ketle-manandClaude Opus 5.5 086a767aff feat: experimental Game tab (needs the ComfyUI-WFS-Games pack)
- Game tab shows only when /wfs_games/manifest responds (pack installed);
  the help page is hidden the same way
- Games are loaded with dynamic import and mounted via mount(container, host);
  host passes language and play settings (difficulty, sound, bgm)
- On clear, the prompts returned by the game (style / heroine / scene /
  stage) are listed with their kind; the base prompt plus the checked
  prompts are written into the chosen workflow's positive prompt and
  generated with comfyUI.generate(); the game's negative tags are added
- Generation workflow is chosen in the Game settings
  (default ws_game_sdxl_t2i.json); no generation on game over
- Settings kept in localStorage wfm_game_settings (included in backups)
- en / ja / zh strings, help page, PLAN_GAME_TAB.md (plan, library
  choice, research on similar nodes, implementation notes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 23:51:40 +09:00
15 changed files with 1152 additions and 9 deletions
+1
View File
@@ -12,3 +12,4 @@ graphify-out/
# Working-notes plan docs — local scratch, not meant to ship with the repo
VIDEO_EDIT_TAB_PLAN.md
QWEN_CHAT_INTEGRATION_PLAN.md
PLAN_GAME_TAB.md
+3
View File
@@ -2,6 +2,9 @@
Condensed version-by-version index of DEVLOG.md (each line: version + one-line summary of what changed and why). Full rationale, code details, and "How to apply" lessons live in the excluded DEVLOG.md itself; this index exists so graphify can extract a queryable semantic node per release without feeding the full log to the local Ollama model. Regenerate with `python tools/generate_doc_index.py devlog` whenever DEVLOG.md changes.
- **v0.10.2(2026-11-18)** — Game タブ: 右ペインを「結果 / 設定」のタブに、第3弾・第4弾に対応(ゲームパック ComfyUI-WFS-Games v0.3.0)
- **v0.10.1(2026-11-18)** — Game タブ: 第2弾 Turbo Heart に対応(ゲームパック ComfyUI-WFS-Games v0.2.0)
- **v0.10.0(2026-11-17)** — Game タブ(実験的機能・別パッケージ ComfyUI-WFS-Games が必要)
- **v0.9.10(2026-11-15)** — プロンプト翻訳API(Comic Creator から使うための整備)
- **v0.9.9(2026-11-15)** — プロンプト翻訳(自国語 → 英語、PLaMo 3 Translate)
- **v0.9.8(2026-11-14)** — セキュリティ: クライアントから受け取るパスを解決前に検証
+39
View File
@@ -2,6 +2,45 @@
---
## v0.10.2(2026-11-18)
### Game タブ: 右ペインを「結果 / 設定」のタブに、第3弾・第4弾に対応(ゲームパック ComfyUI-WFS-Games v0.3.0)
- 左ペインはゲーム一覧だけにし、プレイ設定と画像生成設定を右ペインの「設定」タブへ移動。「結果」タブは画像カード。新しい画像カードが追加されたときは結果タブに切り替える。タブは共通の .wfm-side-tab-nav / .wfm-side-tab-btn を使用、i18n キー gameSettingsTab(英日中)。
- ヘルプに Prompt Typer(helpGame10)と Sky Heart(helpGame11)の項目を追加し、helpGame2 に右ペインのタブの説明を追記(英日中)。
- README の Game タブ節に第3弾・第4弾を追加。Host API の変更はなし。
- 第3弾 Prompt Typer(パック側): 打った文字(誤字込み)がそのままプロンプトになるタイピングゲーム。10ステージ x 20ワード、85%でクリア、クリアできなくても毎ステージ画像生成、リトライ可。英日中(日中は IME の入力欄、漢字に読みがな、ひらがな/カタカナ同一視)、バックスペースは今のワードのみ(ミス数は減らない)、BGM なし。
- 第4弾 Sky Heart(パック側): 画面の奥へ飛ぶ疑似3Dシューティング。ヒカリ(ジェットパック)で全5ステージ+ボス、高度計、空中・地上のハート、地上のミサイル発射台、パワーアップ(1UP・バリア・サポートメカ)、ステージ4のビルは4発で破壊。
---
## v0.10.1(2026-11-18)
### Game タブ: 第2弾 Turbo Heart に対応(ゲームパック ComfyUI-WFS-Games v0.2.0)
- ヘルプページに Turbo Heart の項目を追加(英日中): 操作、全5レース、8台で3位以内なら次へ、コース上のハート5個、障害物(ダンボール・オイル・道を渡る人)、画像の仕組みは Star Formation と同じ。
- README の Game タブ節に Turbo Heart を追加。WFS 側のコード変更はなし(Host API はそのまま使える)。
- 企画書 PLAN_GAME_TAB.md はリポジトリ外で管理するようにした(.gitignore に追加し、履歴からも削除)。
---
## v0.10.0(2026-11-17)
### Game タブ(実験的機能・別パッケージ ComfyUI-WFS-Games が必要)
- ゲームをクリアした結果で画像を生成するタブ。ゲーム本体は別パッケージ [ComfyUI-WFS-Games](https://github.com/ketle-man/ComfyUI-WFS-Games)(Phaser 4.2.1 同梱、ノードなし)で配布し、`/wfs_games/manifest` が応答したときだけタブとヘルプページを表示する(Mask Editor One 連携と同じ「ルート疎通」方式)。未インストール環境では従来どおり。
- ゲームは manifest の `entry`(同一オリジン `/wfs_games/static/` 配下のみ許可)を動的 import し `mount(container, host)` で起動。host は言語・プレイ設定(難易度・BGM・効果音)と `runStart()` / `stageClear(result)` / `finish(result)` を渡す。ゲームは ComfyUI を直接操作しない。
- 結果パネルは「画像1枚 = カード1枚」。ステージクリア・エンディング・ゲームオーバーごとにカードを追加し、生成はキューで1枚ずつ順番に(プレイは止めない)。カードではゲームから渡されたプロンプトを種類(画風/ヒロイン/シーン/ステージ)付きで確認・除外・編集でき、「再生成」「GenerateUIで開く」。ゲームのネガティブはワークフローのネガティブ(または設定値)に足す。
- 設定(localStorage `wfm_game_settings`、バックアップ対象): 生成ワークフロー(既定 `ws_game_sdxl_t2i.json`)、ベースプロンプト、ネガティブ、ステージクリアごと/エンディング/ゲームオーバーの自動生成、難易度・BGM・効果音。旧既定のベースプロンプトは自動で置き換え。
- サンプルワークフロー `workflows/ws_game_sdxl_t2i.json`(SDXL T2I、1216x832、出力 `WFS_Game/`)を同梱。Game タブの既定。
- 生成は既存の `convertUiToApi` → `analyzeWorkflow` → ポジティブノードへ書き込み → `_expandWildcardsInWorkflow` → `comfyUI.generate` を再利用。
- VRAM 調整: `prepareVramForGeneration({ quiet })` と `comfyUI.generate(..., { quietVram })` を追加。Game タブからの生成と Game タブ表示中はトーストを出さずコンソールにだけ出す(ゲーム画面を隠さない)。
- 第一弾「Star Formation」(パック側): 80年代(アーケード/MSX2/PC-8801)風の縦シューティング。全5ステージ・ステージごとのボス(WARNING とボス BGM)、ナビゲーターのリナとの ADV 風会話、PSG 風のオリジナル BGM、ドット絵・DotGothic16・走査線。ステージクリアで勝利の記念カット、各ステージ5個のハートを全部取るとプライベート写真(ステージごとに露出が増え、上限は水着。ネガティブで制限)、全クリアでエンディング、ゲームオーバーで敗北シーンを生成。
- en/ja/zh の文言とヘルプページ、企画書(企画・ライブラリ選定・類似ノード調査・実装記録。リポジトリ外で管理)。
- 実機確認: Playwright で検出/非表示、操作・一時停止、各ボスの動き、アイテム、ステージごと・エンディング・ゲームオーバー・プライベート写真の実生成、VRAM 調整でモデルがアンロードされてもトーストが出ないこと。
---
## v0.9.10(2026-11-15)
### プロンプト翻訳API(Comic Creator から使うための整備)
+6 -1
View File
@@ -27,7 +27,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.9.10-green)
![Version](https://img.shields.io/badge/version-0.10.2-green)
## Features (tab -> feature names)
@@ -76,6 +76,9 @@ Model Browser, Thumbnail / Table views, Table column sort, Search & Filter, User
### TagSpace Tab (v0.9.0)
Choose tags visually in a 3D latent space, Build / Update, Choosing tags, Explore, Search with a card's or Gallery image's tags, Make a prompt, Tagger fill, Glow / Twinkle, Hover preview, Requirements
### Game Tab (v0.10.0 – v0.10.2, experimental)
Play, then generate, Star Formation, Turbo Heart, Prompt Typer, Sky Heart, An image at every stage clear, Prompts from the game, Settings, For game authors
### Image Edit Tab (v0.3.65)
Layer-based image editor, Loading images, Open PSD button, Close button, New button, Tools, Layer panel, Duplicate layer (⧉), Layer lock, Text quality, Export, Canvas navigation, Undo / Redo
@@ -114,6 +117,8 @@ Sample workflows are included in the `workflows/` folder. You can open them dire
Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder` (Image Loop mode, require the `comfyui-image-feeder` custom node) and `ws_sdxl_gallery_feeder_i2i` (v0.8.3, SDXL I2I with the bundled **WFS_GalleryFeeder** node — no extra custom node needed; put images in the `__Feeder__` Gallery group and use the Feeder tab's Gallery mode).
Sample for the Game tab: `ws_game_sdxl_t2i` (v0.10.0, SDXL text-to-image, 1216x832, saves to `output/WFS_Game`) — the Game tab's default workflow. Import it from the Workflow tab (or copy it into ComfyUI's `user/default/workflows`) and change the checkpoint to an SDXL model you have (the sample uses an Illustrious model, which suits the game's 1980s anime prompts).
> **Note:** Some sample workflows require additional custom nodes.
> If a node is shown as missing (red/unknown) after loading, install the required custom nodes via **ComfyUI Manager** or by cloning the repository from GitHub into your `ComfyUI/custom_nodes/` directory.
>
+18 -1
View File
@@ -23,7 +23,7 @@ A comprehensive workflow, asset management, and generation UI plugin for [ComfyU
- Built-in AI tools (translation and more)
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.9.10-green)
![Version](https://img.shields.io/badge/version-0.10.2-green)
## Screenshots
@@ -439,6 +439,21 @@ An experimental batch generator: runs the workflow currently loaded in GenerateU
</details>
<details>
<summary><h3>Game Tab (v0.10.0 – v0.10.2, experimental)</h3></summary>
- **Play, then generate** — a tab for mini games that end in image generation. The games come from a separate pack, [ComfyUI-WFS-Games](https://github.com/ketle-man/ComfyUI-WFS-Games); the tab appears only when the pack is installed (Workflow Studio checks `/wfs_games/manifest` on start), so without it nothing changes
- **Star Formation** (first game) — a 1980s-style vertical shooter (arcade / MSX2 / PC-8801 look: pixel sprites, pixel font, scanlines, chiptune music) built on Phaser 4. 5 stages, each ending with a boss (WARNING, boss music; big and tough / fast with fast shots / radial bursts / flashing straight-line ram / a giant carrier launching small fighters). Navigator Rina talks between stages in an adventure-game style window
- **Turbo Heart** (second game, pack v0.2.0) — a 1980s-style behind-the-car racer with a pseudo-3D road and city-pop style chiptune music. 5 races (seaside highway, autumn mountain pass, desert canyon, neon city at night, tropical coast at dawn); 8 cars, start last, top 3 to advance. Nitro, speed lines, overtakes, tire squeal; obstacles (cardboard boxes, an oil slick, sometimes a person crossing — hitting them ends the game). Mechanic Misaki talks between races, and the images work the same way as in Star Formation
- **Prompt Typer** (third game, pack v0.3.0) — a 1980s-style typing game whose typing becomes the image prompt, typos included. 10 stages of 20 words, longer every 2 stages; 85% correct clears a stage, an image is generated after every stage either way, and you can retry. English, Japanese and Chinese (Japanese / Chinese through your IME). No music
- **Sky Heart** (fourth game, pack v0.3.0) — a 1980s-style into-the-screen flying shooter with a pseudo-3D ground. Hikari flies a jet pack through 5 stages with bosses; an altimeter, hearts in the air and near the ground, ground missile launchers, and power-ups (1UP, a 3-hit barrier, support mechs that fire with you). The images work the same way as in Star Formation
- **An image at every stage clear** — a card is added to the Result panel and a victory shot of Rina with that stage in the background is generated in the background while you keep playing (one at a time, in order). Five flashing enemies per stage drop hearts; catch all 5 and that stage's image becomes a private photo of Rina instead (more casual clothes each stage, up to a swimsuit — the game adds negative tags so it goes no further). Clearing all 5 stages adds the ending scene; a game over adds a defeat scene (screen darkens, her call goes unanswered)
- **Prompts from the game** — each card lists the prompts the game returned with their kind (Style / Heroine / Scene / Stage); uncheck or edit them and Regenerate, or **Open in GenerateUI**. The game's negative tags are added to the workflow's negative prompt
- **Settings** (the Settings tab of the right pane since v0.10.2; the left pane lists the games only) — the workflow used for generation (default `ws_game_sdxl_t2i.json`, an SDXL text-to-image workflow included in `workflows/` — import it and set your checkpoint; output in `output/WFS_Game`), base prompt, negative prompt, and whether to generate at each stage clear / the ending / on game over automatically; difficulty, music and sound effects. VRAM Management notices are not shown while the Game tab is open
- **For game authors** — a game is an ES module with `mount(container, host)`; it reports results through `host.stageClear()` / `host.finish()` and never calls ComfyUI itself — Workflow Studio builds the prompt and runs the generation. See the [pack's README](https://github.com/ketle-man/ComfyUI-WFS-Games)
</details>
<details>
<summary><h3>Image Edit Tab (v0.3.65)</h3></summary>
@@ -596,6 +611,8 @@ Sample workflows are included in the `workflows/` folder. You can open them dire
Samples for the Feeder tab: `ws_sdxl_image_feeder_i2i` / `ws_dwpose_image_feeder` (Image Loop mode, require the `comfyui-image-feeder` custom node) and `ws_sdxl_gallery_feeder_i2i` (v0.8.3, SDXL I2I with the bundled **WFS_GalleryFeeder** node — no extra custom node needed; put images in the `__Feeder__` Gallery group and use the Feeder tab's Gallery mode).
Sample for the Game tab: `ws_game_sdxl_t2i` (v0.10.0, SDXL text-to-image, 1216x832, saves to `output/WFS_Game`) — the Game tab's default workflow. Import it from the Workflow tab (or copy it into ComfyUI's `user/default/workflows`) and change the checkpoint to an SDXL model you have (the sample uses an Illustrious model, which suits the game's 1980s anime prompts).
> **Note:** Some sample workflows require additional custom nodes.
> If a node is shown as missing (red/unknown) after loading, install the required custom nodes via **ComfyUI Manager** or by cloning the repository from GitHub into your `ComfyUI/custom_nodes/` directory.
>
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-workflow-studio"
description = "A comprehensive workflow, asset management, and generation UI plugin for ComfyUI. Manage workflows, models, images, and prompts; batch generation and Image Feeder in the GenerateUI tab; library side panel with canvas drag & drop and AI tools."
version = "0.9.10"
version = "0.10.2"
license = { file = "LICENSE" }
requires-python = ">= 3.10"
dependencies = ["jinja2"]
+58
View File
@@ -0,0 +1,58 @@
/* Game タブ (実験的機能・ComfyUI-WFS-Games が必要) */
#wfm-tab-game.active { overflow: hidden; }
.wfm-game-layout { display: flex; height: 100%; min-height: 0; }
.wfm-game-layout [hidden] { display: none !important; }
.wfm-game-side,
.wfm-game-result { width: 290px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: auto; }
.wfm-game-side { border-right: 1px solid var(--wfm-border, #444); }
.wfm-game-result { border-left: 1px solid var(--wfm-border, #444); width: 320px; padding: 0; gap: 0; overflow: hidden; }
/* 右ペインのタブ (結果 / 設定)。タブ本体の見た目は main.css の .wfm-side-tab-nav / .wfm-side-tab-btn */
.wfm-game-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: auto; }
.wfm-game-section { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px solid var(--wfm-border, #444); border-radius: var(--wfm-radius, 6px); background: var(--wfm-surface, transparent); }
.wfm-game-section-title { font-size: 12px; font-weight: 600; color: var(--wfm-text-secondary, #aaa); text-transform: uppercase; letter-spacing: 0.04em; }
.wfm-game-list { display: flex; flex-direction: column; gap: 6px; }
.wfm-game-card { display: flex; flex-direction: column; gap: 3px; padding: 8px; text-align: left; border-radius: var(--wfm-radius-sm, 4px); cursor: pointer; color: var(--wfm-text, #ddd); background: var(--wfm-bg-secondary, #222); border: 1px solid var(--wfm-border, #444); }
.wfm-game-card:hover { border-color: var(--wfm-primary, #4a9eff); }
.wfm-game-card.active { border-color: var(--wfm-primary, #4a9eff); box-shadow: 0 0 0 1px var(--wfm-primary, #4a9eff) inset; }
.wfm-game-card img { width: 100%; max-height: 90px; object-fit: cover; border-radius: 3px; }
.wfm-game-card-name { font-weight: 600; font-size: 13px; }
.wfm-game-card-desc { font-size: 11px; color: var(--wfm-text-secondary, #aaa); line-height: 1.4; }
.wfm-game-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.wfm-game-field > span { color: var(--wfm-text-secondary, #aaa); }
.wfm-game-field textarea { width: 100%; resize: vertical; box-sizing: border-box; }
.wfm-game-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.wfm-game-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.wfm-game-row select { flex: 1; min-width: 0; }
.wfm-game-note { font-size: 11px; color: var(--wfm-text-secondary, #aaa); line-height: 1.4; }
.wfm-game-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wfm-game-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--wfm-border, #444); }
.wfm-game-current { font-weight: 600; }
.wfm-game-spacer { flex: 1; }
.wfm-game-stage { flex: 1; min-height: 0; position: relative; background: #05060f; overflow: hidden; }
.wfm-game-stage canvas { display: block; }
.wfm-game-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: #94a3b8; }
.wfm-game-result-status { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.wfm-game-result-head { font-size: 20px; font-weight: 700; letter-spacing: 0.05em; }
.wfm-game-result-head.cleared { color: var(--wfm-success, #2ed573); }
.wfm-game-result-head.failed { color: var(--wfm-danger, #ff4757); }
.wfm-game-rewards { display: flex; flex-direction: column; gap: 4px; }
.wfm-game-reward { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; padding: 4px 6px; border-radius: var(--wfm-radius-sm, 4px); background: var(--wfm-bg-secondary, #222); cursor: pointer; }
.wfm-game-reward span { word-break: break-word; }
.wfm-game-reward-src { display: inline-block; margin-right: 6px; padding: 0 5px; border-radius: 3px; font-size: 10px; line-height: 16px; vertical-align: 1px; color: var(--wfm-text, #ddd); background: var(--wfm-bg-tertiary, #334); }
.wfm-game-progress { height: 6px; border-radius: 3px; overflow: hidden; background: var(--wfm-bg-secondary, #333); }
.wfm-game-progress-bar { height: 100%; width: 0; background: var(--wfm-primary, #4a9eff); transition: width 0.2s; }
.wfm-game-progress-text { font-size: 11px; color: var(--wfm-text-secondary, #aaa); word-break: break-all; min-height: 14px; }
.wfm-game-jobs { display: flex; flex-direction: column; gap: 8px; }
.wfm-game-job { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--wfm-border, #444); border-radius: var(--wfm-radius, 6px); background: var(--wfm-surface, transparent); }
.wfm-game-job-gameover { border-color: var(--wfm-danger, #ff4757); }
.wfm-game-job-gameover .wfm-game-job-title { color: var(--wfm-danger, #ff4757); }
.wfm-game-job-head { display: flex; align-items: baseline; gap: 8px; }
.wfm-game-job-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wfm-game-job-status { flex: none; font-size: 11px; color: var(--wfm-text-secondary, #aaa); }
.wfm-game-job-status[data-status="done"] { color: var(--wfm-success, #2ed573); }
.wfm-game-job-status[data-status="failed"] { color: var(--wfm-danger, #ff4757); white-space: normal; }
.wfm-game-job-img { width: 100%; border-radius: var(--wfm-radius-sm, 4px); background: #000; }
.wfm-game-job-details summary { cursor: pointer; font-size: 12px; color: var(--wfm-text-secondary, #aaa); }
.wfm-game-job-details[open] { display: flex; flex-direction: column; gap: 6px; }
.wfm-game-job-private { border-color: #f472b6; }
.wfm-game-job-private .wfm-game-job-title { color: #f472b6; }
+4 -1
View File
@@ -112,7 +112,7 @@ function initTabs() {
function applyI18nToHtml() {
// Tab labels
const tabMap = { workflow: "tabWorkflow", nodes: "tabNodes", models: "tabModels", generate: "tabGenerate", prompt: "tabPrompt", gallery: "tabGallery", "image-edit": "tabImageEdit", video: "tabVideo", settings: "tabSettings", help: "tabHelp", ai: "tabAi", tagger: "tabTagger", tagspace: "tabTagSpace" };
const tabMap = { workflow: "tabWorkflow", nodes: "tabNodes", models: "tabModels", generate: "tabGenerate", prompt: "tabPrompt", gallery: "tabGallery", "image-edit": "tabImageEdit", video: "tabVideo", settings: "tabSettings", help: "tabHelp", ai: "tabAi", tagger: "tabTagger", tagspace: "tabTagSpace", game: "tabGame" };
document.querySelectorAll(".wfm-tab").forEach((tab) => {
const key = tabMap[tab.dataset.tab];
if (key) tab.textContent = t(key);
@@ -625,6 +625,7 @@ function applyI18nToHtml() {
"wfm-help-gallery-card-stylecatalog-title": "helpGalleryCardStylecatalog",
"wfm-help-tagger-title": "helpTaggerTitle",
"wfm-help-tagspace-title": "helpTagSpaceTitle", "wfm-help-tagspace-card-overview-title": "helpTagSpaceCardOverview", "wfm-help-tagspace-card-use-title": "helpTagSpaceCardUse", "wfm-help-tagspace-1": "helpTagSpace1", "wfm-help-tagspace-2": "helpTagSpace2", "wfm-help-tagspace-3": "helpTagSpace3", "wfm-help-tagspace-4": "helpTagSpace4", "wfm-help-tagspace-5": "helpTagSpace5", "wfm-help-tagspace-6": "helpTagSpace6", "wfm-help-tagspace-7": "helpTagSpace7", "wfm-help-tagspace-8": "helpTagSpace8", "wfm-help-tagspace-9": "helpTagSpace9", "wfm-help-tagspace-10": "helpTagSpace10",
"wfm-help-game-title": "helpGameTitle", "wfm-help-game-card-overview-title": "helpGameCardOverview", "wfm-help-game-card-gen-title": "helpGameCardGen", "wfm-help-game-1": "helpGame1", "wfm-help-game-2": "helpGame2", "wfm-help-game-3": "helpGame3", "wfm-help-game-4": "helpGame4", "wfm-help-game-5": "helpGame5", "wfm-help-game-6": "helpGame6", "wfm-help-game-7": "helpGame7", "wfm-help-game-8": "helpGame8", "wfm-help-game-9": "helpGame9", "wfm-help-game-10": "helpGame10", "wfm-help-game-11": "helpGame11",
"wfm-help-tagger-1": "helpTagger1", "wfm-help-tagger-2": "helpTagger2",
"wfm-help-tagger-3": "helpTagger3", "wfm-help-tagger-4": "helpTagger4",
"wfm-help-tagger-5": "helpTagger5", "wfm-help-tagger-6": "helpTagger6",
@@ -889,6 +890,7 @@ import { initMetadataTab } from "./metadata-tab.js";
import { initAiTab } from "./ai-tab.js";
import { initTaggerTab } from "./tagger-tab.js";
import { initTagSpaceTab } from "./tagspace-tab.js";
import { initGameTab } from "./game-tab.js";
import { imageEditTab } from "./image-edit-tab.js";
import { initVideoTab } from "./video-tab.js";
@@ -942,6 +944,7 @@ document.addEventListener("DOMContentLoaded", () => {
initAiTab();
initTaggerTab();
initTagSpaceTab();
initGameTab(); // ゲームパック(ComfyUI-WFS-Games)があるときだけタブを表示
imageEditTab.init();
initVideoTab();
+4 -4
View File
@@ -211,9 +211,9 @@ export const comfyUI = {
},
// Generation
async queuePrompt(workflow, extraData = null) {
async queuePrompt(workflow, extraData = null, { quietVram = false } = {}) {
// Settings tab "VRAM Management": unload Ollama models to free VRAM (no-op when off, never throws)
await prepareVramForGeneration();
await prepareVramForGeneration({ quiet: quietVram });
const body = {
prompt: workflow,
client_id: this.clientId,
@@ -349,7 +349,7 @@ export const comfyUI = {
// High-level generate
async generate(workflow, options = {}) {
const { seedMode = "random", seedValue = -1, onProgress, onComplete, onError, timeoutMs } = options;
const { seedMode = "random", seedValue = -1, onProgress, onComplete, onError, timeoutMs, quietVram = false } = options;
this.generating = true;
try {
@@ -379,7 +379,7 @@ export const comfyUI = {
}
// Queue prompt — pass workflow as extra_pnginfo so SaveImage embeds it in PNG metadata
const result = await this.queuePrompt(workflow, { extra_pnginfo: { workflow } });
const result = await this.queuePrompt(workflow, { extra_pnginfo: { workflow } }, { quietVram });
this.currentPromptId = result.prompt_id;
// Track progress
+641
View File
@@ -0,0 +1,641 @@
/**
* Game タブ (実験的機能)
*
* ゲーム本体は別パッケージ ComfyUI-WFS-Games が配信する。
* GET /wfs_games/manifest が応答したときだけタブを表示する (未インストールなら何もしない)。
* ゲームは manifest の entry を動的 import し、mount(container, host) で起動する。
* ゲームが host.finish(result) で返した報酬プロンプトから、WFS がワークフローを組み立てて生成する。
* ゲームは ComfyUI を直接操作しない。
*
* 契約の詳細は ComfyUI-WFS-Games の README を参照。
*/
import { showToast } from "./app.js";
import { t, getLang } from "./i18n.js";
import { escapeHtml, readJsonStorage } from "./util.js";
import { comfyUI } from "./comfyui-client.js";
import { comfyWorkflow } from "./comfyui-workflow.js";
import { _expandWildcardsInWorkflow } from "./generate-tab.js";
const HOST_API_VERSION = 1;
const MANIFEST_URL = "/wfs_games/manifest";
const ENTRY_PREFIX = "/wfs_games/static/";
const LS_SETTINGS = "wfm_game_settings";
const DEFAULT_SETTINGS = {
gameId: "",
difficulty: "normal",
sound: true,
bgm: true,
workflow: "ws_game_sdxl_t2i.json",
// 画風・キャラ・シーンはゲームが報酬プロンプトとして渡すので、ここは品質タグだけ
basePrompt: "masterpiece, best quality",
negativePrompt: "",
generateEachStage: true, // ステージクリアごとに画像を生成する
autoGenerateEnding: true, // 全クリア時のエンディング画像も自動で生成する
autoGenerateGameover: true, // ゲームオーバー時の敗北画像も自動で生成する
};
const state = {
manifest: null,
opened: false,
handle: null, // mount() の戻り値
mountToken: 0,
jobs: [], // 画像1枚ごとのカード { id, kind, title, result, selected, el, status, apiWf, imageUrl }
jobSeq: 0,
queue: Promise.resolve(), // 生成は1枚ずつ順番に行う
};
const $ = (id) => document.getElementById(id);
// ---------------------------------------------------------------------------
// settings
// ---------------------------------------------------------------------------
// 以前の既定値。保存値がこれと同じなら新しい既定値に置き換える(ユーザーが編集した値は残す)
const OLD_DEFAULT_BASE_PROMPTS = ["masterpiece, best quality, outer space scenery"];
function loadSettings() {
const s = { ...DEFAULT_SETTINGS, ...readJsonStorage(LS_SETTINGS, {}) };
if (OLD_DEFAULT_BASE_PROMPTS.includes(s.basePrompt)) s.basePrompt = DEFAULT_SETTINGS.basePrompt;
return s;
}
function saveSettings(patch) {
const next = { ...loadSettings(), ...patch };
try { localStorage.setItem(LS_SETTINGS, JSON.stringify(next)); } catch { /* storage unavailable */ }
return next;
}
// ---------------------------------------------------------------------------
// detection
// ---------------------------------------------------------------------------
function isSafeGamePath(p) {
return typeof p === "string" && p.startsWith(ENTRY_PREFIX) && !p.includes("..") && !p.includes("//", 1) && !/[\\?#]/.test(p);
}
async function fetchManifest() {
const ctrl = new AbortController();
const timer = setTimeout(() => ctrl.abort(), 5000);
try {
const res = await fetch(MANIFEST_URL, { signal: ctrl.signal, cache: "no-store" });
if (!res.ok) return null;
const data = await res.json();
if (data?.api_version !== HOST_API_VERSION) {
console.warn(`[WFS Game] unsupported game pack api_version: ${data?.api_version} (expected ${HOST_API_VERSION})`);
return null;
}
const games = (Array.isArray(data.games) ? data.games : []).filter((g) => g && typeof g.id === "string" && isSafeGamePath(g.entry));
if (!games.length) return null;
games.forEach((g) => { if (g.thumbnail && !isSafeGamePath(g.thumbnail)) delete g.thumbnail; });
return { ...data, games };
} catch {
return null; // 未インストール (404) / 接続不可
} finally {
clearTimeout(timer);
}
}
function localized(obj, fallback = "") {
if (!obj) return fallback;
if (typeof obj === "string") return obj;
return obj[getLang()] || obj.en || Object.values(obj)[0] || fallback;
}
function currentGame() {
const s = loadSettings();
const games = state.manifest?.games || [];
return games.find((g) => g.id === s.gameId) || games[0] || null;
}
// ---------------------------------------------------------------------------
// shell
// ---------------------------------------------------------------------------
function renderShell() {
const root = $("wfm-tab-game");
const s = loadSettings();
const games = state.manifest.games;
// 左ペイン: ゲーム選択のみ / 中央: ゲーム / 右ペイン: タブ (結果 / 設定 = プレイ設定 + 画像生成設定)
root.innerHTML = `
<div class="wfm-game-layout">
<aside class="wfm-game-side">
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gameListTitle"))}</div>
<div class="wfm-game-list" id="wfm-game-list">
${games.map((g) => `
<button type="button" class="wfm-game-card" data-game-id="${escapeHtml(g.id)}">
${g.thumbnail ? `<img src="${escapeHtml(g.thumbnail)}" alt="">` : ""}
<span class="wfm-game-card-name">${escapeHtml(localized(g.name, g.id))}</span>
<span class="wfm-game-card-desc">${escapeHtml(localized(g.description))}</span>
</button>`).join("")}
</div>
</div>
</aside>
<section class="wfm-game-main">
<div class="wfm-game-toolbar">
<span class="wfm-game-current" id="wfm-game-current"></span>
<span class="wfm-game-spacer"></span>
<button type="button" id="wfm-game-restart" class="wfm-btn wfm-btn-sm">${escapeHtml(t("gameRestart"))}</button>
</div>
<div class="wfm-game-stage" id="wfm-game-stage"></div>
</section>
<aside class="wfm-game-result" id="wfm-game-result">
<div class="wfm-side-tab-nav" id="wfm-game-pane-nav">
<button type="button" class="wfm-side-tab-btn active" data-game-pane="result">${escapeHtml(t("gameResultTitle"))}</button>
<button type="button" class="wfm-side-tab-btn" data-game-pane="settings">${escapeHtml(t("gameSettingsTab"))}</button>
</div>
<div class="wfm-game-pane" data-game-pane="result">
<div class="wfm-game-result-status" id="wfm-game-result-status">${escapeHtml(t("gameResultEmpty"))}</div>
<div class="wfm-game-row" id="wfm-game-end-row" hidden>
<button type="button" id="wfm-game-play-again" class="wfm-btn wfm-btn-sm">${escapeHtml(t("gamePlayAgain"))}</button>
</div>
<div class="wfm-game-jobs" id="wfm-game-jobs"></div>
</div>
<div class="wfm-game-pane" data-game-pane="settings" hidden>
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gamePlaySettings"))}</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameDifficulty"))}</span>
<select id="wfm-game-difficulty" class="wfm-select">
<option value="easy">${escapeHtml(t("gameDifficultyEasy"))}</option>
<option value="normal">${escapeHtml(t("gameDifficultyNormal"))}</option>
<option value="hard">${escapeHtml(t("gameDifficultyHard"))}</option>
</select>
</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-bgm"> ${escapeHtml(t("gameBgm"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-sound"> ${escapeHtml(t("gameSound"))}</label>
<div class="wfm-game-note">${escapeHtml(t("gamePlaySettingsNote"))}</div>
</div>
<div class="wfm-game-section">
<div class="wfm-game-section-title">${escapeHtml(t("gameGenSettings"))}</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameWorkflow"))}</span>
<div class="wfm-game-row">
<select id="wfm-game-workflow" class="wfm-select"></select>
<button type="button" id="wfm-game-workflow-reload" class="wfm-btn wfm-btn-sm" title="${escapeHtml(t("gameWorkflowReload"))}">&#x21bb;</button>
</div>
</label>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameBasePrompt"))}</span>
<textarea id="wfm-game-base-prompt" class="wfm-textarea" rows="3"></textarea>
</label>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameNegativePrompt"))}</span>
<textarea id="wfm-game-negative-prompt" class="wfm-textarea" rows="2" placeholder="${escapeHtml(t("gameNegativePlaceholder"))}"></textarea>
</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-each-stage"> ${escapeHtml(t("gameEachStage"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-auto-generate"> ${escapeHtml(t("gameAutoGenerate"))}</label>
<label class="wfm-game-check"><input type="checkbox" id="wfm-game-auto-gameover"> ${escapeHtml(t("gameAutoGameover"))}</label>
</div>
</div>
</aside>
</div>`;
$("wfm-game-difficulty").value = s.difficulty;
$("wfm-game-sound").checked = s.sound !== false;
$("wfm-game-bgm").checked = s.bgm !== false;
$("wfm-game-base-prompt").value = s.basePrompt;
$("wfm-game-negative-prompt").value = s.negativePrompt;
$("wfm-game-each-stage").checked = s.generateEachStage !== false;
$("wfm-game-auto-generate").checked = s.autoGenerateEnding !== false;
$("wfm-game-auto-gameover").checked = s.autoGenerateGameover !== false;
markSelectedGame();
}
function markSelectedGame() {
const g = currentGame();
document.querySelectorAll("#wfm-game-list .wfm-game-card").forEach((el) => {
el.classList.toggle("active", el.dataset.gameId === g?.id);
});
const cur = $("wfm-game-current");
if (cur) cur.textContent = g ? localized(g.name, g.id) : "";
}
async function loadWorkflowOptions() {
const sel = $("wfm-game-workflow");
if (!sel) return;
const s = loadSettings();
// 一覧の取得(全ワークフローの解析)は時間がかかるので、先に保存済みの選択だけ表示しておく
if (!sel.options.length && s.workflow) {
sel.innerHTML = `<option value="${escapeHtml(s.workflow)}">${escapeHtml(s.workflow)}</option>`;
sel.value = s.workflow;
}
let names = [];
try {
const res = await fetch("/api/wfm/workflows");
const list = await res.json();
names = (Array.isArray(list) ? list : [])
.filter((w) => ["api", "ui"].includes(w.analysis?.format) && (w.analysis?.inputs?.prompts ?? 1) > 0)
.map((w) => w.filename);
} catch { /* keep empty */ }
if (s.workflow && !names.includes(s.workflow)) names.unshift(s.workflow);
sel.innerHTML = names.map((n) => `<option value="${escapeHtml(n)}">${escapeHtml(n)}</option>`).join("");
sel.value = s.workflow;
}
// 右ペインのタブ (結果 / 設定)
function showPane(name) {
document.querySelectorAll("#wfm-game-pane-nav .wfm-side-tab-btn").forEach((b) => b.classList.toggle("active", b.dataset.gamePane === name));
document.querySelectorAll("#wfm-game-result .wfm-game-pane").forEach((p) => { p.hidden = p.dataset.gamePane !== name; });
}
function bindShell() {
$("wfm-game-pane-nav").addEventListener("click", (e) => {
const btn = e.target.closest("[data-game-pane]");
if (btn) showPane(btn.dataset.gamePane);
});
$("wfm-game-list").addEventListener("click", (e) => {
const card = e.target.closest(".wfm-game-card");
if (!card) return;
if (card.dataset.gameId === currentGame()?.id && state.handle) { state.handle.focus?.(); return; }
saveSettings({ gameId: card.dataset.gameId });
markSelectedGame();
mountCurrentGame();
});
// プレイ設定はゲーム起動時に渡すので、変更したら再起動して反映する
$("wfm-game-difficulty").addEventListener("change", (e) => { saveSettings({ difficulty: e.target.value }); mountCurrentGame(); });
$("wfm-game-sound").addEventListener("change", (e) => { saveSettings({ sound: e.target.checked }); mountCurrentGame(); });
$("wfm-game-bgm").addEventListener("change", (e) => { saveSettings({ bgm: e.target.checked }); mountCurrentGame(); });
$("wfm-game-workflow").addEventListener("change", (e) => saveSettings({ workflow: e.target.value }));
$("wfm-game-workflow-reload").addEventListener("click", loadWorkflowOptions);
$("wfm-game-base-prompt").addEventListener("change", (e) => {
saveSettings({ basePrompt: e.target.value });
state.jobs.forEach((job) => { if (job.status === "idle" || job.status === "queued") refreshJobPrompt(job); });
});
$("wfm-game-negative-prompt").addEventListener("change", (e) => saveSettings({ negativePrompt: e.target.value }));
$("wfm-game-each-stage").addEventListener("change", (e) => saveSettings({ generateEachStage: e.target.checked }));
$("wfm-game-auto-generate").addEventListener("change", (e) => saveSettings({ autoGenerateEnding: e.target.checked }));
$("wfm-game-auto-gameover").addEventListener("change", (e) => saveSettings({ autoGenerateGameover: e.target.checked }));
$("wfm-game-restart").addEventListener("click", restartGame);
$("wfm-game-play-again").addEventListener("click", restartGame);
const jobs = $("wfm-game-jobs");
jobs.addEventListener("change", (e) => {
const cb = e.target.closest("input[data-reward-idx]");
const job = jobOf(e.target);
if (!cb || !job) return;
const idx = Number(cb.dataset.rewardIdx);
if (cb.checked) job.selected.add(idx); else job.selected.delete(idx);
refreshJobPrompt(job);
});
jobs.addEventListener("click", (e) => {
const btn = e.target.closest("button[data-act]");
const job = jobOf(e.target);
if (!btn || !job) return;
if (btn.dataset.act === "generate") enqueueJob(job);
else if (btn.dataset.act === "open") openInGenerateUI(job);
});
}
// ---------------------------------------------------------------------------
// game lifecycle
// ---------------------------------------------------------------------------
function unmountGame() {
if (state.handle) {
try { state.handle.unmount?.(); } catch (e) { console.error("[WFS Game] unmount failed", e); }
state.handle = null;
}
}
function resetResult() {
// 生成中・待機中のジョブはそのまま続く(カードだけ消える)。画像は出力フォルダに残る
state.jobs.forEach((job) => { job.removed = true; if (job.imageUrl) URL.revokeObjectURL(job.imageUrl); });
state.jobs = [];
const jobs = $("wfm-game-jobs");
if (jobs) jobs.innerHTML = "";
const st = $("wfm-game-result-status");
if (st) st.textContent = t("gameResultEmpty");
const end = $("wfm-game-end-row");
if (end) end.hidden = true;
}
async function mountCurrentGame() {
const game = currentGame();
const stage = $("wfm-game-stage");
if (!game || !stage) return;
const token = ++state.mountToken;
unmountGame();
resetResult();
stage.innerHTML = `<div class="wfm-game-loading">${escapeHtml(t("gameLoading"))}</div>`;
try {
// ゲームパック更新後に古いモジュールがキャッシュから読まれないよう、バージョンを付ける
const ver = encodeURIComponent(game.version || state.manifest.package_version || "0");
const mod = await import(`${game.entry}?v=${ver}`);
if (token !== state.mountToken) return; // 読み込み中に別ゲームへ切り替わった
if (typeof mod.mount !== "function") throw new Error("mount() not found");
const s = loadSettings();
const host = {
apiVersion: HOST_API_VERSION,
lang: getLang(),
settings: { difficulty: s.difficulty, sound: s.sound !== false, bgm: s.bgm !== false },
runStart: () => { if (token === state.mountToken) resetResult(); },
stageClear: (result) => { if (token === state.mountToken) onStageClear(result); },
finish: (result) => { if (token === state.mountToken) onGameFinished(result); },
};
const handle = await mod.mount(stage, host);
if (token !== state.mountToken) { try { handle?.unmount?.(); } catch { /* ignore */ } return; }
state.handle = handle || null;
if (!isGameTabActive()) state.handle?.pause?.();
} catch (e) {
console.error("[WFS Game] failed to load game", e);
stage.innerHTML = `<div class="wfm-game-loading">${escapeHtml(t("gameLoadFailed", e.message))}</div>`;
}
}
function restartGame() {
resetResult();
if (state.handle?.restart) state.handle.restart();
else mountCurrentGame();
}
function isGameTabActive() {
return $("wfm-tab-game")?.classList.contains("active");
}
// ---------------------------------------------------------------------------
// result & generation
// ---------------------------------------------------------------------------
function sanitizeResult(raw) {
const r = raw && typeof raw === "object" ? raw : {};
const rewards = (Array.isArray(r.rewards) ? r.rewards : [])
.filter((x) => x && x.type === "prompt" && typeof x.text === "string" && x.text.trim())
.slice(0, 50)
.map((x) => ({
text: x.text.trim().slice(0, 500),
weight: Number.isFinite(Number(x.weight)) ? Number(x.weight) : 1,
source: typeof x.source === "string" ? x.source : "clear",
}));
const kind = ["stage", "ending", "gameover"].includes(r.kind) ? r.kind : (r.cleared ? "ending" : "gameover");
const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0);
return {
kind,
bonus: !!r.bonus, // アイテムを全部取ったステージ(プライベート写真)
negative: typeof r.negative === "string" ? r.negative.trim().slice(0, 500) : "",
cleared: !!r.cleared,
score: num(r.score),
stage: num(r.stage),
stagesTotal: num(r.stagesTotal),
stageName: typeof r.stageName === "string" ? r.stageName.slice(0, 100) : "",
rewards,
};
}
function onStageClear(raw) {
const result = sanitizeResult(raw);
const job = result.bonus
? addJob(result, t("gameJobStagePrivate", result.stage, result.stageName), "private")
: addJob(result, t("gameJobStage", result.stage, result.stageName));
if (loadSettings().generateEachStage !== false) enqueueJob(job);
}
function onGameFinished(raw) {
const result = sanitizeResult(raw);
const cleared = result.kind === "ending";
$("wfm-game-result-status").innerHTML = `
<div class="wfm-game-result-head ${cleared ? "cleared" : "failed"}">${escapeHtml(cleared ? t("gameCleared") : t("gameOverLabel"))}</div>
<div>${escapeHtml(t("gameScore", result.score))}</div>`;
$("wfm-game-end-row").hidden = false;
const s = loadSettings();
if (cleared) {
const job = addJob(result, t("gameJobEnding"));
if (s.autoGenerateEnding !== false) enqueueJob(job);
} else if (result.rewards.length) {
// ゲームオーバー: 負けたステージを背景にした敗北の場面(クリア済みステージの画像は残る)
const job = addJob(result, t("gameJobGameover", result.stage, result.stageName), "gameover");
if (s.autoGenerateGameover !== false) enqueueJob(job);
}
}
// ---- image cards ----
function jobOf(el) {
const card = el.closest?.(".wfm-game-job");
return card ? state.jobs.find((j) => String(j.id) === card.dataset.jobId) : null;
}
function addJob(result, title, variant = "") {
const job = {
id: ++state.jobSeq, kind: result.kind, title, result,
selected: new Set(result.rewards.map((_, i) => i)),
status: "idle", apiWf: null, imageUrl: null, el: null,
};
const el = document.createElement("div");
el.className = variant ? `wfm-game-job wfm-game-job-${variant}` : "wfm-game-job";
el.dataset.jobId = String(job.id);
el.innerHTML = `
<div class="wfm-game-job-head">
<span class="wfm-game-job-title">${escapeHtml(title)}</span>
<span class="wfm-game-job-status" data-role="status"></span>
</div>
<div class="wfm-game-progress" data-role="progress" hidden><div class="wfm-game-progress-bar" data-role="bar"></div></div>
<img class="wfm-game-job-img" data-role="img" alt="" hidden>
<details class="wfm-game-job-details">
<summary>${escapeHtml(t("gamePromptDetails"))}</summary>
<div class="wfm-game-rewards">
${result.rewards.map((r, i) => `
<label class="wfm-game-reward">
<input type="checkbox" data-reward-idx="${i}" checked>
<span><span class="wfm-game-reward-src">${escapeHtml(sourceLabel(r.source))}</span>${escapeHtml(r.text)}</span>
</label>`).join("")}
${result.negative ? `<div class="wfm-game-note">${escapeHtml(t("gameNegativeFromGame"))}: ${escapeHtml(result.negative)}</div>` : ""}
</div>
<label class="wfm-game-field">
<span>${escapeHtml(t("gameFinalPrompt"))}</span>
<textarea class="wfm-textarea" data-role="prompt" rows="4"></textarea>
</label>
</details>
<div class="wfm-game-row">
<button type="button" class="wfm-btn wfm-btn-sm wfm-btn-primary" data-act="generate">${escapeHtml(t("gameGenerate"))}</button>
<button type="button" class="wfm-btn wfm-btn-sm" data-act="open" hidden>${escapeHtml(t("gameOpenInGenerateUI"))}</button>
</div>`;
job.el = el;
state.jobs.push(job);
$("wfm-game-jobs")?.prepend(el); // 新しいものを上に
showPane("result"); // 設定タブを開いていても、新しい画像カードが見えるようにする
refreshJobPrompt(job);
setJobStatus(job, "idle");
return job;
}
const part = (job, role) => job.el.querySelector(`[data-role="${role}"]`);
function setJobStatus(job, status, text = "") {
job.status = status;
const label = { idle: "", queued: t("gameJobQueued"), running: t("gameGenerating"), done: t("gameJobDone"), failed: t("gameGenerateFailed", "") }[status] ?? "";
const st = part(job, "status");
st.textContent = text || label;
st.dataset.status = status;
part(job, "progress").hidden = status !== "running";
const gen = job.el.querySelector('button[data-act="generate"]');
gen.disabled = status === "queued" || status === "running";
gen.textContent = job.imageUrl || status === "failed" ? t("gameRegenerate") : t("gameGenerate");
}
function buildPrompt(job) {
const s = loadSettings();
const parts = [];
const seen = new Set();
const push = (txt) => {
const v = (txt || "").trim();
if (!v) return;
const key = v.toLowerCase().replace(/\s+/g, " ");
if (seen.has(key)) return;
seen.add(key);
parts.push(v);
};
push(s.basePrompt);
job.result.rewards.forEach((r, i) => { if (job.selected.has(i)) push(formatReward(r)); });
return parts.join(", ");
}
function refreshJobPrompt(job) {
part(job, "prompt").value = buildPrompt(job);
}
function enqueueJob(job) {
if (job.status === "queued" || job.status === "running") return;
setJobStatus(job, "queued");
state.queue = state.queue.then(() => runJob(job)).catch(() => {});
}
async function runJob(job) {
if (job.removed) return;
const prompt = (part(job, "prompt").value || buildPrompt(job)).trim();
if (!prompt) { setJobStatus(job, "failed", t("gameEmptyPrompt")); return; }
setJobStatus(job, "running");
const bar = part(job, "bar");
bar.style.width = "0%";
try {
const wf = await buildWorkflow(prompt, job.result.negative);
job.apiWf = wf;
const expanded = await _expandWildcardsInWorkflow(wf);
const { images } = await comfyUI.generate(expanded, {
seedMode: "random",
quietVram: true, // VRAM 調整のトーストでゲーム画面を隠さない
onProgress: (pct) => {
bar.style.width = `${(pct * 100).toFixed(1)}%`;
part(job, "status").textContent = `${t("gameGenerating")} ${(pct * 100).toFixed(0)}%`;
},
});
const img = images.filter((x) => x.type !== "temp")[0] || images[0];
if (!img) throw new Error(t("gameNoImage"));
const blob = await comfyUI.getImageBlob(img);
if (job.imageUrl) URL.revokeObjectURL(job.imageUrl);
job.imageUrl = URL.createObjectURL(blob);
if (job.removed) { URL.revokeObjectURL(job.imageUrl); return; }
const el = part(job, "img");
el.src = job.imageUrl;
el.title = t("gameGenerated", [img.subfolder, img.filename].filter(Boolean).join("/"));
el.hidden = false;
job.el.querySelector('button[data-act="open"]').hidden = false;
setJobStatus(job, "done");
} catch (e) {
console.error("[WFS Game] generation failed", e);
if (!job.removed) {
setJobStatus(job, "failed", t("gameGenerateFailed", e.message));
showToast(t("gameGenerateFailed", e.message), "error");
}
}
}
function sourceLabel(src) {
const key = { style: "gameSrcStyle", character: "gameSrcCharacter", scene: "gameSrcScene", clear: "gameSrcClear", enemy: "gameSrcEnemy", bonus: "gameSrcBonus" }[src];
return key ? t(key) : src;
}
function joinUnique(...parts) {
const seen = new Set();
const out = [];
for (const p of parts) {
for (const tag of (p || "").split(",")) {
const v = tag.trim();
const k = v.toLowerCase();
if (v && !seen.has(k)) { seen.add(k); out.push(v); }
}
}
return out.join(", ");
}
function formatReward(r) {
return r.weight !== 1 ? `(${r.text}:${r.weight})` : r.text;
}
async function buildWorkflow(prompt, gameNegative) {
const s = loadSettings();
if (!s.workflow) throw new Error(t("gameNoWorkflow"));
const res = await fetch(`/api/wfm/workflows/raw?filename=${encodeURIComponent(s.workflow)}`);
if (!res.ok) throw new Error(t("gameWorkflowLoadFailed", s.workflow));
const raw = await res.json();
const format = comfyWorkflow.detectFormat(raw, s.workflow);
let wf;
if (format === "ui") wf = await comfyWorkflow.convertUiToApi(raw);
else if (format === "api") wf = structuredClone(raw);
else throw new Error(t("unknownWorkflowFormat"));
const analysis = comfyWorkflow.analyzeWorkflow(wf);
const pos = analysis.prompt_nodes?.find((n) => n.role === "positive");
const neg = analysis.prompt_nodes?.find((n) => n.role === "negative");
if (!pos || !wf[pos.id]) throw new Error(t("gameNoPositiveNode"));
wf[pos.id].inputs[pos.textKey || "text"] = prompt;
if (neg && wf[neg.id]) {
// 設定のネガティブ(空ならワークフロー自身のもの)に、ゲームが渡したネガティブを足す
const key = neg.textKey || "text";
const base = s.negativePrompt.trim() || (typeof wf[neg.id].inputs[key] === "string" ? wf[neg.id].inputs[key] : "");
wf[neg.id].inputs[key] = joinUnique(base, gameNegative);
}
return wf;
}
async function openInGenerateUI(job) {
if (!job?.apiWf) return;
const { loadWorkflowIntoEditor } = await import("./generate-tab.js");
const ok = await loadWorkflowIntoEditor(structuredClone(job.apiWf), loadSettings().workflow);
if (ok !== false) document.querySelector('.wfm-tab[data-tab="generate"]')?.click();
}
// ---------------------------------------------------------------------------
// tab visibility
// ---------------------------------------------------------------------------
function onTabsClicked(e) {
const tab = e.target.closest(".wfm-tab");
if (!tab) return;
if (tab.dataset.tab === "game") {
// app.js の表示切替が終わってから初期化する
setTimeout(onOpen, 0);
} else {
state.handle?.pause?.();
}
}
async function onOpen() {
if (!state.opened) {
state.opened = true;
renderShell();
bindShell();
loadWorkflowOptions();
await mountCurrentGame();
return;
}
state.handle?.resume?.();
}
export async function initGameTab() {
const btn = document.querySelector('.wfm-tab[data-tab="game"]');
if (!btn || !$("wfm-tab-game")) return;
const manifest = await fetchManifest();
if (!manifest) return; // ゲームパック未インストール: タブは hidden のまま
state.manifest = manifest;
btn.hidden = false;
document.querySelector('.wfm-help-nav-item[data-help-page="game"]')?.removeAttribute("hidden");
document.querySelector(".wfm-tabs")?.addEventListener("click", onTabsClicked);
document.addEventListener("visibilitychange", () => {
if (document.hidden) state.handle?.pause?.();
else if (isGameTabActive()) state.handle?.resume?.();
});
// 動作確認用 (DevTools から window._wfmGameTab.handle.debugClear() など)
window._wfmGameTab = state;
}
+219
View File
@@ -753,6 +753,79 @@ const LANGUAGES = {
tabAi: "AI TOOL",
tabTagger: "Tagger",
tabTagSpace: "TagSpace",
// --- Game tab (experimental; needs the ComfyUI-WFS-Games pack) ---
tabGame: "Game",
helpGame9: "Turbo Heart: a 1980s-style behind-the-car racer with a pseudo-3D road. 5 races along the coast (seaside highway, autumn mountain pass, desert canyon at sunset, neon city at night, tropical coast at dawn). 8 cars: you start last and must finish in the top 3 to go on — 4th or worse is game over. Steer with ← →, gas with ↑ or Z, brake with ↓ or X, nitro with Space or C (3 per race), pause with Esc or P; a gamepad also works. Pick up the 5 hearts on the road. Mechanic Misaki talks between races, and the images work the same way as in Star Formation (a victory shot per race, a private photo with all 5 hearts, the ending, a defeat scene). Watch out for obstacles: stacked cardboard boxes (2 per race) block part of the road and hide what's behind — driving through them smashes them and slows you down; an oil slick (1 per race) spins you around twice; and there may be a person crossing the road (0 or 1, random each play) — hitting them ends the game.",
helpGame10: "Prompt Typer: a 1980s-style typing game (no music, sound effects only) whose typing becomes the image prompt. 10 stages of 20 words; the words get longer every 2 stages. What you type goes into the prompt as it is, typos included. Backspace fixes the current word, but a typo still counts as a miss. Type 85% of the characters correctly to clear a stage. An image is generated after every stage whether you clear it or not; after a stage, Enter goes on (or retries a failed stage), R retries and Q gives up. On the title, ↑ ↓ picks the typing language (English, Japanese or Chinese — Japanese and Chinese are typed through your IME into an input box; kanji words show their reading and hiragana / katakana count as the same) and ← → the start stage. Japanese and Chinese prompts need an image model that understands those languages",
helpGame11: "Sky Heart: a 1980s-style into-the-screen flying shooter with a pseudo-3D ground. Hikari of the sky patrol flies a jet pack through 5 stages (flower plains, crystal canyon, sunset sea, neon sky city, moon ruins), each ending with a boss. Your shots fly straight into the screen, so line up with an enemy to hit it; dodge bullets, ground missile launchers and the trees, crystals, rocks, towers and columns on the ground (fly over or around them; the stage 4 buildings break after 4 shots). Move with the arrow keys or WASD, hold Space or Z to shoot, pause with Esc or P; a gamepad also works. The altimeter on the left shows your height and the height of incoming items. Each stage has 5 hearts in the air and 5 near the ground — catch any 5 for the private photo. Power-up capsules come in the air and on the ground: 1UP (green), a barrier that blocks 3 hits (blue) and support mechs that fire with you for 15 seconds (orange). The images work the same way as in Star Formation",
gameJobStagePrivate: (n, name) => `STAGE ${n}${name ? " " + name : ""} - PRIVATE ♥`,
gameAutoGameover: "Also generate an image on game over",
gameJobGameover: (n, name) => `GAME OVER - STAGE ${n}${name ? " " + name : ""}`,
gameEachStage: "Generate an image at each stage clear",
gameJobEnding: "ENDING",
gameJobQueued: "Waiting",
gameJobDone: "Done",
gameRegenerate: "Regenerate",
gamePromptDetails: "Prompt",
gameJobStage: (n, name) => `STAGE ${n}${name ? " " + name : ""}`,
gameBgm: "Music",
gameSrcStyle: "Style",
gameSrcCharacter: "Heroine",
gameSrcScene: "Scene",
gameSrcClear: "Stage",
gameSrcEnemy: "Enemy",
gameSrcBonus: "Bonus",
gameNegativeFromGame: "Negative added by the game",
gameListTitle: "Games",
gamePlaySettings: "Play settings",
gameDifficulty: "Difficulty",
gameDifficultyEasy: "Easy",
gameDifficultyNormal: "Normal",
gameDifficultyHard: "Hard",
gameSound: "Sound effects",
gamePlaySettingsNote: "Changing these restarts the game.",
gameGenSettings: "Image generation",
gameWorkflow: "Workflow",
gameWorkflowReload: "Reload workflow list",
gameBasePrompt: "Base prompt (added before the prompts you earn)",
gameNegativePrompt: "Negative prompt",
gameNegativePlaceholder: "Empty = keep the workflow's negative prompt",
gameAutoGenerate: "Also generate the ending image automatically",
gameRestart: "Restart",
gameResultTitle: "Result",
gameSettingsTab: "Settings",
gameResultEmpty: "Each time you clear a stage, a victory shot of Rina is generated here. Clearing every stage adds the ending image; a game over adds a defeat scene.",
gameFinalPrompt: "Prompt to generate (editable)",
gameGenerate: "Generate",
gameOpenInGenerateUI: "Open in GenerateUI",
gamePlayAgain: "Play again",
gameLoading: "Loading game...",
gameLoadFailed: (msg) => `Failed to load the game: ${msg}`,
gameCleared: "CLEAR!",
gameOverLabel: "GAME OVER",
gameScore: (n) => `Score: ${n}`,
gameOverNoGenerate: "Game over: no ending image is generated. The images of the stages you cleared are kept.",
gameRewardsTitle: "Prompts earned (uncheck to leave out):",
gameNoRewards: "No prompts were earned. Only the base prompt is used.",
gameNoWorkflow: "No workflow is selected in the Game settings.",
gameWorkflowLoadFailed: (name) => `Could not load the workflow: ${name}`,
gameNoPositiveNode: "The workflow has no positive prompt node.",
gameEmptyPrompt: "The prompt is empty.",
gameGenerating: "Generating...",
gameNoImage: "The workflow returned no image.",
gameGenerated: (path) => `Saved: ${path}`,
gameGenerateFailed: (msg) => `Generation failed: ${msg}`,
helpGameTitle: "Game Tab (experimental)",
helpGameCardOverview: "Overview",
helpGameCardGen: "Image Generation",
helpGame1: "The Game tab appears only when the separate game pack ComfyUI-WFS-Games is installed (Workflow Studio checks /wfs_games/manifest on start). Without it, the tab and this help page stay hidden",
helpGame2: "Choose a game in the Games list on the left. The game runs in the center; click it to give it the keyboard (keys pressed there do not reach the rest of Workflow Studio). The game pauses when you switch to another tab or window. The right pane has two tabs: Result (the image cards) and Settings (play settings and image generation settings)",
helpGame3: "Star Formation: a vertical shooter in the style of 1980s arcade and home computer (MSX2 / PC-8801) games — pixel sprites, a pixel font, scanlines and chiptune music. 5 stages. Enemy squadrons fly in, line up, then dive at you. Five enemies in each stage flash yellow: shoot them down and they drop a memory heart — catch it before it falls off the screen (+500 points; the hearts at the top right show how many you have). When all enemies are down, WARNING appears, the music changes and the stage boss arrives (a red HP bar at the top) — each boss behaves differently: big and tough, fast with fast shots, radial bursts, a flashing straight-line ram, and a giant carrier that launches 5 small fighters 3 times. Move with ← → or A D, shoot with Space or Z, pause with Esc or P; a gamepad also works. Before and after each stage, Rina — the navigator guiding you from control — talks in an adventure-game style window (Space, Z, Enter or click to go on). When you lose your last ship, the screen darkens and her desperate call goes unanswered before GAME OVER. Diving enemies are worth double points",
helpGame4: "Play settings: Difficulty (Easy: 5 lives / Normal: 3 / Hard: 2, with fewer or more enemy shots and dives), Music and Sound effects. Changing them restarts the game. The high score is kept in this browser",
helpGame5: "Restart starts the game over from the title screen",
helpGame6: "Each time you clear a stage, a card for that stage is added to the Result panel (newest on top) and a victory shot of Rina (peace sign, waving, thumbs up ...) with that stage in the background is generated while you keep playing (images are made one at a time, in order). If you caught all 5 hearts in the stage, PERFECT! appears and the card (pink) becomes a private photo of Rina instead: off duty, in clothes that show a little more skin with each stage — casual clothes at a café, a sleeveless sundress, an off-shoulder top and shorts, a tank top and denim shorts, and a swimsuit on the beach (the swimsuit is the most; the game adds negative tags to keep it there). Clearing all 5 stages adds the ENDING card. On game over, a GAME OVER card (red) is added with a defeat scene: Rina crying in the dark control room under red warning lights, with the stage where you fell in the background. Open \"Prompt\" on a card to see the prompts the game gave, each marked with its kind: Style (1980s PC graphics), Heroine (Rina's look), Scene and Stage. Uncheck any you don't want or edit the prompt, then press Regenerate",
helpGame7: "Workflow: the workflow used for generation (default ws_game_sdxl_t2i.json, an SDXL (Illustrious) text-to-image workflow made for the Game tab, 1216x832; output goes to output/WFS_Game). The prompt is written into the workflow's positive prompt node. The negative prompt is your Negative prompt setting (or, when empty, the workflow's own) plus the game's negative tags. The seed is random each time",
helpGame8: "\"Generate an image at each stage clear\", \"Also generate the ending image automatically\" and \"Also generate an image on game over\" can be turned off; then press Generate on the card when you want the image. \"Open in GenerateUI\" loads that card's workflow with its prompt into GenerateUI. Starting a new game from the title clears the cards (the images stay in output/WFS_Game). The VRAM Management notices are not shown while the Game tab is open. Settings are kept in the browser and included in backups",
tsBuild: "Build / Update",
tsCancel: "Stop",
tsMaxTags: "Tags:",
@@ -2706,6 +2779,79 @@ const LANGUAGES = {
tabAi: "AI TOOL",
tabTagger: "Tagger",
tabTagSpace: "TagSpace",
// --- Game タブ (実験的機能・ComfyUI-WFS-Games が必要) ---
tabGame: "Game",
helpGame9: "Turbo Heart: 80年代風の、後ろから見る疑似3Dのレースゲームです。海岸線を巡る全5レース(海岸ハイウェイ・紅葉の峠・夕陽の渓谷・夜のネオンシティ・夜明けの海岸)。8台で走り、最後尾からスタートして3位以内でゴールすると次のレースへ進めます(4位以下はゲームオーバー)。ハンドルは ← →、アクセルは ↑ または Z、ブレーキは ↓ または X、ニトロは Space または C(1レース3回)、一時停止は Esc または P。ゲームパッドも使えます。コース上のハート5個を拾ってください。レースの合間にメカニックのミサキが話し、画像の仕組みは Star Formation と同じです(レースごとの勝利の記念カット、ハート全部でプライベート写真、エンディング、敗北の場面)。障害物にも注意: 積み上げたダンボール(1レース2か所)は道の一部をふさいで向こうを見えにくくし、突っ込むと粉々になって減速します。オイル(1か所)に乗るとスピンして2回転します。道を渡る人(プレイのたびにランダムで0人か1人)をはねるとゲームオーバーです。",
helpGame10: "Prompt Typer: 打った文字がそのまま画像のプロンプトになる、80年代風のタイピングゲームです(BGMなし・効果音のみ)。全10ステージ・各20ワードで、2ステージごとに文字数が増えます。打った文字は打ち間違いも含めてそのままプロンプトに入ります。バックスペースで今のワードを直せますが、打ち間違えた数は減りません。85%以上正しく入力できればステージクリア。クリアしてもしなくても毎ステージ画像を生成します。ステージの後は Enter で次へ(クリアできなかったときはリトライ)、R でリトライ、Q であきらめます。タイトルの ↑ ↓ でタイピングする言語(英語・日本語・中国語。日本語と中国語は入力欄に IME で入力し、漢字のワードには読みがなが出て、ひらがなとカタカナは同じ文字として扱います)、← → でスタートステージを選べます。日本語・中国語のプロンプトは、その言語がわかる画像モデルで使ってください",
helpGame11: "Sky Heart: 画面の奥へ向かって飛ぶ、80年代風の疑似3Dシューティングです。空のパトロール隊のヒカリがジェットパックで全5ステージ(花の平原・水晶の渓谷・夕焼けの海・ネオンの空中都市・月の遺跡)を飛び、各ステージの最後にボスが出ます。弾は画面の奥へまっすぐ飛ぶので、敵と重なる位置で撃ちます。敵の弾、地上のミサイル発射台、地上の木・水晶・岩・ビル・柱をよけてください(上か横へよけます。ステージ4のビルは4発で壊せます)。移動は矢印キーまたは WASD、ショットは Space または Z を押しっぱなし、一時停止は Esc または P。ゲームパッドも使えます。左の高度計で自機と、近づいてくるアイテムの高さがわかります。ハートは各ステージ空中に5個・地上すれすれに5個あり、合わせて5個取るとプライベート写真になります。パワーアップのカプセルが空中と地上に出ます: 1UP(緑)、3発まで防ぐバリア(青)、15秒間一緒に撃つサポートメカ(オレンジ)。画像の仕組みは Star Formation と同じです",
gameJobStagePrivate: (n, name) => `STAGE ${n}${name ? " " + name : ""} - プライベート♥`,
gameAutoGameover: "ゲームオーバー時も画像を生成する",
gameJobGameover: (n, name) => `GAME OVER - STAGE ${n}${name ? " " + name : ""}`,
gameEachStage: "ステージクリアごとに画像を生成する",
gameJobEnding: "ENDING",
gameJobQueued: "待機中",
gameJobDone: "完了",
gameRegenerate: "再生成",
gamePromptDetails: "プロンプト",
gameJobStage: (n, name) => `STAGE ${n}${name ? " " + name : ""}`,
gameBgm: "BGM",
gameSrcStyle: "画風",
gameSrcCharacter: "ヒロイン",
gameSrcScene: "シーン",
gameSrcClear: "ステージ",
gameSrcEnemy: "撃破",
gameSrcBonus: "ボーナス",
gameNegativeFromGame: "ゲームが追加するネガティブ",
gameListTitle: "ゲーム",
gamePlaySettings: "プレイ設定",
gameDifficulty: "難易度",
gameDifficultyEasy: "やさしい",
gameDifficultyNormal: "ふつう",
gameDifficultyHard: "むずかしい",
gameSound: "効果音",
gamePlaySettingsNote: "変更するとゲームが最初からになります。",
gameGenSettings: "画像生成",
gameWorkflow: "ワークフロー",
gameWorkflowReload: "ワークフロー一覧を再読み込み",
gameBasePrompt: "ベースプロンプト(獲得したプロンプトの前に付きます)",
gameNegativePrompt: "ネガティブプロンプト",
gameNegativePlaceholder: "空欄ならワークフローのネガティブをそのまま使います",
gameAutoGenerate: "エンディング画像も自動で生成する",
gameRestart: "リスタート",
gameResultTitle: "結果",
gameSettingsTab: "設定",
gameResultEmpty: "ステージをクリアするたびに、リナの勝利の記念カットがここに生成されます。全ステージをクリアするとエンディング画像、ゲームオーバーになると敗北の場面が生成されます。",
gameFinalPrompt: "生成するプロンプト(編集できます)",
gameGenerate: "生成",
gameOpenInGenerateUI: "GenerateUIで開く",
gamePlayAgain: "もう一度遊ぶ",
gameLoading: "ゲームを読み込み中...",
gameLoadFailed: (msg) => `ゲームを読み込めませんでした: ${msg}`,
gameCleared: "CLEAR!",
gameOverLabel: "GAME OVER",
gameScore: (n) => `スコア: ${n}`,
gameOverNoGenerate: "ゲームオーバーのため、エンディング画像は生成しません。クリアしたステージの画像は残ります。",
gameRewardsTitle: "獲得したプロンプト(使わないものはチェックを外してください):",
gameNoRewards: "獲得したプロンプトはありません。ベースプロンプトだけで生成します。",
gameNoWorkflow: "Game の設定でワークフローが選ばれていません。",
gameWorkflowLoadFailed: (name) => `ワークフローを読み込めませんでした: ${name}`,
gameNoPositiveNode: "ワークフローにポジティブプロンプトのノードがありません。",
gameEmptyPrompt: "プロンプトが空です。",
gameGenerating: "生成中...",
gameNoImage: "ワークフローから画像が返りませんでした。",
gameGenerated: (path) => `保存しました: ${path}`,
gameGenerateFailed: (msg) => `生成に失敗しました: ${msg}`,
helpGameTitle: "Gameタブ(実験的機能)",
helpGameCardOverview: "概要",
helpGameCardGen: "画像生成",
helpGame1: "Gameタブは、別パッケージのゲームパック ComfyUI-WFS-Games をインストールしているときだけ表示されます(起動時に /wfs_games/manifest を確認します)。入っていないときはタブもこのヘルプページも表示されません",
helpGame2: "左の「ゲーム」一覧から遊ぶゲームを選びます。ゲームは中央で動きます。クリックするとキー操作がゲームに入ります(そこで押したキーは Workflow Studio の他の操作に影響しません)。他のタブやウィンドウに切り替えると一時停止します。右のペインは「結果」(画像のカード)と「設定」(プレイ設定と画像生成の設定)のタブに分かれています",
helpGame3: "Star Formation: 80年代のアーケードゲームやパソコン(MSX2 / PC-8801)風の縦シューティングです。ドット絵・ドットフォント・走査線・チップチューン風のBGM。全5ステージ。敵は編隊で飛んできて整列し、急降下して攻撃してきます。各ステージで5機の敵が黄色く点滅しています。倒すと「思い出のハート」が落ちてくるので、画面の下に落ちる前に取ってください(+500点。右上のハートが獲得数)。敵を全滅させると WARNING が出てBGMが変わり、ステージのボスが登場します(画面上部に赤い耐久力ゲージ)。ボスはそれぞれ特徴があります: 大きくて硬い、速くて弾も速い、放射状に弾を撃つ、点滅したあと一直線に体当たり、小型機を5機ずつ3回出す巨大母艦。移動は ← → または A D、ショットは Space または Z、一時停止は Esc または P。ゲームパッドも使えます。各ステージの前後に、管制から誘導してくれるナビゲーターのリナがアドベンチャーゲーム風のウィンドウで話します(Space・Z・Enter・クリックで進みます)。最後の自機がやられると画面が暗くなり、リナの呼びかけに応答がないまま GAME OVER になります。急降下中の敵を倒すと得点2倍です",
helpGame4: "プレイ設定: 難易度(やさしい: 残機5 / ふつう: 3 / むずかしい: 2。敵の弾や急降下の頻度も変わります)、BGM、効果音。変更するとゲームが最初からになります。ハイスコアはこのブラウザに保存されます",
helpGame5: "「リスタート」でタイトル画面からやり直します",
helpGame6: "ステージをクリアするたびに、右の「結果」にそのステージのカードが追加され(新しいものが上)、そのステージを背景にしたリナの勝利の記念カット(ピース・手を振る・サムズアップなど)がバックグラウンドで生成されます。生成中もプレイを続けられます(画像は1枚ずつ順番に作ります)。そのステージでハートを5つ全部取っていた場合は PERFECT! と表示され、カード(ピンク)は勝利の記念カットの代わりにプライベートのリナの写真になります。ステージが進むごとに肌の露出が少しずつ増えます: カフェでの私服 → ノースリーブのワンピース → オフショルダーとショートパンツ → タンクトップとデニムのショートパンツ → 海辺の水着(水着までです。ゲームがネガティブのタグを足して、それ以上にならないようにしています)。5ステージすべてクリアすると ENDING のカードが追加されます。ゲームオーバーになると赤い GAME OVER のカードが追加され、負けたステージを背景に、赤い警告灯の暗い管制室で泣き崩れるリナの敗北の場面が生成されます。カードの「プロンプト」を開くと、ゲームから渡されたプロンプトが種類つきで並びます: 画風(80年代のパソコングラフィック風)・ヒロイン(リナの外見)・シーン・ステージ。使わないものはチェックを外すかプロンプトを編集し、「再生成」を押してください",
helpGame7: "ワークフロー: 生成に使うワークフローです(既定は ws_game_sdxl_t2i.json。Gameタブ用に用意した SDXL(Illustrious)の T2I ワークフローで、1216x832、出力先は output/WFS_Game)。プロンプトはワークフローのポジティブプロンプトのノードに書き込みます。ネガティブは「ネガティブプロンプト」設定(空ならワークフロー自身のもの)にゲームのネガティブタグを足したものです。seed は毎回ランダムです",
helpGame8: "「ステージクリアごとに画像を生成する」「エンディング画像も自動で生成する」「ゲームオーバー時も画像を生成する」はオフにできます。オフのときは、カードの「生成」を押したときに生成します。「GenerateUIで開く」は、そのカードのプロンプトを入れたワークフローを GenerateUI に読み込みます。タイトルから新しくゲームを始めるとカードは消えます(画像は output/WFS_Game に残ります)。Game タブを開いている間は、VRAM調整のメッセージを表示しません。設定はブラウザに保存され、バックアップにも含まれます",
tsBuild: "作成 / 更新",
tsCancel: "中止",
tsMaxTags: "タグ数:",
@@ -4659,6 +4805,79 @@ const LANGUAGES = {
tabAi: "AI TOOL",
tabTagger: "Tagger",
tabTagSpace: "TagSpace",
// --- Game 标签页 (实验性功能,需要 ComfyUI-WFS-Games) ---
tabGame: "Game",
helpGame9: "Turbo Heart: 80年代风格的后视角伪3D赛车游戏。沿海岸线共 5 场比赛(海岸公路、红叶山道、夕阳峡谷、夜晚的霓虹城市、黎明海岸)。8 辆车同场竞速,你从最后一位起跑,以前三名完赛才能进入下一场(第四名及以后则游戏结束)。用 ← → 转向,↑ 或 Z 加速,↓ 或 X 刹车,Space 或 C 使用氮气(每场 3 次),Esc 或 P 暂停;也支持手柄。请收集赛道上的 5 颗心。比赛之间机械师美咲会说话,图像机制与 Star Formation 相同(每场的胜利纪念画面、集齐 5 颗心的私人照片、结局、败北场景). 注意障碍物: 堆起来的纸箱(每场 2 处)会挡住部分道路和视线,撞上会被撞得粉碎并减速;油渍(每场 1 处)会让赛车打转两圈;路上可能有行人横穿(每次游戏随机 0 或 1 人),撞到就会游戏结束。",
helpGame10: "Prompt Typer: 输入的文字会原样成为图像提示词的 80 年代风格打字游戏(无背景音乐,仅有音效)。共 10 关、每关 20 个词,每 2 关字数增加。输入的文字(包括打错的)会原样进入提示词。退格可以修改当前的词,但打错的次数不会减少。正确率达到 85% 即可过关。无论是否过关,每关都会生成图像;每关结束后按 Enter 继续(未过关时为重试),R 重试,Q 放弃。在标题画面用 ↑ ↓ 选择打字语言(英语、日语、中文。日语和中文用输入法在输入框中输入,含汉字的词会显示读音,平假名和片假名视为相同),用 ← → 选择开始关卡。日语和中文提示词需要使用能理解该语言的图像模型",
helpGame11: "Sky Heart: 向画面深处飞行的 80 年代风格伪 3D 射击游戏。天空巡逻队的光背着喷气背包飞越全部 5 关(花之平原、水晶峡谷、夕阳之海、霓虹空中都市、月之遗迹),每关最后有首领。子弹会笔直地飞向画面深处,请对准敌人射击;躲开子弹、地面的导弹发射台以及地面上的树木、水晶、岩石、大楼和柱子(从上方或旁边躲开;第 4 关的大楼打 4 发即可摧毁)。用方向键或 WASD 移动,按住 Space 或 Z 射击,Esc 或 P 暂停;也支持手柄。左侧的高度计显示自机和接近中道具的高度。每关空中有 5 颗心、贴近地面也有 5 颗,合计收集 5 颗即可获得私人照片。强化胶囊会出现在空中和地面: 1UP(绿)、可抵挡 3 次攻击的护盾(蓝)、15 秒内一起射击的支援机(橙)。图像机制与 Star Formation 相同",
gameJobStagePrivate: (n, name) => `STAGE ${n}${name ? " " + name : ""} - 私人♥`,
gameAutoGameover: "游戏结束时也生成图像",
gameJobGameover: (n, name) => `GAME OVER - STAGE ${n}${name ? " " + name : ""}`,
gameEachStage: "每通过一关生成一张图像",
gameJobEnding: "ENDING",
gameJobQueued: "等待中",
gameJobDone: "完成",
gameRegenerate: "重新生成",
gamePromptDetails: "提示词",
gameJobStage: (n, name) => `STAGE ${n}${name ? " " + name : ""}`,
gameBgm: "背景音乐",
gameSrcStyle: "画风",
gameSrcCharacter: "女主角",
gameSrcScene: "场景",
gameSrcClear: "关卡",
gameSrcEnemy: "击落",
gameSrcBonus: "奖励",
gameNegativeFromGame: "游戏追加的负面提示词",
gameListTitle: "游戏",
gamePlaySettings: "游戏设置",
gameDifficulty: "难度",
gameDifficultyEasy: "简单",
gameDifficultyNormal: "普通",
gameDifficultyHard: "困难",
gameSound: "音效",
gamePlaySettingsNote: "更改后游戏将重新开始。",
gameGenSettings: "图像生成",
gameWorkflow: "工作流",
gameWorkflowReload: "重新加载工作流列表",
gameBasePrompt: "基础提示词(加在获得的提示词之前)",
gameNegativePrompt: "负面提示词",
gameNegativePlaceholder: "留空则使用工作流自带的负面提示词",
gameAutoGenerate: "结局图像也自动生成",
gameRestart: "重新开始",
gameResultTitle: "结果",
gameSettingsTab: "设置",
gameResultEmpty: "每通过一关,都会在这里生成莉娜的胜利纪念画面。通过全部关卡后生成结局图像,游戏结束时生成败北场景。",
gameFinalPrompt: "用于生成的提示词(可编辑)",
gameGenerate: "生成",
gameOpenInGenerateUI: "在 GenerateUI 中打开",
gamePlayAgain: "再玩一次",
gameLoading: "正在加载游戏...",
gameLoadFailed: (msg) => `无法加载游戏: ${msg}`,
gameCleared: "CLEAR!",
gameOverLabel: "GAME OVER",
gameScore: (n) => `得分: ${n}`,
gameOverNoGenerate: "游戏结束,不生成结局图像。已通过关卡的图像会保留。",
gameRewardsTitle: "获得的提示词(取消勾选可排除):",
gameNoRewards: "没有获得提示词。仅使用基础提示词生成。",
gameNoWorkflow: "Game 设置中未选择工作流。",
gameWorkflowLoadFailed: (name) => `无法加载工作流: ${name}`,
gameNoPositiveNode: "工作流中没有正面提示词节点。",
gameEmptyPrompt: "提示词为空。",
gameGenerating: "生成中...",
gameNoImage: "工作流没有返回图像。",
gameGenerated: (path) => `已保存: ${path}`,
gameGenerateFailed: (msg) => `生成失败: ${msg}`,
helpGameTitle: "Game 标签页(实验性功能)",
helpGameCardOverview: "概述",
helpGameCardGen: "图像生成",
helpGame1: "只有安装了单独的游戏包 ComfyUI-WFS-Games 时才会显示 Game 标签页(启动时检查 /wfs_games/manifest)。未安装时,该标签页和本帮助页都不会显示",
helpGame2: "在左侧的“游戏”列表中选择游戏。游戏在中间运行;点击游戏画面后键盘输入只进入游戏(不会影响 Workflow Studio 的其他操作)。切换到其他标签页或窗口时游戏会暂停。右侧窗格分为“结果”(图像卡片)和“设置”(游戏设置和图像生成设置)两个标签页",
helpGame3: "Star Formation: 80年代街机和电脑(MSX2 / PC-8801)风格的纵向射击游戏——像素画、像素字体、扫描线和芯片音乐风格的背景音乐。共 5 关。敌机编队飞入、列阵,然后俯冲攻击。每关有 5 架敌机闪烁黄色,击落后会掉落“回忆之心”,请在它掉出画面前接住(+500 分;右上角的心形显示获得数)。消灭所有敌机后会出现 WARNING,背景音乐改变,关卡首领登场(画面上方的红色耐久条)。每个首领各有特点: 体型大且耐打、速度快且子弹快、放射状射击、闪烁后直线冲撞、分 3 次每次放出 5 架小型机的巨大母舰。用 ← → 或 A D 移动,Space 或 Z 射击,Esc 或 P 暂停;也支持手柄。在每关的前后,从管制室为你导航的莉娜会在冒险游戏风格的窗口中说话(按 Space、Z、Enter 或点击继续)。最后一架机体被击落后画面变暗,莉娜的呼唤得不到回应,随后 GAME OVER。击落俯冲中的敌机得分翻倍",
helpGame4: "游戏设置: 难度(简单: 5 条命 / 普通: 3 / 困难: 2,敌机射击和俯冲的频率也会变化)、背景音乐和音效。更改后游戏将重新开始。最高分保存在此浏览器中",
helpGame5: "“重新开始”会从标题画面重新开始游戏",
helpGame6: "每通过一关,右侧“结果”中就会添加该关的卡片(最新的在上面),并在后台生成以该关为背景的莉娜胜利纪念画面(比耶、挥手、竖大拇指等);生成期间可以继续游戏(图像按顺序一张一张生成)。如果在该关收集了全部 5 颗心,会显示 PERFECT!,卡片(粉色)会变成莉娜的私人照片,代替胜利纪念画面。随着关卡推进,露出会逐渐增加: 咖啡馆的便服 → 无袖连衣裙 → 露肩上衣和短裤 → 背心和牛仔短裤 → 海边的泳装(最多到泳装;游戏会追加负面标签,不会超过这个程度)。通过全部 5 关后会添加 ENDING 卡片。游戏结束时会添加红色的 GAME OVER 卡片,以失败的关卡为背景,生成莉娜在红色警示灯下昏暗的管制室里哭泣的败北场景。展开卡片的“提示词”可以看到游戏给出的提示词及其种类: 画风(80年代电脑图像风格)、女主角(莉娜的外观)、场景、关卡。取消勾选不需要的提示词或编辑提示词,然后按“重新生成”",
helpGame7: "工作流: 用于生成的工作流(默认 ws_game_sdxl_t2i.json,为 Game 标签页准备的 SDXL(Illustrious)文生图工作流,1216x832,输出到 output/WFS_Game)。提示词写入工作流的正面提示词节点。负面提示词为“负面提示词”设置(为空时使用工作流自带的)加上游戏的负面标签。seed 每次随机",
helpGame8: "可以关闭“每通过一关生成一张图像”“结局图像也自动生成”和“游戏结束时也生成图像”;关闭时,按卡片上的“生成”才会生成。“在 GenerateUI 中打开”会把带有该卡片提示词的工作流加载到 GenerateUI。从标题画面开始新游戏时卡片会被清除(图像保留在 output/WFS_Game)。打开 Game 标签页时不显示 VRAM 调整的提示。设置保存在浏览器中,并包含在备份中",
tsBuild: "创建 / 更新",
tsCancel: "停止",
tsMaxTags: "标签数:",
+7 -1
View File
@@ -13,6 +13,8 @@
import { t } from "./i18n.js";
import { showToast } from "./app.js";
const _showToast = showToast;
import { readJsonStorage, getAiBackendDefaultUrl } from "./util.js";
import { getDecisionSettings } from "./decision-client.js";
@@ -147,10 +149,14 @@ let _lastShortNote = "";
* Call right before queuing a generation. Does nothing when the mode is off; never throws.
* Shows a toast only when something was unloaded, the target can't be reached, or it failed
* (the same "can't reach target" note isn't repeated across a batch).
* quiet: no toast, console only. Used for generation from the Game tab, and whenever the Game
* tab is open (the toast would cover the game screen).
*/
export async function prepareVramForGeneration() {
export async function prepareVramForGeneration({ quiet = false } = {}) {
const settings = getVramSettings();
if (settings.mode === "off") return null;
if (!quiet && document.getElementById("wfm-tab-game")?.classList.contains("active")) quiet = true;
const showToast = quiet ? (msg) => console.info("[WFS] vram:", msg) : _showToast;
try {
const d = await requestVramPrepare(settings.mode, settings.targetGb);
const short = d.mode === "auto" && !d.reached;
+35
View File
@@ -12,6 +12,7 @@
<link rel="stylesheet" href="/wfm_static/css/lab-tab.css">
<link rel="stylesheet" href="/wfm_static/css/video-tab.css">
<link rel="stylesheet" href="/wfm_static/css/tagspace-tab.css">
<link rel="stylesheet" href="/wfm_static/css/game-tab.css">
</head>
<body>
<!-- Header -->
@@ -30,6 +31,8 @@
<button class="wfm-tab" data-tab="video">Video</button>
<button class="wfm-tab" data-tab="tagger">Tagger</button>
<button class="wfm-tab" data-tab="tagspace">TagSpace</button>
<!-- Game: ComfyUI-WFS-Games がインストールされているときだけ game-tab.js が表示する -->
<button class="wfm-tab" data-tab="game" hidden>Game</button>
<button class="wfm-tab" data-tab="settings">Settings</button>
<button class="wfm-tab" data-tab="help">Help</button>
<button class="wfm-tab" data-tab="ai">AI TOOL</button>
@@ -1359,6 +1362,7 @@
<button class="wfm-help-nav-item" data-help-page="tagspace">TagSpace Tab</button>
<button class="wfm-help-nav-item" data-help-page="imageedit">Image Edit Tab</button>
<button class="wfm-help-nav-item" data-help-page="video">Video Tab</button>
<button class="wfm-help-nav-item" data-help-page="game" hidden>Game Tab</button>
<button class="wfm-help-nav-item" data-help-page="shortcuts">Keyboard Shortcuts</button>
<button class="wfm-help-nav-item" data-help-page="trouble">Troubleshooting</button>
</div>
@@ -2050,6 +2054,34 @@
</div>
</div>
<div class="wfm-help-page" id="wfm-help-page-game">
<div class="wfm-help-article-header">
<h2 id="wfm-help-game-title">Game Tab (experimental)</h2>
<button type="button" class="wfm-btn wfm-btn-sm wfm-help-jump-btn" data-jump-tab="game">Open tab &rarr;</button>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-game-card-overview-title">Overview</h3>
<ul>
<li id="wfm-help-game-1"></li>
<li id="wfm-help-game-2"></li>
<li id="wfm-help-game-3"></li>
<li id="wfm-help-game-4"></li>
<li id="wfm-help-game-5"></li>
<li id="wfm-help-game-9"></li>
<li id="wfm-help-game-10"></li>
<li id="wfm-help-game-11"></li>
</ul>
</div>
<div class="wfm-help-card">
<h3 id="wfm-help-game-card-gen-title">Image Generation</h3>
<ul>
<li id="wfm-help-game-6"></li>
<li id="wfm-help-game-7"></li>
<li id="wfm-help-game-8"></li>
</ul>
</div>
</div>
<div class="wfm-help-page" id="wfm-help-page-imageedit">
<div class="wfm-help-article-header">
<h2 id="wfm-help-imageedit-title">Image Edit Tab</h2>
@@ -3451,6 +3483,9 @@
<!-- TagSpace Tab (内容は tagspace-tab.js が生成) -->
<section id="wfm-tab-tagspace" class="wfm-tab-content"></section>
<!-- Game Tab (内容は game-tab.js が生成。ゲームパック未インストール時は使われない) -->
<section id="wfm-tab-game" class="wfm-tab-content"></section>
<!-- AI Tab -->
<section id="wfm-tab-ai" class="wfm-tab-content">
<!-- Translation pane -->
+116
View File
@@ -0,0 +1,116 @@
{
"3": {
"class_type": "KSampler",
"inputs": {
"model": [
"4",
0
],
"positive": [
"6",
0
],
"negative": [
"7",
0
],
"latent_image": [
"5",
0
],
"seed": 636718080453780,
"steps": 20,
"cfg": 8,
"sampler_name": "euler",
"scheduler": "normal",
"denoise": 1
},
"_meta": {
"title": "KSampler"
}
},
"4": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "Illustrious\\IllustriousStyle_v22.safetensors"
},
"_meta": {
"title": "CheckpointLoaderSimple"
}
},
"5": {
"class_type": "EmptyLatentImage",
"inputs": {
"width": 1216,
"height": 832,
"batch_size": 1
},
"_meta": {
"title": "EmptyLatentImage"
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "masterpiece, best quality, outer space scenery"
},
"_meta": {
"title": "Positive Prompt (Game)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"4",
1
],
"text": "lowres, worst quality, bad quality, text, watermark, signature"
},
"_meta": {
"title": "Negative Prompt (Game)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"3",
0
],
"vae": [
"10",
0
]
},
"_meta": {
"title": "VAEDecode"
}
},
"9": {
"class_type": "SaveImage",
"inputs": {
"images": [
"8",
0
],
"filename_prefix": "WFS_Game/game"
},
"_meta": {
"title": "SaveImage"
}
},
"10": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "sdxl_vae.safetensors"
},
"_meta": {
"title": "VAELoader"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB