From 3e53fac30a302bcce714d43e3a62eda90453b883 Mon Sep 17 00:00:00 2001 From: Lenni009 Date: Sun, 19 Nov 2023 00:53:21 +0100 Subject: [PATCH] MVP --- README.md | 2 +- src/App.vue | 20 ++++---- src/common.ts | 15 ++++-- src/components/CopyButton.vue | 4 -- src/components/EditEndpointDialogue.vue | 62 +++++++++++++++---------- src/components/EndpointCard.vue | 5 +- src/components/FilterInput.vue | 22 ++++++++- src/stores/endpointData.ts | 4 +- 8 files changed, 85 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 1f81fa4..f8aefea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # NMS-Teleport-Editor -Allows you to edit multiple destinations into your teleporter list +Allows you to edit your teleporter list diff --git a/src/App.vue b/src/App.vue index 7f01fea..6066ed9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,14 +10,16 @@ import { computed } from 'vue'; import { endpointToAddress } from './common'; const endpointData = useEndpointDataStore(); -const { json, filter } = storeToRefs(endpointData); +const { json, filter, filterType } = storeToRefs(endpointData); const renderJson = computed(() => { - if (filter.value) { + if (filter.value || filterType.value) { return json.value.filter( (item) => - item.Name.toLowerCase().includes(filter.value.toLowerCase()) || - endpointToAddress(item).includes(filter.value.toUpperCase()) + (!filter.value || + item.Name.toLowerCase().includes(filter.value.toLowerCase()) || + endpointToAddress(item).includes(filter.value.toUpperCase())) && + (!filterType.value || item.TeleporterType === filterType.value) ); } else { return json.value; @@ -72,19 +74,15 @@ nav { .input-wrapper { display: flex; - flex-wrap: wrap; gap: 1rem; - - & > * { - flex-grow: 1; - } + flex-direction: column; .action-wrapper { display: flex; - flex-grow: 0; + flex-grow: 1; gap: 1rem; flex-wrap: wrap; - width: min-content; + align-items: end; } } diff --git a/src/common.ts b/src/common.ts index bbbabdb..61a07ab 100644 --- a/src/common.ts +++ b/src/common.ts @@ -37,11 +37,17 @@ export function createEndpoint( } export function endpointToAddress(endpoint: TeleportEndpoint) { - const {VoxelX, VoxelY, VoxelZ, SolarSystemIndex, PlanetIndex } = endpoint.UniverseAddress.GalacticAddress; + const { VoxelX, VoxelY, VoxelZ, SolarSystemIndex, PlanetIndex } = endpoint.UniverseAddress.GalacticAddress; return xyzToAddress(VoxelX, VoxelY, VoxelZ, SolarSystemIndex, PlanetIndex); } -export function xyzToAddress(voxelX: number, voxelY: number, voxelZ: number, system_idx: number, planet_idx: number): string { +export function xyzToAddress( + voxelX: number, + voxelY: number, + voxelZ: number, + system_idx: number, + planet_idx: number +): string { let x_glyphs, y_glyphs, z_glyphs; if (voxelX < 0) { x_glyphs = voxelX + 4096; @@ -78,6 +84,7 @@ export function addressToXYZ(input: string) { const y_glyphs = numberCoords[1]; const z_glyphs = numberCoords[2]; // NoSonar this is stupid indexing const system_idx = numberCoords[3]; // NoSonar this is stupid indexing + const planet_idx = numberCoords[4]; // NoSonar this is stupid indexing let VoxelX, VoxelY, VoxelZ; if (x_glyphs > 2047) { @@ -101,6 +108,7 @@ export function addressToXYZ(input: string) { VoxelY, VoxelZ, SolarSystemIndex: system_idx, + PlanetIndex: planet_idx, }; } @@ -109,8 +117,9 @@ function convertGlyphs(glyphs: string): string[] { const y_glyphs = glyphs.substring(4, 6); const z_glyphs = glyphs.substring(6, 9); const system_idx = glyphs.substring(1, 4); + const planet_idx = glyphs.substring(0, 1); - return [x_glyphs, y_glyphs, z_glyphs, system_idx]; + return [x_glyphs, y_glyphs, z_glyphs, system_idx, planet_idx]; } function convertCoords(coords: string): string[] { diff --git a/src/components/CopyButton.vue b/src/components/CopyButton.vue index e8f108f..fc65c91 100644 --- a/src/components/CopyButton.vue +++ b/src/components/CopyButton.vue @@ -34,10 +34,6 @@ function copyJson() {