diff --git a/client/src/core/components/modals/modal.vue b/client/src/core/components/modals/modal.vue
index 757a7ba92..c03fb4bd3 100644
--- a/client/src/core/components/modals/modal.vue
+++ b/client/src/core/components/modals/modal.vue
@@ -3,11 +3,18 @@
-
+
@@ -18,7 +25,8 @@
@@ -99,7 +119,6 @@ export default class Modal extends Vue {
.mask {
position: fixed;
- z-index: 9998;
top: 0;
left: 0;
width: 100%;
diff --git a/client/src/core/components/modals/store.ts b/client/src/core/components/modals/store.ts
new file mode 100644
index 000000000..33f3a7b1e
--- /dev/null
+++ b/client/src/core/components/modals/store.ts
@@ -0,0 +1,31 @@
+import Modal from "@/core/components/modals/modal.vue";
+
+import { rootStore } from "@/store";
+import { getModule, Module, Mutation, VuexModule } from "vuex-module-decorators";
+
+@Module({ dynamic: true, store: rootStore, name: "modals", namespaced: true })
+class ModalsStore extends VuexModule {
+ modals: Modal[] = [];
+
+ get topModal(): Modal {
+ return this.modals[0];
+ }
+
+ @Mutation
+ setTopModal(modal: Modal): void {
+ // Dont bother doing anything if the chosen modal is already at the top
+ if (this.topModal === modal) return;
+ // Put the chosen modal at the start of the array, and remove it from the rest of the list if exists
+ this.modals = [modal, ...this.modals.filter(item => item !== modal).slice(0, 999)];
+ this.modals.forEach((element: Modal, i: number) => {
+ element.$data.zIndex = 8999 - i;
+ });
+ }
+
+ @Mutation
+ removeFromModals(modal: Modal): void {
+ this.modals = this.modals.filter(item => item !== modal);
+ }
+}
+
+export const modalsStore = getModule(ModalsStore);
diff --git a/client/src/game/ui/dmsettings.vue b/client/src/game/ui/dmsettings.vue
index 86c036e7a..5a241e50a 100644
--- a/client/src/game/ui/dmsettings.vue
+++ b/client/src/game/ui/dmsettings.vue
@@ -1,5 +1,5 @@
-
+
@@ -90,10 +92,9 @@
import Vue from "vue";
import Component from "vue-class-component";
-import { mapState } from "vuex";
-
import InputCopyElement from "@/core/components/inputCopy.vue";
import Modal from "@/core/components/modals/modal.vue";
+import { modalsStore } from "@/core/components/modals/store";
import { EventBus } from "@/game/event-bus";
@@ -102,9 +103,6 @@ import { EventBus } from "@/game/event-bus";
InputCopyElement,
Modal,
},
- computed: {
- ...mapState("game", ["invitationCode"]),
- },
})
export default class KeybindSettings extends Vue {
visible = false;
@@ -112,13 +110,18 @@ export default class KeybindSettings extends Vue {
selection = 0;
mounted() {
- EventBus.$on("KeybindSettings.Open", () => {
- this.visible = true;
+ EventBus.$on("KeybindSettings.Toggle", () => {
+ if (this.visible && modalsStore.topModal === this.$refs.modal) {
+ this.close();
+ } else {
+ this.visible = true;
+ modalsStore.setTopModal(this.$refs.modal as Modal);
+ }
});
}
beforeDestroy() {
- EventBus.$off("KeybindSettings.Open");
+ EventBus.$off("KeybindSettings.Toggle");
}
handleClick(event: { target: HTMLElement }) {
@@ -127,9 +130,10 @@ export default class KeybindSettings extends Vue {
child.click();
}
}
- onClose() {
+ close() {
this.visible = false;
EventBus.$emit("KeybindSettings.Close");
+ modalsStore.removeFromModals(this.$refs.modal as Modal);
}
}
diff --git a/client/src/game/ui/menu/menu.vue b/client/src/game/ui/menu/menu.vue
index afc7c47c7..2fb3469da 100644
--- a/client/src/game/ui/menu/menu.vue
+++ b/client/src/game/ui/menu/menu.vue
@@ -204,19 +204,19 @@ export default class MenuBar extends Vue {
}
openDmSettings(event: { target: HTMLElement }) {
- EventBus.$emit("DmSettings.Open");
event.target.classList.add("menu-accordion-active");
EventBus.$once("DmSettings.Close", () => {
event.target.classList.remove("menu-accordion-active");
});
+ EventBus.$emit("DmSettings.Toggle");
}
openKeybindSettings(event: { target: HTMLElement }) {
- EventBus.$emit("KeybindSettings.Open");
event.target.classList.add("menu-accordion-active");
EventBus.$once("KeybindSettings.Close", () => {
event.target.classList.remove("menu-accordion-active");
});
+ EventBus.$emit("KeybindSettings.Toggle");
}
}
diff --git a/client/src/game/ui/note.vue b/client/src/game/ui/note.vue
index 1185c9f6a..085f78771 100644
--- a/client/src/game/ui/note.vue
+++ b/client/src/game/ui/note.vue
@@ -1,5 +1,5 @@
-
+
-
+