From fe865bff9d723d10ab405e16337a9f31ee6ac997 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Thu, 21 Jul 2022 19:23:33 -0500 Subject: [PATCH] Add onLoad event --- src/game/events.ts | 5 +++++ src/util/save.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/game/events.ts b/src/game/events.ts index 78219fd..3be00b7 100644 --- a/src/game/events.ts +++ b/src/game/events.ts @@ -45,6 +45,11 @@ export interface GlobalEvents { * @param vue The Vue App being constructed. */ setupVue: (vue: App) => void; + /** + * Sent whenever a save has finished loading. + * Happens when the page is opened and upon switching saves in the saves manager. + */ + onLoad: VoidFunction; } /** A global event bus for hooking into {@link GlobalEvents}. */ diff --git a/src/util/save.ts b/src/util/save.ts index c5a0073..4138e17 100644 --- a/src/util/save.ts +++ b/src/util/save.ts @@ -1,4 +1,5 @@ import projInfo from "data/projInfo.json"; +import { globalBus } from "game/events"; import type { Player, PlayerData } from "game/player"; import player, { stringifySave } from "game/player"; import settings, { loadSettings } from "game/settings"; @@ -112,6 +113,8 @@ export async function loadSave(playerObj: Partial): Promise { Object.assign(player, playerObj); settings.active = player.id; + + globalBus.emit("onLoad"); } setInterval(() => {