Open day when beginning mastery

This commit is contained in:
thepaperpilot 2022-12-17 10:42:59 -06:00
parent 271485a5a6
commit 5f1b2e7178
2 changed files with 25 additions and 15 deletions

View file

@ -20,6 +20,7 @@ import Modal from "components/Modal.vue";
import { createMilestone } from "features/milestones/milestone";
import { createClickable } from "features/clickables/clickable";
import { main } from "../projEntry";
import player from "game/player";
const id = "wrappingPaper";
const day = 15;
@ -373,6 +374,10 @@ const layer = createLayer(id, () => {
}),
onClick() {
main.toggleMastery();
const layer = main.currentlyMastering.value?.id ?? "trees";
if (!player.tabs.includes(layer)) {
main.openDay(layer);
}
},
style: {
backgroundColor: "gold"

View file

@ -114,6 +114,24 @@ export const main = createLayer("main", function (this: BaseLayer) {
}
}
function openDay(layer: string) {
// 1468 is because two tabs with minWidth of 700px plus the minimized calendar of 60px plus 2 dividers of 4px each
if (window.matchMedia("(min-width: 1468px)").matches) {
// Desktop, allow multiple tabs to be open
if (player.tabs.includes(layer)) {
const index = player.tabs.lastIndexOf(layer);
player.tabs.splice(index, 1);
} else {
player.tabs.push(layer);
main.minimized.value = true;
}
} else {
// Mobile, use single tab mode
player.tabs.splice(1, Infinity, layer);
}
layers[layer]!.minimized.value = false;
}
function createDay(
optionsFunc: () => {
day: number;
@ -182,21 +200,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
},
onOpenLayer() {
recentlyUpdated.value = false;
// 1468 is because two tabs with minWidth of 700px plus the minimized calendar of 60px plus 2 dividers of 4px each
if (window.matchMedia("(min-width: 1468px)").matches) {
// Desktop, allow multiple tabs to be open
if (player.tabs.includes(layer ?? "trees")) {
const index = player.tabs.lastIndexOf(layer ?? "trees");
player.tabs.splice(index, 1);
} else {
player.tabs.push(layer ?? "trees");
main.minimized.value = true;
}
} else {
// Mobile, use single tab mode
player.tabs.splice(1, Infinity, layer ?? "trees");
}
layers[layer ?? "trees"]!.minimized.value = false;
openDay(layer ?? "trees");
},
onUnlockLayer() {
if (layer) {
@ -480,6 +484,7 @@ export const main = createLayer("main", function (this: BaseLayer) {
name: "Calendar",
days,
day,
openDay,
timeUntilNewDay,
loreScene,
loreTitle,