2017-01-20 02:28:55 +00:00
|
|
|
var CONST = require('./const');
|
2017-01-18 14:48:02 +00:00
|
|
|
var ScaleModes = require('../renderer/ScaleModes');
|
2017-04-26 15:03:14 +00:00
|
|
|
var GetValue = require('../utils/object/GetValue');
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
var Settings = {
|
|
|
|
|
|
|
|
create: function (config)
|
2016-11-29 13:01:16 +00:00
|
|
|
{
|
2017-02-06 23:59:15 +00:00
|
|
|
if (typeof config === 'string')
|
|
|
|
{
|
|
|
|
config = { key: config };
|
|
|
|
}
|
|
|
|
else if (config === undefined)
|
|
|
|
{
|
|
|
|
// Pass the 'hasOwnProperty' checks
|
|
|
|
config = {};
|
|
|
|
}
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
return {
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
status: CONST.PENDING,
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
op: CONST.BOOT,
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
key: GetValue(config, 'key', ''),
|
|
|
|
active: GetValue(config, 'active', false),
|
|
|
|
visible: GetValue(config, 'visible', true),
|
2017-02-07 18:44:26 +00:00
|
|
|
|
|
|
|
// Loader payload array
|
|
|
|
|
2017-02-17 02:07:56 +00:00
|
|
|
data: {},
|
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
files: GetValue(config, 'files', false),
|
2016-11-29 13:01:16 +00:00
|
|
|
|
2017-02-06 23:59:15 +00:00
|
|
|
// -1 means the State Manager will set it to be the Game dimensions
|
2017-01-26 04:06:10 +00:00
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
x: GetValue(config, 'x', 0),
|
|
|
|
y: GetValue(config, 'y', 0),
|
|
|
|
rotation: GetValue(config, 'rotation', 0),
|
|
|
|
width: GetValue(config, 'width', -1),
|
|
|
|
height: GetValue(config, 'height', -1),
|
2017-01-20 02:28:55 +00:00
|
|
|
|
2017-02-07 18:44:26 +00:00
|
|
|
// State Render Settings (applies only to this State)
|
2017-01-20 02:28:55 +00:00
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
scaleMode: GetValue(config, 'scaleMode', ScaleModes.DEFAULT),
|
|
|
|
roundPixels: GetValue(config, 'roundPixels', false),
|
2017-02-07 12:54:51 +00:00
|
|
|
|
2017-04-26 15:03:14 +00:00
|
|
|
dirtyRender: GetValue(config, 'dirtyRender', false),
|
|
|
|
renderToTexture: GetValue(config, 'renderToTexture', false),
|
2017-02-07 18:44:26 +00:00
|
|
|
|
|
|
|
// The following only apply if renderToTexture is true
|
2017-02-07 12:54:51 +00:00
|
|
|
|
2017-06-28 00:50:49 +00:00
|
|
|
autoResize: GetValue(config, 'autoResize', false)
|
2017-02-06 23:59:15 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function (config, gameConfig)
|
|
|
|
{
|
|
|
|
if (config.width === -1)
|
|
|
|
{
|
|
|
|
config.width = gameConfig.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.height === -1)
|
|
|
|
{
|
|
|
|
config.height = gameConfig.height;
|
|
|
|
}
|
|
|
|
}
|
2017-01-20 02:28:55 +00:00
|
|
|
|
2016-11-29 13:01:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Settings;
|