From 8afcd5d1185bc53d51b3dacec0b00428c3975e58 Mon Sep 17 00:00:00 2001 From: sopiro Date: Mon, 4 Mar 2024 21:22:02 +0900 Subject: [PATCH] Update ts version --- out/settings.js | 32 +++++++++++++++++++++----------- package.json | 2 +- src/game.ts | 4 ++-- src/settings.ts | 5 +++-- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/out/settings.js b/out/settings.js index badbdd9..508d625 100644 --- a/out/settings.js +++ b/out/settings.js @@ -1,13 +1,15 @@ import * as Util from "./util.js"; export var GenerationShape; -(function (GenerationShape) { +(function (GenerationShape) +{ GenerationShape[GenerationShape["Box"] = 0] = "Box"; GenerationShape[GenerationShape["Circle"] = 1] = "Circle"; GenerationShape[GenerationShape["Regular"] = 2] = "Regular"; GenerationShape[GenerationShape["Random"] = 3] = "Random"; })(GenerationShape || (GenerationShape = {})); export var MouseMode; -(function (MouseMode) { +(function (MouseMode) +{ MouseMode[MouseMode["Grab"] = 0] = "Grab"; MouseMode[MouseMode["Force"] = 1] = "Force"; })(MouseMode || (MouseMode = {})); @@ -24,14 +26,16 @@ export const Settings = { paused: false, boxCount: 15, genSpeed: 50, - aabbMargin: 0.1, - aabbMultiplier: 4.0, colorize: true, applyRotation: true, + // These two options are actually tree member variables.. + aabbMargin: 0.1, + aabbMultiplier: 4.0, }; // Remove the default pop-up context menu let cvs = document.querySelector("#canvas"); -cvs.oncontextmenu = (e) => { +cvs.oncontextmenu = (e) => +{ e.preventDefault(); e.stopPropagation(); }; @@ -39,7 +43,8 @@ const boxCount = document.querySelector("#boxCount"); boxCount.value = String(Util.map(Settings.boxCount, boxCountRange.p1, boxCountRange.p2, 0, 100)); const boxCountLabel = document.querySelector("#boxCount_label"); boxCountLabel.innerHTML = String(Settings.boxCount); -boxCount.addEventListener("input", () => { +boxCount.addEventListener("input", () => +{ let mappedValue = Util.map(Number(boxCount.value), 0, 100, boxCountRange.p1, boxCountRange.p2); mappedValue = Math.trunc(mappedValue); boxCountLabel.innerHTML = String(mappedValue); @@ -49,7 +54,8 @@ const genSpeed = document.querySelector("#genSpeed"); genSpeed.value = String(Util.map(Settings.genSpeed, genSpeedRange.p1, genSpeedRange.p2, 0, 100)); const genSpeedLabel = document.querySelector("#genSpeed_label"); genSpeedLabel.innerHTML = String(Settings.genSpeed) + "ms"; -genSpeed.addEventListener("input", () => { +genSpeed.addEventListener("input", () => +{ let mappedValue = Util.map(Number(genSpeed.value), 0, 100, genSpeedRange.p1, genSpeedRange.p2); mappedValue = Math.trunc(mappedValue); genSpeedLabel.innerHTML = String(mappedValue) + "ms"; @@ -59,7 +65,8 @@ const margin = document.querySelector("#margin"); margin.value = String(Util.map(Settings.aabbMargin, marginRange.p1, marginRange.p2, 0, 100)); const marginLabel = document.querySelector("#margin_label"); marginLabel.innerHTML = String(Settings.aabbMargin) + "cm"; -margin.addEventListener("input", () => { +margin.addEventListener("input", () => +{ let mappedValue = Util.map(Number(margin.value), 0, 100, marginRange.p1, marginRange.p2); marginLabel.innerHTML = String(mappedValue) + "cm"; updateSetting("margin", mappedValue); @@ -68,7 +75,8 @@ const multiplier = document.querySelector("#multiplier"); multiplier.value = String(Util.map(Settings.aabbMultiplier, multiplierRange.p1, multiplierRange.p2, 0, 100)); const multiplierLabel = document.querySelector("#multiplier_label"); multiplierLabel.innerHTML = String(Settings.aabbMultiplier); -multiplier.addEventListener("input", () => { +multiplier.addEventListener("input", () => +{ let mappedValue = Util.map(Number(multiplier.value), 0, 100, multiplierRange.p1, multiplierRange.p2); mappedValue = Math.trunc(mappedValue); multiplierLabel.innerHTML = String(mappedValue); @@ -80,8 +88,10 @@ colorize.addEventListener("click", () => { Settings.colorize = colorize.checked; const applyRotation = document.querySelector("#applyRotation"); applyRotation.checked = Settings.applyRotation; applyRotation.addEventListener("click", () => { Settings.applyRotation = applyRotation.checked; }); -export function updateSetting(id, content) { - switch (id) { +export function updateSetting(id, content) +{ + switch (id) + { case "pause": Settings.paused = !Settings.paused; break; diff --git a/package.json b/package.json index 03e7cfd..3dbc1a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { "ts-loader": "^9.2.6", - "typescript": "^4.4.4" + "typescript": "^4.9.5" } } diff --git a/src/game.ts b/src/game.ts index 2416498..f9b4b3c 100644 --- a/src/game.ts +++ b/src/game.ts @@ -29,7 +29,7 @@ export class Game private tree: AABBTree; - private initRoutines: NodeJS.Timer[] = []; + private initRoutines: NodeJS.Timeout[] = []; private creating: boolean = false; private grabbing: boolean = false; private removing: boolean = false; @@ -84,7 +84,7 @@ export class Game this.tree.reset(); for (let r of this.initRoutines) - clearInterval(r); + clearInterval(r) // Random initial spread let seedString = this.seedTextBox.value; diff --git a/src/settings.ts b/src/settings.ts index 0675cbf..bc17ba9 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -28,10 +28,11 @@ export const Settings = { paused: false, boxCount: 15, genSpeed: 50, - aabbMargin: 0.1, - aabbMultiplier: 4.0, colorize: true, applyRotation: true, + // These two options are actually tree member variables.. + aabbMargin: 0.1, + aabbMultiplier: 4.0, } // Remove the default pop-up context menu