@urso/core 0.4.29 → 0.4.32
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/_info.js +2 -0
- package/src/js/components/layersSwitcher/_info.js +4 -0
- package/src/js/components/layersSwitcher/config.js +26 -0
- package/src/js/components/layersSwitcher/controller.js +34 -0
- package/src/js/modules/objects/baseModel.js +14 -0
- package/src/js/modules/observer/events.js +1 -0
- package/src/js/modules/scenes/controller.js +9 -0
- package/src/js/modules/scenes/pixiWrapper.js +9 -0
- package/src/js/modules/template/types.js +0 -1
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Urso.Core.Components = {};
|
|
2
|
+
|
|
2
3
|
require('./base/_info.js');
|
|
3
4
|
require('./debug/_info.js');
|
|
4
5
|
require('./deviceRotate/_info.js');
|
|
5
6
|
require('./fullscreen/_info.js');
|
|
7
|
+
require('./layersSwitcher/_info.js');
|
|
6
8
|
require('./loader/_info.js');
|
|
7
9
|
require('./soundInitialPopup/_info.js');
|
|
8
10
|
require('./stateDriven/_info.js');
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class ComponentsLayersSwitcher {
|
|
2
|
+
|
|
3
|
+
constructor() {
|
|
4
|
+
|
|
5
|
+
//allLayers config example
|
|
6
|
+
this.allLayers = [
|
|
7
|
+
'^granny',
|
|
8
|
+
'^mainButton',
|
|
9
|
+
'^logo',
|
|
10
|
+
'.backround',
|
|
11
|
+
'^bonusPopup',
|
|
12
|
+
'.baseGame',
|
|
13
|
+
'.bonusGame'
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
//groups layers config example
|
|
17
|
+
this.groupsLayers = {
|
|
18
|
+
'mainElements': ['^logo', '^mainButton', '.baseGame'],
|
|
19
|
+
'background': ['.backround'],
|
|
20
|
+
'granny': ['^granny'],
|
|
21
|
+
'bonusGame': ['.bonusGame', '^bonusPopup']
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = ComponentsLayersSwitcher;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class ComponentsLayersSwitcherController extends Urso.Core.Components.Base.Controller {
|
|
2
|
+
|
|
3
|
+
constructor(...args) {
|
|
4
|
+
super(...args);
|
|
5
|
+
this._config = this.getInstance('Config');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* disable all layers from the list of managed layers (config.allLayers) and enables layers corresponding to the desired group (config.groupsLayers[groupName])
|
|
10
|
+
* @param {String} groupName
|
|
11
|
+
*/
|
|
12
|
+
_showGroup(groupName) {
|
|
13
|
+
const configLayersGroup = this._config.groupsLayers[groupName];
|
|
14
|
+
|
|
15
|
+
if (configLayersGroup) {
|
|
16
|
+
this._config.allLayers.forEach(selectorLayers => {
|
|
17
|
+
const layerVisibleStatus = (configLayersGroup.includes(selectorLayers)) ? true : false;
|
|
18
|
+
|
|
19
|
+
Urso.findAll(selectorLayers).forEach((selectorObject) => {
|
|
20
|
+
selectorObject.visible = layerVisibleStatus;
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
} else {
|
|
25
|
+
Urso.logger.error(`ComponentsLayersSwitcherController: group '${groupName}' was not found!`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_subscribeOnce() {
|
|
30
|
+
this.addListener(Urso.events.COMPONENTS_LAYERS_SWITCHER_SWITCH, (groupName) => { this._showGroup(groupName) });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = ComponentsLayersSwitcherController;
|
|
@@ -172,6 +172,20 @@ class ModulesObjectsBaseModel {
|
|
|
172
172
|
|
|
173
173
|
return { x, y };
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* generate texture from current object
|
|
178
|
+
* @param {String} [key]
|
|
179
|
+
* @returns {Object} - pixi.Texture
|
|
180
|
+
*/
|
|
181
|
+
generateTexture(key = '') {
|
|
182
|
+
const newTexture = Urso.scenes.generateTexture(this._baseObject);
|
|
183
|
+
|
|
184
|
+
if (key)
|
|
185
|
+
Urso.cache.addTexture(key, newTexture);
|
|
186
|
+
|
|
187
|
+
return newTexture;
|
|
188
|
+
}
|
|
175
189
|
}
|
|
176
190
|
|
|
177
191
|
module.exports = ModulesObjectsBaseModel;
|
|
@@ -5,6 +5,7 @@ class ModulesObserverConfig {
|
|
|
5
5
|
this.list = {
|
|
6
6
|
COMPONENTS_FULLSCREEN_CHANGE: 'components.fullscreen.change',
|
|
7
7
|
COMPONENTS_FULLSCREEN_SWITCH: 'components.fullscreen.switch',
|
|
8
|
+
COMPONENTS_LAYERS_SWITCHER_SWITCH: 'components.layersSwitcher.switch',
|
|
8
9
|
MODULES_ASSETS_GROUP_LOADED: 'modules.assets.group.loaded',
|
|
9
10
|
MODULES_ASSETS_LOAD_PROGRESS: 'modules.assets.load.progress',
|
|
10
11
|
MODULES_ASSETS_LAZYLOAD_FINISHED: 'modules.assets.lazyLoad.finished',
|
|
@@ -76,6 +76,15 @@ class ModulesScenesController {
|
|
|
76
76
|
return this._service.addObject(objects, parent, doNotRefreshStylesFlag);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* generateTexture from object
|
|
81
|
+
* @param {Object} obj
|
|
82
|
+
* @returns {Object} - pixi.Texture
|
|
83
|
+
*/
|
|
84
|
+
generateTexture(obj) {
|
|
85
|
+
return this.getInstance('PixiWrapper').generateTexture(obj);
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
/**
|
|
80
89
|
* global timeScale getter
|
|
81
90
|
*/
|
|
@@ -220,6 +220,15 @@ class ModulesScenesPixiWrapper {
|
|
|
220
220
|
}, 16);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* generateTexture from object
|
|
225
|
+
* @param {Object} obj
|
|
226
|
+
* @returns {Object} - pixi.Texture
|
|
227
|
+
*/
|
|
228
|
+
generateTexture(obj) {
|
|
229
|
+
return this.renderer.generateTexture(obj);
|
|
230
|
+
}
|
|
231
|
+
|
|
223
232
|
_subscribeOnce() {
|
|
224
233
|
this.addListener(Urso.events.EXTRA_BROWSEREVENTS_WINDOW_VISIBILITYCHANGE, this.visibilityChangeHandler.bind(this), true);
|
|
225
234
|
}
|