|
| 1 | +var CONST = require('../CONST'); |
| 2 | +var STATE_CONST = require('./STATE_CONST'); |
| 3 | +var GetObjectValue = require('../utils/GetObjectValue'); |
| 4 | + |
| 5 | +var Settings = function (state, config) |
| 6 | +{ |
| 7 | + if (typeof config === 'string') |
| 8 | + { |
| 9 | + config = { key: config }; |
| 10 | + } |
| 11 | + else if (config === undefined) |
| 12 | + { |
| 13 | + // Pass the 'hasOwnProperty' checks |
| 14 | + config = {}; |
| 15 | + } |
| 16 | + |
| 17 | + this.state = state; // Do we actually need this reference? This could just be a property bucket |
| 18 | + |
| 19 | + this.status = STATE_CONST.PENDING; |
| 20 | + |
| 21 | + // Which part of this State is currently being processed? |
| 22 | + // preload, create, update, shutdown, etc |
| 23 | + this.op = STATE_CONST.BOOT; |
| 24 | + |
| 25 | + this.key = GetObjectValue(config, 'key', ''); |
| 26 | + this.active = GetObjectValue(config, 'active', false); |
| 27 | + this.visible = GetObjectValue(config, 'visible', true); |
| 28 | + this.scaleMode = GetObjectValue(config, 'scaleMode', CONST.scaleModes.DEFAULT); |
| 29 | + this.fps = GetObjectValue(config, 'fps', 60); |
| 30 | + this.x = GetObjectValue(config, 'x', 0); |
| 31 | + this.y = GetObjectValue(config, 'y', 0); |
| 32 | + |
| 33 | + // -1 means the State Manager will set it to be the Game dimensions |
| 34 | + this.width = GetObjectValue(config, 'width', -1); |
| 35 | + this.height = GetObjectValue(config, 'height', -1); |
| 36 | +}; |
| 37 | + |
| 38 | +// Unless we add some actual functions in here, we'll make this just return an Object instead of an instance |
| 39 | +Settings.prototype.constructor = Settings; |
| 40 | + |
| 41 | +module.exports = Settings; |
0 commit comments