forked from profectus/Profectus
Fixed several issues with Microtabs
This commit is contained in:
parent
8842da90ec
commit
d0bb9c1e99
2 changed files with 11 additions and 13 deletions
|
@ -25,7 +25,7 @@ import { layers } from "@/game/layers";
|
||||||
import player from "@/game/player";
|
import player from "@/game/player";
|
||||||
import { Microtab, MicrotabFamily } from "@/typings/features/subtab";
|
import { Microtab, MicrotabFamily } from "@/typings/features/subtab";
|
||||||
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
|
import { coerceComponent, InjectLayerMixin } from "@/util/vue";
|
||||||
import { Component, defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "microtab",
|
name: "microtab",
|
||||||
|
@ -35,11 +35,9 @@ export default defineComponent({
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
id: {
|
id: String
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
inject: ["tab"],
|
||||||
computed: {
|
computed: {
|
||||||
floating() {
|
floating() {
|
||||||
return themes[player.theme].floatingTabs;
|
return themes[player.theme].floatingTabs;
|
||||||
|
@ -47,7 +45,7 @@ export default defineComponent({
|
||||||
tabFamily(): MicrotabFamily {
|
tabFamily(): MicrotabFamily {
|
||||||
return layers[this.layer].microtabs![this.family];
|
return layers[this.layer].microtabs![this.family];
|
||||||
},
|
},
|
||||||
microtabs(): Record<string, Microtab> {
|
microtabs() {
|
||||||
return Object.keys(this.tabFamily.data)
|
return Object.keys(this.tabFamily.data)
|
||||||
.filter(
|
.filter(
|
||||||
microtab =>
|
microtab =>
|
||||||
|
@ -60,15 +58,15 @@ export default defineComponent({
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
},
|
},
|
||||||
activeMicrotab(): Microtab | undefined {
|
activeMicrotab() {
|
||||||
return this.id != undefined
|
return this.id != undefined
|
||||||
? this.tabFamily.data[this.id]
|
? this.tabFamily.data[this.id]
|
||||||
: this.tabFamily.activeMicrotab;
|
: this.tabFamily.activeMicrotab;
|
||||||
},
|
},
|
||||||
embed(): string | undefined {
|
embed() {
|
||||||
return this.activeMicrotab!.embedLayer;
|
return this.activeMicrotab!.embedLayer;
|
||||||
},
|
},
|
||||||
display(): Component | string | undefined {
|
display() {
|
||||||
return this.activeMicrotab!.display && coerceComponent(this.activeMicrotab!.display!);
|
return this.activeMicrotab!.display && coerceComponent(this.activeMicrotab!.display!);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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]] &&
|
||||||
this.data[playerProxy.subtabs[this.layer as string][family]].unlocked !== false
|
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
|
// Default to first unlocked tab
|
||||||
const firstUnlocked: string | undefined = Object.keys(this).find(
|
const firstUnlocked: string | undefined = Object.keys(this.data).find(
|
||||||
microtab =>
|
microtab =>
|
||||||
microtab !== "activeMicrotab" && this.data[microtab].unlocked !== false
|
microtab !== "activeMicrotab" && this.data[microtab].unlocked !== false
|
||||||
);
|
);
|
||||||
return firstUnlocked != undefined ? this[firstUnlocked] : undefined;
|
return firstUnlocked != undefined ? this.data[firstUnlocked] : undefined;
|
||||||
};
|
};
|
||||||
setDefault(
|
setDefault(
|
||||||
player.subtabs[layer.id],
|
player.subtabs[layer.id],
|
||||||
|
@ -561,7 +561,7 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
|
||||||
microtab.family = family;
|
microtab.family = family;
|
||||||
microtab.id = id;
|
microtab.id = id;
|
||||||
microtab.active = function() {
|
microtab.active = function() {
|
||||||
return playerProxy.subtabs[this.layer][this.family] === this.id;
|
return layers[this.layer].microtabs![this.family].activeMicrotab === this;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue