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}
|
|
|
|
*/
|
|
|
|
|
2017-01-25 12:01:52 +00:00
|
|
|
var MATH = require('../math');
|
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');
|
2017-02-04 05:39:37 +00:00
|
|
|
var GetObjectValue = require('../utils/object/GetObjectValue');
|
2017-02-11 08:18:22 +00:00
|
|
|
var ValueToColor = require('../graphics/color/ValueToColor');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
var defaultBannerColor = [
|
|
|
|
'#ff0000',
|
|
|
|
'#ffff00',
|
|
|
|
'#00ff00',
|
|
|
|
'#00ffff',
|
|
|
|
'#000000'
|
|
|
|
];
|
|
|
|
|
|
|
|
var defaultBannerTextColor = '#ffffff';
|
|
|
|
|
2017-01-16 22:43:46 +00:00
|
|
|
var Config = function (config)
|
2016-11-24 01:35:02 +00:00
|
|
|
{
|
|
|
|
if (config === undefined) { config = {}; }
|
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.width = GetObjectValue(config, 'width', 1024);
|
|
|
|
this.height = GetObjectValue(config, 'height', 768);
|
2017-02-04 18:02:31 +00:00
|
|
|
this.zoom = GetObjectValue(config, 'zoom', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.resolution = GetObjectValue(config, 'resolution', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.renderType = GetObjectValue(config, 'type', CONST.AUTO);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.parent = GetObjectValue(config, 'parent', null);
|
|
|
|
this.canvas = GetObjectValue(config, 'canvas', null);
|
|
|
|
this.canvasStyle = GetObjectValue(config, 'canvasStyle', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.stateConfig = GetObjectValue(config, 'state', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.seed = GetObjectValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-01-25 12:01:52 +00:00
|
|
|
MATH.RND.init(this.seed);
|
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.gameTitle = GetObjectValue(config, 'title', '');
|
|
|
|
this.gameURL = GetObjectValue(config, 'url', 'http://phaser.io');
|
|
|
|
this.gameVersion = GetObjectValue(config, 'version', '');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
// If you do: { banner: false } it won't display any banner at all
|
2017-01-16 22:43:46 +00:00
|
|
|
this.hideBanner = (GetObjectValue(config, 'banner', null) === false);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.hidePhaser = GetObjectValue(config, 'banner.hidePhaser', false);
|
|
|
|
this.bannerTextColor = GetObjectValue(config, 'banner.text', defaultBannerTextColor);
|
|
|
|
this.bannerBackgroundColor = GetObjectValue(config, 'banner.background', defaultBannerColor);
|
2016-11-29 15:25:14 +00:00
|
|
|
|
2017-01-25 17:10:19 +00:00
|
|
|
this.fps = GetObjectValue(config, 'fps', 60);
|
2016-11-29 13:01:05 +00:00
|
|
|
this.forceSetTimeOut = GetObjectValue(config, 'forceSetTimeOut', false);
|
2017-02-07 18:41:53 +00:00
|
|
|
|
2016-11-29 13:01:05 +00:00
|
|
|
this.pixelArt = GetObjectValue(config, 'pixelArt', false);
|
2017-02-07 18:41:53 +00:00
|
|
|
this.transparent = GetObjectValue(config, 'transparent', false);
|
|
|
|
this.clearBeforeRender = GetObjectValue(config, 'clearBeforeRender', true);
|
2017-02-11 08:18:22 +00:00
|
|
|
this.backgroundColor = ValueToColor(GetObjectValue(config, 'backgroundColor', 0));
|
2017-02-13 12:08:30 +00:00
|
|
|
this.preserveDrawingBuffer = ValueToColor(GetObjectValue(config, 'preserveDrawingBuffer', false));
|
2016-11-25 02:08:33 +00:00
|
|
|
|
2016-11-28 16:55:13 +00:00
|
|
|
// Callbacks
|
2016-11-29 13:01:05 +00:00
|
|
|
this.preBoot = GetObjectValue(config, 'callbacks.preBoot', NOOP);
|
|
|
|
this.postBoot = GetObjectValue(config, 'callbacks.postBoot', NOOP);
|
2017-02-07 12:43:20 +00:00
|
|
|
|
|
|
|
// Default / Missing Images
|
|
|
|
this.defaultImage = GetObjectValue(config, 'images.default', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==');
|
|
|
|
this.missingImage = GetObjectValue(config, 'images.missing', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==');
|
2017-01-16 22:43:46 +00:00
|
|
|
};
|
2016-11-24 01:35:02 +00:00
|
|
|
|
|
|
|
Config.prototype.constructor = Config;
|
|
|
|
|
|
|
|
module.exports = Config;
|