From d7d15026d8168ff871c91fa2ff866c5e80dd5d64 Mon Sep 17 00:00:00 2001 From: David Camp Date: Thu, 7 Aug 2025 19:51:40 -0700 Subject: [PATCH 1/4] Add GPS mode toggle and partial implementation --- index.js | 13 ++++++++++++- legend.js | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 990f135..80bb024 100644 --- a/index.js +++ b/index.js @@ -497,9 +497,20 @@ function redrawDynamics(){ for(const marker of MapData.dynamicMarkers){ curSprite = null; marker.visible = false; - if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue; let markerX = MapData.view.convertX(marker.position.x); let markerY = MapData.view.convertY(marker.position.z); + + // Placing this here means the map should always snap to the player if the toggle is on. + // Placing it after culling means that if the user fast travels the map won't snap to them until manually scrolled to near their position. + if(MapData.layers.gps && marker.type === 'player') { + //This works fine + MapData.view.x = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; + //This does not + // MapData.view.y = -marker.position.z * MapData.view.scale; + MapData.view.dirty = true; + } + + if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue; if(markerX > mapCanvas.width + Config.viewCullMargin || markerX < -Config.viewCullMargin || markerY > mapCanvas.height + Config.viewCullMargin || markerY < -Config.viewCullMargin) continue; // View Culling switch(marker.type){ case 'player': diff --git a/legend.js b/legend.js index bd83411..cf1c0dc 100644 --- a/legend.js +++ b/legend.js @@ -256,7 +256,20 @@ let settingEntries = [ func: state =>{ MapData.layers.player = state; MapData.view.dynDirty = true; - } + }, + children: [ + { + label: 'Follow Player', + tooltip: 'Keep View centered on player', + id: 'toggle_gps', + saveState: true, + state: true, + func: state =>{ + MapData.layers.gps = state; + MapData.view.dynDirty = true; + } + } + ] }, { label: 'Train Cars', From 2d69836887920dae8172d80bf958e5790faa31d5 Mon Sep 17 00:00:00 2001 From: David Camp Date: Thu, 7 Aug 2025 21:05:35 -0700 Subject: [PATCH 2/4] reduce overhead by not spamming updates when stationary --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 80bb024..671b52a 100644 --- a/index.js +++ b/index.js @@ -504,10 +504,14 @@ function redrawDynamics(){ // Placing it after culling means that if the user fast travels the map won't snap to them until manually scrolled to near their position. if(MapData.layers.gps && marker.type === 'player') { //This works fine - MapData.view.x = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; - //This does not + let newX = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; + if(Math.abs(MapData.view.x - newX) >= 10) { // Needs some tuning, but the idea is to not keep calling the map update _constantly_ when stationary. + MapData.view.x = newX; + MapData.view.dirty = true; + } + //This calculation does not // MapData.view.y = -marker.position.z * MapData.view.scale; - MapData.view.dirty = true; + } if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue; From 70943cf60de9bee7cd21f6990d00b3c3aaff8189 Mon Sep 17 00:00:00 2001 From: David Camp Date: Mon, 11 Aug 2025 22:13:01 -0700 Subject: [PATCH 3/4] Fix Y value Calculation. --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 671b52a..bea3d41 100644 --- a/index.js +++ b/index.js @@ -503,15 +503,15 @@ function redrawDynamics(){ // Placing this here means the map should always snap to the player if the toggle is on. // Placing it after culling means that if the user fast travels the map won't snap to them until manually scrolled to near their position. if(MapData.layers.gps && marker.type === 'player') { - //This works fine + + // These functions are very closely related to convertX and convertY let newX = -marker.position.x * MapData.view.scale + mapCanvas.width * 0.5; - if(Math.abs(MapData.view.x - newX) >= 10) { // Needs some tuning, but the idea is to not keep calling the map update _constantly_ when stationary. + let newY = ((MapData.matrix.minY+MapData.matrix.maxY-marker.position.z) * MapData.view.scale - mapCanvas.height * 0.5); + if(Math.abs(MapData.view.x - newX) >= 10 || Math.abs(MapData.view.y - newY) >= 10) { MapData.view.x = newX; + MapData.view.y = newY; MapData.view.dirty = true; } - //This calculation does not - // MapData.view.y = -marker.position.z * MapData.view.scale; - } if(marker.hidden || (marker.minZoom && MapData.view.scale < marker.minZoom) || (marker.maxZoom && MapData.view.scale > marker.maxZoom)) continue; From 212c655b9d0848416edcb0d06cc62a43d8dbbd47 Mon Sep 17 00:00:00 2001 From: Pyro Nicampt <81565698+PyroNicampt@users.noreply.github.com> Date: Wed, 13 Aug 2025 15:14:03 -0500 Subject: [PATCH 4/4] Version Bump v0.6.6a > v0.6.7a --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index aa7927f..6da3c30 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@
- Map v0.6.6 alpha + Map v0.6.7 alpha
Updated for Game Build 99.7