From d0bb9c1e99cf89d72fd05b6c307610f5aa534d82 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 5 Sep 2021 13:18:17 -0500 Subject: [PATCH] Fixed several issues with Microtabs --- src/components/system/Microtab.vue | 16 +++++++--------- src/game/layers.ts | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/system/Microtab.vue b/src/components/system/Microtab.vue index 82b1b42..e2c5445 100644 --- a/src/components/system/Microtab.vue +++ b/src/components/system/Microtab.vue @@ -25,7 +25,7 @@ import { layers } from "@/game/layers"; import player from "@/game/player"; import { Microtab, MicrotabFamily } from "@/typings/features/subtab"; import { coerceComponent, InjectLayerMixin } from "@/util/vue"; -import { Component, defineComponent } from "vue"; +import { defineComponent } from "vue"; export default defineComponent({ name: "microtab", @@ -35,11 +35,9 @@ export default defineComponent({ type: String, required: true }, - id: { - type: String, - required: true - } + id: String }, + inject: ["tab"], computed: { floating() { return themes[player.theme].floatingTabs; @@ -47,7 +45,7 @@ export default defineComponent({ tabFamily(): MicrotabFamily { return layers[this.layer].microtabs![this.family]; }, - microtabs(): Record { + microtabs() { return Object.keys(this.tabFamily.data) .filter( microtab => @@ -60,15 +58,15 @@ export default defineComponent({ return acc; }, {}); }, - activeMicrotab(): Microtab | undefined { + activeMicrotab() { return this.id != undefined ? this.tabFamily.data[this.id] : this.tabFamily.activeMicrotab; }, - embed(): string | undefined { + embed() { return this.activeMicrotab!.embedLayer; }, - display(): Component | string | undefined { + display() { return this.activeMicrotab!.display && coerceComponent(this.activeMicrotab!.display!); } }, diff --git a/src/game/layers.ts b/src/game/layers.ts index 2b91139..ac8a190 100644 --- a/src/game/layers.ts +++ b/src/game/layers.ts @@ -539,14 +539,14 @@ export function addLayer(layer: RawLayer, player?: Partial): void { this.data[playerProxy.subtabs[this.layer as string][family]] && this.data[playerProxy.subtabs[this.layer as string][family]].unlocked !== false ) { - return this[playerProxy.subtabs[this.layer as string][family]]; + return this.data[playerProxy.subtabs[this.layer as string][family]]; } // Default to first unlocked tab - const firstUnlocked: string | undefined = Object.keys(this).find( + const firstUnlocked: string | undefined = Object.keys(this.data).find( microtab => microtab !== "activeMicrotab" && this.data[microtab].unlocked !== false ); - return firstUnlocked != undefined ? this[firstUnlocked] : undefined; + return firstUnlocked != undefined ? this.data[firstUnlocked] : undefined; }; setDefault( player.subtabs[layer.id], @@ -561,7 +561,7 @@ export function addLayer(layer: RawLayer, player?: Partial): void { microtab.family = family; microtab.id = id; microtab.active = function() { - return playerProxy.subtabs[this.layer][this.family] === this.id; + return layers[this.layer].microtabs![this.family].activeMicrotab === this; }; } }