[HTML5] Better engine config parsing.

(cherry picked from commit 2f509f1b12)
This commit is contained in:
Fabio Alessandrelli 2022-01-30 17:41:40 +01:00 committed by Rémi Verschelde
parent 0a77d2d850
commit 6209eede00
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 21 additions and 20 deletions

View File

@ -225,33 +225,34 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
*/ */
Config.prototype.update = function (opts) { Config.prototype.update = function (opts) {
const config = opts || {}; const config = opts || {};
function parse(key, def) { const me = this;
function parse(key) {
if (typeof (config[key]) === 'undefined') { if (typeof (config[key]) === 'undefined') {
return def; return me[key];
} }
return config[key]; return config[key];
} }
// Module config // Module config
this.unloadAfterInit = parse('unloadAfterInit', this.unloadAfterInit); this.unloadAfterInit = parse('unloadAfterInit');
this.onPrintError = parse('onPrintError', this.onPrintError); this.onPrintError = parse('onPrintError');
this.onPrint = parse('onPrint', this.onPrint); this.onPrint = parse('onPrint');
this.onProgress = parse('onProgress', this.onProgress); this.onProgress = parse('onProgress');
// Godot config // Godot config
this.canvas = parse('canvas', this.canvas); this.canvas = parse('canvas');
this.executable = parse('executable', this.executable); this.executable = parse('executable');
this.mainPack = parse('mainPack', this.mainPack); this.mainPack = parse('mainPack');
this.locale = parse('locale', this.locale); this.locale = parse('locale');
this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy); this.canvasResizePolicy = parse('canvasResizePolicy');
this.persistentPaths = parse('persistentPaths', this.persistentPaths); this.persistentPaths = parse('persistentPaths');
this.persistentDrops = parse('persistentDrops', this.persistentDrops); this.persistentDrops = parse('persistentDrops');
this.experimentalVK = parse('experimentalVK', this.experimentalVK); this.experimentalVK = parse('experimentalVK');
this.focusCanvas = parse('focusCanvas', this.focusCanvas); this.focusCanvas = parse('focusCanvas');
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs); this.gdnativeLibs = parse('gdnativeLibs');
this.fileSizes = parse('fileSizes', this.fileSizes); this.fileSizes = parse('fileSizes');
this.args = parse('args', this.args); this.args = parse('args');
this.onExecute = parse('onExecute', this.onExecute); this.onExecute = parse('onExecute');
this.onExit = parse('onExit', this.onExit); this.onExit = parse('onExit');
}; };
/** /**