Skip to content

Type refactor - #1

Merged
sblzdddd merged 7 commits into
mainfrom
type-refactor
Mar 27, 2026
Merged

sblzdddd merged 7 commits into
mainfrom
type-refactor

Conversation

@sblzdddd

Copy link
Copy Markdown
Collaborator

No description provided.

sblzdddd and others added 7 commits February 3, 2026 09:14
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 AI review requested due to automatic review settings March 27, 2026 02:45
@sblzdddd

Copy link
Copy Markdown
Collaborator Author

@copilot 给老子说话

@sblzdddd

Copy link
Copy Markdown
Collaborator Author

666飞舞

@sblzdddd
sblzdddd merged commit 0360fcd into main Mar 27, 2026
4 of 5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 shows src/InputSystem/InputSystem.Gamepad.js (and no .ts file). This will cause a module resolution failure. Align the filename/extension (either create InputSystem.Gamepad.ts and 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 to SkipModeStarted/SkipModeEnded).
    src/Utils/DialogHelper.ts:1
  • Unconditional console.log in 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, previousNode is set to undefined, but the loop continues; any subsequent instruction in the same block will hit previousNode.connect(...) and crash. If ShowDecision semantically ends the linear chain, exit early (e.g., stop iterating) or handle the post-decision chain explicitly instead of nulling previousNode.
    src/Debug/Graph/SubgraphBuilder.ts:1
  • After a ShowDecision, previousNode is set to undefined, but the loop continues; any subsequent instruction in the same block will hit previousNode.connect(...) and crash. If ShowDecision semantically ends the linear chain, exit early (e.g., stop iterating) or handle the post-decision chain explicitly instead of nulling previousNode.
    src/Scripts/SYSTEM.ts:1
  • The message handler trusts event.data without validating event.origin and (ideally) event.source against the window returned by window.open(...). Add an origin check (same-origin) and ignore unexpected senders to prevent other pages/tabs from posting spoofed save-game / load-game messages.
    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 consider newline=\"\") to make the tool deterministic across environments.
    src/Graphics/Toggle.ts:1
  • toToggle currently always returns null, which is a breaking/unsafe API if any callers expect a working toggle (or at least a Toggle instance). Either implement the conversion (mirroring toButton) 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:1
  • toToggle currently always returns null, which is a breaking/unsafe API if any callers expect a working toggle (or at least a Toggle instance). Either implement the conversion (mirroring toButton) 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.

Comment on lines +73 to +75
<div id="event-graph-toolbar">
<button id="btn-refresh-graph" class="graph-btn">Refresh</button>
</div>

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
this.container = document.getElementById("event-graph-overlay")!;
this.canvasElement = document.getElementById("event-graph-canvas") as HTMLCanvasElement;

$("#btn-close-graph").on("click", () => this.toggle());

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
return;
}

console.log("Refrehsing Event Graph...", eventsMap);

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in log message: 'Refrehsing' should be 'Refreshing'.

Copilot uses AI. Check for mistakes.
sblzdddd added a commit that referenced this pull request Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants