@urso/core 0.4.41 → 0.4.44

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.41",
3
+ "version": "0.4.44",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -88,6 +88,11 @@ class ModulesObjectsProxy {
88
88
 
89
89
  this._setProperty(target, propertyName, value, oldValue);
90
90
 
91
+ //if property is text - we will update it
92
+ if (propertyName === 'text') {
93
+ target._baseObject.updateText(true);
94
+ }
95
+
91
96
  this._checkMaxSize(target);
92
97
 
93
98
  //setup dirty to recalc params
@@ -101,6 +106,27 @@ class ModulesObjectsProxy {
101
106
  if (!target.maxWidth && !target.maxHeight)
102
107
  return;
103
108
 
109
+ let calculationNeed = false;
110
+
111
+ const baseObject = target._baseObject;
112
+
113
+ //Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
114
+ if (baseObject._texture && (!baseObject._texture.orig.width || !baseObject._texture.orig.height)) {
115
+ baseObject.updateText(true);
116
+ }
117
+
118
+ const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
119
+ const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
120
+
121
+ if (target.maxWidth && target.maxWidth < baseObjectWidth) //check maxWidth
122
+ calculationNeed = true;
123
+
124
+ if (target.maxHeight && target.maxHeight < baseObjectHeight) //check maxHeight
125
+ calculationNeed = true;
126
+
127
+ if (!calculationNeed)
128
+ return;
129
+
104
130
  let scaleNeed = 1;
105
131
 
106
132
  if (target.maxWidth) {
@@ -42,7 +42,6 @@ class ModulesObjectsStyles {
42
42
  delete this._cache[selector];
43
43
  }
44
44
  }
45
-
46
45
  }
47
46
 
48
47
  _apply(selector, style) {
@@ -68,7 +67,7 @@ class ModulesObjectsStyles {
68
67
  _globalResetStyles() {
69
68
  for (let [selector, selectorCache] of Object.entries(this._cache)) {
70
69
  for (let [uid, object] of Object.entries(selectorCache))
71
- this._removeSelectorStyles(object, selector);
70
+ this._removeSelectorStyles(object, selector, true);
72
71
 
73
72
  delete this._cache[selector];
74
73
  }
@@ -84,7 +83,7 @@ class ModulesObjectsStyles {
84
83
  }
85
84
  }
86
85
 
87
- _removeSelectorStyles(object, selector) {
86
+ _removeSelectorStyles(object, selector, globalResetFlag) {
88
87
  delete object._styles[selector];
89
88
  let template = Urso.template.get();
90
89
  let styles = template.styles[selector];
@@ -94,12 +93,12 @@ class ModulesObjectsStyles {
94
93
  }
95
94
 
96
95
  for (let [key, value] of Object.entries(styles)) {
97
- this._restoreValueByKey(key, object);
96
+ this._restoreValueByKey(key, object, globalResetFlag);
98
97
  }
99
98
 
100
99
  }
101
100
 
102
- _restoreValueByKey(key, object) {
101
+ _restoreValueByKey(key, object, globalResetFlag) {
103
102
  //check own
104
103
  if (object._originalModel[key])
105
104
  return;
@@ -110,9 +109,11 @@ class ModulesObjectsStyles {
110
109
  Urso.objects._safeSetValueToTarget(object, key, tempObject[key]);
111
110
 
112
111
  //check other styles
113
- for (let [selector, style] of Object.entries(object._styles))
114
- if (typeof style[key] !== 'undefined')
115
- Urso.objects._safeSetValueToTarget(object, key, style[key]);
112
+ if (!globalResetFlag) {
113
+ for (let [selector, style] of Object.entries(object._styles))
114
+ if (typeof style[key] !== 'undefined')
115
+ Urso.objects._safeSetValueToTarget(object, key, style[key]);
116
+ }
116
117
  }
117
118
  }
118
119