@eva/plugin-ui 2.1.0-beta.1 → 2.1.0-beta.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/README.md +4 -4
- package/dist/EVA.plugin.ui.js +1470 -405
- package/dist/EVA.plugin.ui.min.js +1 -1
- package/dist/plugin-ui.cjs.js +1013 -128
- package/dist/plugin-ui.cjs.prod.js +1 -1
- package/dist/plugin-ui.d.ts +316 -66
- package/dist/plugin-ui.esm.js +1013 -130
- package/package.json +4 -4
package/dist/plugin-ui.cjs.js
CHANGED
|
@@ -7,26 +7,28 @@ var pluginRendererGraphics = require('@eva/plugin-renderer-graphics');
|
|
|
7
7
|
var pixi_js = require('pixi.js');
|
|
8
8
|
var ui = require('@pixi/ui');
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
exports.
|
|
12
|
-
(function (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})(exports.
|
|
10
|
+
/** Shape primitive type enum */
|
|
11
|
+
exports.ShapeType = void 0;
|
|
12
|
+
(function (ShapeType) {
|
|
13
|
+
ShapeType["RECT"] = "rect";
|
|
14
|
+
ShapeType["CIRCLE"] = "circle";
|
|
15
|
+
ShapeType["ELLIPSE"] = "ellipse";
|
|
16
|
+
ShapeType["ROUNDED_RECT"] = "roundedRect";
|
|
17
|
+
})(exports.ShapeType || (exports.ShapeType = {}));
|
|
18
|
+
/** Backward-compatible enum value alias for existing TypeScript consumers. */
|
|
19
|
+
const UIShapeType = exports.ShapeType;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* Shape 组件
|
|
20
22
|
*
|
|
21
23
|
* 基于 `@eva/plugin-renderer-graphics` 实现 rect/circle/ellipse/roundedRect 的
|
|
22
24
|
* 矢量绘制,支持纯色 / linear-gradient 填充与描边。`shapes` 数组允许在同一个
|
|
23
25
|
* GameObject 上层叠多个形状。
|
|
24
26
|
*/
|
|
25
|
-
class
|
|
27
|
+
class Shape extends eva_js.Component {
|
|
26
28
|
constructor() {
|
|
27
29
|
super(...arguments);
|
|
28
30
|
/** 实例侧 componentName,DSL 序列化时使用 */
|
|
29
|
-
this.componentName = '
|
|
31
|
+
this.componentName = 'Shape';
|
|
30
32
|
this.shapes = [];
|
|
31
33
|
}
|
|
32
34
|
/** 编辑器 Inspector 元数据,主仓 ComponentInspector 通过静态方法读取 */
|
|
@@ -43,7 +45,7 @@ class UI extends eva_js.Component {
|
|
|
43
45
|
{ name: 'radius', type: 'number', isArray: false },
|
|
44
46
|
];
|
|
45
47
|
return {
|
|
46
|
-
name:
|
|
48
|
+
name: Shape.componentName,
|
|
47
49
|
type: 'object',
|
|
48
50
|
isArray: false,
|
|
49
51
|
isFolder: true,
|
|
@@ -176,12 +178,12 @@ class UI extends eva_js.Component {
|
|
|
176
178
|
const x = style.x || 0;
|
|
177
179
|
const y = style.y || 0;
|
|
178
180
|
switch (type) {
|
|
179
|
-
case exports.
|
|
180
|
-
case exports.
|
|
181
|
+
case exports.ShapeType.RECT:
|
|
182
|
+
case exports.ShapeType.ROUNDED_RECT:
|
|
181
183
|
return { width: style.width, height: style.height, x, y };
|
|
182
|
-
case exports.
|
|
184
|
+
case exports.ShapeType.CIRCLE:
|
|
183
185
|
return { width: style.radius * 2, height: style.radius * 2, x, y };
|
|
184
|
-
case exports.
|
|
186
|
+
case exports.ShapeType.ELLIPSE:
|
|
185
187
|
return { width: style.width, height: style.height, x, y };
|
|
186
188
|
default:
|
|
187
189
|
return { width: 100, height: 100, x, y };
|
|
@@ -207,32 +209,27 @@ class UI extends eva_js.Component {
|
|
|
207
209
|
}
|
|
208
210
|
/** 绘制单个形状 */
|
|
209
211
|
drawShape(graphics, type, style) {
|
|
212
|
+
var _a;
|
|
210
213
|
if (style.alpha !== undefined) {
|
|
211
214
|
graphics.alpha = style.alpha;
|
|
212
215
|
}
|
|
213
|
-
if (style.stroke && style.lineWidth !== undefined) {
|
|
214
|
-
graphics.setStrokeStyle({ color: style.stroke, width: style.lineWidth });
|
|
215
|
-
}
|
|
216
|
-
else if (style.stroke) {
|
|
217
|
-
graphics.setStrokeStyle({ color: style.stroke, width: 1 });
|
|
218
|
-
}
|
|
219
216
|
switch (type) {
|
|
220
|
-
case exports.
|
|
217
|
+
case exports.ShapeType.RECT:
|
|
221
218
|
this.drawRect(graphics, style);
|
|
222
219
|
break;
|
|
223
|
-
case exports.
|
|
220
|
+
case exports.ShapeType.CIRCLE:
|
|
224
221
|
this.drawCircle(graphics, style);
|
|
225
222
|
break;
|
|
226
|
-
case exports.
|
|
223
|
+
case exports.ShapeType.ELLIPSE:
|
|
227
224
|
this.drawEllipse(graphics, style);
|
|
228
225
|
break;
|
|
229
|
-
case exports.
|
|
226
|
+
case exports.ShapeType.ROUNDED_RECT:
|
|
230
227
|
this.drawRoundedRect(graphics, style);
|
|
231
228
|
break;
|
|
232
229
|
default:
|
|
233
230
|
console.warn(`Unknown shape type: ${type}`);
|
|
234
231
|
}
|
|
235
|
-
if (style.fill) {
|
|
232
|
+
if (style.fill !== undefined) {
|
|
236
233
|
if (typeof style.fill === 'string' && style.fill.includes('linear-gradient')) {
|
|
237
234
|
const gradientInfo = this.parseLinearGradient(style.fill);
|
|
238
235
|
if (gradientInfo) {
|
|
@@ -249,6 +246,12 @@ class UI extends eva_js.Component {
|
|
|
249
246
|
graphics.fill(style.fill);
|
|
250
247
|
}
|
|
251
248
|
}
|
|
249
|
+
if (style.stroke !== undefined) {
|
|
250
|
+
graphics.stroke({
|
|
251
|
+
color: style.stroke,
|
|
252
|
+
width: (_a = style.lineWidth) !== null && _a !== void 0 ? _a : 1,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
252
255
|
}
|
|
253
256
|
drawRect(graphics, style) {
|
|
254
257
|
const x = style.x || 0;
|
|
@@ -330,7 +333,7 @@ class UI extends eva_js.Component {
|
|
|
330
333
|
}
|
|
331
334
|
}
|
|
332
335
|
/** 组件名称 */
|
|
333
|
-
|
|
336
|
+
Shape.componentName = 'Shape';
|
|
334
337
|
|
|
335
338
|
/**
|
|
336
339
|
* Eva GameObject -> PIXI.Container resolver.
|
|
@@ -454,7 +457,7 @@ function whenContainerReady(game, go, fn, attempts = 4) {
|
|
|
454
457
|
* @returns PIXI 显示对象,失败返回 null
|
|
455
458
|
*/
|
|
456
459
|
function resolveViewRef(game, go, ref) {
|
|
457
|
-
var _a;
|
|
460
|
+
var _a, _b;
|
|
458
461
|
if (!ref)
|
|
459
462
|
return null;
|
|
460
463
|
if ('entityName' in ref) {
|
|
@@ -469,15 +472,18 @@ function resolveViewRef(game, go, ref) {
|
|
|
469
472
|
}
|
|
470
473
|
}
|
|
471
474
|
catch (_) { }
|
|
472
|
-
return childContainer;
|
|
475
|
+
return wrapBorrowedEntityView(childContainer, child.name);
|
|
473
476
|
}
|
|
474
477
|
}
|
|
475
478
|
if (ref.fallback)
|
|
476
479
|
return resolveViewRef(game, go, ref.fallback);
|
|
477
480
|
return null;
|
|
478
481
|
}
|
|
482
|
+
if ('shape' in ref) {
|
|
483
|
+
return (_a = drawInlineShape(ref.shape)) !== null && _a !== void 0 ? _a : (ref.fallback ? resolveViewRef(game, go, ref.fallback) : null);
|
|
484
|
+
}
|
|
479
485
|
if ('ui' in ref) {
|
|
480
|
-
return (
|
|
486
|
+
return (_b = drawInlineShape(ref.ui)) !== null && _b !== void 0 ? _b : (ref.fallback ? resolveViewRef(game, go, ref.fallback) : null);
|
|
481
487
|
}
|
|
482
488
|
if ('texture' in ref) {
|
|
483
489
|
const tex = resolveTexture(game, ref.texture);
|
|
@@ -506,9 +512,15 @@ function resolveViewRef(game, go, ref) {
|
|
|
506
512
|
}
|
|
507
513
|
return null;
|
|
508
514
|
}
|
|
515
|
+
function wrapBorrowedEntityView(childContainer, childName) {
|
|
516
|
+
const wrapper = new pixi_js.Container();
|
|
517
|
+
wrapper.label = childName ? `${childName}:view-ref` : 'plugin-ui-view-ref';
|
|
518
|
+
wrapper.addChild(childContainer);
|
|
519
|
+
return wrapper;
|
|
520
|
+
}
|
|
509
521
|
/** 把 ViewRef 解析为已存在的 Texture(用于 ProgressBar/Slider/Input 的 nineSlice 路径) */
|
|
510
522
|
function resolveTexture(game, key) {
|
|
511
|
-
var _a, _b;
|
|
523
|
+
var _a, _b, _c;
|
|
512
524
|
// 1) Eva resource pool
|
|
513
525
|
const resourceModule = (_a = game === null || game === void 0 ? void 0 : game.resource) !== null && _a !== void 0 ? _a : null;
|
|
514
526
|
if ((_b = resourceModule === null || resourceModule === void 0 ? void 0 : resourceModule.instances) === null || _b === void 0 ? void 0 : _b[key]) {
|
|
@@ -520,7 +532,7 @@ function resolveTexture(game, key) {
|
|
|
520
532
|
}
|
|
521
533
|
// 2) global asset cache (Texture.from)
|
|
522
534
|
try {
|
|
523
|
-
return pixi_js.Texture.from(key);
|
|
535
|
+
return (_c = pixi_js.Texture.from(key)) !== null && _c !== void 0 ? _c : null;
|
|
524
536
|
}
|
|
525
537
|
catch (_) {
|
|
526
538
|
return null;
|
|
@@ -552,11 +564,20 @@ function drawInlineShape(shape) {
|
|
|
552
564
|
if (style.fill !== undefined)
|
|
553
565
|
g.fill(style.fill);
|
|
554
566
|
if (style.stroke !== undefined && style.lineWidth !== undefined) {
|
|
555
|
-
g.
|
|
556
|
-
|
|
567
|
+
g.stroke({ color: style.stroke, width: style.lineWidth });
|
|
568
|
+
}
|
|
569
|
+
else if (style.stroke !== undefined) {
|
|
570
|
+
g.stroke({ color: style.stroke, width: 1 });
|
|
557
571
|
}
|
|
558
572
|
if (style.alpha !== undefined)
|
|
559
573
|
g.alpha = style.alpha;
|
|
574
|
+
try {
|
|
575
|
+
Object.defineProperty(g, 'clone', {
|
|
576
|
+
value: () => { var _a; return (_a = drawInlineShape(shape)) !== null && _a !== void 0 ? _a : new pixi_js.Graphics(); },
|
|
577
|
+
configurable: true,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
catch (_) { }
|
|
560
581
|
return g;
|
|
561
582
|
}
|
|
562
583
|
/**
|
|
@@ -609,12 +630,20 @@ class PixiUiComponent extends eva_js.Component {
|
|
|
609
630
|
/** runtime 计数,供 spec / debug 验证(toggleCount / pressCount / hoverCount / ...)*/
|
|
610
631
|
this.toggleCount = 0;
|
|
611
632
|
this.pressCount = 0;
|
|
633
|
+
this.downCount = 0;
|
|
634
|
+
this.upCount = 0;
|
|
612
635
|
this.hoverCount = 0;
|
|
636
|
+
this.outCount = 0;
|
|
637
|
+
this.upOutCount = 0;
|
|
613
638
|
this.changeCount = 0;
|
|
614
639
|
this.updateCount = 0;
|
|
615
640
|
this.selectCount = 0;
|
|
641
|
+
this.lastSignal = 'idle';
|
|
642
|
+
this.visualState = 'default';
|
|
616
643
|
/** Input 私有 focused */
|
|
617
644
|
this.focused = false;
|
|
645
|
+
/** DSL/constructor 中显式传入过的字段,用于区分 metadata default 与用户配置。 */
|
|
646
|
+
this.__evaExplicitFields = new Set();
|
|
618
647
|
}
|
|
619
648
|
init(p) {
|
|
620
649
|
if (p)
|
|
@@ -634,6 +663,7 @@ class PixiUiComponent extends eva_js.Component {
|
|
|
634
663
|
const v = p[name];
|
|
635
664
|
if (v === undefined)
|
|
636
665
|
continue;
|
|
666
|
+
this.__evaExplicitFields.add(name);
|
|
637
667
|
switch (spec.kind) {
|
|
638
668
|
case 'scalar':
|
|
639
669
|
this[name] = v;
|
|
@@ -754,6 +784,114 @@ function resolveViewsBySchema(game, go, component, schema) {
|
|
|
754
784
|
}
|
|
755
785
|
}
|
|
756
786
|
|
|
787
|
+
function readTransformRenderSize(go, options = {}) {
|
|
788
|
+
var _a;
|
|
789
|
+
const size = (_a = go === null || go === void 0 ? void 0 : go.transform) === null || _a === void 0 ? void 0 : _a.size;
|
|
790
|
+
if (!size)
|
|
791
|
+
return null;
|
|
792
|
+
const width = normalizeSizeValue(size.width, options.allowZero);
|
|
793
|
+
const height = normalizeSizeValue(size.height, options.allowZero);
|
|
794
|
+
if (width === undefined && height === undefined)
|
|
795
|
+
return null;
|
|
796
|
+
return { width, height };
|
|
797
|
+
}
|
|
798
|
+
function hasExplicitRenderSize(component) {
|
|
799
|
+
if (!component)
|
|
800
|
+
return false;
|
|
801
|
+
const explicitFields = component.__evaExplicitFields;
|
|
802
|
+
if (explicitFields && typeof explicitFields.has === 'function') {
|
|
803
|
+
return explicitFields.has('width') || explicitFields.has('height');
|
|
804
|
+
}
|
|
805
|
+
return component.width !== undefined || component.height !== undefined;
|
|
806
|
+
}
|
|
807
|
+
function applyTransformSizeToInstance(def, instance, component, go, source) {
|
|
808
|
+
const size = readTransformRenderSize(go, { allowZero: source === 'transform-change' });
|
|
809
|
+
if (!size)
|
|
810
|
+
return false;
|
|
811
|
+
const context = {
|
|
812
|
+
componentName: def.name,
|
|
813
|
+
component,
|
|
814
|
+
gameObject: go,
|
|
815
|
+
source,
|
|
816
|
+
};
|
|
817
|
+
if (def.applySize)
|
|
818
|
+
def.applySize(instance, size, component !== null && component !== void 0 ? component : {}, context);
|
|
819
|
+
else
|
|
820
|
+
applyRuntimeSize(instance, size);
|
|
821
|
+
return true;
|
|
822
|
+
}
|
|
823
|
+
function applyRuntimeSize(instance, size) {
|
|
824
|
+
if (!instance || !size)
|
|
825
|
+
return;
|
|
826
|
+
const width = normalizeSizeValue(size.width, true);
|
|
827
|
+
const height = normalizeSizeValue(size.height, true);
|
|
828
|
+
if (width === undefined && height === undefined)
|
|
829
|
+
return;
|
|
830
|
+
const nextWidth = width !== null && width !== void 0 ? width : getCurrentSize(instance, 'width');
|
|
831
|
+
const nextHeight = height !== null && height !== void 0 ? height : getCurrentSize(instance, 'height');
|
|
832
|
+
let applied = false;
|
|
833
|
+
if (typeof instance.setSize === 'function' && nextWidth !== undefined && nextHeight !== undefined) {
|
|
834
|
+
try {
|
|
835
|
+
instance.setSize(nextWidth, nextHeight);
|
|
836
|
+
applied = true;
|
|
837
|
+
}
|
|
838
|
+
catch (_) {
|
|
839
|
+
applied = false;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
if (!applied) {
|
|
843
|
+
if (width !== undefined)
|
|
844
|
+
instance.width = width;
|
|
845
|
+
if (height !== undefined)
|
|
846
|
+
instance.height = height;
|
|
847
|
+
}
|
|
848
|
+
relayoutRuntimeInstance(instance);
|
|
849
|
+
}
|
|
850
|
+
function applyListLayoutSize(instance, size) {
|
|
851
|
+
const width = normalizeSizeValue(size.width, true);
|
|
852
|
+
const height = normalizeSizeValue(size.height, true);
|
|
853
|
+
if (width !== undefined) {
|
|
854
|
+
try {
|
|
855
|
+
instance.maxWidth = width;
|
|
856
|
+
}
|
|
857
|
+
catch (_) { }
|
|
858
|
+
}
|
|
859
|
+
if (height !== undefined) {
|
|
860
|
+
try {
|
|
861
|
+
instance.maxHeight = height;
|
|
862
|
+
}
|
|
863
|
+
catch (_) { }
|
|
864
|
+
}
|
|
865
|
+
relayoutRuntimeInstance(instance);
|
|
866
|
+
}
|
|
867
|
+
function relayoutRuntimeInstance(instance) {
|
|
868
|
+
var _a, _b, _c, _d;
|
|
869
|
+
try {
|
|
870
|
+
(_b = (_a = instance === null || instance === void 0 ? void 0 : instance.list) === null || _a === void 0 ? void 0 : _a.arrangeChildren) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
871
|
+
}
|
|
872
|
+
catch (_) { }
|
|
873
|
+
try {
|
|
874
|
+
(_c = instance === null || instance === void 0 ? void 0 : instance.arrangeChildren) === null || _c === void 0 ? void 0 : _c.call(instance);
|
|
875
|
+
}
|
|
876
|
+
catch (_) { }
|
|
877
|
+
try {
|
|
878
|
+
(_d = instance === null || instance === void 0 ? void 0 : instance.resize) === null || _d === void 0 ? void 0 : _d.call(instance, true);
|
|
879
|
+
}
|
|
880
|
+
catch (_) { }
|
|
881
|
+
}
|
|
882
|
+
function normalizeSizeValue(value, allowZero = false) {
|
|
883
|
+
const n = Number(value);
|
|
884
|
+
if (!Number.isFinite(n))
|
|
885
|
+
return undefined;
|
|
886
|
+
if (allowZero ? n < 0 : n <= 0)
|
|
887
|
+
return undefined;
|
|
888
|
+
return n;
|
|
889
|
+
}
|
|
890
|
+
function getCurrentSize(instance, key) {
|
|
891
|
+
const n = Number(instance === null || instance === void 0 ? void 0 : instance[key]);
|
|
892
|
+
return Number.isFinite(n) && n >= 0 ? n : undefined;
|
|
893
|
+
}
|
|
894
|
+
|
|
757
895
|
/**
|
|
758
896
|
* @pixi/ui v2.x 包装层 — 14 个 ECS Component 由 metadata 驱动生成。
|
|
759
897
|
*
|
|
@@ -801,8 +939,42 @@ const BUTTON_DEF = {
|
|
|
801
939
|
optionsBuilder: (_c, v) => [v.single],
|
|
802
940
|
postCreate: (inst, c) => { inst.enabled = c.enabled; },
|
|
803
941
|
signalMap: (c) => ({
|
|
804
|
-
press: () => {
|
|
805
|
-
|
|
942
|
+
press: () => {
|
|
943
|
+
c.pressCount += 1;
|
|
944
|
+
c.lastSignal = 'press';
|
|
945
|
+
c.visualState = 'default';
|
|
946
|
+
return { pressCount: c.pressCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
947
|
+
},
|
|
948
|
+
down: () => {
|
|
949
|
+
c.downCount += 1;
|
|
950
|
+
c.lastSignal = 'down';
|
|
951
|
+
c.visualState = 'pressed';
|
|
952
|
+
return { downCount: c.downCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
953
|
+
},
|
|
954
|
+
up: () => {
|
|
955
|
+
c.upCount += 1;
|
|
956
|
+
c.lastSignal = 'up';
|
|
957
|
+
c.visualState = 'default';
|
|
958
|
+
return { upCount: c.upCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
959
|
+
},
|
|
960
|
+
hover: () => {
|
|
961
|
+
c.hoverCount += 1;
|
|
962
|
+
c.lastSignal = 'hover';
|
|
963
|
+
c.visualState = 'hover';
|
|
964
|
+
return { hoverCount: c.hoverCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
965
|
+
},
|
|
966
|
+
out: () => {
|
|
967
|
+
c.outCount += 1;
|
|
968
|
+
c.lastSignal = 'out';
|
|
969
|
+
c.visualState = 'default';
|
|
970
|
+
return { outCount: c.outCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
971
|
+
},
|
|
972
|
+
upOut: () => {
|
|
973
|
+
c.upOutCount += 1;
|
|
974
|
+
c.lastSignal = 'upOut';
|
|
975
|
+
c.visualState = 'default';
|
|
976
|
+
return { upOutCount: c.upOutCount, lastSignal: c.lastSignal, visualState: c.visualState };
|
|
977
|
+
},
|
|
806
978
|
}),
|
|
807
979
|
syncOnChange: (inst, c) => { inst.enabled = c.enabled; },
|
|
808
980
|
};
|
|
@@ -820,10 +992,28 @@ const FANCY_BUTTON_DEF = {
|
|
|
820
992
|
views: { kind: 'shallowMerge', default: {}, inspector: { name: 'views', type: 'object', isFolder: true, children: [
|
|
821
993
|
{ name: 'default', type: 'object' }, { name: 'hover', type: 'object' },
|
|
822
994
|
{ name: 'pressed', type: 'object' }, { name: 'disabled', type: 'object' },
|
|
995
|
+
{ name: 'icon', type: 'object' },
|
|
823
996
|
] } },
|
|
824
997
|
offset: { kind: 'shallowMerge', default: {} },
|
|
825
998
|
textOffset: { kind: 'shallowMerge', default: {} },
|
|
999
|
+
iconOffset: { kind: 'shallowMerge', default: {} },
|
|
826
1000
|
nineSliceSprite: { kind: 'opaque' },
|
|
1001
|
+
textStyle: { kind: 'shallowMerge', default: {} },
|
|
1002
|
+
textClass: { kind: 'scalar', default: 'text' },
|
|
1003
|
+
bitmapFontName: { kind: 'scalar', default: 'TitleFont' },
|
|
1004
|
+
defaultTextScale: { kind: 'opaque' },
|
|
1005
|
+
defaultIconScale: { kind: 'opaque' },
|
|
1006
|
+
defaultTextAnchor: { kind: 'opaque' },
|
|
1007
|
+
defaultIconAnchor: { kind: 'opaque' },
|
|
1008
|
+
anchor: { kind: 'scalar' },
|
|
1009
|
+
anchorX: { kind: 'scalar' },
|
|
1010
|
+
anchorY: { kind: 'scalar' },
|
|
1011
|
+
scale: { kind: 'scalar' },
|
|
1012
|
+
animations: { kind: 'opaque' },
|
|
1013
|
+
contentFittingMode: { kind: 'scalar' },
|
|
1014
|
+
ignoreRefitting: { kind: 'scalar' },
|
|
1015
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1016
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
827
1017
|
},
|
|
828
1018
|
views: {
|
|
829
1019
|
kind: 'object', folder: 'views',
|
|
@@ -832,28 +1022,43 @@ const FANCY_BUTTON_DEF = {
|
|
|
832
1022
|
{ name: 'hover', required: false },
|
|
833
1023
|
{ name: 'pressed', required: false },
|
|
834
1024
|
{ name: 'disabled', required: false },
|
|
1025
|
+
{ name: 'icon', required: false },
|
|
835
1026
|
],
|
|
836
1027
|
},
|
|
837
1028
|
optionsBuilder: (c, v) => {
|
|
838
|
-
var _a, _b, _d, _e;
|
|
1029
|
+
var _a, _b, _d, _e, _f;
|
|
839
1030
|
// FancyButton 内部 updateView 不接受 null;只把已 resolve 的 view 字段传过去
|
|
840
1031
|
const opts = {
|
|
841
|
-
text: c
|
|
842
|
-
offset: c.offset, textOffset: c.textOffset,
|
|
1032
|
+
text: makeFancyButtonText(c), padding: c.padding,
|
|
1033
|
+
offset: c.offset, textOffset: c.textOffset, iconOffset: c.iconOffset,
|
|
843
1034
|
nineSliceSprite: c.nineSliceSprite,
|
|
1035
|
+
defaultTextScale: c.defaultTextScale,
|
|
1036
|
+
defaultIconScale: c.defaultIconScale,
|
|
1037
|
+
defaultTextAnchor: c.defaultTextAnchor,
|
|
1038
|
+
defaultIconAnchor: c.defaultIconAnchor,
|
|
1039
|
+
anchor: c.anchor, anchorX: c.anchorX, anchorY: c.anchorY,
|
|
1040
|
+
scale: c.scale, animations: c.animations,
|
|
1041
|
+
contentFittingMode: c.contentFittingMode,
|
|
1042
|
+
ignoreRefitting: c.ignoreRefitting,
|
|
844
1043
|
};
|
|
845
1044
|
if ((_a = v.object) === null || _a === void 0 ? void 0 : _a.default)
|
|
846
|
-
opts.defaultView = v.object.default;
|
|
1045
|
+
opts.defaultView = getFancyButtonView(c, 'default', v.object.default);
|
|
847
1046
|
if ((_b = v.object) === null || _b === void 0 ? void 0 : _b.hover)
|
|
848
|
-
opts.hoverView = v.object.hover;
|
|
1047
|
+
opts.hoverView = getFancyButtonView(c, 'hover', v.object.hover);
|
|
849
1048
|
if ((_d = v.object) === null || _d === void 0 ? void 0 : _d.pressed)
|
|
850
|
-
opts.pressedView = v.object.pressed;
|
|
1049
|
+
opts.pressedView = getFancyButtonView(c, 'pressed', v.object.pressed);
|
|
851
1050
|
if ((_e = v.object) === null || _e === void 0 ? void 0 : _e.disabled)
|
|
852
|
-
opts.disabledView = v.object.disabled;
|
|
1051
|
+
opts.disabledView = getFancyButtonView(c, 'disabled', v.object.disabled);
|
|
1052
|
+
if ((_f = v.object) === null || _f === void 0 ? void 0 : _f.icon)
|
|
1053
|
+
opts.icon = v.object.icon;
|
|
853
1054
|
return opts;
|
|
854
1055
|
},
|
|
855
1056
|
postCreate: (inst, c) => {
|
|
856
1057
|
inst.enabled = c.enabled;
|
|
1058
|
+
if (c.state && typeof inst.setState === 'function')
|
|
1059
|
+
inst.setState(c.state, true);
|
|
1060
|
+
applyFancyButtonAnchor(inst, c);
|
|
1061
|
+
applyOptionalSize(inst, c);
|
|
857
1062
|
if (c.selected)
|
|
858
1063
|
applySelectedTint(inst, c);
|
|
859
1064
|
},
|
|
@@ -868,9 +1073,84 @@ const FANCY_BUTTON_DEF = {
|
|
|
868
1073
|
inst.text = c.text;
|
|
869
1074
|
if (c.padding !== undefined && inst.padding !== c.padding)
|
|
870
1075
|
inst.padding = c.padding;
|
|
1076
|
+
if (c.textOffset !== undefined)
|
|
1077
|
+
inst.textOffset = c.textOffset;
|
|
1078
|
+
if (c.iconOffset !== undefined)
|
|
1079
|
+
inst.iconOffset = c.iconOffset;
|
|
1080
|
+
if (c.defaultTextScale !== undefined)
|
|
1081
|
+
inst.defaultTextScale = c.defaultTextScale;
|
|
1082
|
+
if (c.defaultIconScale !== undefined)
|
|
1083
|
+
inst.defaultIconScale = c.defaultIconScale;
|
|
1084
|
+
if (c.defaultTextAnchor !== undefined)
|
|
1085
|
+
inst.defaultTextAnchor = c.defaultTextAnchor;
|
|
1086
|
+
if (c.defaultIconAnchor !== undefined)
|
|
1087
|
+
inst.defaultIconAnchor = c.defaultIconAnchor;
|
|
1088
|
+
if (c.contentFittingMode !== undefined)
|
|
1089
|
+
inst.contentFittingMode = c.contentFittingMode;
|
|
1090
|
+
if (c.ignoreRefitting !== undefined && inst.options)
|
|
1091
|
+
inst.options.ignoreRefitting = c.ignoreRefitting;
|
|
1092
|
+
if (c.state && typeof inst.setState === 'function')
|
|
1093
|
+
inst.setState(c.state, true);
|
|
1094
|
+
applyFancyButtonAnchor(inst, c);
|
|
1095
|
+
applyOptionalSize(inst, c);
|
|
871
1096
|
applySelectedTint(inst, c);
|
|
872
1097
|
},
|
|
873
1098
|
};
|
|
1099
|
+
function applyFancyButtonAnchor(inst, c) {
|
|
1100
|
+
var _a, _b, _d, _e, _f, _g, _h;
|
|
1101
|
+
const hasAnchor = c.anchor !== undefined || c.anchorX !== undefined || c.anchorY !== undefined;
|
|
1102
|
+
if (!hasAnchor || !((_a = inst === null || inst === void 0 ? void 0 : inst.anchor) === null || _a === void 0 ? void 0 : _a.set))
|
|
1103
|
+
return;
|
|
1104
|
+
const x = (_e = (_d = (_b = c.anchorX) !== null && _b !== void 0 ? _b : c.anchor) !== null && _d !== void 0 ? _d : inst.anchor.x) !== null && _e !== void 0 ? _e : 0;
|
|
1105
|
+
const y = (_h = (_g = (_f = c.anchorY) !== null && _f !== void 0 ? _f : c.anchor) !== null && _g !== void 0 ? _g : inst.anchor.y) !== null && _h !== void 0 ? _h : 0;
|
|
1106
|
+
try {
|
|
1107
|
+
inst.anchor.set(x, y);
|
|
1108
|
+
}
|
|
1109
|
+
catch (_) { }
|
|
1110
|
+
}
|
|
1111
|
+
function makeFancyButtonText(c) {
|
|
1112
|
+
var _a, _b, _d;
|
|
1113
|
+
if (c.text === undefined)
|
|
1114
|
+
return undefined;
|
|
1115
|
+
const text = String(c.text);
|
|
1116
|
+
if (c.textClass === 'html') {
|
|
1117
|
+
return new pixi_js.HTMLText({ text, style: c.textStyle });
|
|
1118
|
+
}
|
|
1119
|
+
if (c.textClass === 'bitmap') {
|
|
1120
|
+
const fontFamily = (_a = c.bitmapFontName) !== null && _a !== void 0 ? _a : 'TitleFont';
|
|
1121
|
+
ensureBitmapFont(fontFamily, c.textStyle);
|
|
1122
|
+
return new pixi_js.BitmapText({
|
|
1123
|
+
text,
|
|
1124
|
+
style: {
|
|
1125
|
+
fontFamily,
|
|
1126
|
+
fontSize: (_d = (_b = c.textStyle) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _d !== void 0 ? _d : 40,
|
|
1127
|
+
},
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
if (c.textStyle && Object.keys(c.textStyle).length > 0) {
|
|
1131
|
+
return new pixi_js.Text({ text, style: c.textStyle });
|
|
1132
|
+
}
|
|
1133
|
+
return c.text;
|
|
1134
|
+
}
|
|
1135
|
+
const installedBitmapFonts = new Set();
|
|
1136
|
+
function ensureBitmapFont(name, style) {
|
|
1137
|
+
if (installedBitmapFonts.has(name))
|
|
1138
|
+
return;
|
|
1139
|
+
try {
|
|
1140
|
+
pixi_js.BitmapFontManager.install({ name, style: (style !== null && style !== void 0 ? style : {}) });
|
|
1141
|
+
}
|
|
1142
|
+
catch (_) {
|
|
1143
|
+
// Reinstalling an existing font can throw in Pixi; rendering can still use the current font.
|
|
1144
|
+
}
|
|
1145
|
+
installedBitmapFonts.add(name);
|
|
1146
|
+
}
|
|
1147
|
+
function getFancyButtonView(c, key, resolved) {
|
|
1148
|
+
var _a;
|
|
1149
|
+
const ref = (_a = c.views) === null || _a === void 0 ? void 0 : _a[key];
|
|
1150
|
+
if (c.nineSliceSprite && ref && 'texture' in ref)
|
|
1151
|
+
return getTextureView(ref.texture);
|
|
1152
|
+
return resolved;
|
|
1153
|
+
}
|
|
874
1154
|
function applySelectedTint(inst, c) {
|
|
875
1155
|
try {
|
|
876
1156
|
const dv = inst.defaultView;
|
|
@@ -879,6 +1159,22 @@ function applySelectedTint(inst, c) {
|
|
|
879
1159
|
}
|
|
880
1160
|
catch (_) { }
|
|
881
1161
|
}
|
|
1162
|
+
function syncCheckBoxTextStyle(inst, c) {
|
|
1163
|
+
var _a, _b, _d;
|
|
1164
|
+
const style = inst.style;
|
|
1165
|
+
if (!style || (!c.textStyle && !c.textOffset))
|
|
1166
|
+
return;
|
|
1167
|
+
const nextStyle = Object.assign(Object.assign({}, style), { text: (_a = c.textStyle) !== null && _a !== void 0 ? _a : style.text, textOffset: (_b = c.textOffset) !== null && _b !== void 0 ? _b : style.textOffset });
|
|
1168
|
+
// @pixi/ui CheckBox.style rebuilds checked/unchecked views. If RadioGroup is
|
|
1169
|
+
// listening, that rebuild can emit onChange while only one view exists.
|
|
1170
|
+
inst._style = nextStyle;
|
|
1171
|
+
if (inst.labelText && c.textStyle)
|
|
1172
|
+
inst.labelText.style = c.textStyle;
|
|
1173
|
+
try {
|
|
1174
|
+
(_d = inst.alignText) === null || _d === void 0 ? void 0 : _d.call(inst);
|
|
1175
|
+
}
|
|
1176
|
+
catch (_) { }
|
|
1177
|
+
}
|
|
882
1178
|
const CHECKBOX_DEF = {
|
|
883
1179
|
name: 'CheckBox',
|
|
884
1180
|
signalPrefix: 'checkbox',
|
|
@@ -891,6 +1187,8 @@ const CHECKBOX_DEF = {
|
|
|
891
1187
|
views: { kind: 'shallowMerge', default: {}, inspector: { name: 'views', type: 'object', isFolder: true, children: [
|
|
892
1188
|
{ name: 'checked', type: 'object' }, { name: 'unchecked', type: 'object' },
|
|
893
1189
|
] } },
|
|
1190
|
+
textStyle: { kind: 'shallowMerge', default: { fill: 0xffffff } },
|
|
1191
|
+
textOffset: { kind: 'shallowMerge', default: {} },
|
|
894
1192
|
disabledStyle: { kind: 'shallowMerge', default: { alpha: 0.4, scale: 1 } },
|
|
895
1193
|
},
|
|
896
1194
|
views: {
|
|
@@ -901,7 +1199,7 @@ const CHECKBOX_DEF = {
|
|
|
901
1199
|
],
|
|
902
1200
|
},
|
|
903
1201
|
optionsBuilder: (c, v) => ({
|
|
904
|
-
style: { checked: v.object.checked, unchecked: v.object.unchecked },
|
|
1202
|
+
style: { checked: v.object.checked, unchecked: v.object.unchecked, text: c.textStyle, textOffset: c.textOffset },
|
|
905
1203
|
text: c.text, checked: c.checked,
|
|
906
1204
|
}),
|
|
907
1205
|
signalMap: (c) => ({
|
|
@@ -910,6 +1208,9 @@ const CHECKBOX_DEF = {
|
|
|
910
1208
|
syncOnChange: (inst, c) => {
|
|
911
1209
|
if (inst.checked !== c.checked)
|
|
912
1210
|
inst.checked = c.checked;
|
|
1211
|
+
if (c.text !== undefined && inst.text !== c.text)
|
|
1212
|
+
inst.text = c.text;
|
|
1213
|
+
syncCheckBoxTextStyle(inst, c);
|
|
913
1214
|
},
|
|
914
1215
|
};
|
|
915
1216
|
const SWITCHER_DEF = {
|
|
@@ -936,6 +1237,8 @@ const SWITCHER_DEF = {
|
|
|
936
1237
|
syncOnChange: (inst, c) => {
|
|
937
1238
|
if (inst.active !== c.active)
|
|
938
1239
|
inst.active = c.active;
|
|
1240
|
+
if (c.triggerEvent !== undefined)
|
|
1241
|
+
inst.triggerEvents = c.triggerEvent;
|
|
939
1242
|
},
|
|
940
1243
|
};
|
|
941
1244
|
const SLIDER_DEF = {
|
|
@@ -951,6 +1254,12 @@ const SLIDER_DEF = {
|
|
|
951
1254
|
orientation: { kind: 'scalar', default: 'horizontal', inspector: { name: 'orientation', type: 'string' } },
|
|
952
1255
|
showValue: { kind: 'scalar', default: false, inspector: { name: 'showValue', type: 'boolean' } },
|
|
953
1256
|
views: { kind: 'shallowMerge', default: {} },
|
|
1257
|
+
nineSliceSprite: { kind: 'opaque' },
|
|
1258
|
+
fillPaddings: { kind: 'shallowMerge', default: {} },
|
|
1259
|
+
valueTextStyle: { kind: 'shallowMerge', default: { fill: 0xffffff } },
|
|
1260
|
+
valueTextOffset: { kind: 'shallowMerge', default: {} },
|
|
1261
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1262
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
954
1263
|
bindToStore: BIND_STORE,
|
|
955
1264
|
},
|
|
956
1265
|
views: {
|
|
@@ -962,12 +1271,20 @@ const SLIDER_DEF = {
|
|
|
962
1271
|
],
|
|
963
1272
|
},
|
|
964
1273
|
optionsBuilder: (c, v) => {
|
|
965
|
-
|
|
1274
|
+
var _a, _b, _d;
|
|
1275
|
+
const bg = getSliderView((_a = c.views) === null || _a === void 0 ? void 0 : _a.bg, v.object.bg);
|
|
1276
|
+
const fill = getSliderView((_b = c.views) === null || _b === void 0 ? void 0 : _b.fill, v.object.fill);
|
|
1277
|
+
const thumb = getSliderView((_d = c.views) === null || _d === void 0 ? void 0 : _d.thumb, v.object.thumb);
|
|
966
1278
|
return {
|
|
967
|
-
bg
|
|
1279
|
+
bg, fill, slider: thumb,
|
|
968
1280
|
min: c.min, max: c.max, step: c.step, value: c.value, showValue: c.showValue,
|
|
1281
|
+
fillPaddings: c.fillPaddings,
|
|
1282
|
+
nineSliceSprite: c.nineSliceSprite,
|
|
1283
|
+
valueTextStyle: c.valueTextStyle,
|
|
1284
|
+
valueTextOffset: c.valueTextOffset,
|
|
969
1285
|
};
|
|
970
1286
|
},
|
|
1287
|
+
postCreate: (inst, c) => applyOptionalSize(inst, c),
|
|
971
1288
|
signalMap: (c) => ({
|
|
972
1289
|
update: (vv) => { c.value = vv; c.updateCount += 1; return { value: vv }; },
|
|
973
1290
|
change: (vv) => { c.value = vv; c.changeCount += 1; return { value: vv }; },
|
|
@@ -975,37 +1292,9 @@ const SLIDER_DEF = {
|
|
|
975
1292
|
syncOnChange: (inst, c) => {
|
|
976
1293
|
if (inst.value !== c.value)
|
|
977
1294
|
inst.value = c.value;
|
|
1295
|
+
applyOptionalSize(inst, c);
|
|
978
1296
|
},
|
|
979
1297
|
};
|
|
980
|
-
/**
|
|
981
|
-
* @pixi/ui Slider 的 update 逻辑:
|
|
982
|
-
* slider.x = (bg.width/100 * progress) - (slider.width / 2) // x 已居中
|
|
983
|
-
* slider.y = bg.height / 2 // y 未居中(bug)
|
|
984
|
-
*
|
|
985
|
-
* 因 y 维度 @pixi/ui 假设 thumb anchor / pivot 在中心(对 Sprite 自动 anchor.set(0.5),
|
|
986
|
-
* 但 Graphics 没 anchor),Graphics 渲染时左上角对齐 bg 中线,thumb 中心落到中线下方。
|
|
987
|
-
*
|
|
988
|
-
* 修法:只设 pivot.y = h/2 让 thumb 沿 y 居中。pivot.x 保持 0(x 在 update
|
|
989
|
-
* 里已用 -width/2 居中过,再设 pivot.x 会双倍偏移)。
|
|
990
|
-
*/
|
|
991
|
-
function centerThumbPivot(thumb) {
|
|
992
|
-
var _a, _b, _d, _e;
|
|
993
|
-
if (!thumb)
|
|
994
|
-
return;
|
|
995
|
-
if (thumb.anchor)
|
|
996
|
-
return; // Sprite — @pixi/ui 自己 anchor.set(0.5)
|
|
997
|
-
let h = 0;
|
|
998
|
-
try {
|
|
999
|
-
const b = (_a = thumb.getBounds) === null || _a === void 0 ? void 0 : _a.call(thumb);
|
|
1000
|
-
h = (_d = (_b = b === null || b === void 0 ? void 0 : b.height) !== null && _b !== void 0 ? _b : thumb.height) !== null && _d !== void 0 ? _d : 0;
|
|
1001
|
-
}
|
|
1002
|
-
catch (_) {
|
|
1003
|
-
h = (_e = thumb.height) !== null && _e !== void 0 ? _e : 0;
|
|
1004
|
-
}
|
|
1005
|
-
if (h > 0 && thumb.pivot) {
|
|
1006
|
-
thumb.pivot.set(0, h / 2);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
1298
|
const DOUBLE_SLIDER_DEF = {
|
|
1010
1299
|
name: 'DoubleSlider',
|
|
1011
1300
|
signalPrefix: 'doubleslider',
|
|
@@ -1019,6 +1308,12 @@ const DOUBLE_SLIDER_DEF = {
|
|
|
1019
1308
|
step: { kind: 'scalar', default: 1 },
|
|
1020
1309
|
showValue: { kind: 'scalar', default: false, inspector: { name: 'showValue', type: 'boolean' } },
|
|
1021
1310
|
views: { kind: 'shallowMerge', default: {} },
|
|
1311
|
+
nineSliceSprite: { kind: 'opaque' },
|
|
1312
|
+
fillPaddings: { kind: 'shallowMerge', default: {} },
|
|
1313
|
+
valueTextStyle: { kind: 'shallowMerge', default: { fill: 0xffffff } },
|
|
1314
|
+
valueTextOffset: { kind: 'shallowMerge', default: {} },
|
|
1315
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1316
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
1022
1317
|
bindToStore1: { kind: 'scalar' },
|
|
1023
1318
|
bindToStore2: { kind: 'scalar' },
|
|
1024
1319
|
},
|
|
@@ -1030,14 +1325,22 @@ const DOUBLE_SLIDER_DEF = {
|
|
|
1030
1325
|
],
|
|
1031
1326
|
},
|
|
1032
1327
|
optionsBuilder: (c, v) => {
|
|
1033
|
-
|
|
1034
|
-
|
|
1328
|
+
var _a, _b, _d, _e;
|
|
1329
|
+
const bg = getSliderView((_a = c.views) === null || _a === void 0 ? void 0 : _a.bg, v.object.bg);
|
|
1330
|
+
const fill = getSliderView((_b = c.views) === null || _b === void 0 ? void 0 : _b.fill, v.object.fill);
|
|
1331
|
+
const slider1 = getSliderView((_d = c.views) === null || _d === void 0 ? void 0 : _d.slider1, v.object.slider1);
|
|
1332
|
+
const slider2 = getSliderView((_e = c.views) === null || _e === void 0 ? void 0 : _e.slider2, v.object.slider2);
|
|
1035
1333
|
return {
|
|
1036
|
-
bg
|
|
1037
|
-
slider1
|
|
1038
|
-
min: c.min, max: c.max, value1: c.value1, value2: c.value2, showValue: c.showValue,
|
|
1334
|
+
bg, fill,
|
|
1335
|
+
slider1, slider2,
|
|
1336
|
+
min: c.min, max: c.max, step: c.step, value1: c.value1, value2: c.value2, showValue: c.showValue,
|
|
1337
|
+
fillPaddings: c.fillPaddings,
|
|
1338
|
+
nineSliceSprite: c.nineSliceSprite,
|
|
1339
|
+
valueTextStyle: c.valueTextStyle,
|
|
1340
|
+
valueTextOffset: c.valueTextOffset,
|
|
1039
1341
|
};
|
|
1040
1342
|
},
|
|
1343
|
+
postCreate: (inst, c) => applyOptionalSize(inst, c),
|
|
1041
1344
|
signalMap: (c) => ({
|
|
1042
1345
|
update: (v1, v2) => { c.value1 = v1; c.value2 = v2; c.updateCount += 1; return { value1: v1, value2: v2 }; },
|
|
1043
1346
|
change: (v1, v2) => { c.value1 = v1; c.value2 = v2; c.changeCount += 1; return { value1: v1, value2: v2 }; },
|
|
@@ -1047,6 +1350,7 @@ const DOUBLE_SLIDER_DEF = {
|
|
|
1047
1350
|
inst.value1 = c.value1;
|
|
1048
1351
|
if (inst.value2 !== c.value2)
|
|
1049
1352
|
inst.value2 = c.value2;
|
|
1353
|
+
applyOptionalSize(inst, c);
|
|
1050
1354
|
},
|
|
1051
1355
|
};
|
|
1052
1356
|
const PROGRESS_BAR_DEF = {
|
|
@@ -1060,6 +1364,8 @@ const PROGRESS_BAR_DEF = {
|
|
|
1060
1364
|
fillView: { kind: 'opaque' },
|
|
1061
1365
|
nineSliceSprite: { kind: 'opaque' },
|
|
1062
1366
|
fillPaddings: { kind: 'shallowMerge', default: {} },
|
|
1367
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1368
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
1063
1369
|
bindToStore: BIND_STORE,
|
|
1064
1370
|
},
|
|
1065
1371
|
views: {
|
|
@@ -1070,17 +1376,54 @@ const PROGRESS_BAR_DEF = {
|
|
|
1070
1376
|
// 这里用 inline resolution(在 system.ts handleGeneric 里有 fast path 处理 views=undefined 的情形,
|
|
1071
1377
|
// optionsBuilder 接受 raw component 自己 resolve)
|
|
1072
1378
|
optionsBuilder: (c, _v) => ({
|
|
1073
|
-
bg: c.
|
|
1379
|
+
bg: c.__resolved_bg_view, fill: c.__resolved_fill_view,
|
|
1074
1380
|
fillPaddings: c.fillPaddings,
|
|
1381
|
+
nineSliceSprite: c.nineSliceSprite,
|
|
1075
1382
|
progress: computeProgressPct(c),
|
|
1076
1383
|
}),
|
|
1384
|
+
postCreate: (inst, c) => applyOptionalSize(inst, c),
|
|
1077
1385
|
syncOnChange: (inst, c) => {
|
|
1078
1386
|
const pct = computeProgressPct(c);
|
|
1079
1387
|
if (inst.progress !== pct)
|
|
1080
1388
|
inst.progress = pct;
|
|
1389
|
+
applyOptionalSize(inst, c);
|
|
1081
1390
|
},
|
|
1082
1391
|
mixin: { getProgressPct: getProgressPctMixin },
|
|
1083
1392
|
};
|
|
1393
|
+
function getSliderView(ref, resolved) {
|
|
1394
|
+
if (ref && 'texture' in ref) {
|
|
1395
|
+
return getTextureView(ref.texture);
|
|
1396
|
+
}
|
|
1397
|
+
return resolved;
|
|
1398
|
+
}
|
|
1399
|
+
function getProgressView(ref, resolved, nineSliceSprite) {
|
|
1400
|
+
if (nineSliceSprite && ref && 'texture' in ref) {
|
|
1401
|
+
return getTextureView(ref.texture);
|
|
1402
|
+
}
|
|
1403
|
+
return resolved;
|
|
1404
|
+
}
|
|
1405
|
+
function getTextureView(textureKey) {
|
|
1406
|
+
var _a;
|
|
1407
|
+
return (_a = resolveTexture(undefined, textureKey)) !== null && _a !== void 0 ? _a : textureKey;
|
|
1408
|
+
}
|
|
1409
|
+
function applyOptionalSize(inst, c) {
|
|
1410
|
+
var _a, _b;
|
|
1411
|
+
if (c.width === undefined && c.height === undefined)
|
|
1412
|
+
return;
|
|
1413
|
+
const width = (_a = c.width) !== null && _a !== void 0 ? _a : inst.width;
|
|
1414
|
+
const height = (_b = c.height) !== null && _b !== void 0 ? _b : inst.height;
|
|
1415
|
+
if (typeof inst.setSize === 'function') {
|
|
1416
|
+
try {
|
|
1417
|
+
inst.setSize(width, height);
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
catch (_) { }
|
|
1421
|
+
}
|
|
1422
|
+
if (c.width !== undefined)
|
|
1423
|
+
inst.width = c.width;
|
|
1424
|
+
if (c.height !== undefined)
|
|
1425
|
+
inst.height = c.height;
|
|
1426
|
+
}
|
|
1084
1427
|
function computeProgressPct(c) {
|
|
1085
1428
|
const [min, max] = c.valueRange;
|
|
1086
1429
|
if (max <= min)
|
|
@@ -1102,21 +1445,36 @@ const CIRCULAR_PROGRESS_BAR_DEF = {
|
|
|
1102
1445
|
fillColor: { kind: 'scalar', default: '#22c55e', inspector: { name: 'fillColor', type: 'color' } },
|
|
1103
1446
|
backgroundAlpha: { kind: 'scalar', default: 1, inspector: { name: 'backgroundAlpha', type: 'number', step: 0.05 } },
|
|
1104
1447
|
fillAlpha: { kind: 'scalar', default: 1, inspector: { name: 'fillAlpha', type: 'number', step: 0.05 } },
|
|
1448
|
+
cap: { kind: 'scalar', inspector: { name: 'cap', type: 'string' } },
|
|
1449
|
+
rotation: { kind: 'scalar', default: 0 },
|
|
1450
|
+
offset: { kind: 'shallowMerge', default: {} },
|
|
1105
1451
|
bindToStore: BIND_STORE,
|
|
1106
1452
|
},
|
|
1107
1453
|
optionsBuilder: (c) => ({
|
|
1108
1454
|
radius: c.radius, lineWidth: c.lineWidth,
|
|
1109
1455
|
backgroundColor: c.backgroundColor, fillColor: c.fillColor,
|
|
1110
1456
|
backgroundAlpha: c.backgroundAlpha, fillAlpha: c.fillAlpha,
|
|
1457
|
+
cap: c.cap,
|
|
1111
1458
|
value: computeProgressPct(c),
|
|
1112
1459
|
}),
|
|
1460
|
+
postCreate: (inst, c) => applyCircularProgressTransform(inst, c),
|
|
1113
1461
|
syncOnChange: (inst, c) => {
|
|
1114
1462
|
const pct = computeProgressPct(c);
|
|
1115
1463
|
if (inst.progress !== pct)
|
|
1116
1464
|
inst.progress = pct;
|
|
1465
|
+
applyCircularProgressTransform(inst, c);
|
|
1117
1466
|
},
|
|
1118
1467
|
mixin: { getProgressPct: getProgressPctMixin },
|
|
1119
1468
|
};
|
|
1469
|
+
function applyCircularProgressTransform(inst, c) {
|
|
1470
|
+
var _a, _b;
|
|
1471
|
+
if (c.rotation !== undefined)
|
|
1472
|
+
inst.rotation = c.rotation;
|
|
1473
|
+
if (c.offset) {
|
|
1474
|
+
inst.x = (_a = c.offset.x) !== null && _a !== void 0 ? _a : 0;
|
|
1475
|
+
inst.y = (_b = c.offset.y) !== null && _b !== void 0 ? _b : 0;
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1120
1478
|
const INPUT_DEF = {
|
|
1121
1479
|
name: 'Input',
|
|
1122
1480
|
signalPrefix: 'input',
|
|
@@ -1134,15 +1492,18 @@ const INPUT_DEF = {
|
|
|
1134
1492
|
nineSliceSprite: { kind: 'opaque' },
|
|
1135
1493
|
cleanOnFocus: { kind: 'scalar', default: false, inspector: { name: 'cleanOnFocus', type: 'boolean' } },
|
|
1136
1494
|
addMask: { kind: 'scalar', default: false, inspector: { name: 'addMask', type: 'boolean' } },
|
|
1495
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1496
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
1137
1497
|
bindToStore: BIND_STORE,
|
|
1138
1498
|
},
|
|
1139
1499
|
views: { kind: 'single', key: 'bgView', required: true },
|
|
1140
1500
|
optionsBuilder: (c, v) => ({
|
|
1141
|
-
bg: v.single, textStyle: c.textStyle,
|
|
1501
|
+
bg: getProgressView(c.bgView, v.single, c.nineSliceSprite), textStyle: c.textStyle,
|
|
1142
1502
|
placeholder: c.placeholder, value: c.value, maxLength: c.maxLength, secure: c.secure,
|
|
1143
1503
|
align: c.align, padding: c.padding,
|
|
1144
1504
|
cleanOnFocus: c.cleanOnFocus, nineSliceSprite: c.nineSliceSprite, addMask: c.addMask,
|
|
1145
1505
|
}),
|
|
1506
|
+
postCreate: (inst, c) => { inst.enabled = c.enabled; applyOptionalSize(inst, c); },
|
|
1146
1507
|
signalMap: (c) => ({
|
|
1147
1508
|
change: (text) => { c.value = text; c.changeCount += 1; return { value: text }; },
|
|
1148
1509
|
enter: (text) => ({ value: text }),
|
|
@@ -1150,6 +1511,9 @@ const INPUT_DEF = {
|
|
|
1150
1511
|
syncOnChange: (inst, c) => {
|
|
1151
1512
|
if (inst.value !== c.value)
|
|
1152
1513
|
inst.value = c.value;
|
|
1514
|
+
if (inst.enabled !== c.enabled)
|
|
1515
|
+
inst.enabled = c.enabled;
|
|
1516
|
+
applyOptionalSize(inst, c);
|
|
1153
1517
|
},
|
|
1154
1518
|
};
|
|
1155
1519
|
const LIST_DEF = {
|
|
@@ -1171,18 +1535,25 @@ const LIST_DEF = {
|
|
|
1171
1535
|
itemsChildName: { kind: 'scalar', default: 'items' },
|
|
1172
1536
|
},
|
|
1173
1537
|
// List 不走 ViewSchema,view 是 collectChildContainers 副作用,system.ts 处理
|
|
1174
|
-
optionsBuilder: (c, _v) => {
|
|
1538
|
+
optionsBuilder: (c, _v) => ({
|
|
1539
|
+
type: c.type,
|
|
1540
|
+
elementsMargin: c.elementsMargin,
|
|
1541
|
+
padding: c.padding,
|
|
1542
|
+
vertPadding: c.vertPadding, horPadding: c.horPadding,
|
|
1543
|
+
topPadding: c.topPadding, bottomPadding: c.bottomPadding,
|
|
1544
|
+
leftPadding: c.leftPadding, rightPadding: c.rightPadding,
|
|
1545
|
+
maxWidth: c.maxWidth, maxHeight: c.maxHeight,
|
|
1546
|
+
}),
|
|
1547
|
+
postCreate: (inst, c) => {
|
|
1175
1548
|
var _a;
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
children: (_a = c.__resolved_items) !== null && _a !== void 0 ? _a : [],
|
|
1185
|
-
});
|
|
1549
|
+
for (const item of (_a = c.__resolved_items) !== null && _a !== void 0 ? _a : []) {
|
|
1550
|
+
try {
|
|
1551
|
+
inst.addChild(item);
|
|
1552
|
+
}
|
|
1553
|
+
catch (_) { }
|
|
1554
|
+
}
|
|
1555
|
+
if (typeof inst.arrangeChildren === 'function')
|
|
1556
|
+
inst.arrangeChildren();
|
|
1186
1557
|
},
|
|
1187
1558
|
syncOnChange: (inst, c) => {
|
|
1188
1559
|
if (inst.type !== c.type)
|
|
@@ -1192,6 +1563,7 @@ const LIST_DEF = {
|
|
|
1192
1563
|
if (typeof inst.arrangeChildren === 'function')
|
|
1193
1564
|
inst.arrangeChildren();
|
|
1194
1565
|
},
|
|
1566
|
+
applySize: applyListLayoutSize,
|
|
1195
1567
|
};
|
|
1196
1568
|
const SCROLL_BOX_DEF = {
|
|
1197
1569
|
name: 'ScrollBox',
|
|
@@ -1202,12 +1574,22 @@ const SCROLL_BOX_DEF = {
|
|
|
1202
1574
|
height: { kind: 'scalar', default: 240, inspector: { name: 'height', type: 'number' } },
|
|
1203
1575
|
direction: { kind: 'scalar', default: 'vertical', inspector: { name: 'direction', type: 'string' } },
|
|
1204
1576
|
contentChildName: { kind: 'scalar', default: 'content' },
|
|
1205
|
-
background: { kind: 'scalar',
|
|
1577
|
+
background: { kind: 'scalar', inspector: { name: 'background', type: 'color' } },
|
|
1206
1578
|
radius: { kind: 'scalar', default: 0, inspector: { name: 'radius', type: 'number' } },
|
|
1207
1579
|
elementsMargin: { kind: 'scalar', default: 0 },
|
|
1208
1580
|
disableDynamicRendering: { kind: 'scalar', default: false },
|
|
1209
1581
|
disableEasing: { kind: 'scalar', default: false, inspector: { name: 'disableEasing', type: 'boolean' } },
|
|
1210
1582
|
padding: { kind: 'scalar', default: 0 },
|
|
1583
|
+
vertPadding: { kind: 'scalar' },
|
|
1584
|
+
horPadding: { kind: 'scalar' },
|
|
1585
|
+
topPadding: { kind: 'scalar' },
|
|
1586
|
+
bottomPadding: { kind: 'scalar' },
|
|
1587
|
+
leftPadding: { kind: 'scalar' },
|
|
1588
|
+
rightPadding: { kind: 'scalar' },
|
|
1589
|
+
globalScroll: { kind: 'scalar', default: true },
|
|
1590
|
+
shiftScroll: { kind: 'scalar', default: false },
|
|
1591
|
+
proximityRange: { kind: 'scalar' },
|
|
1592
|
+
proximityDebounce: { kind: 'scalar' },
|
|
1211
1593
|
// legacy fields(spec 兼容)
|
|
1212
1594
|
inertia: { kind: 'scalar', default: true },
|
|
1213
1595
|
inertiaDecay: { kind: 'scalar', default: 0.92 },
|
|
@@ -1219,7 +1601,7 @@ const SCROLL_BOX_DEF = {
|
|
|
1219
1601
|
getBounds() { return { minX: 0, maxX: 0, minY: 0, maxY: 0 }; },
|
|
1220
1602
|
},
|
|
1221
1603
|
optionsBuilder: (c, _v) => {
|
|
1222
|
-
var _a
|
|
1604
|
+
var _a;
|
|
1223
1605
|
const typeMap = {
|
|
1224
1606
|
horizontal: 'horizontal', vertical: 'vertical', both: 'bidirectional',
|
|
1225
1607
|
};
|
|
@@ -1228,21 +1610,37 @@ const SCROLL_BOX_DEF = {
|
|
|
1228
1610
|
type: (_a = typeMap[c.direction]) !== null && _a !== void 0 ? _a : 'vertical',
|
|
1229
1611
|
background: c.background, radius: c.radius,
|
|
1230
1612
|
elementsMargin: c.elementsMargin, padding: c.padding,
|
|
1613
|
+
vertPadding: c.vertPadding, horPadding: c.horPadding,
|
|
1614
|
+
topPadding: c.topPadding, bottomPadding: c.bottomPadding,
|
|
1615
|
+
leftPadding: c.leftPadding, rightPadding: c.rightPadding,
|
|
1231
1616
|
disableEasing: c.disableEasing, disableDynamicRendering: c.disableDynamicRendering,
|
|
1232
|
-
|
|
1617
|
+
globalScroll: c.globalScroll, shiftScroll: c.shiftScroll,
|
|
1618
|
+
proximityRange: c.proximityRange, proximityDebounce: c.proximityDebounce,
|
|
1233
1619
|
};
|
|
1234
1620
|
},
|
|
1235
1621
|
signalMap: () => ({
|
|
1236
1622
|
scroll: (v) => ({ value: v }),
|
|
1237
1623
|
}),
|
|
1238
|
-
|
|
1624
|
+
postCreate: (inst, c) => {
|
|
1625
|
+
var _a, _b;
|
|
1626
|
+
if (typeof inst.addItems === 'function') {
|
|
1627
|
+
try {
|
|
1628
|
+
inst.addItems((_a = c.__resolved_items) !== null && _a !== void 0 ? _a : []);
|
|
1629
|
+
}
|
|
1630
|
+
catch (_) { }
|
|
1631
|
+
}
|
|
1632
|
+
if (typeof ((_b = inst.list) === null || _b === void 0 ? void 0 : _b.arrangeChildren) === 'function')
|
|
1633
|
+
inst.list.arrangeChildren();
|
|
1239
1634
|
if (typeof inst.resize === 'function') {
|
|
1240
1635
|
try {
|
|
1241
|
-
inst.resize(
|
|
1636
|
+
inst.resize();
|
|
1242
1637
|
}
|
|
1243
1638
|
catch (_) { }
|
|
1244
1639
|
}
|
|
1245
1640
|
},
|
|
1641
|
+
syncOnChange: (inst, c) => {
|
|
1642
|
+
applyOptionalSize(inst, c);
|
|
1643
|
+
},
|
|
1246
1644
|
};
|
|
1247
1645
|
const SELECT_DEF = {
|
|
1248
1646
|
name: 'Select',
|
|
@@ -1256,26 +1654,51 @@ const SELECT_DEF = {
|
|
|
1256
1654
|
openView: { kind: 'opaque' },
|
|
1257
1655
|
textStyle: { kind: 'shallowMerge', default: { fontFamily: 'Arial', fontSize: 14, fill: '#222' } },
|
|
1258
1656
|
nineSliceSprite: { kind: 'opaque' },
|
|
1657
|
+
width: { kind: 'scalar', inspector: { name: 'width', type: 'number' } },
|
|
1658
|
+
height: { kind: 'scalar', inspector: { name: 'height', type: 'number' } },
|
|
1659
|
+
radius: { kind: 'scalar', default: 4 },
|
|
1660
|
+
visibleItems: { kind: 'scalar' },
|
|
1661
|
+
itemWidth: { kind: 'scalar' },
|
|
1662
|
+
itemHeight: { kind: 'scalar' },
|
|
1663
|
+
itemBackgroundColor: { kind: 'scalar', default: 0x000000 },
|
|
1664
|
+
itemHoverColor: { kind: 'scalar', default: 0x666666 },
|
|
1665
|
+
selectedTextOffset: { kind: 'shallowMerge', default: {} },
|
|
1666
|
+
scrollBox: { kind: 'shallowMerge', default: {} },
|
|
1667
|
+
textClass: { kind: 'scalar', default: 'text' },
|
|
1668
|
+
open: { kind: 'scalar', default: false },
|
|
1259
1669
|
bindToStore: BIND_STORE,
|
|
1260
1670
|
},
|
|
1261
1671
|
views: {
|
|
1262
1672
|
kind: 'object', folder: '__select_views__', keys: [],
|
|
1263
1673
|
},
|
|
1264
1674
|
optionsBuilder: (c) => {
|
|
1265
|
-
var _a;
|
|
1675
|
+
var _a, _b, _d, _e, _f;
|
|
1266
1676
|
return ({
|
|
1267
1677
|
closedBG: c.__resolved_closedView,
|
|
1268
1678
|
openBG: c.__resolved_openView,
|
|
1269
1679
|
textStyle: c.textStyle,
|
|
1680
|
+
TextClass: c.textClass === 'html' ? pixi_js.HTMLText : undefined,
|
|
1681
|
+
selectedTextOffset: c.selectedTextOffset,
|
|
1270
1682
|
items: {
|
|
1271
1683
|
items: ((_a = c.items) !== null && _a !== void 0 ? _a : []).map((it) => it.text),
|
|
1272
|
-
backgroundColor:
|
|
1273
|
-
|
|
1684
|
+
backgroundColor: c.itemBackgroundColor,
|
|
1685
|
+
hoverColor: c.itemHoverColor,
|
|
1686
|
+
width: (_d = (_b = c.itemWidth) !== null && _b !== void 0 ? _b : c.width) !== null && _d !== void 0 ? _d : 200,
|
|
1687
|
+
height: (_f = (_e = c.itemHeight) !== null && _e !== void 0 ? _e : c.height) !== null && _f !== void 0 ? _f : 30,
|
|
1688
|
+
textStyle: c.textStyle,
|
|
1689
|
+
TextClass: c.textClass === 'html' ? pixi_js.HTMLText : undefined,
|
|
1690
|
+
radius: c.radius,
|
|
1274
1691
|
},
|
|
1275
1692
|
selected: c.selectedIndex >= 0 ? c.selectedIndex : undefined,
|
|
1693
|
+
visibleItems: c.visibleItems,
|
|
1694
|
+
scrollBox: Object.assign({ width: c.width, height: c.height && c.visibleItems ? c.height * c.visibleItems : undefined, radius: c.radius }, c.scrollBox),
|
|
1276
1695
|
nineSliceSprite: c.nineSliceSprite,
|
|
1277
1696
|
});
|
|
1278
1697
|
},
|
|
1698
|
+
postCreate: (inst, c) => {
|
|
1699
|
+
if (c.open && typeof inst.open === 'function')
|
|
1700
|
+
inst.open();
|
|
1701
|
+
},
|
|
1279
1702
|
signalMap: (c) => ({
|
|
1280
1703
|
select: (value, text) => {
|
|
1281
1704
|
c.selectedIndex = value;
|
|
@@ -1283,6 +1706,12 @@ const SELECT_DEF = {
|
|
|
1283
1706
|
return { index: value, text };
|
|
1284
1707
|
},
|
|
1285
1708
|
}),
|
|
1709
|
+
syncOnChange: (inst, c) => {
|
|
1710
|
+
if (c.open && typeof inst.open === 'function')
|
|
1711
|
+
inst.open();
|
|
1712
|
+
if (!c.open && typeof inst.close === 'function')
|
|
1713
|
+
inst.close();
|
|
1714
|
+
},
|
|
1286
1715
|
};
|
|
1287
1716
|
const DIALOG_DEF = {
|
|
1288
1717
|
name: 'Dialog',
|
|
@@ -1301,36 +1730,340 @@ const DIALOG_DEF = {
|
|
|
1301
1730
|
closeOnBackdropClick: { kind: 'scalar', default: true, inspector: { name: 'closeOnBackdropClick', type: 'boolean' } },
|
|
1302
1731
|
contentChildName: { kind: 'scalar', default: 'content', inspector: { name: 'contentChildName', type: 'string' } },
|
|
1303
1732
|
nineSliceSprite: { kind: 'opaque' },
|
|
1733
|
+
titleStyle: { kind: 'shallowMerge', default: {} },
|
|
1734
|
+
content: { kind: 'scalar' },
|
|
1735
|
+
contentStyle: { kind: 'shallowMerge', default: {} },
|
|
1736
|
+
contentButtons: { kind: 'arrayCopy', default: [] },
|
|
1737
|
+
contentCheckBoxes: { kind: 'arrayCopy', default: [] },
|
|
1738
|
+
buttons: { kind: 'arrayCopy', default: [] },
|
|
1739
|
+
buttonList: { kind: 'shallowMerge', default: {} },
|
|
1740
|
+
buttonListOffset: { kind: 'shallowMerge', default: {} },
|
|
1741
|
+
scrollBox: { kind: 'shallowMerge', default: {} },
|
|
1742
|
+
animations: { kind: 'opaque' },
|
|
1304
1743
|
bindToStore: BIND_STORE,
|
|
1305
1744
|
},
|
|
1306
1745
|
optionsBuilder: (c) => {
|
|
1307
1746
|
var _a;
|
|
1308
|
-
|
|
1747
|
+
const background = c.nineSliceSprite && c.backgroundView && 'texture' in c.backgroundView
|
|
1748
|
+
? c.backgroundView.texture
|
|
1749
|
+
: ((_a = c.__resolved_background_view) !== null && _a !== void 0 ? _a : new pixi_js.Container());
|
|
1750
|
+
return {
|
|
1309
1751
|
backdrop: c.__resolved_backdropView,
|
|
1310
1752
|
backdropColor: backdropColorToNumber(c.backdropColor),
|
|
1311
1753
|
backdropAlpha: c.backdropAlpha,
|
|
1312
|
-
background
|
|
1313
|
-
title: c.title,
|
|
1754
|
+
background,
|
|
1755
|
+
title: makeDialogText(c.title, c.titleStyle),
|
|
1756
|
+
content: makeDialogContent(c),
|
|
1757
|
+
buttons: makeDialogButtons(c.buttons),
|
|
1758
|
+
buttonList: c.buttonList,
|
|
1759
|
+
scrollBox: c.scrollBox,
|
|
1314
1760
|
width: c.width, height: c.height, padding: c.padding,
|
|
1315
1761
|
closeOnBackdropClick: c.closeOnBackdropClick,
|
|
1316
1762
|
nineSliceSprite: c.nineSliceSprite,
|
|
1317
|
-
|
|
1763
|
+
animations: c.animations,
|
|
1764
|
+
};
|
|
1318
1765
|
},
|
|
1319
1766
|
postCreate: (inst, c) => {
|
|
1767
|
+
alignDialogAnchoredContent(inst, c);
|
|
1320
1768
|
if (c.open && typeof inst.open === 'function')
|
|
1321
1769
|
inst.open();
|
|
1322
1770
|
},
|
|
1771
|
+
applySize: applyDialogSize,
|
|
1772
|
+
onAttachedExtra: (inst, c, go) => {
|
|
1773
|
+
wireDialogContentButtonPresses(inst, c, go);
|
|
1774
|
+
},
|
|
1323
1775
|
signalMap: (c) => ({
|
|
1324
1776
|
close: () => { c.open = false; return {}; },
|
|
1325
1777
|
select: (idx, text) => ({ index: idx, text }),
|
|
1326
1778
|
}),
|
|
1327
1779
|
syncOnChange: (inst, c) => {
|
|
1780
|
+
alignDialogAnchoredContent(inst, c);
|
|
1328
1781
|
if (c.open && !inst.isOpen && typeof inst.open === 'function')
|
|
1329
1782
|
inst.open();
|
|
1330
1783
|
else if (!c.open && inst.isOpen && typeof inst.close === 'function')
|
|
1331
1784
|
inst.close();
|
|
1332
1785
|
},
|
|
1333
1786
|
};
|
|
1787
|
+
function applyDialogSize(inst, size, c) {
|
|
1788
|
+
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x, _y;
|
|
1789
|
+
const width = readPositiveSize((_b = (_a = size.width) !== null && _a !== void 0 ? _a : c.width) !== null && _b !== void 0 ? _b : (_d = inst === null || inst === void 0 ? void 0 : inst.options) === null || _d === void 0 ? void 0 : _d.width);
|
|
1790
|
+
const height = readPositiveSize((_f = (_e = size.height) !== null && _e !== void 0 ? _e : c.height) !== null && _f !== void 0 ? _f : (_g = inst === null || inst === void 0 ? void 0 : inst.options) === null || _g === void 0 ? void 0 : _g.height);
|
|
1791
|
+
if (width === undefined && height === undefined)
|
|
1792
|
+
return;
|
|
1793
|
+
inst.options = (_h = inst.options) !== null && _h !== void 0 ? _h : {};
|
|
1794
|
+
if (width !== undefined)
|
|
1795
|
+
inst.options.width = width;
|
|
1796
|
+
if (height !== undefined)
|
|
1797
|
+
inst.options.height = height;
|
|
1798
|
+
const dialogWidth = width !== null && width !== void 0 ? width : (Number(inst.options.width) || Number((_j = inst.innerView) === null || _j === void 0 ? void 0 : _j.width) || 0);
|
|
1799
|
+
const dialogHeight = height !== null && height !== void 0 ? height : (Number(inst.options.height) || Number((_k = inst.innerView) === null || _k === void 0 ? void 0 : _k.height) || 0);
|
|
1800
|
+
const padding = Number((_m = (_l = c.padding) !== null && _l !== void 0 ? _l : inst.options.padding) !== null && _m !== void 0 ? _m : 20) || 20;
|
|
1801
|
+
if (inst.innerView) {
|
|
1802
|
+
if (width !== undefined)
|
|
1803
|
+
inst.innerView.width = width;
|
|
1804
|
+
if (height !== undefined)
|
|
1805
|
+
inst.innerView.height = height;
|
|
1806
|
+
if ('anchor' in inst.innerView && ((_o = inst.innerView.anchor) === null || _o === void 0 ? void 0 : _o.set)) {
|
|
1807
|
+
inst.innerView.anchor.set(0.5, 0.5);
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
try {
|
|
1811
|
+
(_q = (_p = inst.innerView.pivot) === null || _p === void 0 ? void 0 : _p.set) === null || _q === void 0 ? void 0 : _q.call(_p, dialogWidth / 2, dialogHeight / 2);
|
|
1812
|
+
}
|
|
1813
|
+
catch (_) { }
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (inst.titleText) {
|
|
1817
|
+
inst.titleText.x = dialogWidth / 2;
|
|
1818
|
+
inst.titleText.y = padding;
|
|
1819
|
+
}
|
|
1820
|
+
const titleHeight = Number((_r = inst.titleText) === null || _r === void 0 ? void 0 : _r.height) || 0;
|
|
1821
|
+
const buttonHeight = Number((_s = inst.buttonContainer) === null || _s === void 0 ? void 0 : _s.height) || 0;
|
|
1822
|
+
if (inst.buttonContainer) {
|
|
1823
|
+
inst.buttonContainer.x = dialogWidth / 2 - ((Number(inst.buttonContainer.width) || 0) / 2);
|
|
1824
|
+
inst.buttonContainer.y = dialogHeight - padding - buttonHeight;
|
|
1825
|
+
}
|
|
1826
|
+
if (inst.scrollBox) {
|
|
1827
|
+
inst.scrollBox.x = padding;
|
|
1828
|
+
inst.scrollBox.y = padding + titleHeight;
|
|
1829
|
+
const overrideSize = (_t = c.scrollBox) === null || _t === void 0 ? void 0 : _t.size;
|
|
1830
|
+
const scrollWidth = (_u = readPositiveSize(overrideSize === null || overrideSize === void 0 ? void 0 : overrideSize.width)) !== null && _u !== void 0 ? _u : Math.max(0, dialogWidth - (padding * 2));
|
|
1831
|
+
const scrollHeight = (_w = readPositiveSize(overrideSize === null || overrideSize === void 0 ? void 0 : overrideSize.height)) !== null && _w !== void 0 ? _w : Math.max(0, dialogHeight - (padding * 2) - titleHeight - buttonHeight);
|
|
1832
|
+
if (typeof inst.scrollBox.setSize === 'function')
|
|
1833
|
+
inst.scrollBox.setSize(scrollWidth, scrollHeight);
|
|
1834
|
+
else {
|
|
1835
|
+
inst.scrollBox.width = scrollWidth;
|
|
1836
|
+
inst.scrollBox.height = scrollHeight;
|
|
1837
|
+
}
|
|
1838
|
+
try {
|
|
1839
|
+
(_y = (_x = inst.scrollBox).resize) === null || _y === void 0 ? void 0 : _y.call(_x, true);
|
|
1840
|
+
}
|
|
1841
|
+
catch (_) { }
|
|
1842
|
+
}
|
|
1843
|
+
alignDialogAnchoredContent(inst, Object.assign(Object.assign({}, c), { width: dialogWidth, height: dialogHeight }));
|
|
1844
|
+
}
|
|
1845
|
+
function readPositiveSize(value) {
|
|
1846
|
+
const n = Number(value);
|
|
1847
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
1848
|
+
}
|
|
1849
|
+
function alignDialogAnchoredContent(inst, c) {
|
|
1850
|
+
var _a, _b;
|
|
1851
|
+
const innerView = inst === null || inst === void 0 ? void 0 : inst.innerView;
|
|
1852
|
+
const contentView = inst === null || inst === void 0 ? void 0 : inst.contentView;
|
|
1853
|
+
if ((innerView === null || innerView === void 0 ? void 0 : innerView.anchor) && contentView && c.width && c.height) {
|
|
1854
|
+
contentView.x = -c.width / 2;
|
|
1855
|
+
contentView.y = -c.height / 2;
|
|
1856
|
+
}
|
|
1857
|
+
applyDialogOffset(inst, 'buttonListOffset', inst.buttonContainer, c.buttonListOffset);
|
|
1858
|
+
applyDialogOffset(inst, 'scrollBoxOffset', inst.scrollBox, (_a = c.scrollBox) === null || _a === void 0 ? void 0 : _a.offset);
|
|
1859
|
+
applyDialogScrollBoxSize(inst, (_b = c.scrollBox) === null || _b === void 0 ? void 0 : _b.size);
|
|
1860
|
+
}
|
|
1861
|
+
function applyDialogOffset(inst, key, target, nextOffset) {
|
|
1862
|
+
var _a, _b, _d, _e;
|
|
1863
|
+
if (!target)
|
|
1864
|
+
return;
|
|
1865
|
+
const applied = (_a = inst.__evaDialogAppliedOffsets) !== null && _a !== void 0 ? _a : {};
|
|
1866
|
+
const prev = (_b = applied[key]) !== null && _b !== void 0 ? _b : { x: 0, y: 0 };
|
|
1867
|
+
const next = { x: (_d = nextOffset === null || nextOffset === void 0 ? void 0 : nextOffset.x) !== null && _d !== void 0 ? _d : 0, y: (_e = nextOffset === null || nextOffset === void 0 ? void 0 : nextOffset.y) !== null && _e !== void 0 ? _e : 0 };
|
|
1868
|
+
target.x += next.x - prev.x;
|
|
1869
|
+
target.y += next.y - prev.y;
|
|
1870
|
+
inst.__evaDialogAppliedOffsets = Object.assign(Object.assign({}, applied), { [key]: next });
|
|
1871
|
+
}
|
|
1872
|
+
function applyDialogScrollBoxSize(inst, nextSize) {
|
|
1873
|
+
var _a, _b, _d;
|
|
1874
|
+
const scrollBox = inst === null || inst === void 0 ? void 0 : inst.scrollBox;
|
|
1875
|
+
if (!scrollBox)
|
|
1876
|
+
return;
|
|
1877
|
+
const base = (_a = inst.__evaDialogBaseScrollBoxSize) !== null && _a !== void 0 ? _a : {
|
|
1878
|
+
width: scrollBox.width,
|
|
1879
|
+
height: scrollBox.height,
|
|
1880
|
+
};
|
|
1881
|
+
inst.__evaDialogBaseScrollBoxSize = base;
|
|
1882
|
+
const wasApplied = inst.__evaDialogAppliedScrollBoxSize;
|
|
1883
|
+
if (!nextSize && !wasApplied)
|
|
1884
|
+
return;
|
|
1885
|
+
const width = (_b = nextSize === null || nextSize === void 0 ? void 0 : nextSize.width) !== null && _b !== void 0 ? _b : base.width;
|
|
1886
|
+
const height = (_d = nextSize === null || nextSize === void 0 ? void 0 : nextSize.height) !== null && _d !== void 0 ? _d : base.height;
|
|
1887
|
+
if (typeof scrollBox.setSize === 'function')
|
|
1888
|
+
scrollBox.setSize(width, height);
|
|
1889
|
+
else {
|
|
1890
|
+
scrollBox.width = width;
|
|
1891
|
+
scrollBox.height = height;
|
|
1892
|
+
}
|
|
1893
|
+
if (typeof scrollBox.resize === 'function')
|
|
1894
|
+
scrollBox.resize(true);
|
|
1895
|
+
inst.__evaDialogAppliedScrollBoxSize = !!nextSize;
|
|
1896
|
+
}
|
|
1897
|
+
function makeDialogText(text, style) {
|
|
1898
|
+
if (text === undefined)
|
|
1899
|
+
return undefined;
|
|
1900
|
+
if (style && Object.keys(style).length > 0) {
|
|
1901
|
+
return new pixi_js.Text({ text, style: style });
|
|
1902
|
+
}
|
|
1903
|
+
return text;
|
|
1904
|
+
}
|
|
1905
|
+
function makeDialogContent(c) {
|
|
1906
|
+
var _a, _b;
|
|
1907
|
+
if ((_a = c.contentButtons) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1908
|
+
const records = [];
|
|
1909
|
+
const buttons = c.contentButtons.map((button, index) => {
|
|
1910
|
+
const pixiButton = new ui.FancyButton(makeDialogButtonOptions(button));
|
|
1911
|
+
applyOptionalSize(pixiButton, button);
|
|
1912
|
+
if (button.disabled !== undefined)
|
|
1913
|
+
pixiButton.enabled = !button.disabled;
|
|
1914
|
+
records.push({ button: pixiButton, params: button, index });
|
|
1915
|
+
return pixiButton;
|
|
1916
|
+
});
|
|
1917
|
+
c.__dialogContentButtons = records;
|
|
1918
|
+
return buttons;
|
|
1919
|
+
}
|
|
1920
|
+
if ((_b = c.contentCheckBoxes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1921
|
+
return c.contentCheckBoxes.map((checkBox) => new ui.CheckBox(makeDialogCheckBoxOptions(checkBox)));
|
|
1922
|
+
}
|
|
1923
|
+
return makeDialogText(c.content, c.contentStyle);
|
|
1924
|
+
}
|
|
1925
|
+
function wireDialogContentButtonPresses(inst, c, go) {
|
|
1926
|
+
const records = c.__dialogContentButtons;
|
|
1927
|
+
if (!Array.isArray(records) || records.length === 0 || inst.__evaDialogContentButtonPressesWired)
|
|
1928
|
+
return;
|
|
1929
|
+
inst.__evaDialogContentButtonPressesWired = true;
|
|
1930
|
+
inst.__evaDialogContentButtonPressCleanups = records.map((record) => {
|
|
1931
|
+
var _a;
|
|
1932
|
+
const signal = (_a = record.button) === null || _a === void 0 ? void 0 : _a.onPress;
|
|
1933
|
+
if (!signal || typeof signal.connect !== 'function')
|
|
1934
|
+
return undefined;
|
|
1935
|
+
const conn = signal.connect(() => {
|
|
1936
|
+
var _a, _b, _d, _e;
|
|
1937
|
+
const value = (_b = (_a = record.params.value) !== null && _a !== void 0 ? _a : record.params.text) !== null && _b !== void 0 ? _b : record.index;
|
|
1938
|
+
c.selectedContentIndex = record.index;
|
|
1939
|
+
c.selectedContentValue = value;
|
|
1940
|
+
c.selectCount = ((_d = c.selectCount) !== null && _d !== void 0 ? _d : 0) + 1;
|
|
1941
|
+
c.lastSignal = 'select';
|
|
1942
|
+
emitDialogSelection(go, { index: record.index, text: String((_e = record.params.text) !== null && _e !== void 0 ? _e : ''), value });
|
|
1943
|
+
if (record.params.closeOnPress && typeof inst.close === 'function')
|
|
1944
|
+
inst.close();
|
|
1945
|
+
const reopenDelay = Number(record.params.reopenDelay);
|
|
1946
|
+
if (Number.isFinite(reopenDelay) && reopenDelay >= 0 && typeof inst.open === 'function') {
|
|
1947
|
+
setTimeout(() => {
|
|
1948
|
+
try {
|
|
1949
|
+
inst.open();
|
|
1950
|
+
}
|
|
1951
|
+
catch (_) { }
|
|
1952
|
+
}, reopenDelay);
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
return () => { try {
|
|
1956
|
+
conn.disconnect();
|
|
1957
|
+
}
|
|
1958
|
+
catch (_) { } };
|
|
1959
|
+
}).filter(Boolean);
|
|
1960
|
+
}
|
|
1961
|
+
function emitDialogSelection(go, payload) {
|
|
1962
|
+
var _a, _b, _d;
|
|
1963
|
+
const eventPayload = Object.assign({ entityName: go === null || go === void 0 ? void 0 : go.name }, payload);
|
|
1964
|
+
try {
|
|
1965
|
+
(_a = go === null || go === void 0 ? void 0 : go.emit) === null || _a === void 0 ? void 0 : _a.call(go, 'select', eventPayload);
|
|
1966
|
+
}
|
|
1967
|
+
catch (_) { }
|
|
1968
|
+
try {
|
|
1969
|
+
(_b = go === null || go === void 0 ? void 0 : go.emit) === null || _b === void 0 ? void 0 : _b.call(go, 'dialog:select', eventPayload);
|
|
1970
|
+
}
|
|
1971
|
+
catch (_) { }
|
|
1972
|
+
const mx = (typeof globalThis !== 'undefined' ? globalThis.mx : undefined);
|
|
1973
|
+
if ((_d = mx === null || mx === void 0 ? void 0 : mx.event) === null || _d === void 0 ? void 0 : _d.emit) {
|
|
1974
|
+
try {
|
|
1975
|
+
mx.event.emit('dialog:select', eventPayload);
|
|
1976
|
+
}
|
|
1977
|
+
catch (_) { }
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
function makeDialogButtons(buttons) {
|
|
1981
|
+
if (!(buttons === null || buttons === void 0 ? void 0 : buttons.length))
|
|
1982
|
+
return undefined;
|
|
1983
|
+
return buttons.map((button) => {
|
|
1984
|
+
const options = makeDialogButtonOptions(button);
|
|
1985
|
+
const shouldMaterialize = button.disabled !== undefined
|
|
1986
|
+
|| !!(button.nineSliceSprite && (button.width !== undefined || button.height !== undefined));
|
|
1987
|
+
if (button.kind === 'button' || !shouldMaterialize)
|
|
1988
|
+
return options;
|
|
1989
|
+
const pixiButton = new ui.FancyButton(options);
|
|
1990
|
+
applyOptionalSize(pixiButton, button);
|
|
1991
|
+
pixiButton.enabled = !button.disabled;
|
|
1992
|
+
return pixiButton;
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
function makeDialogButtonOptions(button) {
|
|
1996
|
+
var _a, _b, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1997
|
+
if (button.kind === 'button')
|
|
1998
|
+
return makeDialogBareButton(button);
|
|
1999
|
+
const width = (_a = button.width) !== null && _a !== void 0 ? _a : 110;
|
|
2000
|
+
const height = (_b = button.height) !== null && _b !== void 0 ? _b : 48;
|
|
2001
|
+
const radius = (_d = button.radius) !== null && _d !== void 0 ? _d : 12;
|
|
2002
|
+
const color = (_e = button.color) !== null && _e !== void 0 ? _e : pixiStoryDefaultButtonColor;
|
|
2003
|
+
return {
|
|
2004
|
+
text: makeDialogText(button.text, button.textStyle),
|
|
2005
|
+
defaultView: (_f = resolveDialogButtonView(button.defaultView)) !== null && _f !== void 0 ? _f : makeDialogButtonView(width, height, radius, color),
|
|
2006
|
+
hoverView: (_g = resolveDialogButtonView(button.hoverView)) !== null && _g !== void 0 ? _g : makeDialogButtonView(width, height, radius, (_h = button.hoverColor) !== null && _h !== void 0 ? _h : color),
|
|
2007
|
+
pressedView: (_j = resolveDialogButtonView(button.pressedView)) !== null && _j !== void 0 ? _j : makeDialogButtonView(width, height, radius, (_k = button.pressedColor) !== null && _k !== void 0 ? _k : color),
|
|
2008
|
+
disabledView: (_l = resolveDialogButtonView(button.disabledView)) !== null && _l !== void 0 ? _l : (button.disabledColor ? makeDialogButtonView(width, height, radius, button.disabledColor) : undefined),
|
|
2009
|
+
nineSliceSprite: button.nineSliceSprite,
|
|
2010
|
+
enabled: button.disabled === undefined ? undefined : !button.disabled,
|
|
2011
|
+
animations: button.animations,
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
function resolveDialogButtonView(view) {
|
|
2015
|
+
return view ? getTextureView(view) : undefined;
|
|
2016
|
+
}
|
|
2017
|
+
const pixiStoryDefaultButtonColor = '#e91e63';
|
|
2018
|
+
const pixiStoryDefaultTextColor = '#ffffff';
|
|
2019
|
+
function makeDialogButtonView(width, height, radius, color) {
|
|
2020
|
+
return new pixi_js.Graphics()
|
|
2021
|
+
.roundRect(0, 0, width, height, radius)
|
|
2022
|
+
.fill(color);
|
|
2023
|
+
}
|
|
2024
|
+
function makeDialogBareButton(button) {
|
|
2025
|
+
var _a, _b, _d, _e, _f, _g;
|
|
2026
|
+
const width = (_a = button.width) !== null && _a !== void 0 ? _a : 110;
|
|
2027
|
+
const height = (_b = button.height) !== null && _b !== void 0 ? _b : 48;
|
|
2028
|
+
const radius = (_d = button.radius) !== null && _d !== void 0 ? _d : 12;
|
|
2029
|
+
const view = makeDialogButtonView(width, height, radius, (_e = button.color) !== null && _e !== void 0 ? _e : pixiStoryDefaultButtonColor);
|
|
2030
|
+
const label = makeDialogText(button.text, button.textStyle);
|
|
2031
|
+
if (label) {
|
|
2032
|
+
label.x = width / 2;
|
|
2033
|
+
label.y = height / 2;
|
|
2034
|
+
try {
|
|
2035
|
+
(_g = (_f = label.anchor) === null || _f === void 0 ? void 0 : _f.set) === null || _g === void 0 ? void 0 : _g.call(_f, 0.5);
|
|
2036
|
+
}
|
|
2037
|
+
catch (_) { }
|
|
2038
|
+
view.addChild(label);
|
|
2039
|
+
}
|
|
2040
|
+
const pixiButton = new ui.Button(view);
|
|
2041
|
+
if (button.disabled !== undefined)
|
|
2042
|
+
pixiButton.enabled = !button.disabled;
|
|
2043
|
+
return pixiButton;
|
|
2044
|
+
}
|
|
2045
|
+
function makeDialogCheckBoxOptions(checkBox) {
|
|
2046
|
+
var _a, _b, _d, _e, _f, _g;
|
|
2047
|
+
const size = (_a = checkBox.size) !== null && _a !== void 0 ? _a : 30;
|
|
2048
|
+
const radius = (_b = checkBox.radius) !== null && _b !== void 0 ? _b : 5;
|
|
2049
|
+
const strokeColor = (_d = checkBox.strokeColor) !== null && _d !== void 0 ? _d : pixiStoryDefaultTextColor;
|
|
2050
|
+
const strokeWidth = (_e = checkBox.strokeWidth) !== null && _e !== void 0 ? _e : 2;
|
|
2051
|
+
return {
|
|
2052
|
+
style: {
|
|
2053
|
+
unchecked: new pixi_js.Graphics()
|
|
2054
|
+
.roundRect(0, 0, size, size, radius)
|
|
2055
|
+
.fill(((_f = checkBox.uncheckedColor) !== null && _f !== void 0 ? _f : '#3e3f40'))
|
|
2056
|
+
.stroke({ color: strokeColor, width: strokeWidth }),
|
|
2057
|
+
checked: new pixi_js.Graphics()
|
|
2058
|
+
.roundRect(0, 0, size, size, radius)
|
|
2059
|
+
.fill(((_g = checkBox.checkedColor) !== null && _g !== void 0 ? _g : pixiStoryDefaultButtonColor))
|
|
2060
|
+
.stroke({ color: strokeColor, width: strokeWidth }),
|
|
2061
|
+
text: checkBox.textStyle,
|
|
2062
|
+
},
|
|
2063
|
+
text: checkBox.text,
|
|
2064
|
+
checked: checkBox.checked,
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
1334
2067
|
const MASKED_FRAME_DEF = {
|
|
1335
2068
|
name: 'MaskedFrame',
|
|
1336
2069
|
signalPrefix: 'maskedframe',
|
|
@@ -1339,12 +2072,14 @@ const MASKED_FRAME_DEF = {
|
|
|
1339
2072
|
targetView: { kind: 'opaque' },
|
|
1340
2073
|
maskView: { kind: 'opaque' },
|
|
1341
2074
|
borderView: { kind: 'opaque' },
|
|
2075
|
+
borderWidth: { kind: 'scalar', default: 0, inspector: { name: 'borderWidth', type: 'number' } },
|
|
2076
|
+
borderColor: { kind: 'scalar', default: 0x000000, inspector: { name: 'borderColor', type: 'color' } },
|
|
1342
2077
|
},
|
|
1343
2078
|
optionsBuilder: (c) => ({
|
|
1344
|
-
target: c.
|
|
1345
|
-
mask: c.
|
|
1346
|
-
borderWidth:
|
|
1347
|
-
borderColor:
|
|
2079
|
+
target: c.__resolved_target_view,
|
|
2080
|
+
mask: c.__resolved_mask_view,
|
|
2081
|
+
borderWidth: c.borderWidth,
|
|
2082
|
+
borderColor: c.borderColor,
|
|
1348
2083
|
}),
|
|
1349
2084
|
};
|
|
1350
2085
|
// ============================================================
|
|
@@ -1541,13 +2276,16 @@ function safeProject(projector, args) {
|
|
|
1541
2276
|
/**
|
|
1542
2277
|
* UISystem - generic handler driven by COMPONENT_DEFINITIONS metadata.
|
|
1543
2278
|
*
|
|
1544
|
-
* 16 个 ECS 组件(
|
|
2279
|
+
* 16 个 ECS 组件(Shape 自渲染 + 14 个 @pixi/ui factory wrapper + RadioGroup 独立)由本 system 统一驱动。
|
|
1545
2280
|
* 不再为每个组件写独立 handler 方法 - 14 个 @pixi/ui 组件走 handleGeneric,RadioGroup 单独处理。
|
|
1546
2281
|
*/
|
|
1547
2282
|
// observer schema:把 COMPONENT_DEFINITIONS.fields 转成 componentObserver decorator 参数
|
|
1548
2283
|
function buildObserverSchema() {
|
|
1549
2284
|
const out = {
|
|
2285
|
+
Transform: [{ prop: ['size'], deep: true }],
|
|
2286
|
+
Shape: [{ prop: ['shapes'], deep: true }],
|
|
1550
2287
|
UI: [{ prop: ['shapes'], deep: true }],
|
|
2288
|
+
UIComponent: [{ prop: ['shapes'], deep: true }],
|
|
1551
2289
|
RadioGroup: [
|
|
1552
2290
|
{ prop: ['selectedId'], deep: false },
|
|
1553
2291
|
{ prop: ['direction'], deep: false },
|
|
@@ -1564,6 +2302,9 @@ function buildObserverSchema() {
|
|
|
1564
2302
|
}
|
|
1565
2303
|
return out;
|
|
1566
2304
|
}
|
|
2305
|
+
function isShapeComponentName(name) {
|
|
2306
|
+
return name === 'Shape' || name === 'UI' || name === 'UIComponent';
|
|
2307
|
+
}
|
|
1567
2308
|
let UISystem = class UISystem extends eva_js.System {
|
|
1568
2309
|
constructor() {
|
|
1569
2310
|
super(...arguments);
|
|
@@ -1571,6 +2312,7 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1571
2312
|
/** componentName -> instance map(generic 共享一份) */
|
|
1572
2313
|
this.instances = new Map();
|
|
1573
2314
|
this.signalCleanups = new Map();
|
|
2315
|
+
this.transformSizeAuthorities = new Set();
|
|
1574
2316
|
this.radioGroupInstances = new Map();
|
|
1575
2317
|
}
|
|
1576
2318
|
/** 给 RadioGroup 反查 PixiCheckBox 实例用 */
|
|
@@ -1594,8 +2336,10 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1594
2336
|
}
|
|
1595
2337
|
componentChanged(changed) {
|
|
1596
2338
|
const name = changed.componentName;
|
|
1597
|
-
if (name === '
|
|
1598
|
-
return this.
|
|
2339
|
+
if (name === 'Transform')
|
|
2340
|
+
return this.handleTransformSizeChanged(changed);
|
|
2341
|
+
if (isShapeComponentName(name))
|
|
2342
|
+
return this.handleShape(changed);
|
|
1599
2343
|
if (name === 'RadioGroup')
|
|
1600
2344
|
return this.handleRadioGroup(changed);
|
|
1601
2345
|
const def = COMPONENT_DEFINITIONS[name];
|
|
@@ -1603,13 +2347,13 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1603
2347
|
return this.handleGeneric(def, changed);
|
|
1604
2348
|
}
|
|
1605
2349
|
// ============================================================
|
|
1606
|
-
//
|
|
2350
|
+
// Shape(自渲染,无 @pixi/ui 实例)
|
|
1607
2351
|
// ============================================================
|
|
1608
|
-
|
|
2352
|
+
handleShape(changed) {
|
|
1609
2353
|
if (changed.type === eva_js.OBSERVER_TYPE.ADD || changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
1610
|
-
const
|
|
1611
|
-
if (typeof
|
|
1612
|
-
|
|
2354
|
+
const shape = changed.component;
|
|
2355
|
+
if (typeof shape.redraw === 'function')
|
|
2356
|
+
shape.redraw();
|
|
1613
2357
|
}
|
|
1614
2358
|
}
|
|
1615
2359
|
// ============================================================
|
|
@@ -1633,13 +2377,16 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1633
2377
|
return;
|
|
1634
2378
|
}
|
|
1635
2379
|
(_a = def.syncOnChange) === null || _a === void 0 ? void 0 : _a.call(def, inst, c);
|
|
2380
|
+
if (this.transformSizeAuthorities.has(go.id)) {
|
|
2381
|
+
applyTransformSizeToInstance(def, inst, c, go, 'component-change');
|
|
2382
|
+
}
|
|
1636
2383
|
}
|
|
1637
2384
|
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
1638
2385
|
this.detachGeneric(go.id, instMap, go);
|
|
1639
2386
|
}
|
|
1640
2387
|
}
|
|
1641
2388
|
attachGeneric(def, c, go, instMap) {
|
|
1642
|
-
var _a, _b, _c, _d, _f, _g, _h;
|
|
2389
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
1643
2390
|
if (instMap.has(go.id))
|
|
1644
2391
|
return;
|
|
1645
2392
|
const game = this.gameRef(go);
|
|
@@ -1656,25 +2403,39 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1656
2403
|
if (def.name === 'List' || def.name === 'ScrollBox') {
|
|
1657
2404
|
const childName = def.name === 'List' ? c.itemsChildName : c.contentChildName;
|
|
1658
2405
|
c.__resolved_items = collectChildContainers(game, go, childName);
|
|
2406
|
+
const expectedCount = getCollectedChildCount(go, childName);
|
|
2407
|
+
if (expectedCount > 0 && c.__resolved_items.length < expectedCount && ((_a = c.__collect_retry) !== null && _a !== void 0 ? _a : 0) < 10) {
|
|
2408
|
+
c.__collect_retry = ((_b = c.__collect_retry) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
2409
|
+
requestAnimationFrame(() => this.attachGeneric(def, c, go, instMap));
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
1659
2412
|
}
|
|
1660
2413
|
// 4) 构造 PIXI 实例
|
|
2414
|
+
const restoreTransientSize = this.applyTransientTransformSize(c, go);
|
|
1661
2415
|
const built = def.optionsBuilder(c, views !== null && views !== void 0 ? views : {});
|
|
1662
2416
|
const inst = def.positional
|
|
1663
2417
|
? new def.pixiClass(...built)
|
|
1664
2418
|
: new def.pixiClass(built);
|
|
1665
2419
|
// 5) postCreate(enabled / selected tint 等)
|
|
1666
|
-
(
|
|
2420
|
+
(_c = def.postCreate) === null || _c === void 0 ? void 0 : _c.call(def, inst, c);
|
|
2421
|
+
// 5.5) 新 DSL 以 Transform.size 作为 plugin-ui 渲染尺寸来源。
|
|
2422
|
+
// 历史 DSL 若显式写了组件 width/height,初次 attach 保持旧行为;之后 Transform.size change 会接管。
|
|
2423
|
+
if (this.transformSizeAuthorities.has(go.id) || !hasExplicitRenderSize(c)) {
|
|
2424
|
+
const applied = applyTransformSizeToInstance(def, inst, c, go, 'initial-transform');
|
|
2425
|
+
if (applied)
|
|
2426
|
+
this.transformSizeAuthorities.add(go.id);
|
|
2427
|
+
}
|
|
1667
2428
|
// 6) 注册 + attach
|
|
1668
2429
|
instMap.set(go.id, inst);
|
|
1669
2430
|
attachToGameObject(game, go, inst);
|
|
1670
2431
|
// 7) onAttachedExtra(Dialog 挂 contentChild)
|
|
1671
2432
|
if (def.name === 'Dialog') {
|
|
1672
|
-
const contentChild = findChildEntity(go, (
|
|
2433
|
+
const contentChild = findChildEntity(go, (_d = c.contentChildName) !== null && _d !== void 0 ? _d : 'content');
|
|
1673
2434
|
if (contentChild) {
|
|
1674
2435
|
const cc = getEvaContainer(game, contentChild);
|
|
1675
2436
|
if (cc) {
|
|
1676
2437
|
try {
|
|
1677
|
-
(
|
|
2438
|
+
(_g = (_f = inst).addChild) === null || _g === void 0 ? void 0 : _g.call(_f, cc);
|
|
1678
2439
|
}
|
|
1679
2440
|
catch (_) { }
|
|
1680
2441
|
}
|
|
@@ -1685,7 +2446,7 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1685
2446
|
const border = resolveViewRef(game, go, c.borderView);
|
|
1686
2447
|
if (border) {
|
|
1687
2448
|
try {
|
|
1688
|
-
(
|
|
2449
|
+
(_j = (_h = inst).addChild) === null || _j === void 0 ? void 0 : _j.call(_h, border);
|
|
1689
2450
|
}
|
|
1690
2451
|
catch (_) { }
|
|
1691
2452
|
}
|
|
@@ -1695,7 +2456,8 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1695
2456
|
const offs = bridgeSignals(inst, { go, prefix: def.signalPrefix }, def.signalMap(c));
|
|
1696
2457
|
this.signalCleanups.set(go.id, offs);
|
|
1697
2458
|
}
|
|
1698
|
-
(
|
|
2459
|
+
(_k = def.onAttachedExtra) === null || _k === void 0 ? void 0 : _k.call(def, inst, c, go, game);
|
|
2460
|
+
restoreTransientSize();
|
|
1699
2461
|
}
|
|
1700
2462
|
detachGeneric(id, instMap, go) {
|
|
1701
2463
|
const inst = instMap.get(id);
|
|
@@ -1772,6 +2534,11 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1772
2534
|
items, type: (_f = typeMap[c.direction]) !== null && _f !== void 0 ? _f : 'vertical',
|
|
1773
2535
|
elementsMargin: c.elementsMargin, selectedItem: initialIndex,
|
|
1774
2536
|
});
|
|
2537
|
+
if (this.transformSizeAuthorities.has(go.id)) {
|
|
2538
|
+
const size = readTransformRenderSize(go, { allowZero: true });
|
|
2539
|
+
if (size)
|
|
2540
|
+
applyRuntimeSize(inst, size);
|
|
2541
|
+
}
|
|
1775
2542
|
this.radioGroupInstances.set(go.id, inst);
|
|
1776
2543
|
attachToGameObject(game, go, inst);
|
|
1777
2544
|
const offs = bridgeSignals(inst, { go, prefix: 'radiogroup' }, {
|
|
@@ -1807,6 +2574,74 @@ let UISystem = class UISystem extends eva_js.System {
|
|
|
1807
2574
|
}
|
|
1808
2575
|
return null;
|
|
1809
2576
|
}
|
|
2577
|
+
// ============================================================
|
|
2578
|
+
// Transform.size -> plugin-ui runtime size
|
|
2579
|
+
// ============================================================
|
|
2580
|
+
handleTransformSizeChanged(changed) {
|
|
2581
|
+
var _a, _b;
|
|
2582
|
+
if (changed.type !== eva_js.OBSERVER_TYPE.CHANGE)
|
|
2583
|
+
return;
|
|
2584
|
+
const transform = changed.component;
|
|
2585
|
+
const go = (_a = changed.gameObject) !== null && _a !== void 0 ? _a : transform === null || transform === void 0 ? void 0 : transform.gameObject;
|
|
2586
|
+
if (!go)
|
|
2587
|
+
return;
|
|
2588
|
+
let applied = false;
|
|
2589
|
+
for (const [componentName, def] of Object.entries(COMPONENT_DEFINITIONS)) {
|
|
2590
|
+
const inst = (_b = this.instances.get(componentName)) === null || _b === void 0 ? void 0 : _b.get(go.id);
|
|
2591
|
+
if (!inst)
|
|
2592
|
+
continue;
|
|
2593
|
+
const component = getComponentSafe(go, componentName);
|
|
2594
|
+
if (applyTransformSizeToInstance(def, inst, component, go, 'transform-change')) {
|
|
2595
|
+
applied = true;
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
const radioGroup = this.radioGroupInstances.get(go.id);
|
|
2599
|
+
if (radioGroup) {
|
|
2600
|
+
const size = readTransformRenderSize(go, { allowZero: true });
|
|
2601
|
+
if (size) {
|
|
2602
|
+
applyRuntimeSize(radioGroup, size);
|
|
2603
|
+
applied = true;
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
if (applied)
|
|
2607
|
+
this.transformSizeAuthorities.add(go.id);
|
|
2608
|
+
this.relayoutLayoutInstances();
|
|
2609
|
+
}
|
|
2610
|
+
relayoutLayoutInstances() {
|
|
2611
|
+
for (const name of ['List', 'ScrollBox']) {
|
|
2612
|
+
const instMap = this.instances.get(name);
|
|
2613
|
+
if (!instMap)
|
|
2614
|
+
continue;
|
|
2615
|
+
for (const inst of instMap.values()) {
|
|
2616
|
+
relayoutRuntimeInstance(inst);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
applyTransientTransformSize(c, go) {
|
|
2621
|
+
if (hasExplicitRenderSize(c))
|
|
2622
|
+
return () => { };
|
|
2623
|
+
const size = readTransformRenderSize(go);
|
|
2624
|
+
if (!size)
|
|
2625
|
+
return () => { };
|
|
2626
|
+
const hadWidth = Object.prototype.hasOwnProperty.call(c, 'width');
|
|
2627
|
+
const hadHeight = Object.prototype.hasOwnProperty.call(c, 'height');
|
|
2628
|
+
const prevWidth = c.width;
|
|
2629
|
+
const prevHeight = c.height;
|
|
2630
|
+
if (size.width !== undefined)
|
|
2631
|
+
c.width = size.width;
|
|
2632
|
+
if (size.height !== undefined)
|
|
2633
|
+
c.height = size.height;
|
|
2634
|
+
return () => {
|
|
2635
|
+
if (hadWidth)
|
|
2636
|
+
c.width = prevWidth;
|
|
2637
|
+
else
|
|
2638
|
+
delete c.width;
|
|
2639
|
+
if (hadHeight)
|
|
2640
|
+
c.height = prevHeight;
|
|
2641
|
+
else
|
|
2642
|
+
delete c.height;
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
1810
2645
|
};
|
|
1811
2646
|
UISystem.systemName = 'UISystem';
|
|
1812
2647
|
UISystem = __decorate([
|
|
@@ -1830,6 +2665,8 @@ function inlineResolveSpecialViews(name, c, game, go) {
|
|
|
1830
2665
|
case 'ProgressBar':
|
|
1831
2666
|
c.__resolved_bg = resolveViewRef(game, go, c.bgView);
|
|
1832
2667
|
c.__resolved_fill = resolveViewRef(game, go, c.fillView);
|
|
2668
|
+
c.__resolved_bg_view = c.nineSliceSprite && c.bgView && 'texture' in c.bgView ? c.bgView.texture : c.__resolved_bg;
|
|
2669
|
+
c.__resolved_fill_view = c.nineSliceSprite && c.fillView && 'texture' in c.fillView ? c.fillView.texture : c.__resolved_fill;
|
|
1833
2670
|
break;
|
|
1834
2671
|
case 'Select':
|
|
1835
2672
|
c.__resolved_closedView = resolveViewRef(game, go, c.closedView);
|
|
@@ -1838,10 +2675,15 @@ function inlineResolveSpecialViews(name, c, game, go) {
|
|
|
1838
2675
|
case 'Dialog':
|
|
1839
2676
|
c.__resolved_backdropView = resolveViewRef(game, go, c.backdropView);
|
|
1840
2677
|
c.__resolved_backgroundView = resolveViewRef(game, go, c.backgroundView);
|
|
2678
|
+
c.__resolved_background_view = c.nineSliceSprite && c.backgroundView && 'texture' in c.backgroundView
|
|
2679
|
+
? c.backgroundView.texture
|
|
2680
|
+
: c.__resolved_backgroundView;
|
|
1841
2681
|
break;
|
|
1842
2682
|
case 'MaskedFrame':
|
|
1843
2683
|
c.__resolved_targetView = resolveViewRef(game, go, c.targetView);
|
|
1844
2684
|
c.__resolved_maskView = resolveViewRef(game, go, c.maskView);
|
|
2685
|
+
c.__resolved_target_view = c.targetView && 'texture' in c.targetView ? c.targetView.texture : c.__resolved_targetView;
|
|
2686
|
+
c.__resolved_mask_view = c.maskView && 'texture' in c.maskView ? c.maskView.texture : c.__resolved_maskView;
|
|
1845
2687
|
break;
|
|
1846
2688
|
}
|
|
1847
2689
|
}
|
|
@@ -1849,14 +2691,14 @@ function inlineResolveSpecialViews(name, c, game, go) {
|
|
|
1849
2691
|
function validateInlineResolved(name, c) {
|
|
1850
2692
|
switch (name) {
|
|
1851
2693
|
case 'ProgressBar':
|
|
1852
|
-
return !!(c.
|
|
2694
|
+
return !!(c.__resolved_bg_view && c.__resolved_fill_view);
|
|
1853
2695
|
case 'Select':
|
|
1854
2696
|
return !!(c.__resolved_closedView && c.__resolved_openView);
|
|
1855
2697
|
case 'Dialog':
|
|
1856
2698
|
// backgroundView 可 fallback PixiContainer,backdropView 也可 null
|
|
1857
2699
|
return true;
|
|
1858
2700
|
case 'MaskedFrame':
|
|
1859
|
-
return !!(c.
|
|
2701
|
+
return !!(c.__resolved_target_view && c.__resolved_mask_view);
|
|
1860
2702
|
default:
|
|
1861
2703
|
return true;
|
|
1862
2704
|
}
|
|
@@ -1874,15 +2716,47 @@ function collectChildContainers(game, go, childName) {
|
|
|
1874
2716
|
continue;
|
|
1875
2717
|
const childContainer = getEvaContainer(game, child);
|
|
1876
2718
|
if (childContainer) {
|
|
2719
|
+
if (childContainer.width <= 0 || childContainer.height <= 0)
|
|
2720
|
+
continue;
|
|
1877
2721
|
try {
|
|
1878
2722
|
(_c = (_b = childContainer.parent) === null || _b === void 0 ? void 0 : _b.removeChild) === null || _c === void 0 ? void 0 : _c.call(_b, childContainer);
|
|
1879
2723
|
}
|
|
1880
2724
|
catch (_) { }
|
|
1881
|
-
result.push(childContainer);
|
|
2725
|
+
result.push(wrapLayoutItem(childContainer, child));
|
|
1882
2726
|
}
|
|
1883
2727
|
}
|
|
1884
2728
|
return result;
|
|
1885
2729
|
}
|
|
2730
|
+
function wrapLayoutItem(childContainer, child) {
|
|
2731
|
+
const wrapper = new pixi_js.Container();
|
|
2732
|
+
const childName = child === null || child === void 0 ? void 0 : child.name;
|
|
2733
|
+
wrapper.label = childName ? `${childName}:layout-item` : 'plugin-ui-layout-item';
|
|
2734
|
+
wrapper.addChild(childContainer);
|
|
2735
|
+
Object.defineProperty(wrapper, 'width', {
|
|
2736
|
+
get: () => resolveLayoutItemSize(child, childContainer, 'width'),
|
|
2737
|
+
set: () => { },
|
|
2738
|
+
configurable: true,
|
|
2739
|
+
});
|
|
2740
|
+
Object.defineProperty(wrapper, 'height', {
|
|
2741
|
+
get: () => resolveLayoutItemSize(child, childContainer, 'height'),
|
|
2742
|
+
set: () => { },
|
|
2743
|
+
configurable: true,
|
|
2744
|
+
});
|
|
2745
|
+
return wrapper;
|
|
2746
|
+
}
|
|
2747
|
+
function resolveLayoutItemSize(child, childContainer, key) {
|
|
2748
|
+
var _a, _b;
|
|
2749
|
+
const transformSize = Number((_b = (_a = child === null || child === void 0 ? void 0 : child.transform) === null || _a === void 0 ? void 0 : _a.size) === null || _b === void 0 ? void 0 : _b[key]);
|
|
2750
|
+
if (Number.isFinite(transformSize) && transformSize > 0)
|
|
2751
|
+
return transformSize;
|
|
2752
|
+
const containerSize = Number(childContainer === null || childContainer === void 0 ? void 0 : childContainer[key]);
|
|
2753
|
+
return Number.isFinite(containerSize) ? containerSize : 0;
|
|
2754
|
+
}
|
|
2755
|
+
function getCollectedChildCount(go, childName) {
|
|
2756
|
+
var _a, _b, _c;
|
|
2757
|
+
const contentChild = findChildEntity(go, childName);
|
|
2758
|
+
return (_c = (_b = (_a = contentChild === null || contentChild === void 0 ? void 0 : contentChild.transform) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
2759
|
+
}
|
|
1886
2760
|
function findChildEntity(go, name) {
|
|
1887
2761
|
var _a, _b;
|
|
1888
2762
|
if (!go)
|
|
@@ -1901,6 +2775,15 @@ function findChildEntity(go, name) {
|
|
|
1901
2775
|
return tf.gameObject;
|
|
1902
2776
|
}
|
|
1903
2777
|
return null;
|
|
2778
|
+
}
|
|
2779
|
+
function getComponentSafe(go, componentName) {
|
|
2780
|
+
var _a;
|
|
2781
|
+
try {
|
|
2782
|
+
return (_a = go === null || go === void 0 ? void 0 : go.getComponent) === null || _a === void 0 ? void 0 : _a.call(go, componentName);
|
|
2783
|
+
}
|
|
2784
|
+
catch (_) {
|
|
2785
|
+
return undefined;
|
|
2786
|
+
}
|
|
1904
2787
|
}
|
|
1905
2788
|
|
|
1906
2789
|
exports.Button = Button;
|
|
@@ -1919,8 +2802,10 @@ exports.ProgressBar = ProgressBar;
|
|
|
1919
2802
|
exports.RadioGroup = RadioGroup;
|
|
1920
2803
|
exports.ScrollBox = ScrollBox;
|
|
1921
2804
|
exports.Select = Select;
|
|
2805
|
+
exports.Shape = Shape;
|
|
1922
2806
|
exports.Slider = Slider;
|
|
1923
2807
|
exports.Switcher = Switcher;
|
|
1924
|
-
exports.UI =
|
|
2808
|
+
exports.UI = Shape;
|
|
2809
|
+
exports.UIShapeType = UIShapeType;
|
|
1925
2810
|
exports.UISystem = UISystem$1;
|
|
1926
2811
|
exports.defineUiComponent = defineUiComponent;
|