From 5d002ed57e33b222e4e78c9ac46151c701d65d80 Mon Sep 17 00:00:00 2001 From: Smoren Date: Mon, 29 Apr 2024 18:39:41 +0300 Subject: [PATCH] View Mode switch refactored. --- .../components/sections/view-mode-section.vue | 7 +------ src/store/simulation.ts | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/config-editor/components/sections/view-mode-section.vue b/src/components/config-editor/components/sections/view-mode-section.vue index 79548a2..d909474 100644 --- a/src/components/config-editor/components/sections/view-mode-section.vue +++ b/src/components/config-editor/components/sections/view-mode-section.vue @@ -14,12 +14,7 @@ watch(() => configStore.worldConfig.VIEW_MODE, () => { }); watch(viewMode, async () => { - if (configStore.worldConfig.VIEW_MODE === viewMode.value) { - return; - } - await simulation.stop(); - configStore.setViewMode(viewMode.value); - await simulation.restart(); + await simulation.setViewMode(viewMode.value); }); diff --git a/src/store/simulation.ts b/src/store/simulation.ts index 5200c04..dc08179 100644 --- a/src/store/simulation.ts +++ b/src/store/simulation.ts @@ -138,6 +138,12 @@ export const useSimulationStore = defineStore("simulation", () => { return getCurrentSimulation().togglePause(); } + const setViewMode = async (viewMode: ViewMode) => { + await stop(); + configStore.setViewMode(viewMode); + await restart(); + } + // watch(() => configStore.worldConfig.VIEW_MODE, async () => { // await restart(); // }); @@ -156,5 +162,6 @@ export const useSimulationStore = defineStore("simulation", () => { stop, isPaused, togglePause, + setViewMode, } });