Skip to content

Commit

Permalink
automatically switch to fixposition to avoid overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni009 committed Jul 20, 2024
1 parent c747b5b commit cca2fd6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/EditEndpointDialogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { DialogProps } from '@/types/props';
import { teleporterTypes, type TeleporterTypes } from '@/types/teleportEndpoint';
import { maxStations } from '@/variables/limits';
import { storeToRefs } from 'pinia';
import { computed, ref } from 'vue';
import { computed, ref, watch } from 'vue';
const props = withDefaults(defineProps<DialogProps>(), {
endpointData: () => createEndpoint(),
Expand All @@ -29,7 +29,7 @@ function resetEndpointInputs() {
newEndpointName.value = props.endpointData.Name;
newEndpointAddress.value = endpointToGlyphs(props.endpointData);
newEndpointGalaxy.value = (props.endpointData.UniverseAddress.RealityIndex + 1).toString();
newEndpointType.value = props.endpointData.TeleporterType;
changeInitialEndpointType();
}
function addEndpoint() {
Expand All @@ -51,7 +51,7 @@ function addEndpoint() {
planet: PlanetIndex,
});
if (props.endpointData.Name) {
if (!isNewEndpoint.value) {
const locationData = addressToXYZ(newEndpointAddress.value);
if (!locationData) return;
const { VoxelX, VoxelY, VoxelZ, SolarSystemIndex, PlanetIndex } = locationData;
Expand Down Expand Up @@ -102,6 +102,16 @@ const isOverLimit = computed(() => {
});
const amountOverLimit = computed(() => Math.max((typeCounter.value[newEndpointType.value] ?? 0) - maxStations, 1));
function changeInitialEndpointType() {
if ((typeCounter.value.Spacestation ?? 0) + 1 > maxStations && isNewEndpoint.value) {
newEndpointType.value = 'SpacestationFixPosition';
} else {
newEndpointType.value = props.endpointData.TeleporterType;
}
}
watch(typeCounter, changeInitialEndpointType);
</script>

<template>
Expand Down

0 comments on commit cca2fd6

Please sign in to comment.