hudini 0.17.0 → 0.17.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 +34 -0
- package/dist/components/card/card.d.ts +9 -0
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/card.js +44 -8
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.spec.js +2 -7
- package/dist/components/card/card.spec.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/circular-progress.js +11 -2
- package/dist/components/circular-progress/circular-progress.js.map +1 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/panel/index.d.ts +2 -0
- package/dist/components/panel/index.d.ts.map +1 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/panel/index.js.map +1 -0
- package/dist/components/panel/panel.d.ts.map +1 -1
- package/dist/components/panel/panel.js +5 -2
- package/dist/components/panel/panel.js.map +1 -1
- package/dist/components/text-button/text-button.d.ts.map +1 -1
- package/dist/components/text-button/text-button.js +1 -1
- package/dist/components/text-button/text-button.js.map +1 -1
- package/dist/hudini.js +1078 -839
- package/dist/hudini.min.js +1 -1
- package/dist/test-setup.js +31 -2
- package/dist/test-setup.js.map +1 -1
- package/package.json +2 -2
- package/dist/components/column/column.d.ts +0 -88
- package/dist/components/column/column.d.ts.map +0 -1
- package/dist/components/column/column.js +0 -143
- package/dist/components/column/column.js.map +0 -1
- package/dist/components/column/column.spec.d.ts +0 -2
- package/dist/components/column/column.spec.d.ts.map +0 -1
- package/dist/components/column/column.spec.js +0 -114
- package/dist/components/column/column.spec.js.map +0 -1
- package/dist/components/column/index.d.ts +0 -2
- package/dist/components/column/index.d.ts.map +0 -1
- package/dist/components/column/index.js +0 -2
- package/dist/components/column/index.js.map +0 -1
- package/dist/components/layout/layout-utils.d.ts +0 -13
- package/dist/components/layout/layout-utils.d.ts.map +0 -1
- package/dist/components/layout/layout-utils.js +0 -96
- package/dist/components/layout/layout-utils.js.map +0 -1
- package/dist/components/layout/layout-utils.spec.d.ts +0 -2
- package/dist/components/layout/layout-utils.spec.d.ts.map +0 -1
- package/dist/components/layout/layout-utils.spec.js +0 -70
- package/dist/components/layout/layout-utils.spec.js.map +0 -1
- package/dist/components/row/index.d.ts +0 -2
- package/dist/components/row/index.d.ts.map +0 -1
- package/dist/components/row/index.js +0 -2
- package/dist/components/row/index.js.map +0 -1
- package/dist/components/row/row.d.ts +0 -87
- package/dist/components/row/row.d.ts.map +0 -1
- package/dist/components/row/row.js +0 -146
- package/dist/components/row/row.js.map +0 -1
- package/dist/components/row/row.spec.d.ts +0 -2
- package/dist/components/row/row.spec.d.ts.map +0 -1
- package/dist/components/row/row.spec.js +0 -114
- package/dist/components/row/row.spec.js.map +0 -1
package/dist/hudini.js
CHANGED
|
@@ -40,6 +40,387 @@
|
|
|
40
40
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
/** Default gap between elements in pixels */
|
|
44
|
+
const DEFAULT_GAP = 8;
|
|
45
|
+
/** Measures the display width of a game object, with fallbacks */
|
|
46
|
+
const getDisplayWidthOf = (child) => {
|
|
47
|
+
const childTyped = child;
|
|
48
|
+
// Check if it's a Container-like object (has list property and width/height)
|
|
49
|
+
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
50
|
+
if (typeof childTyped.displayWidth === 'number' && childTyped.displayWidth > 0) {
|
|
51
|
+
return childTyped.displayWidth;
|
|
52
|
+
}
|
|
53
|
+
if (typeof childTyped.width === 'number' && childTyped.width > 0) {
|
|
54
|
+
return childTyped.width;
|
|
55
|
+
}
|
|
56
|
+
const container = child;
|
|
57
|
+
if (typeof container.displayWidth === 'number' && container.displayWidth > 0) {
|
|
58
|
+
return container.displayWidth;
|
|
59
|
+
}
|
|
60
|
+
if (typeof container.width === 'number' && container.width > 0) {
|
|
61
|
+
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
62
|
+
return container.width / container.scale;
|
|
63
|
+
}
|
|
64
|
+
return container.width;
|
|
65
|
+
}
|
|
66
|
+
let w = 0;
|
|
67
|
+
for (const sub of container.list) {
|
|
68
|
+
const size = getDisplayWidthOf(sub);
|
|
69
|
+
w = Math.max(w, size);
|
|
70
|
+
}
|
|
71
|
+
return w;
|
|
72
|
+
}
|
|
73
|
+
if (typeof childTyped.displayWidth === 'number') {
|
|
74
|
+
return childTyped.displayWidth;
|
|
75
|
+
}
|
|
76
|
+
if (typeof childTyped.width === 'number') {
|
|
77
|
+
return childTyped.width;
|
|
78
|
+
}
|
|
79
|
+
const bounds = childTyped.getBounds?.();
|
|
80
|
+
return bounds ? bounds.width : 0;
|
|
81
|
+
};
|
|
82
|
+
/** Measures the display height of a game object, with fallbacks */
|
|
83
|
+
const getDisplayHeightOf = (child) => {
|
|
84
|
+
const childTyped = child;
|
|
85
|
+
// Check if it's a Container-like object (has list property and width/height)
|
|
86
|
+
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
87
|
+
if (typeof childTyped.displayHeight === 'number' && childTyped.displayHeight > 0) {
|
|
88
|
+
return childTyped.displayHeight;
|
|
89
|
+
}
|
|
90
|
+
if (typeof childTyped.height === 'number' && childTyped.height > 0) {
|
|
91
|
+
return childTyped.height;
|
|
92
|
+
}
|
|
93
|
+
const container = child;
|
|
94
|
+
if (typeof container.displayHeight === 'number' && container.displayHeight > 0) {
|
|
95
|
+
return container.displayHeight;
|
|
96
|
+
}
|
|
97
|
+
if (typeof container.height === 'number' && container.height > 0) {
|
|
98
|
+
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
99
|
+
return container.height / container.scale;
|
|
100
|
+
}
|
|
101
|
+
return container.height;
|
|
102
|
+
}
|
|
103
|
+
let h = 0;
|
|
104
|
+
for (const sub of container.list) {
|
|
105
|
+
const size = getDisplayHeightOf(sub);
|
|
106
|
+
h = Math.max(h, size);
|
|
107
|
+
}
|
|
108
|
+
return h;
|
|
109
|
+
}
|
|
110
|
+
if (typeof childTyped.displayHeight === 'number') {
|
|
111
|
+
return childTyped.displayHeight;
|
|
112
|
+
}
|
|
113
|
+
if (typeof childTyped.height === 'number') {
|
|
114
|
+
return childTyped.height;
|
|
115
|
+
}
|
|
116
|
+
const bounds = childTyped.getBounds?.();
|
|
117
|
+
return bounds ? bounds.height : 0;
|
|
118
|
+
};
|
|
119
|
+
/** Returns normalized origin (0..1) for a game object */
|
|
120
|
+
const getNormalizedOriginOf = (child) => {
|
|
121
|
+
const width = getDisplayWidthOf(child);
|
|
122
|
+
const height = getDisplayHeightOf(child);
|
|
123
|
+
const childTyped = child;
|
|
124
|
+
let ox = typeof childTyped.originX === 'number' ? childTyped.originX : undefined;
|
|
125
|
+
let oy = typeof childTyped.originY === 'number' ? childTyped.originY : undefined;
|
|
126
|
+
if (ox === undefined &&
|
|
127
|
+
typeof childTyped.displayOriginX === 'number' &&
|
|
128
|
+
width > 0) {
|
|
129
|
+
ox = childTyped.displayOriginX / width;
|
|
130
|
+
}
|
|
131
|
+
if (oy === undefined &&
|
|
132
|
+
typeof childTyped.displayOriginY === 'number' &&
|
|
133
|
+
height > 0) {
|
|
134
|
+
oy = childTyped.displayOriginY / height;
|
|
135
|
+
}
|
|
136
|
+
return { x: ox ?? 0.5, y: oy ?? 0.5 };
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/* eslint-disable max-lines-per-function */
|
|
140
|
+
/* eslint-disable complexity */
|
|
141
|
+
/**
|
|
142
|
+
* Column is a layout container that stacks children vertically with a gap.
|
|
143
|
+
* The container position (x, y) represents the center of the whole column.
|
|
144
|
+
*/
|
|
145
|
+
class Column extends Phaser$1.GameObjects.Container {
|
|
146
|
+
/** Gap between elements in pixels */
|
|
147
|
+
gap;
|
|
148
|
+
/** Horizontal alignment of elements */
|
|
149
|
+
align;
|
|
150
|
+
/** Vertical origin point of the column */
|
|
151
|
+
verticalOrigin;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a new Column container
|
|
154
|
+
* @param params Configuration parameters for the column
|
|
155
|
+
*/
|
|
156
|
+
constructor({ scene, x, y, gap = DEFAULT_GAP, align = 'center', children = [], verticalOrigin = 'center', }) {
|
|
157
|
+
super(scene, x, y);
|
|
158
|
+
this.gap = gap;
|
|
159
|
+
this.align = align;
|
|
160
|
+
this.verticalOrigin = verticalOrigin;
|
|
161
|
+
if (children.length > 0) {
|
|
162
|
+
this.add(children);
|
|
163
|
+
}
|
|
164
|
+
this.layout();
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Sets the spacing between children and relayouts
|
|
168
|
+
* @param gap Gap in pixels between elements
|
|
169
|
+
*/
|
|
170
|
+
setGap(gap) {
|
|
171
|
+
this.gap = gap;
|
|
172
|
+
this.layout();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets the horizontal alignment and relayouts
|
|
176
|
+
* @param align New horizontal alignment
|
|
177
|
+
*/
|
|
178
|
+
setAlign(align) {
|
|
179
|
+
this.align = align;
|
|
180
|
+
this.layout();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Adds a child game object to the column
|
|
184
|
+
* @param child Game object to add
|
|
185
|
+
* @param relayout Whether to relayout after adding (default: true)
|
|
186
|
+
* @returns This column instance for chaining
|
|
187
|
+
*/
|
|
188
|
+
addChild(child, relayout = true) {
|
|
189
|
+
this.add(child);
|
|
190
|
+
if (relayout)
|
|
191
|
+
this.layout();
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Adds multiple children to the column
|
|
196
|
+
* @param children Array of game objects to add
|
|
197
|
+
* @param relayout Whether to relayout after adding (default: true)
|
|
198
|
+
* @returns This column instance for chaining
|
|
199
|
+
*/
|
|
200
|
+
addChildren(children, relayout = true) {
|
|
201
|
+
if (children.length > 0)
|
|
202
|
+
this.add(children);
|
|
203
|
+
if (relayout)
|
|
204
|
+
this.layout();
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Recomputes children's positions and updates this container size
|
|
209
|
+
* Positions are calculated based on alignment, origins and gaps
|
|
210
|
+
*/
|
|
211
|
+
layout() {
|
|
212
|
+
const children = this.list;
|
|
213
|
+
if (children.length === 0) {
|
|
214
|
+
// Reset size when empty
|
|
215
|
+
this.setSize(0, 0);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// Measure sizes and origins
|
|
219
|
+
const entries = children.map((child) => ({
|
|
220
|
+
child,
|
|
221
|
+
width: this.getDisplayWidth(child),
|
|
222
|
+
height: this.getDisplayHeight(child),
|
|
223
|
+
origin: this.getNormalizedOrigin(child),
|
|
224
|
+
}));
|
|
225
|
+
const maxWidth = entries.reduce((m, s) => Math.max(m, s.width), 0);
|
|
226
|
+
const totalHeight = entries.reduce((sum, s) => sum + s.height, 0) + this.gap * (entries.length - 1);
|
|
227
|
+
// Determine top of content based on verticalOrigin
|
|
228
|
+
const contentTopY = this.verticalOrigin === 'top' ? 0 : this.verticalOrigin === 'center' ? -totalHeight / 2 : -totalHeight;
|
|
229
|
+
// Walk from top to bottom, aligning considering each child's origin
|
|
230
|
+
let cursorTopY = contentTopY;
|
|
231
|
+
for (const { child, width, height, origin } of entries) {
|
|
232
|
+
// Horizontal alignment: align left/right edges or centers correctly using origin
|
|
233
|
+
let x = 0;
|
|
234
|
+
if (this.align === 'left') {
|
|
235
|
+
// place child's left edge at content left
|
|
236
|
+
x = -maxWidth / 2 + origin.x * width;
|
|
237
|
+
}
|
|
238
|
+
else if (this.align === 'right') {
|
|
239
|
+
// place child's right edge at content right
|
|
240
|
+
x = maxWidth / 2 - (1 - origin.x) * width;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
// center alignment: center of child at 0 accounting for origin
|
|
244
|
+
x = (origin.x - 0.5) * width;
|
|
245
|
+
}
|
|
246
|
+
// Vertical position so that child's top is at cursorTopY
|
|
247
|
+
const y = cursorTopY + origin.y * height;
|
|
248
|
+
child.setPosition(x, y);
|
|
249
|
+
cursorTopY += height + this.gap;
|
|
250
|
+
}
|
|
251
|
+
// Update this container size to match content bounds
|
|
252
|
+
this.setSize(maxWidth, totalHeight);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets the display width of a game object
|
|
256
|
+
* @param child GameObject to measure
|
|
257
|
+
* @returns Display width in pixels
|
|
258
|
+
*/
|
|
259
|
+
getDisplayWidth(child) {
|
|
260
|
+
return getDisplayWidthOf(child);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Gets the display height of a game object
|
|
264
|
+
* @param child GameObject to measure
|
|
265
|
+
* @returns Display height in pixels
|
|
266
|
+
*/
|
|
267
|
+
getDisplayHeight(child) {
|
|
268
|
+
return getDisplayHeightOf(child);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Gets the normalized origin point of a game object
|
|
272
|
+
* @param child GameObject to get origin from
|
|
273
|
+
* @returns Object with normalized x,y coordinates of the origin point
|
|
274
|
+
*/
|
|
275
|
+
getNormalizedOrigin(child) {
|
|
276
|
+
return getNormalizedOriginOf(child);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/* eslint-disable max-lines-per-function */
|
|
281
|
+
/* eslint-disable complexity */
|
|
282
|
+
/**
|
|
283
|
+
* Row is a layout container that arranges children horizontally with a gap.
|
|
284
|
+
* The container position (x, y) represents the center of the whole row.
|
|
285
|
+
*/
|
|
286
|
+
class Row extends Phaser$1.GameObjects.Container {
|
|
287
|
+
/** Gap between elements in pixels */
|
|
288
|
+
gap;
|
|
289
|
+
/** Vertical alignment of elements */
|
|
290
|
+
align;
|
|
291
|
+
/** Horizontal origin point of the row */
|
|
292
|
+
horizontalOrigin;
|
|
293
|
+
/**
|
|
294
|
+
* Creates a new Row container
|
|
295
|
+
* @param params Configuration parameters for the row
|
|
296
|
+
*/
|
|
297
|
+
constructor({ scene, x, y, gap = DEFAULT_GAP, align = 'center', children = [], horizontalOrigin = 'center', }) {
|
|
298
|
+
super(scene, x, y);
|
|
299
|
+
this.gap = gap;
|
|
300
|
+
this.align = align;
|
|
301
|
+
this.horizontalOrigin = horizontalOrigin;
|
|
302
|
+
if (children.length > 0) {
|
|
303
|
+
this.add(children);
|
|
304
|
+
}
|
|
305
|
+
this.layout();
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Sets the gap between elements and updates layout
|
|
309
|
+
* @param gap Gap size in pixels
|
|
310
|
+
*/
|
|
311
|
+
setGap(gap) {
|
|
312
|
+
this.gap = gap;
|
|
313
|
+
this.layout();
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Sets the vertical alignment and updates layout
|
|
317
|
+
* @param align New vertical alignment
|
|
318
|
+
*/
|
|
319
|
+
setAlign(align) {
|
|
320
|
+
this.align = align;
|
|
321
|
+
this.layout();
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Adds a single child to the row
|
|
325
|
+
* @param child GameObject to add
|
|
326
|
+
* @param relayout Whether to update layout after adding
|
|
327
|
+
* @returns This row instance for chaining
|
|
328
|
+
*/
|
|
329
|
+
addChild(child, relayout = true) {
|
|
330
|
+
this.add(child);
|
|
331
|
+
if (relayout) {
|
|
332
|
+
this.layout();
|
|
333
|
+
}
|
|
334
|
+
return this;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Adds multiple children to the row
|
|
338
|
+
* @param children Array of GameObjects to add
|
|
339
|
+
* @param relayout Whether to update layout after adding
|
|
340
|
+
* @returns This row instance for chaining
|
|
341
|
+
*/
|
|
342
|
+
addChildren(children, relayout = true) {
|
|
343
|
+
if (children.length > 0)
|
|
344
|
+
this.add(children);
|
|
345
|
+
if (relayout)
|
|
346
|
+
this.layout();
|
|
347
|
+
return this;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Recomputes children's positions and updates this container size
|
|
351
|
+
*/
|
|
352
|
+
layout() {
|
|
353
|
+
const children = this.list;
|
|
354
|
+
if (children.length === 0) {
|
|
355
|
+
this.setSize(0, 0);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
// Measure sizes and origins
|
|
359
|
+
const entries = children.map(child => ({
|
|
360
|
+
child,
|
|
361
|
+
width: this.getDisplayWidth(child),
|
|
362
|
+
height: this.getDisplayHeight(child),
|
|
363
|
+
origin: this.getNormalizedOrigin(child),
|
|
364
|
+
}));
|
|
365
|
+
const maxHeight = entries.reduce((m, s) => Math.max(m, s.height), 0);
|
|
366
|
+
const totalWidth = entries.reduce((sum, s) => sum + s.width, 0) +
|
|
367
|
+
this.gap * (entries.length - 1);
|
|
368
|
+
// Determine left of content based on horizontalOrigin
|
|
369
|
+
const contentLeftX = this.horizontalOrigin === 'left'
|
|
370
|
+
? 0
|
|
371
|
+
: this.horizontalOrigin === 'center'
|
|
372
|
+
? -totalWidth / 2
|
|
373
|
+
: -totalWidth;
|
|
374
|
+
// Walk left to right, aligning considering each child's origin
|
|
375
|
+
let cursorLeftX = contentLeftX;
|
|
376
|
+
for (const { child, width, height, origin } of entries) {
|
|
377
|
+
// Vertical alignment: align top/bottom edges or centers correctly using origin
|
|
378
|
+
let y = 0;
|
|
379
|
+
if (this.align === 'top') {
|
|
380
|
+
// place child's top edge at content top
|
|
381
|
+
y = -maxHeight / 2 + origin.y * height;
|
|
382
|
+
}
|
|
383
|
+
else if (this.align === 'bottom') {
|
|
384
|
+
// place child's bottom edge at content bottom
|
|
385
|
+
y = maxHeight / 2 - (1 - origin.y) * height;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
// center alignment
|
|
389
|
+
y = (origin.y - 0.5) * height;
|
|
390
|
+
}
|
|
391
|
+
// Horizontal position so that child's left is at cursorLeftX
|
|
392
|
+
const x = cursorLeftX + origin.x * width;
|
|
393
|
+
child.setPosition(x, y);
|
|
394
|
+
cursorLeftX += width + this.gap;
|
|
395
|
+
}
|
|
396
|
+
this.setSize(totalWidth, maxHeight);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Gets the display width of a game object
|
|
400
|
+
* @param child GameObject to measure
|
|
401
|
+
* @returns Display width in pixels
|
|
402
|
+
*/
|
|
403
|
+
getDisplayWidth(child) {
|
|
404
|
+
return getDisplayWidthOf(child);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Gets the display height of a game object
|
|
408
|
+
* @param child GameObject to measure
|
|
409
|
+
* @returns Display height in pixels
|
|
410
|
+
*/
|
|
411
|
+
getDisplayHeight(child) {
|
|
412
|
+
return getDisplayHeightOf(child);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Gets the normalized origin point of a game object
|
|
416
|
+
* @param child GameObject to get origin from
|
|
417
|
+
* @returns Object with normalized x,y coordinates of the origin point
|
|
418
|
+
*/
|
|
419
|
+
getNormalizedOrigin(child) {
|
|
420
|
+
return getNormalizedOriginOf(child);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
43
424
|
/**
|
|
44
425
|
* Deep merge utility function that recursively merges objects
|
|
45
426
|
* Similar to lodash.merge but implemented natively
|
|
@@ -1149,106 +1530,6 @@
|
|
|
1149
1530
|
return scene.pw;
|
|
1150
1531
|
};
|
|
1151
1532
|
|
|
1152
|
-
/** Default gap between elements in pixels */
|
|
1153
|
-
var DEFAULT_GAP = 8;
|
|
1154
|
-
/** Measures the display width of a game object, with fallbacks */
|
|
1155
|
-
var getDisplayWidthOf = function (child) {
|
|
1156
|
-
var _a;
|
|
1157
|
-
var childTyped = child;
|
|
1158
|
-
// Check if it's a Container-like object (has list property and width/height)
|
|
1159
|
-
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
1160
|
-
if (typeof childTyped.displayWidth === 'number' && childTyped.displayWidth > 0) {
|
|
1161
|
-
return childTyped.displayWidth;
|
|
1162
|
-
}
|
|
1163
|
-
if (typeof childTyped.width === 'number' && childTyped.width > 0) {
|
|
1164
|
-
return childTyped.width;
|
|
1165
|
-
}
|
|
1166
|
-
var container = child;
|
|
1167
|
-
if (typeof container.displayWidth === 'number' && container.displayWidth > 0) {
|
|
1168
|
-
return container.displayWidth;
|
|
1169
|
-
}
|
|
1170
|
-
if (typeof container.width === 'number' && container.width > 0) {
|
|
1171
|
-
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
1172
|
-
return container.width / container.scale;
|
|
1173
|
-
}
|
|
1174
|
-
return container.width;
|
|
1175
|
-
}
|
|
1176
|
-
var w = 0;
|
|
1177
|
-
for (var _i = 0, _b = container.list; _i < _b.length; _i++) {
|
|
1178
|
-
var sub = _b[_i];
|
|
1179
|
-
var size = getDisplayWidthOf(sub);
|
|
1180
|
-
w = Math.max(w, size);
|
|
1181
|
-
}
|
|
1182
|
-
return w;
|
|
1183
|
-
}
|
|
1184
|
-
if (typeof childTyped.displayWidth === 'number') {
|
|
1185
|
-
return childTyped.displayWidth;
|
|
1186
|
-
}
|
|
1187
|
-
if (typeof childTyped.width === 'number') {
|
|
1188
|
-
return childTyped.width;
|
|
1189
|
-
}
|
|
1190
|
-
var bounds = (_a = childTyped.getBounds) === null || _a === void 0 ? void 0 : _a.call(childTyped);
|
|
1191
|
-
return bounds ? bounds.width : 0;
|
|
1192
|
-
};
|
|
1193
|
-
/** Measures the display height of a game object, with fallbacks */
|
|
1194
|
-
var getDisplayHeightOf = function (child) {
|
|
1195
|
-
var _a;
|
|
1196
|
-
var childTyped = child;
|
|
1197
|
-
// Check if it's a Container-like object (has list property and width/height)
|
|
1198
|
-
if (child && typeof child === 'object' && 'list' in child && Array.isArray(child.list)) {
|
|
1199
|
-
if (typeof childTyped.displayHeight === 'number' && childTyped.displayHeight > 0) {
|
|
1200
|
-
return childTyped.displayHeight;
|
|
1201
|
-
}
|
|
1202
|
-
if (typeof childTyped.height === 'number' && childTyped.height > 0) {
|
|
1203
|
-
return childTyped.height;
|
|
1204
|
-
}
|
|
1205
|
-
var container = child;
|
|
1206
|
-
if (typeof container.displayHeight === 'number' && container.displayHeight > 0) {
|
|
1207
|
-
return container.displayHeight;
|
|
1208
|
-
}
|
|
1209
|
-
if (typeof container.height === 'number' && container.height > 0) {
|
|
1210
|
-
if (typeof container.scale === 'number' && container.scale > 0) {
|
|
1211
|
-
return container.height / container.scale;
|
|
1212
|
-
}
|
|
1213
|
-
return container.height;
|
|
1214
|
-
}
|
|
1215
|
-
var h = 0;
|
|
1216
|
-
for (var _i = 0, _b = container.list; _i < _b.length; _i++) {
|
|
1217
|
-
var sub = _b[_i];
|
|
1218
|
-
var size = getDisplayHeightOf(sub);
|
|
1219
|
-
h = Math.max(h, size);
|
|
1220
|
-
}
|
|
1221
|
-
return h;
|
|
1222
|
-
}
|
|
1223
|
-
if (typeof childTyped.displayHeight === 'number') {
|
|
1224
|
-
return childTyped.displayHeight;
|
|
1225
|
-
}
|
|
1226
|
-
if (typeof childTyped.height === 'number') {
|
|
1227
|
-
return childTyped.height;
|
|
1228
|
-
}
|
|
1229
|
-
var bounds = (_a = childTyped.getBounds) === null || _a === void 0 ? void 0 : _a.call(childTyped);
|
|
1230
|
-
return bounds ? bounds.height : 0;
|
|
1231
|
-
};
|
|
1232
|
-
/** Returns normalized origin (0..1) for a game object */
|
|
1233
|
-
var getNormalizedOriginOf = function (child) {
|
|
1234
|
-
var width = getDisplayWidthOf(child);
|
|
1235
|
-
var height = getDisplayHeightOf(child);
|
|
1236
|
-
var childTyped = child;
|
|
1237
|
-
var ox = typeof childTyped.originX === 'number' ? childTyped.originX : undefined;
|
|
1238
|
-
var oy = typeof childTyped.originY === 'number' ? childTyped.originY : undefined;
|
|
1239
|
-
if (ox === undefined &&
|
|
1240
|
-
typeof childTyped.displayOriginX === 'number' &&
|
|
1241
|
-
width > 0) {
|
|
1242
|
-
ox = childTyped.displayOriginX / width;
|
|
1243
|
-
}
|
|
1244
|
-
if (oy === undefined &&
|
|
1245
|
-
typeof childTyped.displayOriginY === 'number' &&
|
|
1246
|
-
height > 0) {
|
|
1247
|
-
oy = childTyped.displayOriginY / height;
|
|
1248
|
-
}
|
|
1249
|
-
return { x: ox !== null && ox !== void 0 ? ox : 0.5, y: oy !== null && oy !== void 0 ? oy : 0.5 };
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
1533
|
/**
|
|
1253
1534
|
* A flexible card component that adapts to its child content size
|
|
1254
1535
|
*/
|
|
@@ -1261,6 +1542,8 @@
|
|
|
1261
1542
|
function Card(_a) {
|
|
1262
1543
|
var scene = _a.scene, x = _a.x, y = _a.y, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? 'white' : _b, _c = _a.borderRadius, borderRadius = _c === void 0 ? 'md' : _c, _d = _a.margin, margin = _d === void 0 ? '4' : _d, child = _a.child, width = _a.width, height = _a.height;
|
|
1263
1544
|
var _this = _super.call(this, scene, x, y) || this;
|
|
1545
|
+
/** Whether we have an explicit size set (width and height provided) */
|
|
1546
|
+
_this.hasExplicitSize = false;
|
|
1264
1547
|
_this.pw = getPWFromScene(scene);
|
|
1265
1548
|
// Store values
|
|
1266
1549
|
_this.marginPx =
|
|
@@ -1274,11 +1557,29 @@
|
|
|
1274
1557
|
_this.backgroundColorValue = Color.rgb(backgroundColor);
|
|
1275
1558
|
// Store child reference
|
|
1276
1559
|
_this.child = child;
|
|
1560
|
+
// Check if explicit size was provided
|
|
1561
|
+
_this.hasExplicitSize = width !== undefined && height !== undefined;
|
|
1277
1562
|
// Create background and setup container
|
|
1278
1563
|
_this.createBackgroundGraphics(scene, width, height);
|
|
1279
1564
|
_this.setupContainer();
|
|
1280
1565
|
return _this;
|
|
1281
1566
|
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Override setSize to redraw background when size changes
|
|
1569
|
+
* @param width Width in pixels
|
|
1570
|
+
* @param height Height in pixels
|
|
1571
|
+
* @returns this for chaining
|
|
1572
|
+
*/
|
|
1573
|
+
Card.prototype.setSize = function (width, height) {
|
|
1574
|
+
// Mark that we now have explicit size
|
|
1575
|
+
this.hasExplicitSize = true;
|
|
1576
|
+
// Set size directly on the container to avoid recursion
|
|
1577
|
+
this.width = width;
|
|
1578
|
+
this.height = height;
|
|
1579
|
+
// Redraw background with new size
|
|
1580
|
+
this.drawBackground(width, height);
|
|
1581
|
+
return this;
|
|
1582
|
+
};
|
|
1282
1583
|
/**
|
|
1283
1584
|
* Sets the width of the card. Useful when you want to set a fixed width without a child component.
|
|
1284
1585
|
* @param width Width in pixels
|
|
@@ -1365,7 +1666,10 @@
|
|
|
1365
1666
|
if (this.child) {
|
|
1366
1667
|
this.add([this.child]);
|
|
1367
1668
|
}
|
|
1368
|
-
|
|
1669
|
+
// Only call layout if we don't have explicit size
|
|
1670
|
+
if (!this.hasExplicitSize) {
|
|
1671
|
+
this.layout();
|
|
1672
|
+
}
|
|
1369
1673
|
};
|
|
1370
1674
|
/**
|
|
1371
1675
|
* Updates the layout after property changes
|
|
@@ -1384,10 +1688,13 @@
|
|
|
1384
1688
|
// Calculate child position considering its origin
|
|
1385
1689
|
var childX = this.calculateChildX(cardWidth, childBounds.width, childOrigin);
|
|
1386
1690
|
var childY = this.calculateChildY(cardHeight, childBounds.height, childOrigin);
|
|
1691
|
+
// Set size directly (don't use setSize to avoid marking as explicit size)
|
|
1692
|
+
this.width = cardWidth;
|
|
1693
|
+
this.height = cardHeight;
|
|
1694
|
+
// Redraw background with new dimensions
|
|
1695
|
+
this.drawBackground(cardWidth, cardHeight);
|
|
1387
1696
|
// Position child in the center of the card
|
|
1388
1697
|
this.child.setPosition(childX, childY);
|
|
1389
|
-
// Redraw background with new dimensions
|
|
1390
|
-
this.drawBackground();
|
|
1391
1698
|
};
|
|
1392
1699
|
/**
|
|
1393
1700
|
* Gets the child's origin if it exists
|
|
@@ -1468,10 +1775,21 @@
|
|
|
1468
1775
|
height = h;
|
|
1469
1776
|
}
|
|
1470
1777
|
else {
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1778
|
+
// If no explicit size provided and we have a child, measure it
|
|
1779
|
+
if (this.child) {
|
|
1780
|
+
var _b = this.measureChild(this.child), cw = _b.w, ch = _b.h;
|
|
1781
|
+
width = cw + this.marginPx * 2;
|
|
1782
|
+
height = ch + this.marginPx * 2;
|
|
1783
|
+
}
|
|
1784
|
+
else {
|
|
1785
|
+
// If no child and no explicit size, use current size
|
|
1786
|
+
width = this.width;
|
|
1787
|
+
height = this.height;
|
|
1788
|
+
}
|
|
1474
1789
|
}
|
|
1790
|
+
// Set size directly to avoid recursion (since we override setSize)
|
|
1791
|
+
this.width = width;
|
|
1792
|
+
this.height = height;
|
|
1475
1793
|
this.backgroundGraphics.clear();
|
|
1476
1794
|
// Limit radius to maximum possible for the card dimensions
|
|
1477
1795
|
var maxRadius = Math.min(width / 2, height / 2);
|
|
@@ -3584,6 +3902,16 @@
|
|
|
3584
3902
|
configurable: true
|
|
3585
3903
|
});
|
|
3586
3904
|
CircularProgress.prototype.createIconText = function (scene, icon, size, color) {
|
|
3905
|
+
// Convert color to ColorToken if it's just a ColorKey
|
|
3906
|
+
// 'black' and 'white' are already ColorTokens, and colors with '-' are already ColorTokens
|
|
3907
|
+
var colorToken;
|
|
3908
|
+
if (color === 'black' || color === 'white' || color.includes('-')) {
|
|
3909
|
+
colorToken = color;
|
|
3910
|
+
}
|
|
3911
|
+
else {
|
|
3912
|
+
// Default to -500 shade for ColorKey
|
|
3913
|
+
colorToken = "".concat(color, "-500");
|
|
3914
|
+
}
|
|
3587
3915
|
this.iconText = new IconText({
|
|
3588
3916
|
scene: scene,
|
|
3589
3917
|
x: 0,
|
|
@@ -3591,7 +3919,7 @@
|
|
|
3591
3919
|
icon: icon,
|
|
3592
3920
|
size: size,
|
|
3593
3921
|
style: {
|
|
3594
|
-
color:
|
|
3922
|
+
color: this.pw.color.rgb(colorToken),
|
|
3595
3923
|
},
|
|
3596
3924
|
});
|
|
3597
3925
|
this.iconText.setOrigin(0.5, 0.5);
|
|
@@ -3626,147 +3954,6 @@
|
|
|
3626
3954
|
return CircularProgress;
|
|
3627
3955
|
}(Phaser$1.GameObjects.Container));
|
|
3628
3956
|
|
|
3629
|
-
/**
|
|
3630
|
-
* Column is a layout container that stacks children vertically with a gap.
|
|
3631
|
-
* The container position (x, y) represents the center of the whole column.
|
|
3632
|
-
*/
|
|
3633
|
-
var Column = /** @class */ (function (_super) {
|
|
3634
|
-
__extends(Column, _super);
|
|
3635
|
-
/**
|
|
3636
|
-
* Creates a new Column container
|
|
3637
|
-
* @param params Configuration parameters for the column
|
|
3638
|
-
*/
|
|
3639
|
-
function Column(_a) {
|
|
3640
|
-
var scene = _a.scene, x = _a.x, y = _a.y, _b = _a.gap, gap = _b === void 0 ? DEFAULT_GAP : _b, _c = _a.align, align = _c === void 0 ? 'center' : _c, _d = _a.children, children = _d === void 0 ? [] : _d, _e = _a.verticalOrigin, verticalOrigin = _e === void 0 ? 'center' : _e;
|
|
3641
|
-
var _this = _super.call(this, scene, x, y) || this;
|
|
3642
|
-
_this.gap = gap;
|
|
3643
|
-
_this.align = align;
|
|
3644
|
-
_this.verticalOrigin = verticalOrigin;
|
|
3645
|
-
if (children.length > 0) {
|
|
3646
|
-
_this.add(children);
|
|
3647
|
-
}
|
|
3648
|
-
_this.layout();
|
|
3649
|
-
return _this;
|
|
3650
|
-
}
|
|
3651
|
-
/**
|
|
3652
|
-
* Sets the spacing between children and relayouts
|
|
3653
|
-
* @param gap Gap in pixels between elements
|
|
3654
|
-
*/
|
|
3655
|
-
Column.prototype.setGap = function (gap) {
|
|
3656
|
-
this.gap = gap;
|
|
3657
|
-
this.layout();
|
|
3658
|
-
};
|
|
3659
|
-
/**
|
|
3660
|
-
* Sets the horizontal alignment and relayouts
|
|
3661
|
-
* @param align New horizontal alignment
|
|
3662
|
-
*/
|
|
3663
|
-
Column.prototype.setAlign = function (align) {
|
|
3664
|
-
this.align = align;
|
|
3665
|
-
this.layout();
|
|
3666
|
-
};
|
|
3667
|
-
/**
|
|
3668
|
-
* Adds a child game object to the column
|
|
3669
|
-
* @param child Game object to add
|
|
3670
|
-
* @param relayout Whether to relayout after adding (default: true)
|
|
3671
|
-
* @returns This column instance for chaining
|
|
3672
|
-
*/
|
|
3673
|
-
Column.prototype.addChild = function (child, relayout) {
|
|
3674
|
-
if (relayout === void 0) { relayout = true; }
|
|
3675
|
-
this.add(child);
|
|
3676
|
-
if (relayout)
|
|
3677
|
-
this.layout();
|
|
3678
|
-
return this;
|
|
3679
|
-
};
|
|
3680
|
-
/**
|
|
3681
|
-
* Adds multiple children to the column
|
|
3682
|
-
* @param children Array of game objects to add
|
|
3683
|
-
* @param relayout Whether to relayout after adding (default: true)
|
|
3684
|
-
* @returns This column instance for chaining
|
|
3685
|
-
*/
|
|
3686
|
-
Column.prototype.addChildren = function (children, relayout) {
|
|
3687
|
-
if (relayout === void 0) { relayout = true; }
|
|
3688
|
-
if (children.length > 0)
|
|
3689
|
-
this.add(children);
|
|
3690
|
-
if (relayout)
|
|
3691
|
-
this.layout();
|
|
3692
|
-
return this;
|
|
3693
|
-
};
|
|
3694
|
-
/**
|
|
3695
|
-
* Recomputes children's positions and updates this container size
|
|
3696
|
-
* Positions are calculated based on alignment, origins and gaps
|
|
3697
|
-
*/
|
|
3698
|
-
Column.prototype.layout = function () {
|
|
3699
|
-
var _this = this;
|
|
3700
|
-
var children = this.list;
|
|
3701
|
-
if (children.length === 0) {
|
|
3702
|
-
// Reset size when empty
|
|
3703
|
-
this.setSize(0, 0);
|
|
3704
|
-
return;
|
|
3705
|
-
}
|
|
3706
|
-
// Measure sizes and origins
|
|
3707
|
-
var entries = children.map(function (child) { return ({
|
|
3708
|
-
child: child,
|
|
3709
|
-
width: _this.getDisplayWidth(child),
|
|
3710
|
-
height: _this.getDisplayHeight(child),
|
|
3711
|
-
origin: _this.getNormalizedOrigin(child),
|
|
3712
|
-
}); });
|
|
3713
|
-
var maxWidth = entries.reduce(function (m, s) { return Math.max(m, s.width); }, 0);
|
|
3714
|
-
var totalHeight = entries.reduce(function (sum, s) { return sum + s.height; }, 0) + this.gap * (entries.length - 1);
|
|
3715
|
-
// Determine top of content based on verticalOrigin
|
|
3716
|
-
var contentTopY = this.verticalOrigin === 'top' ? 0 : this.verticalOrigin === 'center' ? -totalHeight / 2 : -totalHeight;
|
|
3717
|
-
// Walk from top to bottom, aligning considering each child's origin
|
|
3718
|
-
var cursorTopY = contentTopY;
|
|
3719
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
3720
|
-
var _a = entries_1[_i], child = _a.child, width = _a.width, height = _a.height, origin_1 = _a.origin;
|
|
3721
|
-
// Horizontal alignment: align left/right edges or centers correctly using origin
|
|
3722
|
-
var x = 0;
|
|
3723
|
-
if (this.align === 'left') {
|
|
3724
|
-
// place child's left edge at content left
|
|
3725
|
-
x = -maxWidth / 2 + origin_1.x * width;
|
|
3726
|
-
}
|
|
3727
|
-
else if (this.align === 'right') {
|
|
3728
|
-
// place child's right edge at content right
|
|
3729
|
-
x = maxWidth / 2 - (1 - origin_1.x) * width;
|
|
3730
|
-
}
|
|
3731
|
-
else {
|
|
3732
|
-
// center alignment: center of child at 0 accounting for origin
|
|
3733
|
-
x = (origin_1.x - 0.5) * width;
|
|
3734
|
-
}
|
|
3735
|
-
// Vertical position so that child's top is at cursorTopY
|
|
3736
|
-
var y = cursorTopY + origin_1.y * height;
|
|
3737
|
-
child.setPosition(x, y);
|
|
3738
|
-
cursorTopY += height + this.gap;
|
|
3739
|
-
}
|
|
3740
|
-
// Update this container size to match content bounds
|
|
3741
|
-
this.setSize(maxWidth, totalHeight);
|
|
3742
|
-
};
|
|
3743
|
-
/**
|
|
3744
|
-
* Gets the display width of a game object
|
|
3745
|
-
* @param child GameObject to measure
|
|
3746
|
-
* @returns Display width in pixels
|
|
3747
|
-
*/
|
|
3748
|
-
Column.prototype.getDisplayWidth = function (child) {
|
|
3749
|
-
return getDisplayWidthOf(child);
|
|
3750
|
-
};
|
|
3751
|
-
/**
|
|
3752
|
-
* Gets the display height of a game object
|
|
3753
|
-
* @param child GameObject to measure
|
|
3754
|
-
* @returns Display height in pixels
|
|
3755
|
-
*/
|
|
3756
|
-
Column.prototype.getDisplayHeight = function (child) {
|
|
3757
|
-
return getDisplayHeightOf(child);
|
|
3758
|
-
};
|
|
3759
|
-
/**
|
|
3760
|
-
* Gets the normalized origin point of a game object
|
|
3761
|
-
* @param child GameObject to get origin from
|
|
3762
|
-
* @returns Object with normalized x,y coordinates of the origin point
|
|
3763
|
-
*/
|
|
3764
|
-
Column.prototype.getNormalizedOrigin = function (child) {
|
|
3765
|
-
return getNormalizedOriginOf(child);
|
|
3766
|
-
};
|
|
3767
|
-
return Column;
|
|
3768
|
-
}(Phaser$1.GameObjects.Container));
|
|
3769
|
-
|
|
3770
3957
|
var durations$2 = {
|
|
3771
3958
|
click: 100};
|
|
3772
3959
|
var CLICK_OFFSET$2 = 2;
|
|
@@ -4379,728 +4566,775 @@
|
|
|
4379
4566
|
return LinearProgress;
|
|
4380
4567
|
}(Phaser$1.GameObjects.Container));
|
|
4381
4568
|
|
|
4382
|
-
|
|
4383
|
-
var
|
|
4384
|
-
|
|
4385
|
-
var
|
|
4386
|
-
|
|
4387
|
-
var
|
|
4388
|
-
|
|
4389
|
-
var
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4569
|
+
/** Vertical offset for the shadow */
|
|
4570
|
+
var SHADOW_OFFSET_Y = 4;
|
|
4571
|
+
/** Opacity value for the shadow */
|
|
4572
|
+
var SHADOW_OPACITY$1 = 0.25;
|
|
4573
|
+
/** Thickness of the text stroke */
|
|
4574
|
+
var STROKE_THICKNESS = 2;
|
|
4575
|
+
/** Shadow size as a percentage of the header size */
|
|
4576
|
+
var SHADOW_SCALE = 0.95;
|
|
4577
|
+
/**
|
|
4578
|
+
* A stylized section header component with shadow, text stroke and auto-sizing
|
|
4579
|
+
*/
|
|
4580
|
+
var SectionHeader = /** @class */ (function (_super) {
|
|
4581
|
+
__extends(SectionHeader, _super);
|
|
4582
|
+
/**
|
|
4583
|
+
* Creates a new SectionHeader
|
|
4584
|
+
* @param params Configuration parameters for the header
|
|
4585
|
+
*/
|
|
4586
|
+
function SectionHeader(_a) {
|
|
4587
|
+
var scene = _a.scene, x = _a.x, y = _a.y, text = _a.text, fontSize = _a.fontSize, font = _a.font, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? 'blue-600' : _b, _c = _a.textColor, textColor = _c === void 0 ? 'white' : _c, strokeColor = _a.strokeColor, _d = _a.borderRadius, borderRadius = _d === void 0 ? 'md' : _d, _e = _a.margin, margin = _e === void 0 ? '4' : _e;
|
|
4394
4588
|
var _this = _super.call(this, scene, x, y) || this;
|
|
4395
|
-
_this.pw = getPWFromScene(scene);
|
|
4396
|
-
|
|
4397
|
-
_this.
|
|
4398
|
-
_this.
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
_this.
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
_this.
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4589
|
+
_this.pw = getPWFromScene(scene);
|
|
4590
|
+
// Store values
|
|
4591
|
+
_this.textValue = text;
|
|
4592
|
+
_this.fontSizePx =
|
|
4593
|
+
typeof fontSize === 'number'
|
|
4594
|
+
? fontSize
|
|
4595
|
+
: _this.pw.fontSize.px(fontSize !== null && fontSize !== void 0 ? fontSize : 'lg');
|
|
4596
|
+
_this.marginPx =
|
|
4597
|
+
typeof margin === 'number'
|
|
4598
|
+
? margin
|
|
4599
|
+
: _this.pw.spacing.px(margin !== null && margin !== void 0 ? margin : '4');
|
|
4600
|
+
_this.borderRadiusPx =
|
|
4601
|
+
typeof borderRadius === 'number'
|
|
4602
|
+
? borderRadius
|
|
4603
|
+
: _this.pw.radius.px(borderRadius !== null && borderRadius !== void 0 ? borderRadius : 'md');
|
|
4604
|
+
_this.backgroundColorValue = Color.rgb(backgroundColor);
|
|
4605
|
+
_this.textColorValue = Color.rgb(textColor);
|
|
4606
|
+
// If no stroke color provided, use a darker version of the background
|
|
4607
|
+
_this.strokeColorValue = strokeColor
|
|
4608
|
+
? Color.rgb(strokeColor)
|
|
4609
|
+
: _this.getDarkerColor(backgroundColor);
|
|
4610
|
+
_this.fontValue = typeof font === 'string' ? font : _this.pw.font.family(font !== null && font !== void 0 ? font : 'display');
|
|
4611
|
+
_this.createHeaderText(scene);
|
|
4612
|
+
_this.createShadowGraphics(scene);
|
|
4613
|
+
_this.createBackgroundGraphics(scene);
|
|
4412
4614
|
_this.setupContainer();
|
|
4413
|
-
_this.
|
|
4615
|
+
_this.setupInteractivity();
|
|
4414
4616
|
return _this;
|
|
4415
4617
|
}
|
|
4416
4618
|
/**
|
|
4417
|
-
* Sets the
|
|
4418
|
-
* @param
|
|
4419
|
-
* @
|
|
4619
|
+
* Sets the text content of the header
|
|
4620
|
+
* @param text New text content
|
|
4621
|
+
* @returns this for chaining
|
|
4420
4622
|
*/
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
if (this.currentProgress === newProgress) {
|
|
4426
|
-
return this;
|
|
4427
|
-
}
|
|
4428
|
-
if (animate) {
|
|
4429
|
-
var target_1 = { value: this.currentProgress };
|
|
4430
|
-
this.scene.tweens.add({
|
|
4431
|
-
targets: target_1,
|
|
4432
|
-
value: newProgress,
|
|
4433
|
-
duration: 300,
|
|
4434
|
-
ease: 'Power2',
|
|
4435
|
-
onUpdate: function () {
|
|
4436
|
-
_this.currentProgress = target_1.value;
|
|
4437
|
-
_this.updateProgressBar();
|
|
4438
|
-
_this.updatePercentageText();
|
|
4439
|
-
},
|
|
4440
|
-
});
|
|
4441
|
-
}
|
|
4442
|
-
else {
|
|
4443
|
-
this.currentProgress = newProgress;
|
|
4444
|
-
this.updateProgressBar();
|
|
4445
|
-
this.updatePercentageText();
|
|
4446
|
-
}
|
|
4623
|
+
SectionHeader.prototype.setText = function (text) {
|
|
4624
|
+
this.textValue = text;
|
|
4625
|
+
this.headerText.setText(text);
|
|
4626
|
+
this.regenerateGraphics();
|
|
4447
4627
|
return this;
|
|
4448
4628
|
};
|
|
4449
4629
|
/**
|
|
4450
|
-
*
|
|
4451
|
-
* @
|
|
4630
|
+
* Sets the font size of the header text
|
|
4631
|
+
* @param fontSize New font size (number in px or FontSizeKey)
|
|
4632
|
+
* @returns this for chaining
|
|
4452
4633
|
*/
|
|
4453
|
-
|
|
4454
|
-
|
|
4634
|
+
SectionHeader.prototype.setFontSize = function (fontSize) {
|
|
4635
|
+
this.fontSizePx =
|
|
4636
|
+
typeof fontSize === 'number'
|
|
4637
|
+
? fontSize
|
|
4638
|
+
: this.pw.fontSize.px(fontSize !== null && fontSize !== void 0 ? fontSize : 'lg');
|
|
4639
|
+
this.headerText.setFontSize(this.fontSizePx);
|
|
4640
|
+
this.regenerateGraphics();
|
|
4641
|
+
return this;
|
|
4455
4642
|
};
|
|
4456
4643
|
/**
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
this.
|
|
4465
|
-
this.recreateSprites();
|
|
4644
|
+
* Sets the font family of the header text
|
|
4645
|
+
* @param font New font family (FontKey or string)
|
|
4646
|
+
* @returns this for chaining
|
|
4647
|
+
*/
|
|
4648
|
+
SectionHeader.prototype.setFont = function (font) {
|
|
4649
|
+
this.fontValue = typeof font === 'string' ? font : this.pw.font.family(font !== null && font !== void 0 ? font : 'display');
|
|
4650
|
+
this.headerText.setFontFamily(this.fontValue);
|
|
4651
|
+
this.regenerateGraphics();
|
|
4466
4652
|
return this;
|
|
4467
4653
|
};
|
|
4468
4654
|
/**
|
|
4469
|
-
* Sets the background
|
|
4470
|
-
* @param
|
|
4655
|
+
* Sets the background color of the header
|
|
4656
|
+
* @param color New background color (ColorKey or string)
|
|
4657
|
+
* @returns this for chaining
|
|
4471
4658
|
*/
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4659
|
+
SectionHeader.prototype.setBackgroundColor = function (color) {
|
|
4660
|
+
this.backgroundColorValue = Color.rgb(color);
|
|
4661
|
+
// Update stroke color to match new background if it was auto-generated
|
|
4662
|
+
if (!this.strokeColorValue.startsWith('#')) {
|
|
4663
|
+
this.strokeColorValue = this.getDarkerColor(color);
|
|
4664
|
+
this.headerText.setStroke(this.strokeColorValue, STROKE_THICKNESS);
|
|
4475
4665
|
}
|
|
4476
|
-
this.
|
|
4477
|
-
this.recreateSprites();
|
|
4666
|
+
this.regenerateGraphics();
|
|
4478
4667
|
return this;
|
|
4479
4668
|
};
|
|
4480
4669
|
/**
|
|
4481
|
-
* Sets the
|
|
4482
|
-
* @param color
|
|
4670
|
+
* Sets the text color of the header
|
|
4671
|
+
* @param color New text color (ColorKey or string)
|
|
4672
|
+
* @returns this for chaining
|
|
4483
4673
|
*/
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
}
|
|
4488
|
-
this.progressColor = color;
|
|
4489
|
-
this.recreateSprites();
|
|
4674
|
+
SectionHeader.prototype.setTextColor = function (color) {
|
|
4675
|
+
this.textColorValue = Color.rgb(color);
|
|
4676
|
+
this.headerText.setColor(this.textColorValue);
|
|
4490
4677
|
return this;
|
|
4491
4678
|
};
|
|
4492
4679
|
/**
|
|
4493
|
-
* Sets
|
|
4494
|
-
* @param
|
|
4680
|
+
* Sets the stroke color of the header text
|
|
4681
|
+
* @param color New stroke color (ColorKey or string)
|
|
4682
|
+
* @returns this for chaining
|
|
4495
4683
|
*/
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
}
|
|
4500
|
-
this.showText = show;
|
|
4501
|
-
if (show && !this.percentageText) {
|
|
4502
|
-
this.createPercentageText();
|
|
4503
|
-
if (this.percentageText) {
|
|
4504
|
-
this.add(this.percentageText);
|
|
4505
|
-
}
|
|
4506
|
-
}
|
|
4507
|
-
else if (!show && this.percentageText) {
|
|
4508
|
-
this.remove(this.percentageText);
|
|
4509
|
-
this.percentageText.destroy();
|
|
4510
|
-
this.percentageText = undefined;
|
|
4511
|
-
}
|
|
4684
|
+
SectionHeader.prototype.setStrokeColor = function (color) {
|
|
4685
|
+
this.strokeColorValue = Color.rgb(color);
|
|
4686
|
+
this.headerText.setStroke(this.strokeColorValue, STROKE_THICKNESS);
|
|
4512
4687
|
return this;
|
|
4513
4688
|
};
|
|
4514
4689
|
/**
|
|
4515
|
-
* Sets the
|
|
4516
|
-
* @param
|
|
4690
|
+
* Sets the border radius of the header
|
|
4691
|
+
* @param borderRadius New border radius (number in px or RadiusKey)
|
|
4692
|
+
* @returns this for chaining
|
|
4517
4693
|
*/
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
this.percentageText.destroy();
|
|
4525
|
-
this.createPercentageText();
|
|
4526
|
-
this.add(this.percentageText);
|
|
4527
|
-
}
|
|
4694
|
+
SectionHeader.prototype.setBorderRadius = function (borderRadius) {
|
|
4695
|
+
this.borderRadiusPx =
|
|
4696
|
+
typeof borderRadius === 'number'
|
|
4697
|
+
? borderRadius
|
|
4698
|
+
: this.pw.radius.px(borderRadius !== null && borderRadius !== void 0 ? borderRadius : 'md');
|
|
4699
|
+
this.regenerateGraphics();
|
|
4528
4700
|
return this;
|
|
4529
4701
|
};
|
|
4530
4702
|
/**
|
|
4531
|
-
* Sets the
|
|
4532
|
-
* @param
|
|
4703
|
+
* Sets the margin/padding of the header
|
|
4704
|
+
* @param margin New margin size (number in px or SpacingKey)
|
|
4705
|
+
* @returns this for chaining
|
|
4533
4706
|
*/
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
this.percentageText.destroy();
|
|
4541
|
-
this.createPercentageText();
|
|
4542
|
-
this.add(this.percentageText);
|
|
4543
|
-
}
|
|
4707
|
+
SectionHeader.prototype.setMargin = function (margin) {
|
|
4708
|
+
this.marginPx =
|
|
4709
|
+
typeof margin === 'number'
|
|
4710
|
+
? margin
|
|
4711
|
+
: this.pw.spacing.px(margin !== null && margin !== void 0 ? margin : '4');
|
|
4712
|
+
this.regenerateGraphics();
|
|
4544
4713
|
return this;
|
|
4545
4714
|
};
|
|
4546
4715
|
/**
|
|
4547
|
-
*
|
|
4548
|
-
* @param
|
|
4716
|
+
* Creates the header text game object
|
|
4717
|
+
* @param scene The scene to add the text to
|
|
4718
|
+
*/
|
|
4719
|
+
SectionHeader.prototype.createHeaderText = function (scene) {
|
|
4720
|
+
this.headerText = scene.add.text(0, 0, this.textValue, {
|
|
4721
|
+
fontSize: "".concat(this.fontSizePx, "px"),
|
|
4722
|
+
fontFamily: this.fontValue,
|
|
4723
|
+
color: this.textColorValue,
|
|
4724
|
+
stroke: this.strokeColorValue,
|
|
4725
|
+
strokeThickness: STROKE_THICKNESS,
|
|
4726
|
+
fontStyle: 'bold', // Make section headers bold by default
|
|
4727
|
+
});
|
|
4728
|
+
this.headerText.setOrigin(0.5, 0.5);
|
|
4729
|
+
};
|
|
4730
|
+
/**
|
|
4731
|
+
* Creates the shadow graphics below the header
|
|
4732
|
+
* @param scene The scene to add the graphics to
|
|
4733
|
+
*/
|
|
4734
|
+
SectionHeader.prototype.createShadowGraphics = function (scene) {
|
|
4735
|
+
this.shadowGraphics = scene.add.graphics();
|
|
4736
|
+
this.drawShadow();
|
|
4737
|
+
};
|
|
4738
|
+
/**
|
|
4739
|
+
* Creates the background graphics for the header
|
|
4740
|
+
* @param scene The scene to add the graphics to
|
|
4741
|
+
*/
|
|
4742
|
+
SectionHeader.prototype.createBackgroundGraphics = function (scene) {
|
|
4743
|
+
this.backgroundGraphics = scene.add.graphics();
|
|
4744
|
+
this.drawBackground();
|
|
4745
|
+
};
|
|
4746
|
+
/**
|
|
4747
|
+
* Regenerates all graphics after a property change
|
|
4748
|
+
*/
|
|
4749
|
+
SectionHeader.prototype.regenerateGraphics = function () {
|
|
4750
|
+
// Update text bounds after text/font changes
|
|
4751
|
+
this.headerText.setText(this.textValue);
|
|
4752
|
+
// Redraw graphics with new properties
|
|
4753
|
+
this.drawShadow();
|
|
4754
|
+
this.drawBackground();
|
|
4755
|
+
};
|
|
4756
|
+
/**
|
|
4757
|
+
* Draws the shadow graphics
|
|
4758
|
+
*/
|
|
4759
|
+
SectionHeader.prototype.drawShadow = function () {
|
|
4760
|
+
var sizes = this.getHeaderDimensions();
|
|
4761
|
+
var height = sizes.height, width = sizes.width;
|
|
4762
|
+
this.shadowGraphics.clear();
|
|
4763
|
+
// Limit radius to maximum possible for the header dimensions
|
|
4764
|
+
var maxRadius = Math.min(width / 2, height / 2);
|
|
4765
|
+
var effectiveRadius = Math.min(this.borderRadiusPx, maxRadius);
|
|
4766
|
+
// Shadow size is 80% of the header size
|
|
4767
|
+
var shadowWidth = width * SHADOW_SCALE;
|
|
4768
|
+
var shadowHeight = height * SHADOW_SCALE;
|
|
4769
|
+
// Calculate shadow position to center it
|
|
4770
|
+
// Since Graphics doesn't have setOrigin, we need to calculate the offset manually
|
|
4771
|
+
var shadowX = -shadowWidth / 2;
|
|
4772
|
+
var shadowY = SHADOW_OFFSET_Y - shadowHeight / 2 + 4;
|
|
4773
|
+
// Calculate shadow radius (proportional to shadow size)
|
|
4774
|
+
var shadowMaxRadius = Math.min(shadowWidth / 2, shadowHeight / 2);
|
|
4775
|
+
var shadowEffectiveRadius = Math.min(effectiveRadius * SHADOW_SCALE, shadowMaxRadius);
|
|
4776
|
+
// Shadow (only vertical offset, no horizontal)
|
|
4777
|
+
this.shadowGraphics.fillStyle(Color.hex('black'), SHADOW_OPACITY$1);
|
|
4778
|
+
this.shadowGraphics.fillRoundedRect(shadowX, shadowY, shadowWidth, shadowHeight, shadowEffectiveRadius);
|
|
4779
|
+
};
|
|
4780
|
+
/**
|
|
4781
|
+
* Draws the background graphics
|
|
4549
4782
|
*/
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4783
|
+
SectionHeader.prototype.drawBackground = function () {
|
|
4784
|
+
var _a = this.getHeaderDimensions(), width = _a.width, height = _a.height;
|
|
4785
|
+
this.backgroundGraphics.clear();
|
|
4786
|
+
// Limit radius to maximum possible for the header dimensions
|
|
4787
|
+
var maxRadius = Math.min(width / 2, height / 2);
|
|
4788
|
+
var effectiveRadius = Math.min(this.borderRadiusPx, maxRadius);
|
|
4789
|
+
// Since Graphics doesn't have setOrigin, we need to calculate the offset manually
|
|
4790
|
+
var bgX = -width / 2;
|
|
4791
|
+
var bgY = -height / 2;
|
|
4792
|
+
// Main background with subtle gradient effect
|
|
4793
|
+
this.backgroundGraphics.fillStyle(Color.hex(this.backgroundColorValue), 1);
|
|
4794
|
+
this.backgroundGraphics.fillRoundedRect(bgX, bgY, width, height, effectiveRadius);
|
|
4795
|
+
var depth = 0.15;
|
|
4796
|
+
var hightlightWidth = width;
|
|
4797
|
+
if (this.borderRadiusPx > 12) {
|
|
4798
|
+
hightlightWidth = width * 0.7;
|
|
4557
4799
|
}
|
|
4558
|
-
|
|
4800
|
+
var highlightX = bgX + (width - hightlightWidth) / 2;
|
|
4801
|
+
// Add a subtle highlight on top for depth
|
|
4802
|
+
var highlightHeight = Math.max(2, height * depth);
|
|
4803
|
+
// For the highlight, use a smaller radius if the highlight is too small
|
|
4804
|
+
var highlightRadius = Math.min(effectiveRadius, highlightHeight / 2);
|
|
4805
|
+
this.backgroundGraphics.fillStyle(Color.hex('white'), depth);
|
|
4806
|
+
this.backgroundGraphics.fillRoundedRect(highlightX, bgY, hightlightWidth, highlightHeight, highlightRadius);
|
|
4559
4807
|
};
|
|
4560
4808
|
/**
|
|
4561
|
-
*
|
|
4562
|
-
* @
|
|
4809
|
+
* Gets the dimensions of the header based on text content
|
|
4810
|
+
* @returns Object containing width and height
|
|
4563
4811
|
*/
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
this.recreateSprites();
|
|
4570
|
-
return this;
|
|
4812
|
+
SectionHeader.prototype.getHeaderDimensions = function () {
|
|
4813
|
+
var textBounds = this.headerText.getBounds();
|
|
4814
|
+
var width = textBounds.width + this.marginPx * 2;
|
|
4815
|
+
var height = textBounds.height + this.marginPx * 2;
|
|
4816
|
+
return { width: width, height: height };
|
|
4571
4817
|
};
|
|
4572
4818
|
/**
|
|
4573
|
-
*
|
|
4819
|
+
* Sets up the container with all graphics in the correct order
|
|
4574
4820
|
*/
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
};
|
|
4578
|
-
RadialProgress.prototype.createBackgroundSprite = function () {
|
|
4579
|
-
var bgGraphic = this.scene.add.graphics();
|
|
4580
|
-
// Draw a circle with alpha background
|
|
4581
|
-
bgGraphic.fillStyle(this.pw.color.hex(this.backgroundColor), this.backgroundAlpha);
|
|
4582
|
-
bgGraphic.beginPath();
|
|
4583
|
-
bgGraphic.arc(0, 0, this.radius, 0, Phaser.Math.PI2, false);
|
|
4584
|
-
bgGraphic.closePath();
|
|
4585
|
-
bgGraphic.fillPath();
|
|
4586
|
-
this.backgroundProgressBar = bgGraphic;
|
|
4587
|
-
};
|
|
4588
|
-
RadialProgress.prototype.createRadialArc = function () {
|
|
4589
|
-
var graphics = this.scene.add.graphics();
|
|
4590
|
-
graphics.lineStyle(this.thickness, this.pw.color.hex(this.progressColor), 1);
|
|
4591
|
-
graphics.beginPath();
|
|
4592
|
-
graphics.arc(0, 0, this.radius, this.startAngle, Phaser.Math.DegToRad(THREE_SIXTY), true);
|
|
4593
|
-
graphics.strokePath();
|
|
4594
|
-
this.radialArc = graphics;
|
|
4821
|
+
SectionHeader.prototype.setupContainer = function () {
|
|
4822
|
+
this.add([this.shadowGraphics, this.backgroundGraphics, this.headerText]);
|
|
4595
4823
|
};
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4824
|
+
/**
|
|
4825
|
+
* Sets up interactivity for the header
|
|
4826
|
+
*/
|
|
4827
|
+
SectionHeader.prototype.setupInteractivity = function () {
|
|
4828
|
+
var _this = this;
|
|
4829
|
+
this.setInteractive();
|
|
4830
|
+
this.on('pointerdown', function () {
|
|
4831
|
+
_this.setScale(0.95);
|
|
4832
|
+
_this.on('pointerup', function () {
|
|
4833
|
+
_this.setScale(1);
|
|
4834
|
+
});
|
|
4601
4835
|
});
|
|
4602
|
-
this.percentageText.setOrigin(0.5);
|
|
4603
|
-
this.percentageText.setAlpha(this.textAlpha);
|
|
4604
|
-
};
|
|
4605
|
-
RadialProgress.prototype.setThickness = function (thickness) {
|
|
4606
|
-
this.thickness = thickness;
|
|
4607
|
-
this.recreateSprites();
|
|
4608
|
-
};
|
|
4609
|
-
RadialProgress.prototype.setupContainer = function () {
|
|
4610
|
-
var children = [this.backgroundProgressBar, this.radialArc];
|
|
4611
|
-
if (this.percentageText) {
|
|
4612
|
-
children.push(this.percentageText);
|
|
4613
|
-
}
|
|
4614
|
-
this.add(children);
|
|
4615
|
-
};
|
|
4616
|
-
RadialProgress.prototype.updateProgressBar = function () {
|
|
4617
|
-
if (!this.radialArc)
|
|
4618
|
-
return;
|
|
4619
|
-
this.radialArc.clear();
|
|
4620
|
-
var startAngleRad = Phaser.Math.DegToRad(this.startAngle);
|
|
4621
|
-
var sweepRad = Phaser.Math.DegToRad((this.currentProgress / A_HUNDRED) * THREE_SIXTY);
|
|
4622
|
-
var endAngleRad = startAngleRad + sweepRad;
|
|
4623
|
-
var isFullCircle = this.currentProgress >= A_HUNDRED;
|
|
4624
|
-
this.radialArc.lineStyle(this.thickness, this.pw.color.hex(this.progressColor), 1);
|
|
4625
|
-
this.radialArc.beginPath();
|
|
4626
|
-
if (isFullCircle) {
|
|
4627
|
-
this.radialArc.arc(0, 0, this.radius, 0, Phaser.Math.PI2, false);
|
|
4628
|
-
}
|
|
4629
|
-
else {
|
|
4630
|
-
this.radialArc.arc(0, 0, this.radius, startAngleRad, endAngleRad, false);
|
|
4631
|
-
}
|
|
4632
|
-
this.radialArc.strokePath();
|
|
4633
|
-
};
|
|
4634
|
-
RadialProgress.prototype.updatePercentageText = function () {
|
|
4635
|
-
if (this.percentageText) {
|
|
4636
|
-
this.percentageText.setText("".concat(Math.round(this.currentProgress), "%"));
|
|
4637
|
-
}
|
|
4638
4836
|
};
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4837
|
+
/**
|
|
4838
|
+
* Gets a darker version of the given color
|
|
4839
|
+
* @param color Base color to darken
|
|
4840
|
+
* @returns Darker color string
|
|
4841
|
+
*/
|
|
4842
|
+
SectionHeader.prototype.getDarkerColor = function (color) {
|
|
4843
|
+
// Try to get a darker shade of the same color family
|
|
4844
|
+
var colorStr = color;
|
|
4845
|
+
// If it's already a shade (e.g., "blue-600"), try to make it darker
|
|
4846
|
+
if (colorStr.includes('-')) {
|
|
4847
|
+
var _a = colorStr.split('-'), family = _a[0], shade = _a[1];
|
|
4848
|
+
if (family && shade) {
|
|
4849
|
+
var currentShade = parseInt(shade);
|
|
4850
|
+
var shadeLimit = 900;
|
|
4851
|
+
var shadeIncrement = 200;
|
|
4852
|
+
if (!isNaN(currentShade) && currentShade < shadeLimit) {
|
|
4853
|
+
var darkerShade = Math.min(shadeLimit, currentShade + shadeIncrement);
|
|
4854
|
+
return Color.rgb("".concat(family, "-").concat(darkerShade));
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4650
4857
|
}
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
if (
|
|
4654
|
-
|
|
4858
|
+
// If it's a base color (e.g., "blue"), add a dark shade
|
|
4859
|
+
var baseColors = ['red', 'blue', 'green', 'yellow', 'purple', 'orange', 'pink', 'gray'];
|
|
4860
|
+
if (baseColors.includes(colorStr)) {
|
|
4861
|
+
return Color.rgb("".concat(colorStr, "-800"));
|
|
4655
4862
|
}
|
|
4656
|
-
|
|
4657
|
-
|
|
4863
|
+
// Fallback to a dark color
|
|
4864
|
+
return Color.rgb('gray-800');
|
|
4658
4865
|
};
|
|
4659
|
-
return
|
|
4866
|
+
return SectionHeader;
|
|
4660
4867
|
}(Phaser$1.GameObjects.Container));
|
|
4661
4868
|
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
var
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
var
|
|
4674
|
-
|
|
4675
|
-
_this.
|
|
4676
|
-
_this.
|
|
4677
|
-
_this.
|
|
4678
|
-
|
|
4679
|
-
|
|
4869
|
+
// Constants for default values
|
|
4870
|
+
var DEFAULT_BORDER_RADIUS = 8;
|
|
4871
|
+
var DEFAULT_MARGIN = 16;
|
|
4872
|
+
var DEFAULT_BACKGROUND_COLOR = 'red-500';
|
|
4873
|
+
var DEFAULT_HEADER_HEIGHT = 60;
|
|
4874
|
+
var CLOSE_BUTTON_SIZE = 32;
|
|
4875
|
+
var CLOSE_BUTTON_MARGIN = 8;
|
|
4876
|
+
var Panel = /** @class */ (function (_super) {
|
|
4877
|
+
__extends(Panel, _super);
|
|
4878
|
+
function Panel(params) {
|
|
4879
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4880
|
+
var _this = _super.call(this, params.scene, (_a = params.x) !== null && _a !== void 0 ? _a : 0, (_b = params.y) !== null && _b !== void 0 ? _b : 0) || this;
|
|
4881
|
+
_this.sectionHeader = null;
|
|
4882
|
+
_this.closeButton = null;
|
|
4883
|
+
_this.title = (_c = params.title) !== null && _c !== void 0 ? _c : '';
|
|
4884
|
+
_this.showCloseButton = (_d = params.showCloseButton) !== null && _d !== void 0 ? _d : false;
|
|
4885
|
+
_this.onClose = params.onClose;
|
|
4886
|
+
_this.headerHeight = DEFAULT_HEADER_HEIGHT;
|
|
4887
|
+
// Create the card first
|
|
4888
|
+
_this.card = new Card({
|
|
4889
|
+
scene: params.scene,
|
|
4890
|
+
x: 0,
|
|
4891
|
+
y: 0,
|
|
4892
|
+
backgroundColor: (_e = params.backgroundColor) !== null && _e !== void 0 ? _e : DEFAULT_BACKGROUND_COLOR,
|
|
4893
|
+
borderRadius: (_f = params.borderRadius) !== null && _f !== void 0 ? _f : DEFAULT_BORDER_RADIUS,
|
|
4894
|
+
margin: (_g = params.margin) !== null && _g !== void 0 ? _g : DEFAULT_MARGIN,
|
|
4895
|
+
child: params.child
|
|
4896
|
+
});
|
|
4897
|
+
// Add card to container
|
|
4898
|
+
_this.add(_this.card);
|
|
4899
|
+
// Create section header if title is provided
|
|
4900
|
+
if (_this.title) {
|
|
4901
|
+
_this.createSectionHeader();
|
|
4902
|
+
}
|
|
4903
|
+
// Create close button if requested
|
|
4904
|
+
if (_this.showCloseButton) {
|
|
4905
|
+
_this.createCloseButton();
|
|
4680
4906
|
}
|
|
4681
|
-
|
|
4907
|
+
// Update layout
|
|
4908
|
+
_this.updateLayout();
|
|
4682
4909
|
return _this;
|
|
4683
4910
|
}
|
|
4684
4911
|
/**
|
|
4685
|
-
*
|
|
4686
|
-
* @param gap Gap size in pixels
|
|
4687
|
-
*/
|
|
4688
|
-
Row.prototype.setGap = function (gap) {
|
|
4689
|
-
this.gap = gap;
|
|
4690
|
-
this.layout();
|
|
4691
|
-
};
|
|
4692
|
-
/**
|
|
4693
|
-
* Sets the vertical alignment and updates layout
|
|
4694
|
-
* @param align New vertical alignment
|
|
4695
|
-
*/
|
|
4696
|
-
Row.prototype.setAlign = function (align) {
|
|
4697
|
-
this.align = align;
|
|
4698
|
-
this.layout();
|
|
4699
|
-
};
|
|
4700
|
-
/**
|
|
4701
|
-
* Adds a single child to the row
|
|
4702
|
-
* @param child GameObject to add
|
|
4703
|
-
* @param relayout Whether to update layout after adding
|
|
4704
|
-
* @returns This row instance for chaining
|
|
4705
|
-
*/
|
|
4706
|
-
Row.prototype.addChild = function (child, relayout) {
|
|
4707
|
-
if (relayout === void 0) { relayout = true; }
|
|
4708
|
-
this.add(child);
|
|
4709
|
-
if (relayout) {
|
|
4710
|
-
this.layout();
|
|
4711
|
-
}
|
|
4712
|
-
return this;
|
|
4713
|
-
};
|
|
4714
|
-
/**
|
|
4715
|
-
* Adds multiple children to the row
|
|
4716
|
-
* @param children Array of GameObjects to add
|
|
4717
|
-
* @param relayout Whether to update layout after adding
|
|
4718
|
-
* @returns This row instance for chaining
|
|
4912
|
+
* Creates the section header
|
|
4719
4913
|
*/
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
this.
|
|
4726
|
-
|
|
4914
|
+
Panel.prototype.createSectionHeader = function () {
|
|
4915
|
+
this.sectionHeader = new SectionHeader({
|
|
4916
|
+
scene: this.scene,
|
|
4917
|
+
x: 0,
|
|
4918
|
+
y: 0,
|
|
4919
|
+
text: this.title,
|
|
4920
|
+
backgroundColor: DEFAULT_BACKGROUND_COLOR,
|
|
4921
|
+
borderRadius: 0
|
|
4922
|
+
});
|
|
4923
|
+
// Add header to container
|
|
4924
|
+
this.add(this.sectionHeader);
|
|
4727
4925
|
};
|
|
4728
4926
|
/**
|
|
4729
|
-
*
|
|
4927
|
+
* Creates the close button
|
|
4730
4928
|
*/
|
|
4731
|
-
|
|
4929
|
+
Panel.prototype.createCloseButton = function () {
|
|
4732
4930
|
var _this = this;
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
});
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
this.gap * (entries.length - 1);
|
|
4748
|
-
// Determine left of content based on horizontalOrigin
|
|
4749
|
-
var contentLeftX = this.horizontalOrigin === 'left'
|
|
4750
|
-
? 0
|
|
4751
|
-
: this.horizontalOrigin === 'center'
|
|
4752
|
-
? -totalWidth / 2
|
|
4753
|
-
: -totalWidth;
|
|
4754
|
-
// Walk left to right, aligning considering each child's origin
|
|
4755
|
-
var cursorLeftX = contentLeftX;
|
|
4756
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
4757
|
-
var _a = entries_1[_i], child = _a.child, width = _a.width, height = _a.height, origin_1 = _a.origin;
|
|
4758
|
-
// Vertical alignment: align top/bottom edges or centers correctly using origin
|
|
4759
|
-
var y = 0;
|
|
4760
|
-
if (this.align === 'top') {
|
|
4761
|
-
// place child's top edge at content top
|
|
4762
|
-
y = -maxHeight / 2 + origin_1.y * height;
|
|
4763
|
-
}
|
|
4764
|
-
else if (this.align === 'bottom') {
|
|
4765
|
-
// place child's bottom edge at content bottom
|
|
4766
|
-
y = maxHeight / 2 - (1 - origin_1.y) * height;
|
|
4767
|
-
}
|
|
4768
|
-
else {
|
|
4769
|
-
// center alignment
|
|
4770
|
-
y = (origin_1.y - 0.5) * height;
|
|
4771
|
-
}
|
|
4772
|
-
// Horizontal position so that child's left is at cursorLeftX
|
|
4773
|
-
var x = cursorLeftX + origin_1.x * width;
|
|
4774
|
-
child.setPosition(x, y);
|
|
4775
|
-
cursorLeftX += width + this.gap;
|
|
4776
|
-
}
|
|
4777
|
-
this.setSize(totalWidth, maxHeight);
|
|
4931
|
+
this.closeButton = new FlatIconButton({
|
|
4932
|
+
scene: this.scene,
|
|
4933
|
+
x: 0,
|
|
4934
|
+
y: 0,
|
|
4935
|
+
icon: 'x',
|
|
4936
|
+
size: CLOSE_BUTTON_SIZE,
|
|
4937
|
+
onClick: function () {
|
|
4938
|
+
if (_this.onClose) {
|
|
4939
|
+
_this.onClose();
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
});
|
|
4943
|
+
// Add close button to container
|
|
4944
|
+
this.add(this.closeButton);
|
|
4778
4945
|
};
|
|
4779
4946
|
/**
|
|
4780
|
-
*
|
|
4781
|
-
* @param child GameObject to measure
|
|
4782
|
-
* @returns Display width in pixels
|
|
4947
|
+
* Updates the layout after property changes
|
|
4783
4948
|
*/
|
|
4784
|
-
|
|
4785
|
-
|
|
4949
|
+
Panel.prototype.updateLayout = function () {
|
|
4950
|
+
// Get card bounds
|
|
4951
|
+
var cardBounds = this.card.getBounds();
|
|
4952
|
+
// Calculate header position (top of the card)
|
|
4953
|
+
if (this.sectionHeader) {
|
|
4954
|
+
var headerY = -cardBounds.height / 2 + this.headerHeight / 2;
|
|
4955
|
+
this.sectionHeader.setPosition(0, headerY);
|
|
4956
|
+
// Note: SectionHeader doesn't have setWidth, it auto-sizes to content
|
|
4957
|
+
}
|
|
4958
|
+
// Calculate close button position (top-right corner)
|
|
4959
|
+
if (this.closeButton) {
|
|
4960
|
+
var buttonX = cardBounds.width / 2 - CLOSE_BUTTON_SIZE / 2 - CLOSE_BUTTON_MARGIN;
|
|
4961
|
+
var buttonY = -cardBounds.height / 2 + CLOSE_BUTTON_SIZE / 2 + CLOSE_BUTTON_MARGIN;
|
|
4962
|
+
this.closeButton.setPosition(buttonX, buttonY);
|
|
4963
|
+
}
|
|
4786
4964
|
};
|
|
4787
4965
|
/**
|
|
4788
|
-
*
|
|
4789
|
-
* @param child GameObject to measure
|
|
4790
|
-
* @returns Display height in pixels
|
|
4966
|
+
* Sets the title of the panel
|
|
4791
4967
|
*/
|
|
4792
|
-
|
|
4793
|
-
|
|
4968
|
+
Panel.prototype.setTitle = function (title) {
|
|
4969
|
+
this.title = title;
|
|
4970
|
+
if (title && !this.sectionHeader) {
|
|
4971
|
+
this.createSectionHeader();
|
|
4972
|
+
}
|
|
4973
|
+
else if (!title && this.sectionHeader) {
|
|
4974
|
+
this.remove(this.sectionHeader);
|
|
4975
|
+
this.sectionHeader = null;
|
|
4976
|
+
}
|
|
4977
|
+
else if (this.sectionHeader) {
|
|
4978
|
+
this.sectionHeader.setText(title);
|
|
4979
|
+
}
|
|
4980
|
+
this.updateLayout();
|
|
4981
|
+
return this;
|
|
4794
4982
|
};
|
|
4795
4983
|
/**
|
|
4796
|
-
*
|
|
4797
|
-
* @param child GameObject to get origin from
|
|
4798
|
-
* @returns Object with normalized x,y coordinates of the origin point
|
|
4984
|
+
* Sets whether to show the close button
|
|
4799
4985
|
*/
|
|
4800
|
-
|
|
4801
|
-
|
|
4986
|
+
Panel.prototype.setShowCloseButton = function (show) {
|
|
4987
|
+
this.showCloseButton = show;
|
|
4988
|
+
if (show && !this.closeButton) {
|
|
4989
|
+
this.createCloseButton();
|
|
4990
|
+
}
|
|
4991
|
+
else if (!show && this.closeButton) {
|
|
4992
|
+
this.remove(this.closeButton);
|
|
4993
|
+
this.closeButton = null;
|
|
4994
|
+
}
|
|
4995
|
+
this.updateLayout();
|
|
4996
|
+
return this;
|
|
4802
4997
|
};
|
|
4803
|
-
return Row;
|
|
4804
|
-
}(Phaser$1.GameObjects.Container));
|
|
4805
|
-
|
|
4806
|
-
/** Vertical offset for the shadow */
|
|
4807
|
-
var SHADOW_OFFSET_Y = 4;
|
|
4808
|
-
/** Opacity value for the shadow */
|
|
4809
|
-
var SHADOW_OPACITY$1 = 0.25;
|
|
4810
|
-
/** Thickness of the text stroke */
|
|
4811
|
-
var STROKE_THICKNESS = 2;
|
|
4812
|
-
/** Shadow size as a percentage of the header size */
|
|
4813
|
-
var SHADOW_SCALE = 0.95;
|
|
4814
|
-
/**
|
|
4815
|
-
* A stylized section header component with shadow, text stroke and auto-sizing
|
|
4816
|
-
*/
|
|
4817
|
-
var SectionHeader = /** @class */ (function (_super) {
|
|
4818
|
-
__extends(SectionHeader, _super);
|
|
4819
4998
|
/**
|
|
4820
|
-
*
|
|
4821
|
-
* @param params Configuration parameters for the header
|
|
4999
|
+
* Sets the close callback
|
|
4822
5000
|
*/
|
|
4823
|
-
function
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
// Store values
|
|
4828
|
-
_this.textValue = text;
|
|
4829
|
-
_this.fontSizePx =
|
|
4830
|
-
typeof fontSize === 'number'
|
|
4831
|
-
? fontSize
|
|
4832
|
-
: _this.pw.fontSize.px(fontSize !== null && fontSize !== void 0 ? fontSize : 'lg');
|
|
4833
|
-
_this.marginPx =
|
|
4834
|
-
typeof margin === 'number'
|
|
4835
|
-
? margin
|
|
4836
|
-
: _this.pw.spacing.px(margin !== null && margin !== void 0 ? margin : '4');
|
|
4837
|
-
_this.borderRadiusPx =
|
|
4838
|
-
typeof borderRadius === 'number'
|
|
4839
|
-
? borderRadius
|
|
4840
|
-
: _this.pw.radius.px(borderRadius !== null && borderRadius !== void 0 ? borderRadius : 'md');
|
|
4841
|
-
_this.backgroundColorValue = Color.rgb(backgroundColor);
|
|
4842
|
-
_this.textColorValue = Color.rgb(textColor);
|
|
4843
|
-
// If no stroke color provided, use a darker version of the background
|
|
4844
|
-
_this.strokeColorValue = strokeColor
|
|
4845
|
-
? Color.rgb(strokeColor)
|
|
4846
|
-
: _this.getDarkerColor(backgroundColor);
|
|
4847
|
-
_this.fontValue = typeof font === 'string' ? font : _this.pw.font.family(font !== null && font !== void 0 ? font : 'display');
|
|
4848
|
-
_this.createHeaderText(scene);
|
|
4849
|
-
_this.createShadowGraphics(scene);
|
|
4850
|
-
_this.createBackgroundGraphics(scene);
|
|
4851
|
-
_this.setupContainer();
|
|
4852
|
-
_this.setupInteractivity();
|
|
4853
|
-
return _this;
|
|
4854
|
-
}
|
|
5001
|
+
Panel.prototype.setOnClose = function (callback) {
|
|
5002
|
+
this.onClose = callback;
|
|
5003
|
+
return this;
|
|
5004
|
+
};
|
|
4855
5005
|
/**
|
|
4856
|
-
* Sets the
|
|
4857
|
-
* @param text New text content
|
|
4858
|
-
* @returns this for chaining
|
|
5006
|
+
* Sets the background color
|
|
4859
5007
|
*/
|
|
4860
|
-
|
|
4861
|
-
this.
|
|
4862
|
-
this.
|
|
4863
|
-
|
|
5008
|
+
Panel.prototype.setBackgroundColor = function (color) {
|
|
5009
|
+
this.card.setBackgroundColor(color);
|
|
5010
|
+
if (this.sectionHeader) {
|
|
5011
|
+
this.sectionHeader.setBackgroundColor(color);
|
|
5012
|
+
}
|
|
4864
5013
|
return this;
|
|
4865
5014
|
};
|
|
4866
5015
|
/**
|
|
4867
|
-
* Sets the
|
|
4868
|
-
* @param fontSize New font size (number in px or FontSizeKey)
|
|
4869
|
-
* @returns this for chaining
|
|
5016
|
+
* Sets the border radius
|
|
4870
5017
|
*/
|
|
4871
|
-
|
|
4872
|
-
this.
|
|
4873
|
-
|
|
4874
|
-
? fontSize
|
|
4875
|
-
: this.pw.fontSize.px(fontSize !== null && fontSize !== void 0 ? fontSize : 'lg');
|
|
4876
|
-
this.headerText.setFontSize(this.fontSizePx);
|
|
4877
|
-
this.regenerateGraphics();
|
|
5018
|
+
Panel.prototype.setBorderRadius = function (radius) {
|
|
5019
|
+
this.card.setBorderRadius(radius);
|
|
5020
|
+
this.updateLayout();
|
|
4878
5021
|
return this;
|
|
4879
5022
|
};
|
|
4880
5023
|
/**
|
|
4881
|
-
* Sets the
|
|
4882
|
-
* @param font New font family (FontKey or string)
|
|
4883
|
-
* @returns this for chaining
|
|
5024
|
+
* Sets the margin
|
|
4884
5025
|
*/
|
|
4885
|
-
|
|
4886
|
-
this.
|
|
4887
|
-
this.
|
|
4888
|
-
this.regenerateGraphics();
|
|
5026
|
+
Panel.prototype.setMargin = function (margin) {
|
|
5027
|
+
this.card.setMargin(margin);
|
|
5028
|
+
this.updateLayout();
|
|
4889
5029
|
return this;
|
|
4890
5030
|
};
|
|
4891
5031
|
/**
|
|
4892
|
-
* Sets
|
|
4893
|
-
* @param color New background color (ColorKey or string)
|
|
4894
|
-
* @returns this for chaining
|
|
5032
|
+
* Sets a new child component
|
|
4895
5033
|
*/
|
|
4896
|
-
|
|
4897
|
-
this.
|
|
4898
|
-
|
|
4899
|
-
if (!this.strokeColorValue.startsWith('#')) {
|
|
4900
|
-
this.strokeColorValue = this.getDarkerColor(color);
|
|
4901
|
-
this.headerText.setStroke(this.strokeColorValue, STROKE_THICKNESS);
|
|
4902
|
-
}
|
|
4903
|
-
this.regenerateGraphics();
|
|
5034
|
+
Panel.prototype.setChild = function (child) {
|
|
5035
|
+
this.card.setChild(child);
|
|
5036
|
+
this.updateLayout();
|
|
4904
5037
|
return this;
|
|
4905
5038
|
};
|
|
4906
5039
|
/**
|
|
4907
|
-
*
|
|
4908
|
-
* @param color New text color (ColorKey or string)
|
|
4909
|
-
* @returns this for chaining
|
|
5040
|
+
* Gets the card component
|
|
4910
5041
|
*/
|
|
4911
|
-
|
|
4912
|
-
this.
|
|
4913
|
-
this.headerText.setColor(this.textColorValue);
|
|
4914
|
-
return this;
|
|
5042
|
+
Panel.prototype.getCard = function () {
|
|
5043
|
+
return this.card;
|
|
4915
5044
|
};
|
|
4916
5045
|
/**
|
|
4917
|
-
*
|
|
4918
|
-
* @param color New stroke color (ColorKey or string)
|
|
4919
|
-
* @returns this for chaining
|
|
5046
|
+
* Gets the section header component
|
|
4920
5047
|
*/
|
|
4921
|
-
|
|
4922
|
-
this.
|
|
4923
|
-
|
|
5048
|
+
Panel.prototype.getSectionHeader = function () {
|
|
5049
|
+
return this.sectionHeader;
|
|
5050
|
+
};
|
|
5051
|
+
/**
|
|
5052
|
+
* Gets the close button component
|
|
5053
|
+
*/
|
|
5054
|
+
Panel.prototype.getCloseButton = function () {
|
|
5055
|
+
return this.closeButton;
|
|
5056
|
+
};
|
|
5057
|
+
return Panel;
|
|
5058
|
+
}(Phaser$1.GameObjects.Container));
|
|
5059
|
+
|
|
5060
|
+
var A_HUNDRED = 100;
|
|
5061
|
+
var THREE_SIXTY = 360;
|
|
5062
|
+
var START_ANGLE = 270;
|
|
5063
|
+
var DEFAULT_THICKNESS = 4;
|
|
5064
|
+
var DEFAULT_BACKGROUND_ALPHA = 0.2;
|
|
5065
|
+
var DEFAULT_TEXT_COLOR = 'white';
|
|
5066
|
+
var DEFAULT_FONT_SIZE = 'base';
|
|
5067
|
+
var DEFAULT_TEXT_ALPHA = 1;
|
|
5068
|
+
var RadialProgress = /** @class */ (function (_super) {
|
|
5069
|
+
__extends(RadialProgress, _super);
|
|
5070
|
+
function RadialProgress(_a) {
|
|
5071
|
+
var scene = _a.scene, x = _a.x, y = _a.y, radius = _a.radius, _b = _a.thickness, thickness = _b === void 0 ? DEFAULT_THICKNESS : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? 'gray-200' : _c, _d = _a.backgroundAlpha, backgroundAlpha = _d === void 0 ? DEFAULT_BACKGROUND_ALPHA : _d, _e = _a.progressColor, progressColor = _e === void 0 ? 'blue-500' : _e, _f = _a.progress, progress = _f === void 0 ? 0 : _f, _g = _a.startAngle, startAngle = _g === void 0 ? START_ANGLE : _g, _h = _a.showText, showText = _h === void 0 ? false : _h, _j = _a.textColor, textColor = _j === void 0 ? DEFAULT_TEXT_COLOR : _j, _k = _a.fontSize, fontSize = _k === void 0 ? DEFAULT_FONT_SIZE : _k, _l = _a.textAlpha, textAlpha = _l === void 0 ? DEFAULT_TEXT_ALPHA : _l;
|
|
5072
|
+
var _this = _super.call(this, scene, x, y) || this;
|
|
5073
|
+
_this.pw = getPWFromScene(scene);
|
|
5074
|
+
_this.radius = radius;
|
|
5075
|
+
_this.thickness = thickness;
|
|
5076
|
+
_this.backgroundColor = backgroundColor;
|
|
5077
|
+
_this.backgroundAlpha = backgroundAlpha;
|
|
5078
|
+
_this.progressColor = progressColor;
|
|
5079
|
+
_this.currentProgress = Math.max(0, Math.min(A_HUNDRED, progress));
|
|
5080
|
+
_this.startAngle = startAngle;
|
|
5081
|
+
_this.showText = showText;
|
|
5082
|
+
_this.textColor = textColor;
|
|
5083
|
+
_this.fontSize = fontSize;
|
|
5084
|
+
_this.textAlpha = textAlpha;
|
|
5085
|
+
_this.createBackgroundSprite();
|
|
5086
|
+
_this.createRadialArc();
|
|
5087
|
+
if (_this.showText) {
|
|
5088
|
+
_this.createPercentageText();
|
|
5089
|
+
}
|
|
5090
|
+
_this.setupContainer();
|
|
5091
|
+
_this.updateProgressBar();
|
|
5092
|
+
return _this;
|
|
5093
|
+
}
|
|
5094
|
+
/**
|
|
5095
|
+
* Sets the progress value (0-100)
|
|
5096
|
+
* @param progress Progress value between 0 and 100
|
|
5097
|
+
* @param animate Whether to animate the change (default: true)
|
|
5098
|
+
*/
|
|
5099
|
+
RadialProgress.prototype.setProgress = function (progress, animate) {
|
|
5100
|
+
var _this = this;
|
|
5101
|
+
if (animate === void 0) { animate = true; }
|
|
5102
|
+
var newProgress = Math.max(0, Math.min(A_HUNDRED, progress));
|
|
5103
|
+
if (this.currentProgress === newProgress) {
|
|
5104
|
+
return this;
|
|
5105
|
+
}
|
|
5106
|
+
if (animate) {
|
|
5107
|
+
var target_1 = { value: this.currentProgress };
|
|
5108
|
+
this.scene.tweens.add({
|
|
5109
|
+
targets: target_1,
|
|
5110
|
+
value: newProgress,
|
|
5111
|
+
duration: 300,
|
|
5112
|
+
ease: 'Power2',
|
|
5113
|
+
onUpdate: function () {
|
|
5114
|
+
_this.currentProgress = target_1.value;
|
|
5115
|
+
_this.updateProgressBar();
|
|
5116
|
+
_this.updatePercentageText();
|
|
5117
|
+
},
|
|
5118
|
+
});
|
|
5119
|
+
}
|
|
5120
|
+
else {
|
|
5121
|
+
this.currentProgress = newProgress;
|
|
5122
|
+
this.updateProgressBar();
|
|
5123
|
+
this.updatePercentageText();
|
|
5124
|
+
}
|
|
4924
5125
|
return this;
|
|
4925
5126
|
};
|
|
4926
5127
|
/**
|
|
4927
|
-
*
|
|
4928
|
-
* @
|
|
4929
|
-
* @returns this for chaining
|
|
5128
|
+
* Gets the current progress value
|
|
5129
|
+
* @returns Current progress value (0-100)
|
|
4930
5130
|
*/
|
|
4931
|
-
|
|
4932
|
-
this.
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
5131
|
+
RadialProgress.prototype.getProgress = function () {
|
|
5132
|
+
return this.currentProgress;
|
|
5133
|
+
};
|
|
5134
|
+
/**
|
|
5135
|
+
* Sets the background color of the progress bar
|
|
5136
|
+
* @param color Background color token
|
|
5137
|
+
*/
|
|
5138
|
+
RadialProgress.prototype.setBackgroundColor = function (color) {
|
|
5139
|
+
if (this.backgroundColor === color) {
|
|
5140
|
+
return this;
|
|
5141
|
+
}
|
|
5142
|
+
this.backgroundColor = color;
|
|
5143
|
+
this.recreateSprites();
|
|
4937
5144
|
return this;
|
|
4938
5145
|
};
|
|
4939
5146
|
/**
|
|
4940
|
-
* Sets the
|
|
4941
|
-
* @param
|
|
4942
|
-
* @returns this for chaining
|
|
5147
|
+
* Sets the background alpha of the progress bar
|
|
5148
|
+
* @param alpha Background alpha value (0-1)
|
|
4943
5149
|
*/
|
|
4944
|
-
|
|
4945
|
-
this.
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
this.
|
|
5150
|
+
RadialProgress.prototype.setBackgroundAlpha = function (alpha) {
|
|
5151
|
+
if (this.backgroundAlpha === alpha) {
|
|
5152
|
+
return this;
|
|
5153
|
+
}
|
|
5154
|
+
this.backgroundAlpha = alpha;
|
|
5155
|
+
this.recreateSprites();
|
|
4950
5156
|
return this;
|
|
4951
5157
|
};
|
|
4952
5158
|
/**
|
|
4953
|
-
*
|
|
4954
|
-
* @param
|
|
5159
|
+
* Sets the progress color of the progress bar
|
|
5160
|
+
* @param color Progress color token
|
|
4955
5161
|
*/
|
|
4956
|
-
|
|
4957
|
-
this.
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
fontStyle: 'bold', // Make section headers bold by default
|
|
4964
|
-
});
|
|
4965
|
-
this.headerText.setOrigin(0.5, 0.5);
|
|
5162
|
+
RadialProgress.prototype.setProgressColor = function (color) {
|
|
5163
|
+
if (this.progressColor === color) {
|
|
5164
|
+
return this;
|
|
5165
|
+
}
|
|
5166
|
+
this.progressColor = color;
|
|
5167
|
+
this.recreateSprites();
|
|
5168
|
+
return this;
|
|
4966
5169
|
};
|
|
4967
5170
|
/**
|
|
4968
|
-
*
|
|
4969
|
-
* @param
|
|
5171
|
+
* Sets whether to show the percentage text
|
|
5172
|
+
* @param show Whether to show the text
|
|
4970
5173
|
*/
|
|
4971
|
-
|
|
4972
|
-
this.
|
|
4973
|
-
|
|
5174
|
+
RadialProgress.prototype.setShowText = function (show) {
|
|
5175
|
+
if (this.showText === show) {
|
|
5176
|
+
return this;
|
|
5177
|
+
}
|
|
5178
|
+
this.showText = show;
|
|
5179
|
+
if (show && !this.percentageText) {
|
|
5180
|
+
this.createPercentageText();
|
|
5181
|
+
if (this.percentageText) {
|
|
5182
|
+
this.add(this.percentageText);
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
5185
|
+
else if (!show && this.percentageText) {
|
|
5186
|
+
this.remove(this.percentageText);
|
|
5187
|
+
this.percentageText.destroy();
|
|
5188
|
+
this.percentageText = undefined;
|
|
5189
|
+
}
|
|
5190
|
+
return this;
|
|
4974
5191
|
};
|
|
4975
5192
|
/**
|
|
4976
|
-
*
|
|
4977
|
-
* @param
|
|
5193
|
+
* Sets the text color
|
|
5194
|
+
* @param color Text color token
|
|
4978
5195
|
*/
|
|
4979
|
-
|
|
4980
|
-
this.
|
|
4981
|
-
|
|
5196
|
+
RadialProgress.prototype.setTextColor = function (color) {
|
|
5197
|
+
if (this.textColor === color) {
|
|
5198
|
+
return this;
|
|
5199
|
+
}
|
|
5200
|
+
this.textColor = color;
|
|
5201
|
+
if (this.percentageText) {
|
|
5202
|
+
this.percentageText.destroy();
|
|
5203
|
+
this.createPercentageText();
|
|
5204
|
+
this.add(this.percentageText);
|
|
5205
|
+
}
|
|
5206
|
+
return this;
|
|
4982
5207
|
};
|
|
4983
5208
|
/**
|
|
4984
|
-
*
|
|
5209
|
+
* Sets the font size
|
|
5210
|
+
* @param size Font size in pixels
|
|
4985
5211
|
*/
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
this.
|
|
4991
|
-
this.
|
|
5212
|
+
RadialProgress.prototype.setFontSize = function (size) {
|
|
5213
|
+
if (this.fontSize === size) {
|
|
5214
|
+
return this;
|
|
5215
|
+
}
|
|
5216
|
+
this.fontSize = size;
|
|
5217
|
+
if (this.percentageText) {
|
|
5218
|
+
this.percentageText.destroy();
|
|
5219
|
+
this.createPercentageText();
|
|
5220
|
+
this.add(this.percentageText);
|
|
5221
|
+
}
|
|
5222
|
+
return this;
|
|
4992
5223
|
};
|
|
4993
5224
|
/**
|
|
4994
|
-
*
|
|
5225
|
+
* Sets the text alpha
|
|
5226
|
+
* @param alpha Alpha value (0-1)
|
|
4995
5227
|
*/
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
var shadowHeight = height * SHADOW_SCALE;
|
|
5006
|
-
// Calculate shadow position to center it
|
|
5007
|
-
// Since Graphics doesn't have setOrigin, we need to calculate the offset manually
|
|
5008
|
-
var shadowX = -shadowWidth / 2;
|
|
5009
|
-
var shadowY = SHADOW_OFFSET_Y - shadowHeight / 2 + 4;
|
|
5010
|
-
// Calculate shadow radius (proportional to shadow size)
|
|
5011
|
-
var shadowMaxRadius = Math.min(shadowWidth / 2, shadowHeight / 2);
|
|
5012
|
-
var shadowEffectiveRadius = Math.min(effectiveRadius * SHADOW_SCALE, shadowMaxRadius);
|
|
5013
|
-
// Shadow (only vertical offset, no horizontal)
|
|
5014
|
-
this.shadowGraphics.fillStyle(Color.hex('black'), SHADOW_OPACITY$1);
|
|
5015
|
-
this.shadowGraphics.fillRoundedRect(shadowX, shadowY, shadowWidth, shadowHeight, shadowEffectiveRadius);
|
|
5228
|
+
RadialProgress.prototype.setTextAlpha = function (alpha) {
|
|
5229
|
+
if (this.textAlpha === alpha) {
|
|
5230
|
+
return this;
|
|
5231
|
+
}
|
|
5232
|
+
this.textAlpha = alpha;
|
|
5233
|
+
if (this.percentageText) {
|
|
5234
|
+
this.percentageText.setAlpha(this.textAlpha);
|
|
5235
|
+
}
|
|
5236
|
+
return this;
|
|
5016
5237
|
};
|
|
5017
5238
|
/**
|
|
5018
|
-
*
|
|
5239
|
+
* Sets the radius of the progress bar
|
|
5240
|
+
* @param radius New radius in pixels
|
|
5019
5241
|
*/
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
// Limit radius to maximum possible for the header dimensions
|
|
5024
|
-
var maxRadius = Math.min(width / 2, height / 2);
|
|
5025
|
-
var effectiveRadius = Math.min(this.borderRadiusPx, maxRadius);
|
|
5026
|
-
// Since Graphics doesn't have setOrigin, we need to calculate the offset manually
|
|
5027
|
-
var bgX = -width / 2;
|
|
5028
|
-
var bgY = -height / 2;
|
|
5029
|
-
// Main background with subtle gradient effect
|
|
5030
|
-
this.backgroundGraphics.fillStyle(Color.hex(this.backgroundColorValue), 1);
|
|
5031
|
-
this.backgroundGraphics.fillRoundedRect(bgX, bgY, width, height, effectiveRadius);
|
|
5032
|
-
var depth = 0.15;
|
|
5033
|
-
var hightlightWidth = width;
|
|
5034
|
-
if (this.borderRadiusPx > 12) {
|
|
5035
|
-
hightlightWidth = width * 0.7;
|
|
5242
|
+
RadialProgress.prototype.setRadius = function (radius) {
|
|
5243
|
+
if (this.radius === radius) {
|
|
5244
|
+
return this;
|
|
5036
5245
|
}
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
// For the highlight, use a smaller radius if the highlight is too small
|
|
5041
|
-
var highlightRadius = Math.min(effectiveRadius, highlightHeight / 2);
|
|
5042
|
-
this.backgroundGraphics.fillStyle(Color.hex('white'), depth);
|
|
5043
|
-
this.backgroundGraphics.fillRoundedRect(highlightX, bgY, hightlightWidth, highlightHeight, highlightRadius);
|
|
5246
|
+
this.radius = radius;
|
|
5247
|
+
this.recreateSprites();
|
|
5248
|
+
return this;
|
|
5044
5249
|
};
|
|
5045
5250
|
/**
|
|
5046
|
-
*
|
|
5047
|
-
* @returns Object containing width and height
|
|
5251
|
+
* Destroys the component and cleans up animations
|
|
5048
5252
|
*/
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
var width = textBounds.width + this.marginPx * 2;
|
|
5052
|
-
var height = textBounds.height + this.marginPx * 2;
|
|
5053
|
-
return { width: width, height: height };
|
|
5253
|
+
RadialProgress.prototype.destroy = function () {
|
|
5254
|
+
_super.prototype.destroy.call(this);
|
|
5054
5255
|
};
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5256
|
+
RadialProgress.prototype.createBackgroundSprite = function () {
|
|
5257
|
+
var bgGraphic = this.scene.add.graphics();
|
|
5258
|
+
// Draw a circle with alpha background
|
|
5259
|
+
bgGraphic.fillStyle(this.pw.color.hex(this.backgroundColor), this.backgroundAlpha);
|
|
5260
|
+
bgGraphic.beginPath();
|
|
5261
|
+
bgGraphic.arc(0, 0, this.radius, 0, Phaser.Math.PI2, false);
|
|
5262
|
+
bgGraphic.closePath();
|
|
5263
|
+
bgGraphic.fillPath();
|
|
5264
|
+
this.backgroundProgressBar = bgGraphic;
|
|
5060
5265
|
};
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
this.
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5266
|
+
RadialProgress.prototype.createRadialArc = function () {
|
|
5267
|
+
var graphics = this.scene.add.graphics();
|
|
5268
|
+
graphics.lineStyle(this.thickness, this.pw.color.hex(this.progressColor), 1);
|
|
5269
|
+
graphics.beginPath();
|
|
5270
|
+
graphics.arc(0, 0, this.radius, this.startAngle, Phaser.Math.DegToRad(THREE_SIXTY), true);
|
|
5271
|
+
graphics.strokePath();
|
|
5272
|
+
this.radialArc = graphics;
|
|
5273
|
+
};
|
|
5274
|
+
RadialProgress.prototype.createPercentageText = function () {
|
|
5275
|
+
this.percentageText = this.scene.add.text(0, 0, "".concat(Math.round(this.currentProgress), "%"), {
|
|
5276
|
+
fontSize: this.pw.fontSize.css(this.fontSize),
|
|
5277
|
+
color: this.pw.color.rgb(this.textColor),
|
|
5278
|
+
fontStyle: 'bold',
|
|
5072
5279
|
});
|
|
5280
|
+
this.percentageText.setOrigin(0.5);
|
|
5281
|
+
this.percentageText.setAlpha(this.textAlpha);
|
|
5073
5282
|
};
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
// If it's already a shade (e.g., "blue-600"), try to make it darker
|
|
5083
|
-
if (colorStr.includes('-')) {
|
|
5084
|
-
var _a = colorStr.split('-'), family = _a[0], shade = _a[1];
|
|
5085
|
-
if (family && shade) {
|
|
5086
|
-
var currentShade = parseInt(shade);
|
|
5087
|
-
var shadeLimit = 900;
|
|
5088
|
-
var shadeIncrement = 200;
|
|
5089
|
-
if (!isNaN(currentShade) && currentShade < shadeLimit) {
|
|
5090
|
-
var darkerShade = Math.min(shadeLimit, currentShade + shadeIncrement);
|
|
5091
|
-
return Color.rgb("".concat(family, "-").concat(darkerShade));
|
|
5092
|
-
}
|
|
5093
|
-
}
|
|
5283
|
+
RadialProgress.prototype.setThickness = function (thickness) {
|
|
5284
|
+
this.thickness = thickness;
|
|
5285
|
+
this.recreateSprites();
|
|
5286
|
+
};
|
|
5287
|
+
RadialProgress.prototype.setupContainer = function () {
|
|
5288
|
+
var children = [this.backgroundProgressBar, this.radialArc];
|
|
5289
|
+
if (this.percentageText) {
|
|
5290
|
+
children.push(this.percentageText);
|
|
5094
5291
|
}
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5292
|
+
this.add(children);
|
|
5293
|
+
};
|
|
5294
|
+
RadialProgress.prototype.updateProgressBar = function () {
|
|
5295
|
+
if (!this.radialArc)
|
|
5296
|
+
return;
|
|
5297
|
+
this.radialArc.clear();
|
|
5298
|
+
var startAngleRad = Phaser.Math.DegToRad(this.startAngle);
|
|
5299
|
+
var sweepRad = Phaser.Math.DegToRad((this.currentProgress / A_HUNDRED) * THREE_SIXTY);
|
|
5300
|
+
var endAngleRad = startAngleRad + sweepRad;
|
|
5301
|
+
var isFullCircle = this.currentProgress >= A_HUNDRED;
|
|
5302
|
+
this.radialArc.lineStyle(this.thickness, this.pw.color.hex(this.progressColor), 1);
|
|
5303
|
+
this.radialArc.beginPath();
|
|
5304
|
+
if (isFullCircle) {
|
|
5305
|
+
this.radialArc.arc(0, 0, this.radius, 0, Phaser.Math.PI2, false);
|
|
5099
5306
|
}
|
|
5100
|
-
|
|
5101
|
-
|
|
5307
|
+
else {
|
|
5308
|
+
this.radialArc.arc(0, 0, this.radius, startAngleRad, endAngleRad, false);
|
|
5309
|
+
}
|
|
5310
|
+
this.radialArc.strokePath();
|
|
5102
5311
|
};
|
|
5103
|
-
|
|
5312
|
+
RadialProgress.prototype.updatePercentageText = function () {
|
|
5313
|
+
if (this.percentageText) {
|
|
5314
|
+
this.percentageText.setText("".concat(Math.round(this.currentProgress), "%"));
|
|
5315
|
+
}
|
|
5316
|
+
};
|
|
5317
|
+
RadialProgress.prototype.recreateSprites = function () {
|
|
5318
|
+
var children = [this.backgroundProgressBar, this.radialArc];
|
|
5319
|
+
if (this.percentageText) {
|
|
5320
|
+
children.push(this.percentageText);
|
|
5321
|
+
}
|
|
5322
|
+
this.remove(children);
|
|
5323
|
+
this.backgroundProgressBar.destroy();
|
|
5324
|
+
this.radialArc.destroy();
|
|
5325
|
+
if (this.percentageText) {
|
|
5326
|
+
this.percentageText.destroy();
|
|
5327
|
+
this.percentageText = undefined;
|
|
5328
|
+
}
|
|
5329
|
+
this.createBackgroundSprite();
|
|
5330
|
+
this.createRadialArc();
|
|
5331
|
+
if (this.showText) {
|
|
5332
|
+
this.createPercentageText();
|
|
5333
|
+
}
|
|
5334
|
+
this.setupContainer();
|
|
5335
|
+
this.updateProgressBar();
|
|
5336
|
+
};
|
|
5337
|
+
return RadialProgress;
|
|
5104
5338
|
}(Phaser$1.GameObjects.Container));
|
|
5105
5339
|
|
|
5106
5340
|
/**
|
|
@@ -5175,7 +5409,7 @@
|
|
|
5175
5409
|
* @param params TextButtonParams
|
|
5176
5410
|
*/
|
|
5177
5411
|
function TextButton(_a) {
|
|
5178
|
-
var scene = _a.scene, x = _a.x, y = _a.y, text = _a.text,
|
|
5412
|
+
var scene = _a.scene, x = _a.x, y = _a.y, text = _a.text, _b = _a.fontSize, fontSize = _b === void 0 ? 'base' : _b, font = _a.font, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? 'blue' : _c, _d = _a.textColor, textColor = _d === void 0 ? 'white' : _d, _e = _a.borderRadius, borderRadius = _e === void 0 ? 'md' : _e, _f = _a.margin, margin = _f === void 0 ? '4' : _f, onClick = _a.onClick;
|
|
5179
5413
|
var _this = _super.call(this, scene, x, y) || this;
|
|
5180
5414
|
_this.pw = getPWFromScene(scene);
|
|
5181
5415
|
// Store values
|
|
@@ -5561,6 +5795,7 @@
|
|
|
5561
5795
|
exports.CircularProgress = CircularProgress;
|
|
5562
5796
|
exports.Color = Color;
|
|
5563
5797
|
exports.Column = Column;
|
|
5798
|
+
exports.DEFAULT_GAP = DEFAULT_GAP;
|
|
5564
5799
|
exports.FlatIconButton = FlatIconButton;
|
|
5565
5800
|
exports.FontSize = FontSize;
|
|
5566
5801
|
exports.HUDINI_KEY = HUDINI_KEY;
|
|
@@ -5568,6 +5803,7 @@
|
|
|
5568
5803
|
exports.IconButton = IconButton;
|
|
5569
5804
|
exports.LinearProgress = LinearProgress;
|
|
5570
5805
|
exports.PHASER_WIND_KEY = PHASER_WIND_KEY;
|
|
5806
|
+
exports.Panel = Panel;
|
|
5571
5807
|
exports.PhaserWindPlugin = PhaserWindPlugin;
|
|
5572
5808
|
exports.RadialProgress = RadialProgress;
|
|
5573
5809
|
exports.Radius = Radius;
|
|
@@ -5591,7 +5827,10 @@
|
|
|
5591
5827
|
exports.defaultShadowMap = defaultShadowMap;
|
|
5592
5828
|
exports.fontMap = fontMap;
|
|
5593
5829
|
exports.fontSizeMap = fontSizeMap;
|
|
5830
|
+
exports.getDisplayHeightOf = getDisplayHeightOf;
|
|
5831
|
+
exports.getDisplayWidthOf = getDisplayWidthOf;
|
|
5594
5832
|
exports.getHudini = getHudini;
|
|
5833
|
+
exports.getNormalizedOriginOf = getNormalizedOriginOf;
|
|
5595
5834
|
exports.getPWFromScene = getPWFromScene;
|
|
5596
5835
|
exports.isValidColor = isValidColor;
|
|
5597
5836
|
exports.merge = merge;
|