2017-08-18 00:42:14 +00:00
|
|
|
var Scene = require('../../local/Scene');
|
2017-07-14 13:30:20 +00:00
|
|
|
|
|
|
|
// private
|
|
|
|
var GetKey = function (key, sceneConfig)
|
|
|
|
{
|
|
|
|
if (!key) { key = 'default'; }
|
|
|
|
|
|
|
|
if (typeof sceneConfig === 'function')
|
|
|
|
{
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
else if (sceneConfig instanceof Scene)
|
|
|
|
{
|
|
|
|
key = sceneConfig.sys.settings.key;
|
|
|
|
}
|
|
|
|
else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key'))
|
|
|
|
{
|
|
|
|
key = sceneConfig.key;
|
|
|
|
}
|
|
|
|
|
|
|
|
// By this point it's either 'default' or extracted from the Scene
|
|
|
|
|
|
|
|
if (this.keys.hasOwnProperty(key))
|
|
|
|
{
|
|
|
|
throw new Error('Cannot add a Scene with duplicate key: ' + key);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetKey;
|