2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
var Class = require('../utils/Class');
|
2016-11-24 15:40:05 +00:00
|
|
|
var CONST = require('../const');
|
2018-05-10 16:15:25 +00:00
|
|
|
var GetFastValue = require('../utils/object/GetFastValue');
|
2017-04-26 15:03:14 +00:00
|
|
|
var GetValue = require('../utils/object/GetValue');
|
2018-05-10 16:15:25 +00:00
|
|
|
var IsPlainObject = require('../utils/object/IsPlainObject');
|
2017-09-13 16:09:16 +00:00
|
|
|
var MATH = require('../math/const');
|
2017-06-30 14:47:51 +00:00
|
|
|
var NOOP = require('../utils/NOOP');
|
2018-02-12 23:03:48 +00:00
|
|
|
var Plugins = require('../plugins');
|
2017-10-11 16:05:59 +00:00
|
|
|
var ValueToColor = require('../display/color/ValueToColor');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-10-04 18:59:08 +00:00
|
|
|
/**
|
|
|
|
* This callback type is completely empty, a no-operation.
|
|
|
|
*
|
|
|
|
* @callback NOOP
|
|
|
|
*/
|
|
|
|
|
2018-03-19 21:37:47 +00:00
|
|
|
/**
|
|
|
|
* @callback BootCallback
|
|
|
|
*
|
|
|
|
* @param {Phaser.Game} game - [description]
|
|
|
|
*/
|
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
/**
|
|
|
|
* @typedef {object} FPSConfig
|
2018-01-08 16:39:46 +00:00
|
|
|
*
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {integer} [min=10] - [description]
|
|
|
|
* @property {integer} [target=60] - [description]
|
|
|
|
* @property {boolean} [forceSetTimeOut=false] - [description]
|
|
|
|
* @property {integer} [deltaHistory=10] - [description]
|
|
|
|
* @property {integer} [panicMax=120] - [description]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-01-25 00:48:48 +00:00
|
|
|
* @typedef {object} LoaderConfig
|
2017-10-04 22:48:16 +00:00
|
|
|
*
|
2018-01-25 00:48:48 +00:00
|
|
|
* @property {string} [baseURL] - [description]
|
|
|
|
* @property {string} [path] - [description]
|
2018-05-02 16:23:51 +00:00
|
|
|
* @property {integer} [maxParallelDownloads=32] - [description]
|
2018-03-20 14:58:02 +00:00
|
|
|
* @property {(string|undefined)} [crossOrigin=undefined] - [description]
|
2018-01-25 00:48:48 +00:00
|
|
|
* @property {string} [responseType] - [description]
|
|
|
|
* @property {boolean} [async=true] - [description]
|
|
|
|
* @property {string} [user] - [description]
|
|
|
|
* @property {string} [password] - [description]
|
|
|
|
* @property {integer} [timeout=0] - [description]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} GameConfig
|
2018-01-08 16:39:46 +00:00
|
|
|
*
|
2018-03-20 14:58:02 +00:00
|
|
|
* @property {(integer|string)} [width=1024] - [description]
|
|
|
|
* @property {(integer|string)} [height=768] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {number} [zoom=1] - [description]
|
|
|
|
* @property {number} [resolution=1] - [description]
|
|
|
|
* @property {number} [type=CONST.AUTO] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {*} [parent=null] - [description]
|
2018-05-10 11:25:33 +00:00
|
|
|
* @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one.
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {string} [canvasStyle=null] - [description]
|
2018-05-10 11:25:33 +00:00
|
|
|
* @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one.
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {object} [scene=null] - [description]
|
2018-03-19 16:55:21 +00:00
|
|
|
* @property {string[]} [seed] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {string} [title=''] - [description]
|
|
|
|
* @property {string} [url='http://phaser.io'] - [description]
|
|
|
|
* @property {string} [version=''] - [description]
|
2018-03-27 11:30:00 +00:00
|
|
|
* @property {(boolean|object)} [input] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {boolean} [input.keyboard=true] - [description]
|
2018-03-27 11:30:00 +00:00
|
|
|
* @property {*} [input.keyboard.target=window] - [description]
|
|
|
|
* @property {(boolean|object)} [input.mouse=true] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {*} [input.mouse.target=null] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {boolean} [input.touch=true] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {*} [input.touch.target=null] - [description]
|
|
|
|
* @property {boolean} [input.touch.capture=true] - [description]
|
2018-03-27 11:30:00 +00:00
|
|
|
* @property {(boolean|object)} [input.gamepad=false] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {boolean} [disableContextMenu=false] - [description]
|
2018-03-27 11:30:00 +00:00
|
|
|
* @property {(boolean|object)} [banner=false] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {boolean} [banner.hidePhaser=false] - [description]
|
|
|
|
* @property {string} [banner.text='#ffffff'] - [description]
|
2018-03-19 16:55:21 +00:00
|
|
|
* @property {string[]} [banner.background] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {FPSConfig} [fps] - [description]
|
2018-05-08 08:17:13 +00:00
|
|
|
* @property {boolean} [render.antialias=true] - [description]
|
|
|
|
* @property {boolean} [render.pixelArt=false] - [description]
|
|
|
|
* @property {boolean} [render.autoResize=false] - [description]
|
|
|
|
* @property {boolean} [render.roundPixels=false] - [description]
|
|
|
|
* @property {boolean} [render.transparent=false] - [description]
|
|
|
|
* @property {boolean} [render.clearBeforeRender=true] - [description]
|
|
|
|
* @property {boolean} [render.premultipliedAlpha=true] - [description]
|
|
|
|
* @property {boolean} [render.preserveDrawingBuffer=false] - [description]
|
|
|
|
* @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description]
|
|
|
|
* @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default"
|
2018-03-20 14:58:02 +00:00
|
|
|
* @property {(string|number)} [backgroundColor=0x000000] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {object} [callbacks] - [description]
|
2018-03-19 21:37:47 +00:00
|
|
|
* @property {BootCallback} [callbacks.preBoot=NOOP] - [description]
|
|
|
|
* @property {BootCallback} [callbacks.postBoot=NOOP] - [description]
|
2018-04-02 11:03:05 +00:00
|
|
|
* @property {LoaderConfig} [loader] - [description]
|
|
|
|
* @property {object} [images] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
* @property {string} [images.default] - [description]
|
|
|
|
* @property {string} [images.missing] - [description]
|
2018-04-07 15:18:48 +00:00
|
|
|
* @property {object} [physics] - [description]
|
2017-10-04 22:48:16 +00:00
|
|
|
*/
|
|
|
|
|
2018-02-07 15:27:21 +00:00
|
|
|
/**
|
|
|
|
* @classdesc
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @class Config
|
|
|
|
* @memberOf Phaser.Boot
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-19 16:55:21 +00:00
|
|
|
* @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance.
|
2018-02-07 15:27:21 +00:00
|
|
|
*
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
var Config = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
|
|
|
function Config (config)
|
|
|
|
{
|
|
|
|
if (config === undefined) { config = {}; }
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
var defaultBannerColor = [
|
|
|
|
'#ff0000',
|
|
|
|
'#ffff00',
|
|
|
|
'#00ff00',
|
|
|
|
'#00ffff',
|
|
|
|
'#000000'
|
|
|
|
];
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
var defaultBannerTextColor = '#ffffff';
|
2016-11-24 01:35:02 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {(integer|string)} Phaser.Boot.Config#width - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.width = GetValue(config, 'width', 1024);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {(integer|string)} Phaser.Boot.Config#height - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.height = GetValue(config, 'height', 768);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {number} Phaser.Boot.Config#zoom - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.zoom = GetValue(config, 'zoom', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {number} Phaser.Boot.Config#resolution - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.resolution = GetValue(config, 'resolution', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {number} Phaser.Boot.Config#renderType - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.renderType = GetValue(config, 'type', CONST.AUTO);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {?*} Phaser.Boot.Config#parent - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.parent = GetValue(config, 'parent', null);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
2018-05-10 11:25:33 +00:00
|
|
|
* @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one.
|
2018-05-08 08:17:13 +00:00
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.canvas = GetValue(config, 'canvas', null);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
2018-05-10 11:25:33 +00:00
|
|
|
/**
|
|
|
|
* @const {?(CanvasRenderingContext2D|WebGLRenderingContext)} Phaser.Boot.Config#context - Force Phaser to use your own Canvas context instead of creating one.
|
|
|
|
*/
|
2018-05-10 11:42:08 +00:00
|
|
|
this.context = GetValue(config, 'context', null);
|
2018-05-10 11:25:33 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {?string} Phaser.Boot.Config#canvasStyle - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.canvasStyle = GetValue(config, 'canvasStyle', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {?object} Phaser.Boot.Config#sceneConfig - [description]
|
|
|
|
*/
|
2017-07-14 13:30:20 +00:00
|
|
|
this.sceneConfig = GetValue(config, 'scene', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {string[]} Phaser.Boot.Config#seed - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
MATH.RND.init(this.seed);
|
2017-01-25 12:01:52 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#gameTitle - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.gameTitle = GetValue(config, 'title', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#gameURL - [description]
|
|
|
|
*/
|
2018-01-28 04:10:44 +00:00
|
|
|
this.gameURL = GetValue(config, 'url', 'https://phaser.io');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#gameVersion - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.gameVersion = GetValue(config, 'version', '');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Input
|
2018-05-10 11:25:33 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#inputKeyboard - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.inputKeyboard = GetValue(config, 'input.keyboard', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {*} Phaser.Boot.Config#inputKeyboardEventTarget - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window);
|
2017-02-21 01:04:11 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {(boolean|object)} Phaser.Boot.Config#inputMouse - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.inputMouse = GetValue(config, 'input.mouse', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {?*} Phaser.Boot.Config#inputMouseEventTarget - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#inputMouseCapture - [description]
|
|
|
|
*/
|
2017-12-27 23:52:46 +00:00
|
|
|
this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true);
|
2017-06-12 23:38:48 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#inputTouch - [description]
|
|
|
|
*/
|
2017-07-28 02:28:10 +00:00
|
|
|
this.inputTouch = GetValue(config, 'input.touch', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description]
|
|
|
|
*/
|
2017-07-28 02:28:10 +00:00
|
|
|
this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#inputTouchCapture - [description]
|
|
|
|
*/
|
2017-12-27 23:52:46 +00:00
|
|
|
this.inputTouchCapture = GetValue(config, 'input.touch.capture', true);
|
2017-07-28 02:28:10 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#inputGamepad - [description]
|
|
|
|
*/
|
2017-09-13 13:18:34 +00:00
|
|
|
this.inputGamepad = GetValue(config, 'input.gamepad', false);
|
2017-09-09 02:17:13 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#disableContextMenu - [description]
|
|
|
|
*/
|
2017-07-25 11:33:37 +00:00
|
|
|
this.disableContextMenu = GetValue(config, 'disableContextMenu', false);
|
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {any} Phaser.Boot.Config#audio - [description]
|
|
|
|
*/
|
2018-01-08 16:39:46 +00:00
|
|
|
this.audio = GetValue(config, 'audio');
|
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// If you do: { banner: false } it won't display any banner at all
|
2018-05-10 11:25:33 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#hideBanner - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.hideBanner = (GetValue(config, 'banner', null) === false);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#hidePhaser - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.hidePhaser = GetValue(config, 'banner.hidePhaser', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#bannerTextColor - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string[]} Phaser.Boot.Config#bannerBackgroundColor - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor);
|
2017-10-04 22:48:16 +00:00
|
|
|
|
|
|
|
if (this.gameTitle === '' && this.hidePhaser)
|
|
|
|
{
|
|
|
|
this.hideBanner = true;
|
|
|
|
}
|
2018-01-08 16:39:46 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Frame Rate config
|
|
|
|
// fps: {
|
|
|
|
// min: 10,
|
|
|
|
// target: 60,
|
|
|
|
// forceSetTimeOut: false,
|
|
|
|
// deltaHistory: 10
|
|
|
|
// }
|
2017-05-03 16:07:15 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {?FPSConfig} Phaser.Boot.Config#fps - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.fps = GetValue(config, 'fps', null);
|
2017-02-07 18:41:53 +00:00
|
|
|
|
2018-03-15 21:15:12 +00:00
|
|
|
// Renderer Settings
|
2018-03-16 13:22:52 +00:00
|
|
|
// These can either be in a `render` object within the Config, or specified on their own
|
|
|
|
|
|
|
|
var renderConfig = GetValue(config, 'render', config);
|
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#antialias - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.antialias = GetValue(renderConfig, 'antialias', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#pixelArt - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#autoResize - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.autoResize = GetValue(renderConfig, 'autoResize', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#roundPixels - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#transparent - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.transparent = GetValue(renderConfig, 'transparent', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#zoclearBeforeRenderom - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#premultipliedAlpha - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#preserveDrawingBuffer - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#failIfMajorPerformanceCaveat - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#powerPreference - [description]
|
|
|
|
*/
|
2018-03-16 13:22:52 +00:00
|
|
|
this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default');
|
2018-02-28 21:15:18 +00:00
|
|
|
|
|
|
|
var bgc = GetValue(config, 'backgroundColor', 0);
|
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - [description]
|
|
|
|
*/
|
2018-02-28 21:15:18 +00:00
|
|
|
this.backgroundColor = ValueToColor(bgc);
|
|
|
|
|
|
|
|
if (bgc === 0 && this.transparent)
|
|
|
|
{
|
|
|
|
this.backgroundColor.alpha = 0;
|
|
|
|
}
|
2016-11-25 02:08:33 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Callbacks
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {BootCallback} Phaser.Boot.Config#preBoot - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {BootCallback} Phaser.Boot.Config#postBoot - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP);
|
2017-02-07 12:43:20 +00:00
|
|
|
|
2017-08-15 22:34:39 +00:00
|
|
|
// Physics
|
|
|
|
// physics: {
|
|
|
|
// system: 'impact',
|
2017-08-18 00:42:14 +00:00
|
|
|
// setBounds: true,
|
2017-08-15 22:34:39 +00:00
|
|
|
// gravity: 0,
|
2017-08-18 00:42:14 +00:00
|
|
|
// cellSize: 64
|
2017-08-15 22:34:39 +00:00
|
|
|
// }
|
2018-03-16 13:22:52 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {object} Phaser.Boot.Config#physics - [description]
|
|
|
|
*/
|
2017-08-18 00:42:14 +00:00
|
|
|
this.physics = GetValue(config, 'physics', {});
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#defaultPhysicsSystem - [description]
|
|
|
|
*/
|
2017-08-18 00:42:14 +00:00
|
|
|
this.defaultPhysicsSystem = GetValue(this.physics, 'default', false);
|
2017-08-15 22:34:39 +00:00
|
|
|
|
2018-01-19 16:56:41 +00:00
|
|
|
// Loader Defaults
|
2018-05-10 11:25:33 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#loaderBaseURL - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderBaseURL = GetValue(config, 'loader.baseURL', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#loaderPath - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderPath = GetValue(config, 'loader.path', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - [description]
|
|
|
|
*/
|
2018-05-02 16:23:51 +00:00
|
|
|
this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {(string|undefined)} Phaser.Boot.Config#loaderCrossOrigin - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#loaderResponseType - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderResponseType = GetValue(config, 'loader.responseType', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {boolean} Phaser.Boot.Config#loaderAsync - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderAsync = GetValue(config, 'loader.async', true);
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#loaderUser - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderUser = GetValue(config, 'loader.user', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#loaderPassword - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderPassword = GetValue(config, 'loader.password', '');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {integer} Phaser.Boot.Config#loaderTimeout - [description]
|
|
|
|
*/
|
2018-01-19 16:56:41 +00:00
|
|
|
this.loaderTimeout = GetValue(config, 'loader.timeout', 0);
|
|
|
|
|
2018-05-10 16:15:25 +00:00
|
|
|
// Plugins
|
2018-05-10 11:25:33 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
2018-05-10 16:15:25 +00:00
|
|
|
* @const {any} Phaser.Boot.Config#defaultPlugins - The plugins installed into every Scene (in addition to CoreScene and Global).
|
2018-05-08 08:17:13 +00:00
|
|
|
*/
|
2018-05-10 16:15:25 +00:00
|
|
|
this.defaultPlugins = Plugins.DefaultScene;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {any} Phaser.Boot.Config#installPlugins - [description]
|
|
|
|
*/
|
|
|
|
this.installPlugins = { global: [], scene: [], files: [] };
|
|
|
|
|
|
|
|
var plugins = GetValue(config, 'plugins', null);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allows `plugins` property to either be an array, in which case it just replaces
|
|
|
|
* the default plugins like previously.
|
|
|
|
*
|
|
|
|
* plugins: {
|
|
|
|
* install: [
|
|
|
|
* ModPlayerPlugin,
|
|
|
|
* WireFramePlugin
|
|
|
|
* ],
|
|
|
|
* filetypes: [
|
|
|
|
* MODFile
|
|
|
|
* OBJFile,
|
|
|
|
* ],
|
|
|
|
* default: [], OR
|
|
|
|
* defaultMerge: {
|
|
|
|
* 'ModPlayer': 'mod'
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* If an object, it checks for an 'install' property,
|
|
|
|
*/
|
|
|
|
if (plugins)
|
|
|
|
{
|
|
|
|
// Old 3.7 array format?
|
|
|
|
if (Array.isArray(plugins))
|
|
|
|
{
|
|
|
|
this.defaultPlugins = plugins;
|
|
|
|
}
|
|
|
|
else if (IsPlainObject(plugins))
|
|
|
|
{
|
|
|
|
this.installPlugins.global = GetFastValue(plugins, 'install', []);
|
|
|
|
|
|
|
|
if (Array.isArray(plugins.default))
|
|
|
|
{
|
|
|
|
this.defaultPlugins = plugins.default;
|
|
|
|
}
|
|
|
|
else if (Array.isArray(plugins.defaultMerge))
|
|
|
|
{
|
|
|
|
this.defaultPlugins = this.defaultPlugins.concat(plugins.defaultMerge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-18 05:16:02 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Default / Missing Images
|
|
|
|
var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg';
|
2017-03-28 22:56:00 +00:00
|
|
|
|
2018-05-08 08:17:13 +00:00
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#defaultImage - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==');
|
2018-05-08 08:17:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @const {string} Phaser.Boot.Config#missingImage - [description]
|
|
|
|
*/
|
2017-06-30 14:47:51 +00:00
|
|
|
this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==');
|
|
|
|
}
|
2016-11-24 01:35:02 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
});
|
2016-11-24 01:35:02 +00:00
|
|
|
|
|
|
|
module.exports = Config;
|