Repository navigation
Type refactor - #1
Conversation
debug panes deprecated; remove d3 in dependency
…ation Implement helper functions for dialog text processing including: - Plain text normalization - Dialog data extraction with character name validation - Voice event and character voice name generation - Binary translation file loading and parsing
|
@copilot 给老子说话 |
|
666飞舞 |
There was a problem hiding this comment.
Pull request overview
Migrates the codebase toward a TypeScript + Vite setup while adding/adjusting runtime features like translation loading, UI scene scripts, and an in-game event graph overlay.
Changes:
- Added Vite + TypeScript project configuration and switched entrypoints to TS.
- Refactored many engine/game modules and UI scripts toward typed implementations, removing older JS counterparts.
- Added translation tooling/assets and a new debug Event Graph overlay (LiteGraph-based).
Reviewed changes
Copilot reviewed 68 out of 84 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| vite.config.ts | Adds Vite config with @ alias and build/server options. |
| tsconfig.json | Introduces TS compiler settings + path alias for @/*. |
| translation/pyproject.toml | Adds Python project metadata for translation tooling. |
| translation/main.py | Updates translation binary generation logic to incorporate choices.txt. |
| translation/choices.txt | Adds choice strings (JP + CN) used to build translation mapping. |
| translation/.python-version | Pins Python version for the translation tool. |
| src/main.ts | Switches app entrypoint to TS; initializes engine, scenes, audio, translation, overlay. |
| src/main.js | Removes old JS entrypoint. |
| src/Utils/Translator.ts | Adds translation binary loader and $translate() helper. |
| src/Utils/DialogHelper.ts | Ports dialog parsing to TS and applies $translate() to dialog content. |
| src/Utils/DialogHelper.js | Removes old JS dialog helper. |
| src/Scripts/WINDOW/WINDOW.ts | Ports dialog window scene logic to TS and hooks dialog events. |
| src/Scripts/WINDOW/WINDOW.js | Removes old JS dialog window. |
| src/Scripts/WINDOW/WINDOW.SelectionsBox.ts | Adds TS selections box with animation + translation for choice text. |
| src/Scripts/WINDOW/WINDOW.SelectionsBox.js | Removes old JS selections box. |
| src/Scripts/WINDOW/WINDOW.DialogHider.js | Updates dialog hider imports/types and switches to alias-based paths. |
| src/Scripts/SYSTEM.ts | Ports pause/system screen to TS and keeps save/load message flow. |
| src/Scripts/SYSTEM.js | Removes old JS system screen. |
| src/Scripts/START.ts | Ports start scene to TS and preserves load flow. |
| src/Scripts/START.js | Removes old JS start scene. |
| src/Scripts/GALLERY.js | Refactors gallery script imports/typing and adds null checks. |
| src/Scripts/BACKGROUND.ts | Ports background scene creation/event handlers to TS. |
| src/Scripts/BACKGROUND.js | Removes old JS background scene. |
| src/Scene/SceneManagement.js | Adds types and refactors scene loading/creation logic (but remains .js). |
| src/Scene/SceneData.ts | Introduces typed scene JSON structures. |
| src/Scene/Scene.ts | Ports Scene implementation to TS with typed object lookup. |
| src/Scene/Scene.js | Removes old JS Scene implementation. |
| src/InputSystem/InputSystem.Keyboard.ts | Ports keyboard input to TS and adds single-flight exit handler behavior. |
| src/InputSystem/InputSystem.Keyboard.js | Removes old JS keyboard input. |
| src/InputSystem/InputSystem.Gamepad.js | Refactors gamepad input and focus/click triggering (but introduces TS syntax in .js). |
| src/Graphics/Toggle.ts | Adds TS Toggle skeleton (currently stubbed). |
| src/Graphics/Graphics.Toggle.js | Removes old JS Toggle/toToggle. |
| src/Graphics/Graphics.TextMessPoor.js | Refactors text components with TS types (but remains .js). |
| src/Graphics/Graphics.SceneElement.js | Refactors SceneElement with TS types/accessors (but remains .js). |
| src/Graphics/Graphics.FocusableElement.js | Removes old JS FocusableElement. |
| src/Graphics/Graphics.Button.js | Removes old JS Button/toButton. |
| src/Graphics/Graphics.Background.js | Removes old JS Background/toBackground. |
| src/Graphics/Graphics.AnimatedSceneElement.js | Refactors animation element with TS types (but remains .js). |
| src/Graphics/FocusableElement.ts | Adds TS FocusableElement implementation. |
| src/Graphics/Button.ts | Adds TS Button/toButton implementation. |
| src/Graphics/Background.ts | Adds TS Background/toBackground implementation. |
| src/Debug/SceneGraphPane.js | Removes old D3-based scene graph/debug pane. |
| src/Debug/Graph/SubgraphBuilder.ts | Adds LiteGraph subgraph builder for event blocks. |
| src/Debug/Graph/Nodes/index.ts | Registers LiteGraph node types and instruction-to-node mapping. |
| src/Debug/Graph/Nodes/TransitionToGraphicsNode.ts | Adds image-preview nodes for TransitionToGraphics instructions. |
| src/Debug/Graph/Nodes/SetCharaImgNode.ts | Adds image-preview node for character portrait instruction. |
| src/Debug/Graph/Nodes/ImagePreviewNode.ts | Adds base class for drawing image thumbnails in nodes. |
| src/Debug/Graph/Nodes/DialogNodes.ts | Adds dialog/branch nodes for graph visualization. |
| src/Debug/Graph/Nodes/BaseNodes.ts | Adds base generic/start/end node types. |
| src/Debug/Graph/Nodes/BackgroundNodes.ts | Adds BG/CG preview nodes. |
| src/Debug/Graph/LayoutStrategy.ts | Implements deterministic graph layout strategy. |
| src/Debug/Graph/EventGraphLayout.ts | Builds/layouts main graph + subgraphs; lazy-loads internals. |
| src/Debug/Graph/EventGraphEditor.ts | Adds in-game overlay editor toggled by F3. |
| src/Debug/EnginePane.js | Removes old tweakpane-based engine pane. |
| src/Debug/DebugPane.js | Removes old debug pane container logic. |
| src/Core/NotUnityEngine.js | Adds TS interfaces/typing to engine (but remains .js). |
| src/Core/GameSave.js | Adds types and improves background object checks (but remains .js). |
| src/Core/Events.js | Adds TS interfaces/types and refactors event execution (but remains .js). |
| src/Audio/Voice.ts | Adds TS voice playback logic tied to dialog/skip events. |
| src/Audio/Se.ts | Adds TS sound-effect playback logic. |
| src/Audio/Audio.Voice.js | Removes old JS voice module. |
| src/Audio/Audio.Se.js | Removes old JS SE module. |
| src/Audio/Audio.Bgm.js | Adds types and refactors BGM module (but remains .js). |
| save_load.html | Updates module imports to TS paths and adjusts selection comparison. |
| pnpm-workspace.yaml | Adds pnpm workspace config for dependency build allowlist. |
| package.json | Adds pnpm + Vite + TS deps and scripts. |
| index.html | Switches entry script to TS module and removes manual lib scripts. |
| LICENSE | Adjusts license header indentation. |
Files not reviewed (5)
- .idea/.gitignore: Language not supported
- .idea/ALIVEJS.iml: Language not supported
- .idea/modules.xml: Language not supported
- .idea/vcs.xml: Language not supported
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (9)
src/main.ts:1
- The import points to
InputSystem.Gamepad.ts, but the diff showssrc/InputSystem/InputSystem.Gamepad.js(and no.tsfile). This will cause a module resolution failure. Align the filename/extension (either createInputSystem.Gamepad.tsand update references, or import the existing module path).
src/Scripts/BACKGROUND.ts:1 - This interval runs indefinitely and is not cleared on scene destroy, which can leak timers across reloads/scenes. Store the interval id and clear it in
backgroundScene.onDestroyCallbacks, or replace polling with event-driven updates (e.g., react toSkipModeStarted/SkipModeEnded).
src/Utils/DialogHelper.ts:1 - Unconditional
console.login the dialog parse path will spam logs during normal gameplay. Remove it or gate it behind a debug flag/log-level check.
src/Debug/Graph/SubgraphBuilder.ts:1 - After a
ShowDecision,previousNodeis set toundefined, but the loop continues; any subsequent instruction in the same block will hitpreviousNode.connect(...)and crash. IfShowDecisionsemantically ends the linear chain, exit early (e.g., stop iterating) or handle the post-decision chain explicitly instead of nullingpreviousNode.
src/Debug/Graph/SubgraphBuilder.ts:1 - After a
ShowDecision,previousNodeis set toundefined, but the loop continues; any subsequent instruction in the same block will hitpreviousNode.connect(...)and crash. IfShowDecisionsemantically ends the linear chain, exit early (e.g., stop iterating) or handle the post-decision chain explicitly instead of nullingpreviousNode.
src/Scripts/SYSTEM.ts:1 - The
messagehandler trustsevent.datawithout validatingevent.originand (ideally)event.sourceagainst the window returned bywindow.open(...). Add an origin check (same-origin) and ignore unexpected senders to prevent other pages/tabs from posting spoofedsave-game/load-gamemessages.
translation/main.py:1 - The file contains Japanese/Chinese text; opening without an explicit encoding can break on systems whose default locale isn't UTF-8. Open with
encoding=\"utf-8\"(and considernewline=\"\") to make the tool deterministic across environments.
src/Graphics/Toggle.ts:1 toTogglecurrently always returnsnull, which is a breaking/unsafe API if any callers expect a working toggle (or at least aToggleinstance). Either implement the conversion (mirroringtoButton) or remove/avoid exporting this helper until it’s functional; alternatively, throw a clear error so failures are immediate and diagnosable.
src/Graphics/Toggle.ts:1toTogglecurrently always returnsnull, which is a breaking/unsafe API if any callers expect a working toggle (or at least aToggleinstance). Either implement the conversion (mirroringtoButton) or remove/avoid exporting this helper until it’s functional; alternatively, throw a clear error so failures are immediate and diagnosable.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <div id="event-graph-toolbar"> | ||
| <button id="btn-refresh-graph" class="graph-btn">Refresh</button> | ||
| </div> |
There was a problem hiding this comment.
A click handler is registered for #btn-close-graph, but the overlay HTML doesn't include an element with that id. Either add a Close button to the toolbar/template or remove the unused binding.
| this.container = document.getElementById("event-graph-overlay")!; | ||
| this.canvasElement = document.getElementById("event-graph-canvas") as HTMLCanvasElement; | ||
|
|
||
| $("#btn-close-graph").on("click", () => this.toggle()); |
There was a problem hiding this comment.
A click handler is registered for #btn-close-graph, but the overlay HTML doesn't include an element with that id. Either add a Close button to the toolbar/template or remove the unused binding.
| return; | ||
| } | ||
|
|
||
| console.log("Refrehsing Event Graph...", eventsMap); |
There was a problem hiding this comment.
Typo in log message: 'Refrehsing' should be 'Refreshing'.
No description provided.