2016-11-24 01:35:02 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2016-11-24 15:40:05 +00:00
|
|
|
var CONST = require('../const');
|
2016-11-28 16:55:13 +00:00
|
|
|
var NOOP = require('../utils/NOOP');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
var defaultBannerColor = [
|
|
|
|
'#ff0000',
|
|
|
|
'#ffff00',
|
|
|
|
'#00ff00',
|
|
|
|
'#00ffff',
|
|
|
|
'#000000'
|
|
|
|
];
|
|
|
|
|
|
|
|
var defaultBannerTextColor = '#ffffff';
|
|
|
|
|
|
|
|
function getValue (obj, key, def)
|
|
|
|
{
|
|
|
|
if (obj.hasOwnProperty(key))
|
|
|
|
{
|
|
|
|
return obj[key];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
2016-11-24 01:35:02 +00:00
|
|
|
|
|
|
|
function Config (config)
|
|
|
|
{
|
|
|
|
if (config === undefined) { config = {}; }
|
|
|
|
|
2016-11-24 15:40:05 +00:00
|
|
|
this.width = getValue(config, 'width', 1024);
|
|
|
|
this.height = getValue(config, 'height', 768);
|
|
|
|
|
|
|
|
this.resolution = getValue(config, 'resolution', 1);
|
|
|
|
|
|
|
|
this.renderType = getValue(config, 'type', CONST.AUTO);
|
|
|
|
|
|
|
|
this.parent = getValue(config, 'parent', null);
|
|
|
|
|
|
|
|
this.stateConfig = getValue(config, 'state', null);
|
|
|
|
|
2016-11-25 05:12:02 +00:00
|
|
|
this.seed = getValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
this.gameTitle = getValue(config, 'title', '');
|
|
|
|
this.gameURL = getValue(config, 'url', 'http://phaser.io');
|
|
|
|
this.gameVersion = getValue(config, 'version', '');
|
|
|
|
|
|
|
|
// If you do: { banner: false } it won't display any banner at all
|
|
|
|
var banner = getValue(config, 'banner', null);
|
|
|
|
|
|
|
|
this.hideBanner = (banner === false);
|
|
|
|
|
|
|
|
if (!banner)
|
|
|
|
{
|
|
|
|
// Use the default banner set-up
|
|
|
|
banner = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
this.hidePhaser = getValue(banner, 'hidePhaser', false);
|
|
|
|
this.bannerTextColor = getValue(banner, 'text', defaultBannerTextColor);
|
|
|
|
this.bannerBackgroundColor = getValue(banner, 'background', defaultBannerColor);
|
2016-11-25 00:34:37 +00:00
|
|
|
|
|
|
|
this.forceSetTimeOut = getValue(config, 'forceSetTimeOut', false);
|
|
|
|
|
2016-11-25 02:08:33 +00:00
|
|
|
this.transparent = getValue(config, 'transparent', false);
|
|
|
|
|
|
|
|
this.pixelArt = getValue(config, 'pixelArt', false);
|
|
|
|
|
2016-11-28 16:55:13 +00:00
|
|
|
// Callbacks
|
|
|
|
|
|
|
|
var callbacks = getValue(config, 'callbacks', null);
|
|
|
|
|
|
|
|
if (!callbacks)
|
|
|
|
{
|
|
|
|
// Use the default banner set-up
|
|
|
|
callbacks = {};
|
|
|
|
}
|
|
|
|
|
2016-11-29 10:46:35 +00:00
|
|
|
this.preBoot = getValue(callbacks, 'preBoot', NOOP);
|
|
|
|
this.postBoot = getValue(callbacks, 'postBoot', NOOP);
|
2016-11-28 16:55:13 +00:00
|
|
|
|
2016-11-24 01:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Config.prototype.constructor = Config;
|
|
|
|
|
|
|
|
module.exports = Config;
|