2016-11-29 15:25:14 +00:00
|
|
|
var CONST = require('../const');
|
2017-01-18 14:48:02 +00:00
|
|
|
var ScaleModes = require('../renderer/ScaleModes');
|
2016-11-29 13:01:16 +00:00
|
|
|
var GetObjectValue = require('../utils/GetObjectValue');
|
|
|
|
|
|
|
|
var Settings = function (state, config)
|
|
|
|
{
|
|
|
|
if (typeof config === 'string')
|
|
|
|
{
|
|
|
|
config = { key: config };
|
|
|
|
}
|
|
|
|
else if (config === undefined)
|
|
|
|
{
|
|
|
|
// Pass the 'hasOwnProperty' checks
|
|
|
|
config = {};
|
|
|
|
}
|
|
|
|
|
|
|
|
this.state = state; // Do we actually need this reference? This could just be a property bucket
|
|
|
|
|
2016-11-29 15:25:14 +00:00
|
|
|
this.status = CONST.state.PENDING;
|
2016-11-29 13:01:16 +00:00
|
|
|
|
|
|
|
// Which part of this State is currently being processed?
|
|
|
|
// preload, create, update, shutdown, etc
|
2016-11-29 15:25:14 +00:00
|
|
|
this.op = CONST.state.BOOT;
|
2016-11-29 13:01:16 +00:00
|
|
|
|
|
|
|
this.key = GetObjectValue(config, 'key', '');
|
|
|
|
this.active = GetObjectValue(config, 'active', false);
|
|
|
|
this.visible = GetObjectValue(config, 'visible', true);
|
2017-01-18 14:48:02 +00:00
|
|
|
this.scaleMode = GetObjectValue(config, 'scaleMode', ScaleModes.DEFAULT);
|
2016-11-29 13:01:16 +00:00
|
|
|
this.fps = GetObjectValue(config, 'fps', 60);
|
|
|
|
this.x = GetObjectValue(config, 'x', 0);
|
|
|
|
this.y = GetObjectValue(config, 'y', 0);
|
|
|
|
|
|
|
|
// -1 means the State Manager will set it to be the Game dimensions
|
|
|
|
this.width = GetObjectValue(config, 'width', -1);
|
|
|
|
this.height = GetObjectValue(config, 'height', -1);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Unless we add some actual functions in here, we'll make this just return an Object instead of an instance
|
|
|
|
Settings.prototype.constructor = Settings;
|
|
|
|
|
|
|
|
module.exports = Settings;
|