@urso/core 0.2.3-dev → 0.2.4-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/build/js/index.js +1 -1
- package/build/js/index.js.LICENSE.txt +10 -8
- package/package.json +5 -2
- package/src/js/components/stateDriven/controller.js +1 -1
- package/src/js/extra/_info.js +1 -0
- package/src/js/lib/helper.js +11 -0
- 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
|
@@ -26,14 +26,6 @@ object-assign
|
|
|
26
26
|
* MIT License
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
/*!
|
|
30
|
-
* @pixi/accessibility - v5.3.10
|
|
31
|
-
* Compiled Mon, 07 Jun 2021 22:37:25 UTC
|
|
32
|
-
*
|
|
33
|
-
* @pixi/accessibility is licensed under the MIT License.
|
|
34
|
-
* http://www.opensource.org/licenses/mit-license
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
29
|
/*!
|
|
38
30
|
* @pixi/constants - v5.3.10
|
|
39
31
|
* Compiled Mon, 07 Jun 2021 22:37:25 UTC
|
|
@@ -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.2.
|
|
3
|
+
"version": "0.2.04-dev",
|
|
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",
|
|
@@ -11,7 +11,7 @@ class ComponentsStateDrivenController extends ComponentsBaseController {
|
|
|
11
11
|
|
|
12
12
|
//config for the actions configs. Guard and terminate functions are optional. Run will called when action starts.
|
|
13
13
|
//call finish callback in the run handler to immidiately finish this action
|
|
14
|
-
//use callFinish(actionKey) when its need after run handler called to delayed finish this action
|
|
14
|
+
//use this.callFinish(actionKey) when its need after run handler called to delayed finish this action
|
|
15
15
|
configActions = {
|
|
16
16
|
/*startSpin: {
|
|
17
17
|
guard: () => { log(123, 'guard'); return true; },
|
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
|
|
@@ -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;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
class ModulesObjectsModelsScrollbox extends Urso.Core.Modules.Objects.BaseModel {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
super(params);
|
|
4
|
+
|
|
5
|
+
this.type = Urso.types.objects.SCROLLBOX;
|
|
6
|
+
this._addBaseObject();
|
|
7
|
+
this._createContent();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
setupParams(params) {
|
|
11
|
+
super.setupParams(params);
|
|
12
|
+
|
|
13
|
+
this.content = Urso.helper.recursiveGet('content', params, []);
|
|
14
|
+
this.dragScroll = Urso.helper.recursiveGet('dragScroll', params, true);
|
|
15
|
+
this.scrollType = Urso.helper.recursiveGet('scrollType', params, 3);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_getScrollboxParams(){
|
|
19
|
+
return {
|
|
20
|
+
boxWidth: this.width,
|
|
21
|
+
boxHeight: this.height,
|
|
22
|
+
dragScroll: this.dragScroll,
|
|
23
|
+
fade: true,
|
|
24
|
+
fadeScrollbarTime: 300
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_setScrollWidth(){
|
|
29
|
+
if(this.scrollType === 1 || this.scrollType === 0){
|
|
30
|
+
this._baseObject.scrollWidth = this.width;
|
|
31
|
+
this._baseObject.overflowX = 'hidden';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_setScrollHeight(){
|
|
36
|
+
if(this.scrollType === 2 || this.scrollType === 0){
|
|
37
|
+
this._baseObject.scrollHeight = this.height;
|
|
38
|
+
this._baseObject.overflowY = 'hidden'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_createContent(){
|
|
43
|
+
this.content.forEach(child => {
|
|
44
|
+
let object = Urso.objects.create(child)
|
|
45
|
+
this._baseObject.content.addChild(object._baseObject)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
this._baseObject.update();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_addBaseObject() {
|
|
52
|
+
const params = this._getScrollboxParams();
|
|
53
|
+
|
|
54
|
+
const Scrollbox = require('pixi-scrollbox').Scrollbox;
|
|
55
|
+
this._baseObject = new Scrollbox(params);
|
|
56
|
+
|
|
57
|
+
this._setScrollHeight();
|
|
58
|
+
this._setScrollWidth();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = ModulesObjectsModelsScrollbox
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
class ModulesObjectsModelsSlider extends Urso.Core.Modules.Objects.BaseModel {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
super(params);
|
|
4
|
+
|
|
5
|
+
this.type = Urso.types.objects.SLIDER;
|
|
6
|
+
this._sliderBg = null;
|
|
7
|
+
this._sliderHandle = null;
|
|
8
|
+
this._baseObject = null;
|
|
9
|
+
this._handleIsPulling = false;
|
|
10
|
+
|
|
11
|
+
this._addBaseObject();
|
|
12
|
+
this._createSliderTextures();
|
|
13
|
+
this._createValueText();
|
|
14
|
+
this._setDefaultValue();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setupParams(params) {
|
|
18
|
+
super.setupParams(params);
|
|
19
|
+
this.contents = [];
|
|
20
|
+
this.points = Urso.helper.recursiveGet('points', params, [0, 1]);
|
|
21
|
+
this.defaultValue = Urso.helper.recursiveGet('defaultValue', params, this.points[0]);
|
|
22
|
+
this.bgTexture = Urso.helper.recursiveGet('bgTexture', params, false);
|
|
23
|
+
this.handleTexture = Urso.helper.recursiveGet('handleTexture', params, false);
|
|
24
|
+
this.minValueTextModel = Urso.helper.recursiveGet('minValueTextModel', params, false);
|
|
25
|
+
this.maxValueTextModel = Urso.helper.recursiveGet('maxValueTextModel', params, false);
|
|
26
|
+
this.currentValueTextModel = Urso.helper.recursiveGet('currentValueTextModel', params, false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_createSliderTextures() {
|
|
30
|
+
this._sliderBg = this._createTexture(this.bgTexture);
|
|
31
|
+
this._sliderHandle = this._createTexture(this.handleTexture);
|
|
32
|
+
|
|
33
|
+
this._setEvents(this._sliderBg._baseObject);
|
|
34
|
+
this._setEvents(this._sliderHandle._baseObject);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_createValueText() {
|
|
38
|
+
if (this.minValueTextModel) {
|
|
39
|
+
this.minValueText = Urso.objects.create(this.minValueTextModel, this);
|
|
40
|
+
this.minValueText.text = this.points[0];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (this.maxValueTextModel) {
|
|
44
|
+
this.maxValueText = Urso.objects.create(this.maxValueTextModel, this);
|
|
45
|
+
this.maxValueText.text = this.points.length <= 2 ? '100' : this.points[this.points.length - 1];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if(this.currentValueTextModel){
|
|
49
|
+
this.currentValueText = Urso.objects.create(this.currentValueTextModel, this);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_createTexture(model) {
|
|
54
|
+
if (model.type === Urso.types.objects.GRAPHICS || model.type === Urso.types.objects.IMAGE)
|
|
55
|
+
return Urso.objects.create(model, this);
|
|
56
|
+
else
|
|
57
|
+
Urso.logger.error('ModulesObjectsModelsSlider objects error: textures should be GRAPHICS or IMAGE type');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_setEvents(obj) {
|
|
61
|
+
obj.interactive = true;
|
|
62
|
+
obj.buttonMode = true;
|
|
63
|
+
|
|
64
|
+
obj
|
|
65
|
+
.on('pointerdown', this._onPointerDown.bind(this))
|
|
66
|
+
.on('pointerup', this._onPointerUp.bind(this))
|
|
67
|
+
.on('pointerupoutside', this._onPointerUp.bind(this))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_addBaseObject() {
|
|
71
|
+
this._baseObject = new PIXI.Container();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
_onPointerDown(obj) {
|
|
75
|
+
if (obj.target === this._sliderHandle._baseObject)
|
|
76
|
+
this._handleIsDragging = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_onMouseMove({ x }) {
|
|
80
|
+
if (!this._handleIsDragging)
|
|
81
|
+
return
|
|
82
|
+
|
|
83
|
+
if (x < this.x)
|
|
84
|
+
this._sliderHandle.x = 0;
|
|
85
|
+
else if (x > this.x + this._sliderBg._baseObject.width)
|
|
86
|
+
this._sliderHandle.x = this._sliderBg._baseObject.width;
|
|
87
|
+
else
|
|
88
|
+
this._sliderHandle.x = x - this.x;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_onPointerUp(obj) {
|
|
92
|
+
this._handleIsDragging = false;
|
|
93
|
+
let x;
|
|
94
|
+
|
|
95
|
+
if (obj.target === this._sliderBg._baseObject) {
|
|
96
|
+
x = obj.data.getLocalPosition(obj.target).x;
|
|
97
|
+
} else
|
|
98
|
+
x = this._sliderHandle.x;
|
|
99
|
+
|
|
100
|
+
this._dropHandle(x);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_setDefaultValue(){
|
|
104
|
+
if(!this.defaultValue)
|
|
105
|
+
return
|
|
106
|
+
|
|
107
|
+
if(!this.points.includes(this.defaultValue))
|
|
108
|
+
this.defaultValue = this.points[0];
|
|
109
|
+
|
|
110
|
+
let x = this.points.indexOf(this.defaultValue) * this._sliderBg._baseObject.width / (this.points.length - 1);
|
|
111
|
+
|
|
112
|
+
this._setNewValue(x, this.defaultValue);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
_dropHandle(x) {
|
|
116
|
+
let value;
|
|
117
|
+
let handleX;
|
|
118
|
+
|
|
119
|
+
if(this.points.length <= 2){
|
|
120
|
+
handleX = x;
|
|
121
|
+
value = ~~(100 / this._sliderBg._baseObject.width * x);
|
|
122
|
+
}
|
|
123
|
+
// calculate closest point
|
|
124
|
+
else{
|
|
125
|
+
for (let i = 0; i < this.points.length; i++) {
|
|
126
|
+
let pointX = i * this._sliderBg._baseObject.width / (this.points.length - 1);
|
|
127
|
+
|
|
128
|
+
if (typeof (handleX) === 'number' && x - pointX < handleX - x) {
|
|
129
|
+
handleX = handleX;
|
|
130
|
+
} else {
|
|
131
|
+
handleX = pointX;
|
|
132
|
+
value = this.points[i];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this._setNewValue(handleX, value)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_setNewValue(x, value){
|
|
141
|
+
this._sliderHandle.x = x;
|
|
142
|
+
|
|
143
|
+
if (this.currentValueText)
|
|
144
|
+
this.currentValueText.text = value;
|
|
145
|
+
|
|
146
|
+
this.emit(Urso.events.MODULES_OBJECTS_SLIDER_SET_NEW_VALUE, { name: this.name, value: value });
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_subscribeOnce() {
|
|
150
|
+
this.addListener(Urso.events.MODULES_SCENES_MOUSE_NEW_POSITION, this._onMouseMove.bind(this));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
module.exports = ModulesObjectsModelsSlider;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class ModulesObjectsModelsTextInput extends Urso.Core.Modules.Objects.BaseModel {
|
|
2
|
+
constructor(params) {
|
|
3
|
+
super(params);
|
|
4
|
+
|
|
5
|
+
this.type = Urso.types.objects.TEXTINPUT;
|
|
6
|
+
this.text = '';
|
|
7
|
+
this._addBaseObject();
|
|
8
|
+
this._setRestrictedSymbosl();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
setupParams(params) {
|
|
12
|
+
super.setupParams(params);
|
|
13
|
+
|
|
14
|
+
this.input = Urso.helper.recursiveGet('input', params, false);
|
|
15
|
+
this.box = Urso.helper.recursiveGet('box', params, false);
|
|
16
|
+
this.numbersOnly = Urso.helper.recursiveGet('numbersOnly', params, false);
|
|
17
|
+
this.allowedSymbols = Urso.helper.recursiveGet('allowedSymbols', params, false);
|
|
18
|
+
this.substituteText = Urso.helper.recursiveGet('substituteText', params, false);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
restrictInput(allowedSymbols) {
|
|
22
|
+
this._baseObject.restrict = allowedSymbols;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
disable(){
|
|
26
|
+
this._baseObject.disabled = true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
enable(){
|
|
30
|
+
this._baseObject.disabled = false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_setRestrictedSymbosl() {
|
|
34
|
+
if (this.numbersOnly) {
|
|
35
|
+
const regex = new RegExp('^[0-9]*');
|
|
36
|
+
this.restrictInput(regex);
|
|
37
|
+
} else if (this.allowedSymbols) {
|
|
38
|
+
this.restrictInput(this.allowedSymbols);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_onBlur(){
|
|
43
|
+
this.text = this._baseObject.text;
|
|
44
|
+
const data = {name: this.name, class: this.class, id: this.id, text: this.text};
|
|
45
|
+
this.emit(Urso.events.MODULES_OBJECTS_TEXTINPUT_BLUR, data);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_addBaseObject() {
|
|
49
|
+
this._baseObject = new PIXI.TextInput({ input: this.input, box: this.box });
|
|
50
|
+
this._baseObject.substituteText = this.substituteText;
|
|
51
|
+
this._baseObject.on('blur', this._onBlur.bind(this))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = ModulesObjectsModelsTextInput;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
|
|
2
|
+
const UrsoCoreModulesObjectsModelsButton = require('./button');
|
|
3
|
+
|
|
4
|
+
class ModulesObjectsModelsToggle extends UrsoCoreModulesObjectsModelsButton {
|
|
5
|
+
constructor(params) {
|
|
6
|
+
super(params);
|
|
7
|
+
|
|
8
|
+
this._toggleStatus = 'unpressed';
|
|
9
|
+
|
|
10
|
+
this.type = Urso.types.objects.TOGGLE;
|
|
11
|
+
this._addBaseObject();
|
|
12
|
+
|
|
13
|
+
this.enable = this.enable.bind(this);
|
|
14
|
+
this.disable = this.disable.bind(this);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
setupParams(params) {
|
|
18
|
+
super.setupParams(params);
|
|
19
|
+
|
|
20
|
+
this.action = Urso.helper.recursiveGet('action', params, () => {
|
|
21
|
+
this.emit(Urso.events.MODULES_OBJECTS_TOGGLE_PRESS, { name: this.name, status: this._toggleStatus })
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
this.buttonFrames = {
|
|
25
|
+
pressedOver: Urso.helper.recursiveGet('buttonFrames.pressedOver', params, false),
|
|
26
|
+
pressedOut: Urso.helper.recursiveGet('buttonFrames.pressedOut', params, false),
|
|
27
|
+
unpressedOver: Urso.helper.recursiveGet('buttonFrames.unpressedOver', params, false),
|
|
28
|
+
unpressedOut: Urso.helper.recursiveGet('buttonFrames.unpressedOut', params, false),
|
|
29
|
+
pressedDown: Urso.helper.recursiveGet('buttonFrames.pressedDown', params, false),
|
|
30
|
+
unpressedDown: Urso.helper.recursiveGet('buttonFrames.unpressedDown', params, false),
|
|
31
|
+
pressedDisabled: Urso.helper.recursiveGet('buttonFrames.pressedDisabled', params, false),
|
|
32
|
+
unpressedDisabled: Urso.helper.recursiveGet('buttonFrames.unpressedDisabled', params, false),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setButtonFrame(key, assetKey) {
|
|
37
|
+
this.buttonFrames[key] = assetKey;
|
|
38
|
+
|
|
39
|
+
if (this._isOver)
|
|
40
|
+
this._changeTexture(`${this._toggleStatus}Over`);
|
|
41
|
+
else if(this._isDown)
|
|
42
|
+
this._changeTexture(`${this._toggleStatus}Down`);
|
|
43
|
+
else if(this._isDisabled)
|
|
44
|
+
this._changeTexture(`${this._toggleStatus}Disabled`);
|
|
45
|
+
else
|
|
46
|
+
this._changeTexture(`${this._toggleStatus}Out`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
enable() {
|
|
50
|
+
if (!this._isDisabled)
|
|
51
|
+
return false;
|
|
52
|
+
|
|
53
|
+
if (this._isOver)
|
|
54
|
+
this._changeTexture(`${this._toggleStatus}Over`);
|
|
55
|
+
else
|
|
56
|
+
this._changeTexture(`${this._toggleStatus}Out`);
|
|
57
|
+
|
|
58
|
+
this._isDisabled = false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
disable() {
|
|
62
|
+
if (this._isDisabled)
|
|
63
|
+
return false;
|
|
64
|
+
|
|
65
|
+
this._changeTexture(`${this._toggleStatus}Disabled`);
|
|
66
|
+
this._isDisabled = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_addBaseObject() {
|
|
70
|
+
this._baseObject = new PIXI.Sprite();
|
|
71
|
+
this._changeTexture('unpressedOut');
|
|
72
|
+
|
|
73
|
+
this._baseObject.interactive = true;
|
|
74
|
+
this._baseObject.buttonMode = true;
|
|
75
|
+
|
|
76
|
+
if (this.pixelPerfectOver) {
|
|
77
|
+
//todo
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.pixelPerfectClick) {
|
|
81
|
+
//todo
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this._baseObject
|
|
85
|
+
.on('pointerdown', this._onButtonDown.bind(this))
|
|
86
|
+
.on('pointerup', this._onButtonUp.bind(this))
|
|
87
|
+
.on('pointerupoutside', this._onButtonUp.bind(this))
|
|
88
|
+
.on('pointerover', this._onButtonOver.bind(this))
|
|
89
|
+
.on('pointerout', this._onButtonOut.bind(this));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
_onButtonDown() {
|
|
93
|
+
if (this._isDisabled)
|
|
94
|
+
return false;
|
|
95
|
+
|
|
96
|
+
this._isDown = true;
|
|
97
|
+
|
|
98
|
+
if (this.keyDownAction)
|
|
99
|
+
this.keyDownAction();
|
|
100
|
+
|
|
101
|
+
if (this._isDisabled) //can be disabled after keyDownAction
|
|
102
|
+
return false;
|
|
103
|
+
|
|
104
|
+
this._changeTexture(`${this._toggleStatus}Down`);
|
|
105
|
+
|
|
106
|
+
this._toggleStatus = this._toggleStatus === 'pressed' ? 'unpressed' : 'pressed';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_onButtonUp() {
|
|
110
|
+
if (this._isDisabled)
|
|
111
|
+
return false;
|
|
112
|
+
|
|
113
|
+
this._isDown = false;
|
|
114
|
+
|
|
115
|
+
if (this.action)
|
|
116
|
+
this.action();
|
|
117
|
+
|
|
118
|
+
if (this._isDisabled) //can be disabled after action
|
|
119
|
+
return false;
|
|
120
|
+
|
|
121
|
+
if (this._isOver)
|
|
122
|
+
this._changeTexture(`${this._toggleStatus}Over`);
|
|
123
|
+
else
|
|
124
|
+
this._changeTexture(`${this._toggleStatus}Out`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_onButtonOver() {
|
|
128
|
+
this._isOver = true;
|
|
129
|
+
|
|
130
|
+
if (this._isDisabled || this._isDown)
|
|
131
|
+
return false;
|
|
132
|
+
|
|
133
|
+
if (this.mouseOverAction)
|
|
134
|
+
this.mouseOverAction();
|
|
135
|
+
|
|
136
|
+
this._changeTexture(`${this._toggleStatus}Over`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
_onButtonOut() {
|
|
140
|
+
this._isOver = false;
|
|
141
|
+
|
|
142
|
+
if (this._isDisabled || this._isDown)
|
|
143
|
+
return false;
|
|
144
|
+
|
|
145
|
+
if (this.mouseOutAction)
|
|
146
|
+
this.mouseOutAction();
|
|
147
|
+
|
|
148
|
+
this._changeTexture(`${this._toggleStatus}Out`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_changeTexture(key) {
|
|
152
|
+
let texture = Urso.cache.getTexture(this.buttonFrames[key]);
|
|
153
|
+
|
|
154
|
+
if (!texture) {
|
|
155
|
+
if (key === `${this._toggleStatus}Out`) {
|
|
156
|
+
Urso.logger.error('ModulesObjectsModelsButton assets error: no out image ' + this.buttonFrames.out);
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
this._changeTexture(`${this._toggleStatus}Out`); // load default texture for this key
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this._baseObject.texture = texture;
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
module.exports = ModulesObjectsModelsToggle;
|
|
@@ -31,7 +31,9 @@ class PropertyAdapter {
|
|
|
31
31
|
Urso.types.objects.COMPONENT,
|
|
32
32
|
Urso.types.objects.CONTAINER,
|
|
33
33
|
Urso.types.objects.GROUP,
|
|
34
|
-
Urso.types.objects.WORLD
|
|
34
|
+
Urso.types.objects.WORLD,
|
|
35
|
+
Urso.types.objects.SLIDER,
|
|
36
|
+
Urso.types.objects.SCROLLBOX,
|
|
35
37
|
];
|
|
36
38
|
|
|
37
39
|
this._typesWithoutAnchor = [
|
|
@@ -40,7 +42,10 @@ class PropertyAdapter {
|
|
|
40
42
|
Urso.types.objects.HITAREA,
|
|
41
43
|
Urso.types.objects.MASK,
|
|
42
44
|
Urso.types.objects.SPINE,
|
|
43
|
-
Urso.types.objects.
|
|
45
|
+
Urso.types.objects.SLIDER,
|
|
46
|
+
Urso.types.objects.TEXTINPUT,
|
|
47
|
+
Urso.types.objects.CHECKBOX,
|
|
48
|
+
Urso.types.objects.WORLD,
|
|
44
49
|
];
|
|
45
50
|
}
|
|
46
51
|
|