@urso/core 0.4.30 → 0.4.31
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/observer/events.js +1 -0
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;
|
|
@@ -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',
|