Refactor runtime bootstrap and ship control flows

This commit is contained in:
2026-04-03 01:12:26 -04:00
parent 0bb72bee35
commit 706e1cda8f
129 changed files with 9588 additions and 3548 deletions

View File

@@ -5,8 +5,13 @@ import { ViewerPresentationController } from "./viewerPresentationController";
import { ViewerSceneDataController } from "./viewerSceneDataController";
import { ViewerWorldLifecycle } from "./viewerWorldLifecycle";
import { ViewerHistoryWindowController } from "./viewerHistoryWindowController";
import { useViewerSceneStore } from "./ui/stores/viewerScene";
import { useViewerOrderContextMenuStore } from "./ui/stores/viewerOrderContextMenu";
import { viewerPinia } from "./ui/stores/pinia";
export function createViewerControllers(host: any) {
const sceneStore = useViewerSceneStore(viewerPinia);
const orderContextMenuStore = useViewerOrderContextMenuStore(viewerPinia);
const sceneDataController = new ViewerSceneDataController({
documentRef: document,
getWorldOrbitalTimeSeconds: () => host.world?.orbitalTimeSeconds,
@@ -41,6 +46,7 @@ export function createViewerControllers(host: any) {
getActiveSystemId: () => host.activeSystemId,
setActiveSystemId: (value) => {
host.activeSystemId = value;
sceneStore.setViewContext(value ?? null, host.povLevel);
},
onActiveSystemChanged: (oldId, newId) => {
sceneDataController.onActiveSystemChanged(oldId, newId);
@@ -243,6 +249,8 @@ export function createViewerControllers(host: any) {
updatePanels: () => host.updatePanels(),
focusOnSelection: (selection) => navigationController.focusOnSelection(selection),
updateGamePanel: (mode) => host.updateGamePanel(mode),
openOrderContextMenu: (x, y, target) => orderContextMenuStore.open(x, y, target),
closeOrderContextMenu: () => orderContextMenuStore.close(),
historyController,
});
@@ -263,6 +271,7 @@ export function wireViewerEvents(host: any) {
canvas.addEventListener("pointerup", host.interactionController.onPointerUp);
canvas.addEventListener("pointerleave", host.interactionController.onPointerUp);
canvas.addEventListener("click", host.interactionController.onClick);
canvas.addEventListener("contextmenu", host.interactionController.onContextMenu);
canvas.addEventListener("dblclick", host.interactionController.onDoubleClick);
canvas.addEventListener("wheel", host.interactionController.onWheel, { passive: false });
host.historyLayerEl.addEventListener("click", host.interactionController.onHistoryLayerClick);
@@ -277,6 +286,7 @@ export function wireViewerEvents(host: any) {
canvas.removeEventListener("pointerup", host.interactionController.onPointerUp);
canvas.removeEventListener("pointerleave", host.interactionController.onPointerUp);
canvas.removeEventListener("click", host.interactionController.onClick);
canvas.removeEventListener("contextmenu", host.interactionController.onContextMenu);
canvas.removeEventListener("dblclick", host.interactionController.onDoubleClick);
canvas.removeEventListener("wheel", host.interactionController.onWheel);
host.historyLayerEl.removeEventListener("click", host.interactionController.onHistoryLayerClick);