From e85728b73d6c1ebdb902cf733ecb8730cef51da5 Mon Sep 17 00:00:00 2001 From: tobspr Date: Thu, 28 May 2020 20:36:53 +0200 Subject: [PATCH] Further waypoint improvements --- res/ui/icons/waypoint.png | Bin 0 -> 691 bytes src/css/ingame_hud/building_placer.scss | 1 + src/css/ingame_hud/waypoints.scss | 41 +++++++++- src/css/main.scss | 3 +- src/js/changelog.js | 2 + src/js/game/hud/base_hud_part.js | 9 ++- src/js/game/hud/parts/waypoints.js | 100 +++++++++++++++++------- src/js/game/upgrades.js | 8 +- src/js/platform/wrapper.js | 2 +- translations/base-en.yaml | 2 +- 10 files changed, 131 insertions(+), 37 deletions(-) create mode 100644 res/ui/icons/waypoint.png diff --git a/res/ui/icons/waypoint.png b/res/ui/icons/waypoint.png new file mode 100644 index 0000000000000000000000000000000000000000..068d57cc7dd4cf1d7aa7b6f8a94d1215fe0dd6d4 GIT binary patch literal 691 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4i*LmhMUEk>KPaqSkfJR9T^xl_H+M9WCckk zdj$D1FjT2AFf_CO=u<5X=vX$A%c_7YEDSN12YGD3U?CfEMOGcYhVdb&7yu(MuEA9$HS`#0vx@gAtNTVu% zQz>)Gv=EPLp1=Ld%gSDFpFXqp{_~kP&+@#ue3~n>>&l8im9s{+6@KcoLpIEs$K`3Y z_d)ZW8xQtBpS40-Zt07T=!iSQW)B(H_3UVMombYmMYE|?Y)a*{+D$*E_PYO2SR8Nf z;<@I_DWAPU%XPF=o2m{@+H_TN>9l~X?y7^089TRx7BAX$z2dF7u5wb&|5Mzx%SFC) zZ#=IyA)oCFlV#scmSn!UO8uw$yR^4PF8#JZe2$iHst{9saF#l+$Gla>%Z{#@o%|`~ zgJANO%$3D|`IKsQ%B663&-&AuRc6Z>WTEDBRrJ3}{L9?%gJQ>6D$O40w-lV56}aJ5 zn{z|7`yPk(-3-rUS&QQe8hXUeXRe#!d~9oz=6Z_*6M5}(Slbo%iT-JSc#UO35R3KN zM;DG)%dWSImk*v)dhl3%!HY*HUw${T.ingame.waypoints.waypoints} @@ -36,6 +43,8 @@ export class HUDWaypoints extends BaseHUDPart { } this.waypointSprite = Loader.getSprite("sprites/misc/waypoint.png"); + + this.waypointsListElement = makeDiv(parent, "ingame_HUD_Waypoints", [], "Waypoints"); } serialize() { @@ -49,15 +58,48 @@ export class HUDWaypoints extends BaseHUDPart { return "Invalid waypoints data"; } this.waypoints = data.waypoints; + this.rerenderWaypointList(); + } + + rerenderWaypointList() { + removeAllChildren(this.waypointsListElement); + this.cleanupClickDetectors(); + + for (let i = 0; i < this.waypoints.length; ++i) { + const waypoint = this.waypoints[i]; + + const element = makeDiv(this.waypointsListElement, null, ["waypoint"]); + element.innerText = waypoint.label; + + if (waypoint.deletable) { + const deleteButton = makeDiv(element, null, ["deleteButton"]); + this.trackClicks(deleteButton, () => this.deleteWaypoint(waypoint)); + } + + this.trackClicks(element, () => this.moveToWaypoint(waypoint), { + targetOnly: true, + }); + } + } + + /** + * @param {Waypoint} waypoint + */ + moveToWaypoint(waypoint) { + this.root.camera.setDesiredCenter(new Vector(waypoint.center.x, waypoint.center.y)); + this.root.camera.setDesiredZoom(waypoint.zoomLevel); + } + + /** + * @param {Waypoint} waypoint + */ + deleteWaypoint(waypoint) { + arrayDeleteValue(this.waypoints, waypoint); + this.rerenderWaypointList(); } initialize() { - /** @type {Array<{ - * label: string, - * center: { x: number, y: number }, - * zoomLevel: number, - * deletable: boolean - * }>} + /** @type {Array} */ this.waypoints = [ { @@ -74,7 +116,7 @@ export class HUDWaypoints extends BaseHUDPart { })[1]; this.root.camera.downPreHandler.add(this.onMouseDown, this); - this.domAttach = new DynamicDomAttach(this.root, this.element); + this.domAttach = new DynamicDomAttach(this.root, this.hintElement); this.root.keyMapper.getBinding(KEYMAPPINGS.ingame.createMarker).add(this.requestCreateMarker, this); @@ -82,7 +124,6 @@ export class HUDWaypoints extends BaseHUDPart { } /** - * * @param {Vector=} worldPos Override the world pos, otherwise it is the camera position */ requestCreateMarker(worldPos = null) { @@ -116,10 +157,12 @@ export class HUDWaypoints extends BaseHUDPart { zoomLevel: Math_max(this.root.camera.zoomLevel, globalConfig.mapChunkOverviewMinZoom + 0.05), deletable: true, }); + this.waypoints.sort((a, b) => a.label.padStart(20, "0").localeCompare(b.label.padStart(20, "0"))); this.root.hud.signals.notification.dispatch( T.ingame.waypoints.creationSuccessNotification, enumNotificationType.success ); + this.rerenderWaypointList(); }); } @@ -168,12 +211,11 @@ export class HUDWaypoints extends BaseHUDPart { if (waypoint) { if (button === enumMouseButton.left) { this.root.soundProxy.playUiClick(); - this.root.camera.setDesiredCenter(new Vector(waypoint.center.x, waypoint.center.y)); - this.root.camera.setDesiredZoom(waypoint.zoomLevel); + this.moveToWaypoint(waypoint); } else if (button === enumMouseButton.right) { if (waypoint.deletable) { this.root.soundProxy.playUiClick(); - arrayDeleteValue(this.waypoints, waypoint); + this.deleteWaypoint(waypoint); } else { this.root.soundProxy.playUiError(); } @@ -183,9 +225,11 @@ export class HUDWaypoints extends BaseHUDPart { } else { // Allow right click to create a marker if (button === enumMouseButton.right) { - const worldPos = this.root.camera.screenToWorld(pos); - this.requestCreateMarker(worldPos); - return STOP_PROPAGATION; + if (this.root.camera.getIsMapOverlayActive()) { + const worldPos = this.root.camera.screenToWorld(pos); + this.requestCreateMarker(worldPos); + return STOP_PROPAGATION; + } } } } diff --git a/src/js/game/upgrades.js b/src/js/game/upgrades.js index b766c149..500a2afe 100644 --- a/src/js/game/upgrades.js +++ b/src/js/game/upgrades.js @@ -98,12 +98,12 @@ export const UPGRADES = { painting: { tiers: [ { - required: [{ shape: "WrWrWrWr", amount: 500 }], - improvement: 1, + required: [{ shape: "RbRb----", amount: 1500 }], + improvement: 2, }, { - required: [{ shape: "RbRb----", amount: 4000 }], - improvement: 2, + required: [{ shape: "WrWrWrWr", amount: 5000 }], + improvement: 1, }, { required: [{ shape: "RpRpRpRp:CwCwCwCw", amount: 30000 }], diff --git a/src/js/platform/wrapper.js b/src/js/platform/wrapper.js index 5754a8a2..9fee5b3a 100644 --- a/src/js/platform/wrapper.js +++ b/src/js/platform/wrapper.js @@ -66,7 +66,7 @@ export class PlatformWrapperInterface { * @returns {number} */ getMinimumZoom() { - return 0.1 * this.getScreenScale(); + return 0.2 * this.getScreenScale(); } /** diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 91a90c2f..e293516f 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -61,8 +61,8 @@ demoBanners: intro: >- If you enjoy this game, please consider buying the full version! advantages: - - No advertisements - Unlimited savegames + - Waypoints - Dark mode & more - >- Allow me to further develop shapez.io ❤️