From 5f1b2e7178e44ce1df7a2f7f29cd27c5c86deddd Mon Sep 17 00:00:00 2001 From: thepaperpilot <thepaperpilot@gmail.com> Date: Sat, 17 Dec 2022 10:42:59 -0600 Subject: [PATCH] Open day when beginning mastery --- src/data/layers/wrapping-paper.tsx | 5 +++++ src/data/projEntry.tsx | 35 +++++++++++++++++------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/data/layers/wrapping-paper.tsx b/src/data/layers/wrapping-paper.tsx index 52cac92..0ec8697 100644 --- a/src/data/layers/wrapping-paper.tsx +++ b/src/data/layers/wrapping-paper.tsx @@ -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" diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 488354c..5ada93c 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -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,