112 lines
4 KiB
JavaScript
112 lines
4 KiB
JavaScript
"use strict";
|
|
|
|
const canvas = document.getElementById("gameCanvas");
|
|
const ctx = canvas.getContext("2d");
|
|
const ui = {
|
|
pauseBtn: document.getElementById("pauseBtn"),
|
|
speedBtn: document.getElementById("speedBtn"),
|
|
ecologyBtn: document.getElementById("ecologyBtn"),
|
|
soundBtn: document.getElementById("soundBtn"),
|
|
soundMenu: document.getElementById("soundMenu"),
|
|
soundPanel: document.getElementById("soundPanel"),
|
|
soundMasterToggle: document.getElementById("soundMasterToggle"),
|
|
creditsBtn: document.getElementById("creditsBtn"),
|
|
resetBtn: document.getElementById("resetBtn"),
|
|
creditsDialog: document.getElementById("creditsDialog"),
|
|
creditsCloseBtn: document.getElementById("creditsCloseBtn"),
|
|
toolPalette: document.getElementById("toolPalette"),
|
|
toolCard: document.getElementById("toolCard"),
|
|
selectedCard: document.getElementById("selectedCard"),
|
|
selectedCloseBtn: document.getElementById("selectedCloseBtn"),
|
|
colonyChartTabs: document.getElementById("colonyChartTabs"),
|
|
selectedInfo: document.getElementById("selectedInfo"),
|
|
log: document.getElementById("log"),
|
|
logPushControls: document.getElementById("logPushControls"),
|
|
logPushEnabled: document.getElementById("logPushEnabled"),
|
|
logPushOverlay: document.getElementById("logPushOverlay"),
|
|
mobileModeControls: document.getElementById("mobileModeControls"),
|
|
soundCategoryControls: document.getElementById("soundPanel"),
|
|
toast: document.getElementById("toast"),
|
|
statPop: document.getElementById("statPop"),
|
|
statDead: document.getElementById("statDead"),
|
|
colonyChart: document.getElementById("colonyChart"),
|
|
colonyChartLegend: document.getElementById("colonyChartLegend"),
|
|
archiveContent: document.getElementById("archiveContent"),
|
|
archiveUpdateToggleBtn: document.getElementById("archiveUpdateToggleBtn"),
|
|
archiveResetBtn: document.getElementById("archiveResetBtn"),
|
|
archiveResetDialog: document.getElementById("archiveResetDialog"),
|
|
archiveResetCancelBtn: document.getElementById("archiveResetCancelBtn"),
|
|
archiveResetConfirmBtn: document.getElementById("archiveResetConfirmBtn"),
|
|
fieldDialog: document.getElementById("fieldDialog"),
|
|
fieldCancelBtn: document.getElementById("fieldCancelBtn"),
|
|
ecologyDialog: document.getElementById("ecologyDialog"),
|
|
ecologyGrid: document.getElementById("ecologyGrid"),
|
|
ecologyCloseBtn: document.getElementById("ecologyCloseBtn"),
|
|
};
|
|
|
|
const uiCache = {
|
|
stats: {},
|
|
selectedSnapshot: "",
|
|
selectedEmpty: false,
|
|
selectedCollapsedCategories: new Set(),
|
|
logPushEnabled: false,
|
|
logPushKinds: new Set(["death", "accident", "birth"]),
|
|
archiveUpdateEnabled: false,
|
|
toolButtons: [],
|
|
archiveVersion: "",
|
|
archiveRows: [],
|
|
archiveFamilyVersion: null,
|
|
archiveRelationSignature: "",
|
|
archiveHtmlCache: new Map(),
|
|
archiveRenderTimer: 0,
|
|
archiveRenderForce: false,
|
|
archiveRenderRunning: false,
|
|
archiveScheduled: false,
|
|
archivePendingOffscreen: false,
|
|
archivePendingWhileRunning: false,
|
|
archivePendingDirtyAfterRun: false,
|
|
archiveLastHiddenCheckAt: -Infinity,
|
|
archiveLastRenderedAt: 0,
|
|
archiveLastScheduleFamilyVersion: null,
|
|
archiveDiagnostics: { renders: 0, lastMs: 0, lastFamilies: 0, lastNodes: 0, skippedWhileRunning: 0 },
|
|
archiveScrollScheduled: false,
|
|
deferArchiveUntil: 0,
|
|
lastArchiveWindow: "",
|
|
chartHistory: [],
|
|
chartBucketStart: -Infinity,
|
|
chartBucketEnd: -Infinity,
|
|
chartBucketAccum: null,
|
|
environmentInitialRow: null,
|
|
lastChartSample: -Infinity,
|
|
lastChartDraw: "",
|
|
lastChartDrawAt: 0,
|
|
chartMode: "population",
|
|
canvasDpr: 0,
|
|
panning: false,
|
|
panLastX: 0,
|
|
panLastY: 0,
|
|
panMoved: false,
|
|
grabbing: false,
|
|
grabTarget: null,
|
|
grabKind: "",
|
|
grabMoved: false,
|
|
grabStartX: 0,
|
|
grabStartY: 0,
|
|
grabLastWorldX: 0,
|
|
grabLastWorldY: 0,
|
|
grabLastSpatialAt: 0,
|
|
mobileInputMode: window.TarinaiInputMode?.currentMode || "auto",
|
|
touchMode: "",
|
|
touchMoved: false,
|
|
touchStartX: 0,
|
|
touchStartY: 0,
|
|
touchLastX: 0,
|
|
touchLastY: 0,
|
|
touchLastWorldX: 0,
|
|
touchLastWorldY: 0,
|
|
pinchStartDistance: 0,
|
|
pinchStartZoom: 1,
|
|
pinchFocusWorld: null,
|
|
pinchLastCenterX: 0,
|
|
pinchLastCenterY: 0,
|
|
};
|