From 41380b39b950f9eeb49b31a48c0e7f5a25232de3 Mon Sep 17 00:00:00 2001 From: Moka <54149968+MokaStitcher@users.noreply.github.com> Date: Sun, 27 Oct 2024 21:32:30 +0100 Subject: [PATCH] [Hotfix] Fix manifest getting loaded before the game is initialized (#4739) * Fix manifest being used before the game is initialized * bump game version * make manifest fix more future proof * Revert "make manifest fix more future proof" This reverts commit 32591b35d0438dac99eb2ea29cd6757e3086008a. * fix locales path for offline builds --- package-lock.json | 4 ++-- package.json | 2 +- src/main.ts | 10 ++++++---- src/plugins/i18n.ts | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c36f9cfee97..5c134ae70dd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pokemon-rogue-battle", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pokemon-rogue-battle", - "version": "1.1.2", + "version": "1.1.3", "hasInstallScript": true, "dependencies": { "@material/material-color-utilities": "^0.2.7", diff --git a/package.json b/package.json index aef6e7b2ba03..4a8743745b9e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pokemon-rogue-battle", "private": true, - "version": "1.1.2", + "version": "1.1.3", "type": "module", "scripts": { "start": "vite", diff --git a/src/main.ts b/src/main.ts index d25ff08222d7..993bd1018aed 100644 --- a/src/main.ts +++ b/src/main.ts @@ -44,7 +44,7 @@ document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems let game; -const startGame = async () => { +const startGame = async (manifest?: any) => { await initI18n(); const LoadingScene = (await import("./loading-scene")).LoadingScene; const BattleScene = (await import("./battle-scene")).default; @@ -94,16 +94,18 @@ const startGame = async () => { version: version }); game.sound.pauseOnBlur = false; + if (manifest) { + game["manifest"] = manifest; + } }; fetch("/manifest.json") .then(res => res.json()) .then(jsonResponse => { - startGame(); - game["manifest"] = jsonResponse.manifest; + startGame(jsonResponse.manifest); }).catch(() => { // Manifest not found (likely local build) - // startGame(); + startGame(); }); export default game; diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index d24484bbf9d3..91a67b9414ca 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -164,7 +164,7 @@ export async function initI18n(): Promise { } else { fileName = camelCaseToKebabCase(ns); } - return `/locales/${lng}/${fileName}.json?v=${pkg.version}`; + return `./locales/${lng}/${fileName}.json?v=${pkg.version}`; }, }, defaultNS: "menu",