Accept non-default main packs in engine.js startGame()
Allows using startGame() with main packs exported as .zip, but also any other custom extension, for example if a web game host does not allow the .pck filename extension.
This commit is contained in:
parent
32eb3e1b7d
commit
96f907c023
2 changed files with 7 additions and 3 deletions
4
misc/dist/html/default.html
vendored
4
misc/dist/html/default.html
vendored
|
@ -229,7 +229,7 @@ $GODOT_HEAD_INCLUDE
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
const BASENAME = '$GODOT_BASENAME';
|
const MAIN_PACK = '$GODOT_BASENAME.pck';
|
||||||
const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
|
const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
|
||||||
const INDETERMINATE_STATUS_STEP_MS = 100;
|
const INDETERMINATE_STATUS_STEP_MS = 100;
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ $GODOT_HEAD_INCLUDE
|
||||||
} else {
|
} else {
|
||||||
setStatusMode('indeterminate');
|
setStatusMode('indeterminate');
|
||||||
engine.setCanvas(canvas);
|
engine.setCanvas(canvas);
|
||||||
engine.startGame(BASENAME + '.pck').then(() => {
|
engine.startGame(MAIN_PACK).then(() => {
|
||||||
setStatusMode('hidden');
|
setStatusMode('hidden');
|
||||||
initializing = false;
|
initializing = false;
|
||||||
}, displayFailureNotice);
|
}, displayFailureNotice);
|
||||||
|
|
|
@ -130,13 +130,17 @@
|
||||||
this.startGame = function(mainPack) {
|
this.startGame = function(mainPack) {
|
||||||
|
|
||||||
executableName = getBaseName(mainPack);
|
executableName = getBaseName(mainPack);
|
||||||
|
var mainArgs = [];
|
||||||
|
if (!getPathLeaf(mainPack).endsWith('.pck')) {
|
||||||
|
mainArgs = ['--main-pack', getPathLeaf(mainPack)];
|
||||||
|
}
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
// Load from directory,
|
// Load from directory,
|
||||||
this.init(getBasePath(mainPack)),
|
this.init(getBasePath(mainPack)),
|
||||||
// ...but write to root where the engine expects it.
|
// ...but write to root where the engine expects it.
|
||||||
this.preloadFile(mainPack, getPathLeaf(mainPack))
|
this.preloadFile(mainPack, getPathLeaf(mainPack))
|
||||||
]).then(
|
]).then(
|
||||||
Function.prototype.apply.bind(synchronousStart, this, [])
|
Function.prototype.apply.bind(synchronousStart, this, mainArgs)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue