var Class = require('../utils/Class'); var CONST = require('../const'); var GetValue = require('../utils/object/GetValue'); var MATH = require('../math/const'); var NOOP = require('../utils/NOOP'); var Plugins = require('../plugins'); var ValueToColor = require('../display/color/ValueToColor'); var Config = new Class({ initialize: function Config(config){ if (config === undefined) { config = { } ; } var defaultBannerColor = ['#ff0000', '#ffff00', '#00ff00', '#00ffff', '#000000'] ; var defaultBannerTextColor = '#ffffff'; this.width = GetValue(config, 'width', 1024); this.height = GetValue(config, 'height', 768); this.zoom = GetValue(config, 'zoom', 1); this.resolution = GetValue(config, 'resolution', 1); this.renderType = GetValue(config, 'type', CONST.AUTO); this.parent = GetValue(config, 'parent', null ); this.canvas = GetValue(config, 'canvas', null ); this.canvasStyle = GetValue(config, 'canvasStyle', null ); this.sceneConfig = GetValue(config, 'scene', null ); this.seed = GetValue(config, 'seed', [(Date.now() * Math.random()).toString()] ); _AN_Call_init('init', MATH.RND, this.seed); this.gameTitle = GetValue(config, 'title', ''); this.gameURL = GetValue(config, 'url', 'https://phaser.io'); this.gameVersion = GetValue(config, 'version', ''); this.inputKeyboard = GetValue(config, 'input.keyboard', true ); this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); this.inputMouse = GetValue(config, 'input.mouse', true ); this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null ); this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true ); this.inputTouch = GetValue(config, 'input.touch', true ); this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null ); this.inputTouchCapture = GetValue(config, 'input.touch.capture', true ); this.inputGamepad = GetValue(config, 'input.gamepad', false ); this.disableContextMenu = GetValue(config, 'disableContextMenu', false ); this.audio = GetValue(config, 'audio'); this.hideBanner = (GetValue(config, 'banner', null ) === false ); this.hidePhaser = GetValue(config, 'banner.hidePhaser', false ); this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); if (this.gameTitle === '' && this.hidePhaser) { this.hideBanner = true ; } this.fps = GetValue(config, 'fps', null ); 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.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); this.physics = GetValue(config, 'physics', { } ); this.defaultPhysicsSystem = GetValue(this.physics, 'default', false ); this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); this.loaderPath = GetValue(config, 'loader.path', ''); this.loaderEnableParallel = GetValue(config, 'loader.enableParallel', true ); this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 4); this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); this.loaderResponseType = GetValue(config, 'loader.responseType', ''); this.loaderAsync = GetValue(config, 'loader.async', true ); this.loaderUser = GetValue(config, 'loader.user', ''); this.loaderPassword = GetValue(config, 'loader.password', ''); this.loaderTimeout = GetValue(config, 'loader.timeout', 0); this.defaultPlugins = GetValue(config, 'plugins', Plugins.DefaultScene); var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; 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=='); } } ); module.exports = Config;