/** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ var CONST = require('./const'); var GetValue = require('../utils/object/GetValue'); var InjectionMap = require('./InjectionMap'); /** * @typedef {object} SettingsConfig * * @property {string} [key] - [description] * @property {boolean} [active=false] - [description] * @property {boolean} [visible=true] - [description] * @property {(false|[type])} [files=false] - [description] * @property {?[type]} [cameras=null] - [description] * @property {Object.} [map] - [description] * @property {object} [physics={}] - [description] * @property {object} [loader={}] - [description] * @property {(false|[type])} [plugins=false] - [description] */ /** * @typedef {object} SettingsObject * * @property {number} status - [description] * @property {string} key - [description] * @property {boolean} active - [description] * @property {boolean} visible - [description] * @property {boolean} isBooted - [description] * @property {object} data - [description] * @property {(false|[type])} files - [description] * @property {?[type]} cameras - [description] * @property {Object.} map - [description] * @property {object} physics - [description] * @property {object} loader - [description] * @property {(false|[type])} plugins - [description] */ var Settings = { /** * 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] */ create: function (config) { if (typeof config === 'string') { config = { key: config }; } else if (config === undefined) { // Pass the 'hasOwnProperty' checks config = {}; } return { status: CONST.PENDING, key: GetValue(config, 'key', ''), active: GetValue(config, 'active', false), visible: GetValue(config, 'visible', true), isBooted: false, // Loader payload array data: {}, files: GetValue(config, 'files', false), // Cameras cameras: GetValue(config, 'cameras', null), // Scene Property Injection Map map: GetValue(config, 'map', InjectionMap), // Physics physics: GetValue(config, 'physics', {}), // Loader loader: GetValue(config, 'loader', {}), // Plugins plugins: GetValue(config, 'plugins', false) }; } }; module.exports = Settings;