Fixing local development and offline builds
This commit is contained in:
parent
22865c010a
commit
9983ccfd18
13
src/main.ts
13
src/main.ts
|
@ -43,6 +43,7 @@ Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative
|
||||||
document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems"));
|
document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems"));
|
||||||
|
|
||||||
let game;
|
let game;
|
||||||
|
let manifest;
|
||||||
|
|
||||||
const startGame = async () => {
|
const startGame = async () => {
|
||||||
await initI18n();
|
await initI18n();
|
||||||
|
@ -94,15 +95,19 @@ 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();
|
manifest = jsonResponse.manifest;
|
||||||
game["manifest"] = jsonResponse.manifest;
|
}).catch(err => {
|
||||||
}).catch(() => {
|
// Manifest not found (likely local build or error path on live)
|
||||||
// Manifest not found (likely local build)
|
console.log(`Manifest not found. ${err}`);
|
||||||
|
}).finally(() => {
|
||||||
startGame();
|
startGame();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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