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}
|
|
|
|
*/
|
|
|
|
|
2018-01-16 19:49:13 +00:00
|
|
|
var CONST = require('./const');
|
|
|
|
var GetValue = require('../utils/object/GetValue');
|
2017-06-29 23:32:18 +00:00
|
|
|
var InjectionMap = require('./InjectionMap');
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2018-03-22 12:51:30 +00:00
|
|
|
// TODO 22/03/2018 Fix "plugins" type
|
|
|
|
|
2018-02-12 15:18:31 +00:00
|
|
|
/**
|
2018-03-21 13:41:17 +00:00
|
|
|
* @typedef {object} SettingsConfig
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
2018-03-21 13:41:17 +00:00
|
|
|
* @property {string} [key] - [description]
|
|
|
|
* @property {boolean} [active=false] - [description]
|
|
|
|
* @property {boolean} [visible=true] - [description]
|
2018-03-22 12:51:30 +00:00
|
|
|
* @property {(false|LoaderFileObject[])} [files=false] - [description]
|
|
|
|
* @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description]
|
2018-03-21 13:41:17 +00:00
|
|
|
* @property {Object.<string, string>} [map] - [description]
|
|
|
|
* @property {object} [physics={}] - [description]
|
|
|
|
* @property {object} [loader={}] - [description]
|
2018-03-22 12:51:30 +00:00
|
|
|
* @property {(false|*)} [plugins=false] - [description]
|
2018-03-21 13:41:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {object} SettingsObject
|
2018-02-12 15:18:31 +00:00
|
|
|
*
|
2018-03-21 13:41:17 +00:00
|
|
|
* @property {number} status - [description]
|
|
|
|
* @property {string} key - [description]
|
|
|
|
* @property {boolean} active - [description]
|
|
|
|
* @property {boolean} visible - [description]
|
|
|
|
* @property {boolean} isBooted - [description]
|
|
|
|
* @property {object} data - [description]
|
2018-03-22 12:51:30 +00:00
|
|
|
* @property {(false|LoaderFileObject[])} files - [description]
|
|
|
|
* @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description]
|
2018-03-21 13:41:17 +00:00
|
|
|
* @property {Object.<string, string>} map - [description]
|
|
|
|
* @property {object} physics - [description]
|
|
|
|
* @property {object} loader - [description]
|
2018-03-22 12:51:30 +00:00
|
|
|
* @property {(false|*)} plugins - [description]
|
2018-02-12 15:18:31 +00:00
|
|
|
*/
|
2018-03-21 13:41:17 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
var Settings = {
|
|
|
|
|
2018-03-21 13:41:17 +00:00
|
|
|
/**
|
|
|
|
* Takes a Scene configuration object and returns a fully formed Systems object.
|
|
|
|
*
|
|
|
|
* @function Phaser.Scenes.Settings.create
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {(string|SettingsConfig)} config - [description]
|
|
|
|
*
|
|
|
|
* @return {SettingsObject} [description]
|
|
|
|
*/
|
2017-02-06 23:59:15 +00:00
|
|
|
create: function (config)
|
2016-11-29 13:01:16 +00:00
|
|
|
{
|
2017-02-06 23:59:15 +00:00
|
|
|
if (typeof config === 'string')
|
|
|
|
{
|
|
|
|
config = { key: config };
|
|
|
|
}
|
|
|
|
else if (config === undefined)
|
|
|
|
{
|
|
|
|
// Pass the 'hasOwnProperty' checks
|
|
|
|
config = {};
|
|
|
|
}
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
return {
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
status: CONST.PENDING,
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-07-03 11:24:18 +00:00
|
|
|
key: GetValue(config, 'key', ''),
|
2017-04-26 15:03:14 +00:00
|
|
|
active: GetValue(config, 'active', false),
|
|
|
|
visible: GetValue(config, 'visible', true),
|
2017-02-07 18:44:26 +00:00
|
|
|
|
2018-01-18 13:59:32 +00:00
|
|
|
isBooted: false,
|
|
|
|
|
2017-02-07 18:44:26 +00:00
|
|
|
// Loader payload array
|
|
|
|
|
2017-02-17 02:07:56 +00:00
|
|
|
data: {},
|
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
files: GetValue(config, 'files', false),
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-06-29 15:49:05 +00:00
|
|
|
// Cameras
|
2017-01-26 04:06:10 +00:00
|
|
|
|
2017-06-29 15:49:05 +00:00
|
|
|
cameras: GetValue(config, 'cameras', null),
|
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
// Scene Property Injection Map
|
2017-06-29 23:32:18 +00:00
|
|
|
|
|
|
|
map: GetValue(config, 'map', InjectionMap),
|
|
|
|
|
2017-08-18 00:42:14 +00:00
|
|
|
// Physics
|
2018-01-18 05:18:45 +00:00
|
|
|
|
2017-08-18 00:42:14 +00:00
|
|
|
physics: GetValue(config, 'physics', {}),
|
|
|
|
|
2018-01-19 16:56:41 +00:00
|
|
|
// Loader
|
|
|
|
|
|
|
|
loader: GetValue(config, 'loader', {}),
|
|
|
|
|
2018-01-18 05:18:45 +00:00
|
|
|
// Plugins
|
|
|
|
|
2018-01-20 04:47:03 +00:00
|
|
|
plugins: GetValue(config, 'plugins', false)
|
2017-02-06 23:59:15 +00:00
|
|
|
|
|
|
|
};
|
2017-06-29 15:49:05 +00:00
|
|
|
}
|
2017-02-06 23:59:15 +00:00
|
|
|
|
2016-11-29 13:01:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Settings;
|