Skip to content

Commit

Permalink
Add setting to Copy Coordinates as (X,Y,Z), Y defined by layer
Browse files Browse the repository at this point in the history
  • Loading branch information
savage13 committed Oct 26, 2024
1 parent b64c6c5 commit 1a79547
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MapBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CanvasMarker } from '@/util/CanvasMarker';
import * as map from '@/util/map';
import { Point } from '@/util/map';
import * as ui from '@/util/ui';
import { Settings } from '@/util/settings';

declare module 'leaflet' {
export type RasterCoords = any;
Expand Down Expand Up @@ -172,7 +173,14 @@ export class MapBase {
text: 'Copy coordinates',
callback: ({ latlng }: ui.LeafletContextMenuCbArg) => {
const [x, y, z] = this.toXYZ(latlng);
ui.copyToClipboard(`${x},${-z}`);
let s = Settings.getInstance();
if (s.copyCoordinatesXYZ) {
// @ts-ignore
const yv = { Surface: 150, Sky: 1500, Depths: -500 }[this.activeLayer]
ui.copyToClipboard(`${x},${yv},${-z}`)
return
}
ui.copyToClipboard(`${x},${-z}`)
},
},
{
Expand Down
5 changes: 5 additions & 0 deletions src/components/AppMapSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<b-btn class="mt-2" size="sm" @click="s.customSearchPresets.push(['', ''])"><i class="fa fa-plus"></i> Add</b-btn>
</section>
<hr>
<h4 class="subsection-heading">Copy Coordinates</h4>
<b-checkbox switch v-model="s.copyCoordinatesXYZ">Copy (x,y,z) instead of (x,z).</b-checkbox>
<p class="small">
Result of 'Copy coordinates' in the map's context menu, right click, returns (x,y,z) instead of (x,z). Value of y (height) is defined by the active layer.
</p>
<h4 class="subsection-heading">Map Drawing</h4>
<b-checkbox switch v-model="s.noTouchScreen">Not using a touch screen</b-checkbox>
<p class="small">
Expand Down
3 changes: 3 additions & 0 deletions src/util/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class Settings {
decompBannerHidden!: boolean;
noTouchScreen!: boolean;
inGameCoordinates!: boolean;
copyCoordinatesXYZ!: boolean;

private constructor() {
this.load();
Expand Down Expand Up @@ -75,6 +76,7 @@ export class Settings {
this.decompBannerHidden = parse(data.decompBannerHidden, Id, false);
this.noTouchScreen = parse(data.noTouchScreen, Id, false);
this.inGameCoordinates = parse(data.inGameCoordinates, Id, false);
this.copyCoordinatesXYZ = parse(data.copyCoordinatesXYZ, Id, false);
this.invokeCallbacks();
}

Expand All @@ -99,6 +101,7 @@ export class Settings {
decompBannerHidden: this.decompBannerHidden,
noTouchScreen: this.noTouchScreen,
inGameCoordinates: this.inGameCoordinates,
copyCoordinatesXYZ: this.copyCoordinatesXYZ,
};
// Merge with existing data to avoid data loss.
const existingDataStr = localStorage.getItem(Settings.KEY);
Expand Down

0 comments on commit 1a79547

Please sign in to comment.