@eva/plugin-renderer-nine-patch 1.3.0-alpha.1 → 2.0.0-beta.1
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/EVA.plugin.renderer.ninePatch.js +84 -152
- package/dist/EVA.plugin.renderer.ninePatch.min.js +1 -1
- package/dist/plugin-renderer-nine-patch.cjs.js +10 -3
- package/dist/plugin-renderer-nine-patch.cjs.prod.js +1 -1
- package/dist/plugin-renderer-nine-patch.d.ts +2 -2
- package/dist/plugin-renderer-nine-patch.esm.js +10 -3
- package/package.json +4 -5
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer, rendererAdapter) {
|
|
1
|
+
window.EVA = window.EVA || {};
|
|
2
|
+
window.EVA.plugin = window.EVA.plugin || {};
|
|
3
|
+
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
4
|
+
var _EVA_IIFE_ninePatch = function (exports, eva_js, pluginRenderer, rendererAdapter) {
|
|
6
5
|
'use strict';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_extendStatics = Object.setPrototypeOf || {
|
|
6
|
+
var extendStatics = function (d, b) {
|
|
7
|
+
extendStatics = Object.setPrototypeOf || {
|
|
10
8
|
__proto__: []
|
|
11
9
|
} instanceof Array && function (d, b) {
|
|
12
10
|
d.__proto__ = b;
|
|
13
11
|
} || function (d, b) {
|
|
14
|
-
for (var p in b)
|
|
15
|
-
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
16
|
-
}
|
|
12
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
17
13
|
};
|
|
18
|
-
|
|
19
|
-
return _extendStatics(d, b);
|
|
14
|
+
return extendStatics(d, b);
|
|
20
15
|
};
|
|
21
|
-
|
|
22
16
|
function __extends(d, b) {
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
extendStatics(d, b);
|
|
25
18
|
function __() {
|
|
26
19
|
this.constructor = d;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
function __decorate(decorators, target, key, desc) {
|
|
33
24
|
var c = arguments.length,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--)
|
|
37
|
-
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
38
|
-
}
|
|
25
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
26
|
+
d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
39
28
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
43
31
|
function adopt(value) {
|
|
44
32
|
return value instanceof P ? value : new P(function (resolve) {
|
|
45
33
|
resolve(value);
|
|
46
34
|
});
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
37
|
function fulfilled(value) {
|
|
51
38
|
try {
|
|
@@ -54,7 +41,6 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
54
41
|
reject(e);
|
|
55
42
|
}
|
|
56
43
|
}
|
|
57
|
-
|
|
58
44
|
function rejected(value) {
|
|
59
45
|
try {
|
|
60
46
|
step(generator["throw"](value));
|
|
@@ -62,29 +48,26 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
62
48
|
reject(e);
|
|
63
49
|
}
|
|
64
50
|
}
|
|
65
|
-
|
|
66
51
|
function step(result) {
|
|
67
52
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
68
53
|
}
|
|
69
|
-
|
|
70
54
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
71
55
|
});
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
function __generator(thisArg, body) {
|
|
75
58
|
var _ = {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
59
|
+
label: 0,
|
|
60
|
+
sent: function () {
|
|
61
|
+
if (t[0] & 1) throw t[1];
|
|
62
|
+
return t[1];
|
|
63
|
+
},
|
|
64
|
+
trys: [],
|
|
65
|
+
ops: []
|
|
80
66
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
y,
|
|
86
|
-
t,
|
|
87
|
-
g;
|
|
67
|
+
f,
|
|
68
|
+
y,
|
|
69
|
+
t,
|
|
70
|
+
g;
|
|
88
71
|
return g = {
|
|
89
72
|
next: verb(0),
|
|
90
73
|
"throw": verb(1),
|
|
@@ -92,88 +75,66 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
92
75
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
93
76
|
return this;
|
|
94
77
|
}), g;
|
|
95
|
-
|
|
96
78
|
function verb(n) {
|
|
97
79
|
return function (v) {
|
|
98
80
|
return step([n, v]);
|
|
99
81
|
};
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
function step(op) {
|
|
103
84
|
if (f) throw new TypeError("Generator is already executing.");
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
85
|
+
while (_) try {
|
|
86
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
87
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
88
|
+
switch (op[0]) {
|
|
89
|
+
case 0:
|
|
90
|
+
case 1:
|
|
91
|
+
t = op;
|
|
92
|
+
break;
|
|
93
|
+
case 4:
|
|
94
|
+
_.label++;
|
|
95
|
+
return {
|
|
96
|
+
value: op[1],
|
|
97
|
+
done: false
|
|
98
|
+
};
|
|
99
|
+
case 5:
|
|
100
|
+
_.label++;
|
|
101
|
+
y = op[1];
|
|
102
|
+
op = [0];
|
|
103
|
+
continue;
|
|
104
|
+
case 7:
|
|
105
|
+
op = _.ops.pop();
|
|
106
|
+
_.trys.pop();
|
|
107
|
+
continue;
|
|
108
|
+
default:
|
|
109
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
110
|
+
_ = 0;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
114
|
+
_.label = op[1];
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
118
|
+
_.label = t[1];
|
|
113
119
|
t = op;
|
|
114
120
|
break;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
_.label
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
_.label++;
|
|
125
|
-
y = op[1];
|
|
126
|
-
op = [0];
|
|
127
|
-
continue;
|
|
128
|
-
|
|
129
|
-
case 7:
|
|
130
|
-
op = _.ops.pop();
|
|
131
|
-
|
|
132
|
-
_.trys.pop();
|
|
133
|
-
|
|
134
|
-
continue;
|
|
135
|
-
|
|
136
|
-
default:
|
|
137
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
138
|
-
_ = 0;
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
143
|
-
_.label = op[1];
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
148
|
-
_.label = t[1];
|
|
149
|
-
t = op;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (t && _.label < t[2]) {
|
|
154
|
-
_.label = t[2];
|
|
155
|
-
|
|
156
|
-
_.ops.push(op);
|
|
157
|
-
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (t[2]) _.ops.pop();
|
|
162
|
-
|
|
163
|
-
_.trys.pop();
|
|
164
|
-
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
op = body.call(thisArg, _);
|
|
169
|
-
} catch (e) {
|
|
170
|
-
op = [6, e];
|
|
171
|
-
y = 0;
|
|
172
|
-
} finally {
|
|
173
|
-
f = t = 0;
|
|
121
|
+
}
|
|
122
|
+
if (t && _.label < t[2]) {
|
|
123
|
+
_.label = t[2];
|
|
124
|
+
_.ops.push(op);
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (t[2]) _.ops.pop();
|
|
128
|
+
_.trys.pop();
|
|
129
|
+
continue;
|
|
174
130
|
}
|
|
131
|
+
op = body.call(thisArg, _);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
op = [6, e];
|
|
134
|
+
y = 0;
|
|
135
|
+
} finally {
|
|
136
|
+
f = t = 0;
|
|
175
137
|
}
|
|
176
|
-
|
|
177
138
|
if (op[0] & 5) throw op[1];
|
|
178
139
|
return {
|
|
179
140
|
value: op[0] ? op[1] : void 0,
|
|
@@ -181,20 +142,16 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
181
142
|
};
|
|
182
143
|
}
|
|
183
144
|
}
|
|
184
|
-
|
|
185
145
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
186
146
|
if (!target.constructor.IDEProps) {
|
|
187
147
|
target.constructor.IDEProps = {};
|
|
188
148
|
}
|
|
189
|
-
|
|
190
149
|
if (!target.constructor.IDEProps[propertyKey]) {
|
|
191
150
|
target.constructor.IDEProps[propertyKey] = {};
|
|
192
151
|
}
|
|
193
|
-
|
|
194
152
|
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
195
153
|
return propertyObj;
|
|
196
154
|
}
|
|
197
|
-
|
|
198
155
|
function type(type) {
|
|
199
156
|
return function (target, propertyKey) {
|
|
200
157
|
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
@@ -202,20 +159,16 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
202
159
|
prop.type = type;
|
|
203
160
|
};
|
|
204
161
|
}
|
|
205
|
-
|
|
206
162
|
function step(step) {
|
|
207
163
|
return function (target, propertyKey) {
|
|
208
164
|
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
209
165
|
prop.step = step;
|
|
210
166
|
};
|
|
211
167
|
}
|
|
212
|
-
|
|
213
168
|
var NinePatch$2 = function (_super) {
|
|
214
169
|
__extends(NinePatch, _super);
|
|
215
|
-
|
|
216
170
|
function NinePatch() {
|
|
217
171
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
218
|
-
|
|
219
172
|
_this.resource = '';
|
|
220
173
|
_this.spriteName = '';
|
|
221
174
|
_this.leftWidth = 0;
|
|
@@ -224,7 +177,6 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
224
177
|
_this.bottomHeight = 0;
|
|
225
178
|
return _this;
|
|
226
179
|
}
|
|
227
|
-
|
|
228
180
|
NinePatch.prototype.init = function (obj) {
|
|
229
181
|
this.resource = obj.resource;
|
|
230
182
|
this.spriteName = obj.spriteName;
|
|
@@ -233,54 +185,38 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
233
185
|
this.rightWidth = obj.rightWidth;
|
|
234
186
|
this.bottomHeight = obj.bottomHeight;
|
|
235
187
|
};
|
|
236
|
-
|
|
237
188
|
NinePatch.componentName = 'NinePatch';
|
|
238
|
-
|
|
239
189
|
__decorate([type('string')], NinePatch.prototype, "resource", void 0);
|
|
240
|
-
|
|
241
190
|
__decorate([type('string')], NinePatch.prototype, "spriteName", void 0);
|
|
242
|
-
|
|
243
191
|
__decorate([type('number'), step(1)], NinePatch.prototype, "leftWidth", void 0);
|
|
244
|
-
|
|
245
192
|
__decorate([type('number'), step(1)], NinePatch.prototype, "topHeight", void 0);
|
|
246
|
-
|
|
247
193
|
__decorate([type('number'), step(1)], NinePatch.prototype, "rightWidth", void 0);
|
|
248
|
-
|
|
249
194
|
__decorate([type('number'), step(1)], NinePatch.prototype, "bottomHeight", void 0);
|
|
250
|
-
|
|
251
195
|
return NinePatch;
|
|
252
196
|
}(eva_js.Component);
|
|
253
|
-
|
|
254
197
|
var NinePatch$3 = NinePatch$2;
|
|
255
198
|
var resourceKeySplit = '_s|r|c_';
|
|
256
|
-
|
|
257
199
|
var NinePatch = function (_super) {
|
|
258
200
|
__extends(NinePatch, _super);
|
|
259
|
-
|
|
260
201
|
function NinePatch() {
|
|
261
202
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
262
|
-
|
|
263
203
|
_this.name = 'NinePatch';
|
|
264
204
|
_this.ninePatch = {};
|
|
265
205
|
return _this;
|
|
266
206
|
}
|
|
267
|
-
|
|
268
207
|
NinePatch.prototype.init = function () {
|
|
269
208
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
270
209
|
this.renderSystem.rendererManager.register(this);
|
|
271
210
|
};
|
|
272
|
-
|
|
273
211
|
NinePatch.prototype.rendererUpdate = function (gameObject) {
|
|
274
212
|
var _a = gameObject.transform.size,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
213
|
+
width = _a.width,
|
|
214
|
+
height = _a.height;
|
|
278
215
|
if (this.ninePatch[gameObject.id]) {
|
|
279
216
|
this.ninePatch[gameObject.id].width = width;
|
|
280
217
|
this.ninePatch[gameObject.id].height = height;
|
|
281
218
|
}
|
|
282
219
|
};
|
|
283
|
-
|
|
284
220
|
NinePatch.prototype.componentChanged = function (changed) {
|
|
285
221
|
return __awaiter(this, void 0, void 0, function () {
|
|
286
222
|
return __generator(this, function (_a) {
|
|
@@ -294,35 +230,32 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
294
230
|
this.add(changed);
|
|
295
231
|
}
|
|
296
232
|
}
|
|
297
|
-
|
|
298
233
|
return [2];
|
|
299
234
|
});
|
|
300
235
|
});
|
|
301
236
|
};
|
|
302
|
-
|
|
303
237
|
NinePatch.prototype.add = function (changed) {
|
|
304
238
|
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
306
|
-
|
|
239
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
307
240
|
return __generator(this, function (_b) {
|
|
308
241
|
switch (_b.label) {
|
|
309
242
|
case 0:
|
|
310
243
|
component = changed.component;
|
|
244
|
+
gameObjectId = changed.gameObject.id;
|
|
245
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
311
246
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
312
|
-
|
|
313
247
|
case 1:
|
|
314
248
|
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
315
|
-
|
|
249
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
316
250
|
if (!data) {
|
|
317
|
-
|
|
251
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
252
|
+
return [2];
|
|
318
253
|
}
|
|
319
|
-
|
|
320
254
|
if (type === eva_js.RESOURCE_TYPE.SPRITE) {
|
|
321
255
|
img = component.resource + resourceKeySplit + component.spriteName;
|
|
322
256
|
} else {
|
|
323
257
|
img = data.image;
|
|
324
258
|
}
|
|
325
|
-
|
|
326
259
|
leftWidth = component.leftWidth, topHeight = component.topHeight, rightWidth = component.rightWidth, bottomHeight = component.bottomHeight;
|
|
327
260
|
np = new rendererAdapter.NinePatch(img, leftWidth, topHeight, rightWidth, bottomHeight);
|
|
328
261
|
this.ninePatch[changed.gameObject.id] = np;
|
|
@@ -333,10 +266,10 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
333
266
|
});
|
|
334
267
|
});
|
|
335
268
|
};
|
|
336
|
-
|
|
337
269
|
NinePatch.prototype.remove = function (changed) {
|
|
338
|
-
var
|
|
339
|
-
|
|
270
|
+
var gameObjectId = changed.gameObject.id;
|
|
271
|
+
this.increaseAsyncId(gameObjectId);
|
|
272
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
340
273
|
if (sprite) {
|
|
341
274
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
342
275
|
delete this.ninePatch[changed.gameObject.id];
|
|
@@ -345,14 +278,12 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
345
278
|
});
|
|
346
279
|
}
|
|
347
280
|
};
|
|
348
|
-
|
|
349
281
|
NinePatch.systemName = 'NinePatch';
|
|
350
282
|
NinePatch = __decorate([eva_js.decorators.componentObserver({
|
|
351
283
|
NinePatch: ['resource', 'spriteName', 'leftWidth', 'topHeight', 'rightWidth', 'bottomHeight']
|
|
352
284
|
})], NinePatch);
|
|
353
285
|
return NinePatch;
|
|
354
286
|
}(pluginRenderer.Renderer);
|
|
355
|
-
|
|
356
287
|
var NinePatch$1 = NinePatch;
|
|
357
288
|
exports.NinePatch = NinePatch$3;
|
|
358
289
|
exports.NinePatchSystem = NinePatch$1;
|
|
@@ -361,3 +292,4 @@ this.EVA.plugin.renderer.ninePatch = function (exports, eva_js, pluginRenderer,
|
|
|
361
292
|
});
|
|
362
293
|
return exports;
|
|
363
294
|
}({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter);
|
|
295
|
+
window.EVA.plugin.renderer.ninePatch = window.EVA.plugin.renderer.ninePatch || _EVA_IIFE_ninePatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_ninePatch=function(t,e,n,r){"use strict";var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},i(t,e)};function o(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function c(t,e,n,r){var i,o=arguments.length,c=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(o<3?i(c):o>3?i(e,n,c):i(e,n))||c);return o>3&&c&&Object.defineProperty(e,n,c),c}function a(t,e,n,r){return new(n||(n=Promise))((function(i,o){function c(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,o,c={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,r=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(i=c.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){c.label=o[1];break}if(6===o[0]&&c.label<i[1]){c.label=i[1],i=o;break}if(i&&c.label<i[2]){c.label=i[2],c.ops.push(o);break}i[2]&&c.ops.pop(),c.trys.pop();continue}o=e.call(t,c)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function u(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}function h(t){return function(e,n){var r=u(e,n);r.key=n,r.type=t}}function p(t){return function(e,n){u(e,n).step=t}}var d=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.spriteName="",e.leftWidth=0,e.topHeight=0,e.rightWidth=0,e.bottomHeight=0,e}return o(e,t),e.prototype.init=function(t){this.resource=t.resource,this.spriteName=t.spriteName,this.leftWidth=t.leftWidth,this.topHeight=t.topHeight,this.rightWidth=t.rightWidth,this.bottomHeight=t.bottomHeight},e.componentName="NinePatch",c([h("string")],e.prototype,"resource",void 0),c([h("string")],e.prototype,"spriteName",void 0),c([h("number"),p(1)],e.prototype,"leftWidth",void 0),c([h("number"),p(1)],e.prototype,"topHeight",void 0),c([h("number"),p(1)],e.prototype,"rightWidth",void 0),c([h("number"),p(1)],e.prototype,"bottomHeight",void 0),e}(e.Component),l=d,f=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),i.prototype.init=function(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(t){var e=t.transform.size,n=e.width,r=e.height;this.ninePatch[t.id]&&(this.ninePatch[t.id].width=n,this.ninePatch[t.id].height=r)},i.prototype.componentChanged=function(t){return a(this,void 0,void 0,(function(){return s(this,(function(n){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return a(this,void 0,void 0,(function(){var n,i,o,c,a,u,h,p,d,l,f,y;return s(this,(function(s){switch(s.label){case 0:return n=t.component,i=t.gameObject.id,o=this.increaseAsyncId(i),[4,e.resource.getResource(n.resource)];case 1:return c=s.sent(),a=c.type,u=c.data,this.validateAsyncId(i,o)?u?(h=a===e.RESOURCE_TYPE.SPRITE?n.resource+"_s|r|c_"+n.spriteName:u.image,p=n.leftWidth,d=n.topHeight,l=n.rightWidth,f=n.bottomHeight,y=new r.NinePatch(h,p,d,l,f),this.ninePatch[t.gameObject.id]=y,n.ninePatch=y,this.containerManager.getContainer(t.gameObject.id).addChildAt(y,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2]):[2]}}))}))},i.prototype.remove=function(t){var e=t.gameObject.id;this.increaseAsyncId(e);var n=this.ninePatch[e];n&&(this.containerManager.getContainer(t.gameObject.id).removeChild(n),delete this.ninePatch[t.gameObject.id],n.destroy({children:!0}))},i.systemName="NinePatch",i=c([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(n.Renderer),y=f;return t.NinePatch=l,t.NinePatchSystem=y,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter);window.EVA.plugin.renderer.ninePatch=window.EVA.plugin.renderer.ninePatch||_EVA_IIFE_ninePatch;
|
|
@@ -168,16 +168,21 @@ var NinePatch = (function (_super) {
|
|
|
168
168
|
};
|
|
169
169
|
NinePatch.prototype.add = function (changed) {
|
|
170
170
|
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
-
var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
171
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
172
172
|
return __generator(this, function (_b) {
|
|
173
173
|
switch (_b.label) {
|
|
174
174
|
case 0:
|
|
175
175
|
component = changed.component;
|
|
176
|
+
gameObjectId = changed.gameObject.id;
|
|
177
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
176
178
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
177
179
|
case 1:
|
|
178
180
|
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
181
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
182
|
+
return [2];
|
|
179
183
|
if (!data) {
|
|
180
|
-
|
|
184
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
185
|
+
return [2];
|
|
181
186
|
}
|
|
182
187
|
if (type === eva_js.RESOURCE_TYPE.SPRITE) {
|
|
183
188
|
img = component.resource + resourceKeySplit + component.spriteName;
|
|
@@ -198,7 +203,9 @@ var NinePatch = (function (_super) {
|
|
|
198
203
|
});
|
|
199
204
|
};
|
|
200
205
|
NinePatch.prototype.remove = function (changed) {
|
|
201
|
-
var
|
|
206
|
+
var gameObjectId = changed.gameObject.id;
|
|
207
|
+
this.increaseAsyncId(gameObjectId);
|
|
208
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
202
209
|
if (sprite) {
|
|
203
210
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
204
211
|
delete this.ninePatch[changed.gameObject.id];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),i=function(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},i(e,t)};function o(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(e,t,r,n){var i,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(o<3?i(a):o>3?i(t,r,a):i(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function c(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new r((function(t){t(e.value)})).then(a,c)}s((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function c(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}var h=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.spriteName="",t.leftWidth=0,t.topHeight=0,t.rightWidth=0,t.bottomHeight=0,t}return o(r,e),r.prototype.init=function(e){this.resource=e.resource,this.spriteName=e.spriteName,this.leftWidth=e.leftWidth,this.topHeight=e.topHeight,this.rightWidth=e.rightWidth,this.bottomHeight=e.bottomHeight},r.componentName="NinePatch",a([t.type("string")],r.prototype,"resource",void 0),a([t.type("string")],r.prototype,"spriteName",void 0),a([t.type("number"),t.step(1)],r.prototype,"leftWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"topHeight",void 0),a([t.type("number"),t.step(1)],r.prototype,"rightWidth",void 0),a([t.type("number"),t.step(1)],r.prototype,"bottomHeight",void 0),r}(e.Component),p=h,u=function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="NinePatch",e.ninePatch={},e}return o(i,t),i.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},i.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.ninePatch[e.id]&&(this.ninePatch[e.id].width=r,this.ninePatch[e.id].height=n)},i.prototype.componentChanged=function(t){return c(this,void 0,void 0,(function(){return s(this,(function(r){return"NinePatch"===t.componentName&&(t.type===e.OBSERVER_TYPE.ADD?this.add(t):t.type===e.OBSERVER_TYPE.REMOVE?this.remove(t):(this.remove(t),this.add(t))),[2]}))}))},i.prototype.add=function(t){return c(this,void 0,void 0,(function(){var r,i,o,a,c,h,p,u,d,l,f,y;return s(this,(function(s){switch(s.label){case 0:return r=t.component,i=t.gameObject.id,o=this.increaseAsyncId(i),[4,e.resource.getResource(r.resource)];case 1:return a=s.sent(),c=a.type,h=a.data,this.validateAsyncId(i,o)?h?(p=c===e.RESOURCE_TYPE.SPRITE?r.resource+"_s|r|c_"+r.spriteName:h.image,u=r.leftWidth,d=r.topHeight,l=r.rightWidth,f=r.bottomHeight,y=new n.NinePatch(p,u,d,l,f),this.ninePatch[t.gameObject.id]=y,r.ninePatch=y,this.containerManager.getContainer(t.gameObject.id).addChildAt(y,0),[2]):(console.error("GameObject:"+t.gameObject.name+"'s NinePatch resource load error"),[2]):[2]}}))}))},i.prototype.remove=function(e){var t=e.gameObject.id;this.increaseAsyncId(t);var r=this.ninePatch[t];r&&(this.containerManager.getContainer(e.gameObject.id).removeChild(r),delete this.ninePatch[e.gameObject.id],r.destroy({children:!0}))},i.systemName="NinePatch",i=a([e.decorators.componentObserver({NinePatch:["resource","spriteName","leftWidth","topHeight","rightWidth","bottomHeight"]})],i)}(r.Renderer);exports.NinePatch=p,exports.NinePatchSystem=u;
|
|
@@ -40,8 +40,8 @@ export declare class NinePatchSystem extends Renderer {
|
|
|
40
40
|
init(): void;
|
|
41
41
|
rendererUpdate(gameObject: GameObject): void;
|
|
42
42
|
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
43
|
-
add(changed:
|
|
44
|
-
remove(changed:
|
|
43
|
+
add(changed: ComponentChanged): Promise<void>;
|
|
44
|
+
remove(changed: ComponentChanged): void;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export { }
|
|
@@ -164,16 +164,21 @@ var NinePatch = (function (_super) {
|
|
|
164
164
|
};
|
|
165
165
|
NinePatch.prototype.add = function (changed) {
|
|
166
166
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var component, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
167
|
+
var component, gameObjectId, asyncId, _a, type, data, img, leftWidth, topHeight, rightWidth, bottomHeight, np;
|
|
168
168
|
return __generator(this, function (_b) {
|
|
169
169
|
switch (_b.label) {
|
|
170
170
|
case 0:
|
|
171
171
|
component = changed.component;
|
|
172
|
+
gameObjectId = changed.gameObject.id;
|
|
173
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
172
174
|
return [4, resource.getResource(component.resource)];
|
|
173
175
|
case 1:
|
|
174
176
|
_a = _b.sent(), type = _a.type, data = _a.data;
|
|
177
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
178
|
+
return [2];
|
|
175
179
|
if (!data) {
|
|
176
|
-
|
|
180
|
+
console.error("GameObject:" + changed.gameObject.name + "'s NinePatch resource load error");
|
|
181
|
+
return [2];
|
|
177
182
|
}
|
|
178
183
|
if (type === RESOURCE_TYPE.SPRITE) {
|
|
179
184
|
img = component.resource + resourceKeySplit + component.spriteName;
|
|
@@ -194,7 +199,9 @@ var NinePatch = (function (_super) {
|
|
|
194
199
|
});
|
|
195
200
|
};
|
|
196
201
|
NinePatch.prototype.remove = function (changed) {
|
|
197
|
-
var
|
|
202
|
+
var gameObjectId = changed.gameObject.id;
|
|
203
|
+
this.increaseAsyncId(gameObjectId);
|
|
204
|
+
var sprite = this.ninePatch[gameObjectId];
|
|
198
205
|
if (sprite) {
|
|
199
206
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(sprite);
|
|
200
207
|
delete this.ninePatch[changed.gameObject.id];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-nine-patch",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "@eva/plugin-renderer-nine-patch",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-nine-patch.esm.js",
|
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "
|
|
23
|
-
"@eva/renderer-adapter": "
|
|
24
|
-
"@eva/eva.js": "
|
|
25
|
-
"@types/pixi.js": "^4.8.9"
|
|
22
|
+
"@eva/plugin-renderer": "2.0.0-beta.1",
|
|
23
|
+
"@eva/renderer-adapter": "2.0.0-beta.1",
|
|
24
|
+
"@eva/eva.js": "2.0.0-beta.1"
|
|
26
25
|
}
|
|
27
26
|
}
|