Skip to content

Commit b534803

Browse files
committed
Removed 'default' from State Settings to allow override from StateManager.add phaserjs#3029
1 parent 5522426 commit b534803

3 files changed

Lines changed: 42 additions & 8 deletions

File tree

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: 'd47a7c70-5daa-11e7-82ed-658705aa8112'
2+
build: 'c709d480-5fe1-11e7-96a8-9381099cfcf1'
33
};
44
module.exports = CHECKSUM;

v3/src/state/GlobalStateManager.js

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,15 @@ GlobalStateManager.prototype = {
147147
return;
148148
}
149149

150-
var ok = key;
150+
// var ok = key;
151151
key = this.getKey(key, stateConfig);
152152

153-
// console.log('GlobalStateManager.add', ok, key, stateConfig, autoStart);
153+
// console.group('GlobalStateManager.add');
154+
// console.log('add key:', ok);
155+
// console.log('config key:', key);
156+
// console.log('config:', stateConfig);
157+
// console.log('autoStart:', autoStart);
158+
// console.groupEnd();
154159

155160
var newState;
156161

@@ -175,9 +180,11 @@ GlobalStateManager.prototype = {
175180
newState = this.createStateFromFunction(key, stateConfig);
176181
}
177182

178-
// Replace key incase the state changed it
183+
// Replace key in case the state changed it
179184
key = newState.sys.settings.key;
180185

186+
// console.log('replaced key', key);
187+
181188
this.keys[key] = newState;
182189

183190
this.states.push(newState);
@@ -199,7 +206,16 @@ GlobalStateManager.prototype = {
199206

200207
createStateFromInstance: function (key, newState)
201208
{
202-
newState.sys.settings.key = key;
209+
var configKey = newState.sys.settings.key;
210+
211+
if (configKey !== '')
212+
{
213+
key = configKey;
214+
}
215+
else
216+
{
217+
newState.sys.settings.key = key;
218+
}
203219

204220
newState.sys.init(this.game);
205221

@@ -212,7 +228,16 @@ GlobalStateManager.prototype = {
212228
{
213229
var newState = new State(stateConfig);
214230

215-
newState.sys.settings.key = key;
231+
var configKey = newState.sys.settings.key;
232+
233+
if (configKey !== '')
234+
{
235+
key = configKey;
236+
}
237+
else
238+
{
239+
newState.sys.settings.key = key;
240+
}
216241

217242
newState.sys.init(this.game);
218243

@@ -223,11 +248,20 @@ GlobalStateManager.prototype = {
223248

224249
createStateFromFunction: function (key, state)
225250
{
251+
// console.log('createStateFromFunction', key);
252+
226253
var newState = new state();
227254

228255
if (newState instanceof State)
229256
{
230-
key = newState.sys.settings.key;
257+
// console.log('instanceof State');
258+
259+
var configKey = newState.sys.settings.key;
260+
261+
if (configKey !== '')
262+
{
263+
key = configKey;
264+
}
231265

232266
if (this.keys.hasOwnProperty(key))
233267
{

v3/src/state/Settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var Settings = {
2323

2424
op: CONST.BOOT,
2525

26-
key: GetValue(config, 'key', 'default'),
26+
key: GetValue(config, 'key', ''),
2727
active: GetValue(config, 'active', false),
2828
visible: GetValue(config, 'visible', true),
2929

0 commit comments

Comments
 (0)