@eva/plugin-renderer-text 2.1.0-beta.3 → 2.1.0-beta.4
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.text.js +475 -0
- package/dist/EVA.plugin.renderer.text.min.js +1 -0
- package/dist/plugin-renderer-text.cjs.js +864 -0
- package/dist/plugin-renderer-text.cjs.prod.js +1 -0
- package/dist/plugin-renderer-text.d.ts +314 -0
- package/dist/plugin-renderer-text.esm.js +857 -0
- package/package.json +4 -4
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var eva_js = require('@eva/eva.js');
|
|
6
|
+
var pixi_js = require('pixi.js');
|
|
7
|
+
var pluginRenderer = require('@eva/plugin-renderer');
|
|
8
|
+
var rendererAdapter = require('@eva/renderer-adapter');
|
|
9
|
+
|
|
10
|
+
/******************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
|
|
25
|
+
function __decorate(decorators, target, key, desc) {
|
|
26
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
27
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
28
|
+
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;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function __metadata(metadataKey, metadataValue) {
|
|
33
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
47
|
+
var e = new Error(message);
|
|
48
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
class BitmapTextStyleMetadata {
|
|
52
|
+
}
|
|
53
|
+
__decorate([
|
|
54
|
+
eva_js.type('string'),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], BitmapTextStyleMetadata.prototype, "fontFamily", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
eva_js.type('number'),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], BitmapTextStyleMetadata.prototype, "fontSize", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
eva_js.Field({ type: 'color' }),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], BitmapTextStyleMetadata.prototype, "fill", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
eva_js.type('string'),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], BitmapTextStyleMetadata.prototype, "align", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
eva_js.type('number'),
|
|
71
|
+
__metadata("design:type", Number)
|
|
72
|
+
], BitmapTextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
eva_js.type('number'),
|
|
75
|
+
__metadata("design:type", Number)
|
|
76
|
+
], BitmapTextStyleMetadata.prototype, "padding", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
eva_js.Field({ type: 'color' }),
|
|
79
|
+
__metadata("design:type", Object)
|
|
80
|
+
], BitmapTextStyleMetadata.prototype, "stroke", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
eva_js.type('number'),
|
|
83
|
+
__metadata("design:type", Number)
|
|
84
|
+
], BitmapTextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
eva_js.type('string'),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], BitmapTextStyleMetadata.prototype, "fontWeight", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
eva_js.type('string'),
|
|
91
|
+
__metadata("design:type", String)
|
|
92
|
+
], BitmapTextStyleMetadata.prototype, "fontStyle", void 0);
|
|
93
|
+
/**
|
|
94
|
+
* 位图文本组件
|
|
95
|
+
*
|
|
96
|
+
* BitmapText 组件使用位图字体渲染文本,性能优于 Canvas 文本渲染。
|
|
97
|
+
* 适用于频繁更新的文本场景,如计分板、倒计时等。
|
|
98
|
+
*
|
|
99
|
+
* 支持两种字体模式:
|
|
100
|
+
* - 动态生成:指定 TextStyle,PixiJS 自动生成 bitmap font
|
|
101
|
+
* - 预加载字体:通过 BitmapFont.install() 预安装或从 .fnt 文件加载
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const score = new GameObject('score');
|
|
106
|
+
* score.addComponent(new BitmapText({
|
|
107
|
+
* text: 'Score: 0',
|
|
108
|
+
* style: {
|
|
109
|
+
* fontSize: 32,
|
|
110
|
+
* fill: '#ffffff',
|
|
111
|
+
* fontFamily: 'Arial'
|
|
112
|
+
* }
|
|
113
|
+
* }));
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
class BitmapText extends eva_js.Component {
|
|
117
|
+
constructor() {
|
|
118
|
+
super(...arguments);
|
|
119
|
+
this.text = '';
|
|
120
|
+
this.style = {};
|
|
121
|
+
}
|
|
122
|
+
init(obj) {
|
|
123
|
+
this.style = Object.assign({ fontSize: 24, fill: '#000000', fontFamily: 'Arial' }, obj === null || obj === void 0 ? void 0 : obj.style);
|
|
124
|
+
if (obj) {
|
|
125
|
+
this.text = obj.text;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
BitmapText.componentName = 'BitmapText';
|
|
130
|
+
__decorate([
|
|
131
|
+
eva_js.type('string'),
|
|
132
|
+
__metadata("design:type", String)
|
|
133
|
+
], BitmapText.prototype, "text", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
eva_js.Field(() => BitmapTextStyleMetadata),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], BitmapText.prototype, "style", void 0);
|
|
138
|
+
|
|
139
|
+
class TextStyleStrokeMetadata {
|
|
140
|
+
}
|
|
141
|
+
__decorate([
|
|
142
|
+
eva_js.type('number'),
|
|
143
|
+
__metadata("design:type", Number)
|
|
144
|
+
], TextStyleStrokeMetadata.prototype, "alpha", void 0);
|
|
145
|
+
__decorate([
|
|
146
|
+
eva_js.Field({ type: 'color' }),
|
|
147
|
+
__metadata("design:type", Object)
|
|
148
|
+
], TextStyleStrokeMetadata.prototype, "color", void 0);
|
|
149
|
+
__decorate([
|
|
150
|
+
eva_js.type('string'),
|
|
151
|
+
__metadata("design:type", String)
|
|
152
|
+
], TextStyleStrokeMetadata.prototype, "join", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
eva_js.type('number'),
|
|
155
|
+
__metadata("design:type", Number)
|
|
156
|
+
], TextStyleStrokeMetadata.prototype, "miterLimit", void 0);
|
|
157
|
+
__decorate([
|
|
158
|
+
eva_js.type('number'),
|
|
159
|
+
__metadata("design:type", Number)
|
|
160
|
+
], TextStyleStrokeMetadata.prototype, "width", void 0);
|
|
161
|
+
class TextStyleDropShadowMetadata {
|
|
162
|
+
}
|
|
163
|
+
__decorate([
|
|
164
|
+
eva_js.type('number'),
|
|
165
|
+
__metadata("design:type", Number)
|
|
166
|
+
], TextStyleDropShadowMetadata.prototype, "alpha", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
eva_js.type('number'),
|
|
169
|
+
__metadata("design:type", Number)
|
|
170
|
+
], TextStyleDropShadowMetadata.prototype, "angle", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
eva_js.type('number'),
|
|
173
|
+
__metadata("design:type", Number)
|
|
174
|
+
], TextStyleDropShadowMetadata.prototype, "blur", void 0);
|
|
175
|
+
__decorate([
|
|
176
|
+
eva_js.Field({ type: 'color' }),
|
|
177
|
+
__metadata("design:type", Object)
|
|
178
|
+
], TextStyleDropShadowMetadata.prototype, "color", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
eva_js.type('number'),
|
|
181
|
+
__metadata("design:type", Number)
|
|
182
|
+
], TextStyleDropShadowMetadata.prototype, "distance", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
eva_js.type('boolean'),
|
|
185
|
+
__metadata("design:type", Boolean)
|
|
186
|
+
], TextStyleDropShadowMetadata.prototype, "enabled", void 0);
|
|
187
|
+
class TextStyleMetadata {
|
|
188
|
+
}
|
|
189
|
+
__decorate([
|
|
190
|
+
eva_js.type('string'),
|
|
191
|
+
__metadata("design:type", String)
|
|
192
|
+
], TextStyleMetadata.prototype, "align", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
eva_js.type('boolean'),
|
|
195
|
+
__metadata("design:type", Boolean)
|
|
196
|
+
], TextStyleMetadata.prototype, "breakWords", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
eva_js.Field(() => TextStyleDropShadowMetadata),
|
|
199
|
+
__metadata("design:type", Object)
|
|
200
|
+
], TextStyleMetadata.prototype, "dropShadow", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
eva_js.type('number'),
|
|
203
|
+
__metadata("design:type", Number)
|
|
204
|
+
], TextStyleMetadata.prototype, "dropShadowAlpha", void 0);
|
|
205
|
+
__decorate([
|
|
206
|
+
eva_js.type('number'),
|
|
207
|
+
__metadata("design:type", Number)
|
|
208
|
+
], TextStyleMetadata.prototype, "dropShadowAngle", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
eva_js.type('number'),
|
|
211
|
+
__metadata("design:type", Number)
|
|
212
|
+
], TextStyleMetadata.prototype, "dropShadowBlur", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
eva_js.Field({ type: 'color' }),
|
|
215
|
+
__metadata("design:type", Object)
|
|
216
|
+
], TextStyleMetadata.prototype, "dropShadowColor", void 0);
|
|
217
|
+
__decorate([
|
|
218
|
+
eva_js.type('number'),
|
|
219
|
+
__metadata("design:type", Number)
|
|
220
|
+
], TextStyleMetadata.prototype, "dropShadowDistance", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
eva_js.Field({ type: 'color' }),
|
|
223
|
+
__metadata("design:type", Object)
|
|
224
|
+
], TextStyleMetadata.prototype, "fill", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
eva_js.type('number'),
|
|
227
|
+
__metadata("design:type", Number)
|
|
228
|
+
], TextStyleMetadata.prototype, "fillGradientType", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
eva_js.type('number'),
|
|
231
|
+
__metadata("design:type", Array)
|
|
232
|
+
], TextStyleMetadata.prototype, "fillGradientStops", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
eva_js.type('string'),
|
|
235
|
+
__metadata("design:type", Object)
|
|
236
|
+
], TextStyleMetadata.prototype, "fontFamily", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
eva_js.type('number'),
|
|
239
|
+
__metadata("design:type", Object)
|
|
240
|
+
], TextStyleMetadata.prototype, "fontSize", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
eva_js.type('string'),
|
|
243
|
+
__metadata("design:type", String)
|
|
244
|
+
], TextStyleMetadata.prototype, "fontStyle", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
eva_js.type('string'),
|
|
247
|
+
__metadata("design:type", String)
|
|
248
|
+
], TextStyleMetadata.prototype, "fontVariant", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
eva_js.type('string'),
|
|
251
|
+
__metadata("design:type", String)
|
|
252
|
+
], TextStyleMetadata.prototype, "fontWeight", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
eva_js.type('number'),
|
|
255
|
+
__metadata("design:type", Number)
|
|
256
|
+
], TextStyleMetadata.prototype, "leading", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
eva_js.type('number'),
|
|
259
|
+
__metadata("design:type", Number)
|
|
260
|
+
], TextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
eva_js.type('number'),
|
|
263
|
+
__metadata("design:type", Number)
|
|
264
|
+
], TextStyleMetadata.prototype, "lineHeight", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
eva_js.type('string'),
|
|
267
|
+
__metadata("design:type", String)
|
|
268
|
+
], TextStyleMetadata.prototype, "lineJoin", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
eva_js.type('number'),
|
|
271
|
+
__metadata("design:type", Number)
|
|
272
|
+
], TextStyleMetadata.prototype, "miterLimit", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
eva_js.type('number'),
|
|
275
|
+
__metadata("design:type", Number)
|
|
276
|
+
], TextStyleMetadata.prototype, "padding", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
eva_js.Field(() => TextStyleStrokeMetadata),
|
|
279
|
+
__metadata("design:type", Object)
|
|
280
|
+
], TextStyleMetadata.prototype, "stroke", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
eva_js.type('number'),
|
|
283
|
+
__metadata("design:type", Number)
|
|
284
|
+
], TextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
eva_js.type('string'),
|
|
287
|
+
__metadata("design:type", String)
|
|
288
|
+
], TextStyleMetadata.prototype, "textBaseline", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
eva_js.type('string'),
|
|
291
|
+
__metadata("design:type", String)
|
|
292
|
+
], TextStyleMetadata.prototype, "verticalAlign", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
eva_js.type('boolean'),
|
|
295
|
+
__metadata("design:type", Boolean)
|
|
296
|
+
], TextStyleMetadata.prototype, "trim", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
eva_js.type('string'),
|
|
299
|
+
__metadata("design:type", String)
|
|
300
|
+
], TextStyleMetadata.prototype, "whiteSpace", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
eva_js.type('boolean'),
|
|
303
|
+
__metadata("design:type", Boolean)
|
|
304
|
+
], TextStyleMetadata.prototype, "wordWrap", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
eva_js.type('number'),
|
|
307
|
+
__metadata("design:type", Number)
|
|
308
|
+
], TextStyleMetadata.prototype, "wordWrapWidth", void 0);
|
|
309
|
+
/**
|
|
310
|
+
* 文本组件(基于 PixiJS Text)
|
|
311
|
+
*
|
|
312
|
+
* Text 组件用于渲染文本内容,支持丰富的文本样式配置。
|
|
313
|
+
* 它基于 PixiJS 的 Text 实现,支持字体、颜色、描边、阴影、对齐等多种样式。
|
|
314
|
+
*
|
|
315
|
+
* 主要特性:
|
|
316
|
+
* - 支持多种字体和字号
|
|
317
|
+
* - 支持文本颜色、渐变填充
|
|
318
|
+
* - 支持描边和投影效果
|
|
319
|
+
* - 支持文本对齐和换行
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* // 基础文本
|
|
324
|
+
* const label = new GameObject('label');
|
|
325
|
+
* label.addComponent(new Text({
|
|
326
|
+
* text: 'Hello EVA!',
|
|
327
|
+
* style: {
|
|
328
|
+
* fontSize: 32,
|
|
329
|
+
* fill: 0xffffff
|
|
330
|
+
* }
|
|
331
|
+
* }));
|
|
332
|
+
*
|
|
333
|
+
* // 带样式的文本
|
|
334
|
+
* label.addComponent(new Text({
|
|
335
|
+
* text: '得分: 9999',
|
|
336
|
+
* style: {
|
|
337
|
+
* fontFamily: 'Arial',
|
|
338
|
+
* fontSize: 48,
|
|
339
|
+
* fontWeight: 'bold',
|
|
340
|
+
* fill: ['#ff0000', '#ffff00'], // 渐变色
|
|
341
|
+
* stroke: '#000000',
|
|
342
|
+
* strokeThickness: 4,
|
|
343
|
+
* dropShadow: true,
|
|
344
|
+
* dropShadowDistance: 3
|
|
345
|
+
* }
|
|
346
|
+
* }));
|
|
347
|
+
* // 如需高清渲染,使用 Render 组件的 resolution 属性
|
|
348
|
+
* label.addComponent(new Render({ resolution: 2 }));
|
|
349
|
+
* ```
|
|
350
|
+
*/
|
|
351
|
+
class Text$2 extends eva_js.Component {
|
|
352
|
+
constructor(params) {
|
|
353
|
+
super(params);
|
|
354
|
+
/** 文本内容 */
|
|
355
|
+
this.text = '';
|
|
356
|
+
/** 文本样式配置 */
|
|
357
|
+
this.style = {};
|
|
358
|
+
this.init(params);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* 初始化组件
|
|
362
|
+
* @param obj - 初始化参数
|
|
363
|
+
*/
|
|
364
|
+
init(obj) {
|
|
365
|
+
const style = new pixi_js.TextStyle({
|
|
366
|
+
fontSize: 20,
|
|
367
|
+
});
|
|
368
|
+
const newStyle = {};
|
|
369
|
+
for (const key in style) {
|
|
370
|
+
if (key.indexOf('_') === 0) {
|
|
371
|
+
newStyle[key.substring(1)] = style[key];
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
delete newStyle['styleKey'];
|
|
375
|
+
this.style = newStyle;
|
|
376
|
+
if (obj) {
|
|
377
|
+
this.text = obj.text;
|
|
378
|
+
Object.assign(this.style, obj.style);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
/** 组件名称 */
|
|
383
|
+
Text$2.componentName = 'Text';
|
|
384
|
+
__decorate([
|
|
385
|
+
eva_js.type('string'),
|
|
386
|
+
__metadata("design:type", String)
|
|
387
|
+
], Text$2.prototype, "text", void 0);
|
|
388
|
+
__decorate([
|
|
389
|
+
eva_js.Field(() => TextStyleMetadata),
|
|
390
|
+
__metadata("design:type", Object)
|
|
391
|
+
], Text$2.prototype, "style", void 0);
|
|
392
|
+
|
|
393
|
+
class HTMLTextTextureStyleMetadata {
|
|
394
|
+
}
|
|
395
|
+
__decorate([
|
|
396
|
+
eva_js.type('string'),
|
|
397
|
+
__metadata("design:type", String)
|
|
398
|
+
], HTMLTextTextureStyleMetadata.prototype, "scaleMode", void 0);
|
|
399
|
+
__decorate([
|
|
400
|
+
eva_js.type('number'),
|
|
401
|
+
__metadata("design:type", Number)
|
|
402
|
+
], HTMLTextTextureStyleMetadata.prototype, "resolution", void 0);
|
|
403
|
+
class HTMLTextStyleMetadata {
|
|
404
|
+
}
|
|
405
|
+
__decorate([
|
|
406
|
+
eva_js.type('string'),
|
|
407
|
+
__metadata("design:type", Object)
|
|
408
|
+
], HTMLTextStyleMetadata.prototype, "fontFamily", void 0);
|
|
409
|
+
__decorate([
|
|
410
|
+
eva_js.type('number'),
|
|
411
|
+
__metadata("design:type", Object)
|
|
412
|
+
], HTMLTextStyleMetadata.prototype, "fontSize", void 0);
|
|
413
|
+
__decorate([
|
|
414
|
+
eva_js.type('string'),
|
|
415
|
+
__metadata("design:type", String)
|
|
416
|
+
], HTMLTextStyleMetadata.prototype, "fontWeight", void 0);
|
|
417
|
+
__decorate([
|
|
418
|
+
eva_js.type('string'),
|
|
419
|
+
__metadata("design:type", String)
|
|
420
|
+
], HTMLTextStyleMetadata.prototype, "fontStyle", void 0);
|
|
421
|
+
__decorate([
|
|
422
|
+
eva_js.type('string'),
|
|
423
|
+
__metadata("design:type", String)
|
|
424
|
+
], HTMLTextStyleMetadata.prototype, "fontVariant", void 0);
|
|
425
|
+
__decorate([
|
|
426
|
+
eva_js.type('string'),
|
|
427
|
+
__metadata("design:type", String)
|
|
428
|
+
], HTMLTextStyleMetadata.prototype, "align", void 0);
|
|
429
|
+
__decorate([
|
|
430
|
+
eva_js.type('string'),
|
|
431
|
+
__metadata("design:type", String)
|
|
432
|
+
], HTMLTextStyleMetadata.prototype, "textBaseline", void 0);
|
|
433
|
+
__decorate([
|
|
434
|
+
eva_js.Field({ type: 'color' }),
|
|
435
|
+
__metadata("design:type", Object)
|
|
436
|
+
], HTMLTextStyleMetadata.prototype, "fill", void 0);
|
|
437
|
+
__decorate([
|
|
438
|
+
eva_js.Field({ type: 'color' }),
|
|
439
|
+
__metadata("design:type", Object)
|
|
440
|
+
], HTMLTextStyleMetadata.prototype, "stroke", void 0);
|
|
441
|
+
__decorate([
|
|
442
|
+
eva_js.type('number'),
|
|
443
|
+
__metadata("design:type", Number)
|
|
444
|
+
], HTMLTextStyleMetadata.prototype, "strokeThickness", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
eva_js.type('number'),
|
|
447
|
+
__metadata("design:type", Number)
|
|
448
|
+
], HTMLTextStyleMetadata.prototype, "lineHeight", void 0);
|
|
449
|
+
__decorate([
|
|
450
|
+
eva_js.type('number'),
|
|
451
|
+
__metadata("design:type", Number)
|
|
452
|
+
], HTMLTextStyleMetadata.prototype, "letterSpacing", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
eva_js.type('number'),
|
|
455
|
+
__metadata("design:type", Number)
|
|
456
|
+
], HTMLTextStyleMetadata.prototype, "padding", void 0);
|
|
457
|
+
__decorate([
|
|
458
|
+
eva_js.type('boolean'),
|
|
459
|
+
__metadata("design:type", Boolean)
|
|
460
|
+
], HTMLTextStyleMetadata.prototype, "wordWrap", void 0);
|
|
461
|
+
__decorate([
|
|
462
|
+
eva_js.type('number'),
|
|
463
|
+
__metadata("design:type", Number)
|
|
464
|
+
], HTMLTextStyleMetadata.prototype, "wordWrapWidth", void 0);
|
|
465
|
+
__decorate([
|
|
466
|
+
eva_js.type('boolean'),
|
|
467
|
+
__metadata("design:type", Boolean)
|
|
468
|
+
], HTMLTextStyleMetadata.prototype, "breakWords", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
eva_js.type('string'),
|
|
471
|
+
__metadata("design:type", String)
|
|
472
|
+
], HTMLTextStyleMetadata.prototype, "whiteSpace", void 0);
|
|
473
|
+
__decorate([
|
|
474
|
+
eva_js.type('boolean'),
|
|
475
|
+
__metadata("design:type", Boolean)
|
|
476
|
+
], HTMLTextStyleMetadata.prototype, "dropShadow", void 0);
|
|
477
|
+
__decorate([
|
|
478
|
+
eva_js.Field({ type: 'color' }),
|
|
479
|
+
__metadata("design:type", Object)
|
|
480
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowColor", void 0);
|
|
481
|
+
__decorate([
|
|
482
|
+
eva_js.type('number'),
|
|
483
|
+
__metadata("design:type", Number)
|
|
484
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowAlpha", void 0);
|
|
485
|
+
__decorate([
|
|
486
|
+
eva_js.type('number'),
|
|
487
|
+
__metadata("design:type", Number)
|
|
488
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowAngle", void 0);
|
|
489
|
+
__decorate([
|
|
490
|
+
eva_js.type('number'),
|
|
491
|
+
__metadata("design:type", Number)
|
|
492
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowBlur", void 0);
|
|
493
|
+
__decorate([
|
|
494
|
+
eva_js.type('number'),
|
|
495
|
+
__metadata("design:type", Number)
|
|
496
|
+
], HTMLTextStyleMetadata.prototype, "dropShadowDistance", void 0);
|
|
497
|
+
__decorate([
|
|
498
|
+
eva_js.type('object'),
|
|
499
|
+
__metadata("design:type", Array)
|
|
500
|
+
], HTMLTextStyleMetadata.prototype, "cssOverrides", void 0);
|
|
501
|
+
__decorate([
|
|
502
|
+
eva_js.type('object'),
|
|
503
|
+
__metadata("design:type", Object)
|
|
504
|
+
], HTMLTextStyleMetadata.prototype, "tagStyles", void 0);
|
|
505
|
+
__decorate([
|
|
506
|
+
eva_js.type('boolean'),
|
|
507
|
+
__metadata("design:type", Boolean)
|
|
508
|
+
], HTMLTextStyleMetadata.prototype, "trim", void 0);
|
|
509
|
+
/**
|
|
510
|
+
* HTML 富文本组件
|
|
511
|
+
*
|
|
512
|
+
* HTMLText 组件支持渲染带有 HTML 标签的富文本内容。
|
|
513
|
+
* 可以在文本中使用 HTML 标签(如 `<b>`, `<i>`, `<span>` 等)来实现丰富的文本样式,
|
|
514
|
+
* 适用于聊天对话、新闻内容、富文本显示等需要多样式文本的场景。
|
|
515
|
+
*
|
|
516
|
+
* 支持的 HTML 标签:
|
|
517
|
+
* - `<b>` - 粗体
|
|
518
|
+
* - `<i>` - 斜体
|
|
519
|
+
* - `<span style="color:#ff0000">` - 自定义样式
|
|
520
|
+
* - `<br>` - 换行
|
|
521
|
+
* 以及更多标准 HTML 文本标签
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* // 基础富文本
|
|
526
|
+
* const label = new GameObject('label');
|
|
527
|
+
* label.addComponent(new HTMLText({
|
|
528
|
+
* text: '这是<b>粗体</b>和<i>斜体</i>文本',
|
|
529
|
+
* style: {
|
|
530
|
+
* fontSize: 24,
|
|
531
|
+
* fill: '#000000',
|
|
532
|
+
* fontFamily: 'Arial'
|
|
533
|
+
* }
|
|
534
|
+
* }));
|
|
535
|
+
*
|
|
536
|
+
* // 带颜色的富文本
|
|
537
|
+
* label.addComponent(new HTMLText({
|
|
538
|
+
* text: '欢迎 <span style="color:#ff0000">玩家123</span> 加入游戏!',
|
|
539
|
+
* style: {
|
|
540
|
+
* fontSize: 20,
|
|
541
|
+
* wordWrap: true,
|
|
542
|
+
* wordWrapWidth: 300
|
|
543
|
+
* }
|
|
544
|
+
* }));
|
|
545
|
+
*
|
|
546
|
+
* // 自定义标签样式
|
|
547
|
+
* label.addComponent(new HTMLText({
|
|
548
|
+
* text: '获得 <gold>100</gold> 金币',
|
|
549
|
+
* style: {
|
|
550
|
+
* fontSize: 18,
|
|
551
|
+
* tagStyles: {
|
|
552
|
+
* gold: {
|
|
553
|
+
* fill: '#ffd700',
|
|
554
|
+
* fontWeight: 'bold'
|
|
555
|
+
* }
|
|
556
|
+
* }
|
|
557
|
+
* }
|
|
558
|
+
* }));
|
|
559
|
+
*
|
|
560
|
+
* // 高分辨率渲染(推荐使用 Render 组件的 resolution 属性)
|
|
561
|
+
* label.addComponent(new HTMLText({
|
|
562
|
+
* text: '高清文本',
|
|
563
|
+
* textureStyle: {
|
|
564
|
+
* scaleMode: 'linear'
|
|
565
|
+
* }
|
|
566
|
+
* }));
|
|
567
|
+
* label.addComponent(new Render({ resolution: 2 }));
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
class HTMLText extends eva_js.Component {
|
|
571
|
+
constructor() {
|
|
572
|
+
super(...arguments);
|
|
573
|
+
/** 富文本内容(支持 HTML 标签) */
|
|
574
|
+
this.text = '';
|
|
575
|
+
/** 文本样式配置 */
|
|
576
|
+
this.style = {};
|
|
577
|
+
/** 纹理渲染配置 */
|
|
578
|
+
this.textureStyle = {};
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* 初始化组件
|
|
582
|
+
* @param obj - 初始化参数
|
|
583
|
+
*/
|
|
584
|
+
init(obj) {
|
|
585
|
+
this.style = Object.assign({ fontSize: 24, fill: '#000000', fontFamily: 'Arial' }, obj === null || obj === void 0 ? void 0 : obj.style);
|
|
586
|
+
this.textureStyle = Object.assign({ scaleMode: 'linear', resolution: window.devicePixelRatio || 1 }, obj === null || obj === void 0 ? void 0 : obj.textureStyle);
|
|
587
|
+
if (obj) {
|
|
588
|
+
this.text = obj.text;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
/** 组件名称 */
|
|
593
|
+
HTMLText.componentName = 'HTMLText';
|
|
594
|
+
__decorate([
|
|
595
|
+
eva_js.type('string'),
|
|
596
|
+
__metadata("design:type", String)
|
|
597
|
+
], HTMLText.prototype, "text", void 0);
|
|
598
|
+
__decorate([
|
|
599
|
+
eva_js.Field(() => HTMLTextStyleMetadata),
|
|
600
|
+
__metadata("design:type", Object)
|
|
601
|
+
], HTMLText.prototype, "style", void 0);
|
|
602
|
+
__decorate([
|
|
603
|
+
eva_js.Field(() => HTMLTextTextureStyleMetadata),
|
|
604
|
+
__metadata("design:type", Object)
|
|
605
|
+
], HTMLText.prototype, "textureStyle", void 0);
|
|
606
|
+
|
|
607
|
+
let Text = class Text extends pluginRenderer.Renderer {
|
|
608
|
+
constructor() {
|
|
609
|
+
super(...arguments);
|
|
610
|
+
this.name = 'Text';
|
|
611
|
+
this.texts = {};
|
|
612
|
+
}
|
|
613
|
+
init() {
|
|
614
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
615
|
+
this.renderSystem.rendererManager.register(this);
|
|
616
|
+
}
|
|
617
|
+
componentChanged(changed) {
|
|
618
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
619
|
+
const isText = changed.componentName === 'Text';
|
|
620
|
+
const isHTMLText = changed.componentName === 'HTMLText';
|
|
621
|
+
const isBitmapText = changed.componentName === 'BitmapText';
|
|
622
|
+
if (!isText && !isHTMLText && !isBitmapText)
|
|
623
|
+
return;
|
|
624
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
625
|
+
if (isText) {
|
|
626
|
+
yield this.addTextComponent(changed);
|
|
627
|
+
}
|
|
628
|
+
else if (isHTMLText) {
|
|
629
|
+
yield this.addHTMLTextComponent(changed);
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
yield this.addBitmapTextComponent(changed);
|
|
633
|
+
}
|
|
634
|
+
this.setSize(changed);
|
|
635
|
+
}
|
|
636
|
+
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
637
|
+
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
638
|
+
this.texts[changed.gameObject.id].text.destroy({ children: true });
|
|
639
|
+
delete this.texts[changed.gameObject.id];
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
this.change(changed);
|
|
643
|
+
// 如果样式改变且涉及字体,也需要等待字体资源加载
|
|
644
|
+
const component = changed.component;
|
|
645
|
+
if (changed.prop.prop[0] === 'style' && component.style && component.style.fontFamily) {
|
|
646
|
+
const { text } = this.texts[changed.gameObject.id];
|
|
647
|
+
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
648
|
+
}
|
|
649
|
+
this.setSize(changed);
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
addTextComponent(changed) {
|
|
654
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
655
|
+
const component = changed.component;
|
|
656
|
+
// 创建文本样式副本,先不设置 fontFamily
|
|
657
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
658
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
659
|
+
delete styleWithoutFont.fontFamily;
|
|
660
|
+
const initialText = fontFamily ? '' : component.text;
|
|
661
|
+
const text = new rendererAdapter.Text(initialText, styleWithoutFont);
|
|
662
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(text, 0);
|
|
663
|
+
this.texts[changed.gameObject.id] = {
|
|
664
|
+
text,
|
|
665
|
+
component,
|
|
666
|
+
};
|
|
667
|
+
// 如果指定了字体资源,等待资源加载完成后设置 fontFamily
|
|
668
|
+
if (fontFamily) {
|
|
669
|
+
yield this.waitForFontResource(text, changed, fontFamily);
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
addHTMLTextComponent(changed) {
|
|
674
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
675
|
+
const component = changed.component;
|
|
676
|
+
// 创建样式副本,先不设置 fontFamily
|
|
677
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
678
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
679
|
+
delete styleWithoutFont.fontFamily;
|
|
680
|
+
const initialText = fontFamily ? '' : component.text;
|
|
681
|
+
const htmlText = new rendererAdapter.HTMLText(Object.assign({ text: initialText, style: styleWithoutFont }, (component.textureStyle && { textureStyle: component.textureStyle })));
|
|
682
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(htmlText, 0);
|
|
683
|
+
this.texts[changed.gameObject.id] = {
|
|
684
|
+
text: htmlText,
|
|
685
|
+
component,
|
|
686
|
+
};
|
|
687
|
+
// 如果指定了字体资源,等待资源加载完成后设置 fontFamily
|
|
688
|
+
if (fontFamily) {
|
|
689
|
+
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
addBitmapTextComponent(changed) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
695
|
+
const component = changed.component;
|
|
696
|
+
// 创建样式副本,先不设置 fontFamily
|
|
697
|
+
const styleWithoutFont = this.processStyle(component.style);
|
|
698
|
+
const fontFamily = styleWithoutFont.fontFamily;
|
|
699
|
+
delete styleWithoutFont.fontFamily;
|
|
700
|
+
const initialText = fontFamily ? '' : component.text;
|
|
701
|
+
const bitmapText = new rendererAdapter.BitmapText(initialText, styleWithoutFont);
|
|
702
|
+
this.containerManager.getContainer(changed.gameObject.id).addChildAt(bitmapText, 0);
|
|
703
|
+
this.texts[changed.gameObject.id] = {
|
|
704
|
+
text: bitmapText,
|
|
705
|
+
component,
|
|
706
|
+
};
|
|
707
|
+
// 如果指定了字体资源,等待资源加载完成后设置 fontFamily
|
|
708
|
+
if (fontFamily) {
|
|
709
|
+
yield this.waitForFontResource(bitmapText, changed, fontFamily);
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* 等待字体资源加载完成并更新文本
|
|
715
|
+
*/
|
|
716
|
+
waitForFontResource(text, changed, fontFamily) {
|
|
717
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
718
|
+
if (!fontFamily) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
try {
|
|
722
|
+
const fontName = Array.isArray(fontFamily) ? fontFamily[0] : fontFamily;
|
|
723
|
+
// 通过 resource 系统获取字体资源
|
|
724
|
+
const asyncId = this.increaseAsyncId(changed.gameObject.id);
|
|
725
|
+
yield eva_js.resource.getResource(fontName);
|
|
726
|
+
// 验证异步操作是否仍然有效(防止组件已被移除)
|
|
727
|
+
if (!this.validateAsyncId(changed.gameObject.id, asyncId))
|
|
728
|
+
return;
|
|
729
|
+
// 字体资源加载成功后,设置 fontFamily 并重新设置文本内容以触发重新渲染
|
|
730
|
+
const component = this.texts[changed.gameObject.id].component;
|
|
731
|
+
text.style.fontFamily = fontFamily;
|
|
732
|
+
text.text = component.text;
|
|
733
|
+
// 更新尺寸
|
|
734
|
+
}
|
|
735
|
+
catch (error) {
|
|
736
|
+
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* 将 Eva.js 的样式格式转换为 PixiJS v8 格式
|
|
742
|
+
*/
|
|
743
|
+
processStyle(style) {
|
|
744
|
+
const processed = Object.assign({}, style);
|
|
745
|
+
// stroke + strokeThickness -> stroke: { color, width }
|
|
746
|
+
if (processed.strokeThickness) {
|
|
747
|
+
const color = processed.stroke;
|
|
748
|
+
processed.stroke = {
|
|
749
|
+
color,
|
|
750
|
+
width: processed.strokeThickness,
|
|
751
|
+
};
|
|
752
|
+
delete processed.strokeThickness;
|
|
753
|
+
}
|
|
754
|
+
// dropShadow*(v7 平铺 alias) -> dropShadow: { color, distance, angle, alpha, blur }
|
|
755
|
+
// 关键:只有当存在任何 v7 平铺 alias 时才合并;否则保留 v8 嵌套对象(以及
|
|
756
|
+
// dropShadow: true / false 这种纯开关)原样透传。否则上一种情况会用空对象
|
|
757
|
+
// 把 DSL 已经写好的 angle/blur/distance/... 整个覆盖。
|
|
758
|
+
const hasFlatDropShadowAlias = processed.dropShadowColor != null ||
|
|
759
|
+
processed.dropShadowDistance != null ||
|
|
760
|
+
processed.dropShadowAngle != null ||
|
|
761
|
+
processed.dropShadowAlpha != null ||
|
|
762
|
+
processed.dropShadowBlur != null;
|
|
763
|
+
if (processed.dropShadow && hasFlatDropShadowAlias) {
|
|
764
|
+
const base = processed.dropShadow && typeof processed.dropShadow === 'object' && !Array.isArray(processed.dropShadow)
|
|
765
|
+
? Object.assign({}, processed.dropShadow) : {};
|
|
766
|
+
if (processed.dropShadowColor != null) {
|
|
767
|
+
base.color = processed.dropShadowColor;
|
|
768
|
+
}
|
|
769
|
+
if (processed.dropShadowDistance != null) {
|
|
770
|
+
base.distance = processed.dropShadowDistance;
|
|
771
|
+
}
|
|
772
|
+
if (processed.dropShadowAngle != null) {
|
|
773
|
+
base.angle = processed.dropShadowAngle;
|
|
774
|
+
}
|
|
775
|
+
if (processed.dropShadowAlpha != null) {
|
|
776
|
+
base.alpha = processed.dropShadowAlpha;
|
|
777
|
+
}
|
|
778
|
+
if (processed.dropShadowBlur != null) {
|
|
779
|
+
base.blur = processed.dropShadowBlur;
|
|
780
|
+
}
|
|
781
|
+
processed.dropShadow = base;
|
|
782
|
+
}
|
|
783
|
+
delete processed.dropShadowColor;
|
|
784
|
+
delete processed.dropShadowDistance;
|
|
785
|
+
delete processed.dropShadowAngle;
|
|
786
|
+
delete processed.dropShadowAlpha;
|
|
787
|
+
delete processed.dropShadowBlur;
|
|
788
|
+
// fill 数组 -> 取第一个值 (deprecated)
|
|
789
|
+
if (Array.isArray(processed.fill)) {
|
|
790
|
+
processed.fill = processed.fill[0];
|
|
791
|
+
}
|
|
792
|
+
// fillGradientStops -> FillGradient 对象
|
|
793
|
+
if (Array.isArray(processed.fillGradientStops)) {
|
|
794
|
+
let fontSize;
|
|
795
|
+
if (processed.fontSize == null) {
|
|
796
|
+
fontSize = pixi_js.TextStyle.defaultTextStyle.fontSize;
|
|
797
|
+
}
|
|
798
|
+
else if (typeof processed.fontSize === 'string') {
|
|
799
|
+
fontSize = parseInt(processed.fontSize, 10);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
fontSize = processed.fontSize;
|
|
803
|
+
}
|
|
804
|
+
const gradientFill = new pixi_js.FillGradient(0, 0, 0, fontSize * 1.7);
|
|
805
|
+
const fills = processed.fillGradientStops.map((color) => pixi_js.Color.shared.setValue(color).toNumber());
|
|
806
|
+
fills.forEach((number, index) => {
|
|
807
|
+
const ratio = index / (fills.length - 1);
|
|
808
|
+
gradientFill.addColorStop(ratio, number);
|
|
809
|
+
});
|
|
810
|
+
processed.fill = { fill: gradientFill };
|
|
811
|
+
delete processed.fillGradientStops;
|
|
812
|
+
}
|
|
813
|
+
return processed;
|
|
814
|
+
}
|
|
815
|
+
change(changed) {
|
|
816
|
+
const { text, component } = this.texts[changed.gameObject.id];
|
|
817
|
+
const isHTMLText = changed.componentName === 'HTMLText';
|
|
818
|
+
if (changed.prop.prop[0] === 'text') {
|
|
819
|
+
text.text = component.text;
|
|
820
|
+
}
|
|
821
|
+
else if (changed.prop.prop[0] === 'style') {
|
|
822
|
+
const processedStyle = this.processStyle(component.style);
|
|
823
|
+
Object.assign(text.style, processedStyle);
|
|
824
|
+
}
|
|
825
|
+
else if (changed.prop.prop[0] === 'textureStyle' && isHTMLText) {
|
|
826
|
+
// HTMLText 纹理样式变化需要重新创建
|
|
827
|
+
const htmlComponent = component;
|
|
828
|
+
const container = this.containerManager.getContainer(changed.gameObject.id);
|
|
829
|
+
const index = container.getChildIndex(text);
|
|
830
|
+
container.removeChild(text);
|
|
831
|
+
text.destroy({ children: true });
|
|
832
|
+
const newText = new rendererAdapter.HTMLText({
|
|
833
|
+
text: htmlComponent.text,
|
|
834
|
+
style: htmlComponent.style,
|
|
835
|
+
textureStyle: htmlComponent.textureStyle,
|
|
836
|
+
});
|
|
837
|
+
container.addChildAt(newText, index);
|
|
838
|
+
this.texts[changed.gameObject.id].text = newText;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
setSize(changed) {
|
|
842
|
+
const { transform } = changed.gameObject;
|
|
843
|
+
if (!transform)
|
|
844
|
+
return;
|
|
845
|
+
const { text } = this.texts[changed.gameObject.id];
|
|
846
|
+
const size = text.getSize();
|
|
847
|
+
transform.size.width = size.width;
|
|
848
|
+
transform.size.height = size.height;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
Text.systemName = 'Text';
|
|
852
|
+
Text = __decorate([
|
|
853
|
+
eva_js.decorators.componentObserver({
|
|
854
|
+
Text: ['text', { prop: ['style'], deep: true }],
|
|
855
|
+
HTMLText: ['text', { prop: ['style'], deep: true }, { prop: ['textureStyle'], deep: true }],
|
|
856
|
+
BitmapText: ['text', { prop: ['style'], deep: true }],
|
|
857
|
+
})
|
|
858
|
+
], Text);
|
|
859
|
+
var Text$1 = Text;
|
|
860
|
+
|
|
861
|
+
exports.BitmapText = BitmapText;
|
|
862
|
+
exports.HTMLText = HTMLText;
|
|
863
|
+
exports.Text = Text$2;
|
|
864
|
+
exports.TextSystem = Text$1;
|