dzkcc-mflow 0.0.1 → 0.0.2
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/dist/App.d.ts +22 -22
- package/dist/App.js +27 -27
- package/dist/_virtual/_tslib.js +30 -30
- package/dist/core/Api.d.ts +53 -53
- package/dist/core/Core.d.ts +18 -18
- package/dist/core/Core.js +78 -78
- package/dist/core/Decorators.d.ts +7 -7
- package/dist/core/Decorators.js +99 -99
- package/dist/core/ICocosResManager.d.ts +11 -11
- package/dist/core/ServiceLocator.d.ts +7 -7
- package/dist/core/ServiceLocator.js +31 -31
- package/dist/core/index.d.ts +5 -5
- package/dist/libs/BaseView.d.ts +21 -21
- package/dist/libs/BaseView.js +78 -78
- package/dist/libs/Broadcaster.d.ts +101 -101
- package/dist/libs/Broadcaster.js +240 -240
- package/dist/libs/CocosCore.d.ts +5 -5
- package/dist/libs/CocosCore.js +16 -16
- package/dist/libs/ResLoader.d.ts +10 -10
- package/dist/libs/ResLoader.js +76 -74
- package/dist/libs/UIManager.d.ts +34 -34
- package/dist/libs/UIManager.js +251 -251
- package/dist/libs/UIRoot.d.ts +4 -4
- package/dist/libs/UIRoot.js +4 -4
- package/dist/libs/index.d.ts +6 -6
- package/dist/mflow-tools.zip +0 -0
- package/dist/utils/ArrayExt.d.ts +67 -67
- package/dist/utils/ArrayExt.js +298 -298
- package/dist/utils/ArrayUtil.d.ts +41 -41
- package/dist/utils/ArrayUtil.js +93 -93
- package/dist/utils/CameraUtil.d.ts +10 -10
- package/dist/utils/CameraUtil.js +23 -23
- package/dist/utils/ImageUtil.d.ts +33 -33
- package/dist/utils/ImageUtil.js +92 -92
- package/dist/utils/MathUtil.d.ts +213 -213
- package/dist/utils/MathUtil.js +435 -435
- package/dist/utils/ObjectUtil.d.ts +24 -24
- package/dist/utils/ObjectUtil.js +58 -58
- package/dist/utils/PlatformUtil.d.ts +9 -9
- package/dist/utils/PlatformUtil.js +27 -27
- package/dist/utils/RotateUtil.d.ts +30 -30
- package/dist/utils/RotateUtil.js +63 -63
- package/dist/utils/StringUtil.d.ts +107 -107
- package/dist/utils/StringUtil.js +249 -249
- package/dist/utils/TimeUtil.d.ts +31 -31
- package/dist/utils/TimeUtil.js +85 -85
- package/dist/utils/index.d.ts +9 -9
- package/package.json +1 -1
package/dist/libs/UIManager.js
CHANGED
|
@@ -3,257 +3,257 @@ import { director, Node, Sprite, Widget, Input, input, instantiate } from 'cc';
|
|
|
3
3
|
import { ServiceLocator } from '../core/ServiceLocator.js';
|
|
4
4
|
import 'reflect-metadata';
|
|
5
5
|
|
|
6
|
-
function addWidget(node) {
|
|
7
|
-
const widget = node.getComponent(Widget) || node.addComponent(Widget);
|
|
8
|
-
widget.isAlignLeft = widget.isAlignRight = widget.isAlignTop = widget.isAlignBottom = true;
|
|
9
|
-
widget.left = widget.right = widget.top = widget.bottom = 0;
|
|
10
|
-
}
|
|
11
|
-
let _uiRoot;
|
|
12
|
-
const UIRoot = new Proxy({}, {
|
|
13
|
-
get(target, prop) {
|
|
14
|
-
if (!_uiRoot) {
|
|
15
|
-
const canvas = director.getScene().getChildByPath('Canvas');
|
|
16
|
-
director.addPersistRootNode(canvas);
|
|
17
|
-
_uiRoot = new Node('__UIRoot__');
|
|
18
|
-
_uiRoot.layer = canvas.layer;
|
|
19
|
-
_uiRoot.setParent(canvas);
|
|
20
|
-
addWidget(_uiRoot);
|
|
21
|
-
}
|
|
22
|
-
return Reflect.get(_uiRoot, prop);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
function setLayer(node) {
|
|
26
|
-
node.layer = UIRoot.layer;
|
|
27
|
-
node.children.forEach(child => {
|
|
28
|
-
setLayer(child);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function addChild(node) {
|
|
32
|
-
UIRoot.addChild(node);
|
|
33
|
-
setLayer(node);
|
|
34
|
-
}
|
|
35
|
-
let _uiMask;
|
|
36
|
-
const UIMask = new Proxy({}, {
|
|
37
|
-
get(target, prop) {
|
|
38
|
-
if (!_uiMask) {
|
|
39
|
-
_uiMask = new Node('__UIMask__');
|
|
40
|
-
addChild(_uiMask);
|
|
41
|
-
addWidget(_uiMask);
|
|
42
|
-
_uiMask.setPosition(0, 0);
|
|
43
|
-
_uiMask.addComponent(Sprite).color.set(0, 0, 0, 0.5);
|
|
44
|
-
}
|
|
45
|
-
const value = Reflect.get(_uiMask, prop);
|
|
46
|
-
// 如果是放的话,可能要绑定原始实例上下文
|
|
47
|
-
return typeof value === 'function' ? value.bind(_uiMask) : value;
|
|
48
|
-
// return Reflect.get(_uiMask, prop)
|
|
49
|
-
},
|
|
50
|
-
set(target, p, newValue, receiver) {
|
|
51
|
-
if (p === 'active') {
|
|
52
|
-
_uiMask.active = newValue;
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return Reflect.set(_uiMask, p, newValue, receiver);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
// 接口隔离,实现具体的CcocosUIManager
|
|
59
|
-
class CcocosUIManager {
|
|
60
|
-
getTopView() {
|
|
61
|
-
return this.internalGetTopView();
|
|
62
|
-
}
|
|
63
|
-
open(viewType, args) {
|
|
64
|
-
let vt = viewType;
|
|
65
|
-
return this.internalOpen(vt, args);
|
|
66
|
-
}
|
|
67
|
-
close(viewortype, destory) {
|
|
68
|
-
this.internalClose(viewortype, destory);
|
|
69
|
-
}
|
|
70
|
-
openAndPush(viewType, group, args) {
|
|
71
|
-
let vt = viewType;
|
|
72
|
-
return this.internalOpenAndPush(vt, group, args);
|
|
73
|
-
}
|
|
74
|
-
closeAndPop(group, destroy) {
|
|
75
|
-
this.internalCloseAndPop(group, destroy);
|
|
76
|
-
}
|
|
77
|
-
clearStack(group, destroy) {
|
|
78
|
-
this.internalClearStack(group, destroy);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
class UIManager extends CcocosUIManager {
|
|
82
|
-
constructor() {
|
|
83
|
-
super();
|
|
84
|
-
this._cache = new Map();
|
|
85
|
-
this._groupStacks = new Map();
|
|
86
|
-
UIMask.on(Node.EventType.TOUCH_END, (event) => {
|
|
87
|
-
let view = this.getTopView();
|
|
88
|
-
if ('__group__' in view) {
|
|
89
|
-
if (view.__group__ != undefined) {
|
|
90
|
-
this.closeAndPop(view.__group__, false);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
this.close(view, false);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
_getPrefabPath(viewType) {
|
|
99
|
-
let prototype = Object.getPrototypeOf(viewType);
|
|
100
|
-
// 沿着原型链向上查找直到找到定义__path__的基类。注意通过类只能找到静态属性。
|
|
101
|
-
while (prototype) {
|
|
102
|
-
if (prototype.hasOwnProperty('__path__')) {
|
|
103
|
-
return prototype.__path__;
|
|
104
|
-
}
|
|
105
|
-
prototype = Object.getPrototypeOf(prototype);
|
|
106
|
-
}
|
|
107
|
-
throw new Error(`Prefab path not found for ${viewType.constructor.name}`);
|
|
108
|
-
}
|
|
109
|
-
// 调整Mask层级
|
|
110
|
-
_adjustMaskLayer() {
|
|
111
|
-
let children = UIRoot.children;
|
|
112
|
-
if (children.length == 1) {
|
|
113
|
-
UIMask.active = false;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
UIMask.active = true;
|
|
117
|
-
UIMask.setSiblingIndex(Math.max(children.length - 2, 0));
|
|
118
|
-
}
|
|
119
|
-
_blockInput(block) {
|
|
120
|
-
function blocker(event) {
|
|
121
|
-
event.propagationImmediateStopped = true;
|
|
122
|
-
}
|
|
123
|
-
if (block) {
|
|
124
|
-
for (const eventType in Input.EventType) {
|
|
125
|
-
input.on(Input.EventType[eventType], blocker);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
for (const eventType in Input.EventType) {
|
|
130
|
-
input.off(Input.EventType[eventType], blocker);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
_load(viewType, args) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
let target;
|
|
137
|
-
if (this._cache.has(viewType.name)) {
|
|
138
|
-
target = this._cache.get(viewType.name);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
let prefabPath = this._getPrefabPath(viewType);
|
|
142
|
-
const ResMgr = ServiceLocator.getService('ResLoader');
|
|
143
|
-
const prefab = yield ResMgr.loadPrefab(prefabPath);
|
|
144
|
-
target = instantiate(prefab);
|
|
145
|
-
this._cache.set(viewType.name, target);
|
|
146
|
-
}
|
|
147
|
-
return target.getComponent(viewType);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
_remove(viewortype, destroy) {
|
|
151
|
-
var _a;
|
|
152
|
-
if (typeof viewortype == 'function') {
|
|
153
|
-
const cached = this._cache.get(viewortype.name);
|
|
154
|
-
if (!cached) {
|
|
155
|
-
console.warn(`No cached view found for ${viewortype.name}`);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
this._remove(cached.getComponent(viewortype), destroy);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if ('__group__' in viewortype) {
|
|
162
|
-
viewortype.__group__ = undefined;
|
|
163
|
-
}
|
|
164
|
-
viewortype.onExit();
|
|
165
|
-
viewortype.node.removeFromParent();
|
|
166
|
-
if (destroy) {
|
|
167
|
-
let cacheKey = viewortype.constructor.name;
|
|
168
|
-
(_a = this._cache.get(cacheKey)) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
169
|
-
this._cache.delete(cacheKey);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
internalGetTopView() {
|
|
173
|
-
let target = UIRoot.children.reverse()[0];
|
|
174
|
-
if (!target) {
|
|
175
|
-
return undefined;
|
|
176
|
-
}
|
|
177
|
-
const comps = target.components;
|
|
178
|
-
for (let i = 0; i < comps.length; i++) {
|
|
179
|
-
const comp = comps[i];
|
|
180
|
-
if ("__isIView__" in comp) {
|
|
181
|
-
if (comp.__isIView__) {
|
|
182
|
-
return comp;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
console.warn(`No view found in ${target.name}`);
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
internalOpen(viewType, args) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
this._blockInput(true);
|
|
192
|
-
let view = yield this._load(viewType, args);
|
|
193
|
-
addChild(view.node);
|
|
194
|
-
this._adjustMaskLayer();
|
|
195
|
-
view.onEnter(args);
|
|
196
|
-
this._blockInput(false);
|
|
197
|
-
return view;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
internalClose(viewortype, destroy) {
|
|
201
|
-
this._remove(viewortype, destroy);
|
|
202
|
-
this._adjustMaskLayer();
|
|
203
|
-
}
|
|
204
|
-
internalOpenAndPush(viewType, group, args) {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
this._blockInput(true);
|
|
207
|
-
let view = yield this._load(viewType, args);
|
|
208
|
-
let stack = this._groupStacks.get(group) || [];
|
|
209
|
-
this._groupStacks.set(group, stack);
|
|
210
|
-
let top = stack[stack.length - 1];
|
|
211
|
-
if (top) {
|
|
212
|
-
top.onPause();
|
|
213
|
-
top.node.removeFromParent();
|
|
214
|
-
}
|
|
215
|
-
if ('__group__' in view) {
|
|
216
|
-
view.__group__ = group;
|
|
217
|
-
}
|
|
218
|
-
stack.push(view);
|
|
219
|
-
addChild(view.node);
|
|
220
|
-
this._adjustMaskLayer();
|
|
221
|
-
view.onEnter(args);
|
|
222
|
-
this._blockInput(false);
|
|
223
|
-
return view;
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
internalCloseAndPop(group, destroy) {
|
|
227
|
-
let stack = this._groupStacks.get(group);
|
|
228
|
-
if (!stack) {
|
|
229
|
-
console.warn(`No stack found for group ${group}`);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (stack.length == 0) {
|
|
233
|
-
console.warn(`Stack is empty for group ${group}`);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
this._remove(stack.pop(), destroy);
|
|
237
|
-
let top = stack[stack.length - 1];
|
|
238
|
-
if (top) {
|
|
239
|
-
top.onResume();
|
|
240
|
-
addChild(top.node);
|
|
241
|
-
}
|
|
242
|
-
this._adjustMaskLayer();
|
|
243
|
-
}
|
|
244
|
-
internalClearStack(group, destroy) {
|
|
245
|
-
let stack = this._groupStacks.get(group);
|
|
246
|
-
if (!stack) {
|
|
247
|
-
console.warn(`No stack found for group ${group}`);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
while (stack.length > 0) {
|
|
251
|
-
let view = stack.pop();
|
|
252
|
-
if (view) {
|
|
253
|
-
this._remove(view, destroy);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
6
|
+
function addWidget(node) {
|
|
7
|
+
const widget = node.getComponent(Widget) || node.addComponent(Widget);
|
|
8
|
+
widget.isAlignLeft = widget.isAlignRight = widget.isAlignTop = widget.isAlignBottom = true;
|
|
9
|
+
widget.left = widget.right = widget.top = widget.bottom = 0;
|
|
10
|
+
}
|
|
11
|
+
let _uiRoot;
|
|
12
|
+
const UIRoot = new Proxy({}, {
|
|
13
|
+
get(target, prop) {
|
|
14
|
+
if (!_uiRoot) {
|
|
15
|
+
const canvas = director.getScene().getChildByPath('Canvas');
|
|
16
|
+
director.addPersistRootNode(canvas);
|
|
17
|
+
_uiRoot = new Node('__UIRoot__');
|
|
18
|
+
_uiRoot.layer = canvas.layer;
|
|
19
|
+
_uiRoot.setParent(canvas);
|
|
20
|
+
addWidget(_uiRoot);
|
|
21
|
+
}
|
|
22
|
+
return Reflect.get(_uiRoot, prop);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
function setLayer(node) {
|
|
26
|
+
node.layer = UIRoot.layer;
|
|
27
|
+
node.children.forEach(child => {
|
|
28
|
+
setLayer(child);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function addChild(node) {
|
|
32
|
+
UIRoot.addChild(node);
|
|
33
|
+
setLayer(node);
|
|
34
|
+
}
|
|
35
|
+
let _uiMask;
|
|
36
|
+
const UIMask = new Proxy({}, {
|
|
37
|
+
get(target, prop) {
|
|
38
|
+
if (!_uiMask) {
|
|
39
|
+
_uiMask = new Node('__UIMask__');
|
|
40
|
+
addChild(_uiMask);
|
|
41
|
+
addWidget(_uiMask);
|
|
42
|
+
_uiMask.setPosition(0, 0);
|
|
43
|
+
_uiMask.addComponent(Sprite).color.set(0, 0, 0, 0.5);
|
|
44
|
+
}
|
|
45
|
+
const value = Reflect.get(_uiMask, prop);
|
|
46
|
+
// 如果是放的话,可能要绑定原始实例上下文
|
|
47
|
+
return typeof value === 'function' ? value.bind(_uiMask) : value;
|
|
48
|
+
// return Reflect.get(_uiMask, prop)
|
|
49
|
+
},
|
|
50
|
+
set(target, p, newValue, receiver) {
|
|
51
|
+
if (p === 'active') {
|
|
52
|
+
_uiMask.active = newValue;
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return Reflect.set(_uiMask, p, newValue, receiver);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// 接口隔离,实现具体的CcocosUIManager
|
|
59
|
+
class CcocosUIManager {
|
|
60
|
+
getTopView() {
|
|
61
|
+
return this.internalGetTopView();
|
|
62
|
+
}
|
|
63
|
+
open(viewType, args) {
|
|
64
|
+
let vt = viewType;
|
|
65
|
+
return this.internalOpen(vt, args);
|
|
66
|
+
}
|
|
67
|
+
close(viewortype, destory) {
|
|
68
|
+
this.internalClose(viewortype, destory);
|
|
69
|
+
}
|
|
70
|
+
openAndPush(viewType, group, args) {
|
|
71
|
+
let vt = viewType;
|
|
72
|
+
return this.internalOpenAndPush(vt, group, args);
|
|
73
|
+
}
|
|
74
|
+
closeAndPop(group, destroy) {
|
|
75
|
+
this.internalCloseAndPop(group, destroy);
|
|
76
|
+
}
|
|
77
|
+
clearStack(group, destroy) {
|
|
78
|
+
this.internalClearStack(group, destroy);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
class UIManager extends CcocosUIManager {
|
|
82
|
+
constructor() {
|
|
83
|
+
super();
|
|
84
|
+
this._cache = new Map();
|
|
85
|
+
this._groupStacks = new Map();
|
|
86
|
+
UIMask.on(Node.EventType.TOUCH_END, (event) => {
|
|
87
|
+
let view = this.getTopView();
|
|
88
|
+
if ('__group__' in view) {
|
|
89
|
+
if (view.__group__ != undefined) {
|
|
90
|
+
this.closeAndPop(view.__group__, false);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.close(view, false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
_getPrefabPath(viewType) {
|
|
99
|
+
let prototype = Object.getPrototypeOf(viewType);
|
|
100
|
+
// 沿着原型链向上查找直到找到定义__path__的基类。注意通过类只能找到静态属性。
|
|
101
|
+
while (prototype) {
|
|
102
|
+
if (prototype.hasOwnProperty('__path__')) {
|
|
103
|
+
return prototype.__path__;
|
|
104
|
+
}
|
|
105
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`Prefab path not found for ${viewType.constructor.name}`);
|
|
108
|
+
}
|
|
109
|
+
// 调整Mask层级
|
|
110
|
+
_adjustMaskLayer() {
|
|
111
|
+
let children = UIRoot.children;
|
|
112
|
+
if (children.length == 1) {
|
|
113
|
+
UIMask.active = false;
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
UIMask.active = true;
|
|
117
|
+
UIMask.setSiblingIndex(Math.max(children.length - 2, 0));
|
|
118
|
+
}
|
|
119
|
+
_blockInput(block) {
|
|
120
|
+
function blocker(event) {
|
|
121
|
+
event.propagationImmediateStopped = true;
|
|
122
|
+
}
|
|
123
|
+
if (block) {
|
|
124
|
+
for (const eventType in Input.EventType) {
|
|
125
|
+
input.on(Input.EventType[eventType], blocker);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
for (const eventType in Input.EventType) {
|
|
130
|
+
input.off(Input.EventType[eventType], blocker);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
_load(viewType, args) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
let target;
|
|
137
|
+
if (this._cache.has(viewType.name)) {
|
|
138
|
+
target = this._cache.get(viewType.name);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
let prefabPath = this._getPrefabPath(viewType);
|
|
142
|
+
const ResMgr = ServiceLocator.getService('ResLoader');
|
|
143
|
+
const prefab = yield ResMgr.loadPrefab(prefabPath);
|
|
144
|
+
target = instantiate(prefab);
|
|
145
|
+
this._cache.set(viewType.name, target);
|
|
146
|
+
}
|
|
147
|
+
return target.getComponent(viewType);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
_remove(viewortype, destroy) {
|
|
151
|
+
var _a;
|
|
152
|
+
if (typeof viewortype == 'function') {
|
|
153
|
+
const cached = this._cache.get(viewortype.name);
|
|
154
|
+
if (!cached) {
|
|
155
|
+
console.warn(`No cached view found for ${viewortype.name}`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this._remove(cached.getComponent(viewortype), destroy);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if ('__group__' in viewortype) {
|
|
162
|
+
viewortype.__group__ = undefined;
|
|
163
|
+
}
|
|
164
|
+
viewortype.onExit();
|
|
165
|
+
viewortype.node.removeFromParent();
|
|
166
|
+
if (destroy) {
|
|
167
|
+
let cacheKey = viewortype.constructor.name;
|
|
168
|
+
(_a = this._cache.get(cacheKey)) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
169
|
+
this._cache.delete(cacheKey);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
internalGetTopView() {
|
|
173
|
+
let target = UIRoot.children.reverse()[0];
|
|
174
|
+
if (!target) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const comps = target.components;
|
|
178
|
+
for (let i = 0; i < comps.length; i++) {
|
|
179
|
+
const comp = comps[i];
|
|
180
|
+
if ("__isIView__" in comp) {
|
|
181
|
+
if (comp.__isIView__) {
|
|
182
|
+
return comp;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
console.warn(`No view found in ${target.name}`);
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
internalOpen(viewType, args) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
this._blockInput(true);
|
|
192
|
+
let view = yield this._load(viewType, args);
|
|
193
|
+
addChild(view.node);
|
|
194
|
+
this._adjustMaskLayer();
|
|
195
|
+
view.onEnter(args);
|
|
196
|
+
this._blockInput(false);
|
|
197
|
+
return view;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
internalClose(viewortype, destroy) {
|
|
201
|
+
this._remove(viewortype, destroy);
|
|
202
|
+
this._adjustMaskLayer();
|
|
203
|
+
}
|
|
204
|
+
internalOpenAndPush(viewType, group, args) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
this._blockInput(true);
|
|
207
|
+
let view = yield this._load(viewType, args);
|
|
208
|
+
let stack = this._groupStacks.get(group) || [];
|
|
209
|
+
this._groupStacks.set(group, stack);
|
|
210
|
+
let top = stack[stack.length - 1];
|
|
211
|
+
if (top) {
|
|
212
|
+
top.onPause();
|
|
213
|
+
top.node.removeFromParent();
|
|
214
|
+
}
|
|
215
|
+
if ('__group__' in view) {
|
|
216
|
+
view.__group__ = group;
|
|
217
|
+
}
|
|
218
|
+
stack.push(view);
|
|
219
|
+
addChild(view.node);
|
|
220
|
+
this._adjustMaskLayer();
|
|
221
|
+
view.onEnter(args);
|
|
222
|
+
this._blockInput(false);
|
|
223
|
+
return view;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
internalCloseAndPop(group, destroy) {
|
|
227
|
+
let stack = this._groupStacks.get(group);
|
|
228
|
+
if (!stack) {
|
|
229
|
+
console.warn(`No stack found for group ${group}`);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (stack.length == 0) {
|
|
233
|
+
console.warn(`Stack is empty for group ${group}`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this._remove(stack.pop(), destroy);
|
|
237
|
+
let top = stack[stack.length - 1];
|
|
238
|
+
if (top) {
|
|
239
|
+
top.onResume();
|
|
240
|
+
addChild(top.node);
|
|
241
|
+
}
|
|
242
|
+
this._adjustMaskLayer();
|
|
243
|
+
}
|
|
244
|
+
internalClearStack(group, destroy) {
|
|
245
|
+
let stack = this._groupStacks.get(group);
|
|
246
|
+
if (!stack) {
|
|
247
|
+
console.warn(`No stack found for group ${group}`);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
while (stack.length > 0) {
|
|
251
|
+
let view = stack.pop();
|
|
252
|
+
if (view) {
|
|
253
|
+
this._remove(view, destroy);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export { UIManager };
|
package/dist/libs/UIRoot.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from 'cc';
|
|
2
|
-
export declare class UIRoot extends Component {
|
|
3
|
-
onLoad(): void;
|
|
4
|
-
}
|
|
1
|
+
import { Component } from 'cc';
|
|
2
|
+
export declare class UIRoot extends Component {
|
|
3
|
+
onLoad(): void;
|
|
4
|
+
}
|
package/dist/libs/UIRoot.js
CHANGED
package/dist/libs/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './BaseView';
|
|
2
|
-
export * from './Broadcaster';
|
|
3
|
-
export * from './CocosCore';
|
|
4
|
-
export * from './ResLoader';
|
|
5
|
-
export * from './UIManager';
|
|
6
|
-
export * from './UIRoot';
|
|
1
|
+
export * from './BaseView';
|
|
2
|
+
export * from './Broadcaster';
|
|
3
|
+
export * from './CocosCore';
|
|
4
|
+
export * from './ResLoader';
|
|
5
|
+
export * from './UIManager';
|
|
6
|
+
export * from './UIRoot';
|
package/dist/mflow-tools.zip
CHANGED
|
Binary file
|