@urso/core 0.1.93 → 0.1.98
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/build/js/index.js.LICENSE.txt +41 -39
- package/package.json +5 -2
- package/src/js/app.js +1 -0
- package/src/js/config/main.js +2 -1
- package/src/js/extra/_info.js +1 -0
- package/src/js/lib/helper.js +11 -0
- package/src/js/lib/loader.js +22 -1
- package/src/js/modules/assets/config.js +11 -1
- package/src/js/modules/assets/controller.js +16 -0
- package/src/js/modules/assets/service.js +64 -37
- package/src/js/modules/objects/create.js +15 -0
- package/src/js/modules/objects/models/_info.js +5 -0
- package/src/js/modules/objects/models/checkbox.js +96 -0
- package/src/js/modules/objects/models/scrollbox.js +62 -0
- package/src/js/modules/objects/models/slider.js +154 -0
- package/src/js/modules/objects/models/textInput.js +55 -0
- package/src/js/modules/objects/models/toggle.js +169 -0
- package/src/js/modules/objects/propertyAdapter.js +7 -2
- package/src/js/modules/observer/events.js +4 -0
- package/src/js/modules/template/types.js +6 -1
|
@@ -27,135 +27,127 @@ object-assign
|
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
29
|
/*!
|
|
30
|
-
* @pixi/
|
|
31
|
-
* Compiled Mon,
|
|
32
|
-
*
|
|
33
|
-
* @pixi/accessibility is licensed under the MIT License.
|
|
34
|
-
* http://www.opensource.org/licenses/mit-license
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/*!
|
|
38
|
-
* @pixi/constants - v5.3.10
|
|
39
|
-
* Compiled Mon, 07 Jun 2021 22:37:25 UTC
|
|
30
|
+
* @pixi/constants - v5.3.11
|
|
31
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
40
32
|
*
|
|
41
33
|
* @pixi/constants is licensed under the MIT License.
|
|
42
34
|
* http://www.opensource.org/licenses/mit-license
|
|
43
35
|
*/
|
|
44
36
|
|
|
45
37
|
/*!
|
|
46
|
-
* @pixi/core - v5.3.
|
|
47
|
-
* Compiled Mon,
|
|
38
|
+
* @pixi/core - v5.3.11
|
|
39
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
48
40
|
*
|
|
49
41
|
* @pixi/core is licensed under the MIT License.
|
|
50
42
|
* http://www.opensource.org/licenses/mit-license
|
|
51
43
|
*/
|
|
52
44
|
|
|
53
45
|
/*!
|
|
54
|
-
* @pixi/display - v5.3.
|
|
55
|
-
* Compiled Mon,
|
|
46
|
+
* @pixi/display - v5.3.11
|
|
47
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
56
48
|
*
|
|
57
49
|
* @pixi/display is licensed under the MIT License.
|
|
58
50
|
* http://www.opensource.org/licenses/mit-license
|
|
59
51
|
*/
|
|
60
52
|
|
|
61
53
|
/*!
|
|
62
|
-
* @pixi/extract - v5.3.
|
|
63
|
-
* Compiled Mon,
|
|
54
|
+
* @pixi/extract - v5.3.11
|
|
55
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
64
56
|
*
|
|
65
57
|
* @pixi/extract is licensed under the MIT License.
|
|
66
58
|
* http://www.opensource.org/licenses/mit-license
|
|
67
59
|
*/
|
|
68
60
|
|
|
69
61
|
/*!
|
|
70
|
-
* @pixi/filter-displacement - v5.3.
|
|
71
|
-
* Compiled Mon,
|
|
62
|
+
* @pixi/filter-displacement - v5.3.11
|
|
63
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
72
64
|
*
|
|
73
65
|
* @pixi/filter-displacement is licensed under the MIT License.
|
|
74
66
|
* http://www.opensource.org/licenses/mit-license
|
|
75
67
|
*/
|
|
76
68
|
|
|
77
69
|
/*!
|
|
78
|
-
* @pixi/loaders - v5.3.
|
|
79
|
-
* Compiled Mon,
|
|
70
|
+
* @pixi/loaders - v5.3.11
|
|
71
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
80
72
|
*
|
|
81
73
|
* @pixi/loaders is licensed under the MIT License.
|
|
82
74
|
* http://www.opensource.org/licenses/mit-license
|
|
83
75
|
*/
|
|
84
76
|
|
|
85
77
|
/*!
|
|
86
|
-
* @pixi/math - v5.3.
|
|
87
|
-
* Compiled Mon,
|
|
78
|
+
* @pixi/math - v5.3.11
|
|
79
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
88
80
|
*
|
|
89
81
|
* @pixi/math is licensed under the MIT License.
|
|
90
82
|
* http://www.opensource.org/licenses/mit-license
|
|
91
83
|
*/
|
|
92
84
|
|
|
93
85
|
/*!
|
|
94
|
-
* @pixi/mesh-extras - v5.3.
|
|
95
|
-
* Compiled Mon,
|
|
86
|
+
* @pixi/mesh-extras - v5.3.11
|
|
87
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
96
88
|
*
|
|
97
89
|
* @pixi/mesh-extras is licensed under the MIT License.
|
|
98
90
|
* http://www.opensource.org/licenses/mit-license
|
|
99
91
|
*/
|
|
100
92
|
|
|
101
93
|
/*!
|
|
102
|
-
* @pixi/mixin-get-child-by-name - v5.3.
|
|
103
|
-
* Compiled Mon,
|
|
94
|
+
* @pixi/mixin-get-child-by-name - v5.3.11
|
|
95
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
104
96
|
*
|
|
105
97
|
* @pixi/mixin-get-child-by-name is licensed under the MIT License.
|
|
106
98
|
* http://www.opensource.org/licenses/mit-license
|
|
107
99
|
*/
|
|
108
100
|
|
|
109
101
|
/*!
|
|
110
|
-
* @pixi/mixin-get-global-position - v5.3.
|
|
111
|
-
* Compiled Mon,
|
|
102
|
+
* @pixi/mixin-get-global-position - v5.3.11
|
|
103
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
112
104
|
*
|
|
113
105
|
* @pixi/mixin-get-global-position is licensed under the MIT License.
|
|
114
106
|
* http://www.opensource.org/licenses/mit-license
|
|
115
107
|
*/
|
|
116
108
|
|
|
117
109
|
/*!
|
|
118
|
-
* @pixi/polyfill - v5.3.
|
|
119
|
-
* Compiled Mon,
|
|
110
|
+
* @pixi/polyfill - v5.3.11
|
|
111
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
120
112
|
*
|
|
121
113
|
* @pixi/polyfill is licensed under the MIT License.
|
|
122
114
|
* http://www.opensource.org/licenses/mit-license
|
|
123
115
|
*/
|
|
124
116
|
|
|
125
117
|
/*!
|
|
126
|
-
* @pixi/prepare - v5.3.
|
|
127
|
-
* Compiled Mon,
|
|
118
|
+
* @pixi/prepare - v5.3.11
|
|
119
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
128
120
|
*
|
|
129
121
|
* @pixi/prepare is licensed under the MIT License.
|
|
130
122
|
* http://www.opensource.org/licenses/mit-license
|
|
131
123
|
*/
|
|
132
124
|
|
|
133
125
|
/*!
|
|
134
|
-
* @pixi/runner - v5.3.
|
|
135
|
-
* Compiled Mon,
|
|
126
|
+
* @pixi/runner - v5.3.11
|
|
127
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
136
128
|
*
|
|
137
129
|
* @pixi/runner is licensed under the MIT License.
|
|
138
130
|
* http://www.opensource.org/licenses/mit-license
|
|
139
131
|
*/
|
|
140
132
|
|
|
141
133
|
/*!
|
|
142
|
-
* @pixi/ticker - v5.3.
|
|
143
|
-
* Compiled Mon,
|
|
134
|
+
* @pixi/ticker - v5.3.11
|
|
135
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
144
136
|
*
|
|
145
137
|
* @pixi/ticker is licensed under the MIT License.
|
|
146
138
|
* http://www.opensource.org/licenses/mit-license
|
|
147
139
|
*/
|
|
148
140
|
|
|
149
141
|
/*!
|
|
150
|
-
* @pixi/utils - v5.3.
|
|
151
|
-
* Compiled Mon,
|
|
142
|
+
* @pixi/utils - v5.3.11
|
|
143
|
+
* Compiled Mon, 01 Nov 2021 16:10:12 UTC
|
|
152
144
|
*
|
|
153
145
|
* @pixi/utils is licensed under the MIT License.
|
|
154
146
|
* http://www.opensource.org/licenses/mit-license
|
|
155
147
|
*/
|
|
156
148
|
|
|
157
149
|
/*!
|
|
158
|
-
* GSAP 3.
|
|
150
|
+
* GSAP 3.8.0
|
|
159
151
|
* https://greensock.com
|
|
160
152
|
*
|
|
161
153
|
* @license Copyright 2008-2021, GreenSock. All rights reserved.
|
|
@@ -172,6 +164,16 @@ object-assign
|
|
|
172
164
|
* http://www.opensource.org/licenses/mit-license
|
|
173
165
|
*/
|
|
174
166
|
|
|
167
|
+
/*!
|
|
168
|
+
* pixi-viewport - v4.34.3
|
|
169
|
+
* Compiled Wed, 01 Dec 2021 19:28:04 UTC
|
|
170
|
+
*
|
|
171
|
+
* pixi-viewport is licensed under the MIT License.
|
|
172
|
+
* http://www.opensource.org/licenses/mit-license
|
|
173
|
+
*
|
|
174
|
+
* Copyright 2019-2020, David Figatner, All Rights Reserved
|
|
175
|
+
*/
|
|
176
|
+
|
|
175
177
|
/*!
|
|
176
178
|
* resource-loader - v3.0.1
|
|
177
179
|
* https://github.com/pixijs/pixi-sound
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@urso/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.98",
|
|
4
4
|
"description": "HTML5 game engine",
|
|
5
5
|
"main": "build/js/index.js",
|
|
6
6
|
"author": "Megbrimef",
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
"pixi-projection": "0.3.15",
|
|
30
30
|
"pixi-spine": "^2.1.11",
|
|
31
31
|
"pixi.js": "^5.1.3",
|
|
32
|
-
"pixi5-dragonbones": "5.7.0-2"
|
|
32
|
+
"pixi5-dragonbones": "5.7.0-2",
|
|
33
|
+
"pixi-scrollbox": "^2.3.1",
|
|
34
|
+
"pixi-viewport": "^4.34.0",
|
|
35
|
+
"pixi-text-input": "^1.0.6"
|
|
33
36
|
},
|
|
34
37
|
"devDependencies": {
|
|
35
38
|
"@babel/core": "^7.12.10",
|
package/src/js/app.js
CHANGED
package/src/js/config/main.js
CHANGED
|
@@ -2,7 +2,8 @@ let ConfigMain = {
|
|
|
2
2
|
title: 'Urso', //game title
|
|
3
3
|
mode: "development", // development/production/testing
|
|
4
4
|
extendingChain: ['Urso.Core'], //chain that will be set as Urso.Game
|
|
5
|
-
defaultScene: 'play' //default scene to display
|
|
5
|
+
defaultScene: 'play', //default scene to display
|
|
6
|
+
useBinPath: false
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
module.exports = ConfigMain;
|
package/src/js/extra/_info.js
CHANGED
package/src/js/lib/helper.js
CHANGED
|
@@ -201,6 +201,17 @@ class LibHelper {
|
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* tranpose matrix (rows to cols)
|
|
206
|
+
* @param {Array} matrix
|
|
207
|
+
* @returns {Array}
|
|
208
|
+
*/
|
|
209
|
+
transpose(matrix) {
|
|
210
|
+
return Object.keys(matrix[0])
|
|
211
|
+
.map(colNumber => matrix
|
|
212
|
+
.map(rowNumber => rowNumber[colNumber]));
|
|
213
|
+
}
|
|
214
|
+
|
|
204
215
|
/**
|
|
205
216
|
* recursive merge two objects into one
|
|
206
217
|
* @param {Object} obj1
|
package/src/js/lib/loader.js
CHANGED
|
@@ -17,6 +17,26 @@ class LibLoader {
|
|
|
17
17
|
this._assetsQuery.push(asset);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* gets part of loading path
|
|
22
|
+
*/
|
|
23
|
+
_getLoadPath(asset){
|
|
24
|
+
const { path } = asset;
|
|
25
|
+
|
|
26
|
+
if(!Urso.config.useBinPath) {
|
|
27
|
+
return `assets/${path}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const quality = Urso.getInstance('Modules.Assets.Service').getQuality();
|
|
31
|
+
const splitted = path.split('/');
|
|
32
|
+
|
|
33
|
+
if (splitted[0] === 'images') {
|
|
34
|
+
splitted.splice(1, 0, quality);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return `bin/${splitted.join('/')}`;
|
|
38
|
+
};
|
|
39
|
+
|
|
20
40
|
/**
|
|
21
41
|
* store loaded asset in cache
|
|
22
42
|
*/
|
|
@@ -79,7 +99,8 @@ class LibLoader {
|
|
|
79
99
|
// TODO: check to load
|
|
80
100
|
|
|
81
101
|
const params = asset.params || false; // TODO: Set params field in base mode
|
|
82
|
-
|
|
102
|
+
const loadPath = this._getLoadPath(asset);
|
|
103
|
+
loader.add(asset.key, loadPath, params, (resource) => this._storeAsset(asset, resource)) //TODO set assets resolution instead _processLoadedImage baseTexture resolution
|
|
83
104
|
});
|
|
84
105
|
|
|
85
106
|
this._onLoadUpdate({progress: 0});
|
|
@@ -2,6 +2,16 @@ class ModulesAssetsConfig {
|
|
|
2
2
|
constructor() {
|
|
3
3
|
this.singleton = true;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* quality settings for resource loading selection
|
|
7
|
+
*/
|
|
8
|
+
this.qualityFactors = {
|
|
9
|
+
medium: 0.5,
|
|
10
|
+
hd: 0.75,
|
|
11
|
+
high: 1
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
5
15
|
/**
|
|
6
16
|
* initial is the default and will load on the preload
|
|
7
17
|
* also you can call preload manualy by assets.loadGroup('groupName')
|
|
@@ -10,7 +20,7 @@ class ModulesAssetsConfig {
|
|
|
10
20
|
initial: 0 //will load on the preload
|
|
11
21
|
/*lazyPart1: 'lazyPart1',
|
|
12
22
|
lazyPart2: 'lazyPart2'*/
|
|
13
|
-
}
|
|
23
|
+
};
|
|
14
24
|
|
|
15
25
|
/**
|
|
16
26
|
* you can make lazy load groups priority here
|
|
@@ -3,6 +3,22 @@ class ModulesAssetsController {
|
|
|
3
3
|
this.singleton = true;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Update quality
|
|
8
|
+
*/
|
|
9
|
+
updateQuality(){
|
|
10
|
+
if(Urso.config.useBinPath){
|
|
11
|
+
this.getInstance('Service').updateQuality();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Current quality getter
|
|
17
|
+
*/
|
|
18
|
+
getQuality(){
|
|
19
|
+
this.getInstance('Service').getQuality();
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
/**
|
|
7
23
|
* instantly load initial assets and start lazy loading process, if needed
|
|
8
24
|
* @param {Mixed} assets - asset or array of assets
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
class ModulesAssetsService {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.singleton = true;
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
this.assets = {};
|
|
6
6
|
|
|
7
|
+
this._currentQuality = 'auto';
|
|
7
8
|
this._addedAssetsCache = [];
|
|
8
9
|
};
|
|
9
10
|
|
|
11
|
+
getQuality(){
|
|
12
|
+
return this._currentQuality;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
updateQuality(){
|
|
16
|
+
this._currentQuality = this._detectQuality();
|
|
17
|
+
Urso.addInstancesMode(this._currentQuality);
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
sortAssets(assets) {
|
|
11
21
|
this.assets[this.getInstance('Config').loadingGroups.initial] = [];
|
|
12
22
|
|
|
@@ -125,13 +135,9 @@ class ModulesAssetsService {
|
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
_processLoadedImage(assetModel) {
|
|
128
|
-
const {
|
|
129
|
-
let imageQualityKey = assetModel.useBinPath;
|
|
138
|
+
const { qualityFactors } = this.getInstance('Config');
|
|
130
139
|
|
|
131
|
-
|
|
132
|
-
imageQualityKey = current;
|
|
133
|
-
|
|
134
|
-
let qualityTextureResolution = params[imageQualityKey] || 1;
|
|
140
|
+
const resolution = qualityFactors[this._currentQuality] || 1;
|
|
135
141
|
|
|
136
142
|
const assetKey = assetModel.key;
|
|
137
143
|
//textures cache
|
|
@@ -140,14 +146,14 @@ class ModulesAssetsService {
|
|
|
140
146
|
if (!imageData) {
|
|
141
147
|
//from atlas ?!
|
|
142
148
|
let texture = Urso.cache.getFile(assetModel.path);
|
|
143
|
-
|
|
149
|
+
|
|
144
150
|
if (!texture)
|
|
145
151
|
return Urso.logger.error('ModulesAssetsService process Loaded Image error: no image ', assetModel);
|
|
146
152
|
|
|
147
153
|
Urso.cache.addTexture(assetKey, texture); //TODO change resolution of base texture
|
|
148
154
|
} else {
|
|
149
155
|
//regular image
|
|
150
|
-
const baseTexture = new PIXI.BaseTexture(imageData.data, { resolution
|
|
156
|
+
const baseTexture = new PIXI.BaseTexture(imageData.data, { resolution });
|
|
151
157
|
const texture = new PIXI.Texture(baseTexture);
|
|
152
158
|
Urso.cache.addTexture(assetKey, texture);
|
|
153
159
|
}
|
|
@@ -215,9 +221,6 @@ class ModulesAssetsService {
|
|
|
215
221
|
//set loadingGroup
|
|
216
222
|
model.loadingGroup = loadingGroup || model.loadingGroup || this.getInstance('Config').loadingGroups.initial;
|
|
217
223
|
|
|
218
|
-
//setup path if its need
|
|
219
|
-
this._setQualityPath(model); //TODO adapt for dragonbones
|
|
220
|
-
|
|
221
224
|
//check if container or dragonbones
|
|
222
225
|
if (model.contents) {
|
|
223
226
|
for (let content of model.contents) {
|
|
@@ -253,41 +256,65 @@ class ModulesAssetsService {
|
|
|
253
256
|
this.loadGroup(groupName, () => { this._continueLazyLoad(step + 1); })
|
|
254
257
|
}
|
|
255
258
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
259
|
+
_qualityReducer(qualityFactors, widthFactor){
|
|
260
|
+
return [(acc, val) => {
|
|
261
|
+
if (acc === null) {
|
|
262
|
+
return val;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const currentQuality = qualityFactors[acc];
|
|
266
|
+
const qualityFactor = qualityFactors[val];
|
|
267
|
+
|
|
268
|
+
const nextQuality = (currentQuality > qualityFactor && qualityFactor >= widthFactor)
|
|
269
|
+
|| (qualityFactor >= widthFactor && widthFactor > currentQuality)
|
|
270
|
+
|| (widthFactor >= qualityFactor && qualityFactor > currentQuality);
|
|
271
|
+
|
|
272
|
+
return nextQuality ? val : acc;
|
|
273
|
+
|
|
274
|
+
}, null]
|
|
266
275
|
}
|
|
267
276
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
277
|
+
_detectQuality(){
|
|
278
|
+
const { qualityFactors } = this.getInstance('Config');
|
|
279
|
+
const userQuality = Urso.helper.parseGetParams()['quality'];
|
|
280
|
+
|
|
281
|
+
if(userQuality && qualityFactors[userQuality]){
|
|
282
|
+
return userQuality;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return this._calculateQuality(qualityFactors);
|
|
286
|
+
}
|
|
271
287
|
|
|
272
|
-
|
|
288
|
+
_calculateQuality(qualityFactors){
|
|
289
|
+
const { android, iOS, iPad, macOS } = Urso.device;
|
|
290
|
+
const isMobile = android || iOS || iPad;
|
|
273
291
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
asset.path = asset.path.replace('assets', `bin/${qualityPath}`);
|
|
292
|
+
if (macOS && !isMobile) {
|
|
293
|
+
return 'high';
|
|
277
294
|
}
|
|
278
295
|
|
|
279
|
-
if
|
|
280
|
-
|
|
281
|
-
return;
|
|
296
|
+
if(macOS && iPad) {
|
|
297
|
+
return 'medium';
|
|
282
298
|
}
|
|
283
299
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
300
|
+
const resCfg = Urso.getInstance('Modules.Scenes.ResolutionsConfig').contents[0];
|
|
301
|
+
|
|
302
|
+
const { devicePixelRatio } = window;
|
|
303
|
+
let { width, height } = screen;
|
|
287
304
|
|
|
288
|
-
|
|
289
|
-
|
|
305
|
+
if (isMobile) {
|
|
306
|
+
width = (width > height) ? width : height;
|
|
290
307
|
}
|
|
308
|
+
|
|
309
|
+
if (iOS) {
|
|
310
|
+
width *= devicePixelRatio;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const widthFactor = width / resCfg.width;
|
|
314
|
+
|
|
315
|
+
return Object
|
|
316
|
+
.keys(qualityFactors)
|
|
317
|
+
.reduce(...this._qualityReducer(qualityFactors, widthFactor));
|
|
291
318
|
}
|
|
292
319
|
|
|
293
320
|
_addAssetToLoader(assetModel, loader) {
|
|
@@ -105,6 +105,21 @@ class ModulesObjectsCreate {
|
|
|
105
105
|
case Urso.types.objects.EMITTER:
|
|
106
106
|
model = this.getInstance('Models.Emitter', object);
|
|
107
107
|
break;
|
|
108
|
+
case Urso.types.objects.SLIDER:
|
|
109
|
+
model = this.getInstance('Models.Slider', object);
|
|
110
|
+
break;
|
|
111
|
+
case Urso.types.objects.TOGGLE:
|
|
112
|
+
model = this.getInstance('Models.Toggle', object);
|
|
113
|
+
break;
|
|
114
|
+
case Urso.types.objects.CHECKBOX:
|
|
115
|
+
model = this.getInstance('Models.Checkbox', object);
|
|
116
|
+
break;
|
|
117
|
+
case Urso.types.objects.SCROLLBOX:
|
|
118
|
+
model = this.getInstance('Models.Scrollbox', object);
|
|
119
|
+
break;
|
|
120
|
+
case Urso.types.objects.TEXTINPUT:
|
|
121
|
+
model = this.getInstance('Models.TextInput', object);
|
|
122
|
+
break;
|
|
108
123
|
default:
|
|
109
124
|
break;
|
|
110
125
|
}
|
|
@@ -16,5 +16,10 @@ Urso.Core.Modules.Objects.Models = {
|
|
|
16
16
|
Mask: require('./mask.js'),
|
|
17
17
|
Spine: require('./spine.js'),
|
|
18
18
|
Text: require('./text.js'),
|
|
19
|
+
Slider: require('./slider.js'),
|
|
20
|
+
Toggle: require('./toggle.js'),
|
|
21
|
+
Checkbox: require('./checkbox.js'),
|
|
22
|
+
Scrollbox: require('./scrollbox.js'),
|
|
23
|
+
TextInput: require('./textInput.js'),
|
|
19
24
|
World: require('./world.js')
|
|
20
25
|
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const UrsoCoreModulesObjectsModelsToggle = require('./toggle');
|
|
2
|
+
|
|
3
|
+
class ModulesObjectsModelsCheckbox extends UrsoCoreModulesObjectsModelsToggle {
|
|
4
|
+
constructor(params) {
|
|
5
|
+
super(params);
|
|
6
|
+
|
|
7
|
+
this._isDisabled = false;
|
|
8
|
+
this._lable = null;
|
|
9
|
+
this._checkbox = null;
|
|
10
|
+
|
|
11
|
+
this.type = Urso.types.objects.CHECKBOX;
|
|
12
|
+
|
|
13
|
+
this._createCheckbox();
|
|
14
|
+
|
|
15
|
+
this.enable = this.enable.bind(this);
|
|
16
|
+
this.disable = this.disable.bind(this);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setupParams(params) {
|
|
20
|
+
super.setupParams(params);
|
|
21
|
+
|
|
22
|
+
this.contents = [];
|
|
23
|
+
|
|
24
|
+
this.action = Urso.helper.recursiveGet('action', params, () => {
|
|
25
|
+
this.emit(Urso.events.MODULES_OBJECTS_CHECKBOX_PRESS, { name: this.name, status: this._toggleStatus })
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
this.action = Urso.helper.recursiveGet('action', params, () => { this.emit(Urso.events.MODULES_OBJECTS_CHECKBOX_PRESS, this.name) });
|
|
29
|
+
this.lable = Urso.helper.recursiveGet('lable', params, false);
|
|
30
|
+
|
|
31
|
+
this.defaultStatus = Urso.helper.recursiveGet('defaultStatus', params, 'unpressed'); //pressed or unpressed
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_createCheckbox() {
|
|
35
|
+
this._toggleStatus = this.defaultStatus;
|
|
36
|
+
this._checkbox = this._createObject(this.buttonFrames[`${this.defaultStatus}Out`])
|
|
37
|
+
|
|
38
|
+
if (this.lable)
|
|
39
|
+
this._lable = this._createObject(this.lable);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_createObject(model) {
|
|
43
|
+
model = Urso.helper.objectClone(model);
|
|
44
|
+
let object = Urso.objects.create(model, this);
|
|
45
|
+
|
|
46
|
+
object._baseObject.interactive = true;
|
|
47
|
+
object._baseObject.buttonMode = true;
|
|
48
|
+
|
|
49
|
+
object._baseObject
|
|
50
|
+
.on('pointerdown', this._onButtonDown.bind(this))
|
|
51
|
+
.on('pointerup', this._onButtonUp.bind(this))
|
|
52
|
+
.on('pointerupoutside', this._onButtonUp.bind(this))
|
|
53
|
+
.on('pointerover', this._onButtonOver.bind(this))
|
|
54
|
+
.on('pointerout', this._onButtonOut.bind(this));
|
|
55
|
+
|
|
56
|
+
return object;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_addBaseObject() {
|
|
60
|
+
this._baseObject = new PIXI.Container();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
_drawGraphics({ polygon, rectangle, fillColor }) {
|
|
64
|
+
if (!polygon && !rectangle)
|
|
65
|
+
return;
|
|
66
|
+
|
|
67
|
+
this._checkbox._baseObject.clear();
|
|
68
|
+
this._checkbox._baseObject.beginFill(fillColor);
|
|
69
|
+
|
|
70
|
+
if (polygon && polygon.length) {
|
|
71
|
+
this._checkbox._baseObject.drawPolygon(polygon);
|
|
72
|
+
} else if (rectangle && rectangle.length) {
|
|
73
|
+
this._checkbox._baseObject.drawRect(...rectangle)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this._checkbox._baseObject.endFill();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
_changeTexture(key) {
|
|
80
|
+
if (!this.buttonFrames[key]) {
|
|
81
|
+
if (key === `${this._toggleStatus}Out`) {
|
|
82
|
+
Urso.logger.error('ModulesObjectsModelsButton assets error: no out image ' + this.buttonFrames.out);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this._changeTexture(`${this._toggleStatus}Out`); // load default texture for this key
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (this.buttonFrames[key].type === Urso.types.objects.GRAPHICS)
|
|
90
|
+
this._drawGraphics(this.buttonFrames[key].figure);
|
|
91
|
+
else
|
|
92
|
+
this._checkbox.changeTexture(this.buttonFrames[key].assetKey);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
module.exports = ModulesObjectsModelsCheckbox;
|