@urso/core 0.3.3 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/components/debug/_info.js +2 -1
- package/src/js/components/debug/controller.js +1 -1
- package/src/js/components/debug/template.js +22 -0
- package/src/js/components/debug/timescale.js +60 -0
- package/src/js/components/stateDriven/controller.js +33 -11
- package/src/js/lib/math.js +15 -0
- package/src/js/modules/objects/models/checkbox.js +5 -4
- package/src/js/modules/objects/models/spine.js +10 -4
- package/src/js/modules/objects/models/textInput.js +12 -1
- package/src/js/modules/objects/models/toggle.js +26 -17
- package/src/js/modules/objects/proxy.js +4 -1
- package/src/js/modules/observer/events.js +1 -0
- package/src/js/modules/scenes/controller.js +8 -0
- package/src/js/modules/scenes/pixiWrapper.js +1 -1
- package/src/js/modules/scenes/service.js +11 -3
- package/src/js/modules/statesManager/controller.js +42 -12
- package/src/js/modules/transport/config.js +6 -15
- package/src/js/modules/transport/connectionTypes/xhr.js +5 -2
- package/src/js/modules/transport/decorator.js +2 -1
- package/src/js/modules/transport/service.js +39 -26
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ class ComponentsDebugController extends ComponentsBaseController {
|
|
|
5
5
|
super(params);
|
|
6
6
|
|
|
7
7
|
this._logicBlocks = [
|
|
8
|
-
'coords', 'fps', /*'renderStats', 'resolution'*/ //TODO
|
|
8
|
+
'coords', 'fps', 'timescale' /*'renderStats', 'resolution'*/ //TODO
|
|
9
9
|
];
|
|
10
10
|
|
|
11
11
|
this._visible = true;
|
|
@@ -22,6 +22,28 @@ class ComponentsDebugTemplate {
|
|
|
22
22
|
fontFamily: 'Helvetica',
|
|
23
23
|
fontSize: 15,
|
|
24
24
|
fill: '#00FF00'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: Urso.types.objects.TEXT,
|
|
28
|
+
name: 'debugTimescaleValue',
|
|
29
|
+
text: '1',
|
|
30
|
+
x: '50%',
|
|
31
|
+
y: '30%',
|
|
32
|
+
visible: false,
|
|
33
|
+
anchorX: 0.5,
|
|
34
|
+
anchorY: 0.5,
|
|
35
|
+
fontFamily: 'Verdana',
|
|
36
|
+
fontSize: 100,
|
|
37
|
+
fontStyle: 'italic',
|
|
38
|
+
fontWeight: 'bold',
|
|
39
|
+
fill: ['#ffffff', '#00ff99'], // gradient
|
|
40
|
+
stroke: '#4a1850',
|
|
41
|
+
strokeThickness: 5,
|
|
42
|
+
dropShadow: true,
|
|
43
|
+
dropShadowColor: '#000000',
|
|
44
|
+
dropShadowBlur: 4,
|
|
45
|
+
dropShadowAngle: Math.PI / 6,
|
|
46
|
+
dropShadowDistance: 6,
|
|
25
47
|
}
|
|
26
48
|
]
|
|
27
49
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
class ComponentsDebugTimescale {
|
|
2
|
+
|
|
3
|
+
constructor() {
|
|
4
|
+
this._timescaleText;
|
|
5
|
+
|
|
6
|
+
this.create = this.create.bind(this);
|
|
7
|
+
|
|
8
|
+
this.scaleStep = 0.5;
|
|
9
|
+
this.scaleInfoDuration = 2000;
|
|
10
|
+
|
|
11
|
+
this._minusButtonsCodes = [109, 189];
|
|
12
|
+
this._plusButtonsCodes = [107, 187];
|
|
13
|
+
this._hideId;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
create() {
|
|
17
|
+
document.addEventListener('keydown', this.keyPressTest.bind(this));
|
|
18
|
+
this._timescaleText = this.common.findOne('^debugTimescaleValue');
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
keyPressTest(e) {
|
|
23
|
+
const evtobj = window.event ? event : e;
|
|
24
|
+
|
|
25
|
+
if (!evtobj.altKey) //alt and +/-
|
|
26
|
+
return;
|
|
27
|
+
|
|
28
|
+
let factor = 0;
|
|
29
|
+
|
|
30
|
+
if (this._minusButtonsCodes.includes(evtobj.keyCode)) {
|
|
31
|
+
factor = -1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (this._plusButtonsCodes.includes(evtobj.keyCode)) {
|
|
35
|
+
factor = 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!factor)
|
|
39
|
+
return;
|
|
40
|
+
|
|
41
|
+
const timescaleDiff = Urso.scenes.timeScale >= 1 ? this.scaleStep * factor : (this.scaleStep * factor) * 0.1;
|
|
42
|
+
let timescaleNewValue = Urso.scenes.timeScale + timescaleDiff;
|
|
43
|
+
|
|
44
|
+
if (timescaleNewValue < 0.1)
|
|
45
|
+
timescaleNewValue = 0.1;
|
|
46
|
+
|
|
47
|
+
Urso.scenes.timeScale = Urso.math.roundToDigits(timescaleNewValue, 2);
|
|
48
|
+
|
|
49
|
+
this._timescaleText.text = Urso.scenes.timeScale;
|
|
50
|
+
this._timescaleText.visible = true;
|
|
51
|
+
|
|
52
|
+
if (this._hideId)
|
|
53
|
+
clearTimeout(this._hideId);
|
|
54
|
+
|
|
55
|
+
this._hideId = setTimeout(() => this._timescaleText.visible = false, this.scaleInfoDuration);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = ComponentsDebugTimescale;
|
|
@@ -23,6 +23,13 @@ class ComponentsStateDrivenController extends ComponentsBaseController {
|
|
|
23
23
|
//system callbacks storage
|
|
24
24
|
_finishCallbacks = {};
|
|
25
25
|
|
|
26
|
+
_callbacksCache = {
|
|
27
|
+
stateGuards: {},
|
|
28
|
+
actionTerminates: {},
|
|
29
|
+
actionGuards: {},
|
|
30
|
+
actionRuns: {}
|
|
31
|
+
};
|
|
32
|
+
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* caller for delayed finish callback
|
|
@@ -40,7 +47,8 @@ class ComponentsStateDrivenController extends ComponentsBaseController {
|
|
|
40
47
|
|
|
41
48
|
_processStates() {
|
|
42
49
|
for (const stateKey in this.configStates) {
|
|
43
|
-
|
|
50
|
+
this._callbacksCache.stateGuards[stateKey] = this.configStates[stateKey].guard.bind(this);
|
|
51
|
+
Urso.statesManager.setStateGuard(stateKey, this._callbacksCache.stateGuards[stateKey]);
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
|
|
@@ -50,21 +58,27 @@ class ComponentsStateDrivenController extends ComponentsBaseController {
|
|
|
50
58
|
//const actionCfg = this.getInstance('ActionConfig', this.configActions[actionKey]);
|
|
51
59
|
const actionCfg = this.configActions[actionKey];
|
|
52
60
|
|
|
53
|
-
if (actionCfg.run)
|
|
54
|
-
|
|
61
|
+
if (actionCfg.run) {
|
|
62
|
+
this._callbacksCache.actionRuns[actionKey] = (finish) => {
|
|
55
63
|
this._saveFinish(actionKey, finish);
|
|
56
64
|
actionCfg.run(() => this.callFinish(actionKey));
|
|
57
|
-
}
|
|
58
|
-
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Urso.statesManager.addActionRun(actionKey, this._callbacksCache.actionRuns[actionKey]);
|
|
68
|
+
} else {
|
|
59
69
|
Urso.logger.error('ComponentsStateDrivenController: no run function in config', actionKey, this);
|
|
60
70
|
continue;
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
if (actionCfg.terminate)
|
|
64
|
-
|
|
73
|
+
if (actionCfg.terminate) {
|
|
74
|
+
this._callbacksCache.actionTerminates[actionKey] = actionCfg.terminate.bind(this);
|
|
75
|
+
Urso.statesManager.addActionTerminate(actionKey, this._callbacksCache.actionTerminates[actionKey]);
|
|
76
|
+
}
|
|
65
77
|
|
|
66
|
-
if (actionCfg.guard)
|
|
67
|
-
|
|
78
|
+
if (actionCfg.guard) {
|
|
79
|
+
this._callbacksCache.actionGuards[actionKey] = actionCfg.guard.bind(this);
|
|
80
|
+
Urso.statesManager.addActionGuard(actionKey, this._callbacksCache.actionGuards[actionKey]);
|
|
81
|
+
}
|
|
68
82
|
}
|
|
69
83
|
}
|
|
70
84
|
|
|
@@ -86,9 +100,17 @@ class ComponentsStateDrivenController extends ComponentsBaseController {
|
|
|
86
100
|
this._processActions();
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
//todo
|
|
90
103
|
destroy() {
|
|
91
|
-
Urso.
|
|
104
|
+
this._removeCallback(Urso.statesManager.removeStateGuard, this._callbacksCache.stateGuards);
|
|
105
|
+
this._removeCallback(Urso.statesManager.removeActionGuard, this._callbacksCache.actionGuards);
|
|
106
|
+
this._removeCallback(Urso.statesManager.removeActionTerminate, this._callbacksCache.actionTerminates);
|
|
107
|
+
this._removeCallback(Urso.statesManager.removeActionRun, this._callbacksCache.actionRuns);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_removeCallback(remover, cacheObject) {
|
|
111
|
+
for (let cacheKey in cacheObject) {
|
|
112
|
+
remover(cacheKey, cacheObject[cacheKey]);
|
|
113
|
+
}
|
|
92
114
|
}
|
|
93
115
|
|
|
94
116
|
}
|
package/src/js/lib/math.js
CHANGED
|
@@ -16,6 +16,21 @@ class LibMath {
|
|
|
16
16
|
getRandomIntBetween(min, max) {
|
|
17
17
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
18
18
|
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* round float number to digits count
|
|
22
|
+
* @param {Number} num
|
|
23
|
+
* @param {Number} digits - rounding digits count
|
|
24
|
+
* @returns {Number}
|
|
25
|
+
*/
|
|
26
|
+
roundToDigits(num, digits) {
|
|
27
|
+
if (isNaN(num) || isNaN(digits))
|
|
28
|
+
return false;
|
|
29
|
+
|
|
30
|
+
const pow = Math.pow(10, digits);
|
|
31
|
+
return Math.round(num * pow) / pow;
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
}
|
|
20
35
|
|
|
21
36
|
module.exports = LibMath;
|
|
@@ -22,7 +22,7 @@ class ModulesObjectsModelsCheckbox extends UrsoCoreModulesObjectsModelsToggle {
|
|
|
22
22
|
this.contents = [];
|
|
23
23
|
|
|
24
24
|
this.action = Urso.helper.recursiveGet('action', params, () => {
|
|
25
|
-
this.emit(Urso.events.MODULES_OBJECTS_CHECKBOX_PRESS, { name: this.name, status: this.
|
|
25
|
+
this.emit(Urso.events.MODULES_OBJECTS_CHECKBOX_PRESS, { name: this.name, status: this.status, class: this.class })
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
this.lable = Urso.helper.recursiveGet('lable', params, false);
|
|
@@ -31,7 +31,7 @@ class ModulesObjectsModelsCheckbox extends UrsoCoreModulesObjectsModelsToggle {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
_createCheckbox() {
|
|
34
|
-
this.
|
|
34
|
+
this.status = this.defaultStatus;
|
|
35
35
|
this._checkbox = this._createObject(this.buttonFrames[`${this.defaultStatus}Out`])
|
|
36
36
|
|
|
37
37
|
if (this.lable)
|
|
@@ -77,14 +77,15 @@ class ModulesObjectsModelsCheckbox extends UrsoCoreModulesObjectsModelsToggle {
|
|
|
77
77
|
|
|
78
78
|
_changeTexture(key) {
|
|
79
79
|
if (!this.buttonFrames[key]) {
|
|
80
|
-
if (key === `${this.
|
|
80
|
+
if (key === `${this.status}Out`) {
|
|
81
81
|
Urso.logger.error('ModulesObjectsModelsButton assets error: no out image ' + this.buttonFrames.out);
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
this._changeTexture(`${this.
|
|
85
|
+
this._changeTexture(`${this.status}Out`); // load default texture for this key
|
|
86
86
|
return false;
|
|
87
87
|
}
|
|
88
|
+
|
|
88
89
|
if (this.buttonFrames[key].type === Urso.types.objects.GRAPHICS)
|
|
89
90
|
this._drawGraphics(this.buttonFrames[key].figure);
|
|
90
91
|
else
|
|
@@ -17,6 +17,8 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
17
17
|
loop: Urso.helper.recursiveGet('animation.loop', params, false),
|
|
18
18
|
onComplete: Urso.helper.recursiveGet('animation.onComplete', params, false)
|
|
19
19
|
};
|
|
20
|
+
|
|
21
|
+
params.animation = this.animation; //we redefine original property here
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
play(animationName, loopFlag = false, track = 0) {
|
|
@@ -53,11 +55,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
53
55
|
...config
|
|
54
56
|
};
|
|
55
57
|
|
|
56
|
-
if (config.timeScale)
|
|
57
|
-
this._baseObject.state.timeScale = config.timeScale
|
|
58
|
+
/*if (config.timeScale)
|
|
59
|
+
this._baseObject.state.timeScale = config.timeScale;*/ //deprecated - now we use getTimeScale getter
|
|
58
60
|
|
|
59
61
|
if (config.onComplete) {
|
|
60
|
-
window.asd = this._baseObject.state
|
|
61
62
|
this._baseObject.state.clearListeners();
|
|
62
63
|
this._baseObject.state.addListener({ complete: this.animation.onComplete });
|
|
63
64
|
}
|
|
@@ -70,7 +71,8 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
70
71
|
Urso.logger.error('ModulesObjectsModelsSpine assets error: no spine object ' + this.assetKey);
|
|
71
72
|
|
|
72
73
|
this._baseObject = new PIXI.spine.Spine(spineAsset.spineData);
|
|
73
|
-
this._baseObject.state.timeScale = this.animation.timeScale;
|
|
74
|
+
//this._baseObject.state.timeScale = this.animation.timeScale;
|
|
75
|
+
Object.defineProperty(this._baseObject.state, 'timeScale', { get: this.getTimeScale.bind(this) });
|
|
74
76
|
|
|
75
77
|
if (this.animation.onComplete)
|
|
76
78
|
this._baseObject.state.addListener({ complete: this.animation.onComplete });
|
|
@@ -78,6 +80,10 @@ class ModulesObjectsModelsSpine extends Urso.Core.Modules.Objects.BaseModel {
|
|
|
78
80
|
if (this.animation.name)
|
|
79
81
|
this.play(this.animation.name, this.animation.loop);
|
|
80
82
|
};
|
|
83
|
+
|
|
84
|
+
getTimeScale() {
|
|
85
|
+
return Urso.scenes.timeScale * this.animation.timeScale;
|
|
86
|
+
}
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
module.exports = ModulesObjectsModelsSpine;
|
|
@@ -16,6 +16,7 @@ class ModulesObjectsModelsTextInput extends Urso.Core.Modules.Objects.BaseModel
|
|
|
16
16
|
this.numbersOnly = Urso.helper.recursiveGet('numbersOnly', params, false);
|
|
17
17
|
this.allowedSymbols = Urso.helper.recursiveGet('allowedSymbols', params, false);
|
|
18
18
|
this.substituteText = Urso.helper.recursiveGet('substituteText', params, false);
|
|
19
|
+
this.maxLength = Urso.helper.recursiveGet('maxLength', params, false);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
restrictInput(allowedSymbols) {
|
|
@@ -40,15 +41,25 @@ class ModulesObjectsModelsTextInput extends Urso.Core.Modules.Objects.BaseModel
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
_onBlur(){
|
|
43
|
-
this.text = this._baseObject.text;
|
|
44
44
|
const data = {name: this.name, class: this.class, id: this.id, text: this.text};
|
|
45
45
|
this.emit(Urso.events.MODULES_OBJECTS_TEXTINPUT_BLUR, data);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
_onInput() {
|
|
49
|
+
this.text = this._baseObject.text;
|
|
50
|
+
const data = {name: this.name, class: this.class, id: this.id, text: this.text};
|
|
51
|
+
this.emit(Urso.events.MODULES_OBJECTS_TEXTINPUT_INPUT, data);
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
_addBaseObject() {
|
|
49
55
|
this._baseObject = new PIXI.TextInput({ input: this.input, box: this.box });
|
|
50
56
|
this._baseObject.substituteText = this.substituteText;
|
|
57
|
+
|
|
58
|
+
if(this.maxLength)
|
|
59
|
+
this._baseObject.maxLength = this.maxLength
|
|
60
|
+
|
|
51
61
|
this._baseObject.on('blur', this._onBlur.bind(this))
|
|
62
|
+
this._baseObject.on('input', this._onInput.bind(this))
|
|
52
63
|
};
|
|
53
64
|
}
|
|
54
65
|
|
|
@@ -5,7 +5,7 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
5
5
|
constructor(params) {
|
|
6
6
|
super(params);
|
|
7
7
|
|
|
8
|
-
this.
|
|
8
|
+
this.status = 'unpressed';
|
|
9
9
|
|
|
10
10
|
this.type = Urso.types.objects.TOGGLE;
|
|
11
11
|
this._addBaseObject();
|
|
@@ -18,7 +18,7 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
18
18
|
super.setupParams(params);
|
|
19
19
|
|
|
20
20
|
this.action = Urso.helper.recursiveGet('action', params, () => {
|
|
21
|
-
this.emit(Urso.events.MODULES_OBJECTS_TOGGLE_PRESS, { name: this.name, status: this.
|
|
21
|
+
this.emit(Urso.events.MODULES_OBJECTS_TOGGLE_PRESS, { name: this.name, status: this.status, class: this.class })
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
this.buttonFrames = {
|
|
@@ -37,13 +37,13 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
37
37
|
this.buttonFrames[key] = assetKey;
|
|
38
38
|
|
|
39
39
|
if (this._isOver)
|
|
40
|
-
this._changeTexture(`${this.
|
|
40
|
+
this._changeTexture(`${this.status}Over`);
|
|
41
41
|
else if(this._isDown)
|
|
42
|
-
this._changeTexture(`${this.
|
|
42
|
+
this._changeTexture(`${this.status}Down`);
|
|
43
43
|
else if(this._isDisabled)
|
|
44
|
-
this._changeTexture(`${this.
|
|
44
|
+
this._changeTexture(`${this.status}Disabled`);
|
|
45
45
|
else
|
|
46
|
-
this._changeTexture(`${this.
|
|
46
|
+
this._changeTexture(`${this.status}Out`);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
enable() {
|
|
@@ -51,9 +51,9 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
51
51
|
return false;
|
|
52
52
|
|
|
53
53
|
if (this._isOver)
|
|
54
|
-
this._changeTexture(`${this.
|
|
54
|
+
this._changeTexture(`${this.status}Over`);
|
|
55
55
|
else
|
|
56
|
-
this._changeTexture(`${this.
|
|
56
|
+
this._changeTexture(`${this.status}Out`);
|
|
57
57
|
|
|
58
58
|
this._isDisabled = false;
|
|
59
59
|
}
|
|
@@ -62,7 +62,7 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
62
62
|
if (this._isDisabled)
|
|
63
63
|
return false;
|
|
64
64
|
|
|
65
|
-
this._changeTexture(`${this.
|
|
65
|
+
this._changeTexture(`${this.status}Disabled`);
|
|
66
66
|
this._isDisabled = true;
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -101,9 +101,9 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
101
101
|
if (this._isDisabled) //can be disabled after keyDownAction
|
|
102
102
|
return false;
|
|
103
103
|
|
|
104
|
-
this._changeTexture(`${this.
|
|
104
|
+
this._changeTexture(`${this.status}Down`);
|
|
105
105
|
|
|
106
|
-
this.
|
|
106
|
+
this.status = this.status === 'pressed' ? 'unpressed' : 'pressed';
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
_onButtonUp() {
|
|
@@ -119,9 +119,9 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
119
119
|
return false;
|
|
120
120
|
|
|
121
121
|
if (this._isOver)
|
|
122
|
-
this._changeTexture(`${this.
|
|
122
|
+
this._changeTexture(`${this.status}Over`);
|
|
123
123
|
else
|
|
124
|
-
this._changeTexture(`${this.
|
|
124
|
+
this._changeTexture(`${this.status}Out`);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
_onButtonOver() {
|
|
@@ -133,7 +133,7 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
133
133
|
if (this.mouseOverAction)
|
|
134
134
|
this.mouseOverAction();
|
|
135
135
|
|
|
136
|
-
this._changeTexture(`${this.
|
|
136
|
+
this._changeTexture(`${this.status}Over`);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
_onButtonOut() {
|
|
@@ -145,19 +145,28 @@ class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
|
145
145
|
if (this.mouseOutAction)
|
|
146
146
|
this.mouseOutAction();
|
|
147
147
|
|
|
148
|
-
this._changeTexture(`${this.
|
|
148
|
+
this._changeTexture(`${this.status}Out`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
switchStatus() {
|
|
152
|
+
this.status = this.status === 'pressed' ? 'unpressed' : 'pressed';
|
|
153
|
+
|
|
154
|
+
if (this._isOver)
|
|
155
|
+
this._changeTexture(`${this.status}Over`);
|
|
156
|
+
else
|
|
157
|
+
this._changeTexture(`${this.status}Out`);
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
_changeTexture(key) {
|
|
152
161
|
let texture = Urso.cache.getTexture(this.buttonFrames[key]);
|
|
153
162
|
|
|
154
163
|
if (!texture) {
|
|
155
|
-
if (key === `${this.
|
|
164
|
+
if (key === `${this.status}Out`) {
|
|
156
165
|
Urso.logger.error('ModulesObjectsModelsButton assets error: no out image ' + this.buttonFrames.out);
|
|
157
166
|
return false;
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
this._changeTexture(`${this.
|
|
169
|
+
this._changeTexture(`${this.status}Out`); // load default texture for this key
|
|
161
170
|
return false;
|
|
162
171
|
}
|
|
163
172
|
|
|
@@ -44,8 +44,11 @@ class ModulesObjectsProxy {
|
|
|
44
44
|
safeSetValueToTarget(target, key, value) {
|
|
45
45
|
this._safeFlag = true;
|
|
46
46
|
|
|
47
|
-
const originalValue = target._originalModel[key];
|
|
47
|
+
const originalValue = target._originalModel[key]; // we need to save original value in the end
|
|
48
|
+
|
|
49
|
+
//setting value
|
|
48
50
|
target[key] = value;
|
|
51
|
+
|
|
49
52
|
target._originalModel[key] = originalValue;
|
|
50
53
|
|
|
51
54
|
this._safeFlag = false;
|
|
@@ -12,6 +12,7 @@ class ModulesObserverConfig {
|
|
|
12
12
|
MODULES_OBJECTS_SLIDER_SET_NEW_VALUE: 'modules.objects.slider.setNewValue',
|
|
13
13
|
MODULES_OBJECTS_TOGGLE_PRESS: 'modules.objects.toggle.press',
|
|
14
14
|
MODULES_OBJECTS_TEXTINPUT_BLUR: 'modules.objects.textinput.blur',
|
|
15
|
+
MODULES_OBJECTS_TEXTINPUT_INPUT: 'modules.objects.textinput.input',
|
|
15
16
|
MODULES_OBJECTS_CHECKBOX_PRESS: 'modules.objects.checkbox.press',
|
|
16
17
|
MODULES_LOGIC_SOUNDS_DO: 'modules.soundManager.do',
|
|
17
18
|
MODULES_SOUND_MANAGER_UPDATE_CFG: 'modules.soundManager.updateCfg',
|
|
@@ -29,6 +29,14 @@ class ModulesScenesController {
|
|
|
29
29
|
getMouseCoords() {
|
|
30
30
|
return this.getInstance('PixiWrapper').getCachedMouseCoords();
|
|
31
31
|
}
|
|
32
|
+
|
|
33
|
+
get timeScale() {
|
|
34
|
+
return this._service.timeScale;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
set timeScale(value) {
|
|
38
|
+
return this._service.setTimeScale(value);
|
|
39
|
+
}
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
module.exports = ModulesScenesController;
|
|
@@ -71,7 +71,7 @@ class ModulesScenesPixiWrapper {
|
|
|
71
71
|
|
|
72
72
|
_getDeltaTime() {
|
|
73
73
|
let newTime = Date.now();
|
|
74
|
-
let deltaTime = newTime - this._loopLastCall;
|
|
74
|
+
let deltaTime = Urso.scenes.timeScale * (newTime - this._loopLastCall);
|
|
75
75
|
this._loopLastCall = newTime;
|
|
76
76
|
|
|
77
77
|
return Urso.math.intMakeBetween(deltaTime, 0, 1000);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
class ModulesScenesService {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.singleton = true;
|
|
4
|
+
|
|
4
5
|
this._displayInProgress = false;
|
|
5
6
|
this._currentSceneName = false;
|
|
6
7
|
this._currentSceneTemplate = false;
|
|
7
8
|
this._sceneModel;
|
|
8
9
|
|
|
10
|
+
this.timeScale = 1;
|
|
11
|
+
|
|
9
12
|
this._pixiWrapper;
|
|
10
13
|
|
|
11
14
|
this.init();
|
|
@@ -18,6 +21,11 @@ class ModulesScenesService {
|
|
|
18
21
|
this._pixiWrapper.init();
|
|
19
22
|
}
|
|
20
23
|
|
|
24
|
+
setTimeScale(value) {
|
|
25
|
+
this.timeScale = value;
|
|
26
|
+
gsap.globalTimeline.timeScale(this.timeScale);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
display(name) {
|
|
22
30
|
if (this._displayInProgress) {
|
|
23
31
|
console.warn("Scenes.display is busy ", this._currentSceneName);
|
|
@@ -62,9 +70,9 @@ class ModulesScenesService {
|
|
|
62
70
|
Urso.assets.preload(this._currentSceneTemplate.assets, this._assetsLoadedHandler);
|
|
63
71
|
|
|
64
72
|
}
|
|
65
|
-
|
|
66
|
-
loadUpdate(loadProgress){
|
|
67
|
-
if(!this._sceneModel)
|
|
73
|
+
|
|
74
|
+
loadUpdate(loadProgress) {
|
|
75
|
+
if (!this._sceneModel)
|
|
68
76
|
return;
|
|
69
77
|
this._sceneModel.loadUpdate(loadProgress);
|
|
70
78
|
this.emit(Urso.events.MODULES_ASSETS_LOAD_PROGRESS, loadProgress);
|
|
@@ -5,6 +5,8 @@ class ModulesStatesManagerController {
|
|
|
5
5
|
this._configStates;
|
|
6
6
|
this._currentState;
|
|
7
7
|
this._started = false;
|
|
8
|
+
this._paused = false;
|
|
9
|
+
this._pauseNeedResume = false;
|
|
8
10
|
|
|
9
11
|
this.statesGuards = this.getInstance('FunctionsStorage');
|
|
10
12
|
this.actionsGuards = this.getInstance('FunctionsStorage');
|
|
@@ -12,7 +14,7 @@ class ModulesStatesManagerController {
|
|
|
12
14
|
this.actionsTerminations = this.getInstance('FunctionsStorage');
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
this._iterator
|
|
17
|
+
this._iterator; //will be defined after start
|
|
16
18
|
this._nextState = this._nextState.bind(this);
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -20,14 +22,29 @@ class ModulesStatesManagerController {
|
|
|
20
22
|
if (this._started)
|
|
21
23
|
return;
|
|
22
24
|
|
|
25
|
+
this._currentState = null;
|
|
26
|
+
this._iterator = this._iteratorConstructor();
|
|
23
27
|
this._started = true;
|
|
24
28
|
this._configStates = this.getInstance('ConfigStates').get();
|
|
25
29
|
this._nextState();
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
pause() {
|
|
33
|
+
this._paused = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resume() {
|
|
37
|
+
this._paused = false;
|
|
38
|
+
|
|
39
|
+
if (this._pauseNeedResume) {
|
|
40
|
+
this._pauseNeedResume = false;
|
|
41
|
+
this._nextState();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
_iteratorConstructor() {
|
|
29
46
|
let nextIndex = 0;
|
|
30
|
-
|
|
47
|
+
|
|
31
48
|
|
|
32
49
|
const getNextStateByOrder = () => {
|
|
33
50
|
let statesArray = Object.keys(this._configStates);
|
|
@@ -75,6 +92,11 @@ class ModulesStatesManagerController {
|
|
|
75
92
|
}
|
|
76
93
|
|
|
77
94
|
_nextState() {
|
|
95
|
+
if (this._paused) {
|
|
96
|
+
this._pauseNeedResume = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
this._currentState = this._iterator.next();
|
|
79
101
|
|
|
80
102
|
this.emit(Urso.events.MODULES_STATES_MANAGER_STATE_CHANGE, this._currentState);
|
|
@@ -92,46 +114,54 @@ class ModulesStatesManagerController {
|
|
|
92
114
|
}
|
|
93
115
|
|
|
94
116
|
//actions guards
|
|
95
|
-
addActionGuard(key, guard) {
|
|
117
|
+
addActionGuard = (key, guard) => {
|
|
96
118
|
this.actionsGuards.add(key, guard, true);
|
|
97
119
|
}
|
|
98
120
|
|
|
99
|
-
checkActionGuard(key) {
|
|
121
|
+
checkActionGuard = (key) => {
|
|
100
122
|
return this.actionsGuards.checkGuard(key);
|
|
101
123
|
}
|
|
102
124
|
|
|
103
|
-
removeActionGuard(key, guard) {
|
|
125
|
+
removeActionGuard = (key, guard) => {
|
|
104
126
|
this.actionsGuards.remove(key, guard);
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
//actions runs
|
|
108
|
-
addActionRun(key, runFunction) {
|
|
130
|
+
addActionRun = (key, runFunction) => {
|
|
109
131
|
this.actionsRuns.add(key, runFunction);
|
|
110
132
|
}
|
|
111
133
|
|
|
112
|
-
runAction(key, onFinishCallback) {
|
|
134
|
+
runAction = (key, onFinishCallback) => {
|
|
113
135
|
this.actionsRuns.runAndCallbackOnFinish(key, onFinishCallback);
|
|
114
136
|
}
|
|
115
137
|
|
|
138
|
+
removeActionRun = (key, runFunction) => {
|
|
139
|
+
this.actionsRuns.remove(key, runFunction);
|
|
140
|
+
}
|
|
141
|
+
|
|
116
142
|
//actions terminations
|
|
117
|
-
addActionTerminate(key, terminateFunction) {
|
|
143
|
+
addActionTerminate = (key, terminateFunction) => {
|
|
118
144
|
this.actionsTerminations.add(key, terminateFunction);
|
|
119
145
|
}
|
|
120
146
|
|
|
121
|
-
terminateAction(key) {
|
|
147
|
+
terminateAction = (key) => {
|
|
122
148
|
this.actionsTerminations.run(key);
|
|
123
149
|
}
|
|
124
150
|
|
|
151
|
+
removeActionTerminate = (key, terminateFunction) => {
|
|
152
|
+
this.actionsTerminations.remove(key, terminateFunction);
|
|
153
|
+
}
|
|
154
|
+
|
|
125
155
|
//states guards
|
|
126
|
-
setStateGuard(key, guard) {
|
|
156
|
+
setStateGuard = (key, guard) => {
|
|
127
157
|
this.statesGuards.add(key, guard, true);
|
|
128
158
|
}
|
|
129
159
|
|
|
130
|
-
checkStateGuard(key) {
|
|
160
|
+
checkStateGuard = (key) => {
|
|
131
161
|
return this.statesGuards.checkGuard(key);
|
|
132
162
|
}
|
|
133
163
|
|
|
134
|
-
removeStateGuard(key, guard) {
|
|
164
|
+
removeStateGuard = (key, guard) => {
|
|
135
165
|
this.statesGuards.remove(key, guard);
|
|
136
166
|
}
|
|
137
167
|
|