Fixed several issues with Microtabs

This commit is contained in:
thepaperpilot 2021-09-05 13:18:17 -05:00
parent 8842da90ec
commit d0bb9c1e99
2 changed files with 11 additions and 13 deletions

View file

@ -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<string, Microtab> {
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!);
}
},

View file

@ -539,14 +539,14 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): 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<PlayerData>): 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;
};
}
}