@urso/core 0.7.92 → 0.7.94-dev
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/.babelrc +11 -11
- package/LICENSE +20 -20
- package/README.md +227 -227
- package/build/162.js/index.js +1 -0
- package/build/24.js/index.js +1 -0
- package/build/js/index.js +1 -1
- package/package.json +50 -50
- package/src/js/app.js +104 -104
- package/src/js/components/base/controller.js +78 -78
- package/src/js/components/debug/controller.js +38 -38
- package/src/js/components/debug/coords.js +23 -23
- package/src/js/components/debug/fps.js +36 -36
- package/src/js/components/debug/template.js +55 -55
- package/src/js/components/debug/timescale.js +60 -60
- package/src/js/components/deviceRotate/controller.js +95 -95
- package/src/js/components/editor/api.js +127 -127
- package/src/js/components/editor/controller.js +12 -12
- package/src/js/components/fullscreen/android.js +104 -104
- package/src/js/components/fullscreen/controller.js +76 -76
- package/src/js/components/fullscreen/desktop.js +49 -49
- package/src/js/components/fullscreen/ios.js +115 -115
- package/src/js/components/layersSwitcher/config.js +26 -26
- package/src/js/components/layersSwitcher/controller.js +36 -36
- package/src/js/components/loader/controller.js +66 -66
- package/src/js/components/loader/template.js +70 -70
- package/src/js/components/soundInitialPopup/controller.js +42 -42
- package/src/js/components/soundInitialPopup/template.js +109 -109
- package/src/js/components/stateDriven/controller.js +123 -123
- package/src/js/config/load.js +194 -194
- package/src/js/config/main.js +17 -17
- package/src/js/extra/browserEvents.js +57 -57
- package/src/js/extra/main.js +19 -19
- package/src/js/extra/pixiPatch.js +171 -171
- package/src/js/index.js +7 -7
- package/src/js/lib/cache.js +125 -125
- package/src/js/lib/composition.js +85 -85
- package/src/js/lib/device.js +1215 -1215
- package/src/js/lib/helper.js +678 -678
- package/src/js/lib/loader.js +211 -211
- package/src/js/lib/localData.js +28 -28
- package/src/js/lib/logger.js +69 -69
- package/src/js/lib/math.js +161 -161
- package/src/js/lib/objectPool.js +207 -207
- package/src/js/lib/time.js +18 -18
- package/src/js/lib/tween.js +152 -152
- package/src/js/modules/assets/baseModel.js +20 -20
- package/src/js/modules/assets/config.js +38 -38
- package/src/js/modules/assets/controller.js +65 -65
- package/src/js/modules/assets/models/atlas.js +18 -18
- package/src/js/modules/assets/models/audiosprite.js +28 -28
- package/src/js/modules/assets/models/bitmapFont.js +10 -10
- package/src/js/modules/assets/models/container.js +18 -18
- package/src/js/modules/assets/models/font.js +10 -10
- package/src/js/modules/assets/models/html.js +10 -10
- package/src/js/modules/assets/models/image.js +17 -17
- package/src/js/modules/assets/models/json.js +10 -10
- package/src/js/modules/assets/models/jsonAtlas.js +10 -10
- package/src/js/modules/assets/models/sound.js +16 -16
- package/src/js/modules/assets/models/spine.js +16 -16
- package/src/js/modules/assets/service.js +541 -541
- package/src/js/modules/i18n/config.js +17 -17
- package/src/js/modules/i18n/controller.js +71 -71
- package/src/js/modules/instances/controller.js +357 -357
- package/src/js/modules/logic/config/sounds.js +23 -23
- package/src/js/modules/logic/controller.js +52 -52
- package/src/js/modules/logic/main.js +8 -8
- package/src/js/modules/logic/sounds.js +103 -103
- package/src/js/modules/objects/baseModel.js +207 -207
- package/src/js/modules/objects/cache.js +99 -99
- package/src/js/modules/objects/config.js +9 -9
- package/src/js/modules/objects/controller.js +139 -139
- package/src/js/modules/objects/find.js +58 -58
- package/src/js/modules/objects/models/atlasImage.js +52 -52
- package/src/js/modules/objects/models/bitmapText.js +48 -48
- package/src/js/modules/objects/models/button.js +196 -196
- package/src/js/modules/objects/models/buttonComposite.js +37 -37
- package/src/js/modules/objects/models/checkbox.js +96 -96
- package/src/js/modules/objects/models/collection.js +54 -54
- package/src/js/modules/objects/models/component.js +48 -48
- package/src/js/modules/objects/models/container.js +21 -21
- package/src/js/modules/objects/models/dragContainer.js +664 -664
- package/src/js/modules/objects/models/emitter.js +69 -69
- package/src/js/modules/objects/models/emitterFx.js +114 -114
- package/src/js/modules/objects/models/graphics.js +40 -40
- package/src/js/modules/objects/models/group.js +21 -21
- package/src/js/modules/objects/models/hitArea.js +119 -119
- package/src/js/modules/objects/models/image.js +36 -36
- package/src/js/modules/objects/models/imagesAnimation.js +115 -115
- package/src/js/modules/objects/models/mask.js +40 -40
- package/src/js/modules/objects/models/nineSlicePlane.js +32 -32
- package/src/js/modules/objects/models/scrollbox.js +66 -66
- package/src/js/modules/objects/models/slider.js +352 -352
- package/src/js/modules/objects/models/spine.js +338 -338
- package/src/js/modules/objects/models/text.js +70 -70
- package/src/js/modules/objects/models/textInput.js +68 -68
- package/src/js/modules/objects/models/toggle.js +179 -179
- package/src/js/modules/objects/models/world.js +21 -21
- package/src/js/modules/objects/pool.js +68 -68
- package/src/js/modules/objects/propertyAdapter.js +591 -588
- package/src/js/modules/objects/proxy.js +298 -298
- package/src/js/modules/objects/selector.js +136 -136
- package/src/js/modules/objects/service.js +254 -254
- package/src/js/modules/objects/styles.js +210 -210
- package/src/js/modules/observer/controller.js +167 -167
- package/src/js/modules/observer/events.js +56 -56
- package/src/js/modules/scenes/controller.js +127 -127
- package/src/js/modules/scenes/model.js +28 -28
- package/src/js/modules/scenes/pixiWrapper.js +351 -351
- package/src/js/modules/scenes/resolutions.js +173 -173
- package/src/js/modules/scenes/resolutionsConfig.js +73 -73
- package/src/js/modules/scenes/service.js +146 -146
- package/src/js/modules/soundManager/controller.js +103 -103
- package/src/js/modules/soundManager/soundSprite.js +285 -285
- package/src/js/modules/statesManager/action.js +97 -97
- package/src/js/modules/statesManager/all.js +23 -23
- package/src/js/modules/statesManager/configStates.js +77 -77
- package/src/js/modules/statesManager/controller.js +218 -218
- package/src/js/modules/statesManager/functionsStorage.js +82 -82
- package/src/js/modules/statesManager/helper.js +27 -27
- package/src/js/modules/statesManager/race.js +91 -91
- package/src/js/modules/statesManager/sequence.js +48 -48
- package/src/js/modules/template/controller.js +28 -28
- package/src/js/modules/template/model.js +11 -11
- package/src/js/modules/template/service.js +137 -137
- package/src/js/modules/template/types.js +48 -48
- package/src/js/modules/transport/baseConnectionType.js +25 -25
- package/src/js/modules/transport/config.js +13 -13
- package/src/js/modules/transport/connectionTypes/websocket.js +76 -76
- package/src/js/modules/transport/connectionTypes/xhr.js +46 -46
- package/src/js/modules/transport/controller.js +48 -48
- package/src/js/modules/transport/decorator.js +17 -17
- package/src/js/modules/transport/service.js +150 -150
- package/webpack.config.js +47 -47
|
@@ -1,298 +1,298 @@
|
|
|
1
|
-
class ModulesObjectsProxy {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.singleton = true;
|
|
4
|
-
this._safeFlag = false;
|
|
5
|
-
|
|
6
|
-
this._customSetLogic = this._customSetLogic.bind(this);
|
|
7
|
-
this._customGetLogic = this._customGetLogic.bind(this);
|
|
8
|
-
|
|
9
|
-
this._propertyAdapter = this.getInstance('PropertyAdapter');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
get(model) {
|
|
13
|
-
const _this = this;
|
|
14
|
-
|
|
15
|
-
let proxy = new Proxy(model, {
|
|
16
|
-
get(target, key, receiver) {
|
|
17
|
-
const rv = Reflect.get(target, key, receiver);
|
|
18
|
-
return _this._customGetLogic({ target: target, proxy: receiver }, key, rv);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
set(target, key, value, receiver) {
|
|
22
|
-
const oldValue = target._baseObject[key];
|
|
23
|
-
const rv = Reflect.set(target, key, value, receiver);
|
|
24
|
-
_this._customSetLogic(target, key, value, proxy, oldValue);
|
|
25
|
-
return rv;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
model.proxyObject = proxy;
|
|
30
|
-
return proxy;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* targetObject - object from models
|
|
34
|
-
* propertyName - property to adapt for PIXI object
|
|
35
|
-
* value - value to set
|
|
36
|
-
*/
|
|
37
|
-
_setProperty(target, propertyName, value, oldValue) {
|
|
38
|
-
const isAdaptiveProperty = this._propertyAdapter.isAdaptiveProperty(propertyName);
|
|
39
|
-
|
|
40
|
-
if (isAdaptiveProperty)
|
|
41
|
-
this._propertyAdapter.propertyChangeHandler(target, propertyName);
|
|
42
|
-
else
|
|
43
|
-
Urso.helper.recursiveSet(propertyName, value, target._baseObject);
|
|
44
|
-
|
|
45
|
-
this._checkNeedTransitions(target, propertyName, value, oldValue);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
safeSetValueToTarget(target, key, value) {
|
|
49
|
-
this._safeFlag = true;
|
|
50
|
-
|
|
51
|
-
const originalValue = target._originalModel[key]; // we need to save original value in the end
|
|
52
|
-
|
|
53
|
-
//setting value
|
|
54
|
-
target[key] = value;
|
|
55
|
-
|
|
56
|
-
target._originalModel[key] = originalValue;
|
|
57
|
-
|
|
58
|
-
this._safeFlag = false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
//returns reflectValue = value that would be used when target[key] is called
|
|
62
|
-
_customGetLogic(object, key, reflectValue) {
|
|
63
|
-
const target = object.target;
|
|
64
|
-
const wrapKey = this._getAliases()[key];
|
|
65
|
-
const isReflectValueObject = typeof reflectValue !== 'undefined'; //&& typeof reflectValue !== 'boolean'; //it was for getting width and height
|
|
66
|
-
|
|
67
|
-
if ((isReflectValueObject && (typeof wrapKey != 'undefined')) || !wrapKey)
|
|
68
|
-
return reflectValue;
|
|
69
|
-
|
|
70
|
-
return Urso.helper.recursiveGet(wrapKey, target._baseObject, reflectValue);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
_customSetLogic(target, key, value, proxy, oldValue) {
|
|
74
|
-
if (!this._getOriginalModelExceptions().includes(key))
|
|
75
|
-
target._originalModel[key] = value;
|
|
76
|
-
|
|
77
|
-
//apply to pixi
|
|
78
|
-
const propertyName = this._getAliases()[key];
|
|
79
|
-
|
|
80
|
-
if (!propertyName)
|
|
81
|
-
return false;
|
|
82
|
-
|
|
83
|
-
if (propertyName.startsWith('function.')) {
|
|
84
|
-
this._runCustomFunction(propertyName, target);
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this._checkSelectorProperties(key);
|
|
89
|
-
|
|
90
|
-
this._setProperty(target, propertyName, value, oldValue);
|
|
91
|
-
|
|
92
|
-
//if property is text - we will update it
|
|
93
|
-
if (propertyName === 'text') {
|
|
94
|
-
target._baseObject.updateText(true);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this._checkMaxSize(target);
|
|
98
|
-
|
|
99
|
-
//setup dirty to recalc params
|
|
100
|
-
if (typeof target._baseObject.dirty !== 'undefined')
|
|
101
|
-
target._baseObject.dirty = true;
|
|
102
|
-
|
|
103
|
-
return true;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
_checkMaxSize(target) {
|
|
107
|
-
if (!target.maxWidth && !target.maxHeight)
|
|
108
|
-
return;
|
|
109
|
-
|
|
110
|
-
let calculationNeed = false;
|
|
111
|
-
|
|
112
|
-
const baseObject = target._baseObject;
|
|
113
|
-
|
|
114
|
-
baseObject.updateTransform();
|
|
115
|
-
|
|
116
|
-
//Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
|
|
117
|
-
if (baseObject._texture && (!baseObject._texture.orig.width || !baseObject._texture.orig.height)) {
|
|
118
|
-
baseObject.updateText(true);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
|
|
122
|
-
const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
target.maxWidth &&
|
|
126
|
-
(
|
|
127
|
-
target.maxWidth < baseObjectWidth || //maxWidth is lower than object width
|
|
128
|
-
(target.maxWidth > baseObjectWidth && target._baseObject.scale.x < 1) //maxWidth is higher than object width and object is downscaled
|
|
129
|
-
)
|
|
130
|
-
) //check maxWidth
|
|
131
|
-
calculationNeed = true;
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
target.maxHeight &&
|
|
135
|
-
(
|
|
136
|
-
target.maxHeight < baseObjectHeight || //maxHeight is lower than object height
|
|
137
|
-
(target.maxHeight > baseObjectHeight && target._baseObject.scale.y < 1) //maxHeight is higher than object height and object is downscaled
|
|
138
|
-
)
|
|
139
|
-
) //check maxHeight
|
|
140
|
-
calculationNeed = true;
|
|
141
|
-
|
|
142
|
-
if (!calculationNeed)
|
|
143
|
-
return;
|
|
144
|
-
|
|
145
|
-
let scaleNeed = 1;
|
|
146
|
-
|
|
147
|
-
if (target.maxWidth) {
|
|
148
|
-
scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (target.maxHeight) {
|
|
152
|
-
const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
|
|
153
|
-
|
|
154
|
-
if (scaleNeed > scaleYNeed)
|
|
155
|
-
scaleNeed = scaleYNeed;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (scaleNeed > 1)
|
|
159
|
-
scaleNeed = 1;
|
|
160
|
-
|
|
161
|
-
target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
|
|
162
|
-
target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
_runCustomFunction(property, target) {
|
|
166
|
-
const funcName = property.replace('function.', '');
|
|
167
|
-
if (target[funcName])
|
|
168
|
-
target[funcName]();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
_checkSelectorProperties(key) {
|
|
172
|
-
if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
|
|
173
|
-
Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector property: ' + key);
|
|
174
|
-
Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* transitions tweens creation
|
|
180
|
-
* @param {Object} target - ObjectsModel
|
|
181
|
-
* @param {String} propertyName
|
|
182
|
-
* @param {Number} value
|
|
183
|
-
* @param {Number} oldValue
|
|
184
|
-
*/
|
|
185
|
-
_checkNeedTransitions(target, propertyName, value, oldValue) {
|
|
186
|
-
if (
|
|
187
|
-
typeof oldValue === 'undefined' ||
|
|
188
|
-
!target.transitionProperty ||
|
|
189
|
-
!target.transitionDuration ||
|
|
190
|
-
!target.transitionProperty.split(' ').includes(propertyName)
|
|
191
|
-
)
|
|
192
|
-
return;
|
|
193
|
-
|
|
194
|
-
const baseNewValue = target._baseObject[propertyName];
|
|
195
|
-
|
|
196
|
-
//remove old active tween
|
|
197
|
-
const currentTween = target._transitions.tweens[propertyName];
|
|
198
|
-
|
|
199
|
-
if (currentTween)
|
|
200
|
-
currentTween.kill();
|
|
201
|
-
|
|
202
|
-
//set base value
|
|
203
|
-
target._baseObject[propertyName] = oldValue;
|
|
204
|
-
|
|
205
|
-
//create new tween
|
|
206
|
-
const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
|
|
207
|
-
tweenParams[propertyName] = baseNewValue;
|
|
208
|
-
|
|
209
|
-
if (target.transitionDelay)
|
|
210
|
-
tweenParams.delay = target.transitionDelay / 1000;
|
|
211
|
-
|
|
212
|
-
const newTween = gsap.to(target._baseObject, tweenParams);
|
|
213
|
-
target._transitions.tweens[propertyName] = newTween;
|
|
214
|
-
|
|
215
|
-
newTween.eventCallback("onComplete", () => {
|
|
216
|
-
target._transitions.tweens[propertyName] = null;
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
_getSelectorProperties() {
|
|
221
|
-
return [
|
|
222
|
-
'id', 'name', 'class'
|
|
223
|
-
];
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
_getOriginalModelExceptions() {
|
|
227
|
-
return [
|
|
228
|
-
'parent', 'contents'
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
_getAliases() {
|
|
233
|
-
return {
|
|
234
|
-
'id': 'id',
|
|
235
|
-
'name': 'name',
|
|
236
|
-
'class': 'class',
|
|
237
|
-
'x': 'x',
|
|
238
|
-
'y': 'y',
|
|
239
|
-
'z': 'zIndex',
|
|
240
|
-
'angle': 'angle',
|
|
241
|
-
'anchorX': 'anchor.x', //'anchor.x',
|
|
242
|
-
'anchorY': 'anchor.y', //'anchor.y',
|
|
243
|
-
'width': 'width', //'width',
|
|
244
|
-
'height': 'height', //'height',
|
|
245
|
-
'stretchingType': 'stretchingType',
|
|
246
|
-
'scaleX': 'scale.x', //'scale.x',
|
|
247
|
-
'scaleY': 'scale.y', //'scale.y',
|
|
248
|
-
'alignX': 'alignX', //'alignX',
|
|
249
|
-
'alignY': 'alignY', //'alignY',
|
|
250
|
-
'parent': 'parent',
|
|
251
|
-
'rightOffset': 'rightOffset',
|
|
252
|
-
'bottomOffset': 'bottomOffset',
|
|
253
|
-
'alpha': 'alpha',
|
|
254
|
-
'visible': 'visible',
|
|
255
|
-
'text': 'text',
|
|
256
|
-
//'assetKey': 'function.setAssetKey', /todo
|
|
257
|
-
'frame': 'frame',
|
|
258
|
-
'blendMode': 'blendMode',
|
|
259
|
-
'tint': 'tint',
|
|
260
|
-
'action': 'events.onInputUp._bindings.0._listener', //todo
|
|
261
|
-
'btnFrames.over': 'frames.over',
|
|
262
|
-
'btnFrames.out': 'frames.out',
|
|
263
|
-
'btnFrames.down': 'frames.down',
|
|
264
|
-
'btnFrames.up': 'frames.up',
|
|
265
|
-
'align': 'align',
|
|
266
|
-
'filters': 'filters',
|
|
267
|
-
'lineSpacing': 'lineSpacing',
|
|
268
|
-
'maxWidth': 'maxWidth',
|
|
269
|
-
'maxHeight': 'maxHeight',
|
|
270
|
-
'lineHeight': 'style.lineHeight',
|
|
271
|
-
'fontFamily': 'style.fontFamily',
|
|
272
|
-
'fontSize': 'style.fontSize',
|
|
273
|
-
'fontStyle': 'style.fontStyle',
|
|
274
|
-
'fontWeight': 'style.fontWeight',
|
|
275
|
-
'fill': 'style.fill',
|
|
276
|
-
'fillCustomColors': 'fillCustomColors',
|
|
277
|
-
'stroke': 'style.stroke',
|
|
278
|
-
'strokeThickness': 'style.strokeThickness',
|
|
279
|
-
'dropShadow': 'style.dropShadow',
|
|
280
|
-
'dropShadowColor': 'style.dropShadowColor',
|
|
281
|
-
'dropShadowBlur': 'style.dropShadowBlur',
|
|
282
|
-
'dropShadowAngle': 'style.dropShadowAngle',
|
|
283
|
-
'dropShadowDistance': 'style.dropShadowDistance',
|
|
284
|
-
'wordWrap': 'style.wordWrap',
|
|
285
|
-
'wordWrapWidth': 'style.wordWrapWidth',
|
|
286
|
-
'leading': 'style.leading',
|
|
287
|
-
'letterSpacing': 'style.letterSpacing',
|
|
288
|
-
'textAlign': 'style.align',
|
|
289
|
-
'enabled': 'input.enabled',
|
|
290
|
-
'cacheAsBitmap': 'cacheAsBitmap',
|
|
291
|
-
'ignoreParentMask': 'ignoreParentMask',
|
|
292
|
-
//baseObject functions
|
|
293
|
-
'toGlobal': 'toGlobal'
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
module.exports = ModulesObjectsProxy;
|
|
1
|
+
class ModulesObjectsProxy {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.singleton = true;
|
|
4
|
+
this._safeFlag = false;
|
|
5
|
+
|
|
6
|
+
this._customSetLogic = this._customSetLogic.bind(this);
|
|
7
|
+
this._customGetLogic = this._customGetLogic.bind(this);
|
|
8
|
+
|
|
9
|
+
this._propertyAdapter = this.getInstance('PropertyAdapter');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
get(model) {
|
|
13
|
+
const _this = this;
|
|
14
|
+
|
|
15
|
+
let proxy = new Proxy(model, {
|
|
16
|
+
get(target, key, receiver) {
|
|
17
|
+
const rv = Reflect.get(target, key, receiver);
|
|
18
|
+
return _this._customGetLogic({ target: target, proxy: receiver }, key, rv);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
set(target, key, value, receiver) {
|
|
22
|
+
const oldValue = target._baseObject[key];
|
|
23
|
+
const rv = Reflect.set(target, key, value, receiver);
|
|
24
|
+
_this._customSetLogic(target, key, value, proxy, oldValue);
|
|
25
|
+
return rv;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
model.proxyObject = proxy;
|
|
30
|
+
return proxy;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* targetObject - object from models
|
|
34
|
+
* propertyName - property to adapt for PIXI object
|
|
35
|
+
* value - value to set
|
|
36
|
+
*/
|
|
37
|
+
_setProperty(target, propertyName, value, oldValue) {
|
|
38
|
+
const isAdaptiveProperty = this._propertyAdapter.isAdaptiveProperty(propertyName);
|
|
39
|
+
|
|
40
|
+
if (isAdaptiveProperty)
|
|
41
|
+
this._propertyAdapter.propertyChangeHandler(target, propertyName);
|
|
42
|
+
else
|
|
43
|
+
Urso.helper.recursiveSet(propertyName, value, target._baseObject);
|
|
44
|
+
|
|
45
|
+
this._checkNeedTransitions(target, propertyName, value, oldValue);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
safeSetValueToTarget(target, key, value) {
|
|
49
|
+
this._safeFlag = true;
|
|
50
|
+
|
|
51
|
+
const originalValue = target._originalModel[key]; // we need to save original value in the end
|
|
52
|
+
|
|
53
|
+
//setting value
|
|
54
|
+
target[key] = value;
|
|
55
|
+
|
|
56
|
+
target._originalModel[key] = originalValue;
|
|
57
|
+
|
|
58
|
+
this._safeFlag = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//returns reflectValue = value that would be used when target[key] is called
|
|
62
|
+
_customGetLogic(object, key, reflectValue) {
|
|
63
|
+
const target = object.target;
|
|
64
|
+
const wrapKey = this._getAliases()[key];
|
|
65
|
+
const isReflectValueObject = typeof reflectValue !== 'undefined'; //&& typeof reflectValue !== 'boolean'; //it was for getting width and height
|
|
66
|
+
|
|
67
|
+
if ((isReflectValueObject && (typeof wrapKey != 'undefined')) || !wrapKey)
|
|
68
|
+
return reflectValue;
|
|
69
|
+
|
|
70
|
+
return Urso.helper.recursiveGet(wrapKey, target._baseObject, reflectValue);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_customSetLogic(target, key, value, proxy, oldValue) {
|
|
74
|
+
if (!this._getOriginalModelExceptions().includes(key))
|
|
75
|
+
target._originalModel[key] = value;
|
|
76
|
+
|
|
77
|
+
//apply to pixi
|
|
78
|
+
const propertyName = this._getAliases()[key];
|
|
79
|
+
|
|
80
|
+
if (!propertyName)
|
|
81
|
+
return false;
|
|
82
|
+
|
|
83
|
+
if (propertyName.startsWith('function.')) {
|
|
84
|
+
this._runCustomFunction(propertyName, target);
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this._checkSelectorProperties(key);
|
|
89
|
+
|
|
90
|
+
this._setProperty(target, propertyName, value, oldValue);
|
|
91
|
+
|
|
92
|
+
//if property is text - we will update it
|
|
93
|
+
if (propertyName === 'text') {
|
|
94
|
+
target._baseObject.updateText(true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this._checkMaxSize(target);
|
|
98
|
+
|
|
99
|
+
//setup dirty to recalc params
|
|
100
|
+
if (typeof target._baseObject.dirty !== 'undefined')
|
|
101
|
+
target._baseObject.dirty = true;
|
|
102
|
+
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
_checkMaxSize(target) {
|
|
107
|
+
if (!target.maxWidth && !target.maxHeight)
|
|
108
|
+
return;
|
|
109
|
+
|
|
110
|
+
let calculationNeed = false;
|
|
111
|
+
|
|
112
|
+
const baseObject = target._baseObject;
|
|
113
|
+
|
|
114
|
+
baseObject.updateTransform();
|
|
115
|
+
|
|
116
|
+
//Pixi texts have _texture.orig.width. When we call baseObject.width, Pixi runs update text. Its too slow operation.
|
|
117
|
+
if (baseObject._texture && (!baseObject._texture.orig.width || !baseObject._texture.orig.height)) {
|
|
118
|
+
baseObject.updateText(true);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const baseObjectWidth = baseObject._texture ? Math.abs(baseObject.scale.x) * baseObject._texture.orig.width : baseObject.width;
|
|
122
|
+
const baseObjectHeight = baseObject._texture ? Math.abs(baseObject.scale.y) * baseObject._texture.orig.height : baseObject.height;
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
target.maxWidth &&
|
|
126
|
+
(
|
|
127
|
+
target.maxWidth < baseObjectWidth || //maxWidth is lower than object width
|
|
128
|
+
(target.maxWidth > baseObjectWidth && target._baseObject.scale.x < 1) //maxWidth is higher than object width and object is downscaled
|
|
129
|
+
)
|
|
130
|
+
) //check maxWidth
|
|
131
|
+
calculationNeed = true;
|
|
132
|
+
|
|
133
|
+
if (
|
|
134
|
+
target.maxHeight &&
|
|
135
|
+
(
|
|
136
|
+
target.maxHeight < baseObjectHeight || //maxHeight is lower than object height
|
|
137
|
+
(target.maxHeight > baseObjectHeight && target._baseObject.scale.y < 1) //maxHeight is higher than object height and object is downscaled
|
|
138
|
+
)
|
|
139
|
+
) //check maxHeight
|
|
140
|
+
calculationNeed = true;
|
|
141
|
+
|
|
142
|
+
if (!calculationNeed)
|
|
143
|
+
return;
|
|
144
|
+
|
|
145
|
+
let scaleNeed = 1;
|
|
146
|
+
|
|
147
|
+
if (target.maxWidth) {
|
|
148
|
+
scaleNeed = Math.abs((target._baseObject.scale.x * target.maxWidth) / target._baseObject.width);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (target.maxHeight) {
|
|
152
|
+
const scaleYNeed = Math.abs((target._baseObject.scale.y * target.maxHeight) / target._baseObject.height);
|
|
153
|
+
|
|
154
|
+
if (scaleNeed > scaleYNeed)
|
|
155
|
+
scaleNeed = scaleYNeed;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (scaleNeed > 1)
|
|
159
|
+
scaleNeed = 1;
|
|
160
|
+
|
|
161
|
+
target._baseObject.scale.x = scaleNeed * Math.sign(target._baseObject.scale.x);
|
|
162
|
+
target._baseObject.scale.y = scaleNeed * Math.sign(target._baseObject.scale.y);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_runCustomFunction(property, target) {
|
|
166
|
+
const funcName = property.replace('function.', '');
|
|
167
|
+
if (target[funcName])
|
|
168
|
+
target[funcName]();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
_checkSelectorProperties(key) {
|
|
172
|
+
if (!this._safeFlag && this._getSelectorProperties().includes(key)) {
|
|
173
|
+
Urso.logger.error('ModulesObjectsProxy error: you are trying to change selector property: ' + key);
|
|
174
|
+
Urso.logger.error('Notice: use functions addClass, removeClass, setId, setName');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* transitions tweens creation
|
|
180
|
+
* @param {Object} target - ObjectsModel
|
|
181
|
+
* @param {String} propertyName
|
|
182
|
+
* @param {Number} value
|
|
183
|
+
* @param {Number} oldValue
|
|
184
|
+
*/
|
|
185
|
+
_checkNeedTransitions(target, propertyName, value, oldValue) {
|
|
186
|
+
if (
|
|
187
|
+
typeof oldValue === 'undefined' ||
|
|
188
|
+
!target.transitionProperty ||
|
|
189
|
+
!target.transitionDuration ||
|
|
190
|
+
!target.transitionProperty.split(' ').includes(propertyName)
|
|
191
|
+
)
|
|
192
|
+
return;
|
|
193
|
+
|
|
194
|
+
const baseNewValue = target._baseObject[propertyName];
|
|
195
|
+
|
|
196
|
+
//remove old active tween
|
|
197
|
+
const currentTween = target._transitions.tweens[propertyName];
|
|
198
|
+
|
|
199
|
+
if (currentTween)
|
|
200
|
+
currentTween.kill();
|
|
201
|
+
|
|
202
|
+
//set base value
|
|
203
|
+
target._baseObject[propertyName] = oldValue;
|
|
204
|
+
|
|
205
|
+
//create new tween
|
|
206
|
+
const tweenParams = { duration: target.transitionDuration / 1000, ease: "none" };
|
|
207
|
+
tweenParams[propertyName] = baseNewValue;
|
|
208
|
+
|
|
209
|
+
if (target.transitionDelay)
|
|
210
|
+
tweenParams.delay = target.transitionDelay / 1000;
|
|
211
|
+
|
|
212
|
+
const newTween = gsap.to(target._baseObject, tweenParams);
|
|
213
|
+
target._transitions.tweens[propertyName] = newTween;
|
|
214
|
+
|
|
215
|
+
newTween.eventCallback("onComplete", () => {
|
|
216
|
+
target._transitions.tweens[propertyName] = null;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
_getSelectorProperties() {
|
|
221
|
+
return [
|
|
222
|
+
'id', 'name', 'class'
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
_getOriginalModelExceptions() {
|
|
227
|
+
return [
|
|
228
|
+
'parent', 'contents'
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_getAliases() {
|
|
233
|
+
return {
|
|
234
|
+
'id': 'id',
|
|
235
|
+
'name': 'name',
|
|
236
|
+
'class': 'class',
|
|
237
|
+
'x': 'x',
|
|
238
|
+
'y': 'y',
|
|
239
|
+
'z': 'zIndex',
|
|
240
|
+
'angle': 'angle',
|
|
241
|
+
'anchorX': 'anchor.x', //'anchor.x',
|
|
242
|
+
'anchorY': 'anchor.y', //'anchor.y',
|
|
243
|
+
'width': 'width', //'width',
|
|
244
|
+
'height': 'height', //'height',
|
|
245
|
+
'stretchingType': 'stretchingType',
|
|
246
|
+
'scaleX': 'scale.x', //'scale.x',
|
|
247
|
+
'scaleY': 'scale.y', //'scale.y',
|
|
248
|
+
'alignX': 'alignX', //'alignX',
|
|
249
|
+
'alignY': 'alignY', //'alignY',
|
|
250
|
+
'parent': 'parent',
|
|
251
|
+
'rightOffset': 'rightOffset',
|
|
252
|
+
'bottomOffset': 'bottomOffset',
|
|
253
|
+
'alpha': 'alpha',
|
|
254
|
+
'visible': 'visible',
|
|
255
|
+
'text': 'text',
|
|
256
|
+
//'assetKey': 'function.setAssetKey', /todo
|
|
257
|
+
'frame': 'frame',
|
|
258
|
+
'blendMode': 'blendMode',
|
|
259
|
+
'tint': 'tint',
|
|
260
|
+
'action': 'events.onInputUp._bindings.0._listener', //todo
|
|
261
|
+
'btnFrames.over': 'frames.over',
|
|
262
|
+
'btnFrames.out': 'frames.out',
|
|
263
|
+
'btnFrames.down': 'frames.down',
|
|
264
|
+
'btnFrames.up': 'frames.up',
|
|
265
|
+
'align': 'align',
|
|
266
|
+
'filters': 'filters',
|
|
267
|
+
'lineSpacing': 'lineSpacing',
|
|
268
|
+
'maxWidth': 'maxWidth',
|
|
269
|
+
'maxHeight': 'maxHeight',
|
|
270
|
+
'lineHeight': 'style.lineHeight',
|
|
271
|
+
'fontFamily': 'style.fontFamily',
|
|
272
|
+
'fontSize': 'style.fontSize',
|
|
273
|
+
'fontStyle': 'style.fontStyle',
|
|
274
|
+
'fontWeight': 'style.fontWeight',
|
|
275
|
+
'fill': 'style.fill',
|
|
276
|
+
'fillCustomColors': 'fillCustomColors',
|
|
277
|
+
'stroke': 'style.stroke',
|
|
278
|
+
'strokeThickness': 'style.strokeThickness',
|
|
279
|
+
'dropShadow': 'style.dropShadow',
|
|
280
|
+
'dropShadowColor': 'style.dropShadowColor',
|
|
281
|
+
'dropShadowBlur': 'style.dropShadowBlur',
|
|
282
|
+
'dropShadowAngle': 'style.dropShadowAngle',
|
|
283
|
+
'dropShadowDistance': 'style.dropShadowDistance',
|
|
284
|
+
'wordWrap': 'style.wordWrap',
|
|
285
|
+
'wordWrapWidth': 'style.wordWrapWidth',
|
|
286
|
+
'leading': 'style.leading',
|
|
287
|
+
'letterSpacing': 'style.letterSpacing',
|
|
288
|
+
'textAlign': 'style.align',
|
|
289
|
+
'enabled': 'input.enabled',
|
|
290
|
+
'cacheAsBitmap': 'cacheAsBitmap',
|
|
291
|
+
'ignoreParentMask': 'ignoreParentMask',
|
|
292
|
+
//baseObject functions
|
|
293
|
+
'toGlobal': 'toGlobal'
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
module.exports = ModulesObjectsProxy;
|