@urso/core 0.4.30 → 0.4.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.4.30",
3
+ "version": "0.4.33",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -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,4 @@
1
+ Urso.Core.Components.LayersSwitcher = {
2
+ Controller: require('./controller'),
3
+ Config: require('./config'),
4
+ };
@@ -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',
@@ -55,6 +55,9 @@ class SoundSprite {
55
55
  this._player.on('end', id => {
56
56
  const soundState = this._getSoundStateById(id);
57
57
 
58
+ if (!soundState)
59
+ return Urso.logger.error(`SoundSprite error: soundState for id '${id}' not found!`);
60
+
58
61
  if (!soundState.loop)
59
62
  soundState.id = null;
60
63
  });
@@ -175,7 +178,7 @@ class SoundSprite {
175
178
  const params = { loop, relaunch, volume, soundKey };
176
179
 
177
180
  if (!self[action])
178
- Urso.logger.error(`Sound action '${action}' not found!`);
181
+ return Urso.logger.error(`SoundSprite error: Sound action '${action}' not found!`);
179
182
 
180
183
  if (!this._isAudioUnlocked)
181
184
  this._addEventToQueue({ ...params, action });
@@ -36,7 +36,6 @@ class ModulesTemplateTypes {
36
36
  CHECKBOX: 20,
37
37
  SCROLLBOX: 21,
38
38
  TEXTINPUT: 22,
39
- TEXTINPUT: 22,
40
39
  NINESLICEPLANE: 23
41
40
  }
42
41
  }