[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 32591b35d0
.
* fix locales path for offline builds
This commit is contained in:
parent
dfb42e44a6
commit
41380b39b9
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@material/material-color-utilities": "^0.2.7",
|
"@material/material-color-utilities": "^0.2.7",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "pokemon-rogue-battle",
|
"name": "pokemon-rogue-battle",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|
10
src/main.ts
10
src/main.ts
|
@ -44,7 +44,7 @@ document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems
|
||||||
|
|
||||||
let game;
|
let game;
|
||||||
|
|
||||||
const startGame = async () => {
|
const startGame = async (manifest?: any) => {
|
||||||
await initI18n();
|
await initI18n();
|
||||||
const LoadingScene = (await import("./loading-scene")).LoadingScene;
|
const LoadingScene = (await import("./loading-scene")).LoadingScene;
|
||||||
const BattleScene = (await import("./battle-scene")).default;
|
const BattleScene = (await import("./battle-scene")).default;
|
||||||
|
@ -94,16 +94,18 @@ const startGame = async () => {
|
||||||
version: version
|
version: version
|
||||||
});
|
});
|
||||||
game.sound.pauseOnBlur = false;
|
game.sound.pauseOnBlur = false;
|
||||||
|
if (manifest) {
|
||||||
|
game["manifest"] = manifest;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("/manifest.json")
|
fetch("/manifest.json")
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(jsonResponse => {
|
.then(jsonResponse => {
|
||||||
startGame();
|
startGame(jsonResponse.manifest);
|
||||||
game["manifest"] = jsonResponse.manifest;
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// Manifest not found (likely local build)
|
// Manifest not found (likely local build)
|
||||||
// startGame();
|
startGame();
|
||||||
});
|
});
|
||||||
|
|
||||||
export default game;
|
export default game;
|
||||||
|
|
|
@ -164,7 +164,7 @@ export async function initI18n(): Promise<void> {
|
||||||
} else {
|
} else {
|
||||||
fileName = camelCaseToKebabCase(ns);
|
fileName = camelCaseToKebabCase(ns);
|
||||||
}
|
}
|
||||||
return `/locales/${lng}/${fileName}.json?v=${pkg.version}`;
|
return `./locales/${lng}/${fileName}.json?v=${pkg.version}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defaultNS: "menu",
|
defaultNS: "menu",
|
||||||
|
|
Loading…
Reference in New Issue