From da94d5264a66cf604f0e6fa9ceee21c1f7854f73 Mon Sep 17 00:00:00 2001 From: Dimava Date: Sat, 30 May 2020 10:54:53 +0300 Subject: [PATCH 01/22] replace MouseEvent.which with MouseEvent.button --- src/js/core/click_detector.js | 4 ++-- src/js/game/camera.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/core/click_detector.js b/src/js/core/click_detector.js index 557c1f28..1e332aa2 100644 --- a/src/js/core/click_detector.js +++ b/src/js/core/click_detector.js @@ -311,7 +311,7 @@ export class ClickDetector { const position = /** @type {typeof ClickDetector} */ (this.constructor).extractPointerPosition(event); if (event instanceof MouseEvent) { - const isRightClick = event.which == 3; + const isRightClick = event.button === 2; if (isRightClick) { // Ignore right clicks this.rightClick.dispatch(position, event); @@ -384,7 +384,7 @@ export class ClickDetector { } if (event instanceof MouseEvent) { - const isRightClick = event.which == 3; + const isRightClick = event.button === 2; if (isRightClick) { return; } diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 930d6932..2e558216 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -436,11 +436,11 @@ export class Camera extends BasicSerializableObject { } this.touchPostMoveVelocity = new Vector(0, 0); - if (event.which === 1) { + if (event.button === 0) { this.combinedSingleTouchStartHandler(event.clientX, event.clientY); - } else if (event.which === 2) { + } else if (event.button === 1) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.middle); - } else if (event.which === 3) { + } else if (event.button === 2) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right); } return false; @@ -460,7 +460,7 @@ export class Camera extends BasicSerializableObject { return; } - if (event.which === 1) { + if (event.button === 0) { this.combinedSingleTouchMoveHandler(event.clientX, event.clientY); } From e58c2fd3711d5ed9afee7381ac7721c76aa3218e Mon Sep 17 00:00:00 2001 From: Dimava Date: Sat, 30 May 2020 10:56:23 +0300 Subject: [PATCH 02/22] use MouseEvent in keyboard hooks --- src/js/core/input_distributor.js | 31 +++++++++++++++++-------------- src/js/game/camera.js | 5 +++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/js/core/input_distributor.js b/src/js/core/input_distributor.js index 4bd476b4..439b8dfe 100644 --- a/src/js/core/input_distributor.js +++ b/src/js/core/input_distributor.js @@ -182,25 +182,28 @@ export class InputDistributor { } /** - * @param {KeyboardEvent} event + * @param {KeyboardEvent | MouseEvent} event */ handleKeydown(event) { + const keyCode = event instanceof MouseEvent ? event.button : event.keyCode; if ( - event.keyCode === 9 || // TAB - event.keyCode === 16 || // SHIFT - event.keyCode === 17 || // CTRL - event.keyCode === 18 || // ALT - (event.keyCode >= 112 && event.keyCode < 122) // F1 - F10 + keyCode === 3 || + keyCode === 4 || // MB3 / MB4 + keyCode === 9 || // TAB + keyCode === 16 || // SHIFT + keyCode === 17 || // CTRL + keyCode === 18 || // ALT + (keyCode >= 112 && keyCode < 122) // F1 - F10 ) { event.preventDefault(); } - const isInitial = !this.keysDown.has(event.keyCode); - this.keysDown.add(event.keyCode); + const isInitial = !this.keysDown.has(keyCode); + this.keysDown.add(keyCode); if ( this.forwardToReceiver("keydown", { - keyCode: event.keyCode, + keyCode: keyCode, shift: event.shiftKey, alt: event.altKey, initial: isInitial, @@ -210,8 +213,7 @@ export class InputDistributor { return; } - const code = event.keyCode; - if (code === 27) { + if (keyCode === 27) { // Escape key event.preventDefault(); event.stopPropagation(); @@ -220,13 +222,14 @@ export class InputDistributor { } /** - * @param {KeyboardEvent} event + * @param {KeyboardEvent | MouseEvent} event */ handleKeyup(event) { - this.keysDown.delete(event.keyCode); + const keyCode = event instanceof MouseEvent ? event.button : event.keyCode; + this.keysDown.delete(keyCode); this.forwardToReceiver("keyup", { - keyCode: event.keyCode, + keyCode: keyCode, shift: event.shiftKey, alt: event.altKey, }); diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 2e558216..21e7bbde 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -442,6 +442,8 @@ export class Camera extends BasicSerializableObject { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.middle); } else if (event.button === 2) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right); + } else { + this.root.app.inputMgr.handleKeydown(event); } return false; } @@ -484,6 +486,9 @@ export class Camera extends BasicSerializableObject { if (!this.checkPreventDoubleMouse()) { return; } + if (event.button >= 3) { + this.root.app.inputMgr.handleKeyup(event); + } this.combinedSingleTouchStopHandler(event.clientX, event.clientY); return false; From 79dcd79734848e25ed736183f638a54c012c59f0 Mon Sep 17 00:00:00 2001 From: Dimava Date: Sat, 30 May 2020 10:57:02 +0300 Subject: [PATCH 03/22] use MouseEvent in keybind change hooks --- src/js/game/key_action_mapper.js | 10 ++++++++++ src/js/states/keybindings.js | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index 60690934..bd49d29e 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -86,6 +86,16 @@ for (const categoryId in KEYMAPPINGS) { */ export function getStringForKeyCode(code) { switch (code) { + case 0: + return "LMB"; + case 1: + return "MMB"; + case 2: + return "RMB"; + case 3: + return "MB4"; + case 4: + return "MB5"; case 8: return "⌫"; case 9: diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index 0f7fcf9e..f4aad427 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -121,9 +121,24 @@ export class KeybindingsState extends TextualGameState { this.updateKeybindings(); }); - dialog.inputReciever.backButton.add(() => {}); + const clickListener = event => { + console.log(event); + if (event.target.tagName == "BUTTON") { + return; + } + event.preventDefault(); + const keyCode = event.button; + this.app.settings.updateKeybindingOverride(id, keyCode); + + this.dialogs.closeDialog(dialog); + this.updateKeybindings(); + }; + + dialog.inputReciever.backButton.add(() => {}); this.dialogs.internalShowDialog(dialog); + dialog.element.onmousedown = clickListener; + this.app.sound.playUiSound(SOUNDS.dialogOk); } From d5d615bfd3d7955cc6ac7bf885182ae417680de6 Mon Sep 17 00:00:00 2001 From: Dimava Date: Sat, 30 May 2020 11:11:26 +0300 Subject: [PATCH 04/22] change MouseEvent keyCode to event.button + 1 --- src/js/core/input_distributor.js | 8 ++++---- src/js/game/key_action_mapper.js | 10 +++++----- src/js/states/keybindings.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/js/core/input_distributor.js b/src/js/core/input_distributor.js index 439b8dfe..e46a3076 100644 --- a/src/js/core/input_distributor.js +++ b/src/js/core/input_distributor.js @@ -185,10 +185,10 @@ export class InputDistributor { * @param {KeyboardEvent | MouseEvent} event */ handleKeydown(event) { - const keyCode = event instanceof MouseEvent ? event.button : event.keyCode; + const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode; if ( - keyCode === 3 || - keyCode === 4 || // MB3 / MB4 + keyCode === 4 || // MB4 + keyCode === 5 || // MB5 keyCode === 9 || // TAB keyCode === 16 || // SHIFT keyCode === 17 || // CTRL @@ -225,7 +225,7 @@ export class InputDistributor { * @param {KeyboardEvent | MouseEvent} event */ handleKeyup(event) { - const keyCode = event instanceof MouseEvent ? event.button : event.keyCode; + const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode; this.keysDown.delete(keyCode); this.forwardToReceiver("keyup", { diff --git a/src/js/game/key_action_mapper.js b/src/js/game/key_action_mapper.js index bd49d29e..69511362 100644 --- a/src/js/game/key_action_mapper.js +++ b/src/js/game/key_action_mapper.js @@ -86,15 +86,15 @@ for (const categoryId in KEYMAPPINGS) { */ export function getStringForKeyCode(code) { switch (code) { - case 0: - return "LMB"; case 1: - return "MMB"; + return "LMB"; case 2: - return "RMB"; + return "MMB"; case 3: - return "MB4"; + return "RMB"; case 4: + return "MB4"; + case 5: return "MB5"; case 8: return "⌫"; diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index f4aad427..28bb05d5 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -127,7 +127,7 @@ export class KeybindingsState extends TextualGameState { return; } event.preventDefault(); - const keyCode = event.button; + const keyCode = event.button + 1; this.app.settings.updateKeybindingOverride(id, keyCode); From fe33f51424ad11bcb6e84283d748a5072266a7f8 Mon Sep 17 00:00:00 2001 From: Dimava Date: Sat, 30 May 2020 11:11:56 +0300 Subject: [PATCH 05/22] always use MouseEvent in keyboard hooks --- src/js/game/camera.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/js/game/camera.js b/src/js/game/camera.js index 21e7bbde..da2ab3f0 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -442,9 +442,8 @@ export class Camera extends BasicSerializableObject { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.middle); } else if (event.button === 2) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right); - } else { - this.root.app.inputMgr.handleKeydown(event); } + this.root.app.inputMgr.handleKeydown(event); return false; } @@ -486,9 +485,7 @@ export class Camera extends BasicSerializableObject { if (!this.checkPreventDoubleMouse()) { return; } - if (event.button >= 3) { - this.root.app.inputMgr.handleKeyup(event); - } + this.root.app.inputMgr.handleKeyup(event); this.combinedSingleTouchStopHandler(event.clientX, event.clientY); return false; From a92d703395e93ac16d6786bdc35d1da023835aba Mon Sep 17 00:00:00 2001 From: hexagonhexagon Date: Fri, 29 May 2020 18:02:35 -0400 Subject: [PATCH 06/22] Make formatBigNumber() include a decimal point, and support numbers up to 999.9T. --- src/js/core/utils.js | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/js/core/utils.js b/src/js/core/utils.js index f756a651..b33d3243 100644 --- a/src/js/core/utils.js +++ b/src/js/core/utils.js @@ -24,9 +24,7 @@ export const BOTTOM = new Vector(0, 1); export const LEFT = new Vector(-1, 0); export const ALL_DIRECTIONS = [TOP, RIGHT, BOTTOM, LEFT]; -export const thousand = 1000; -export const million = 1000 * 1000; -export const billion = 1000 * 1000 * 1000; +const bigNumberSuffixes = ["k", "M", "B", "T"]; /** * Returns the build id @@ -435,21 +433,21 @@ export function formatBigNumber(num, divider = ".") { if (num < 1000) { return sign + "" + num; + } else { + let leadingDigits = num; + let suffix = ""; + for (let suffixIndex = 0; suffixIndex < bigNumberSuffixes.length; ++suffixIndex) { + leadingDigits = leadingDigits / 1000; + suffix = bigNumberSuffixes[suffixIndex]; + if (leadingDigits < 1000) { + break; + } + } + // round down to nearest 0.1 + const leadingDigitsRounded = Math_floor(leadingDigits * 10) / 10; + const leadingDigitsNoTrailingDecimal = leadingDigitsRounded.toString().replace(".0", ""); + return sign + leadingDigitsNoTrailingDecimal + suffix; } - if (num > 10000) { - return Math_floor(num / 1000.0) + "k"; - } - - let rest = num; - let out = ""; - - while (rest >= 1000) { - out = (rest % 1000).toString().padStart(3, "0") + (out !== "" ? divider : "") + out; - rest = Math_floor(rest / 1000); - } - - out = rest + divider + out; - return sign + out; } /** @@ -731,14 +729,14 @@ export function checkTimerExpired(now, lastTick, tickRate) { Client A computes the timer and checks T > lastTick + interval. He computes 30 >= 29.90 + 0.1 <=> 30 >= 30.0000 <=> True <=> Tick performed - + However, this is what it looks on client B: - + 33 >= 32.90 + 0.1 <=> 33 >= 32.999999999999998 <=> False <=> No tick performed! - + This means that Client B will only tick at the *next* frame, which means it from now is out of sync by one tick, which means the game will resync further or later and be not able to recover, - since it will run into the same issue over and over. + since it will run into the same issue over and over. */ // The next tick, in our example it would be 30.0000 / 32.99999999998. In order to fix it, we quantize @@ -913,5 +911,5 @@ export function formatItemsPerSecond(speed, double = false) { return speed === 1.0 ? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond : T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace("", "" + round2Digits(speed)) + - (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); } From 4409dbf17f4b5a848a26b8db9f80af7fe565cbc5 Mon Sep 17 00:00:00 2001 From: hexagonhexagon Date: Fri, 29 May 2020 19:33:38 -0400 Subject: [PATCH 07/22] Comply with ESLint. --- src/js/core/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/core/utils.js b/src/js/core/utils.js index b33d3243..0217f673 100644 --- a/src/js/core/utils.js +++ b/src/js/core/utils.js @@ -911,5 +911,5 @@ export function formatItemsPerSecond(speed, double = false) { return speed === 1.0 ? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond : T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace("", "" + round2Digits(speed)) + - (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : ""); } From 2781d531a12cfd40564f4eccf213b4a51f66d592 Mon Sep 17 00:00:00 2001 From: hexagonhexagon Date: Sat, 30 May 2020 14:02:03 -0400 Subject: [PATCH 08/22] Put suffixes in base-en.yaml under the key global.suffix. --- src/js/core/utils.js | 9 ++++----- translations/base-en.yaml | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/js/core/utils.js b/src/js/core/utils.js index 0217f673..e50b71c8 100644 --- a/src/js/core/utils.js +++ b/src/js/core/utils.js @@ -24,7 +24,7 @@ export const BOTTOM = new Vector(0, 1); export const LEFT = new Vector(-1, 0); export const ALL_DIRECTIONS = [TOP, RIGHT, BOTTOM, LEFT]; -const bigNumberSuffixes = ["k", "M", "B", "T"]; +const bigNumberSuffixTranslationKeys = ["thousands", "millions", "billions", "trillions"]; /** * Returns the build id @@ -436,15 +436,14 @@ export function formatBigNumber(num, divider = ".") { } else { let leadingDigits = num; let suffix = ""; - for (let suffixIndex = 0; suffixIndex < bigNumberSuffixes.length; ++suffixIndex) { + for (let suffixIndex = 0; suffixIndex < bigNumberSuffixTranslationKeys.length; ++suffixIndex) { leadingDigits = leadingDigits / 1000; - suffix = bigNumberSuffixes[suffixIndex]; + suffix = T.global.suffix[bigNumberSuffixTranslationKeys[suffixIndex]]; if (leadingDigits < 1000) { break; } } - // round down to nearest 0.1 - const leadingDigitsRounded = Math_floor(leadingDigits * 10) / 10; + const leadingDigitsRounded = round1Digit(leadingDigits); const leadingDigitsNoTrailingDecimal = leadingDigitsRounded.toString().replace(".0", ""); return sign + leadingDigitsNoTrailingDecimal + suffix; } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 9940b0b5..c031cf06 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -26,6 +26,13 @@ global: # How big numbers are rendered, e.g. "10,000" thousandsDivider: "," + # The suffix for large numbers, e.g. 1.3k, 400.2M, etc. + suffix: + thousands: k + millions: M + billions: B + trillions: T + # Shown for infinitely big numbers infinite: inf From 704b6e14b83fa04004beceff0264be28eb1080ce Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Sat, 30 May 2020 20:12:16 +0200 Subject: [PATCH 09/22] Minor fixes, update changelog, add experimental macosx and linux builds --- gulp/standalone.js | 4 ++-- src/css/states/preload.scss | 3 +++ src/js/changelog.js | 5 ++++- src/js/core/config.js | 4 ++-- src/js/game/hud/hud.js | 2 +- src/js/game/hud/parts/blueprint_placer.js | 5 ++++- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/gulp/standalone.js b/gulp/standalone.js index 34001e07..e8a1e9be 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -182,10 +182,10 @@ function gulptasksStandalone($, gulp, buildFolder) { "standalone.package.prod", $.sequence("standalone.prepare", [ "standalone.package.prod.win64", - // "standalone.package.prod.linux64", + "standalone.package.prod.linux64", + "standalone.package.prod.darwin64", // "standalone.package.prod.win32", // "standalone.package.prod.linux32", - // "standalone.package.prod.darwin64" ]) ); } diff --git a/src/css/states/preload.scss b/src/css/states/preload.scss index 68a268e1..9bd23358 100644 --- a/src/css/states/preload.scss +++ b/src/css/states/preload.scss @@ -36,6 +36,9 @@ @include S(padding, 1px, 2px); @include S(margin-right, 3px); } + a { + color: $colorBlueBright; + } } } diff --git a/src/js/changelog.js b/src/js/changelog.js index 4d8844c8..81f2749a 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -3,9 +3,12 @@ export const CHANGELOG = [ version: "1.1.2", date: "unreleased", entries: [ + "The official trailer is now ready! Check it out here!", + "The steam page is now live!", "Allow hovering pinned shapes to enlarge them", + "Allow deselecting blueprints with right click and 'Q'", "Move default key for deleting from 'X' to 'DEL'", - "Show confirmation when deleting > 100 buildings", + "Show confirmation when deleting more than 100 buildings", "Reintroduce 'SPACE' keybinding to center on map", "Improved keybinding hints", "Fixed some keybindings showing as 'undefined'", diff --git a/src/js/core/config.js b/src/js/core/config.js index 5b802de3..05555793 100644 --- a/src/js/core/config.js +++ b/src/js/core/config.js @@ -83,7 +83,7 @@ export const globalConfig = { debug: { /* dev:start */ - fastGameEnter: true, + // fastGameEnter: true, // noArtificialDelays: true, // disableSavegameWrite: true, // showEntityBounds: true, @@ -105,7 +105,7 @@ export const globalConfig = { // testAds: true, // disableMapOverview: true, disableTutorialHints: true, - disableUpgradeNotification: true, + // disableUpgradeNotification: true, // instantBelts: true, // instantProcessors: true, // instantMiners: true, diff --git a/src/js/game/hud/hud.js b/src/js/game/hud/hud.js index b2472a68..e1f1dbbf 100644 --- a/src/js/game/hud/hud.js +++ b/src/js/game/hud/hud.js @@ -48,8 +48,8 @@ export class GameHUD { this.parts = { processingOverlay: new HUDProcessingOverlay(this.root), buildingsToolbar: new HUDBuildingsToolbar(this.root), - buildingPlacer: new HUDBuildingPlacer(this.root), blueprintPlacer: new HUDBlueprintPlacer(this.root), + buildingPlacer: new HUDBuildingPlacer(this.root), unlockNotification: new HUDUnlockNotification(this.root), gameMenu: new HUDGameMenu(this.root), massSelector: new HUDMassSelector(this.root), diff --git a/src/js/game/hud/parts/blueprint_placer.js b/src/js/game/hud/parts/blueprint_placer.js index b3b91a66..173d1809 100644 --- a/src/js/game/hud/parts/blueprint_placer.js +++ b/src/js/game/hud/parts/blueprint_placer.js @@ -1,4 +1,4 @@ -import { DrawParameters } from "../../../core/draw_parameters"; +//www.youtube.com/watch?v=KyorY1uIqiQimport { DrawParameters } from "../../../core/draw_parameters"; import { STOP_PROPAGATION } from "../../../core/signal"; import { TrackedState } from "../../../core/tracked_state"; import { Vector } from "../../../core/vector"; @@ -36,6 +36,9 @@ export class HUDBlueprintPlacer extends BaseHUDPart { .getBinding(KEYMAPPINGS.placement.abortBuildingPlacement) .add(this.abortPlacement, this); keyActionMapper.getBinding(KEYMAPPINGS.placement.rotateWhilePlacing).add(this.rotateBlueprint, this); + keyActionMapper + .getBinding(KEYMAPPINGS.placement.abortBuildingPlacement) + .add(this.abortPlacement, this); this.root.camera.downPreHandler.add(this.onMouseDown, this); this.root.camera.movePreHandler.add(this.onMouseMove, this); From e4a8e72edd85eaa063bbe820ce138cf2dc351fe7 Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Sat, 30 May 2020 20:25:46 +0200 Subject: [PATCH 10/22] Add .itch.toml file --- gulp/.itch.toml | 9 +++++++++ gulp/standalone.js | 35 ++++++++++++++++++++++++----------- src/js/changelog.js | 2 +- 3 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 gulp/.itch.toml diff --git a/gulp/.itch.toml b/gulp/.itch.toml new file mode 100644 index 00000000..2556ac9c --- /dev/null +++ b/gulp/.itch.toml @@ -0,0 +1,9 @@ +[[actions]] +name = "play" +path = "shapezio.exe" +platform = "windows" + +[[actions]] +name = "play" +path = "play.sh" +platform = "linux" diff --git a/gulp/standalone.js b/gulp/standalone.js index e8a1e9be..1c3d3748 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -121,6 +121,8 @@ function gulptasksStandalone($, gulp, buildFolder) { * @param {boolean=} isRelease */ function packageStandalone(platform, arch, cb, isRelease = false) { + const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml")); + packager({ dir: tempDestBuildDir, appCopyright: "Tobias Springer", @@ -150,17 +152,28 @@ function gulptasksStandalone($, gulp, buildFolder) { fs.readFileSync(path.join(__dirname, "..", "LICENSE")) ); - const playablePath = appPath + "_playable"; - fse.copySync(appPath, playablePath); - fs.writeFileSync(path.join(playablePath, "steam_appid.txt"), "1134480"); - fs.writeFileSync( - path.join(playablePath, "play.bat"), - "start shapezio --dev --disable-direct-composition --in-process-gpu\r\n" - ); - fs.writeFileSync( - path.join(playablePath, "play_local.bat"), - "start shapezio --local --dev --disable-direct-composition --in-process-gpu\r\n" - ); + fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile); + + if (platform === "linux" || platform === "darwin") { + fs.writeFileSync( + path.join(appPath, "play.sh"), + "#!/usr/bin/env bash\r\n./shapezio\r\n" + ); + fs.chmodSync(path.join(appPath, "play.sh"), 0o775); + } else if (platform === "win32") { + // Optional: Create a playable copy. Shouldn't be required + // const playablePath = appPath + "_playable"; + // fse.copySync(appPath, playablePath); + // fs.writeFileSync(path.join(playablePath, "steam_appid.txt"), "1134480"); + // fs.writeFileSync( + // path.join(playablePath, "play.bat"), + // "start shapezio --dev --disable-direct-composition --in-process-gpu\r\n" + // ); + // fs.writeFileSync( + // path.join(playablePath, "play_local.bat"), + // "start shapezio --local --dev --disable-direct-composition --in-process-gpu\r\n" + // ); + } }); cb(); diff --git a/src/js/changelog.js b/src/js/changelog.js index 81f2749a..6c058b51 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -1,7 +1,7 @@ export const CHANGELOG = [ { version: "1.1.2", - date: "unreleased", + date: "30.05.2020", entries: [ "The official trailer is now ready! Check it out here!", "The steam page is now live!", From 56080ea25a71e9f98be85c315c9316721b6b9a07 Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Sat, 30 May 2020 20:28:09 +0200 Subject: [PATCH 11/22] Update changelog, again --- package.json | 3 ++- src/js/changelog.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 64bc8ac1..8774e693 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "tslint": "cd src/js && tsc", "lint": "npx eslint src/js", "prettier-all": "prettier --write src/**/*.* && prettier --write gulp/**/*.*", - "publishOnItch": "butler push tmp_standalone_files/shapez.io-standalone-win32-x64 tobspr/shapezio:windows --userversion-file version", + "publishOnItchWindows": "butler push tmp_standalone_files/shapez.io-standalone-win32-x64 tobspr/shapezio:windows --userversion-file version", + "publishOnItchLinux": "butler push tmp_standalone_files/shapez.io-standalone-linux-x64 tobspr/shapezio:linux-experimental --userversion-file version", "publishOnSteam": "cd gulp/steampipe && ./upload.bat", "publishStandalone": "yarn publishOnItch && yarn publishOnSteam", "publishWeb": "cd gulp && yarn main.deploy.prod", diff --git a/src/js/changelog.js b/src/js/changelog.js index 6c058b51..452cf7a4 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -5,6 +5,7 @@ export const CHANGELOG = [ entries: [ "The official trailer is now ready! Check it out here!", "The steam page is now live!", + "Experimental linux builds are now available! Please give me feedback on them in the discord", "Allow hovering pinned shapes to enlarge them", "Allow deselecting blueprints with right click and 'Q'", "Move default key for deleting from 'X' to 'DEL'", From 3f385b01e0c62be59711213741cfa9d44d74c5b6 Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Sun, 31 May 2020 08:15:07 +0200 Subject: [PATCH 12/22] Update readme and standalone build process --- README.md | 14 ++++++++++---- gulp/standalone.js | 5 +---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 94e3b3f3..a451473a 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,19 @@ # shapez.io shapez.io Logo -shapez.io Screenshot This is the source code for shapez.io, an open source base building game inspired by Factorio. - Your goal is to produce shapes by cutting, rotating, merging and painting parts of shapes. -## Playing +## Planned features & Goals -You can already play it [here](https://shapez.io). +## Links + +- [Trello Board & Roadmap](https://trello.com/b/ISQncpJP/shapezio) +- [Free web version](https://shapez.io) +- [itch.io Page](https://tobspr.itch.io/shapezio) +- [Steam Page](https://steam.shapez.io) +- [Official Discord](https://discord.com/invite/HN7EVzV) <- _Highly recommended to join!_ ## Building @@ -46,3 +50,5 @@ This project is based on ES5. Some ES2015 features are used but most of them are For most assets I use Adobe Photoshop, you can find them in `assets/`. You will need a Texture Packer license in order to regenerate the atlas. If you don't have one but want to contribute assets, let me know and I might compile it for you. I'm currently switching to an open source solution but I can't give an estimate when thats done. + +shapez.io Screenshot diff --git a/gulp/standalone.js b/gulp/standalone.js index 1c3d3748..6c5995bd 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -155,10 +155,7 @@ function gulptasksStandalone($, gulp, buildFolder) { fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile); if (platform === "linux" || platform === "darwin") { - fs.writeFileSync( - path.join(appPath, "play.sh"), - "#!/usr/bin/env bash\r\n./shapezio\r\n" - ); + fs.writeFileSync(path.join(appPath, "play.sh"), "#!/usr/bin/env bash\n./shapezio\n"); fs.chmodSync(path.join(appPath, "play.sh"), 0o775); } else if (platform === "win32") { // Optional: Create a playable copy. Shouldn't be required From 72feaa89e109d2dd912d19f07148ec8d68359d1c Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Sun, 31 May 2020 08:34:28 +0200 Subject: [PATCH 13/22] Update readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index a451473a..f5c9ec84 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,6 @@ This is the source code for shapez.io, an open source base building game inspired by Factorio. Your goal is to produce shapes by cutting, rotating, merging and painting parts of shapes. -## Planned features & Goals - -## Links - - [Trello Board & Roadmap](https://trello.com/b/ISQncpJP/shapezio) - [Free web version](https://shapez.io) - [itch.io Page](https://tobspr.itch.io/shapezio) From 0d342ee4172244143b44b6a97be32d7cdb47fcff Mon Sep 17 00:00:00 2001 From: Dimava Date: Mon, 1 Jun 2020 02:36:41 +0300 Subject: [PATCH 14/22] move KeyMouse listeners to correct location --- src/js/core/input_distributor.js | 13 +++++++++---- src/js/game/camera.js | 2 -- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/js/core/input_distributor.js b/src/js/core/input_distributor.js index e46a3076..03ad8e0c 100644 --- a/src/js/core/input_distributor.js +++ b/src/js/core/input_distributor.js @@ -141,8 +141,13 @@ export class InputDistributor { bindToEvents() { window.addEventListener("popstate", this.handleBackButton.bind(this), false); document.addEventListener("backbutton", this.handleBackButton.bind(this), false); - window.addEventListener("keydown", this.handleKeydown.bind(this)); - window.addEventListener("keyup", this.handleKeyup.bind(this)); + + window.addEventListener("keydown", this.handleKeyMouseDown.bind(this)); + window.addEventListener("keyup", this.handleKeyMouseUp.bind(this)); + + window.addEventListener("mousedown", this.handleKeyMouseDown.bind(this)); + window.addEventListener("mouseup", this.handleKeyMouseUp.bind(this)); + window.addEventListener("blur", this.handleBlur.bind(this)); } @@ -184,7 +189,7 @@ export class InputDistributor { /** * @param {KeyboardEvent | MouseEvent} event */ - handleKeydown(event) { + handleKeyMouseDown(event) { const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode; if ( keyCode === 4 || // MB4 @@ -224,7 +229,7 @@ export class InputDistributor { /** * @param {KeyboardEvent | MouseEvent} event */ - handleKeyup(event) { + handleKeyMouseUp(event) { const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode; this.keysDown.delete(keyCode); diff --git a/src/js/game/camera.js b/src/js/game/camera.js index da2ab3f0..2e558216 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -443,7 +443,6 @@ export class Camera extends BasicSerializableObject { } else if (event.button === 2) { this.downPreHandler.dispatch(new Vector(event.clientX, event.clientY), enumMouseButton.right); } - this.root.app.inputMgr.handleKeydown(event); return false; } @@ -485,7 +484,6 @@ export class Camera extends BasicSerializableObject { if (!this.checkPreventDoubleMouse()) { return; } - this.root.app.inputMgr.handleKeyup(event); this.combinedSingleTouchStopHandler(event.clientX, event.clientY); return false; From 54e11e6baf9a4f804e4f729d02a413ff8c26ff21 Mon Sep 17 00:00:00 2001 From: Dimava Date: Mon, 1 Jun 2020 02:55:54 +0300 Subject: [PATCH 15/22] change onclick to addEventListener --- src/js/states/keybindings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index 28bb05d5..91f38b23 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -137,7 +137,7 @@ export class KeybindingsState extends TextualGameState { dialog.inputReciever.backButton.add(() => {}); this.dialogs.internalShowDialog(dialog); - dialog.element.onmousedown = clickListener; + dialog.element.addEventListener("mousedown", clickListener); this.app.sound.playUiSound(SOUNDS.dialogOk); } From e900d01026a9da9adae99f58f29eee06036af981 Mon Sep 17 00:00:00 2001 From: Dimava Date: Mon, 1 Jun 2020 02:58:01 +0300 Subject: [PATCH 16/22] remove console.log --- src/js/states/keybindings.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index 91f38b23..f9b25359 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -122,7 +122,6 @@ export class KeybindingsState extends TextualGameState { }); const clickListener = event => { - console.log(event); if (event.target.tagName == "BUTTON") { return; } From 6c349479cffb33829d6ddcac6117eed9794a93b8 Mon Sep 17 00:00:00 2001 From: Dimava Date: Mon, 1 Jun 2020 12:45:59 +0300 Subject: [PATCH 17/22] fix belt cloning bug --- src/js/game/components/item_ejector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/game/components/item_ejector.js b/src/js/game/components/item_ejector.js index d5881a7d..5a40870b 100644 --- a/src/js/game/components/item_ejector.js +++ b/src/js/game/components/item_ejector.js @@ -44,7 +44,7 @@ export class ItemEjectorComponent extends Component { return new ItemEjectorComponent({ slots: slotsCopy, - instantEject: false, + instantEject: this.instantEject, }); } From 23db5b117ed06aecf5579958bc24757544a0f75b Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Mon, 1 Jun 2020 12:49:04 +0200 Subject: [PATCH 18/22] Migrate old savegames --- src/html/index.html | 3 ++ src/js/changelog.js | 8 ++++ src/js/platform/browser/google_analytics.js | 5 --- src/js/savegame/savegame.js | 17 +++++++-- .../savegame/savegame_interface_registry.js | 6 ++- src/js/savegame/schemas/1002.js | 37 +++++++++++++++++++ src/js/savegame/schemas/1002.json | 5 +++ version | 2 +- 8 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 src/js/savegame/schemas/1002.js create mode 100644 src/js/savegame/schemas/1002.json diff --git a/src/html/index.html b/src/html/index.html index b1d89377..243455ea 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -40,6 +40,9 @@ + + + diff --git a/src/js/changelog.js b/src/js/changelog.js index 452cf7a4..dd219290 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -1,4 +1,12 @@ export const CHANGELOG = [ + { + version: "1.1.3", + date: "unreleased", + entries: [ + "Allow binding mouse buttons to actions (by Dimava)", + "Fix belts being too slow when copied via blueprint (by Dimava)", + ], + }, { version: "1.1.2", date: "30.05.2020", diff --git a/src/js/platform/browser/google_analytics.js b/src/js/platform/browser/google_analytics.js index 55de95cc..3c54fbbd 100644 --- a/src/js/platform/browser/google_analytics.js +++ b/src/js/platform/browser/google_analytics.js @@ -66,11 +66,6 @@ export class GoogleAnalyticsImpl extends AnalyticsInterface { } trackUiClick(elementName) { - // Only track a fraction of clicks to not annoy google analytics - if (Math_random() < 0.9) { - return; - } - const stateKey = this.app.stateMgr.getCurrentState().key; const fullSelector = stateKey + ">" + elementName; diff --git a/src/js/savegame/savegame.js b/src/js/savegame/savegame.js index a78200f9..7d59a056 100644 --- a/src/js/savegame/savegame.js +++ b/src/js/savegame/savegame.js @@ -10,8 +10,9 @@ import { BaseSavegameInterface } from "./savegame_interface"; import { createLogger } from "../core/logging"; import { globalConfig } from "../core/config"; import { SavegameInterface_V1000 } from "./schemas/1000"; -import { getSavegameInterface } from "./savegame_interface_registry"; +import { getSavegameInterface, savegameInterfaces } from "./savegame_interface_registry"; import { SavegameInterface_V1001 } from "./schemas/1001"; +import { SavegameInterface_V1002 } from "./schemas/1002"; const logger = createLogger("savegame"); @@ -30,6 +31,11 @@ export class Savegame extends ReadWriteProxy { /** @type {import("./savegame_typedefs").SavegameData} */ this.currentData = this.getDefaultData(); + + assert( + savegameInterfaces[Savegame.getCurrentVersion()], + "Savegame interface not defined: " + Savegame.getCurrentVersion() + ); } //////// RW Proxy Impl ////////// @@ -38,14 +44,14 @@ export class Savegame extends ReadWriteProxy { * @returns {number} */ static getCurrentVersion() { - return 1001; + return 1002; } /** * @returns {typeof BaseSavegameInterface} */ static getReaderClass() { - return SavegameInterface_V1001; + return savegameInterfaces[Savegame.getCurrentVersion()]; } /** @@ -82,6 +88,11 @@ export class Savegame extends ReadWriteProxy { data.version = 1001; } + if (data.version === 1001) { + SavegameInterface_V1002.migrate1001to1002(data); + data.version = 1002; + } + return ExplainedResult.good(); } diff --git a/src/js/savegame/savegame_interface_registry.js b/src/js/savegame/savegame_interface_registry.js index 2560b23e..7c6db250 100644 --- a/src/js/savegame/savegame_interface_registry.js +++ b/src/js/savegame/savegame_interface_registry.js @@ -2,11 +2,13 @@ import { BaseSavegameInterface } from "./savegame_interface"; import { SavegameInterface_V1000 } from "./schemas/1000"; import { createLogger } from "../core/logging"; import { SavegameInterface_V1001 } from "./schemas/1001"; +import { SavegameInterface_V1002 } from "./schemas/1002"; /** @type {Object.} */ -const interfaces = { +export const savegameInterfaces = { 1000: SavegameInterface_V1000, 1001: SavegameInterface_V1001, + 1002: SavegameInterface_V1002, }; const logger = createLogger("savegame_interface_registry"); @@ -27,7 +29,7 @@ export function getSavegameInterface(savegame) { return null; } - const interfaceClass = interfaces[version]; + const interfaceClass = savegameInterfaces[version]; if (!interfaceClass) { logger.warn("Version", version, "has no implemented interface!"); return null; diff --git a/src/js/savegame/schemas/1002.js b/src/js/savegame/schemas/1002.js new file mode 100644 index 00000000..92dadfc1 --- /dev/null +++ b/src/js/savegame/schemas/1002.js @@ -0,0 +1,37 @@ +import { createLogger } from "../../core/logging.js"; +import { T } from "../../translations.js"; +import { SavegameInterface_V1001 } from "./1001.js"; + +const schema = require("./1002.json"); +const logger = createLogger("savegame_interface/1002"); + +export class SavegameInterface_V1002 extends SavegameInterface_V1001 { + getVersion() { + return 1002; + } + + getSchemaUncached() { + return schema; + } + + /** + * @param {import("../savegame_typedefs.js").SavegameData} data + */ + static migrate1001to1002(data) { + logger.log("Migrating 1001 to 1002"); + const dump = data.dump; + if (!dump) { + return true; + } + + const entities = dump.entities; + for (let i = 0; i < entities.length; ++i) { + const entity = entities[i]; + const beltComp = entity.components.Belt; + const ejectorComp = entity.components.ItemEjector; + if (beltComp && ejectorComp) { + ejectorComp.instantEject = true; + } + } + } +} diff --git a/src/js/savegame/schemas/1002.json b/src/js/savegame/schemas/1002.json new file mode 100644 index 00000000..6682f615 --- /dev/null +++ b/src/js/savegame/schemas/1002.json @@ -0,0 +1,5 @@ +{ + "type": "object", + "required": [], + "additionalProperties": true +} diff --git a/version b/version index 8428158d..9c1218c2 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.1.2 \ No newline at end of file +1.1.3 \ No newline at end of file From b963b48df52ff6bc9d352d0d84d133909147bff5 Mon Sep 17 00:00:00 2001 From: tobspr <> Date: Mon, 1 Jun 2020 13:02:43 +0200 Subject: [PATCH 19/22] Fix keybindings not being properly assigned --- src/js/states/keybindings.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/js/states/keybindings.js b/src/js/states/keybindings.js index f9b25359..bc2b4a18 100644 --- a/src/js/states/keybindings.js +++ b/src/js/states/keybindings.js @@ -105,6 +105,10 @@ export class KeybindingsState extends TextualGameState { event.preventDefault(); } + if (event.target && event.target.tagName === "BUTTON" && keyCode === 1) { + return; + } + if ( // Enter keyCode === 13 || @@ -121,22 +125,8 @@ export class KeybindingsState extends TextualGameState { this.updateKeybindings(); }); - const clickListener = event => { - if (event.target.tagName == "BUTTON") { - return; - } - event.preventDefault(); - const keyCode = event.button + 1; - - this.app.settings.updateKeybindingOverride(id, keyCode); - - this.dialogs.closeDialog(dialog); - this.updateKeybindings(); - }; - dialog.inputReciever.backButton.add(() => {}); this.dialogs.internalShowDialog(dialog); - dialog.element.addEventListener("mousedown", clickListener); this.app.sound.playUiSound(SOUNDS.dialogOk); } From 8c85018352246771694085ea7fc372e3f63a2889 Mon Sep 17 00:00:00 2001 From: tobspr Date: Mon, 1 Jun 2020 13:05:15 +0200 Subject: [PATCH 20/22] Added setting to configure zoom / mouse wheel / touchpad sensitivity --- src/js/changelog.js | 1 + src/js/core/config.js | 2 +- src/js/game/camera.js | 2 +- src/js/profile/application_settings.js | 63 +++++++++++++++++++++++--- translations/base-en.yaml | 19 +++++++- 5 files changed, 77 insertions(+), 10 deletions(-) diff --git a/src/js/changelog.js b/src/js/changelog.js index dd219290..215e7dcf 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -3,6 +3,7 @@ export const CHANGELOG = [ version: "1.1.3", date: "unreleased", entries: [ + "Added setting to configure zoom / mouse wheel / touchpad sensitivity", "Allow binding mouse buttons to actions (by Dimava)", "Fix belts being too slow when copied via blueprint (by Dimava)", ], diff --git a/src/js/core/config.js b/src/js/core/config.js index 05555793..c84dee3a 100644 --- a/src/js/core/config.js +++ b/src/js/core/config.js @@ -105,7 +105,7 @@ export const globalConfig = { // testAds: true, // disableMapOverview: true, disableTutorialHints: true, - // disableUpgradeNotification: true, + disableUpgradeNotification: true, // instantBelts: true, // instantProcessors: true, // instantMiners: true, diff --git a/src/js/game/camera.js b/src/js/game/camera.js index f4441ad7..1a389cad 100644 --- a/src/js/game/camera.js +++ b/src/js/game/camera.js @@ -503,7 +503,7 @@ export class Camera extends BasicSerializableObject { // event.stopPropagation(); } - const delta = Math.sign(event.deltaY) * -0.15; + const delta = Math.sign(event.deltaY) * -0.15 * this.root.app.settings.getScrollWheelSensitivity(); assert(Number.isFinite(delta), "Got invalid delta in mouse wheel event: " + event.deltaY); assert(Number.isFinite(this.zoomLevel), "Got invalid zoom level *before* wheel: " + this.zoomLevel); this.zoomLevel *= 1 + delta; diff --git a/src/js/profile/application_settings.js b/src/js/profile/application_settings.js index 96cbed2f..ff0051f1 100644 --- a/src/js/profile/application_settings.js +++ b/src/js/profile/application_settings.js @@ -8,6 +8,7 @@ import { createLogger } from "../core/logging"; import { ExplainedResult } from "../core/explained_result"; import { THEMES, THEME, applyGameTheme } from "../game/theme"; import { IS_DEMO } from "../core/config"; +import { T } from "../translations"; const logger = createLogger("application_settings"); @@ -18,27 +19,45 @@ export const uiScales = [ { id: "super_small", size: 0.6, - label: "Super small", }, { id: "small", size: 0.8, - label: "Small", }, { id: "regular", size: 1, - label: "Regular", }, { id: "large", size: 1.2, - label: "Large", }, { id: "huge", size: 1.4, - label: "Huge", + }, +]; + +export const scrollWheelSensitivities = [ + { + id: "super_slow", + scale: 0.25, + }, + { + id: "slow", + scale: 0.5, + }, + { + id: "regular", + scale: 1, + }, + { + id: "fast", + scale: 2, + }, + { + id: "super_fast", + scale: 4, }, ]; @@ -47,7 +66,7 @@ export const allApplicationSettings = [ new EnumSetting("uiScale", { options: uiScales.sort((a, b) => a.size - b.size), valueGetter: scale => scale.id, - textGetter: scale => scale.label, + textGetter: scale => T.settings.labels.uiScale.scales[scale.id], category: categoryApp, restartRequired: false, changeCb: @@ -56,6 +75,7 @@ export const allApplicationSettings = [ */ (app, id) => app.updateAfterUiScaleChanged(), }), + new BoolSetting( "fullscreen", categoryApp, @@ -86,6 +106,18 @@ export const allApplicationSettings = [ */ (app, value) => app.sound.setMusicMuted(value) ), + new EnumSetting("scrollWheelSensitivity", { + options: scrollWheelSensitivities.sort((a, b) => a.scale - b.scale), + valueGetter: scale => scale.id, + textGetter: scale => T.settings.labels.scrollWheelSensitivity.sensitivity[scale.id], + category: categoryApp, + restartRequired: false, + changeCb: + /** + * @param {Application} app + */ + (app, id) => app.updateAfterUiScaleChanged(), + }), // GAME new EnumSetting("theme", { @@ -132,6 +164,7 @@ class SettingsStorage { this.musicMuted = false; this.theme = "light"; this.refreshRate = "60"; + this.scrollWheelSensitivity = "regular"; this.alwaysMultiplace = false; this.offerHints = true; @@ -207,6 +240,17 @@ export class ApplicationSettings extends ReadWriteProxy { return 1; } + getScrollWheelSensitivity() { + const id = this.getAllSettings().scrollWheelSensitivity; + for (let i = 0; i < scrollWheelSensitivities.length; ++i) { + if (scrollWheelSensitivities[i].id === id) { + return scrollWheelSensitivities[i].scale; + } + } + logger.error("Unknown scroll wheel sensitivity id:", id); + return 1; + } + getIsFullScreen() { return this.getAllSettings().fullscreen; } @@ -293,7 +337,7 @@ export class ApplicationSettings extends ReadWriteProxy { } getCurrentVersion() { - return 7; + return 8; } /** @param {{settings: SettingsStorage, version: number}} data */ @@ -315,6 +359,11 @@ export class ApplicationSettings extends ReadWriteProxy { data.version = 7; } + if (data.version < 8) { + data.settings.scrollWheelSensitivity = "regular"; + data.version = 8; + } + return ExplainedResult.good(); } } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 9940b0b5..e861b773 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -127,7 +127,7 @@ dialogs: editKeybinding: title: Change Keybinding - desc: Press the key you want to assign, or escape to cancel. + desc: Press the key or mouse button you want to assign, or escape to cancel. resetKeybindingsConfirmation: title: Reset keybindings @@ -511,6 +511,23 @@ settings: title: Interface scale description: >- Changes the size of the user interface. The interface will still scale based on your device resolution, but this setting controls the amount of scale. + scales: + super_small: Super small + small: Small + regular: Regular + large: Large + huge: Huge + + scrollWheelSensitivity: + title: Zoom sensitivity + description: >- + Changes how sensitive the zoom is (Either mouse wheel or trackpad). + sensitivity: + super_slow: Super slow + slow: Slow + regular: Regular + fast: Fast + super_fast: Super fast fullscreen: title: Fullscreen From 922f8f47d77e69a4fc75cd4bd8484b9a5fdcdd50 Mon Sep 17 00:00:00 2001 From: tobspr Date: Mon, 1 Jun 2020 13:18:44 +0200 Subject: [PATCH 21/22] Increase readability of certain HUD elements --- src/css/ingame_hud/buildings_toolbar.scss | 6 +++++- src/css/ingame_hud/keybindings_overlay.scss | 15 +++++++++++---- src/css/ingame_hud/pinned_shapes.scss | 7 +++---- src/css/ingame_hud/waypoints.scss | 4 ++-- src/js/changelog.js | 3 ++- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/css/ingame_hud/buildings_toolbar.scss b/src/css/ingame_hud/buildings_toolbar.scss index 740e1f58..13da9f99 100644 --- a/src/css/ingame_hud/buildings_toolbar.scss +++ b/src/css/ingame_hud/buildings_toolbar.scss @@ -11,7 +11,11 @@ border-bottom-width: 0; transition: transform 0.12s ease-in-out; - background: rgba(mix(#ddd, $colorBlueBright, 80%), 0.69); + background: rgba(mix(#ddd, $colorBlueBright, 90%), 0.75); + + @include DarkThemeOverride { + background: #222428; + } &:not(.visible) { transform: translateX(-50%) translateY(#{D(100px)}); diff --git a/src/css/ingame_hud/keybindings_overlay.scss b/src/css/ingame_hud/keybindings_overlay.scss index 1737e7b1..5a238f81 100644 --- a/src/css/ingame_hud/keybindings_overlay.scss +++ b/src/css/ingame_hud/keybindings_overlay.scss @@ -6,8 +6,12 @@ display: flex; flex-direction: column; align-items: flex-start; - color: #fff; - text-shadow: #{D(1px)} #{D(1px)} 0 rgba(0, 10, 20, 0.1); + color: #333438; + // text-shadow: #{D(1px)} #{D(1px)} 0 rgba(0, 10, 20, 0.1); + + @include DarkThemeOverride { + color: #fff; + } > .binding { display: inline-grid; @@ -42,10 +46,13 @@ } label { - color: $accentColorDark; + color: #333438; @include SuperSmallText; text-transform: uppercase; - color: #fff; + // color: #fff; + @include DarkThemeOverride { + color: #fff; + } @include S(margin-left, 5px); } diff --git a/src/css/ingame_hud/pinned_shapes.scss b/src/css/ingame_hud/pinned_shapes.scss index afedd6a5..1c944e35 100644 --- a/src/css/ingame_hud/pinned_shapes.scss +++ b/src/css/ingame_hud/pinned_shapes.scss @@ -16,8 +16,8 @@ grid-template-columns: auto 1fr; grid-template-rows: 1fr 1fr; @include S(margin-bottom, 4px); - color: #fff; - text-shadow: #{D(1px)} #{D(1px)} 0 rgba(0, 10, 20, 0.2); + color: #333438; + // text-shadow: #{D(1px)} #{D(1px)} 0 rgba(0, 10, 20, 0.2); &.unpinable { > canvas { @@ -59,7 +59,7 @@ > .goalLabel { @include S(font-size, 7px); - opacity: 0.5; + opacity: 0.9; align-self: start; justify-self: start; font-weight: normal; @@ -81,7 +81,6 @@ display: inline-block; @include S(width, 8px); @include S(height, 8px); - opacity: 0.8; @include S(top, 4px); @include S(left, -7px); background: uiResource("icons/current_goal_marker.png") center center / contain no-repeat; diff --git a/src/css/ingame_hud/waypoints.scss b/src/css/ingame_hud/waypoints.scss index fbb430fd..6517bbcf 100644 --- a/src/css/ingame_hud/waypoints.scss +++ b/src/css/ingame_hud/waypoints.scss @@ -38,13 +38,13 @@ @include SuperSmallText; pointer-events: all; cursor: pointer; - color: #000; + color: #333438; @include S(padding-left, 11px); display: grid; grid-template-columns: 1fr auto; align-items: center; background: uiResource("icons/waypoint.png") left 50% / #{D(8px)} no-repeat; - opacity: 0.5; + opacity: 0.7; @include S(margin-bottom, 1px); font-weight: bold; &:hover { diff --git a/src/js/changelog.js b/src/js/changelog.js index 215e7dcf..d2dc7bb2 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -4,8 +4,9 @@ export const CHANGELOG = [ date: "unreleased", entries: [ "Added setting to configure zoom / mouse wheel / touchpad sensitivity", - "Allow binding mouse buttons to actions (by Dimava)", "Fix belts being too slow when copied via blueprint (by Dimava)", + "Allow binding mouse buttons to actions (by Dimava)", + "Increase readability of certain HUD elements", ], }, { From d09a593f811bef81493d9afdbf3a21a42dba84d9 Mon Sep 17 00:00:00 2001 From: tobspr Date: Mon, 1 Jun 2020 19:28:13 +0200 Subject: [PATCH 22/22] 1.1.3 changelog --- src/js/changelog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/changelog.js b/src/js/changelog.js index d2dc7bb2..0559801f 100644 --- a/src/js/changelog.js +++ b/src/js/changelog.js @@ -1,7 +1,7 @@ export const CHANGELOG = [ { version: "1.1.3", - date: "unreleased", + date: "01.06.2020", entries: [ "Added setting to configure zoom / mouse wheel / touchpad sensitivity", "Fix belts being too slow when copied via blueprint (by Dimava)",