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');
|
2017-04-26 15:03:14 +00:00
|
|
|
var GetValue = require('../utils/object/GetValue');
|
2017-06-30 14:47:51 +00:00
|
|
|
var MATH = require('../math');
|
|
|
|
var NOOP = require('../utils/NOOP');
|
2017-02-11 08:18:22 +00:00
|
|
|
var ValueToColor = require('../graphics/color/ValueToColor');
|
2016-11-24 15:40:05 +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
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.width = GetValue(config, 'width', 1024);
|
|
|
|
this.height = GetValue(config, 'height', 768);
|
|
|
|
this.zoom = GetValue(config, 'zoom', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.resolution = GetValue(config, 'resolution', 1);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.renderType = GetValue(config, 'type', CONST.AUTO);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.parent = GetValue(config, 'parent', null);
|
|
|
|
this.canvas = GetValue(config, 'canvas', null);
|
|
|
|
this.canvasStyle = GetValue(config, 'canvasStyle', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-07-14 13:30:20 +00:00
|
|
|
this.sceneConfig = GetValue(config, 'scene', null);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
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
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.gameTitle = GetValue(config, 'title', '');
|
|
|
|
this.gameURL = GetValue(config, 'url', 'http://phaser.io');
|
|
|
|
this.gameVersion = GetValue(config, 'version', '');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Input
|
|
|
|
this.inputKeyboard = GetValue(config, 'input.keyboard', true);
|
|
|
|
this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window);
|
2017-02-21 01:04:11 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.inputMouse = GetValue(config, 'input.mouse', true);
|
|
|
|
this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null);
|
2017-06-12 23:38:48 +00:00
|
|
|
|
2017-07-28 02:28:10 +00:00
|
|
|
this.inputTouch = GetValue(config, 'input.touch', true);
|
|
|
|
this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null);
|
|
|
|
|
2017-07-25 11:33:37 +00:00
|
|
|
this.disableContextMenu = GetValue(config, 'disableContextMenu', false);
|
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// If you do: { banner: false } it won't display any banner at all
|
|
|
|
this.hideBanner = (GetValue(config, 'banner', null) === false);
|
2016-11-24 15:40:05 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.hidePhaser = GetValue(config, 'banner.hidePhaser', false);
|
|
|
|
this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor);
|
|
|
|
this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor);
|
|
|
|
|
|
|
|
// Frame Rate config
|
|
|
|
// fps: {
|
|
|
|
// min: 10,
|
|
|
|
// target: 60,
|
2017-08-10 02:44:26 +00:00
|
|
|
// max: 120,
|
2017-06-30 14:47:51 +00:00
|
|
|
// forceSetTimeOut: false,
|
|
|
|
// deltaHistory: 10
|
|
|
|
// }
|
2017-05-03 16:07:15 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.fps = GetValue(config, 'fps', null);
|
2017-02-07 18:41:53 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.pixelArt = GetValue(config, 'pixelArt', false);
|
|
|
|
this.transparent = GetValue(config, 'transparent', false);
|
|
|
|
this.clearBeforeRender = GetValue(config, 'clearBeforeRender', true);
|
|
|
|
this.backgroundColor = ValueToColor(GetValue(config, 'backgroundColor', 0));
|
|
|
|
this.preserveDrawingBuffer = ValueToColor(GetValue(config, 'preserveDrawingBuffer', false));
|
2016-11-25 02:08:33 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
// Callbacks
|
|
|
|
this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP);
|
|
|
|
this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP);
|
2017-02-07 12:43:20 +00:00
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.useTicker = GetValue(config, 'useTicker', false);
|
2017-04-27 02:11:56 +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
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==');
|
|
|
|
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;
|