@open-slot-ui/pixi 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +34 -0
- package/README.md +49 -0
- package/dist/index.cjs +3982 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +933 -0
- package/dist/index.d.ts +933 -0
- package/dist/index.js +3954 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3954 @@
|
|
|
1
|
+
import { Container, Graphics, Text, Circle, Sprite, Rectangle, Ticker, BlurFilter, Texture } from 'pixi.js';
|
|
2
|
+
import { resolvePlacement, displayDigits, valueFitMaxWidth, formatAmount, EventLog, composeMenu, buildBlocks, buttonBlocks, createUI, buildPanel } from '@open-slot-ui/core';
|
|
3
|
+
|
|
4
|
+
// src/OpenUIPixi.ts
|
|
5
|
+
var ControlView = class extends Container {
|
|
6
|
+
constructor(control, ui) {
|
|
7
|
+
super();
|
|
8
|
+
this.control = control;
|
|
9
|
+
this.ui = ui;
|
|
10
|
+
this.control.viewInspect = () => ({ bounds: this.computeRect(), animating: this.animating });
|
|
11
|
+
}
|
|
12
|
+
control;
|
|
13
|
+
ui;
|
|
14
|
+
animating = false;
|
|
15
|
+
disposers = [];
|
|
16
|
+
/** Position + fit-scale from the control's layout spec against the screen. */
|
|
17
|
+
applyLayout(screen) {
|
|
18
|
+
const p = resolvePlacement(this.control.layout, screen);
|
|
19
|
+
this.position.set(p.x, p.y);
|
|
20
|
+
this.scale.set(p.scale);
|
|
21
|
+
this.rotation = p.rotation;
|
|
22
|
+
}
|
|
23
|
+
computeRect() {
|
|
24
|
+
if (this.destroyed) return null;
|
|
25
|
+
const b = this.getBounds();
|
|
26
|
+
return { x: b.minX, y: b.minY, width: b.maxX - b.minX, height: b.maxY - b.minY };
|
|
27
|
+
}
|
|
28
|
+
dispose() {
|
|
29
|
+
for (const d of this.disposers) d();
|
|
30
|
+
this.disposers.length = 0;
|
|
31
|
+
this.control.viewInspect = void 0;
|
|
32
|
+
if (!this.destroyed) this.destroy({ children: true });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var Tweener = class {
|
|
36
|
+
constructor(ticker) {
|
|
37
|
+
this.ticker = ticker;
|
|
38
|
+
}
|
|
39
|
+
ticker;
|
|
40
|
+
frames = /* @__PURE__ */ new Set();
|
|
41
|
+
loopResolve = null;
|
|
42
|
+
stop() {
|
|
43
|
+
for (const fn of this.frames) this.ticker.remove(fn);
|
|
44
|
+
this.frames.clear();
|
|
45
|
+
if (this.loopResolve) {
|
|
46
|
+
const resolve = this.loopResolve;
|
|
47
|
+
this.loopResolve = null;
|
|
48
|
+
resolve();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
run(target, transition, _theme) {
|
|
52
|
+
this.stop();
|
|
53
|
+
target.scale.set(1);
|
|
54
|
+
target.rotation = 0;
|
|
55
|
+
target.alpha = 1;
|
|
56
|
+
if (!transition) return Promise.resolve();
|
|
57
|
+
return this.exec(target, transition);
|
|
58
|
+
}
|
|
59
|
+
add(fn) {
|
|
60
|
+
this.frames.add(fn);
|
|
61
|
+
this.ticker.add(fn);
|
|
62
|
+
}
|
|
63
|
+
done(fn) {
|
|
64
|
+
this.ticker.remove(fn);
|
|
65
|
+
this.frames.delete(fn);
|
|
66
|
+
}
|
|
67
|
+
exec(target, t) {
|
|
68
|
+
switch (t.kind) {
|
|
69
|
+
case "squish":
|
|
70
|
+
case "pulse":
|
|
71
|
+
return this.scaleYoyo(target, t.scale, t.ms);
|
|
72
|
+
case "fade":
|
|
73
|
+
return this.fadeTo(target, t.alpha, t.ms);
|
|
74
|
+
case "turn":
|
|
75
|
+
return this.turn(target, t.rps);
|
|
76
|
+
case "sequence":
|
|
77
|
+
return this.runSequence(target, t.steps);
|
|
78
|
+
case "parallel":
|
|
79
|
+
return Promise.all(t.steps.map((s) => this.exec(target, s))).then(() => void 0);
|
|
80
|
+
default:
|
|
81
|
+
return Promise.resolve();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
scaleYoyo(target, peak, ms) {
|
|
85
|
+
return new Promise((resolve) => {
|
|
86
|
+
let elapsed = 0;
|
|
87
|
+
const half = Math.max(ms / 2, 1);
|
|
88
|
+
const fn = (ticker) => {
|
|
89
|
+
elapsed += ticker.deltaMS;
|
|
90
|
+
const k = elapsed < half ? elapsed / half : 1 - (elapsed - half) / half;
|
|
91
|
+
const s = 1 + (peak - 1) * Math.min(Math.max(k, 0), 1);
|
|
92
|
+
target.scale.set(s);
|
|
93
|
+
if (elapsed >= ms) {
|
|
94
|
+
target.scale.set(1);
|
|
95
|
+
this.done(fn);
|
|
96
|
+
resolve();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
this.add(fn);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
fadeTo(target, alpha, ms) {
|
|
103
|
+
return new Promise((resolve) => {
|
|
104
|
+
let elapsed = 0;
|
|
105
|
+
const from = target.alpha;
|
|
106
|
+
const dur = Math.max(ms, 1);
|
|
107
|
+
const fn = (ticker) => {
|
|
108
|
+
elapsed += ticker.deltaMS;
|
|
109
|
+
const k = Math.min(elapsed / dur, 1);
|
|
110
|
+
target.alpha = from + (alpha - from) * k;
|
|
111
|
+
if (k >= 1) {
|
|
112
|
+
this.done(fn);
|
|
113
|
+
resolve();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
this.add(fn);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Continuous rotation; the promise resolves when `stop()` is next called. */
|
|
120
|
+
turn(target, rps) {
|
|
121
|
+
return new Promise((resolve) => {
|
|
122
|
+
this.loopResolve = resolve;
|
|
123
|
+
const fn = (ticker) => {
|
|
124
|
+
target.rotation += rps * Math.PI * 2 * (ticker.deltaMS / 1e3);
|
|
125
|
+
};
|
|
126
|
+
this.add(fn);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async runSequence(target, steps) {
|
|
130
|
+
for (const step of steps) await this.exec(target, step);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
function drawSpin(g, theme, state) {
|
|
134
|
+
g.clear();
|
|
135
|
+
const r = 64;
|
|
136
|
+
const ring = state === "disabled" ? theme.color.disabled : theme.color.accent;
|
|
137
|
+
const glyph = state === "disabled" ? theme.color.textDim : theme.color.text;
|
|
138
|
+
g.circle(0, 0, r).fill({ color: theme.color.surface });
|
|
139
|
+
g.circle(0, 0, r).stroke({ width: 6, color: ring, alpha: 1 });
|
|
140
|
+
const s = 20;
|
|
141
|
+
g.moveTo(-s * 0.5, -s).lineTo(s, 0).lineTo(-s * 0.5, s).closePath().fill({ color: glyph });
|
|
142
|
+
}
|
|
143
|
+
var defaultSpinSkin = (theme) => {
|
|
144
|
+
const g = new Graphics();
|
|
145
|
+
const view = new Container();
|
|
146
|
+
view.addChild(g);
|
|
147
|
+
return {
|
|
148
|
+
view,
|
|
149
|
+
update: (state) => drawSpin(g, theme, state),
|
|
150
|
+
destroy: () => view.destroy({ children: true })
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/util.ts
|
|
155
|
+
function isDesktop() {
|
|
156
|
+
if (typeof window === "undefined") return true;
|
|
157
|
+
const noTouch = !("ontouchstart" in window);
|
|
158
|
+
const noPoints = (navigator.maxTouchPoints ?? 0) === 0;
|
|
159
|
+
return noTouch && noPoints;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/views/SpinView.ts
|
|
163
|
+
var SpinView = class extends ControlView {
|
|
164
|
+
constructor(spin, ui, ticker, skinOrOpts = defaultSpinSkin) {
|
|
165
|
+
super(spin, ui);
|
|
166
|
+
this.spin = spin;
|
|
167
|
+
this.tween = new Tweener(ticker);
|
|
168
|
+
const opts = typeof skinOrOpts === "function" ? { skin: skinOrOpts } : skinOrOpts;
|
|
169
|
+
const skinFactory = opts.skin ?? defaultSpinSkin;
|
|
170
|
+
this.holdDelayMs = opts.holdDelayMs ?? 260;
|
|
171
|
+
this.skin = skinFactory(ui.theme);
|
|
172
|
+
this.art.addChild(this.skin.view);
|
|
173
|
+
const c = ui.theme.color;
|
|
174
|
+
const ring = new Graphics().circle(0, 0, 64).fill({ color: c.surface }).stroke({ width: 6, color: c.accent });
|
|
175
|
+
this.fsCount = new Text({ text: "0", style: { fontFamily: ui.theme.type.family, fontSize: 44, fill: c.text, fontWeight: "800" } });
|
|
176
|
+
this.fsCount.anchor.set(0.5);
|
|
177
|
+
this.fsCount.y = -8;
|
|
178
|
+
this.fsLabel = new Text({ text: ui.t("openui.freeSpins"), style: { fontFamily: ui.theme.type.family, fontSize: 18, fill: c.accent, fontWeight: "800", letterSpacing: 2 } });
|
|
179
|
+
this.fsLabel.anchor.set(0.5);
|
|
180
|
+
this.fsLabel.y = 26;
|
|
181
|
+
this.fsFace.addChild(ring, this.fsCount, this.fsLabel);
|
|
182
|
+
this.fsFace.visible = false;
|
|
183
|
+
this.art.addChild(this.fsFace);
|
|
184
|
+
this.addChild(this.art);
|
|
185
|
+
this.hitArea = new Circle(0, 0, 118);
|
|
186
|
+
this.eventMode = "static";
|
|
187
|
+
this.cursor = "pointer";
|
|
188
|
+
this.on("pointerover", this.onOver);
|
|
189
|
+
this.on("pointerout", this.onOut);
|
|
190
|
+
this.on("pointerdown", this.onDown);
|
|
191
|
+
this.on("pointerup", this.onUp);
|
|
192
|
+
this.on("pointerupoutside", this.onUpOutside);
|
|
193
|
+
this.disposers.push(
|
|
194
|
+
this.spin.state.subscribe(() => {
|
|
195
|
+
this.skin.update(this.spin.current);
|
|
196
|
+
this.updateInteractive();
|
|
197
|
+
}),
|
|
198
|
+
// re-dim if slam-stop is toggled at runtime (e.g. applyJurisdiction)
|
|
199
|
+
this.spin.allowSlamStop.subscribe(() => this.updateInteractive()),
|
|
200
|
+
this.spin.onTransition((t) => this.play(t)),
|
|
201
|
+
// free-spins face: switch between the normal skin and the "N FS" counter
|
|
202
|
+
this.spin.freeSpins.subscribe(() => this.updateFreeSpins()),
|
|
203
|
+
this.ui.locale.subscribe(() => {
|
|
204
|
+
if (!this.destroyed) this.fsLabel.text = this.ui.t("openui.freeSpins");
|
|
205
|
+
})
|
|
206
|
+
);
|
|
207
|
+
this.skin.update(this.spin.current);
|
|
208
|
+
this.updateFreeSpins();
|
|
209
|
+
this.updateInteractive();
|
|
210
|
+
}
|
|
211
|
+
spin;
|
|
212
|
+
art = new Container();
|
|
213
|
+
skin;
|
|
214
|
+
tween;
|
|
215
|
+
holdDelayMs;
|
|
216
|
+
holdTimer;
|
|
217
|
+
holding = false;
|
|
218
|
+
/** Free-spins face — a ring + remaining count + "FS"; shown when `spin.freeSpins > 0`. */
|
|
219
|
+
fsFace = new Container();
|
|
220
|
+
fsCount;
|
|
221
|
+
fsLabel;
|
|
222
|
+
/** Swap the spin face: free-spins counter when `freeSpins > 0`, else the skin. */
|
|
223
|
+
updateFreeSpins() {
|
|
224
|
+
const n = this.spin.freeSpins.get();
|
|
225
|
+
const fs = n > 0;
|
|
226
|
+
this.fsCount.text = String(n);
|
|
227
|
+
this.fsFace.visible = fs;
|
|
228
|
+
this.skin.view.visible = !fs;
|
|
229
|
+
}
|
|
230
|
+
onOver = () => {
|
|
231
|
+
if (isDesktop() && this.spin.current === "idle") this.spin.setState("hover");
|
|
232
|
+
};
|
|
233
|
+
onOut = () => {
|
|
234
|
+
if (this.spin.current === "hover") this.spin.setState("idle");
|
|
235
|
+
};
|
|
236
|
+
onDown = () => {
|
|
237
|
+
if (!this.spin.interactable) return;
|
|
238
|
+
this.spin.setState("pressed");
|
|
239
|
+
if (this.spin.holdToSpin) {
|
|
240
|
+
this.holdTimer = setTimeout(() => {
|
|
241
|
+
this.holdTimer = void 0;
|
|
242
|
+
if (this.spin.current !== "pressed") return;
|
|
243
|
+
if (this.spin.holdBegin()) {
|
|
244
|
+
this.holding = true;
|
|
245
|
+
if (typeof window !== "undefined") {
|
|
246
|
+
window.addEventListener("pointerup", this.endHoldGlobal);
|
|
247
|
+
window.addEventListener("pointercancel", this.endHoldGlobal);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}, this.holdDelayMs);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
onUp = () => {
|
|
254
|
+
if (this.holding) return this.endHold();
|
|
255
|
+
this.clearHoldTimer();
|
|
256
|
+
if (this.spin.current === "pressed") {
|
|
257
|
+
this.spin.setState("idle");
|
|
258
|
+
this.spin.activate();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
onUpOutside = () => {
|
|
262
|
+
if (this.holding) return this.endHold();
|
|
263
|
+
this.clearHoldTimer();
|
|
264
|
+
if (this.spin.current === "pressed") this.spin.setState("idle");
|
|
265
|
+
};
|
|
266
|
+
endHoldGlobal = () => this.endHold();
|
|
267
|
+
clearHoldTimer() {
|
|
268
|
+
if (this.holdTimer != null) {
|
|
269
|
+
clearTimeout(this.holdTimer);
|
|
270
|
+
this.holdTimer = void 0;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
endHold() {
|
|
274
|
+
if (!this.holding) return;
|
|
275
|
+
this.holding = false;
|
|
276
|
+
if (typeof window !== "undefined") {
|
|
277
|
+
window.removeEventListener("pointerup", this.endHoldGlobal);
|
|
278
|
+
window.removeEventListener("pointercancel", this.endHoldGlobal);
|
|
279
|
+
}
|
|
280
|
+
this.spin.holdEnd();
|
|
281
|
+
if (this.spin.current === "pressed") this.spin.setState("idle");
|
|
282
|
+
}
|
|
283
|
+
updateInteractive() {
|
|
284
|
+
const ok = this.spin.interactable;
|
|
285
|
+
this.eventMode = ok ? "static" : "none";
|
|
286
|
+
this.cursor = ok ? "pointer" : "default";
|
|
287
|
+
const inSpin = this.spin.current === "spinning" || this.spin.current === "auto" || this.spin.current === "stop";
|
|
288
|
+
this.art.alpha = !this.spin.allowSlamStop.get() && inSpin ? 0.45 : 1;
|
|
289
|
+
}
|
|
290
|
+
play(t) {
|
|
291
|
+
this.animating = true;
|
|
292
|
+
void this.tween.run(this.art, t, this.ui.theme).then(() => {
|
|
293
|
+
this.animating = false;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
dispose() {
|
|
297
|
+
this.clearHoldTimer();
|
|
298
|
+
this.endHold();
|
|
299
|
+
this.tween.stop();
|
|
300
|
+
this.skin.destroy();
|
|
301
|
+
super.dispose();
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
var __defProp = Object.defineProperty;
|
|
305
|
+
var __export = (target, all) => {
|
|
306
|
+
for (var name in all)
|
|
307
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
308
|
+
};
|
|
309
|
+
var CELLS_PER_STRIP = 20;
|
|
310
|
+
var Strip = class {
|
|
311
|
+
container;
|
|
312
|
+
cells;
|
|
313
|
+
renderer;
|
|
314
|
+
digitHeight;
|
|
315
|
+
dirtyLow = 1;
|
|
316
|
+
dirtyHigh = 0;
|
|
317
|
+
constructor(renderer, digitHeight) {
|
|
318
|
+
this.container = new Container();
|
|
319
|
+
this.renderer = renderer;
|
|
320
|
+
this.digitHeight = digitHeight;
|
|
321
|
+
this.cells = new Array(CELLS_PER_STRIP);
|
|
322
|
+
for (let i = 0; i < CELLS_PER_STRIP; i++) {
|
|
323
|
+
const cell = renderer.createCell(i % 10);
|
|
324
|
+
cell.y = i * digitHeight;
|
|
325
|
+
this.cells[i] = cell;
|
|
326
|
+
this.container.addChild(cell);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
paintFillers(fromIdx, toIdx) {
|
|
330
|
+
const cells = this.cells;
|
|
331
|
+
if (this.dirtyHigh >= this.dirtyLow) {
|
|
332
|
+
for (let i = this.dirtyLow; i <= this.dirtyHigh; i++) {
|
|
333
|
+
this.renderer.setDigit(cells[i], i % 10);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const lo = fromIdx < toIdx ? fromIdx : toIdx;
|
|
337
|
+
const hi = fromIdx < toIdx ? toIdx : fromIdx;
|
|
338
|
+
const fillStart = lo + 1;
|
|
339
|
+
const fillEnd = hi - 1;
|
|
340
|
+
if (fillEnd < fillStart) {
|
|
341
|
+
this.dirtyLow = 1;
|
|
342
|
+
this.dirtyHigh = 0;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
for (let i = fillStart; i <= fillEnd; i++) {
|
|
346
|
+
this.renderer.setFiller(cells[i], i % 10);
|
|
347
|
+
}
|
|
348
|
+
this.dirtyLow = fillStart;
|
|
349
|
+
this.dirtyHigh = fillEnd;
|
|
350
|
+
}
|
|
351
|
+
clearFillers() {
|
|
352
|
+
if (this.dirtyHigh < this.dirtyLow) return;
|
|
353
|
+
const cells = this.cells;
|
|
354
|
+
for (let i = this.dirtyLow; i <= this.dirtyHigh; i++) {
|
|
355
|
+
this.renderer.setDigit(cells[i], i % 10);
|
|
356
|
+
}
|
|
357
|
+
this.dirtyLow = 1;
|
|
358
|
+
this.dirtyHigh = 0;
|
|
359
|
+
}
|
|
360
|
+
setY(y) {
|
|
361
|
+
this.container.y = y;
|
|
362
|
+
}
|
|
363
|
+
yForIndex(index) {
|
|
364
|
+
return -index * this.digitHeight;
|
|
365
|
+
}
|
|
366
|
+
destroy() {
|
|
367
|
+
const cells = this.cells;
|
|
368
|
+
if (this.renderer.destroyCell) {
|
|
369
|
+
for (let i = 0; i < CELLS_PER_STRIP; i++) {
|
|
370
|
+
this.renderer.destroyCell(cells[i]);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
this.container.destroy({ children: true });
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
var DigitColumn = class {
|
|
377
|
+
container;
|
|
378
|
+
strip;
|
|
379
|
+
mask;
|
|
380
|
+
digitWidth;
|
|
381
|
+
digitHeight;
|
|
382
|
+
currentIndex = 0;
|
|
383
|
+
positionTweenIndex = -1;
|
|
384
|
+
alphaTweenIndex = -1;
|
|
385
|
+
constructor(renderer, digitWidth, digitHeight) {
|
|
386
|
+
this.digitWidth = digitWidth;
|
|
387
|
+
this.digitHeight = digitHeight;
|
|
388
|
+
this.container = new Container();
|
|
389
|
+
this.strip = new Strip(renderer, digitHeight);
|
|
390
|
+
this.container.addChild(this.strip.container);
|
|
391
|
+
this.mask = new Graphics();
|
|
392
|
+
this.mask.rect(0, 0, digitWidth, digitHeight).fill({ color: 16777215 });
|
|
393
|
+
this.container.addChild(this.mask);
|
|
394
|
+
this.strip.container.mask = this.mask;
|
|
395
|
+
this.setDigit(0);
|
|
396
|
+
}
|
|
397
|
+
setDigit(digit) {
|
|
398
|
+
const idx = (digit % 10 + 10) % 10;
|
|
399
|
+
this.currentIndex = idx;
|
|
400
|
+
this.strip.setY(this.strip.yForIndex(idx));
|
|
401
|
+
this.strip.clearFillers();
|
|
402
|
+
}
|
|
403
|
+
get currentDigit() {
|
|
404
|
+
return this.currentIndex % 10;
|
|
405
|
+
}
|
|
406
|
+
paintFillers(fromIdx, toIdx) {
|
|
407
|
+
this.strip.paintFillers(fromIdx, toIdx);
|
|
408
|
+
}
|
|
409
|
+
getStripY() {
|
|
410
|
+
return this.strip.container.y;
|
|
411
|
+
}
|
|
412
|
+
setStripY(y) {
|
|
413
|
+
this.strip.setY(y);
|
|
414
|
+
}
|
|
415
|
+
commitIndex(index) {
|
|
416
|
+
this.currentIndex = (index % 10 + 10) % 10;
|
|
417
|
+
this.strip.setY(this.strip.yForIndex(this.currentIndex));
|
|
418
|
+
this.strip.clearFillers();
|
|
419
|
+
}
|
|
420
|
+
destroy() {
|
|
421
|
+
this.mask.destroy();
|
|
422
|
+
this.strip.destroy();
|
|
423
|
+
this.container.destroy({ children: true });
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
function getSeparatorAfter(digits, every, decimals = 0) {
|
|
427
|
+
if (!every || every < 1 || digits < 2) return [];
|
|
428
|
+
const out = [];
|
|
429
|
+
for (let i = 0; i < digits - 1; i++) {
|
|
430
|
+
const placeFromRight = digits - 1 - i;
|
|
431
|
+
const integerPlace = placeFromRight - decimals;
|
|
432
|
+
if (integerPlace > 0 && integerPlace % every === 0) out.push(i);
|
|
433
|
+
}
|
|
434
|
+
return out;
|
|
435
|
+
}
|
|
436
|
+
function getDecimalSeparatorAfter(digits, decimals) {
|
|
437
|
+
if (decimals <= 0 || decimals >= digits) return -1;
|
|
438
|
+
return digits - decimals - 1;
|
|
439
|
+
}
|
|
440
|
+
function placeColumns(digits, digitWidth, separatorAfterColumns, separatorWidth) {
|
|
441
|
+
const columnX = new Array(digits);
|
|
442
|
+
const separatorX = [];
|
|
443
|
+
let x = 0;
|
|
444
|
+
let sepIdx = 0;
|
|
445
|
+
for (let i = 0; i < digits; i++) {
|
|
446
|
+
columnX[i] = x;
|
|
447
|
+
x += digitWidth;
|
|
448
|
+
if (sepIdx < separatorAfterColumns.length && separatorAfterColumns[sepIdx] === i) {
|
|
449
|
+
separatorX.push(x);
|
|
450
|
+
x += separatorWidth;
|
|
451
|
+
sepIdx++;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return { columnX, separatorX, totalWidth: x };
|
|
455
|
+
}
|
|
456
|
+
function digitAtPlace(value, place) {
|
|
457
|
+
return Math.floor(Math.abs(value) / Math.pow(10, place)) % 10;
|
|
458
|
+
}
|
|
459
|
+
function leadingZeroCount(value, digits, decimals = 0) {
|
|
460
|
+
const integerDigits = digits - decimals;
|
|
461
|
+
if (integerDigits <= 0) return 0;
|
|
462
|
+
const integerValue = Math.floor(Math.abs(value) / Math.pow(10, decimals));
|
|
463
|
+
if (integerValue <= 0) return integerDigits - 1;
|
|
464
|
+
let count = 0;
|
|
465
|
+
for (let i = integerDigits - 1; i > 0; i--) {
|
|
466
|
+
if (Math.floor(integerValue / Math.pow(10, i)) % 10 === 0) count++;
|
|
467
|
+
else break;
|
|
468
|
+
}
|
|
469
|
+
return count;
|
|
470
|
+
}
|
|
471
|
+
function computeSteps(oldDigit, newDigit, direction) {
|
|
472
|
+
return direction === "down" ? (oldDigit - newDigit + 10) % 10 || 10 : (newDigit - oldDigit + 10) % 10 || 10;
|
|
473
|
+
}
|
|
474
|
+
function computeDuration(distance, placeFromRight, motion) {
|
|
475
|
+
const raw = motion.msPerStep * distance + motion.placeDurationBump * placeFromRight;
|
|
476
|
+
if (raw < motion.minMs) return motion.minMs;
|
|
477
|
+
if (raw > motion.maxMs) return motion.maxMs;
|
|
478
|
+
return raw;
|
|
479
|
+
}
|
|
480
|
+
function resolveTargetIndex(fromIdx, newDigit, direction) {
|
|
481
|
+
if (direction === "up") {
|
|
482
|
+
let norm2 = fromIdx;
|
|
483
|
+
while (norm2 >= 10) norm2 -= 10;
|
|
484
|
+
while (norm2 < 0) norm2 += 10;
|
|
485
|
+
const toIdx2 = newDigit > norm2 ? newDigit : newDigit + 10;
|
|
486
|
+
return { normalizedFromIdx: norm2, toIdx: toIdx2 };
|
|
487
|
+
}
|
|
488
|
+
let norm = fromIdx;
|
|
489
|
+
while (norm < 10) norm += 10;
|
|
490
|
+
while (norm >= 20) norm -= 10;
|
|
491
|
+
const toIdx = newDigit + 10 < norm ? newDigit + 10 : newDigit;
|
|
492
|
+
return { normalizedFromIdx: norm, toIdx };
|
|
493
|
+
}
|
|
494
|
+
function resolveDirection(hint, oldValue, newValue) {
|
|
495
|
+
if (hint === "up") return "up";
|
|
496
|
+
if (hint === "down") return "down";
|
|
497
|
+
return newValue >= oldValue ? "up" : "down";
|
|
498
|
+
}
|
|
499
|
+
function createInactiveTween() {
|
|
500
|
+
return {
|
|
501
|
+
active: false,
|
|
502
|
+
startTime: 0,
|
|
503
|
+
delay: 0,
|
|
504
|
+
duration: 0,
|
|
505
|
+
startValue: 0,
|
|
506
|
+
targetValue: 0,
|
|
507
|
+
currentValue: 0,
|
|
508
|
+
ease: (t) => t,
|
|
509
|
+
rollId: 0
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
var NOOP_COMPLETE = () => void 0;
|
|
513
|
+
var Scheduler = class {
|
|
514
|
+
ticker;
|
|
515
|
+
tweens;
|
|
516
|
+
onApply;
|
|
517
|
+
onTweenComplete;
|
|
518
|
+
activeCount = 0;
|
|
519
|
+
attached = false;
|
|
520
|
+
constructor(ticker, tweenCount, onApply, onTweenComplete = NOOP_COMPLETE) {
|
|
521
|
+
this.ticker = ticker;
|
|
522
|
+
this.onApply = onApply;
|
|
523
|
+
this.onTweenComplete = onTweenComplete;
|
|
524
|
+
this.tweens = new Array(tweenCount);
|
|
525
|
+
for (let i = 0; i < tweenCount; i++) this.tweens[i] = createInactiveTween();
|
|
526
|
+
}
|
|
527
|
+
get(index) {
|
|
528
|
+
return this.tweens[index];
|
|
529
|
+
}
|
|
530
|
+
get tweenCount() {
|
|
531
|
+
return this.tweens.length;
|
|
532
|
+
}
|
|
533
|
+
get activeTweenCount() {
|
|
534
|
+
return this.activeCount;
|
|
535
|
+
}
|
|
536
|
+
get hasActive() {
|
|
537
|
+
return this.activeCount > 0;
|
|
538
|
+
}
|
|
539
|
+
start(index, now = performance.now()) {
|
|
540
|
+
const t = this.tweens[index];
|
|
541
|
+
if (!t.active) {
|
|
542
|
+
t.active = true;
|
|
543
|
+
this.activeCount++;
|
|
544
|
+
}
|
|
545
|
+
t.startTime = now;
|
|
546
|
+
if (!this.attached) {
|
|
547
|
+
this.ticker.add(this.tick);
|
|
548
|
+
this.attached = true;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
stop(index) {
|
|
552
|
+
const t = this.tweens[index];
|
|
553
|
+
if (!t.active) return;
|
|
554
|
+
t.active = false;
|
|
555
|
+
this.activeCount--;
|
|
556
|
+
if (this.activeCount === 0) this.detach();
|
|
557
|
+
}
|
|
558
|
+
finish(index) {
|
|
559
|
+
const t = this.tweens[index];
|
|
560
|
+
if (!t.active) return;
|
|
561
|
+
const final = t.startValue + (t.targetValue - t.startValue) * t.ease(1);
|
|
562
|
+
t.currentValue = final;
|
|
563
|
+
t.active = false;
|
|
564
|
+
this.activeCount--;
|
|
565
|
+
this.onApply(index, final);
|
|
566
|
+
this.onTweenComplete(index);
|
|
567
|
+
if (this.activeCount === 0) this.detach();
|
|
568
|
+
}
|
|
569
|
+
finishAll() {
|
|
570
|
+
const tweens = this.tweens;
|
|
571
|
+
for (let i = 0, n = tweens.length; i < n; i++) {
|
|
572
|
+
if (tweens[i].active) this.finish(i);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
destroy() {
|
|
576
|
+
this.detach();
|
|
577
|
+
this.activeCount = 0;
|
|
578
|
+
}
|
|
579
|
+
step(now = performance.now()) {
|
|
580
|
+
this.tickImpl(now);
|
|
581
|
+
}
|
|
582
|
+
detach() {
|
|
583
|
+
if (this.attached) {
|
|
584
|
+
this.ticker.remove(this.tick);
|
|
585
|
+
this.attached = false;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
tick = () => {
|
|
589
|
+
if (this.activeCount === 0) {
|
|
590
|
+
this.detach();
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
this.tickImpl(performance.now());
|
|
594
|
+
};
|
|
595
|
+
tickImpl(now) {
|
|
596
|
+
const tweens = this.tweens;
|
|
597
|
+
for (let i = 0, n = tweens.length; i < n; i++) {
|
|
598
|
+
const t = tweens[i];
|
|
599
|
+
if (!t.active) continue;
|
|
600
|
+
const elapsed = now - t.startTime - t.delay;
|
|
601
|
+
if (elapsed < 0) {
|
|
602
|
+
t.currentValue = t.startValue;
|
|
603
|
+
this.onApply(i, t.currentValue);
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (elapsed >= t.duration) {
|
|
607
|
+
const final = t.startValue + (t.targetValue - t.startValue) * t.ease(1);
|
|
608
|
+
t.currentValue = final;
|
|
609
|
+
t.active = false;
|
|
610
|
+
this.activeCount--;
|
|
611
|
+
this.onApply(i, final);
|
|
612
|
+
this.onTweenComplete(i);
|
|
613
|
+
} else {
|
|
614
|
+
const p = t.ease(elapsed / t.duration);
|
|
615
|
+
t.currentValue = t.startValue + (t.targetValue - t.startValue) * p;
|
|
616
|
+
this.onApply(i, t.currentValue);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
var ease_exports = {};
|
|
622
|
+
__export(ease_exports, {
|
|
623
|
+
cubicOut: () => cubicOut,
|
|
624
|
+
defaultEase: () => defaultEase,
|
|
625
|
+
expoOut: () => expoOut,
|
|
626
|
+
linear: () => linear,
|
|
627
|
+
quadOut: () => quadOut,
|
|
628
|
+
quartOut: () => quartOut,
|
|
629
|
+
quintOut: () => quintOut,
|
|
630
|
+
sineInOut: () => sineInOut,
|
|
631
|
+
slotRoll: () => slotRoll
|
|
632
|
+
});
|
|
633
|
+
var linear = (t) => t;
|
|
634
|
+
var quadOut = (t) => 1 - (1 - t) * (1 - t);
|
|
635
|
+
var cubicOut = (t) => 1 - Math.pow(1 - t, 3);
|
|
636
|
+
var quartOut = (t) => 1 - Math.pow(1 - t, 4);
|
|
637
|
+
var quintOut = (t) => 1 - Math.pow(1 - t, 5);
|
|
638
|
+
var expoOut = (t) => t >= 1 ? 1 : 1 - Math.pow(2, -10 * t);
|
|
639
|
+
var sineInOut = (t) => -(Math.cos(Math.PI * t) - 1) / 2;
|
|
640
|
+
var slotRoll = (t) => 1 - Math.pow(1 - t, 4.5);
|
|
641
|
+
var defaultEase = slotRoll;
|
|
642
|
+
var DEFAULTS = {
|
|
643
|
+
motion: {
|
|
644
|
+
msPerStep: 35,
|
|
645
|
+
staggerMs: 28,
|
|
646
|
+
placeDurationBump: 25,
|
|
647
|
+
minMs: 280,
|
|
648
|
+
maxMs: 620
|
|
649
|
+
},
|
|
650
|
+
leadingZeros: {
|
|
651
|
+
mode: "show",
|
|
652
|
+
alpha: 0.35,
|
|
653
|
+
tweenMs: 150
|
|
654
|
+
},
|
|
655
|
+
blur: {
|
|
656
|
+
enabled: false,
|
|
657
|
+
peak: 8
|
|
658
|
+
},
|
|
659
|
+
separatorEvery: 3
|
|
660
|
+
};
|
|
661
|
+
var pulseSin = (t) => Math.sin(Math.PI * t);
|
|
662
|
+
var Counter = class extends Container {
|
|
663
|
+
digits;
|
|
664
|
+
digitWidth;
|
|
665
|
+
digitHeight;
|
|
666
|
+
cellRenderer;
|
|
667
|
+
motion;
|
|
668
|
+
leadingZeros;
|
|
669
|
+
blurOpt;
|
|
670
|
+
tickerRef;
|
|
671
|
+
columns;
|
|
672
|
+
separators;
|
|
673
|
+
sepAfterCol;
|
|
674
|
+
sepAlwaysVisible;
|
|
675
|
+
digitRow;
|
|
676
|
+
blurFilter;
|
|
677
|
+
maxValue;
|
|
678
|
+
decimals;
|
|
679
|
+
columnXLocal;
|
|
680
|
+
fullWidth;
|
|
681
|
+
fitOpt;
|
|
682
|
+
ALPHA_BASE;
|
|
683
|
+
BLUR_INDEX;
|
|
684
|
+
value;
|
|
685
|
+
scheduler;
|
|
686
|
+
prefixContainer = null;
|
|
687
|
+
suffixContainer = null;
|
|
688
|
+
currentRollId = 0;
|
|
689
|
+
activeRollCount = 0;
|
|
690
|
+
pendingResolve = null;
|
|
691
|
+
pendingOnComplete = null;
|
|
692
|
+
_rollStartPayload = { from: 0, to: 0, direction: "up" };
|
|
693
|
+
_rollEndPayload = { value: 0 };
|
|
694
|
+
_digitSettlePayload = { column: 0, digit: 0 };
|
|
695
|
+
constructor(options) {
|
|
696
|
+
super();
|
|
697
|
+
if (options.digits < 1) throw new Error("Counter: digits must be >= 1");
|
|
698
|
+
this.digits = options.digits;
|
|
699
|
+
this.digitWidth = options.digitWidth;
|
|
700
|
+
this.digitHeight = options.digitHeight;
|
|
701
|
+
this.cellRenderer = options.cellRenderer;
|
|
702
|
+
this.tickerRef = options.ticker ?? Ticker.shared;
|
|
703
|
+
this.decimals = options.decimals ?? 0;
|
|
704
|
+
if (this.decimals < 0) throw new Error("Counter: decimals must be >= 0");
|
|
705
|
+
if (this.decimals >= this.digits) {
|
|
706
|
+
throw new Error("Counter: decimals must be less than digits");
|
|
707
|
+
}
|
|
708
|
+
this.maxValue = Math.pow(10, this.digits) - 1;
|
|
709
|
+
this.value = this.clampValue(options.initialValue ?? 0);
|
|
710
|
+
this.motion = {
|
|
711
|
+
msPerStep: options.motion?.msPerStep ?? DEFAULTS.motion.msPerStep,
|
|
712
|
+
staggerMs: options.motion?.staggerMs ?? DEFAULTS.motion.staggerMs,
|
|
713
|
+
placeDurationBump: options.motion?.placeDurationBump ?? DEFAULTS.motion.placeDurationBump,
|
|
714
|
+
minMs: options.motion?.minMs ?? DEFAULTS.motion.minMs,
|
|
715
|
+
maxMs: options.motion?.maxMs ?? DEFAULTS.motion.maxMs,
|
|
716
|
+
ease: options.motion?.ease ?? defaultEase
|
|
717
|
+
};
|
|
718
|
+
this.leadingZeros = {
|
|
719
|
+
mode: options.leadingZeros?.mode ?? DEFAULTS.leadingZeros.mode,
|
|
720
|
+
alpha: options.leadingZeros?.alpha ?? DEFAULTS.leadingZeros.alpha,
|
|
721
|
+
tweenMs: options.leadingZeros?.tweenMs ?? DEFAULTS.leadingZeros.tweenMs
|
|
722
|
+
};
|
|
723
|
+
this.blurOpt = {
|
|
724
|
+
enabled: options.blur?.enabled ?? DEFAULTS.blur.enabled,
|
|
725
|
+
peak: options.blur?.peak ?? DEFAULTS.blur.peak
|
|
726
|
+
};
|
|
727
|
+
this.ALPHA_BASE = this.digits;
|
|
728
|
+
this.BLUR_INDEX = 2 * this.digits;
|
|
729
|
+
if (options.prefix) {
|
|
730
|
+
this.prefixContainer = this.coerceContainer(options.prefix);
|
|
731
|
+
this.addChild(this.prefixContainer);
|
|
732
|
+
}
|
|
733
|
+
this.digitRow = new Container();
|
|
734
|
+
this.addChild(this.digitRow);
|
|
735
|
+
this.columns = new Array(this.digits);
|
|
736
|
+
for (let i = 0; i < this.digits; i++) {
|
|
737
|
+
const col = new DigitColumn(this.cellRenderer, this.digitWidth, this.digitHeight);
|
|
738
|
+
col.positionTweenIndex = i;
|
|
739
|
+
col.alphaTweenIndex = this.ALPHA_BASE + i;
|
|
740
|
+
this.columns[i] = col;
|
|
741
|
+
this.digitRow.addChild(col.container);
|
|
742
|
+
}
|
|
743
|
+
const sepChar = options.separator?.char;
|
|
744
|
+
const sepEvery = options.separator?.every ?? DEFAULTS.separatorEvery;
|
|
745
|
+
const decimalChar = options.decimalChar ?? ".";
|
|
746
|
+
const thousandsCols = sepChar ? getSeparatorAfter(this.digits, sepEvery, this.decimals) : [];
|
|
747
|
+
const decimalCol = getDecimalSeparatorAfter(this.digits, this.decimals);
|
|
748
|
+
const sepCols = [];
|
|
749
|
+
const sepChars = [];
|
|
750
|
+
const sepAlwaysVisible = [];
|
|
751
|
+
let ti = 0;
|
|
752
|
+
for (let col = 0; col < this.digits - 1; col++) {
|
|
753
|
+
if (ti < thousandsCols.length && thousandsCols[ti] === col) {
|
|
754
|
+
sepCols.push(col);
|
|
755
|
+
sepChars.push(sepChar);
|
|
756
|
+
sepAlwaysVisible.push(false);
|
|
757
|
+
ti++;
|
|
758
|
+
}
|
|
759
|
+
if (col === decimalCol) {
|
|
760
|
+
sepCols.push(col);
|
|
761
|
+
sepChars.push(decimalChar);
|
|
762
|
+
sepAlwaysVisible.push(true);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
this.separators = new Array(sepCols.length);
|
|
766
|
+
this.sepAfterCol = new Array(this.digits).fill(-1);
|
|
767
|
+
this.sepAlwaysVisible = sepAlwaysVisible;
|
|
768
|
+
let sepWidth = 0;
|
|
769
|
+
if (sepCols.length > 0 && this.cellRenderer.createSeparator) {
|
|
770
|
+
for (let i = 0; i < sepCols.length; i++) {
|
|
771
|
+
const sep = this.cellRenderer.createSeparator(sepChars[i]);
|
|
772
|
+
this.separators[i] = sep;
|
|
773
|
+
this.digitRow.addChild(sep);
|
|
774
|
+
this.sepAfterCol[sepCols[i]] = i;
|
|
775
|
+
if (sep.width > sepWidth) sepWidth = sep.width;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
const layout = placeColumns(this.digits, this.digitWidth, sepCols, sepWidth);
|
|
779
|
+
this.columnXLocal = layout.columnX.slice();
|
|
780
|
+
for (let i = 0; i < this.digits; i++) {
|
|
781
|
+
this.columns[i].container.x = layout.columnX[i];
|
|
782
|
+
}
|
|
783
|
+
for (let i = 0; i < this.separators.length; i++) {
|
|
784
|
+
this.separators[i].x = layout.separatorX[i];
|
|
785
|
+
}
|
|
786
|
+
if (this.prefixContainer) {
|
|
787
|
+
const prefixWidth = this.prefixContainer.width;
|
|
788
|
+
this.digitRow.x = prefixWidth;
|
|
789
|
+
}
|
|
790
|
+
let suffixWidth = 0;
|
|
791
|
+
if (options.suffix) {
|
|
792
|
+
this.suffixContainer = this.coerceContainer(options.suffix);
|
|
793
|
+
this.suffixContainer.x = this.digitRow.x + layout.totalWidth;
|
|
794
|
+
this.addChild(this.suffixContainer);
|
|
795
|
+
suffixWidth = this.suffixContainer.width;
|
|
796
|
+
}
|
|
797
|
+
this.fullWidth = this.digitRow.x + layout.totalWidth + suffixWidth;
|
|
798
|
+
if (options.fit) {
|
|
799
|
+
this.fitOpt = {
|
|
800
|
+
maxWidth: options.fit.maxWidth,
|
|
801
|
+
minScale: options.fit.minScale ?? 0.4,
|
|
802
|
+
duration: options.fit.duration ?? 0.3,
|
|
803
|
+
ease: options.fit.ease ?? "power2.out",
|
|
804
|
+
anchor: options.fit.anchor ?? "left",
|
|
805
|
+
gsap: options.fit.gsap
|
|
806
|
+
};
|
|
807
|
+
this.pivot.x = this.fitOpt.anchor === "right" ? this.fullWidth : this.fitOpt.anchor === "center" ? this.fullWidth / 2 : 0;
|
|
808
|
+
const initialScale = this.computeFitScale(this.value);
|
|
809
|
+
this.scale.set(initialScale);
|
|
810
|
+
} else {
|
|
811
|
+
this.fitOpt = null;
|
|
812
|
+
}
|
|
813
|
+
if (this.blurOpt.enabled) {
|
|
814
|
+
this.blurFilter = new BlurFilter({ strength: 0, quality: 2 });
|
|
815
|
+
this.blurFilter.strengthX = 0;
|
|
816
|
+
this.digitRow.filters = [this.blurFilter];
|
|
817
|
+
} else {
|
|
818
|
+
this.blurFilter = null;
|
|
819
|
+
}
|
|
820
|
+
this.scheduler = new Scheduler(
|
|
821
|
+
this.tickerRef,
|
|
822
|
+
2 * this.digits + 1,
|
|
823
|
+
this.onApply,
|
|
824
|
+
this.onTweenComplete
|
|
825
|
+
);
|
|
826
|
+
this.applyValueInstant(this.value);
|
|
827
|
+
}
|
|
828
|
+
getValue() {
|
|
829
|
+
return this.value;
|
|
830
|
+
}
|
|
831
|
+
isAnimating() {
|
|
832
|
+
return this.scheduler.hasActive;
|
|
833
|
+
}
|
|
834
|
+
setValue(value, opts = {}) {
|
|
835
|
+
const target = this.clampValue(value);
|
|
836
|
+
const oldValue = this.value;
|
|
837
|
+
if (opts.instant) {
|
|
838
|
+
this.resolvePending();
|
|
839
|
+
this.scheduler.finishAll();
|
|
840
|
+
this.value = target;
|
|
841
|
+
this.applyValueInstant(target);
|
|
842
|
+
this.applyFit(target, false);
|
|
843
|
+
opts.onComplete?.();
|
|
844
|
+
return Promise.resolve();
|
|
845
|
+
}
|
|
846
|
+
if (target === oldValue && !this.scheduler.hasActive) {
|
|
847
|
+
opts.onComplete?.();
|
|
848
|
+
return Promise.resolve();
|
|
849
|
+
}
|
|
850
|
+
this.applyFit(target, true);
|
|
851
|
+
this.resolvePending();
|
|
852
|
+
this.value = target;
|
|
853
|
+
const direction = resolveDirection(opts.direction, oldValue, target);
|
|
854
|
+
const now = performance.now();
|
|
855
|
+
const rollId = ++this.currentRollId;
|
|
856
|
+
this.activeRollCount = 0;
|
|
857
|
+
this.finishStaleTweens(target, rollId);
|
|
858
|
+
const changingCount = this.startColumnTweens(oldValue, target, direction, opts.duration, now, rollId);
|
|
859
|
+
if (changingCount === 0) {
|
|
860
|
+
this.startBlurTween(0, now, rollId);
|
|
861
|
+
this.startLeadingZeroTweens(target, now, rollId);
|
|
862
|
+
opts.onComplete?.();
|
|
863
|
+
return Promise.resolve();
|
|
864
|
+
}
|
|
865
|
+
this.activeRollCount = changingCount;
|
|
866
|
+
let longestEnd = 0;
|
|
867
|
+
for (let col = 0; col < this.digits; col++) {
|
|
868
|
+
const t = this.scheduler.get(col);
|
|
869
|
+
if (t.active && t.rollId === rollId) {
|
|
870
|
+
const end = t.delay + t.duration;
|
|
871
|
+
if (end > longestEnd) longestEnd = end;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
this.startBlurTween(longestEnd, now, rollId);
|
|
875
|
+
this.startLeadingZeroTweens(target, now, rollId);
|
|
876
|
+
this._rollStartPayload.from = oldValue;
|
|
877
|
+
this._rollStartPayload.to = target;
|
|
878
|
+
this._rollStartPayload.direction = direction;
|
|
879
|
+
this.emit("rollstart", this._rollStartPayload);
|
|
880
|
+
return new Promise((resolve) => {
|
|
881
|
+
this.pendingResolve = resolve;
|
|
882
|
+
this.pendingOnComplete = opts.onComplete ?? null;
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Skip the in-flight animation straight to its current target value.
|
|
887
|
+
*
|
|
888
|
+
* - Every active position tween jumps to its target Y (the column shows the
|
|
889
|
+
* target digit, sharp).
|
|
890
|
+
* - Leading-zero alpha tweens jump to their target alpha (dim / hidden / full).
|
|
891
|
+
* - The blur tween snaps to 0 (no residual blur).
|
|
892
|
+
* - `digitsettle` fires for each settling column, then `rollend` fires once.
|
|
893
|
+
* - The pending `setValue` Promise resolves.
|
|
894
|
+
*
|
|
895
|
+
* Use it to fast-forward when the player has impatiently queued another input:
|
|
896
|
+
*
|
|
897
|
+
* ```ts
|
|
898
|
+
* function onBetClick() {
|
|
899
|
+
* counter.cancel(); // snap any in-flight roll to its end
|
|
900
|
+
* counter.setValue(balance); // start a fresh roll from there
|
|
901
|
+
* }
|
|
902
|
+
* ```
|
|
903
|
+
*
|
|
904
|
+
* If no roll is in flight, this is a cheap no-op. Safe to call on every input.
|
|
905
|
+
*/
|
|
906
|
+
cancel() {
|
|
907
|
+
this.scheduler.finishAll();
|
|
908
|
+
this.resolvePending();
|
|
909
|
+
}
|
|
910
|
+
destroy(options) {
|
|
911
|
+
this.scheduler.destroy();
|
|
912
|
+
this.resolvePending();
|
|
913
|
+
if (this.fitOpt) this.fitOpt.gsap.killTweensOf(this.scale);
|
|
914
|
+
for (let i = 0; i < this.columns.length; i++) this.columns[i].destroy();
|
|
915
|
+
if (this.blurFilter) this.blurFilter.destroy();
|
|
916
|
+
super.destroy(options);
|
|
917
|
+
}
|
|
918
|
+
computeFitScale(value) {
|
|
919
|
+
if (!this.fitOpt) return 1;
|
|
920
|
+
const visibleWidth = this.computeVisibleWidth(value);
|
|
921
|
+
if (visibleWidth <= 0) return 1;
|
|
922
|
+
const raw = this.fitOpt.maxWidth / visibleWidth;
|
|
923
|
+
if (raw >= 1) return 1;
|
|
924
|
+
return Math.max(this.fitOpt.minScale, raw);
|
|
925
|
+
}
|
|
926
|
+
computeVisibleWidth(value) {
|
|
927
|
+
if (this.leadingZeros.mode !== "hide") return this.fullWidth;
|
|
928
|
+
const dimCount = leadingZeroCount(value, this.digits, this.decimals);
|
|
929
|
+
if (dimCount >= this.digits) return 0;
|
|
930
|
+
const leftEdge = this.columnXLocal[dimCount] + this.digitRow.x;
|
|
931
|
+
return this.fullWidth - leftEdge;
|
|
932
|
+
}
|
|
933
|
+
applyFit(value, animated) {
|
|
934
|
+
if (!this.fitOpt) return;
|
|
935
|
+
const target = this.computeFitScale(value);
|
|
936
|
+
const gsap = this.fitOpt.gsap;
|
|
937
|
+
gsap.killTweensOf(this.scale);
|
|
938
|
+
if (!animated || this.scale.x === target && this.scale.y === target) {
|
|
939
|
+
this.scale.set(target);
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
gsap.to(this.scale, {
|
|
943
|
+
x: target,
|
|
944
|
+
y: target,
|
|
945
|
+
duration: this.fitOpt.duration,
|
|
946
|
+
ease: this.fitOpt.ease
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
clampValue(value) {
|
|
950
|
+
const i = Math.floor(value);
|
|
951
|
+
if (i < 0) return 0;
|
|
952
|
+
if (i > this.maxValue) return this.maxValue;
|
|
953
|
+
return i;
|
|
954
|
+
}
|
|
955
|
+
coerceContainer(value) {
|
|
956
|
+
if (typeof value !== "string") return value;
|
|
957
|
+
if (this.cellRenderer.createSeparator) return this.cellRenderer.createSeparator(value);
|
|
958
|
+
return new Container();
|
|
959
|
+
}
|
|
960
|
+
applyValueInstant(value) {
|
|
961
|
+
for (let col = 0; col < this.digits; col++) {
|
|
962
|
+
const placeFromRight = this.digits - 1 - col;
|
|
963
|
+
const digit = digitAtPlace(value, placeFromRight);
|
|
964
|
+
this.columns[col].setDigit(digit);
|
|
965
|
+
}
|
|
966
|
+
this.applyLeadingZerosInstant(value);
|
|
967
|
+
}
|
|
968
|
+
applyLeadingZerosInstant(value) {
|
|
969
|
+
const dimCount = this.leadingZeros.mode === "show" ? 0 : leadingZeroCount(value, this.digits, this.decimals);
|
|
970
|
+
const dimAlpha = this.leadingZeros.mode === "hide" ? 0 : this.leadingZeros.alpha;
|
|
971
|
+
for (let col = 0; col < this.digits; col++) {
|
|
972
|
+
const wantAlpha = col < dimCount ? dimAlpha : 1;
|
|
973
|
+
this.columns[col].container.alpha = wantAlpha;
|
|
974
|
+
const sepIdx = this.sepAfterCol[col];
|
|
975
|
+
if (sepIdx >= 0 && !this.sepAlwaysVisible[sepIdx]) {
|
|
976
|
+
this.separators[sepIdx].alpha = wantAlpha;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
finishStaleTweens(target, _rollId) {
|
|
981
|
+
for (let col = 0; col < this.digits; col++) {
|
|
982
|
+
const t = this.scheduler.get(col);
|
|
983
|
+
if (!t.active) continue;
|
|
984
|
+
const placeFromRight = this.digits - 1 - col;
|
|
985
|
+
const newDigit = digitAtPlace(target, placeFromRight);
|
|
986
|
+
const targetIdx = Math.round(-t.targetValue / this.digitHeight);
|
|
987
|
+
const targetDigit = (targetIdx % 10 + 10) % 10;
|
|
988
|
+
if (newDigit === targetDigit) {
|
|
989
|
+
this.scheduler.finish(col);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
startColumnTweens(oldValue, target, direction, durationOverride, now, rollId) {
|
|
994
|
+
let changingCount = 0;
|
|
995
|
+
for (let col = 0; col < this.digits; col++) {
|
|
996
|
+
const placeFromRight = this.digits - 1 - col;
|
|
997
|
+
const oldDigit = digitAtPlace(oldValue, placeFromRight);
|
|
998
|
+
const newDigit = digitAtPlace(target, placeFromRight);
|
|
999
|
+
if (oldDigit === newDigit) continue;
|
|
1000
|
+
const column = this.columns[col];
|
|
1001
|
+
const rawFromIdx = -column.getStripY() / this.digitHeight;
|
|
1002
|
+
const { normalizedFromIdx, toIdx } = resolveTargetIndex(rawFromIdx, newDigit, direction);
|
|
1003
|
+
const distance = Math.abs(toIdx - normalizedFromIdx);
|
|
1004
|
+
const integerSteps = computeSteps(oldDigit, newDigit, direction);
|
|
1005
|
+
const distanceForDuration = distance > 0 ? distance : integerSteps;
|
|
1006
|
+
const duration = durationOverride ?? computeDuration(distanceForDuration, placeFromRight, this.motion);
|
|
1007
|
+
const delay = changingCount * this.motion.staggerMs;
|
|
1008
|
+
const fromY = -normalizedFromIdx * this.digitHeight;
|
|
1009
|
+
const targetY = -toIdx * this.digitHeight;
|
|
1010
|
+
column.setStripY(fromY);
|
|
1011
|
+
column.paintFillers(Math.floor(normalizedFromIdx), toIdx);
|
|
1012
|
+
const t = this.scheduler.get(col);
|
|
1013
|
+
t.startValue = fromY;
|
|
1014
|
+
t.targetValue = targetY;
|
|
1015
|
+
t.duration = duration;
|
|
1016
|
+
t.delay = delay;
|
|
1017
|
+
t.ease = this.motion.ease;
|
|
1018
|
+
t.rollId = rollId;
|
|
1019
|
+
this.scheduler.start(col, now);
|
|
1020
|
+
changingCount++;
|
|
1021
|
+
}
|
|
1022
|
+
return changingCount;
|
|
1023
|
+
}
|
|
1024
|
+
startBlurTween(longestEnd, now, rollId) {
|
|
1025
|
+
if (!this.blurFilter) return;
|
|
1026
|
+
const t = this.scheduler.get(this.BLUR_INDEX);
|
|
1027
|
+
if (longestEnd <= 0) {
|
|
1028
|
+
this.blurFilter.strengthY = 0;
|
|
1029
|
+
if (t.active) this.scheduler.finish(this.BLUR_INDEX);
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
t.startValue = 0;
|
|
1033
|
+
t.targetValue = 1;
|
|
1034
|
+
t.duration = longestEnd;
|
|
1035
|
+
t.delay = 0;
|
|
1036
|
+
t.ease = pulseSin;
|
|
1037
|
+
t.rollId = rollId;
|
|
1038
|
+
this.scheduler.start(this.BLUR_INDEX, now);
|
|
1039
|
+
}
|
|
1040
|
+
startLeadingZeroTweens(target, now, rollId) {
|
|
1041
|
+
if (this.leadingZeros.mode === "show") return;
|
|
1042
|
+
const dimCount = leadingZeroCount(target, this.digits, this.decimals);
|
|
1043
|
+
const dimAlpha = this.leadingZeros.mode === "hide" ? 0 : this.leadingZeros.alpha;
|
|
1044
|
+
for (let col = 0; col < this.digits; col++) {
|
|
1045
|
+
const wantAlpha = col < dimCount ? dimAlpha : 1;
|
|
1046
|
+
const column = this.columns[col];
|
|
1047
|
+
const currentAlpha = column.container.alpha;
|
|
1048
|
+
if (Math.abs(currentAlpha - wantAlpha) < 1e-3) continue;
|
|
1049
|
+
const t = this.scheduler.get(this.ALPHA_BASE + col);
|
|
1050
|
+
t.startValue = currentAlpha;
|
|
1051
|
+
t.targetValue = wantAlpha;
|
|
1052
|
+
t.duration = this.leadingZeros.tweenMs;
|
|
1053
|
+
t.delay = 0;
|
|
1054
|
+
t.ease = linear;
|
|
1055
|
+
t.rollId = rollId;
|
|
1056
|
+
this.scheduler.start(this.ALPHA_BASE + col, now);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
onApply = (idx, value) => {
|
|
1060
|
+
if (idx < this.digits) {
|
|
1061
|
+
this.columns[idx].setStripY(value);
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
if (idx < this.BLUR_INDEX) {
|
|
1065
|
+
const colIdx = idx - this.digits;
|
|
1066
|
+
this.columns[colIdx].container.alpha = value;
|
|
1067
|
+
const sepIdx = this.sepAfterCol[colIdx];
|
|
1068
|
+
if (sepIdx >= 0 && !this.sepAlwaysVisible[sepIdx]) {
|
|
1069
|
+
this.separators[sepIdx].alpha = value;
|
|
1070
|
+
}
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
if (this.blurFilter) this.blurFilter.strengthY = value * this.blurOpt.peak;
|
|
1074
|
+
};
|
|
1075
|
+
onTweenComplete = (idx) => {
|
|
1076
|
+
if (idx >= this.digits) return;
|
|
1077
|
+
const t = this.scheduler.get(idx);
|
|
1078
|
+
const finalIdx = Math.round(-t.targetValue / this.digitHeight);
|
|
1079
|
+
const column = this.columns[idx];
|
|
1080
|
+
column.commitIndex(finalIdx);
|
|
1081
|
+
this._digitSettlePayload.column = idx;
|
|
1082
|
+
this._digitSettlePayload.digit = column.currentDigit;
|
|
1083
|
+
this.emit("digitsettle", this._digitSettlePayload);
|
|
1084
|
+
if (t.rollId !== this.currentRollId) return;
|
|
1085
|
+
if (this.activeRollCount === 0) return;
|
|
1086
|
+
this.activeRollCount--;
|
|
1087
|
+
if (this.activeRollCount === 0) {
|
|
1088
|
+
this._rollEndPayload.value = this.value;
|
|
1089
|
+
this.emit("rollend", this._rollEndPayload);
|
|
1090
|
+
this.resolvePending();
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
resolvePending() {
|
|
1094
|
+
const resolve = this.pendingResolve;
|
|
1095
|
+
const onComplete = this.pendingOnComplete;
|
|
1096
|
+
this.pendingResolve = null;
|
|
1097
|
+
this.pendingOnComplete = null;
|
|
1098
|
+
if (resolve) resolve();
|
|
1099
|
+
if (onComplete) onComplete();
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
var TextCellRenderer = class {
|
|
1103
|
+
constructor(o) {
|
|
1104
|
+
this.o = o;
|
|
1105
|
+
}
|
|
1106
|
+
o;
|
|
1107
|
+
createCell(digit) {
|
|
1108
|
+
const cell = new Container();
|
|
1109
|
+
const t = new Text({ text: String(digit), style: this.o.style });
|
|
1110
|
+
t.anchor.set(0.5, 0.5);
|
|
1111
|
+
t.x = this.o.digitWidth / 2;
|
|
1112
|
+
t.y = this.o.digitHeight / 2;
|
|
1113
|
+
cell.addChild(t);
|
|
1114
|
+
return cell;
|
|
1115
|
+
}
|
|
1116
|
+
setDigit(cell, digit) {
|
|
1117
|
+
const t = cell.children[0];
|
|
1118
|
+
const next = String(digit);
|
|
1119
|
+
if (t.text !== next) t.text = next;
|
|
1120
|
+
}
|
|
1121
|
+
setFiller(cell, digit) {
|
|
1122
|
+
const t = cell.children[0];
|
|
1123
|
+
const next = this.o.fillerChar ?? String(digit);
|
|
1124
|
+
if (t.text !== next) t.text = next;
|
|
1125
|
+
}
|
|
1126
|
+
createSeparator(char) {
|
|
1127
|
+
const cell = new Container();
|
|
1128
|
+
const t = new Text({ text: char, style: this.o.style });
|
|
1129
|
+
t.anchor.set(0.5, 0.5);
|
|
1130
|
+
cell.addChild(t);
|
|
1131
|
+
t.y = this.o.digitHeight / 2;
|
|
1132
|
+
t.x = t.width / 2;
|
|
1133
|
+
return cell;
|
|
1134
|
+
}
|
|
1135
|
+
destroyCell(cell) {
|
|
1136
|
+
cell.destroy({ children: true });
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
// src/views/ValueDisplayView.ts
|
|
1141
|
+
var DIGIT_W = 26;
|
|
1142
|
+
var DIGIT_H = 46;
|
|
1143
|
+
var FONT_SIZE = 40;
|
|
1144
|
+
var FIT_BUDGET_COLS = 9;
|
|
1145
|
+
var ValueDisplayView = class extends ControlView {
|
|
1146
|
+
constructor(vd, ui, ticker, fitGsap) {
|
|
1147
|
+
super(vd, ui);
|
|
1148
|
+
this.vd = vd;
|
|
1149
|
+
this.ticker = ticker;
|
|
1150
|
+
this.fitGsap = fitGsap;
|
|
1151
|
+
this.build();
|
|
1152
|
+
this.disposers.push(
|
|
1153
|
+
this.vd.value.subscribe(() => {
|
|
1154
|
+
if (this.destroyed) return;
|
|
1155
|
+
const cur = this.vd.currency.get();
|
|
1156
|
+
const needed = displayDigits(this.vd.get(), this.vd.digits, cur.decimals);
|
|
1157
|
+
if (this.counter && needed !== this.counter.digits) {
|
|
1158
|
+
const from = needed > this.counter.digits ? this.counter.getValue() : this.vd.minorUnits;
|
|
1159
|
+
this.buildCounter(needed, from);
|
|
1160
|
+
}
|
|
1161
|
+
void this.counter?.setValue(this.vd.minorUnits);
|
|
1162
|
+
}),
|
|
1163
|
+
this.vd.currency.subscribe(() => {
|
|
1164
|
+
if (!this.destroyed) this.rebuild();
|
|
1165
|
+
}),
|
|
1166
|
+
// re-translate the caption on language switch (guard a post-dispose emit)
|
|
1167
|
+
this.ui.locale.subscribe(() => {
|
|
1168
|
+
if (!this.destroyed) this.rebuild();
|
|
1169
|
+
})
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
vd;
|
|
1173
|
+
ticker;
|
|
1174
|
+
fitGsap;
|
|
1175
|
+
counter;
|
|
1176
|
+
caption;
|
|
1177
|
+
side() {
|
|
1178
|
+
const a = this.vd.layout.anchor;
|
|
1179
|
+
return a.includes("left") ? "left" : a.includes("right") ? "right" : "center";
|
|
1180
|
+
}
|
|
1181
|
+
build() {
|
|
1182
|
+
const theme = this.ui.theme;
|
|
1183
|
+
const side = this.side();
|
|
1184
|
+
if (this.vd.label) {
|
|
1185
|
+
this.caption = new Text({
|
|
1186
|
+
text: this.ui.t(this.vd.label).toUpperCase(),
|
|
1187
|
+
style: { fontFamily: theme.type.family, fontSize: 13, fill: theme.color.text, fontWeight: "700", letterSpacing: 2 }
|
|
1188
|
+
});
|
|
1189
|
+
this.caption.alpha = 0.55;
|
|
1190
|
+
this.caption.anchor.set(side === "left" ? 0 : side === "right" ? 1 : 0.5, 1);
|
|
1191
|
+
this.caption.y = -DIGIT_H / 2 - 3;
|
|
1192
|
+
this.addChild(this.caption);
|
|
1193
|
+
}
|
|
1194
|
+
const cur = this.vd.currency.get();
|
|
1195
|
+
this.buildCounter(displayDigits(this.vd.get(), this.vd.digits, cur.decimals), this.vd.minorUnits);
|
|
1196
|
+
}
|
|
1197
|
+
/** (Re)create the rolling counter sized to `total` columns, starting at `fromMinor`. */
|
|
1198
|
+
buildCounter(total, fromMinor) {
|
|
1199
|
+
this.counter?.destroy();
|
|
1200
|
+
const theme = this.ui.theme;
|
|
1201
|
+
const cur = this.vd.currency.get();
|
|
1202
|
+
const side = this.side();
|
|
1203
|
+
const renderer = new TextCellRenderer({
|
|
1204
|
+
style: { fontFamily: theme.type.family, fontSize: FONT_SIZE, fill: theme.color.text, fontWeight: "700" },
|
|
1205
|
+
digitWidth: DIGIT_W,
|
|
1206
|
+
digitHeight: DIGIT_H
|
|
1207
|
+
// no fillerChar → rolling cells show real digits (crisp, no blur, no blank flicker)
|
|
1208
|
+
});
|
|
1209
|
+
const opts = {
|
|
1210
|
+
digits: total,
|
|
1211
|
+
decimals: cur.decimals,
|
|
1212
|
+
decimalChar: cur.decimalChar ?? ".",
|
|
1213
|
+
separator: { char: cur.separator ?? ",", every: 3 },
|
|
1214
|
+
cellRenderer: renderer,
|
|
1215
|
+
digitWidth: DIGIT_W,
|
|
1216
|
+
digitHeight: DIGIT_H,
|
|
1217
|
+
initialValue: fromMinor,
|
|
1218
|
+
// Tight sizing means the value fills its columns — leading-zero hide only ever
|
|
1219
|
+
// trims a digit or two after a grow, never a permanent reserve gap.
|
|
1220
|
+
leadingZeros: { mode: "hide" },
|
|
1221
|
+
blur: { enabled: false },
|
|
1222
|
+
ticker: this.ticker
|
|
1223
|
+
};
|
|
1224
|
+
const symbolMode = cur.display === "symbol" && !!cur.symbol;
|
|
1225
|
+
const affix = symbolMode ? cur.symbol : cur.code;
|
|
1226
|
+
if ((cur.position ?? "suffix") === "prefix") opts.prefix = symbolMode ? affix : `${affix} `;
|
|
1227
|
+
else opts.suffix = symbolMode ? affix : ` ${affix}`;
|
|
1228
|
+
if (this.fitGsap) {
|
|
1229
|
+
opts.fit = {
|
|
1230
|
+
gsap: this.fitGsap,
|
|
1231
|
+
maxWidth: valueFitMaxWidth(Math.max(this.vd.digits, FIT_BUDGET_COLS), DIGIT_W),
|
|
1232
|
+
minScale: 0.5,
|
|
1233
|
+
anchor: side
|
|
1234
|
+
// left→0 · right→fullWidth · center→fullWidth/2
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
this.counter = new Counter(opts);
|
|
1238
|
+
this.counter.y = -DIGIT_H / 2;
|
|
1239
|
+
if (this.fitGsap) {
|
|
1240
|
+
this.counter.x = 0;
|
|
1241
|
+
} else {
|
|
1242
|
+
this.counter.x = side === "left" ? 0 : side === "right" ? -this.counter.width : -this.counter.width / 2;
|
|
1243
|
+
}
|
|
1244
|
+
this.addChild(this.counter);
|
|
1245
|
+
}
|
|
1246
|
+
rebuild() {
|
|
1247
|
+
this.counter?.destroy();
|
|
1248
|
+
this.caption?.destroy();
|
|
1249
|
+
this.counter = void 0;
|
|
1250
|
+
this.caption = void 0;
|
|
1251
|
+
this.removeChildren();
|
|
1252
|
+
this.build();
|
|
1253
|
+
}
|
|
1254
|
+
dispose() {
|
|
1255
|
+
this.counter?.destroy();
|
|
1256
|
+
super.dispose();
|
|
1257
|
+
}
|
|
1258
|
+
};
|
|
1259
|
+
var ButtonView = class extends ControlView {
|
|
1260
|
+
constructor(btn, ui, ticker, opts = {}) {
|
|
1261
|
+
super(btn, ui);
|
|
1262
|
+
this.btn = btn;
|
|
1263
|
+
this.tween = new Tweener(ticker);
|
|
1264
|
+
this.shape = opts.shape ?? "circle";
|
|
1265
|
+
this.radius = opts.radius ?? 40;
|
|
1266
|
+
this.pillHeight = opts.height ?? 56;
|
|
1267
|
+
this.glyph = opts.glyph ?? "none";
|
|
1268
|
+
this.iconTarget = opts.iconTarget ?? 84;
|
|
1269
|
+
this.mono = opts.mono ?? false;
|
|
1270
|
+
this.addChild(this.art);
|
|
1271
|
+
if (opts.iconTexture) {
|
|
1272
|
+
this.sprite = new Sprite(opts.iconTexture);
|
|
1273
|
+
this.sprite.anchor.set(0.5);
|
|
1274
|
+
this.fitSprite();
|
|
1275
|
+
this.art.addChild(this.sprite);
|
|
1276
|
+
} else {
|
|
1277
|
+
this.art.addChild(this.bg);
|
|
1278
|
+
if (btn.label) {
|
|
1279
|
+
this.labelText = new Text({
|
|
1280
|
+
text: ui.t(btn.label),
|
|
1281
|
+
style: { fontFamily: ui.theme.type.family, fontSize: 22, fill: ui.theme.color.text, fontWeight: "700" }
|
|
1282
|
+
});
|
|
1283
|
+
this.labelText.anchor.set(0.5);
|
|
1284
|
+
this.art.addChild(this.labelText);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
this.eventMode = "static";
|
|
1288
|
+
this.cursor = "pointer";
|
|
1289
|
+
this.on("pointerover", this.onOver);
|
|
1290
|
+
this.on("pointerout", this.onOut);
|
|
1291
|
+
this.on("pointerdown", this.onDown);
|
|
1292
|
+
this.on("pointerup", this.onUp);
|
|
1293
|
+
this.on("pointerupoutside", this.onUpOutside);
|
|
1294
|
+
this.disposers.push(
|
|
1295
|
+
this.btn.state.subscribe(() => {
|
|
1296
|
+
this.redraw();
|
|
1297
|
+
this.updateInteractive();
|
|
1298
|
+
}),
|
|
1299
|
+
this.btn.onTransition((t) => this.play(t)),
|
|
1300
|
+
this.ui.locale.subscribe(() => {
|
|
1301
|
+
if (this.destroyed) return;
|
|
1302
|
+
if (this.labelText && this.btn.label) {
|
|
1303
|
+
this.labelText.text = this.ui.t(this.btn.label);
|
|
1304
|
+
this.updateHit();
|
|
1305
|
+
}
|
|
1306
|
+
})
|
|
1307
|
+
);
|
|
1308
|
+
this.redraw();
|
|
1309
|
+
this.updateHit();
|
|
1310
|
+
this.updateInteractive();
|
|
1311
|
+
}
|
|
1312
|
+
btn;
|
|
1313
|
+
art = new Container();
|
|
1314
|
+
bg = new Graphics();
|
|
1315
|
+
sprite;
|
|
1316
|
+
labelText;
|
|
1317
|
+
tween;
|
|
1318
|
+
shape;
|
|
1319
|
+
radius;
|
|
1320
|
+
pillHeight;
|
|
1321
|
+
glyph;
|
|
1322
|
+
iconTarget;
|
|
1323
|
+
mono;
|
|
1324
|
+
/** Swap the displayed art (e.g. ☰ → ✕). */
|
|
1325
|
+
setIconTexture(tex) {
|
|
1326
|
+
if (!this.sprite) return;
|
|
1327
|
+
this.sprite.texture = tex;
|
|
1328
|
+
this.fitSprite();
|
|
1329
|
+
this.updateHit();
|
|
1330
|
+
}
|
|
1331
|
+
/** Swap the placeholder glyph (e.g. speaker ↔ speaker-mute, fullscreen ↔ exit). */
|
|
1332
|
+
setGlyph(glyph) {
|
|
1333
|
+
if (this.glyph === glyph) return;
|
|
1334
|
+
this.glyph = glyph;
|
|
1335
|
+
this.redraw();
|
|
1336
|
+
this.updateHit();
|
|
1337
|
+
}
|
|
1338
|
+
fitSprite() {
|
|
1339
|
+
if (!this.sprite) return;
|
|
1340
|
+
this.sprite.scale.set(1);
|
|
1341
|
+
this.sprite.scale.set(this.iconTarget / this.sprite.height);
|
|
1342
|
+
}
|
|
1343
|
+
onOver = () => {
|
|
1344
|
+
if (isDesktop() && this.btn.current === "idle") this.btn.setState("hover");
|
|
1345
|
+
};
|
|
1346
|
+
onOut = () => {
|
|
1347
|
+
if (this.btn.current === "hover") this.btn.setState("idle");
|
|
1348
|
+
};
|
|
1349
|
+
onDown = () => {
|
|
1350
|
+
if (this.btn.interactable) this.btn.setState("pressed");
|
|
1351
|
+
};
|
|
1352
|
+
onUp = () => {
|
|
1353
|
+
if (this.btn.current === "pressed") {
|
|
1354
|
+
this.btn.setState("idle");
|
|
1355
|
+
this.btn.activate();
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
onUpOutside = () => {
|
|
1359
|
+
if (this.btn.current === "pressed") this.btn.setState("idle");
|
|
1360
|
+
};
|
|
1361
|
+
updateHit() {
|
|
1362
|
+
if (this.sprite) {
|
|
1363
|
+
const w = this.sprite.width;
|
|
1364
|
+
const h = this.sprite.height;
|
|
1365
|
+
this.hitArea = new Rectangle(-w / 2, -h / 2, w, h);
|
|
1366
|
+
} else if (this.shape === "circle") {
|
|
1367
|
+
this.hitArea = new Circle(0, 0, this.radius + 6);
|
|
1368
|
+
} else {
|
|
1369
|
+
const w = this.labelText ? this.labelText.width + 48 : 120;
|
|
1370
|
+
this.hitArea = new Rectangle(-w / 2, -this.pillHeight / 2, w, this.pillHeight);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
updateInteractive() {
|
|
1374
|
+
const ok = this.btn.interactable;
|
|
1375
|
+
this.eventMode = ok ? "static" : "none";
|
|
1376
|
+
this.cursor = ok ? "pointer" : "default";
|
|
1377
|
+
}
|
|
1378
|
+
redraw() {
|
|
1379
|
+
if (this.sprite) {
|
|
1380
|
+
this.sprite.alpha = this.btn.current === "disabled" ? 0.5 : 1;
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
const t = this.ui.theme;
|
|
1384
|
+
const g = this.bg;
|
|
1385
|
+
g.clear();
|
|
1386
|
+
const disabled = this.btn.current === "disabled";
|
|
1387
|
+
const fillC = this.mono ? "#ffffff" : t.color.surface;
|
|
1388
|
+
const lineC = this.mono ? "#0a0a0a" : t.color.accent;
|
|
1389
|
+
const ink = this.mono ? disabled ? "#9aa0a6" : "#0a0a0a" : disabled ? t.color.textDim : t.color.text;
|
|
1390
|
+
if (this.shape === "circle") {
|
|
1391
|
+
const r = this.radius;
|
|
1392
|
+
g.circle(0, 0, r).fill({ color: fillC, alpha: this.mono && disabled ? 0.6 : 1 });
|
|
1393
|
+
g.circle(0, 0, r).stroke({ width: this.mono ? 5 : 4, color: lineC });
|
|
1394
|
+
if (this.glyph === "menu") {
|
|
1395
|
+
for (const dy of [-8, 0, 8]) g.moveTo(-13, dy).lineTo(13, dy).stroke({ width: 4, color: ink });
|
|
1396
|
+
} else if (this.glyph === "close") {
|
|
1397
|
+
g.moveTo(-10, -10).lineTo(10, 10).moveTo(10, -10).lineTo(-10, 10).stroke({ width: 4, color: ink });
|
|
1398
|
+
} else if (this.glyph === "speaker" || this.glyph === "speaker-mute") {
|
|
1399
|
+
g.poly([-12, -4, -6, -4, 1, -11, 1, 11, -6, 4, -12, 4]).fill({ color: ink });
|
|
1400
|
+
if (this.glyph === "speaker") {
|
|
1401
|
+
g.moveTo(6, -6).lineTo(11, 0).lineTo(6, 6).stroke({ width: 2.5, color: ink });
|
|
1402
|
+
g.moveTo(11, -9).lineTo(17, 0).lineTo(11, 9).stroke({ width: 2.5, color: ink });
|
|
1403
|
+
} else {
|
|
1404
|
+
g.moveTo(7, -6).lineTo(17, 6).moveTo(17, -6).lineTo(7, 6).stroke({ width: 2.5, color: ink });
|
|
1405
|
+
}
|
|
1406
|
+
} else if (this.glyph === "fullscreen") {
|
|
1407
|
+
const a = 13, b = 6;
|
|
1408
|
+
g.moveTo(-a, -a + b).lineTo(-a, -a).lineTo(-a + b, -a).moveTo(a - b, -a).lineTo(a, -a).lineTo(a, -a + b).moveTo(-a, a - b).lineTo(-a, a).lineTo(-a + b, a).moveTo(a - b, a).lineTo(a, a).lineTo(a, a - b).stroke({ width: 3, color: ink });
|
|
1409
|
+
} else if (this.glyph === "fullscreen-exit") {
|
|
1410
|
+
const c = 4, d = 12;
|
|
1411
|
+
g.moveTo(-d, -c).lineTo(-c, -c).lineTo(-c, -d).moveTo(d, -c).lineTo(c, -c).lineTo(c, -d).moveTo(-d, c).lineTo(-c, c).lineTo(-c, d).moveTo(d, c).lineTo(c, c).lineTo(c, d).stroke({ width: 3, color: ink });
|
|
1412
|
+
}
|
|
1413
|
+
} else {
|
|
1414
|
+
const w = this.labelText ? this.labelText.width + 48 : 120;
|
|
1415
|
+
const h = this.pillHeight;
|
|
1416
|
+
g.roundRect(-w / 2, -h / 2, w, h, h / 2).fill({ color: t.color.surfaceAlt }).stroke({ width: 3, color: t.color.accent });
|
|
1417
|
+
}
|
|
1418
|
+
if (this.labelText) this.labelText.style.fill = ink;
|
|
1419
|
+
}
|
|
1420
|
+
play(t) {
|
|
1421
|
+
this.animating = true;
|
|
1422
|
+
void this.tween.run(this.art, t, this.ui.theme).then(() => {
|
|
1423
|
+
this.animating = false;
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
dispose() {
|
|
1427
|
+
this.tween.stop();
|
|
1428
|
+
super.dispose();
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var TurboView = class extends ControlView {
|
|
1432
|
+
constructor(turbo, ui, ticker, opts = {}) {
|
|
1433
|
+
super(turbo, ui);
|
|
1434
|
+
this.turbo = turbo;
|
|
1435
|
+
this.tween = new Tweener(ticker);
|
|
1436
|
+
this.modeTex = opts.modeTextures?.length ? opts.modeTextures : void 0;
|
|
1437
|
+
this.offTex = opts.offTexture;
|
|
1438
|
+
this.onTex = opts.onTexture;
|
|
1439
|
+
this.target = opts.target ?? 84;
|
|
1440
|
+
this.radius = opts.radius ?? 40;
|
|
1441
|
+
const hasArt = this.modeTex || this.offTex || this.onTex;
|
|
1442
|
+
if (hasArt) {
|
|
1443
|
+
this.sprite = new Sprite(this.texFor());
|
|
1444
|
+
this.sprite.anchor.set(0.5);
|
|
1445
|
+
this.art.addChild(this.sprite);
|
|
1446
|
+
} else {
|
|
1447
|
+
this.art.addChild(this.bg);
|
|
1448
|
+
}
|
|
1449
|
+
this.addChild(this.art, this.pips);
|
|
1450
|
+
this.eventMode = "static";
|
|
1451
|
+
this.cursor = "pointer";
|
|
1452
|
+
this.hitArea = new Circle(0, 0, (this.sprite ? this.target / 2 : this.radius) + 8);
|
|
1453
|
+
this.on("pointerup", this.onUp);
|
|
1454
|
+
this.disposers.push(
|
|
1455
|
+
this.turbo.state.subscribe(() => this.redraw()),
|
|
1456
|
+
this.turbo.index.subscribe(() => this.redraw()),
|
|
1457
|
+
this.turbo.onTransition((t) => this.play(t))
|
|
1458
|
+
);
|
|
1459
|
+
this.redraw();
|
|
1460
|
+
}
|
|
1461
|
+
turbo;
|
|
1462
|
+
art = new Container();
|
|
1463
|
+
bg = new Graphics();
|
|
1464
|
+
pips = new Graphics();
|
|
1465
|
+
sprite;
|
|
1466
|
+
tween;
|
|
1467
|
+
modeTex;
|
|
1468
|
+
offTex;
|
|
1469
|
+
onTex;
|
|
1470
|
+
target;
|
|
1471
|
+
radius;
|
|
1472
|
+
onUp = () => {
|
|
1473
|
+
this.turbo.cycle();
|
|
1474
|
+
};
|
|
1475
|
+
texFor() {
|
|
1476
|
+
const i = this.turbo.index.get();
|
|
1477
|
+
if (this.modeTex) return this.modeTex[Math.min(i, this.modeTex.length - 1)] ?? this.modeTex[0];
|
|
1478
|
+
return i > 0 ? this.onTex ?? this.offTex : this.offTex ?? this.onTex;
|
|
1479
|
+
}
|
|
1480
|
+
fit() {
|
|
1481
|
+
if (!this.sprite) return;
|
|
1482
|
+
this.sprite.scale.set(1);
|
|
1483
|
+
this.sprite.scale.set(this.target / this.sprite.height);
|
|
1484
|
+
}
|
|
1485
|
+
redraw() {
|
|
1486
|
+
const th = this.ui.theme;
|
|
1487
|
+
const i = this.turbo.index.get();
|
|
1488
|
+
const disabled = this.turbo.current === "disabled";
|
|
1489
|
+
if (this.sprite) {
|
|
1490
|
+
const tex = this.texFor();
|
|
1491
|
+
if (tex) this.sprite.texture = tex;
|
|
1492
|
+
this.fit();
|
|
1493
|
+
this.sprite.alpha = disabled ? 0.5 : 1;
|
|
1494
|
+
} else {
|
|
1495
|
+
const lit = i > 0;
|
|
1496
|
+
const r = this.radius;
|
|
1497
|
+
this.bg.clear();
|
|
1498
|
+
this.bg.circle(0, 0, r).fill({ color: lit ? th.color.accent : th.color.surface, alpha: lit ? Math.min(1, 0.55 + i * 0.25) : 1 }).stroke({ width: 4, color: th.color.accent });
|
|
1499
|
+
this.bg.poly([-6, -r * 0.42, 8, -4, 0, -4, 7, r * 0.42, -9, 2, 0, 2]).fill({ color: lit ? th.color.accentText : th.color.accent, alpha: disabled ? 0.5 : 1 });
|
|
1500
|
+
}
|
|
1501
|
+
this.pips.clear();
|
|
1502
|
+
const steps = this.turbo.modeCount - 1;
|
|
1503
|
+
if (steps >= 2) {
|
|
1504
|
+
const baseR = this.sprite ? this.target / 2 : this.radius;
|
|
1505
|
+
const gap = 16;
|
|
1506
|
+
const total = (steps - 1) * gap;
|
|
1507
|
+
const y = baseR + 14;
|
|
1508
|
+
for (let s = 0; s < steps; s++) {
|
|
1509
|
+
const x = -total / 2 + s * gap;
|
|
1510
|
+
const on = s < i;
|
|
1511
|
+
this.pips.circle(x, y, 5).fill({ color: on ? th.color.accent : th.color.surface, alpha: disabled ? 0.5 : 1 }).stroke({ width: 2, color: th.color.accent, alpha: disabled ? 0.5 : 1 });
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
play(t) {
|
|
1516
|
+
this.animating = true;
|
|
1517
|
+
void this.tween.run(this.art, t, this.ui.theme).then(() => {
|
|
1518
|
+
this.animating = false;
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
dispose() {
|
|
1522
|
+
this.tween.stop();
|
|
1523
|
+
super.dispose();
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
var DEG = Math.PI / 180;
|
|
1527
|
+
var AutoplayView = class extends ControlView {
|
|
1528
|
+
constructor(auto, ui, ticker, opts = {}) {
|
|
1529
|
+
super(auto, ui);
|
|
1530
|
+
this.auto = auto;
|
|
1531
|
+
this.ticker = ticker;
|
|
1532
|
+
this.idleTex = opts.idleTexture;
|
|
1533
|
+
this.activeTex = opts.activeTexture;
|
|
1534
|
+
this.target = opts.target ?? 88;
|
|
1535
|
+
this.radius = opts.radius ?? 44;
|
|
1536
|
+
this.useRadial = opts.picker === "radial";
|
|
1537
|
+
this.art.addChild(this.bg);
|
|
1538
|
+
if (this.idleTex || this.activeTex) {
|
|
1539
|
+
this.sprite = new Sprite(this.idleTex ?? this.activeTex);
|
|
1540
|
+
this.sprite.anchor.set(0.5);
|
|
1541
|
+
this.fit();
|
|
1542
|
+
this.art.addChild(this.sprite);
|
|
1543
|
+
}
|
|
1544
|
+
this.countText = new Text({ text: "", style: { fontFamily: ui.theme.type.family, fontSize: 26, fill: ui.theme.color.accentText, fontWeight: "800" } });
|
|
1545
|
+
this.countText.anchor.set(0.5);
|
|
1546
|
+
this.addChild(this.chipLayer, this.art, this.countText);
|
|
1547
|
+
this.eventMode = "static";
|
|
1548
|
+
this.cursor = "pointer";
|
|
1549
|
+
this.hitArea = new Circle(0, 0, (this.sprite ? this.target / 2 : this.radius) + 8);
|
|
1550
|
+
this.on("pointerup", () => this.auto.press());
|
|
1551
|
+
if (this.useRadial) this.buildChips(opts);
|
|
1552
|
+
this.tick = (t) => this.update(t.deltaMS);
|
|
1553
|
+
this.disposers.push(
|
|
1554
|
+
this.auto.state.subscribe(() => this.onState()),
|
|
1555
|
+
this.auto.count.subscribe(() => this.drawButton())
|
|
1556
|
+
);
|
|
1557
|
+
this.drawButton();
|
|
1558
|
+
}
|
|
1559
|
+
auto;
|
|
1560
|
+
ticker;
|
|
1561
|
+
art = new Container();
|
|
1562
|
+
// the rotating button
|
|
1563
|
+
bg = new Graphics();
|
|
1564
|
+
sprite;
|
|
1565
|
+
countText;
|
|
1566
|
+
chipLayer = new Container();
|
|
1567
|
+
// chips stay upright (don't rotate)
|
|
1568
|
+
chips = [];
|
|
1569
|
+
idleTex;
|
|
1570
|
+
activeTex;
|
|
1571
|
+
target;
|
|
1572
|
+
radius;
|
|
1573
|
+
rot = 0;
|
|
1574
|
+
rotTarget = 0;
|
|
1575
|
+
phase = 0;
|
|
1576
|
+
// ms since last state change (drives the stagger)
|
|
1577
|
+
running = false;
|
|
1578
|
+
useRadial;
|
|
1579
|
+
tick;
|
|
1580
|
+
fit() {
|
|
1581
|
+
if (!this.sprite) return;
|
|
1582
|
+
this.sprite.scale.set(1);
|
|
1583
|
+
this.sprite.scale.set(this.target / this.sprite.height);
|
|
1584
|
+
}
|
|
1585
|
+
fmt(n) {
|
|
1586
|
+
return n === Infinity ? "\u221E" : String(n);
|
|
1587
|
+
}
|
|
1588
|
+
buildChips(opts) {
|
|
1589
|
+
const cx = opts.arcCenter?.x ?? 0;
|
|
1590
|
+
const cy = opts.arcCenter?.y ?? 0;
|
|
1591
|
+
const R = opts.arcRadius ?? (Math.hypot(cx, cy) || 220);
|
|
1592
|
+
const start = Math.atan2(-cy, -cx);
|
|
1593
|
+
const step = (opts.arcStepDeg ?? 24) * DEG * (opts.arcDir ?? 1);
|
|
1594
|
+
const th = this.ui.theme;
|
|
1595
|
+
const CR = 34;
|
|
1596
|
+
this.auto.options.forEach((opt, i) => {
|
|
1597
|
+
const ang = start + (i + 1) * step;
|
|
1598
|
+
const node = new Container();
|
|
1599
|
+
node.addChild(new Graphics().circle(0, 0, CR).fill({ color: 16777215 }).stroke({ width: 4, color: 0 }));
|
|
1600
|
+
const t = new Text({ text: this.fmt(opt), style: { fontFamily: th.type.family, fontSize: 25, fill: 1382172, fontWeight: "800" } });
|
|
1601
|
+
t.anchor.set(0.5);
|
|
1602
|
+
node.addChild(t);
|
|
1603
|
+
node.position.set(cx + R * Math.cos(ang), cy + R * Math.sin(ang));
|
|
1604
|
+
node.scale.set(0);
|
|
1605
|
+
node.visible = false;
|
|
1606
|
+
node.eventMode = "static";
|
|
1607
|
+
node.cursor = "pointer";
|
|
1608
|
+
node.hitArea = new Circle(0, 0, CR + 4);
|
|
1609
|
+
node.on("pointerup", (e) => {
|
|
1610
|
+
e.stopPropagation();
|
|
1611
|
+
this.auto.pick(opt);
|
|
1612
|
+
});
|
|
1613
|
+
this.chipLayer.addChild(node);
|
|
1614
|
+
this.chips.push({ node, scale: 0 });
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
onState() {
|
|
1618
|
+
this.rotTarget = this.useRadial && this.auto.current === "picking" ? -60 * DEG : 0;
|
|
1619
|
+
this.phase = 0;
|
|
1620
|
+
this.drawButton();
|
|
1621
|
+
if (!this.running) {
|
|
1622
|
+
this.running = true;
|
|
1623
|
+
this.ticker.add(this.tick);
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
update(dt) {
|
|
1627
|
+
this.phase += Math.min(dt, 40);
|
|
1628
|
+
this.rot += (this.rotTarget - this.rot) * Math.min(1, dt / 110);
|
|
1629
|
+
this.art.rotation = this.rot;
|
|
1630
|
+
const opening = this.auto.current === "picking";
|
|
1631
|
+
const n = this.chips.length;
|
|
1632
|
+
let settled = Math.abs(this.rot - this.rotTarget) < 3e-3;
|
|
1633
|
+
for (let i = 0; i < n; i++) {
|
|
1634
|
+
const chip = this.chips[i];
|
|
1635
|
+
let target;
|
|
1636
|
+
let ease;
|
|
1637
|
+
if (opening) {
|
|
1638
|
+
target = this.phase > i * 70 ? 1 : 0;
|
|
1639
|
+
ease = Math.min(1, dt / 95);
|
|
1640
|
+
} else {
|
|
1641
|
+
target = this.phase > (n - 1 - i) * 36 ? 0 : 1;
|
|
1642
|
+
ease = Math.min(1, dt / 42);
|
|
1643
|
+
}
|
|
1644
|
+
chip.scale += (target - chip.scale) * ease;
|
|
1645
|
+
chip.node.scale.set(chip.scale);
|
|
1646
|
+
chip.node.visible = chip.scale > 0.01;
|
|
1647
|
+
if (Math.abs(chip.scale - (opening ? 1 : 0)) > 0.01) settled = false;
|
|
1648
|
+
}
|
|
1649
|
+
if (settled) {
|
|
1650
|
+
this.running = false;
|
|
1651
|
+
this.ticker.remove(this.tick);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
drawButton() {
|
|
1655
|
+
const st = this.auto.current;
|
|
1656
|
+
this.countText.visible = st === "active";
|
|
1657
|
+
if (st === "active") this.countText.text = this.fmt(this.auto.count.get());
|
|
1658
|
+
if (st === "active") {
|
|
1659
|
+
if (this.sprite) this.sprite.visible = false;
|
|
1660
|
+
const r = this.sprite ? this.target / 2 : this.radius;
|
|
1661
|
+
this.bg.clear();
|
|
1662
|
+
this.bg.roundRect(-r, -r, 2 * r, 2 * r, r * 0.35).fill({ color: this.ui.theme.color.accent }).stroke({ width: 4, color: this.ui.theme.color.accentText });
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (this.sprite) {
|
|
1666
|
+
this.sprite.visible = true;
|
|
1667
|
+
this.bg.clear();
|
|
1668
|
+
const tex = this.idleTex ?? this.activeTex;
|
|
1669
|
+
if (tex) this.sprite.texture = tex;
|
|
1670
|
+
this.fit();
|
|
1671
|
+
this.sprite.alpha = st === "disabled" ? 0.5 : 1;
|
|
1672
|
+
} else {
|
|
1673
|
+
const th = this.ui.theme;
|
|
1674
|
+
this.bg.clear();
|
|
1675
|
+
this.bg.circle(0, 0, this.radius).fill({ color: th.color.surface }).stroke({ width: 4, color: th.color.accent });
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
dispose() {
|
|
1679
|
+
if (this.running) {
|
|
1680
|
+
this.ticker.remove(this.tick);
|
|
1681
|
+
this.running = false;
|
|
1682
|
+
}
|
|
1683
|
+
super.dispose();
|
|
1684
|
+
}
|
|
1685
|
+
};
|
|
1686
|
+
var WHITE = 16777215;
|
|
1687
|
+
var BLACK = 657930;
|
|
1688
|
+
var DARK = 789776;
|
|
1689
|
+
var CHIP = 2303532;
|
|
1690
|
+
var DIM = 10133670;
|
|
1691
|
+
var AutoplayDrawerView = class extends Container {
|
|
1692
|
+
constructor(auto, ui, ticker) {
|
|
1693
|
+
super();
|
|
1694
|
+
this.auto = auto;
|
|
1695
|
+
this.ui = ui;
|
|
1696
|
+
this.ticker = ticker;
|
|
1697
|
+
this.zIndex = 200;
|
|
1698
|
+
this.visible = false;
|
|
1699
|
+
this.eventMode = "none";
|
|
1700
|
+
const fam = ui.theme.type.family;
|
|
1701
|
+
this.backdrop.eventMode = "static";
|
|
1702
|
+
this.backdrop.cursor = "pointer";
|
|
1703
|
+
this.backdrop.on("pointertap", () => this.auto.cancelPicker());
|
|
1704
|
+
this.title = new Text({ text: ui.t("Autoplay"), style: { fontFamily: fam, fontSize: 30, fill: WHITE, fontWeight: "800", letterSpacing: 1 } });
|
|
1705
|
+
this.title.anchor.set(0.5, 0);
|
|
1706
|
+
this.startLabel = new Text({ text: ui.t("Start"), style: { fontFamily: fam, fontSize: 26, fill: BLACK, fontWeight: "800", letterSpacing: 1 } });
|
|
1707
|
+
this.startLabel.anchor.set(0.5);
|
|
1708
|
+
this.startBtn.eventMode = "static";
|
|
1709
|
+
this.startBtn.cursor = "pointer";
|
|
1710
|
+
this.startBtn.on("pointertap", () => this.start());
|
|
1711
|
+
this.startBtn.addChild(this.startBg, this.startLabel);
|
|
1712
|
+
this.sheet.addChild(this.sheetBg, this.handle, this.title);
|
|
1713
|
+
this.addGroup("count", this.auto.options);
|
|
1714
|
+
if (this.auto.lossLimitOptions.length) this.addGroup("loss", this.auto.lossLimitOptions, "Stop on loss");
|
|
1715
|
+
if (this.auto.winLimitOptions.length) this.addGroup("win", this.auto.winLimitOptions, "Stop on single win");
|
|
1716
|
+
this.sheet.addChild(this.startBtn);
|
|
1717
|
+
this.addChild(this.backdrop, this.sheet);
|
|
1718
|
+
this.tick = (t) => this.update(t.deltaMS);
|
|
1719
|
+
this.disposers.push(this.auto.state.subscribe(() => this.onState()));
|
|
1720
|
+
this.disposers.push(
|
|
1721
|
+
this.ui.locale.subscribe(() => {
|
|
1722
|
+
if (this.destroyed) return;
|
|
1723
|
+
this.title.text = this.ui.t("Autoplay");
|
|
1724
|
+
this.startLabel.text = this.ui.t("Start");
|
|
1725
|
+
for (const g of this.groups) if (g.heading) g.heading.text = this.ui.t(headingKey(g.kind));
|
|
1726
|
+
})
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
auto;
|
|
1730
|
+
ui;
|
|
1731
|
+
ticker;
|
|
1732
|
+
backdrop = new Graphics();
|
|
1733
|
+
sheet = new Container();
|
|
1734
|
+
sheetBg = new Graphics();
|
|
1735
|
+
handle = new Graphics();
|
|
1736
|
+
title;
|
|
1737
|
+
startBtn = new Container();
|
|
1738
|
+
startBg = new Graphics();
|
|
1739
|
+
startLabel;
|
|
1740
|
+
groups = [];
|
|
1741
|
+
screen;
|
|
1742
|
+
prog = 0;
|
|
1743
|
+
// 0 hidden → 1 fully shown
|
|
1744
|
+
running = false;
|
|
1745
|
+
sheetH = 300;
|
|
1746
|
+
kk = 1;
|
|
1747
|
+
// active layout scale (base scale shrunk to fit the viewport height)
|
|
1748
|
+
disposers = [];
|
|
1749
|
+
tick;
|
|
1750
|
+
addGroup(kind, values, headingText) {
|
|
1751
|
+
const fam = this.ui.theme.type.family;
|
|
1752
|
+
const group = { kind, chips: [], selected: 0 };
|
|
1753
|
+
if (headingText) {
|
|
1754
|
+
group.heading = new Text({ text: this.ui.t(headingText), style: { fontFamily: fam, fontSize: 16, fill: DIM, fontWeight: "700", letterSpacing: 0.5 } });
|
|
1755
|
+
group.heading.anchor.set(0.5, 0.5);
|
|
1756
|
+
this.sheet.addChild(group.heading);
|
|
1757
|
+
}
|
|
1758
|
+
values.forEach((value) => {
|
|
1759
|
+
const node = new Container();
|
|
1760
|
+
const bg = new Graphics();
|
|
1761
|
+
const label = new Text({ text: chipText(kind, value), style: { fontFamily: fam, fontSize: 24, fill: WHITE, fontWeight: "800" } });
|
|
1762
|
+
label.anchor.set(0.5);
|
|
1763
|
+
node.eventMode = "static";
|
|
1764
|
+
node.cursor = "pointer";
|
|
1765
|
+
const idx = group.chips.length;
|
|
1766
|
+
node.on("pointertap", () => this.select(group, idx));
|
|
1767
|
+
node.addChild(bg, label);
|
|
1768
|
+
this.sheet.addChild(node);
|
|
1769
|
+
group.chips.push({ node, bg, label, value });
|
|
1770
|
+
});
|
|
1771
|
+
group.selected = defaultSelected(kind, values);
|
|
1772
|
+
this.groups.push(group);
|
|
1773
|
+
}
|
|
1774
|
+
applyLayout(screen) {
|
|
1775
|
+
this.screen = screen;
|
|
1776
|
+
this.position.set(0, 0);
|
|
1777
|
+
this.scale.set(1);
|
|
1778
|
+
this.relayout();
|
|
1779
|
+
}
|
|
1780
|
+
/** Base scale from the screen's shorter edge (before fit-to-height). */
|
|
1781
|
+
baseK() {
|
|
1782
|
+
const s = this.screen;
|
|
1783
|
+
if (!s) return 1;
|
|
1784
|
+
return Math.max(0.78, Math.min(1.3, Math.min(s.width, s.height) / 1e3));
|
|
1785
|
+
}
|
|
1786
|
+
relayout() {
|
|
1787
|
+
const s = this.screen;
|
|
1788
|
+
if (!s) return;
|
|
1789
|
+
let k = this.baseK();
|
|
1790
|
+
let h = this.layoutAt(k);
|
|
1791
|
+
for (let pass = 0; pass < 4 && h > s.height; pass++) {
|
|
1792
|
+
k = Math.max(0.35, k * (s.height / h) * 0.97);
|
|
1793
|
+
h = this.layoutAt(k);
|
|
1794
|
+
}
|
|
1795
|
+
this.render2();
|
|
1796
|
+
}
|
|
1797
|
+
/** Lay the sheet out at scale `k`; returns the full slide height (sheetH + 40). */
|
|
1798
|
+
layoutAt(k) {
|
|
1799
|
+
const s = this.screen;
|
|
1800
|
+
if (!s) return 0;
|
|
1801
|
+
this.kk = k;
|
|
1802
|
+
const W = s.width;
|
|
1803
|
+
const H = s.height;
|
|
1804
|
+
this.backdrop.clear().rect(0, 0, W, H).fill({ color: 0, alpha: 1 });
|
|
1805
|
+
this.backdrop.hitArea = new Rectangle(0, 0, W, H);
|
|
1806
|
+
this.title.style.fontSize = 30 * k;
|
|
1807
|
+
this.title.position.set(W / 2, 22 * k);
|
|
1808
|
+
const cw = 86 * k;
|
|
1809
|
+
const ch = 64 * k;
|
|
1810
|
+
const gap = 14 * k;
|
|
1811
|
+
const maxRowW = W - 48 * k;
|
|
1812
|
+
let y = 22 * k + 30 * k + 20 * k;
|
|
1813
|
+
for (const g of this.groups) {
|
|
1814
|
+
if (g.heading) {
|
|
1815
|
+
g.heading.style.fontSize = 16 * k;
|
|
1816
|
+
g.heading.position.set(W / 2, y + 10 * k);
|
|
1817
|
+
y += 30 * k;
|
|
1818
|
+
}
|
|
1819
|
+
const n = g.chips.length;
|
|
1820
|
+
const perRow = Math.max(1, Math.min(n, Math.floor((maxRowW + gap) / (cw + gap))));
|
|
1821
|
+
const rows = Math.ceil(n / perRow);
|
|
1822
|
+
g.chips.forEach((chip, i) => {
|
|
1823
|
+
const row = Math.floor(i / perRow);
|
|
1824
|
+
const inRow = i % perRow;
|
|
1825
|
+
const countThisRow = Math.min(perRow, n - row * perRow);
|
|
1826
|
+
const rowW = countThisRow * cw + (countThisRow - 1) * gap;
|
|
1827
|
+
const x = (W - rowW) / 2 + inRow * (cw + gap) + cw / 2;
|
|
1828
|
+
const cy = y + row * (ch + gap) + ch / 2;
|
|
1829
|
+
chip.node.position.set(x, cy);
|
|
1830
|
+
chip.label.style.fontSize = 24 * k;
|
|
1831
|
+
chip.node.hitArea = new Rectangle(-cw / 2, -ch / 2, cw, ch);
|
|
1832
|
+
});
|
|
1833
|
+
this.drawGroup(g);
|
|
1834
|
+
y += rows * (ch + gap) + 12 * k;
|
|
1835
|
+
}
|
|
1836
|
+
const startW = Math.min(W - 48 * k, 320 * k);
|
|
1837
|
+
const startH = 58 * k;
|
|
1838
|
+
const startY = y + 4 * k + startH / 2;
|
|
1839
|
+
this.startBg.clear().rect(-startW / 2, -startH / 2, startW, startH).fill({ color: WHITE });
|
|
1840
|
+
this.startLabel.style.fontSize = 24 * k;
|
|
1841
|
+
this.startBtn.position.set(W / 2, startY);
|
|
1842
|
+
this.startBtn.hitArea = new Rectangle(-startW / 2, -startH / 2, startW, startH);
|
|
1843
|
+
this.sheetH = startY + startH / 2 + 20 * k;
|
|
1844
|
+
this.sheetBg.clear().rect(0, 0, W, this.sheetH + 40).fill({ color: DARK });
|
|
1845
|
+
this.handle.clear().rect(W / 2 - 30 * k, 13 * k, 60 * k, 5 * k).fill({ color: DIM });
|
|
1846
|
+
return this.sheetH + 40;
|
|
1847
|
+
}
|
|
1848
|
+
drawGroup(g) {
|
|
1849
|
+
const k = this.kk;
|
|
1850
|
+
const cw = 86 * k;
|
|
1851
|
+
const ch = 64 * k;
|
|
1852
|
+
g.chips.forEach((chip, idx) => {
|
|
1853
|
+
const on = idx === g.selected;
|
|
1854
|
+
chip.bg.clear().rect(-cw / 2, -ch / 2, cw, ch).fill({ color: on ? WHITE : CHIP });
|
|
1855
|
+
chip.label.style.fill = on ? BLACK : WHITE;
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
select(group, i) {
|
|
1859
|
+
group.selected = i;
|
|
1860
|
+
this.drawGroup(group);
|
|
1861
|
+
}
|
|
1862
|
+
valueOf(kind) {
|
|
1863
|
+
const g = this.groups.find((x) => x.kind === kind);
|
|
1864
|
+
return g?.chips[g.selected]?.value;
|
|
1865
|
+
}
|
|
1866
|
+
start() {
|
|
1867
|
+
const count = this.valueOf("count") ?? this.auto.options[0] ?? 1;
|
|
1868
|
+
this.auto.pick(count, {
|
|
1869
|
+
lossLimit: this.valueOf("loss") ?? Infinity,
|
|
1870
|
+
singleWinLimit: this.valueOf("win") ?? Infinity
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
onState() {
|
|
1874
|
+
if (this.auto.current === "picking") this.visible = true;
|
|
1875
|
+
if (!this.running) {
|
|
1876
|
+
this.running = true;
|
|
1877
|
+
this.ticker.add(this.tick);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
update(dt) {
|
|
1881
|
+
const target = this.auto.current === "picking" ? 1 : 0;
|
|
1882
|
+
this.prog += (target - this.prog) * Math.min(1, dt / 140);
|
|
1883
|
+
if (Math.abs(this.prog - target) < 4e-3) {
|
|
1884
|
+
this.prog = target;
|
|
1885
|
+
this.running = false;
|
|
1886
|
+
this.ticker.remove(this.tick);
|
|
1887
|
+
}
|
|
1888
|
+
this.render2();
|
|
1889
|
+
}
|
|
1890
|
+
render2() {
|
|
1891
|
+
const s = this.screen;
|
|
1892
|
+
if (!s) return;
|
|
1893
|
+
const SH = this.sheetH + 40;
|
|
1894
|
+
this.sheet.position.set(0, s.height - SH * this.prog);
|
|
1895
|
+
this.backdrop.alpha = 0.62 * this.prog;
|
|
1896
|
+
const shown = this.prog > 0.01;
|
|
1897
|
+
this.visible = shown;
|
|
1898
|
+
this.eventMode = shown ? "auto" : "none";
|
|
1899
|
+
this.backdrop.eventMode = shown ? "static" : "none";
|
|
1900
|
+
}
|
|
1901
|
+
dispose() {
|
|
1902
|
+
if (this.running) {
|
|
1903
|
+
this.ticker.remove(this.tick);
|
|
1904
|
+
this.running = false;
|
|
1905
|
+
}
|
|
1906
|
+
for (const d of this.disposers) d();
|
|
1907
|
+
this.disposers.length = 0;
|
|
1908
|
+
if (!this.destroyed) this.destroy({ children: true });
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
function chipText(kind, value) {
|
|
1912
|
+
if (value === Infinity) return "\u221E";
|
|
1913
|
+
return kind === "count" ? String(value) : `${value}\xD7`;
|
|
1914
|
+
}
|
|
1915
|
+
function defaultSelected(kind, values) {
|
|
1916
|
+
if (kind === "count") {
|
|
1917
|
+
const i = values.findIndex((v) => v !== Infinity);
|
|
1918
|
+
return i >= 0 ? i : 0;
|
|
1919
|
+
}
|
|
1920
|
+
const inf = values.indexOf(Infinity);
|
|
1921
|
+
return inf >= 0 ? inf : 0;
|
|
1922
|
+
}
|
|
1923
|
+
function headingKey(kind) {
|
|
1924
|
+
return kind === "loss" ? "Stop on loss" : kind === "win" ? "Stop on single win" : "Autoplay";
|
|
1925
|
+
}
|
|
1926
|
+
var VB_W = 290;
|
|
1927
|
+
var VB_H = 60;
|
|
1928
|
+
var GROOVE_X0 = 63;
|
|
1929
|
+
var GROOVE_X1 = 263;
|
|
1930
|
+
var HANDLE_Y = 30;
|
|
1931
|
+
var HANDLE_R = 12;
|
|
1932
|
+
var DISPLAY_W = 260;
|
|
1933
|
+
var S = DISPLAY_W / VB_W;
|
|
1934
|
+
var SliderView = class extends ControlView {
|
|
1935
|
+
constructor(slider, ui, trackTexture) {
|
|
1936
|
+
super(slider, ui);
|
|
1937
|
+
this.slider = slider;
|
|
1938
|
+
this.hasTexture = !!trackTexture;
|
|
1939
|
+
const cy = HANDLE_Y * S;
|
|
1940
|
+
const x0 = GROOVE_X0 * S;
|
|
1941
|
+
const x1 = GROOVE_X1 * S;
|
|
1942
|
+
const trackH = 8 * S;
|
|
1943
|
+
if (trackTexture) {
|
|
1944
|
+
const track = new Sprite(trackTexture);
|
|
1945
|
+
track.width = VB_W * S;
|
|
1946
|
+
track.height = VB_H * S;
|
|
1947
|
+
this.addChild(track);
|
|
1948
|
+
} else {
|
|
1949
|
+
const t = ui.theme;
|
|
1950
|
+
const track = new Graphics().roundRect(x0 - trackH / 2, cy - trackH / 2, x1 - x0 + trackH, trackH, trackH / 2).fill({ color: t.color.surfaceAlt }).roundRect(x0 - trackH / 2, cy - trackH / 2, x1 - x0 + trackH, trackH, trackH / 2).stroke({ width: 1, color: t.color.textDim, alpha: 0.35 });
|
|
1951
|
+
this.addChild(track);
|
|
1952
|
+
}
|
|
1953
|
+
this.addChild(this.handle);
|
|
1954
|
+
this.eventMode = "static";
|
|
1955
|
+
this.cursor = "pointer";
|
|
1956
|
+
this.hitArea = new Rectangle(0, 0, VB_W * S, VB_H * S);
|
|
1957
|
+
this.on("pointerdown", this.onDown);
|
|
1958
|
+
this.on("globalpointermove", this.onMove);
|
|
1959
|
+
this.on("pointerup", this.onUp);
|
|
1960
|
+
this.on("pointerupoutside", this.onUp);
|
|
1961
|
+
this.disposers.push(this.slider.value.subscribe(() => this.redraw()));
|
|
1962
|
+
this.redraw();
|
|
1963
|
+
}
|
|
1964
|
+
slider;
|
|
1965
|
+
handle = new Graphics();
|
|
1966
|
+
hasTexture;
|
|
1967
|
+
dragging = false;
|
|
1968
|
+
redraw() {
|
|
1969
|
+
const cy = HANDLE_Y * S;
|
|
1970
|
+
const x0 = GROOVE_X0 * S;
|
|
1971
|
+
const x1 = GROOVE_X1 * S;
|
|
1972
|
+
const x = x0 + this.slider.value.get() * (x1 - x0);
|
|
1973
|
+
if (this.hasTexture) {
|
|
1974
|
+
this.handle.clear().circle(x, cy, HANDLE_R * S).fill({ color: 16777215 }).stroke({ width: 4 * S, color: 0 });
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
const t = this.ui.theme;
|
|
1978
|
+
const trackH = 8 * S;
|
|
1979
|
+
const knobR = 11 * S;
|
|
1980
|
+
this.handle.clear().roundRect(x0 - trackH / 2, cy - trackH / 2, x - x0 + trackH, trackH, trackH / 2).fill({ color: t.color.accent }).circle(x, cy, knobR).fill({ color: 16777215 }).circle(x, cy, knobR).stroke({ width: 3, color: t.color.accent });
|
|
1981
|
+
}
|
|
1982
|
+
valueFromEvent(e) {
|
|
1983
|
+
const svgX = this.toLocal(e.global).x / S;
|
|
1984
|
+
return Math.min(1, Math.max(0, (svgX - GROOVE_X0) / (GROOVE_X1 - GROOVE_X0)));
|
|
1985
|
+
}
|
|
1986
|
+
onDown = (e) => {
|
|
1987
|
+
this.dragging = true;
|
|
1988
|
+
this.slider.beginDrag();
|
|
1989
|
+
this.slider.setNormalized(this.valueFromEvent(e));
|
|
1990
|
+
};
|
|
1991
|
+
onMove = (e) => {
|
|
1992
|
+
if (this.dragging) this.slider.setNormalized(this.valueFromEvent(e));
|
|
1993
|
+
};
|
|
1994
|
+
onUp = () => {
|
|
1995
|
+
if (this.dragging) {
|
|
1996
|
+
this.dragging = false;
|
|
1997
|
+
this.slider.endDrag();
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
};
|
|
2001
|
+
var ToggleView = class extends ControlView {
|
|
2002
|
+
constructor(toggle, ui, ticker, opts = {}) {
|
|
2003
|
+
super(toggle, ui);
|
|
2004
|
+
this.toggle = toggle;
|
|
2005
|
+
this.tween = new Tweener(ticker);
|
|
2006
|
+
this.offTex = opts.offTexture;
|
|
2007
|
+
this.onTex = opts.onTexture;
|
|
2008
|
+
this.target = opts.target ?? 84;
|
|
2009
|
+
this.radius = opts.radius ?? 40;
|
|
2010
|
+
if (this.offTex || this.onTex) {
|
|
2011
|
+
this.sprite = new Sprite(this.texFor());
|
|
2012
|
+
this.sprite.anchor.set(0.5);
|
|
2013
|
+
this.fit();
|
|
2014
|
+
this.art.addChild(this.sprite);
|
|
2015
|
+
} else {
|
|
2016
|
+
this.art.addChild(this.bg);
|
|
2017
|
+
}
|
|
2018
|
+
this.addChild(this.art);
|
|
2019
|
+
this.eventMode = "static";
|
|
2020
|
+
this.cursor = "pointer";
|
|
2021
|
+
this.hitArea = this.sprite ? new Circle(0, 0, this.target / 2 + 8) : new Rectangle(-35, -23, 70, 46);
|
|
2022
|
+
this.on("pointerup", this.onUp);
|
|
2023
|
+
this.disposers.push(
|
|
2024
|
+
this.toggle.state.subscribe(() => this.redraw()),
|
|
2025
|
+
this.toggle.onTransition((t) => this.play(t))
|
|
2026
|
+
);
|
|
2027
|
+
this.redraw();
|
|
2028
|
+
}
|
|
2029
|
+
toggle;
|
|
2030
|
+
art = new Container();
|
|
2031
|
+
bg = new Graphics();
|
|
2032
|
+
sprite;
|
|
2033
|
+
tween;
|
|
2034
|
+
offTex;
|
|
2035
|
+
onTex;
|
|
2036
|
+
target;
|
|
2037
|
+
radius;
|
|
2038
|
+
onUp = () => {
|
|
2039
|
+
this.toggle.toggle();
|
|
2040
|
+
};
|
|
2041
|
+
texFor() {
|
|
2042
|
+
return this.toggle.isOn ? this.onTex ?? this.offTex : this.offTex ?? this.onTex;
|
|
2043
|
+
}
|
|
2044
|
+
fit() {
|
|
2045
|
+
if (!this.sprite) return;
|
|
2046
|
+
this.sprite.scale.set(1);
|
|
2047
|
+
this.sprite.scale.set(this.target / this.sprite.height);
|
|
2048
|
+
}
|
|
2049
|
+
redraw() {
|
|
2050
|
+
if (this.sprite) {
|
|
2051
|
+
const tex = this.texFor();
|
|
2052
|
+
if (tex) this.sprite.texture = tex;
|
|
2053
|
+
this.fit();
|
|
2054
|
+
this.sprite.alpha = this.toggle.current === "disabled" ? 0.5 : 1;
|
|
2055
|
+
return;
|
|
2056
|
+
}
|
|
2057
|
+
const th = this.ui.theme;
|
|
2058
|
+
const on = this.toggle.isOn;
|
|
2059
|
+
const w = 54;
|
|
2060
|
+
const h = 30;
|
|
2061
|
+
const r = h / 2;
|
|
2062
|
+
const knobX = on ? w / 2 - r : -12;
|
|
2063
|
+
this.bg.clear().roundRect(-w / 2, -h / 2, w, h, r).fill({ color: on ? th.color.accent : th.color.surfaceAlt }).roundRect(-w / 2, -h / 2, w, h, r).stroke({ width: 2, color: on ? th.color.accent : th.color.textDim, alpha: on ? 1 : 0.6 }).circle(knobX, 0, r - 4).fill({ color: 16777215 });
|
|
2064
|
+
}
|
|
2065
|
+
play(t) {
|
|
2066
|
+
this.animating = true;
|
|
2067
|
+
void this.tween.run(this.art, t, this.ui.theme).then(() => {
|
|
2068
|
+
this.animating = false;
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
dispose() {
|
|
2072
|
+
this.tween.stop();
|
|
2073
|
+
super.dispose();
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
var SelectView = class extends ControlView {
|
|
2077
|
+
constructor(select, ui, ticker, opts = {}) {
|
|
2078
|
+
super(select, ui);
|
|
2079
|
+
this.select = select;
|
|
2080
|
+
this.tween = new Tweener(ticker);
|
|
2081
|
+
this.w = opts.width ?? 240;
|
|
2082
|
+
this.h = opts.height ?? 56;
|
|
2083
|
+
this.dropdownLayer = opts.dropdownLayer;
|
|
2084
|
+
const t = ui.theme;
|
|
2085
|
+
this.captionText = new Text({ text: select.caption ?? "", style: { fontFamily: t.type.family, fontSize: 16, fill: t.color.textDim, fontWeight: "600" } });
|
|
2086
|
+
this.captionText.anchor.set(0, 0.5);
|
|
2087
|
+
this.valueText = new Text({ text: select.optionLabel, style: { fontFamily: t.type.family, fontSize: 20, fill: t.color.text, fontWeight: "700" } });
|
|
2088
|
+
this.valueText.anchor.set(1, 0.5);
|
|
2089
|
+
this.art.addChild(this.bg, this.captionText, this.valueText, this.chevron);
|
|
2090
|
+
this.addChild(this.art);
|
|
2091
|
+
this.eventMode = "static";
|
|
2092
|
+
this.cursor = "pointer";
|
|
2093
|
+
this.hitArea = new Rectangle(-this.w / 2, -this.h / 2, this.w, this.h);
|
|
2094
|
+
this.on("pointerup", this.onUp);
|
|
2095
|
+
this.disposers.push(
|
|
2096
|
+
this.select.index.subscribe(() => this.redraw()),
|
|
2097
|
+
this.select.state.subscribe(() => {
|
|
2098
|
+
this.redraw();
|
|
2099
|
+
this.syncDropdown();
|
|
2100
|
+
}),
|
|
2101
|
+
this.select.onTransition((tr) => this.play(tr)),
|
|
2102
|
+
this.ui.locale.subscribe(() => {
|
|
2103
|
+
if (!this.destroyed) this.redraw();
|
|
2104
|
+
})
|
|
2105
|
+
);
|
|
2106
|
+
this.redraw();
|
|
2107
|
+
}
|
|
2108
|
+
select;
|
|
2109
|
+
art = new Container();
|
|
2110
|
+
bg = new Graphics();
|
|
2111
|
+
chevron = new Graphics();
|
|
2112
|
+
captionText;
|
|
2113
|
+
valueText;
|
|
2114
|
+
tween;
|
|
2115
|
+
w;
|
|
2116
|
+
h;
|
|
2117
|
+
dropdownLayer;
|
|
2118
|
+
dropdown;
|
|
2119
|
+
onUp = () => {
|
|
2120
|
+
if (!this.select.interactable) return;
|
|
2121
|
+
if (this.dropdownLayer) this.select.isOpen ? this.select.closeList() : this.select.openList();
|
|
2122
|
+
else this.select.cycle();
|
|
2123
|
+
};
|
|
2124
|
+
syncDropdown() {
|
|
2125
|
+
if (!this.dropdownLayer) return;
|
|
2126
|
+
if (this.select.isOpen) this.showDropdown();
|
|
2127
|
+
else this.hideDropdown();
|
|
2128
|
+
}
|
|
2129
|
+
showDropdown() {
|
|
2130
|
+
this.hideDropdown();
|
|
2131
|
+
const layer = this.dropdownLayer;
|
|
2132
|
+
if (!layer) return;
|
|
2133
|
+
const t = this.ui.theme;
|
|
2134
|
+
const w = Math.max(this.w, 220);
|
|
2135
|
+
const rowH = 46;
|
|
2136
|
+
const opts = this.select.options;
|
|
2137
|
+
const listH = opts.length * rowH + 8;
|
|
2138
|
+
const panel = new Container();
|
|
2139
|
+
panel.zIndex = 1;
|
|
2140
|
+
const backdrop = new Graphics().rect(-6e3, -6e3, 12e3, 12e3).fill({ color: 0, alpha: 1e-3 });
|
|
2141
|
+
backdrop.eventMode = "static";
|
|
2142
|
+
backdrop.on("pointertap", () => this.select.closeList());
|
|
2143
|
+
panel.addChild(backdrop);
|
|
2144
|
+
const list = new Container();
|
|
2145
|
+
list.addChild(new Graphics().roundRect(-w / 2, 0, w, listH, 14).fill({ color: t.color.surface }).stroke({ width: 2, color: t.color.accent }));
|
|
2146
|
+
opts.forEach((o, i) => {
|
|
2147
|
+
const selected = i === this.select.index.get();
|
|
2148
|
+
const cy = 4 + i * rowH + rowH / 2;
|
|
2149
|
+
const row = new Container();
|
|
2150
|
+
if (selected) row.addChild(new Graphics().roundRect(-w / 2 + 5, 4 + i * rowH, w - 10, rowH, 9).fill({ color: t.color.accent }));
|
|
2151
|
+
const label = new Text({ text: this.ui.t(o.label), style: { fontFamily: t.type.family, fontSize: 18, fill: selected ? t.color.accentText : t.color.text, fontWeight: "700" } });
|
|
2152
|
+
label.anchor.set(0, 0.5);
|
|
2153
|
+
label.position.set(-w / 2 + 20, cy);
|
|
2154
|
+
row.addChild(label);
|
|
2155
|
+
row.eventMode = "static";
|
|
2156
|
+
row.cursor = "pointer";
|
|
2157
|
+
row.hitArea = new Rectangle(-w / 2, 4 + i * rowH, w, rowH);
|
|
2158
|
+
row.on("pointertap", (e) => {
|
|
2159
|
+
e.stopPropagation();
|
|
2160
|
+
this.select.choose(o.value);
|
|
2161
|
+
});
|
|
2162
|
+
list.addChild(row);
|
|
2163
|
+
});
|
|
2164
|
+
panel.addChild(list);
|
|
2165
|
+
const g = this.toGlobal({ x: 0, y: this.h / 2 + 6 });
|
|
2166
|
+
const screenH = typeof window !== "undefined" ? window.innerHeight : 1080;
|
|
2167
|
+
const py = listH > screenH - 16 ? 8 : Math.min(g.y, screenH - 8 - listH);
|
|
2168
|
+
list.position.set(g.x, Math.max(8, py));
|
|
2169
|
+
layer.addChild(panel);
|
|
2170
|
+
this.dropdown = panel;
|
|
2171
|
+
}
|
|
2172
|
+
hideDropdown() {
|
|
2173
|
+
if (this.dropdown && !this.dropdown.destroyed) this.dropdown.destroy({ children: true });
|
|
2174
|
+
this.dropdown = void 0;
|
|
2175
|
+
}
|
|
2176
|
+
redraw() {
|
|
2177
|
+
const t = this.ui.theme;
|
|
2178
|
+
const disabled = this.select.current === "disabled";
|
|
2179
|
+
const open = this.select.isOpen;
|
|
2180
|
+
const w = this.w;
|
|
2181
|
+
const h = this.h;
|
|
2182
|
+
const edge = disabled ? t.color.disabled : t.color.accent;
|
|
2183
|
+
this.bg.clear().roundRect(-w / 2, -h / 2, w, h, h / 2).fill({ color: t.color.surfaceAlt }).stroke({ width: 3, color: edge });
|
|
2184
|
+
this.captionText.text = this.ui.t(this.select.caption ?? "");
|
|
2185
|
+
this.captionText.position.set(-w / 2 + 18, 0);
|
|
2186
|
+
this.captionText.style.fill = t.color.textDim;
|
|
2187
|
+
this.valueText.text = this.ui.t(this.select.optionLabel);
|
|
2188
|
+
this.valueText.position.set(w / 2 - 32, 0);
|
|
2189
|
+
this.valueText.style.fill = disabled ? t.color.textDim : t.color.text;
|
|
2190
|
+
const cx = w / 2 - 16;
|
|
2191
|
+
const dir = open ? -1 : 1;
|
|
2192
|
+
this.chevron.clear().moveTo(cx - 5, -4 * dir).lineTo(cx, 4 * dir).lineTo(cx + 5, -4 * dir).stroke({ width: 3, color: edge, cap: "round", join: "round" });
|
|
2193
|
+
this.art.alpha = disabled ? 0.6 : 1;
|
|
2194
|
+
}
|
|
2195
|
+
play(tr) {
|
|
2196
|
+
this.animating = true;
|
|
2197
|
+
void this.tween.run(this.art, tr, this.ui.theme).then(() => {
|
|
2198
|
+
this.animating = false;
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
dispose() {
|
|
2202
|
+
this.hideDropdown();
|
|
2203
|
+
this.tween.stop();
|
|
2204
|
+
super.dispose();
|
|
2205
|
+
}
|
|
2206
|
+
};
|
|
2207
|
+
var StepperView = class extends ControlView {
|
|
2208
|
+
constructor(stepper, ui, _ticker) {
|
|
2209
|
+
super(stepper, ui);
|
|
2210
|
+
this.stepper = stepper;
|
|
2211
|
+
const t = ui.theme;
|
|
2212
|
+
if (stepper.label) {
|
|
2213
|
+
this.captionText = new Text({
|
|
2214
|
+
text: ui.t(stepper.label),
|
|
2215
|
+
style: { fontFamily: t.type.family, fontSize: 14, fill: t.color.textDim, fontWeight: "600" }
|
|
2216
|
+
});
|
|
2217
|
+
this.captionText.anchor.set(0.5);
|
|
2218
|
+
this.captionText.position.set(0, -22);
|
|
2219
|
+
this.addChild(this.captionText);
|
|
2220
|
+
}
|
|
2221
|
+
this.valueText = new Text({
|
|
2222
|
+
text: "",
|
|
2223
|
+
style: { fontFamily: t.type.family, fontSize: 20, fill: t.color.text, fontWeight: "700" }
|
|
2224
|
+
});
|
|
2225
|
+
this.valueText.anchor.set(0.5);
|
|
2226
|
+
this.valueText.position.set(0, this.captionText ? 6 : 0);
|
|
2227
|
+
this.minus.position.set(-64, this.valueText.y);
|
|
2228
|
+
this.plus.position.set(64, this.valueText.y);
|
|
2229
|
+
this.minus.hitArea = new Circle(0, 0, 20);
|
|
2230
|
+
this.plus.hitArea = new Circle(0, 0, 20);
|
|
2231
|
+
this.minus.on("pointerup", () => this.stepper.dec());
|
|
2232
|
+
this.plus.on("pointerup", () => this.stepper.inc());
|
|
2233
|
+
this.addChild(this.minus, this.valueText, this.plus);
|
|
2234
|
+
this.disposers.push(
|
|
2235
|
+
this.stepper.index.subscribe(() => this.redraw()),
|
|
2236
|
+
this.ui.locale.subscribe(() => {
|
|
2237
|
+
if (!this.destroyed) this.redraw();
|
|
2238
|
+
})
|
|
2239
|
+
);
|
|
2240
|
+
this.redraw();
|
|
2241
|
+
}
|
|
2242
|
+
stepper;
|
|
2243
|
+
minus = new Graphics();
|
|
2244
|
+
plus = new Graphics();
|
|
2245
|
+
valueText;
|
|
2246
|
+
captionText;
|
|
2247
|
+
fmt(v) {
|
|
2248
|
+
return Number.isInteger(v) ? String(v) : v.toFixed(2);
|
|
2249
|
+
}
|
|
2250
|
+
redraw() {
|
|
2251
|
+
const t = this.ui.theme;
|
|
2252
|
+
if (this.captionText) this.captionText.text = this.ui.t(this.stepper.label ?? "");
|
|
2253
|
+
this.valueText.text = this.fmt(this.stepper.value);
|
|
2254
|
+
drawStepButton(this.minus, "minus", this.stepper.canDec, t);
|
|
2255
|
+
drawStepButton(this.plus, "plus", this.stepper.canInc, t);
|
|
2256
|
+
}
|
|
2257
|
+
};
|
|
2258
|
+
function drawStepButton(g, kind, enabled, t) {
|
|
2259
|
+
const col = enabled ? t.color.accent : t.color.disabled;
|
|
2260
|
+
g.clear();
|
|
2261
|
+
g.circle(0, 0, 18).fill({ color: t.color.surfaceAlt }).stroke({ width: 3, color: col });
|
|
2262
|
+
g.moveTo(-7, 0).lineTo(7, 0).stroke({ width: 3, color: col, cap: "round" });
|
|
2263
|
+
if (kind === "plus") g.moveTo(0, -7).lineTo(0, 7).stroke({ width: 3, color: col, cap: "round" });
|
|
2264
|
+
g.alpha = enabled ? 1 : 0.5;
|
|
2265
|
+
g.eventMode = enabled ? "static" : "none";
|
|
2266
|
+
g.cursor = enabled ? "pointer" : "default";
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// src/views/blockColumn.ts
|
|
2270
|
+
var ROW_H = 72;
|
|
2271
|
+
var PAD = 28;
|
|
2272
|
+
var GAP = 16;
|
|
2273
|
+
function buildBlockColumn(blocks, controls, ui, ticker, bodyW, opts = {}) {
|
|
2274
|
+
const t = ui.theme;
|
|
2275
|
+
const tr = (s) => ui.t(s);
|
|
2276
|
+
const innerW = bodyW - PAD * 2;
|
|
2277
|
+
const byId = new Map(controls.map((c) => [c.id, c]));
|
|
2278
|
+
const content = new Container();
|
|
2279
|
+
const views = [];
|
|
2280
|
+
let y = PAD;
|
|
2281
|
+
const placeFixed = (node, h) => {
|
|
2282
|
+
node.position.set(0, y + h / 2);
|
|
2283
|
+
content.addChild(node);
|
|
2284
|
+
y += h;
|
|
2285
|
+
};
|
|
2286
|
+
const placeAuto = (node, gap = GAP) => {
|
|
2287
|
+
const h = node.height || 1;
|
|
2288
|
+
node.position.set(0, y + h / 2);
|
|
2289
|
+
content.addChild(node);
|
|
2290
|
+
y += h + gap;
|
|
2291
|
+
};
|
|
2292
|
+
const heading = (s, size = 18) => {
|
|
2293
|
+
const wrap = new Container();
|
|
2294
|
+
const txt = new Text({
|
|
2295
|
+
text: tr(s),
|
|
2296
|
+
style: { fontFamily: t.type.family, fontSize: size, fill: t.color.text, fontWeight: "800", letterSpacing: 1 }
|
|
2297
|
+
});
|
|
2298
|
+
txt.anchor.set(0.5);
|
|
2299
|
+
txt.position.set(0, 0);
|
|
2300
|
+
const half = Math.min(txt.width / 2, innerW / 2 - 24);
|
|
2301
|
+
const gap = 16;
|
|
2302
|
+
wrap.addChild(
|
|
2303
|
+
new Graphics().moveTo(-innerW / 2, 0).lineTo(-half - gap, 0).stroke({ width: 2, color: t.color.text, alpha: 0.85 }),
|
|
2304
|
+
new Graphics().moveTo(half + gap, 0).lineTo(innerW / 2, 0).stroke({ width: 2, color: t.color.text, alpha: 0.85 }),
|
|
2305
|
+
txt
|
|
2306
|
+
);
|
|
2307
|
+
return wrap;
|
|
2308
|
+
};
|
|
2309
|
+
const body = (s) => richParagraphNode(s, ui, innerW, { fontFamily: t.type.family, fontSize: 15, fill: t.color.textDim, lineHeight: 22 });
|
|
2310
|
+
const subheading = (s) => {
|
|
2311
|
+
const wrap = new Container();
|
|
2312
|
+
const txt = new Text({ text: tr(s), style: { fontFamily: t.type.family, fontSize: 15, fill: t.color.text, fontWeight: "800", letterSpacing: 0.5 } });
|
|
2313
|
+
txt.anchor.set(0, 0.5);
|
|
2314
|
+
txt.position.set(-innerW / 2, 0);
|
|
2315
|
+
wrap.addChild(txt);
|
|
2316
|
+
return wrap;
|
|
2317
|
+
};
|
|
2318
|
+
const legal = (s) => richParagraphNode(s, ui, innerW, { fontFamily: t.type.family, fontSize: 12, fill: t.color.textDim, lineHeight: 17 });
|
|
2319
|
+
const caption = (s) => {
|
|
2320
|
+
const wrap = new Container();
|
|
2321
|
+
const txt = new Text({ text: s, style: { fontFamily: t.type.family, fontSize: 15, fill: t.color.text, fontWeight: "700" } });
|
|
2322
|
+
txt.anchor.set(0.5);
|
|
2323
|
+
wrap.addChild(txt);
|
|
2324
|
+
return wrap;
|
|
2325
|
+
};
|
|
2326
|
+
const makeView = (b, control) => {
|
|
2327
|
+
const skin = opts.controlSkins?.[b.id];
|
|
2328
|
+
if (skin) return skin(control, ui, ticker);
|
|
2329
|
+
switch (b.kind) {
|
|
2330
|
+
case "slider":
|
|
2331
|
+
return new SliderView(control, ui);
|
|
2332
|
+
case "toggle":
|
|
2333
|
+
return new ToggleView(control, ui, ticker, { radius: 22 });
|
|
2334
|
+
case "button":
|
|
2335
|
+
return new ButtonView(control, ui, ticker, { shape: "pill", height: 48 });
|
|
2336
|
+
case "select":
|
|
2337
|
+
return new SelectView(control, ui, ticker, { width: 320, dropdownLayer: opts.dropdownLayer });
|
|
2338
|
+
case "stepper":
|
|
2339
|
+
return new StepperView(control, ui, ticker);
|
|
2340
|
+
case "value":
|
|
2341
|
+
return new ValueDisplayView(control, ui, ticker);
|
|
2342
|
+
default:
|
|
2343
|
+
console.warn(`[open-ui] block column: no view for kind "${b.kind}" (id="${b.id}") \u2014 skipped`);
|
|
2344
|
+
return null;
|
|
2345
|
+
}
|
|
2346
|
+
};
|
|
2347
|
+
const walk = (bs) => {
|
|
2348
|
+
for (const b of bs) {
|
|
2349
|
+
switch (b.kind) {
|
|
2350
|
+
case "group":
|
|
2351
|
+
if (b.title) placeAuto(heading(b.title, 14), 10);
|
|
2352
|
+
walk(b.children);
|
|
2353
|
+
break;
|
|
2354
|
+
case "heading":
|
|
2355
|
+
placeAuto(heading(b.text), 12);
|
|
2356
|
+
break;
|
|
2357
|
+
case "subheading":
|
|
2358
|
+
placeAuto(subheading(b.text), 8);
|
|
2359
|
+
break;
|
|
2360
|
+
case "text":
|
|
2361
|
+
placeAuto(body(tr(b.text)));
|
|
2362
|
+
break;
|
|
2363
|
+
case "legal":
|
|
2364
|
+
placeAuto(legal(tr(b.text)));
|
|
2365
|
+
break;
|
|
2366
|
+
case "divider":
|
|
2367
|
+
placeAuto(dividerNode(innerW, ui), 10);
|
|
2368
|
+
break;
|
|
2369
|
+
case "callout":
|
|
2370
|
+
placeAuto(calloutNode(b, ui, innerW));
|
|
2371
|
+
break;
|
|
2372
|
+
case "stat-grid":
|
|
2373
|
+
placeAuto(statGridNode(b, ui, innerW));
|
|
2374
|
+
break;
|
|
2375
|
+
case "steps":
|
|
2376
|
+
placeAuto(body(b.items.map((s, i) => `${b.ordered ? `${i + 1}.` : "\u2022"} ${tr(s)}`).join("\n")));
|
|
2377
|
+
break;
|
|
2378
|
+
case "table":
|
|
2379
|
+
placeAuto(tableNode(b, ui, innerW));
|
|
2380
|
+
break;
|
|
2381
|
+
case "cards":
|
|
2382
|
+
placeAuto(cardsNode(b, ui, innerW));
|
|
2383
|
+
break;
|
|
2384
|
+
case "paytable":
|
|
2385
|
+
placeAuto(paytableNode(b, ui, innerW));
|
|
2386
|
+
break;
|
|
2387
|
+
case "media":
|
|
2388
|
+
placeAuto(mediaNode(b, ui, innerW));
|
|
2389
|
+
break;
|
|
2390
|
+
case "image": {
|
|
2391
|
+
let iw = b.width || 64;
|
|
2392
|
+
let ih = b.height || 64;
|
|
2393
|
+
if (iw > innerW) {
|
|
2394
|
+
ih = Math.round(ih * innerW / iw);
|
|
2395
|
+
iw = innerW;
|
|
2396
|
+
}
|
|
2397
|
+
placeAuto(imageBoxNode(b.src, iw, ih, ui));
|
|
2398
|
+
break;
|
|
2399
|
+
}
|
|
2400
|
+
default: {
|
|
2401
|
+
const control = byId.get(b.id);
|
|
2402
|
+
if (!control) break;
|
|
2403
|
+
if ((b.kind === "slider" || b.kind === "toggle") && b.label) placeAuto(caption(tr(b.label)), 6);
|
|
2404
|
+
const view = makeView(b, control);
|
|
2405
|
+
if (!view) break;
|
|
2406
|
+
views.push(view);
|
|
2407
|
+
const wrap = new Container();
|
|
2408
|
+
if (b.kind === "slider") view.position.set(-130, -27);
|
|
2409
|
+
wrap.addChild(view);
|
|
2410
|
+
placeFixed(wrap, ROW_H);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
};
|
|
2415
|
+
walk(blocks);
|
|
2416
|
+
return { content, views, height: y + PAD, innerW };
|
|
2417
|
+
}
|
|
2418
|
+
function richParagraphNode(s, ui, width, style) {
|
|
2419
|
+
const t = ui.theme;
|
|
2420
|
+
const c = new Container();
|
|
2421
|
+
const lineH = typeof style.lineHeight === "number" ? style.lineHeight : 22;
|
|
2422
|
+
const dim = style.fill;
|
|
2423
|
+
const runs = [];
|
|
2424
|
+
const re = /\*\*(.+?)\*\*/g;
|
|
2425
|
+
let last = 0;
|
|
2426
|
+
let m;
|
|
2427
|
+
while ((m = re.exec(s)) !== null) {
|
|
2428
|
+
if (m.index > last) runs.push({ text: s.slice(last, m.index), bold: false });
|
|
2429
|
+
runs.push({ text: m[1], bold: true });
|
|
2430
|
+
last = re.lastIndex;
|
|
2431
|
+
}
|
|
2432
|
+
if (last < s.length) runs.push({ text: s.slice(last), bold: false });
|
|
2433
|
+
let x = 0;
|
|
2434
|
+
let line = 0;
|
|
2435
|
+
const x0 = -width / 2;
|
|
2436
|
+
for (const run of runs) {
|
|
2437
|
+
for (const w of run.text.split(/(\n|\s+)/).filter((p) => p.length)) {
|
|
2438
|
+
if (w === "\n") {
|
|
2439
|
+
x = 0;
|
|
2440
|
+
line += 1;
|
|
2441
|
+
continue;
|
|
2442
|
+
}
|
|
2443
|
+
const isSpace = /^\s+$/.test(w);
|
|
2444
|
+
if (isSpace && x === 0) continue;
|
|
2445
|
+
const txt = new Text({ text: w, style: { ...style, fontWeight: run.bold ? "800" : style.fontWeight ?? "400", fill: run.bold ? t.color.text : dim } });
|
|
2446
|
+
txt.anchor.set(0, 0);
|
|
2447
|
+
if (!isSpace && x > 0 && x + txt.width > width) {
|
|
2448
|
+
x = 0;
|
|
2449
|
+
line += 1;
|
|
2450
|
+
}
|
|
2451
|
+
txt.position.set(x0 + x, line * lineH);
|
|
2452
|
+
c.addChild(txt);
|
|
2453
|
+
x += txt.width;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
const totalH = (line + 1) * lineH;
|
|
2457
|
+
for (const ch of c.children) ch.y -= totalH / 2;
|
|
2458
|
+
return c;
|
|
2459
|
+
}
|
|
2460
|
+
function calloutNode(b, ui, innerW) {
|
|
2461
|
+
const t = ui.theme;
|
|
2462
|
+
const tone = b.tone === "warning" ? "#ffb020" : t.color.accent;
|
|
2463
|
+
const c = new Container();
|
|
2464
|
+
const padX = 16;
|
|
2465
|
+
const padY = 12;
|
|
2466
|
+
const textW = innerW - padX * 2 - 4;
|
|
2467
|
+
const title = b.title ? new Text({ text: ui.t(b.title), style: { fontFamily: t.type.family, fontSize: 14, fill: tone, fontWeight: "800", letterSpacing: 0.3 } }) : null;
|
|
2468
|
+
title?.anchor.set(0, 0);
|
|
2469
|
+
const bodyNode = richParagraphNode(ui.t(b.text), ui, textW, { fontFamily: t.type.family, fontSize: 14, fill: t.color.text, lineHeight: 20 });
|
|
2470
|
+
const bodyH = bodyNode.height;
|
|
2471
|
+
const titleH = title ? title.height + 6 : 0;
|
|
2472
|
+
const h = padY * 2 + titleH + bodyH;
|
|
2473
|
+
const x = -innerW / 2;
|
|
2474
|
+
const bg = new Graphics().roundRect(x, -h / 2, innerW, h, 10).fill({ color: tone, alpha: 0.08 }).roundRect(x, -h / 2, innerW, h, 10).stroke({ width: 1.5, color: tone, alpha: 0.5 }).roundRect(x, -h / 2, 4, h, 2).fill({ color: tone });
|
|
2475
|
+
c.addChild(bg);
|
|
2476
|
+
if (title) {
|
|
2477
|
+
title.position.set(x + padX, -h / 2 + padY);
|
|
2478
|
+
c.addChild(title);
|
|
2479
|
+
}
|
|
2480
|
+
bodyNode.position.set(x + padX + textW / 2, -h / 2 + padY + titleH + bodyH / 2);
|
|
2481
|
+
c.addChild(bodyNode);
|
|
2482
|
+
return c;
|
|
2483
|
+
}
|
|
2484
|
+
function statGridNode(b, ui, innerW) {
|
|
2485
|
+
const t = ui.theme;
|
|
2486
|
+
const c = new Container();
|
|
2487
|
+
const rowH = 30;
|
|
2488
|
+
const totalH = Math.max(b.items.length * rowH, rowH);
|
|
2489
|
+
b.items.forEach((it, i) => {
|
|
2490
|
+
const cy = -totalH / 2 + rowH / 2 + i * rowH;
|
|
2491
|
+
if (i > 0) {
|
|
2492
|
+
c.addChild(new Graphics().moveTo(-innerW / 2, cy - rowH / 2).lineTo(innerW / 2, cy - rowH / 2).stroke({ width: 1, color: t.color.textDim, alpha: 0.18 }));
|
|
2493
|
+
}
|
|
2494
|
+
const label = new Text({ text: ui.t(it.label), style: { fontFamily: t.type.family, fontSize: 14, fill: t.color.textDim } });
|
|
2495
|
+
label.anchor.set(0, 0.5);
|
|
2496
|
+
label.position.set(-innerW / 2, cy);
|
|
2497
|
+
const value = new Text({ text: ui.t(it.value), style: { fontFamily: t.type.family, fontSize: 14, fill: t.color.text, fontWeight: "700" } });
|
|
2498
|
+
value.anchor.set(1, 0.5);
|
|
2499
|
+
value.position.set(innerW / 2, cy);
|
|
2500
|
+
c.addChild(label, value);
|
|
2501
|
+
});
|
|
2502
|
+
return c;
|
|
2503
|
+
}
|
|
2504
|
+
function dividerNode(innerW, ui) {
|
|
2505
|
+
const c = new Container();
|
|
2506
|
+
c.addChild(new Graphics().rect(-innerW / 2, -0.5, innerW, 1).fill({ color: ui.theme.color.textDim, alpha: 0.3 }));
|
|
2507
|
+
return c;
|
|
2508
|
+
}
|
|
2509
|
+
function tableNode(b, ui, innerW) {
|
|
2510
|
+
const t = ui.theme;
|
|
2511
|
+
const c = new Container();
|
|
2512
|
+
const head = b.columns && b.columns.length ? [b.columns] : [];
|
|
2513
|
+
const allRows = [...head, ...b.rows];
|
|
2514
|
+
const cols = Math.max(1, b.columns?.length ?? b.rows[0]?.length ?? 1);
|
|
2515
|
+
const colW = innerW / cols;
|
|
2516
|
+
const rowH = 30;
|
|
2517
|
+
const totalH = Math.max(allRows.length * rowH, rowH);
|
|
2518
|
+
const left = -innerW / 2;
|
|
2519
|
+
allRows.forEach((row, ri) => {
|
|
2520
|
+
const cy = -totalH / 2 + rowH / 2 + ri * rowH;
|
|
2521
|
+
const isHeader = head.length > 0 && ri === 0;
|
|
2522
|
+
if (ri > 0) {
|
|
2523
|
+
c.addChild(new Graphics().moveTo(left, cy - rowH / 2).lineTo(innerW / 2, cy - rowH / 2).stroke({ width: 1, color: t.color.textDim, alpha: 0.18 }));
|
|
2524
|
+
}
|
|
2525
|
+
for (let ci = 0; ci < cols; ci++) {
|
|
2526
|
+
const raw = row[ci] ?? "";
|
|
2527
|
+
const cx = left + ci * colW + 8;
|
|
2528
|
+
const fill = isHeader ? t.color.text : ci === 0 ? t.color.text : t.color.accent;
|
|
2529
|
+
const weight = isHeader ? "800" : ci === 0 ? "700" : "700";
|
|
2530
|
+
const txt = new Text({ text: ui.t(raw), style: { fontFamily: t.type.family, fontSize: 13, fill, fontWeight: weight } });
|
|
2531
|
+
txt.anchor.set(0, 0.5);
|
|
2532
|
+
txt.position.set(cx, cy);
|
|
2533
|
+
c.addChild(txt);
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
return c;
|
|
2537
|
+
}
|
|
2538
|
+
function cardsNode(b, ui, innerW) {
|
|
2539
|
+
const t = ui.theme;
|
|
2540
|
+
const c = new Container();
|
|
2541
|
+
const n = b.items.length || 1;
|
|
2542
|
+
const gap = 12;
|
|
2543
|
+
const cols = Math.max(1, Math.min(n, Math.floor((innerW + gap) / (150 + gap))));
|
|
2544
|
+
const cardW = (innerW - gap * (cols - 1)) / cols;
|
|
2545
|
+
const rows = Math.ceil(n / cols);
|
|
2546
|
+
const cardH = 132;
|
|
2547
|
+
const totalH = rows * cardH + (rows - 1) * gap;
|
|
2548
|
+
b.items.forEach((it, i) => {
|
|
2549
|
+
const col = i % cols;
|
|
2550
|
+
const row = Math.floor(i / cols);
|
|
2551
|
+
const cardX = -innerW / 2 + col * (cardW + gap);
|
|
2552
|
+
const cardY = -totalH / 2 + row * (cardH + gap);
|
|
2553
|
+
const card = new Container();
|
|
2554
|
+
card.addChild(
|
|
2555
|
+
new Graphics().roundRect(0, 0, cardW, cardH, 12).fill({ color: t.color.surfaceAlt, alpha: 0.6 }).roundRect(0, 0, cardW, cardH, 12).stroke({ width: 1, color: t.color.textDim, alpha: 0.15 })
|
|
2556
|
+
);
|
|
2557
|
+
if (it.icon) {
|
|
2558
|
+
const icon = imageBoxNode(it.icon, 44, 44, ui);
|
|
2559
|
+
icon.position.set(cardW / 2, 34);
|
|
2560
|
+
card.addChild(icon);
|
|
2561
|
+
}
|
|
2562
|
+
const title = new Text({ text: ui.t(it.title), style: { fontFamily: t.type.family, fontSize: 14, fill: t.color.text, fontWeight: "800" } });
|
|
2563
|
+
title.anchor.set(0.5, 0);
|
|
2564
|
+
title.position.set(cardW / 2, it.icon ? 64 : 14);
|
|
2565
|
+
card.addChild(title);
|
|
2566
|
+
if (it.text) {
|
|
2567
|
+
const para = richParagraphNode(ui.t(it.text), ui, cardW - 20, { fontFamily: t.type.family, fontSize: 12, fill: t.color.textDim, lineHeight: 16 });
|
|
2568
|
+
para.position.set(cardW / 2, (it.icon ? 96 : 46) + para.height / 2);
|
|
2569
|
+
card.addChild(para);
|
|
2570
|
+
}
|
|
2571
|
+
card.position.set(cardX, cardY);
|
|
2572
|
+
c.addChild(card);
|
|
2573
|
+
});
|
|
2574
|
+
return c;
|
|
2575
|
+
}
|
|
2576
|
+
function mediaNode(b, ui, innerW) {
|
|
2577
|
+
const t = ui.theme;
|
|
2578
|
+
const c = new Container();
|
|
2579
|
+
const imgW = Math.min(b.width ?? 200, Math.round(innerW * 0.4));
|
|
2580
|
+
const imgH = b.width && b.height ? Math.round(imgW * b.height / b.width) : Math.round(imgW * 0.62);
|
|
2581
|
+
const gap = 18;
|
|
2582
|
+
const textW = innerW - imgW - gap;
|
|
2583
|
+
const side = b.side ?? "left";
|
|
2584
|
+
const imgX = side === "left" ? -innerW / 2 + imgW / 2 : innerW / 2 - imgW / 2;
|
|
2585
|
+
const textCx = side === "left" ? -innerW / 2 + imgW + gap + textW / 2 : -innerW / 2 + textW / 2;
|
|
2586
|
+
const title = b.title ? new Text({ text: ui.t(b.title), style: { fontFamily: t.type.family, fontSize: 15, fill: t.color.text, fontWeight: "800" } }) : null;
|
|
2587
|
+
title?.anchor.set(0, 0);
|
|
2588
|
+
const para = richParagraphNode(ui.t(b.text), ui, textW, { fontFamily: t.type.family, fontSize: 14, fill: t.color.textDim, lineHeight: 19 });
|
|
2589
|
+
const titleH = title ? title.height + 8 : 0;
|
|
2590
|
+
const textH = titleH + para.height;
|
|
2591
|
+
const h = Math.max(imgH, textH);
|
|
2592
|
+
const img = imageBoxNode(b.src, imgW, imgH, ui);
|
|
2593
|
+
img.position.set(imgX, 0);
|
|
2594
|
+
c.addChild(img);
|
|
2595
|
+
if (title) {
|
|
2596
|
+
title.position.set(textCx - textW / 2, -textH / 2);
|
|
2597
|
+
c.addChild(title);
|
|
2598
|
+
}
|
|
2599
|
+
para.position.set(textCx, -textH / 2 + titleH + para.height / 2);
|
|
2600
|
+
c.addChild(para);
|
|
2601
|
+
c.addChild(new Graphics().rect(-innerW / 2, -h / 2, 1, h).fill({ color: 16777215, alpha: 0 }));
|
|
2602
|
+
return c;
|
|
2603
|
+
}
|
|
2604
|
+
function imageBoxNode(src, w, h, ui) {
|
|
2605
|
+
const t = ui.theme;
|
|
2606
|
+
const box = new Container();
|
|
2607
|
+
const placeholder = new Graphics().rect(-w / 2, -h / 2, w, h).fill({ color: t.color.surfaceAlt, alpha: 0.5 });
|
|
2608
|
+
box.addChild(placeholder);
|
|
2609
|
+
if (typeof Image !== "undefined") {
|
|
2610
|
+
const img = new Image();
|
|
2611
|
+
img.crossOrigin = "anonymous";
|
|
2612
|
+
img.onload = () => {
|
|
2613
|
+
if (box.destroyed) return;
|
|
2614
|
+
try {
|
|
2615
|
+
const sp = new Sprite(Texture.from(img));
|
|
2616
|
+
sp.anchor.set(0.5);
|
|
2617
|
+
sp.width = w;
|
|
2618
|
+
sp.height = h;
|
|
2619
|
+
box.addChild(sp);
|
|
2620
|
+
placeholder.visible = false;
|
|
2621
|
+
} catch {
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
img.onerror = () => {
|
|
2625
|
+
};
|
|
2626
|
+
img.src = src;
|
|
2627
|
+
}
|
|
2628
|
+
return box;
|
|
2629
|
+
}
|
|
2630
|
+
function paytableNode(b, ui, innerW) {
|
|
2631
|
+
const want = Math.max(1, b.columns ?? 1);
|
|
2632
|
+
const fit = Math.max(1, Math.floor(innerW / 170));
|
|
2633
|
+
const cols = Math.max(1, Math.min(want, fit, b.rows.length || 1));
|
|
2634
|
+
return cols <= 1 ? paytableList(b, ui, innerW) : paytableGrid(b, ui, innerW, cols);
|
|
2635
|
+
}
|
|
2636
|
+
function paytableList(b, ui, innerW) {
|
|
2637
|
+
const t = ui.theme;
|
|
2638
|
+
const c = new Container();
|
|
2639
|
+
const rowH = 44;
|
|
2640
|
+
const totalH = Math.max(b.rows.length * rowH, rowH);
|
|
2641
|
+
const hasIcons = b.rows.some((r) => r.icon);
|
|
2642
|
+
const left = -innerW / 2;
|
|
2643
|
+
const symbolX = left + (hasIcons ? 48 : 4);
|
|
2644
|
+
b.rows.forEach((r, i) => {
|
|
2645
|
+
const cy = -totalH / 2 + rowH / 2 + i * rowH;
|
|
2646
|
+
if (i > 0) {
|
|
2647
|
+
c.addChild(new Graphics().moveTo(left, cy - rowH / 2).lineTo(innerW / 2, cy - rowH / 2).stroke({ width: 1, color: t.color.textDim, alpha: 0.15 }));
|
|
2648
|
+
}
|
|
2649
|
+
if (r.icon) {
|
|
2650
|
+
const icon = imageBoxNode(r.icon, 36, 36, ui);
|
|
2651
|
+
icon.position.set(left + 22, cy);
|
|
2652
|
+
c.addChild(icon);
|
|
2653
|
+
}
|
|
2654
|
+
const sym = new Text({ text: ui.t(r.symbol ?? ""), style: { fontFamily: t.type.family, fontSize: 15, fill: t.color.text, fontWeight: "700" } });
|
|
2655
|
+
sym.anchor.set(0, 0.5);
|
|
2656
|
+
sym.position.set(symbolX, cy);
|
|
2657
|
+
const pay = new Text({ text: r.payouts, style: { fontFamily: t.type.family, fontSize: 14, fill: t.color.accent, fontWeight: "700" } });
|
|
2658
|
+
pay.anchor.set(1, 0.5);
|
|
2659
|
+
pay.position.set(innerW / 2, cy);
|
|
2660
|
+
c.addChild(sym, pay);
|
|
2661
|
+
});
|
|
2662
|
+
return c;
|
|
2663
|
+
}
|
|
2664
|
+
function paytableGrid(b, ui, innerW, cols) {
|
|
2665
|
+
const c = new Container();
|
|
2666
|
+
const cellW = innerW / cols;
|
|
2667
|
+
const gridRows = Math.ceil(b.rows.length / cols);
|
|
2668
|
+
const lineH = 17;
|
|
2669
|
+
const maxLines = b.rows.reduce((m, r) => Math.max(m, (r.payouts || "").split("\n").length), 1);
|
|
2670
|
+
const cellH = Math.max(48, 14 + maxLines * lineH);
|
|
2671
|
+
const totalH = gridRows * cellH;
|
|
2672
|
+
b.rows.forEach((r, i) => {
|
|
2673
|
+
const col = i % cols;
|
|
2674
|
+
const row = Math.floor(i / cols);
|
|
2675
|
+
const cell = paytableCell(r, ui, cellW, lineH);
|
|
2676
|
+
cell.position.set(-innerW / 2 + col * cellW + cellW / 2, -totalH / 2 + row * cellH + cellH / 2);
|
|
2677
|
+
c.addChild(cell);
|
|
2678
|
+
});
|
|
2679
|
+
return c;
|
|
2680
|
+
}
|
|
2681
|
+
function paytableCell(r, ui, cellW, lineH) {
|
|
2682
|
+
const t = ui.theme;
|
|
2683
|
+
const cell = new Container();
|
|
2684
|
+
const lx = -cellW / 2 + 10;
|
|
2685
|
+
let leftW = 0;
|
|
2686
|
+
if (r.icon) {
|
|
2687
|
+
const icon = imageBoxNode(r.icon, 40, 40, ui);
|
|
2688
|
+
icon.position.set(lx + 20, 0);
|
|
2689
|
+
cell.addChild(icon);
|
|
2690
|
+
leftW = 52;
|
|
2691
|
+
} else if (r.symbol) {
|
|
2692
|
+
const sym = new Text({ text: ui.t(r.symbol), style: { fontFamily: t.type.family, fontSize: 14, fontWeight: "800", fill: t.color.text } });
|
|
2693
|
+
sym.anchor.set(0, 0.5);
|
|
2694
|
+
sym.position.set(lx, 0);
|
|
2695
|
+
cell.addChild(sym);
|
|
2696
|
+
leftW = sym.width + 14;
|
|
2697
|
+
}
|
|
2698
|
+
const lines = (r.payouts || "").split("\n");
|
|
2699
|
+
const blockH = lines.length * lineH;
|
|
2700
|
+
const px = lx + leftW;
|
|
2701
|
+
lines.forEach((ln, j) => {
|
|
2702
|
+
const ly = -blockH / 2 + lineH / 2 + j * lineH;
|
|
2703
|
+
const ci = ln.indexOf(":");
|
|
2704
|
+
if (ci >= 0) {
|
|
2705
|
+
const label = new Text({ text: ln.slice(0, ci + 1), style: { fontFamily: t.type.family, fontSize: 13, fontWeight: "800", fill: t.color.text } });
|
|
2706
|
+
label.anchor.set(0, 0.5);
|
|
2707
|
+
label.position.set(px, ly);
|
|
2708
|
+
const val = new Text({ text: ln.slice(ci + 1), style: { fontFamily: t.type.family, fontSize: 13, fontWeight: "700", fill: t.color.accent } });
|
|
2709
|
+
val.anchor.set(0, 0.5);
|
|
2710
|
+
val.position.set(px + label.width + 4, ly);
|
|
2711
|
+
cell.addChild(label, val);
|
|
2712
|
+
} else {
|
|
2713
|
+
const txt = new Text({ text: ln, style: { fontFamily: t.type.family, fontSize: 13, fontWeight: "700", fill: t.color.accent } });
|
|
2714
|
+
txt.anchor.set(0, 0.5);
|
|
2715
|
+
txt.position.set(px, ly);
|
|
2716
|
+
cell.addChild(txt);
|
|
2717
|
+
}
|
|
2718
|
+
});
|
|
2719
|
+
return cell;
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
// src/views/MenuView.ts
|
|
2723
|
+
var MARGIN = 16;
|
|
2724
|
+
var HEADER_H = 60;
|
|
2725
|
+
var INSET = 22;
|
|
2726
|
+
var MenuView = class extends ControlView {
|
|
2727
|
+
constructor(panel, controls, blocks, ui, ticker, opts = {}) {
|
|
2728
|
+
super(panel, ui);
|
|
2729
|
+
this.panel = panel;
|
|
2730
|
+
this.controls = controls;
|
|
2731
|
+
this.blocks = blocks;
|
|
2732
|
+
this.ticker = ticker;
|
|
2733
|
+
this.opts = opts;
|
|
2734
|
+
this.zIndex = 120;
|
|
2735
|
+
this.titleKey = opts.title ?? "Menu";
|
|
2736
|
+
this.maxWidth = opts.maxWidth ?? 1600;
|
|
2737
|
+
this.backdrop.eventMode = "static";
|
|
2738
|
+
this.backdrop.on("pointertap", () => this.panel.closePanel());
|
|
2739
|
+
this.title = new Text({ text: ui.t(this.titleKey), style: { fontFamily: ui.theme.type.family, fontSize: 24, fill: ui.theme.color.text, fontWeight: "800", letterSpacing: 1 } });
|
|
2740
|
+
this.title.anchor.set(0, 0.5);
|
|
2741
|
+
this.buildClose();
|
|
2742
|
+
this.viewport.addChild(this.catcher, this.content);
|
|
2743
|
+
this.viewport.mask = this.maskG;
|
|
2744
|
+
this.catcher.eventMode = "static";
|
|
2745
|
+
this.catcher.on("pointerdown", this.onDown);
|
|
2746
|
+
this.catcher.on("globalpointermove", this.onMove);
|
|
2747
|
+
this.catcher.on("pointerup", this.onUp);
|
|
2748
|
+
this.catcher.on("pointerupoutside", this.onUp);
|
|
2749
|
+
this.addChild(this.backdrop, this.card, this.viewport, this.maskG, this.headerBar, this.title, this.closeBtn, this.dropdownLayer);
|
|
2750
|
+
this.rebuildContent();
|
|
2751
|
+
this.applyOpen(this.panel.isOpen);
|
|
2752
|
+
this.disposers.push(
|
|
2753
|
+
this.panel.state.subscribe(() => this.applyOpen(this.panel.isOpen)),
|
|
2754
|
+
this.ui.locale.subscribe(() => {
|
|
2755
|
+
if (this.destroyed) return;
|
|
2756
|
+
this.title.text = this.ui.t(this.titleKey);
|
|
2757
|
+
this.rebuildContent();
|
|
2758
|
+
})
|
|
2759
|
+
);
|
|
2760
|
+
}
|
|
2761
|
+
panel;
|
|
2762
|
+
controls;
|
|
2763
|
+
blocks;
|
|
2764
|
+
ticker;
|
|
2765
|
+
opts;
|
|
2766
|
+
backdrop = new Graphics();
|
|
2767
|
+
card = new Graphics();
|
|
2768
|
+
headerBar = new Graphics();
|
|
2769
|
+
title;
|
|
2770
|
+
closeBtn = new Container();
|
|
2771
|
+
viewport = new Container();
|
|
2772
|
+
maskG = new Graphics();
|
|
2773
|
+
catcher = new Graphics();
|
|
2774
|
+
content = new Container();
|
|
2775
|
+
/** Unclipped layer above the scroll mask for open select dropdowns. */
|
|
2776
|
+
dropdownLayer = new Container();
|
|
2777
|
+
childViews = [];
|
|
2778
|
+
titleKey;
|
|
2779
|
+
maxWidth;
|
|
2780
|
+
vpW = 0;
|
|
2781
|
+
vpH = 0;
|
|
2782
|
+
scrollY = 0;
|
|
2783
|
+
contentH = 0;
|
|
2784
|
+
dragging = false;
|
|
2785
|
+
lastY = 0;
|
|
2786
|
+
wheelHandler;
|
|
2787
|
+
buildClose() {
|
|
2788
|
+
const t = this.ui.theme;
|
|
2789
|
+
const r = 22;
|
|
2790
|
+
const bg = new Graphics().circle(0, 0, r).fill({ color: t.color.surfaceAlt }).stroke({ width: 2, color: t.color.textDim });
|
|
2791
|
+
const x = new Graphics().moveTo(-7, -7).lineTo(7, 7).moveTo(7, -7).lineTo(-7, 7).stroke({ width: 3, color: t.color.text });
|
|
2792
|
+
this.closeBtn.addChild(bg, x);
|
|
2793
|
+
this.closeBtn.eventMode = "static";
|
|
2794
|
+
this.closeBtn.cursor = "pointer";
|
|
2795
|
+
this.closeBtn.hitArea = new Rectangle(-r, -r, r * 2, r * 2);
|
|
2796
|
+
this.closeBtn.on("pointertap", () => this.panel.closePanel());
|
|
2797
|
+
}
|
|
2798
|
+
rebuildContent() {
|
|
2799
|
+
for (const v of this.childViews) v.dispose();
|
|
2800
|
+
this.childViews.length = 0;
|
|
2801
|
+
for (const child of this.content.removeChildren()) child.destroy();
|
|
2802
|
+
const bodyW = this.vpW > 0 ? this.vpW : Math.min(this.maxWidth - INSET * 2, 520);
|
|
2803
|
+
const col = buildBlockColumn(this.blocks, this.controls, this.ui, this.ticker, bodyW, { controlSkins: this.opts.controlSkins, dropdownLayer: this.dropdownLayer });
|
|
2804
|
+
this.childViews = col.views;
|
|
2805
|
+
this.content.addChild(...col.content.removeChildren());
|
|
2806
|
+
this.content.x = bodyW / 2;
|
|
2807
|
+
this.contentH = col.height;
|
|
2808
|
+
this.clampScroll();
|
|
2809
|
+
}
|
|
2810
|
+
applyLayout(screen) {
|
|
2811
|
+
const W = screen.width;
|
|
2812
|
+
const H = screen.height;
|
|
2813
|
+
this.position.set(0, 0);
|
|
2814
|
+
this.scale.set(1);
|
|
2815
|
+
const t = this.ui.theme;
|
|
2816
|
+
this.backdrop.clear().rect(0, 0, W, H).fill({ color: 0, alpha: 0.62 });
|
|
2817
|
+
this.backdrop.hitArea = new Rectangle(0, 0, W, H);
|
|
2818
|
+
const marginX = Math.max(MARGIN, Math.round(W * 0.05));
|
|
2819
|
+
const cardW = Math.min(W - marginX * 2, this.maxWidth);
|
|
2820
|
+
const cardH = H - MARGIN * 2;
|
|
2821
|
+
const cx = (W - cardW) / 2;
|
|
2822
|
+
const cy = MARGIN;
|
|
2823
|
+
this.card.clear().roundRect(cx, cy, cardW, cardH, t.radius.card).fill({ color: t.color.surface }).stroke({ width: 2, color: t.color.accent });
|
|
2824
|
+
this.headerBar.clear().roundRect(cx, cy, cardW, HEADER_H, t.radius.card).fill({ color: t.color.surfaceAlt }).moveTo(cx + INSET, cy + HEADER_H).lineTo(cx + cardW - INSET, cy + HEADER_H).stroke({ width: 1, color: t.color.textDim, alpha: 0.3 });
|
|
2825
|
+
this.title.position.set(cx + INSET, cy + HEADER_H / 2);
|
|
2826
|
+
this.closeBtn.position.set(cx + cardW - INSET - 8, cy + HEADER_H / 2);
|
|
2827
|
+
const vpX = cx + INSET;
|
|
2828
|
+
const vpY = cy + HEADER_H + INSET;
|
|
2829
|
+
const newVpW = cardW - INSET * 2;
|
|
2830
|
+
this.vpW = newVpW;
|
|
2831
|
+
this.vpH = cardH - HEADER_H - INSET * 2;
|
|
2832
|
+
this.viewport.position.set(vpX, vpY);
|
|
2833
|
+
this.maskG.clear().rect(vpX, vpY, this.vpW, this.vpH).fill({ color: 16777215 });
|
|
2834
|
+
this.catcher.clear().rect(0, 0, this.vpW, this.vpH).fill({ color: 16777215, alpha: 1e-4 });
|
|
2835
|
+
this.catcher.hitArea = new Rectangle(0, 0, this.vpW, this.vpH);
|
|
2836
|
+
this.rebuildContent();
|
|
2837
|
+
this.clampScroll();
|
|
2838
|
+
}
|
|
2839
|
+
/** Close any open select dropdown (so scrolling/closing doesn't strand it). */
|
|
2840
|
+
closeSelects() {
|
|
2841
|
+
for (const c of this.controls) {
|
|
2842
|
+
const sc = c;
|
|
2843
|
+
if (sc.isOpen && typeof sc.closeList === "function") sc.closeList();
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
onDown = (e) => {
|
|
2847
|
+
this.dragging = true;
|
|
2848
|
+
this.lastY = e.global.y;
|
|
2849
|
+
this.closeSelects();
|
|
2850
|
+
};
|
|
2851
|
+
onMove = (e) => {
|
|
2852
|
+
if (!this.dragging) return;
|
|
2853
|
+
this.scrollY += e.global.y - this.lastY;
|
|
2854
|
+
this.lastY = e.global.y;
|
|
2855
|
+
this.clampScroll();
|
|
2856
|
+
};
|
|
2857
|
+
onUp = () => {
|
|
2858
|
+
this.dragging = false;
|
|
2859
|
+
};
|
|
2860
|
+
clampScroll() {
|
|
2861
|
+
const min = Math.min(0, this.vpH - this.contentH);
|
|
2862
|
+
this.scrollY = Math.max(min, Math.min(0, this.scrollY));
|
|
2863
|
+
this.content.y = this.scrollY;
|
|
2864
|
+
}
|
|
2865
|
+
applyOpen(open) {
|
|
2866
|
+
this.visible = open;
|
|
2867
|
+
this.eventMode = open ? "static" : "none";
|
|
2868
|
+
if (open) {
|
|
2869
|
+
this.scrollY = 0;
|
|
2870
|
+
this.clampScroll();
|
|
2871
|
+
if (!this.wheelHandler && typeof window !== "undefined") {
|
|
2872
|
+
this.wheelHandler = (e) => {
|
|
2873
|
+
this.closeSelects();
|
|
2874
|
+
this.scrollY -= e.deltaY;
|
|
2875
|
+
this.clampScroll();
|
|
2876
|
+
};
|
|
2877
|
+
window.addEventListener("wheel", this.wheelHandler, { passive: true });
|
|
2878
|
+
}
|
|
2879
|
+
} else {
|
|
2880
|
+
this.closeSelects();
|
|
2881
|
+
if (this.wheelHandler && typeof window !== "undefined") {
|
|
2882
|
+
window.removeEventListener("wheel", this.wheelHandler);
|
|
2883
|
+
this.wheelHandler = void 0;
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
dispose() {
|
|
2888
|
+
if (this.wheelHandler && typeof window !== "undefined") window.removeEventListener("wheel", this.wheelHandler);
|
|
2889
|
+
for (const v of this.childViews) v.dispose();
|
|
2890
|
+
this.childViews.length = 0;
|
|
2891
|
+
super.dispose();
|
|
2892
|
+
}
|
|
2893
|
+
};
|
|
2894
|
+
var CAP_DY = -20;
|
|
2895
|
+
function fmtDuration(totalSec) {
|
|
2896
|
+
const s = Math.max(0, Math.floor(totalSec));
|
|
2897
|
+
const h = Math.floor(s / 3600);
|
|
2898
|
+
const m = Math.floor(s % 3600 / 60);
|
|
2899
|
+
const sec = String(s % 60).padStart(2, "0");
|
|
2900
|
+
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${sec}` : `${m}:${sec}`;
|
|
2901
|
+
}
|
|
2902
|
+
var ReadoutView = class extends ControlView {
|
|
2903
|
+
constructor(ro, ui, ticker, opts = {}) {
|
|
2904
|
+
super(ro, ui);
|
|
2905
|
+
this.ro = ro;
|
|
2906
|
+
this.ticker = ticker;
|
|
2907
|
+
const t = ui.theme;
|
|
2908
|
+
const inline = opts.inline ?? false;
|
|
2909
|
+
const fill = opts.mono ? "#ffffff" : t.color.text;
|
|
2910
|
+
if (ro.label) {
|
|
2911
|
+
this.caption = new Text({
|
|
2912
|
+
text: ui.t(ro.label).toUpperCase(),
|
|
2913
|
+
style: { fontFamily: t.type.family, fontSize: 12, fill, fontWeight: "700", letterSpacing: inline ? 0.8 : 2 }
|
|
2914
|
+
});
|
|
2915
|
+
this.caption.alpha = inline ? 0.65 : 0.55;
|
|
2916
|
+
if (inline) {
|
|
2917
|
+
this.caption.anchor.set(1, 0.5);
|
|
2918
|
+
this.caption.position.set(-7, 0);
|
|
2919
|
+
} else {
|
|
2920
|
+
this.caption.anchor.set(0.5, 1);
|
|
2921
|
+
this.caption.y = CAP_DY;
|
|
2922
|
+
}
|
|
2923
|
+
this.addChild(this.caption);
|
|
2924
|
+
}
|
|
2925
|
+
this.valueText = new Text({ text: "", style: { fontFamily: t.type.family, fontSize: inline ? 20 : 26, fill, fontWeight: "800" } });
|
|
2926
|
+
if (inline) {
|
|
2927
|
+
this.valueText.anchor.set(0, 0.5);
|
|
2928
|
+
this.valueText.position.set(this.caption ? 7 : 0, 0);
|
|
2929
|
+
} else {
|
|
2930
|
+
this.valueText.anchor.set(0.5, 0.5);
|
|
2931
|
+
}
|
|
2932
|
+
this.addChild(this.valueText);
|
|
2933
|
+
this.disposers.push(
|
|
2934
|
+
this.ro.value.subscribe(() => this.render()),
|
|
2935
|
+
this.ui.locale.subscribe(() => {
|
|
2936
|
+
if (this.destroyed) return;
|
|
2937
|
+
if (this.caption && this.ro.label) this.caption.text = this.ui.t(this.ro.label).toUpperCase();
|
|
2938
|
+
})
|
|
2939
|
+
);
|
|
2940
|
+
if (this.ro.currency) this.disposers.push(this.ro.currency.subscribe(() => this.render()));
|
|
2941
|
+
if (this.ro.kind === "duration") {
|
|
2942
|
+
this.tick = (tk) => this.ro.tick(tk.deltaMS / 1e3);
|
|
2943
|
+
this.ticker.add(this.tick);
|
|
2944
|
+
}
|
|
2945
|
+
this.render();
|
|
2946
|
+
}
|
|
2947
|
+
ro;
|
|
2948
|
+
ticker;
|
|
2949
|
+
caption;
|
|
2950
|
+
valueText;
|
|
2951
|
+
tick;
|
|
2952
|
+
render() {
|
|
2953
|
+
const v = this.ro.value.get();
|
|
2954
|
+
let text;
|
|
2955
|
+
switch (this.ro.kind) {
|
|
2956
|
+
case "currency":
|
|
2957
|
+
text = this.ro.currency ? formatAmount(v, this.ro.currency.get(), { signed: this.ro.signed }) : String(v);
|
|
2958
|
+
break;
|
|
2959
|
+
case "percent":
|
|
2960
|
+
text = `${v.toFixed(this.ro.decimals)}%`;
|
|
2961
|
+
break;
|
|
2962
|
+
case "duration":
|
|
2963
|
+
text = fmtDuration(v);
|
|
2964
|
+
break;
|
|
2965
|
+
default:
|
|
2966
|
+
text = String(v);
|
|
2967
|
+
}
|
|
2968
|
+
this.valueText.text = text;
|
|
2969
|
+
}
|
|
2970
|
+
dispose() {
|
|
2971
|
+
if (this.tick) this.ticker.remove(this.tick);
|
|
2972
|
+
super.dispose();
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2975
|
+
var INSET2 = 24;
|
|
2976
|
+
var BTN_H = 50;
|
|
2977
|
+
var BTN_GAP = 12;
|
|
2978
|
+
var ROW_GAP = 16;
|
|
2979
|
+
var DialogView = class extends ControlView {
|
|
2980
|
+
constructor(panel, blocks, actions, ui, ticker, opts = {}) {
|
|
2981
|
+
super(panel, ui);
|
|
2982
|
+
this.panel = panel;
|
|
2983
|
+
this.blocks = blocks;
|
|
2984
|
+
this.actions = actions;
|
|
2985
|
+
this.ticker = ticker;
|
|
2986
|
+
this.opts = opts;
|
|
2987
|
+
this.zIndex = 130;
|
|
2988
|
+
this.maxWidth = opts.maxWidth ?? 520;
|
|
2989
|
+
this.backdrop.eventMode = "static";
|
|
2990
|
+
this.backdrop.on("pointertap", () => {
|
|
2991
|
+
if (!this.ui.noticeBlocking.get()) this.panel.closePanel();
|
|
2992
|
+
});
|
|
2993
|
+
this.buildClose();
|
|
2994
|
+
this.content.mask = this.maskG;
|
|
2995
|
+
this.addChild(this.backdrop, this.card, this.content, this.maskG, this.buttons, this.closeBtn);
|
|
2996
|
+
this.applyOpen(this.panel.isOpen);
|
|
2997
|
+
this.disposers.push(
|
|
2998
|
+
this.panel.state.subscribe(() => this.applyOpen(this.panel.isOpen)),
|
|
2999
|
+
// hide the ✕ when the open notice is blocking (re-renders on toggle)
|
|
3000
|
+
this.ui.noticeBlocking.subscribe(() => {
|
|
3001
|
+
this.closeBtn.visible = !this.ui.noticeBlocking.get();
|
|
3002
|
+
}),
|
|
3003
|
+
this.blocks.subscribe(() => {
|
|
3004
|
+
if (!this.destroyed) this.relayout();
|
|
3005
|
+
}),
|
|
3006
|
+
this.actions.subscribe(() => {
|
|
3007
|
+
if (!this.destroyed) this.relayout();
|
|
3008
|
+
}),
|
|
3009
|
+
this.ui.locale.subscribe(() => {
|
|
3010
|
+
if (!this.destroyed) this.relayout();
|
|
3011
|
+
})
|
|
3012
|
+
);
|
|
3013
|
+
}
|
|
3014
|
+
panel;
|
|
3015
|
+
blocks;
|
|
3016
|
+
actions;
|
|
3017
|
+
ticker;
|
|
3018
|
+
opts;
|
|
3019
|
+
backdrop = new Graphics();
|
|
3020
|
+
card = new Graphics();
|
|
3021
|
+
closeBtn = new Container();
|
|
3022
|
+
content = new Container();
|
|
3023
|
+
maskG = new Graphics();
|
|
3024
|
+
buttons = new Container();
|
|
3025
|
+
childViews = [];
|
|
3026
|
+
screen;
|
|
3027
|
+
maxWidth;
|
|
3028
|
+
buildClose() {
|
|
3029
|
+
const t = this.ui.theme;
|
|
3030
|
+
const r = 18;
|
|
3031
|
+
const bg = new Graphics().circle(0, 0, r).fill({ color: t.color.surfaceAlt }).stroke({ width: 2, color: t.color.textDim });
|
|
3032
|
+
const x = new Graphics().moveTo(-6, -6).lineTo(6, 6).moveTo(6, -6).lineTo(-6, 6).stroke({ width: 3, color: t.color.text });
|
|
3033
|
+
this.closeBtn.addChild(bg, x);
|
|
3034
|
+
this.closeBtn.eventMode = "static";
|
|
3035
|
+
this.closeBtn.cursor = "pointer";
|
|
3036
|
+
this.closeBtn.hitArea = new Rectangle(-r, -r, r * 2, r * 2);
|
|
3037
|
+
this.closeBtn.on("pointertap", () => this.panel.closePanel());
|
|
3038
|
+
}
|
|
3039
|
+
applyLayout(screen) {
|
|
3040
|
+
this.screen = screen;
|
|
3041
|
+
this.position.set(0, 0);
|
|
3042
|
+
this.scale.set(1);
|
|
3043
|
+
this.relayout();
|
|
3044
|
+
}
|
|
3045
|
+
relayout() {
|
|
3046
|
+
const s = this.screen;
|
|
3047
|
+
if (!s) return;
|
|
3048
|
+
if (!this.panel.isOpen) return;
|
|
3049
|
+
const W = s.width;
|
|
3050
|
+
const H = s.height;
|
|
3051
|
+
const t = this.ui.theme;
|
|
3052
|
+
for (const v of this.childViews) v.dispose();
|
|
3053
|
+
this.childViews.length = 0;
|
|
3054
|
+
for (const ch of this.content.removeChildren()) ch.destroy();
|
|
3055
|
+
const cardW = Math.min(W - 48, this.maxWidth);
|
|
3056
|
+
const innerW = cardW - INSET2 * 2;
|
|
3057
|
+
const col = buildBlockColumn(this.blocks.get(), [], this.ui, this.ticker, innerW, { controlSkins: this.opts.controlSkins });
|
|
3058
|
+
this.childViews = col.views;
|
|
3059
|
+
const kids = col.content.removeChildren();
|
|
3060
|
+
if (kids.length) this.content.addChild(...kids);
|
|
3061
|
+
const contentH = col.height;
|
|
3062
|
+
const buttonsH = this.buildButtons(innerW);
|
|
3063
|
+
const wantH = contentH + (buttonsH ? ROW_GAP + buttonsH + INSET2 : INSET2);
|
|
3064
|
+
const cardH = Math.min(H - 48, wantH);
|
|
3065
|
+
const cx = (W - cardW) / 2;
|
|
3066
|
+
const cy = (H - cardH) / 2;
|
|
3067
|
+
this.backdrop.clear().rect(0, 0, W, H).fill({ color: 0, alpha: 0.62 });
|
|
3068
|
+
this.backdrop.hitArea = new Rectangle(0, 0, W, H);
|
|
3069
|
+
this.card.clear().roundRect(cx, cy, cardW, cardH, t.radius.card).fill({ color: t.color.surface }).stroke({ width: 2, color: t.color.accent });
|
|
3070
|
+
const bodyH = cardH - (buttonsH ? ROW_GAP + buttonsH + INSET2 : INSET2);
|
|
3071
|
+
this.content.x = cx + cardW / 2;
|
|
3072
|
+
this.content.y = cy;
|
|
3073
|
+
this.maskG.clear().rect(cx, cy, cardW, Math.max(0, bodyH)).fill({ color: 16777215 });
|
|
3074
|
+
this.buttons.position.set(cx + cardW / 2, cy + cardH - INSET2 / 2 - buttonsH / 2);
|
|
3075
|
+
this.closeBtn.position.set(cx + cardW - 20, cy + 20);
|
|
3076
|
+
}
|
|
3077
|
+
/** Build the footer buttons from `noticeActions` into a centered row (shrunk to
|
|
3078
|
+
* fit if needed). Returns the row height (0 when there are no actions). */
|
|
3079
|
+
buildButtons(innerW) {
|
|
3080
|
+
for (const b of this.buttons.removeChildren()) b.destroy();
|
|
3081
|
+
const acts = this.ui.noticeActions.get();
|
|
3082
|
+
if (!acts.length) return 0;
|
|
3083
|
+
const made = acts.map((a, i) => this.makeButton(a, a.variant ?? (i === 0 ? "primary" : "secondary"), innerW));
|
|
3084
|
+
let total = made.reduce((sum, m) => sum + m.width, 0) + BTN_GAP * (made.length - 1);
|
|
3085
|
+
if (total > innerW) {
|
|
3086
|
+
const scale = innerW / total;
|
|
3087
|
+
for (const m of made) {
|
|
3088
|
+
m.width *= scale;
|
|
3089
|
+
this.drawButton(m.bg, m.variant, m.width);
|
|
3090
|
+
m.node.hitArea = new Rectangle(-m.width / 2, -BTN_H / 2, m.width, BTN_H);
|
|
3091
|
+
}
|
|
3092
|
+
total = made.reduce((sum, m) => sum + m.width, 0) + BTN_GAP * (made.length - 1);
|
|
3093
|
+
}
|
|
3094
|
+
let x = -total / 2;
|
|
3095
|
+
for (const m of made) {
|
|
3096
|
+
m.node.position.set(x + m.width / 2, 0);
|
|
3097
|
+
x += m.width + BTN_GAP;
|
|
3098
|
+
this.buttons.addChild(m.node);
|
|
3099
|
+
}
|
|
3100
|
+
return BTN_H;
|
|
3101
|
+
}
|
|
3102
|
+
makeButton(action, variant, innerW) {
|
|
3103
|
+
const t = this.ui.theme;
|
|
3104
|
+
const node = new Container();
|
|
3105
|
+
const bg = new Graphics();
|
|
3106
|
+
const label = new Text({
|
|
3107
|
+
text: this.ui.t(action.label),
|
|
3108
|
+
style: { fontFamily: t.type.family, fontSize: 18, fontWeight: "800", fill: variant === "primary" ? t.color.accentText : t.color.text, letterSpacing: 0.5 }
|
|
3109
|
+
});
|
|
3110
|
+
label.anchor.set(0.5);
|
|
3111
|
+
node.addChild(bg, label);
|
|
3112
|
+
const width = Math.min(innerW, Math.max(140, label.width + 56));
|
|
3113
|
+
this.drawButton(bg, variant, width);
|
|
3114
|
+
node.eventMode = "static";
|
|
3115
|
+
node.cursor = "pointer";
|
|
3116
|
+
node.hitArea = new Rectangle(-width / 2, -BTN_H / 2, width, BTN_H);
|
|
3117
|
+
node.on("pointertap", () => {
|
|
3118
|
+
action.onSelect?.();
|
|
3119
|
+
if (action.emit) this.ui.bus.emit("buttonActivated", { id: action.emit });
|
|
3120
|
+
if (!action.keepOpen) this.panel.closePanel();
|
|
3121
|
+
});
|
|
3122
|
+
return { node, bg, width, variant };
|
|
3123
|
+
}
|
|
3124
|
+
drawButton(bg, variant, width) {
|
|
3125
|
+
const t = this.ui.theme;
|
|
3126
|
+
bg.clear();
|
|
3127
|
+
if (variant === "primary") {
|
|
3128
|
+
bg.roundRect(-width / 2, -BTN_H / 2, width, BTN_H, BTN_H / 2).fill({ color: t.color.accent });
|
|
3129
|
+
} else {
|
|
3130
|
+
bg.roundRect(-width / 2, -BTN_H / 2, width, BTN_H, BTN_H / 2).fill({ color: t.color.surfaceAlt }).stroke({ width: 2, color: t.color.accent });
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
applyOpen(open) {
|
|
3134
|
+
this.visible = open;
|
|
3135
|
+
this.eventMode = open ? "static" : "none";
|
|
3136
|
+
this.closeBtn.visible = !this.ui.noticeBlocking.get();
|
|
3137
|
+
if (open) this.relayout();
|
|
3138
|
+
}
|
|
3139
|
+
dispose() {
|
|
3140
|
+
for (const v of this.childViews) v.dispose();
|
|
3141
|
+
this.childViews.length = 0;
|
|
3142
|
+
super.dispose();
|
|
3143
|
+
}
|
|
3144
|
+
};
|
|
3145
|
+
var BAR_H = 26;
|
|
3146
|
+
var StatusBarView = class _StatusBarView extends Container {
|
|
3147
|
+
constructor(controls, ui, ticker, side) {
|
|
3148
|
+
super();
|
|
3149
|
+
this.ui = ui;
|
|
3150
|
+
this.side = side;
|
|
3151
|
+
this.zIndex = 300;
|
|
3152
|
+
this.addChild(this.bg);
|
|
3153
|
+
for (const c of controls) {
|
|
3154
|
+
const view = new ReadoutView(c, ui, ticker, { inline: true, mono: true });
|
|
3155
|
+
this.addChild(view);
|
|
3156
|
+
this.items.push({ id: c.id, view });
|
|
3157
|
+
}
|
|
3158
|
+
this.disposers.push(
|
|
3159
|
+
this.ui.on("visibilityChanged", ({ id }) => {
|
|
3160
|
+
if (this.items.some((it) => it.id === id)) this.relayout();
|
|
3161
|
+
})
|
|
3162
|
+
);
|
|
3163
|
+
}
|
|
3164
|
+
ui;
|
|
3165
|
+
side;
|
|
3166
|
+
bg = new Graphics();
|
|
3167
|
+
items = [];
|
|
3168
|
+
screen;
|
|
3169
|
+
disposers = [];
|
|
3170
|
+
/** The strip's pixel height for the current screen (used for the HUD margin too). */
|
|
3171
|
+
static heightFor(screen) {
|
|
3172
|
+
const scale = Math.max(0.7, Math.min(1.4, screen.scale));
|
|
3173
|
+
return Math.round(BAR_H * scale);
|
|
3174
|
+
}
|
|
3175
|
+
applyLayout(screen) {
|
|
3176
|
+
this.screen = screen;
|
|
3177
|
+
this.relayout();
|
|
3178
|
+
}
|
|
3179
|
+
relayout() {
|
|
3180
|
+
const s = this.screen;
|
|
3181
|
+
if (!s) return;
|
|
3182
|
+
const W = s.width;
|
|
3183
|
+
const H = s.height;
|
|
3184
|
+
const scale = Math.max(0.7, Math.min(1.4, s.scale));
|
|
3185
|
+
const barH = _StatusBarView.heightFor(s);
|
|
3186
|
+
const y = this.side === "top" ? 0 : H - barH;
|
|
3187
|
+
this.position.set(0, 0);
|
|
3188
|
+
const visible = this.items.filter((it) => !this.ui.hidden.has(it.id));
|
|
3189
|
+
for (const it of this.items) it.view.visible = !this.ui.hidden.has(it.id);
|
|
3190
|
+
this.bg.clear();
|
|
3191
|
+
this.visible = visible.length > 0;
|
|
3192
|
+
if (!visible.length) return;
|
|
3193
|
+
const edgeY = this.side === "top" ? barH - 1 : y;
|
|
3194
|
+
this.bg.rect(0, y, W, barH).fill({ color: 789776, alpha: 0.92 }).rect(0, edgeY, W, 1).fill({ color: 16777215, alpha: 0.18 });
|
|
3195
|
+
const n = visible.length;
|
|
3196
|
+
const cy = y + barH / 2;
|
|
3197
|
+
const pad = 18 * scale;
|
|
3198
|
+
const usableW = Math.max(160, W - pad * 2);
|
|
3199
|
+
visible.forEach((it, i) => {
|
|
3200
|
+
it.view.position.set(pad + usableW * ((i + 0.5) / n), cy);
|
|
3201
|
+
it.view.scale.set(scale);
|
|
3202
|
+
});
|
|
3203
|
+
}
|
|
3204
|
+
dispose() {
|
|
3205
|
+
for (const it of this.items) it.view.dispose();
|
|
3206
|
+
this.items.length = 0;
|
|
3207
|
+
for (const d of this.disposers) d();
|
|
3208
|
+
this.disposers.length = 0;
|
|
3209
|
+
if (!this.destroyed) this.destroy({ children: true });
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
3212
|
+
|
|
3213
|
+
// src/OpenUIPixi.ts
|
|
3214
|
+
function easeInOutCubic(p) {
|
|
3215
|
+
return p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
|
|
3216
|
+
}
|
|
3217
|
+
var OpenUIPixi = class {
|
|
3218
|
+
constructor(ui, opts = {}) {
|
|
3219
|
+
this.ui = ui;
|
|
3220
|
+
this.opts = opts;
|
|
3221
|
+
}
|
|
3222
|
+
ui;
|
|
3223
|
+
opts;
|
|
3224
|
+
root = new Container();
|
|
3225
|
+
views = [];
|
|
3226
|
+
/** Full-screen overlays (e.g. the autoplay drawer) that own their own layout. */
|
|
3227
|
+
overlays = [];
|
|
3228
|
+
disposers = [];
|
|
3229
|
+
_eventLog;
|
|
3230
|
+
/** Show/hide slide: each interactive view slides toward its anchored edge (bottom
|
|
3231
|
+
* controls down, top up — behind the status-bar plaque). Views stay direct children
|
|
3232
|
+
* of `root` (introspection bounds unchanged); only their y moves, and the
|
|
3233
|
+
* ref-counted input lock makes them non-interactive while moving/hidden. */
|
|
3234
|
+
slideProg = 0;
|
|
3235
|
+
// 0 = shown · 1 = fully hidden (set per `intro` on mount)
|
|
3236
|
+
slideTarget = 1;
|
|
3237
|
+
slideHeld = false;
|
|
3238
|
+
lastScreenH = 1080;
|
|
3239
|
+
appTicker;
|
|
3240
|
+
slideTickFn;
|
|
3241
|
+
slideBaseY = /* @__PURE__ */ new Map();
|
|
3242
|
+
slideSign = /* @__PURE__ */ new Map();
|
|
3243
|
+
/** The bus event log backing `window.__OPENUI__.events` (available after mount). */
|
|
3244
|
+
get eventLog() {
|
|
3245
|
+
return this._eventLog;
|
|
3246
|
+
}
|
|
3247
|
+
mount(app) {
|
|
3248
|
+
const { stage, renderer, ticker } = app;
|
|
3249
|
+
this.appTicker = ticker;
|
|
3250
|
+
stage.sortableChildren = true;
|
|
3251
|
+
this.root.zIndex = 1e4;
|
|
3252
|
+
this.root.sortableChildren = true;
|
|
3253
|
+
stage.addChild(this.root);
|
|
3254
|
+
const ic = this.opts.icons ?? {};
|
|
3255
|
+
const spinView = new SpinView(this.ui.spin, this.ui, ticker, this.opts.spinSkin);
|
|
3256
|
+
const balanceView = new ValueDisplayView(this.ui.balance, this.ui, ticker, this.opts.gsap);
|
|
3257
|
+
const betView = new ValueDisplayView(this.ui.bet, this.ui, ticker, this.opts.gsap);
|
|
3258
|
+
const settingsView = new ButtonView(this.ui.settingsButton, this.ui, ticker, {
|
|
3259
|
+
shape: "circle",
|
|
3260
|
+
radius: 40,
|
|
3261
|
+
glyph: "menu",
|
|
3262
|
+
iconTexture: ic.settingsIdle,
|
|
3263
|
+
iconTarget: 88,
|
|
3264
|
+
mono: true
|
|
3265
|
+
// b&w like the turbo button (used on the drawn glyph path)
|
|
3266
|
+
});
|
|
3267
|
+
settingsView.zIndex = 5;
|
|
3268
|
+
const menuView = this.opts.menu === false ? void 0 : this.buildMenu(ticker);
|
|
3269
|
+
const turboView = new TurboView(this.ui.turbo, this.ui, ticker, {
|
|
3270
|
+
offTexture: ic.turboOff,
|
|
3271
|
+
onTexture: ic.turboOn,
|
|
3272
|
+
modeTextures: ic.turboModes,
|
|
3273
|
+
target: 88
|
|
3274
|
+
});
|
|
3275
|
+
const spinOff = this.ui.spin.layout.offset ?? [0, 0];
|
|
3276
|
+
const autoOff = this.ui.autoplay.layout.offset ?? [0, 0];
|
|
3277
|
+
const picker = this.opts.autoplayPicker ?? "drawer";
|
|
3278
|
+
const autoplayView = new AutoplayView(this.ui.autoplay, this.ui, ticker, {
|
|
3279
|
+
idleTexture: ic.autoIdle,
|
|
3280
|
+
activeTexture: ic.autoActive,
|
|
3281
|
+
target: 88,
|
|
3282
|
+
picker,
|
|
3283
|
+
arcCenter: { x: spinOff[0] - autoOff[0], y: spinOff[1] - autoOff[1] },
|
|
3284
|
+
arcStepDeg: 22
|
|
3285
|
+
});
|
|
3286
|
+
autoplayView.zIndex = 20;
|
|
3287
|
+
const bonusView = new ButtonView(this.ui.bonusButton, this.ui, ticker, { shape: "circle", radius: 44, iconTexture: ic.bonus, iconTarget: 110 });
|
|
3288
|
+
const betPlusView = new ButtonView(this.ui.betPlus, this.ui, ticker, { shape: "circle", radius: 30, iconTexture: ic.betPlus, iconTarget: 64 });
|
|
3289
|
+
const betMinusView = new ButtonView(this.ui.betMinus, this.ui, ticker, { shape: "circle", radius: 30, iconTexture: ic.betMinus, iconTarget: 64 });
|
|
3290
|
+
const muteView = new ButtonView(this.ui.muteButton, this.ui, ticker, { shape: "circle", radius: 22, glyph: "speaker", iconTarget: 44, mono: true });
|
|
3291
|
+
const fullscreenView = new ButtonView(this.ui.fullscreenButton, this.ui, ticker, { shape: "circle", radius: 22, glyph: "fullscreen", iconTarget: 44, mono: true });
|
|
3292
|
+
muteView.zIndex = 65;
|
|
3293
|
+
fullscreenView.zIndex = 65;
|
|
3294
|
+
const statusBarSide = this.opts.statusBar;
|
|
3295
|
+
const rtpView = statusBarSide ? void 0 : new ReadoutView(this.ui.rtp, this.ui, ticker);
|
|
3296
|
+
const netView = statusBarSide ? void 0 : new ReadoutView(this.ui.netPosition, this.ui, ticker);
|
|
3297
|
+
const timerView = statusBarSide ? void 0 : new ReadoutView(this.ui.sessionTimer, this.ui, ticker);
|
|
3298
|
+
const entries = [
|
|
3299
|
+
[this.ui.spin.id, spinView],
|
|
3300
|
+
[this.ui.balance.id, balanceView],
|
|
3301
|
+
[this.ui.bet.id, betView],
|
|
3302
|
+
[this.ui.settingsButton.id, settingsView],
|
|
3303
|
+
[this.ui.turbo.id, turboView],
|
|
3304
|
+
[this.ui.autoplay.id, autoplayView],
|
|
3305
|
+
[this.ui.bonusButton.id, bonusView],
|
|
3306
|
+
[this.ui.betPlus.id, betPlusView],
|
|
3307
|
+
[this.ui.betMinus.id, betMinusView],
|
|
3308
|
+
[this.ui.muteButton.id, muteView],
|
|
3309
|
+
[this.ui.fullscreenButton.id, fullscreenView]
|
|
3310
|
+
];
|
|
3311
|
+
if (rtpView) entries.push([this.ui.rtp.id, rtpView]);
|
|
3312
|
+
if (netView) entries.push([this.ui.netPosition.id, netView]);
|
|
3313
|
+
if (timerView) entries.push([this.ui.sessionTimer.id, timerView]);
|
|
3314
|
+
const viewById = /* @__PURE__ */ new Map();
|
|
3315
|
+
const idByView = /* @__PURE__ */ new Map();
|
|
3316
|
+
for (const [id, view] of entries) {
|
|
3317
|
+
view.visible = !this.ui.hidden.has(id);
|
|
3318
|
+
this.root.addChild(view);
|
|
3319
|
+
this.views.push(view);
|
|
3320
|
+
viewById.set(id, view);
|
|
3321
|
+
idByView.set(view, id);
|
|
3322
|
+
}
|
|
3323
|
+
this.disposers.push(
|
|
3324
|
+
this.ui.on("visibilityChanged", ({ id, hidden }) => {
|
|
3325
|
+
const v = viewById.get(id);
|
|
3326
|
+
if (v) v.visible = !hidden;
|
|
3327
|
+
})
|
|
3328
|
+
);
|
|
3329
|
+
this.disposers.push(this.ui.muted.subscribe((m) => muteView.setGlyph(m ? "speaker-mute" : "speaker")));
|
|
3330
|
+
if (typeof document !== "undefined") {
|
|
3331
|
+
this.disposers.push(
|
|
3332
|
+
this.ui.bus.on("buttonActivated", ({ id }) => {
|
|
3333
|
+
if (id !== "fullscreen") return;
|
|
3334
|
+
const el = app.canvas.parentElement ?? document.documentElement;
|
|
3335
|
+
if (document.fullscreenElement) void document.exitFullscreen?.();
|
|
3336
|
+
else void el.requestFullscreen?.();
|
|
3337
|
+
})
|
|
3338
|
+
);
|
|
3339
|
+
const onFsChange = () => fullscreenView.setGlyph(document.fullscreenElement ? "fullscreen-exit" : "fullscreen");
|
|
3340
|
+
document.addEventListener("fullscreenchange", onFsChange);
|
|
3341
|
+
this.disposers.push(() => document.removeEventListener("fullscreenchange", onFsChange));
|
|
3342
|
+
}
|
|
3343
|
+
if (typeof window !== "undefined") {
|
|
3344
|
+
let keyHeld = false;
|
|
3345
|
+
const onKeyDown = (e) => {
|
|
3346
|
+
if (e.code !== "Space" && e.key !== "Enter") return;
|
|
3347
|
+
if (!this.ui.spin.allowKeyboard.get() || e.repeat || keyHeld) return;
|
|
3348
|
+
keyHeld = true;
|
|
3349
|
+
e.preventDefault();
|
|
3350
|
+
if (this.ui.spin.interactable) this.ui.spin.activate();
|
|
3351
|
+
};
|
|
3352
|
+
const onKeyUp = (e) => {
|
|
3353
|
+
if (e.code === "Space" || e.key === "Enter") keyHeld = false;
|
|
3354
|
+
};
|
|
3355
|
+
window.addEventListener("keydown", onKeyDown);
|
|
3356
|
+
window.addEventListener("keyup", onKeyUp);
|
|
3357
|
+
this.disposers.push(() => {
|
|
3358
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
3359
|
+
window.removeEventListener("keyup", onKeyUp);
|
|
3360
|
+
});
|
|
3361
|
+
}
|
|
3362
|
+
if (menuView) {
|
|
3363
|
+
this.root.addChild(menuView);
|
|
3364
|
+
this.overlays.push(menuView);
|
|
3365
|
+
}
|
|
3366
|
+
if (picker === "drawer") {
|
|
3367
|
+
const drawer = new AutoplayDrawerView(this.ui.autoplay, this.ui, ticker);
|
|
3368
|
+
this.root.addChild(drawer);
|
|
3369
|
+
this.overlays.push(drawer);
|
|
3370
|
+
}
|
|
3371
|
+
const dialog = new DialogView(this.ui.noticePanel, this.ui.noticeBlocks, this.ui.noticeActions, this.ui, ticker, { controlSkins: this.opts.controlSkins });
|
|
3372
|
+
this.root.addChild(dialog);
|
|
3373
|
+
this.overlays.push(dialog);
|
|
3374
|
+
if (statusBarSide) {
|
|
3375
|
+
const bar = new StatusBarView([this.ui.netPosition, this.ui.rtp, this.ui.sessionTimer], this.ui, ticker, statusBarSide);
|
|
3376
|
+
this.root.addChild(bar);
|
|
3377
|
+
this.overlays.push(bar);
|
|
3378
|
+
}
|
|
3379
|
+
const replayBadge = new Container();
|
|
3380
|
+
const replayBg = new Graphics();
|
|
3381
|
+
const replayText = new Text({ text: this.ui.t("openui.replay").toUpperCase(), style: { fontFamily: this.ui.theme.type.family, fontSize: 16, fontWeight: "800", fill: 16777215, letterSpacing: 2 } });
|
|
3382
|
+
replayText.anchor.set(0.5);
|
|
3383
|
+
replayBadge.addChild(replayBg, replayText);
|
|
3384
|
+
replayBadge.zIndex = 310;
|
|
3385
|
+
replayBadge.visible = this.ui.replay.get();
|
|
3386
|
+
this.root.addChild(replayBadge);
|
|
3387
|
+
this.overlays.push({
|
|
3388
|
+
applyLayout: (s) => {
|
|
3389
|
+
const w = replayText.width + 36;
|
|
3390
|
+
const h = 32;
|
|
3391
|
+
replayBg.clear().roundRect(-w / 2, -h / 2, w, h, h / 2).fill({ color: 789776 }).stroke({ width: 2, color: 16777215 });
|
|
3392
|
+
const top = statusBarSide === "top" ? StatusBarView.heightFor(s) + 28 : 40;
|
|
3393
|
+
replayBadge.position.set(s.width / 2, top);
|
|
3394
|
+
},
|
|
3395
|
+
dispose: () => {
|
|
3396
|
+
if (!replayBadge.destroyed) replayBadge.destroy({ children: true });
|
|
3397
|
+
}
|
|
3398
|
+
});
|
|
3399
|
+
this.disposers.push(
|
|
3400
|
+
this.ui.replay.subscribe((v) => {
|
|
3401
|
+
replayBadge.visible = v;
|
|
3402
|
+
}),
|
|
3403
|
+
this.ui.locale.subscribe(() => {
|
|
3404
|
+
if (!replayBadge.destroyed) replayText.text = this.ui.t("openui.replay").toUpperCase();
|
|
3405
|
+
})
|
|
3406
|
+
);
|
|
3407
|
+
if (ic.settingsIdle && ic.settingsActive) {
|
|
3408
|
+
const idle = ic.settingsIdle;
|
|
3409
|
+
const active = ic.settingsActive;
|
|
3410
|
+
this.disposers.push(
|
|
3411
|
+
this.ui.settingsPanel.state.subscribe(() => {
|
|
3412
|
+
settingsView.setIconTexture(this.ui.settingsPanel.isOpen ? active : idle);
|
|
3413
|
+
})
|
|
3414
|
+
);
|
|
3415
|
+
} else {
|
|
3416
|
+
this.disposers.push(
|
|
3417
|
+
this.ui.settingsPanel.state.subscribe(() => {
|
|
3418
|
+
settingsView.setGlyph(this.ui.settingsPanel.isOpen ? "close" : "menu");
|
|
3419
|
+
})
|
|
3420
|
+
);
|
|
3421
|
+
}
|
|
3422
|
+
const applyLayout = () => {
|
|
3423
|
+
const screen = this.ui.screen.get();
|
|
3424
|
+
const barH = statusBarSide ? StatusBarView.heightFor(screen) : 0;
|
|
3425
|
+
this.slideBaseY.clear();
|
|
3426
|
+
this.slideSign.clear();
|
|
3427
|
+
for (const v of this.views) {
|
|
3428
|
+
v.applyLayout(screen);
|
|
3429
|
+
const anchor = this.ui.control(idByView.get(v) ?? "")?.layout.anchor ?? "bottom-center";
|
|
3430
|
+
if (barH) {
|
|
3431
|
+
if (statusBarSide === "top" && anchor.startsWith("top")) v.y += barH;
|
|
3432
|
+
else if (statusBarSide === "bottom" && anchor.startsWith("bottom")) v.y -= barH;
|
|
3433
|
+
}
|
|
3434
|
+
this.slideBaseY.set(v, v.y);
|
|
3435
|
+
this.slideSign.set(v, anchor.startsWith("top") ? -1 : 1);
|
|
3436
|
+
}
|
|
3437
|
+
this.lastScreenH = screen.height;
|
|
3438
|
+
this.applySlide();
|
|
3439
|
+
for (const o of this.overlays) o.applyLayout(screen);
|
|
3440
|
+
};
|
|
3441
|
+
const onResize = () => {
|
|
3442
|
+
this.ui.setScreen(app.screen.width, app.screen.height);
|
|
3443
|
+
};
|
|
3444
|
+
renderer.on("resize", onResize);
|
|
3445
|
+
const unsubScreen = this.ui.screen.subscribe(applyLayout);
|
|
3446
|
+
onResize();
|
|
3447
|
+
applyLayout();
|
|
3448
|
+
const intro = this.opts.intro ?? "shown";
|
|
3449
|
+
if (intro === "shown") {
|
|
3450
|
+
this.slideProg = 0;
|
|
3451
|
+
this.applySlide();
|
|
3452
|
+
} else {
|
|
3453
|
+
this.slideProg = 1;
|
|
3454
|
+
this.applySlide();
|
|
3455
|
+
this.ui.lock();
|
|
3456
|
+
this.slideHeld = true;
|
|
3457
|
+
if (intro === "slide-in") this.setControlsVisible(true);
|
|
3458
|
+
}
|
|
3459
|
+
this.disposers.push(() => renderer.off("resize", onResize), unsubScreen);
|
|
3460
|
+
this._eventLog = new EventLog(this.ui.bus);
|
|
3461
|
+
if (this.opts.expose ?? true) this.expose();
|
|
3462
|
+
}
|
|
3463
|
+
/**
|
|
3464
|
+
* Build the unified scrollable MENU bound to the ☰ panel. Composed `menu` blocks
|
|
3465
|
+
* are given by `mountHud`; absent → a default Settings-only menu. Built-in ids
|
|
3466
|
+
* ('music'/'sfx') are reused, not shadowed (P10); button blocks wire `closePanel`.
|
|
3467
|
+
*/
|
|
3468
|
+
buildMenu(ticker) {
|
|
3469
|
+
const menu = this.opts.menu && this.opts.menu.length ? this.opts.menu : composeMenu(void 0, {});
|
|
3470
|
+
const controls = buildBlocks(menu, this.ui.bus, void 0, (id) => this.ui.control(id));
|
|
3471
|
+
for (const c of controls) if (!this.ui.control(c.id)) this.ui.register(c);
|
|
3472
|
+
const buttons = buttonBlocks(menu);
|
|
3473
|
+
this.disposers.push(
|
|
3474
|
+
this.ui.bus.on("buttonActivated", ({ id }) => {
|
|
3475
|
+
const b = buttons.find((x) => x.id === id);
|
|
3476
|
+
if (b?.action === "closePanel") this.ui.settingsPanel.closePanel();
|
|
3477
|
+
})
|
|
3478
|
+
);
|
|
3479
|
+
return new MenuView(this.ui.settingsPanel, controls, menu, this.ui, ticker, {
|
|
3480
|
+
controlSkins: this.opts.controlSkins,
|
|
3481
|
+
title: this.opts.menuTitle
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* Slide the whole interactive HUD in (`true`) or out (`false`): bottom-anchored
|
|
3486
|
+
* controls travel down, top-anchored travel up (behind the status-bar plaque).
|
|
3487
|
+
* Pure translation (no scaling); controls are non-interactive while moving/hidden.
|
|
3488
|
+
*/
|
|
3489
|
+
setControlsVisible(visible) {
|
|
3490
|
+
const target = visible ? 0 : 1;
|
|
3491
|
+
this.slideTarget = target;
|
|
3492
|
+
if (!this.slideHeld) {
|
|
3493
|
+
this.ui.lock();
|
|
3494
|
+
this.slideHeld = true;
|
|
3495
|
+
}
|
|
3496
|
+
const settle = () => {
|
|
3497
|
+
if (this.slideProg === 0 && this.slideHeld) {
|
|
3498
|
+
this.ui.unlock();
|
|
3499
|
+
this.slideHeld = false;
|
|
3500
|
+
}
|
|
3501
|
+
};
|
|
3502
|
+
if (!this.appTicker) {
|
|
3503
|
+
this.slideProg = target;
|
|
3504
|
+
this.applySlide();
|
|
3505
|
+
settle();
|
|
3506
|
+
return;
|
|
3507
|
+
}
|
|
3508
|
+
const from = this.slideProg;
|
|
3509
|
+
const startMs = typeof performance !== "undefined" ? performance.now() : 0;
|
|
3510
|
+
if (this.slideTickFn) this.appTicker.remove(this.slideTickFn);
|
|
3511
|
+
const tick = () => {
|
|
3512
|
+
const nowMs = typeof performance !== "undefined" ? performance.now() : startMs + 360;
|
|
3513
|
+
const k = Math.min(1, (nowMs - startMs) / 360);
|
|
3514
|
+
this.slideProg = from + (target - from) * k;
|
|
3515
|
+
if (k >= 1) {
|
|
3516
|
+
this.slideProg = target;
|
|
3517
|
+
this.appTicker?.remove(tick);
|
|
3518
|
+
this.slideTickFn = void 0;
|
|
3519
|
+
settle();
|
|
3520
|
+
}
|
|
3521
|
+
this.applySlide();
|
|
3522
|
+
};
|
|
3523
|
+
this.slideTickFn = tick;
|
|
3524
|
+
this.appTicker.add(tick);
|
|
3525
|
+
}
|
|
3526
|
+
/** Apply the current slide progress: translate each interactive view toward its
|
|
3527
|
+
* anchored edge (pure translation — no scaling). */
|
|
3528
|
+
applySlide() {
|
|
3529
|
+
const off = easeInOutCubic(this.slideProg) * this.lastScreenH;
|
|
3530
|
+
for (const [view, baseY] of this.slideBaseY) {
|
|
3531
|
+
view.y = baseY + (this.slideSign.get(view) ?? 1) * off;
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
unmount() {
|
|
3535
|
+
if (this.slideTickFn && this.appTicker) this.appTicker.remove(this.slideTickFn);
|
|
3536
|
+
this.slideTickFn = void 0;
|
|
3537
|
+
for (const v of this.views) v.dispose();
|
|
3538
|
+
this.views.length = 0;
|
|
3539
|
+
for (const o of this.overlays) o.dispose();
|
|
3540
|
+
this.overlays.length = 0;
|
|
3541
|
+
this._eventLog?.dispose();
|
|
3542
|
+
this._eventLog = void 0;
|
|
3543
|
+
for (const d of this.disposers) d();
|
|
3544
|
+
this.disposers.length = 0;
|
|
3545
|
+
if (!this.root.destroyed) this.root.destroy({ children: true });
|
|
3546
|
+
if (typeof window !== "undefined") {
|
|
3547
|
+
delete window.__OPENUI__;
|
|
3548
|
+
}
|
|
3549
|
+
}
|
|
3550
|
+
expose() {
|
|
3551
|
+
if (typeof window === "undefined") return;
|
|
3552
|
+
window.__OPENUI__ = {
|
|
3553
|
+
snapshot: () => this.ui.snapshot(),
|
|
3554
|
+
getState: (id) => this.ui.control(id)?.current ?? null,
|
|
3555
|
+
isInteractable: (id) => this.ui.control(id)?.interactable ?? false,
|
|
3556
|
+
isAnimating: (id) => this.ui.control(id)?.inspect().animating ?? false,
|
|
3557
|
+
bounds: (id) => this.ui.snapshot().find((s) => s.id === id)?.bounds ?? null,
|
|
3558
|
+
events: (since) => this._eventLog?.since(since) ?? [],
|
|
3559
|
+
controlsReady: () => this.slideProg < 1e-3
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
var RISE = 26;
|
|
3564
|
+
var STAGGER = 38;
|
|
3565
|
+
var SLIDER_PIVOT_X = 130;
|
|
3566
|
+
var SLIDER_PIVOT_Y = 27;
|
|
3567
|
+
var PopoverView = class extends ControlView {
|
|
3568
|
+
constructor(panel, parts, ui, ticker, art = {}) {
|
|
3569
|
+
super(panel, ui);
|
|
3570
|
+
this.panel = panel;
|
|
3571
|
+
this.ticker = ticker;
|
|
3572
|
+
this.rules = new ButtonView(parts.rules, ui, ticker, { shape: "pill", height: 50, iconTexture: art.rulesTexture, iconTarget: 50 });
|
|
3573
|
+
this.music = new SliderView(parts.music, ui, art.musicTrack);
|
|
3574
|
+
this.sfx = new SliderView(parts.sfx, ui, art.soundTrack);
|
|
3575
|
+
this.music.pivot.set(SLIDER_PIVOT_X, SLIDER_PIVOT_Y);
|
|
3576
|
+
this.sfx.pivot.set(SLIDER_PIVOT_X, SLIDER_PIVOT_Y);
|
|
3577
|
+
this.items = [
|
|
3578
|
+
{ view: this.sfx, tx: -130, ty: -80, prog: 0 },
|
|
3579
|
+
{ view: this.music, tx: -130, ty: -80 * 2, prog: 0 },
|
|
3580
|
+
{ view: this.rules, tx: -132, ty: -80 * 3, prog: 0 }
|
|
3581
|
+
];
|
|
3582
|
+
for (const it of this.items) {
|
|
3583
|
+
it.view.position.set(it.tx, it.ty);
|
|
3584
|
+
it.view.scale.set(0);
|
|
3585
|
+
it.view.alpha = 0;
|
|
3586
|
+
it.view.visible = false;
|
|
3587
|
+
this.addChild(it.view);
|
|
3588
|
+
}
|
|
3589
|
+
this.tick = (t) => this.update(t.deltaMS);
|
|
3590
|
+
this.applyState();
|
|
3591
|
+
this.disposers.push(this.panel.state.subscribe(() => this.applyState()));
|
|
3592
|
+
}
|
|
3593
|
+
panel;
|
|
3594
|
+
ticker;
|
|
3595
|
+
music;
|
|
3596
|
+
sfx;
|
|
3597
|
+
rules;
|
|
3598
|
+
items;
|
|
3599
|
+
phase = 0;
|
|
3600
|
+
running = false;
|
|
3601
|
+
tick;
|
|
3602
|
+
applyState() {
|
|
3603
|
+
this.phase = 0;
|
|
3604
|
+
const open = this.panel.isOpen;
|
|
3605
|
+
this.eventMode = open ? "auto" : "none";
|
|
3606
|
+
if (open) for (const it of this.items) it.view.visible = true;
|
|
3607
|
+
if (!this.running) {
|
|
3608
|
+
this.running = true;
|
|
3609
|
+
this.ticker.add(this.tick);
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
update(dt) {
|
|
3613
|
+
this.phase += Math.min(dt, 40);
|
|
3614
|
+
const open = this.panel.isOpen;
|
|
3615
|
+
const finalTarget = open ? 1 : 0;
|
|
3616
|
+
let settled = true;
|
|
3617
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
3618
|
+
const it = this.items[i];
|
|
3619
|
+
const target = open && this.phase > i * STAGGER ? 1 : 0;
|
|
3620
|
+
it.prog += (target - it.prog) * Math.min(1, dt / (open ? 50 : 80));
|
|
3621
|
+
const s = it.prog;
|
|
3622
|
+
it.view.scale.set(s);
|
|
3623
|
+
it.view.alpha = Math.min(1, s * 1.5);
|
|
3624
|
+
it.view.position.set(it.tx, it.ty + (1 - s) * RISE);
|
|
3625
|
+
it.view.visible = s > 0.01;
|
|
3626
|
+
if (Math.abs(it.prog - finalTarget) > 0.01) settled = false;
|
|
3627
|
+
}
|
|
3628
|
+
if (settled) {
|
|
3629
|
+
this.running = false;
|
|
3630
|
+
this.ticker.remove(this.tick);
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
dispose() {
|
|
3634
|
+
if (this.running) {
|
|
3635
|
+
this.ticker.remove(this.tick);
|
|
3636
|
+
this.running = false;
|
|
3637
|
+
}
|
|
3638
|
+
this.music.dispose();
|
|
3639
|
+
this.sfx.dispose();
|
|
3640
|
+
this.rules.dispose();
|
|
3641
|
+
super.dispose();
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
var INK = 1382172;
|
|
3645
|
+
var CARD = 16777215;
|
|
3646
|
+
var HEADER_BG = 2106411;
|
|
3647
|
+
var PAD2 = 16;
|
|
3648
|
+
var HEADER_H2 = 56;
|
|
3649
|
+
var MAX_W = 600;
|
|
3650
|
+
var PanelView = class extends ControlView {
|
|
3651
|
+
constructor(panel, closeBtn, ui, ticker, opts = {}) {
|
|
3652
|
+
super(panel, ui);
|
|
3653
|
+
this.panel = panel;
|
|
3654
|
+
this.opts = opts;
|
|
3655
|
+
this.zIndex = 100;
|
|
3656
|
+
this.backdrop.eventMode = "static";
|
|
3657
|
+
this.backdrop.on("pointertap", () => this.panel.closePanel());
|
|
3658
|
+
this.title = new Text({
|
|
3659
|
+
text: panel.title ?? "",
|
|
3660
|
+
style: { fontFamily: ui.theme.type.family, fontSize: 22, fill: 16777215, fontWeight: "800", letterSpacing: 1 }
|
|
3661
|
+
});
|
|
3662
|
+
this.title.anchor.set(0.5);
|
|
3663
|
+
this.viewport.mask = this.maskG;
|
|
3664
|
+
this.catcher.eventMode = "static";
|
|
3665
|
+
this.catcher.on("pointerdown", this.onDown);
|
|
3666
|
+
this.catcher.on("globalpointermove", this.onMove);
|
|
3667
|
+
this.catcher.on("pointerup", this.onUp);
|
|
3668
|
+
this.catcher.on("pointerupoutside", this.onUp);
|
|
3669
|
+
this.close = new ButtonView(closeBtn, ui, ticker, { iconTexture: opts.closeTexture, iconTarget: 44, glyph: "close", radius: 24 });
|
|
3670
|
+
this.addChild(this.backdrop, this.card, this.viewport, this.maskG, this.catcher, this.headerBg, this.title, this.close);
|
|
3671
|
+
this.applyOpen(this.panel.isOpen);
|
|
3672
|
+
this.disposers.push(this.panel.state.subscribe(() => this.applyOpen(this.panel.isOpen)));
|
|
3673
|
+
}
|
|
3674
|
+
panel;
|
|
3675
|
+
opts;
|
|
3676
|
+
backdrop = new Graphics();
|
|
3677
|
+
card = new Graphics();
|
|
3678
|
+
headerBg = new Graphics();
|
|
3679
|
+
title;
|
|
3680
|
+
viewport = new Container();
|
|
3681
|
+
maskG = new Graphics();
|
|
3682
|
+
catcher = new Graphics();
|
|
3683
|
+
close;
|
|
3684
|
+
content;
|
|
3685
|
+
builtWidth = -1;
|
|
3686
|
+
scrollY = 0;
|
|
3687
|
+
contentH = 0;
|
|
3688
|
+
viewportH = 0;
|
|
3689
|
+
dragging = false;
|
|
3690
|
+
lastY = 0;
|
|
3691
|
+
wheelHandler;
|
|
3692
|
+
applyLayout(screen) {
|
|
3693
|
+
const W = screen.width;
|
|
3694
|
+
const H = screen.height;
|
|
3695
|
+
this.position.set(0, 0);
|
|
3696
|
+
this.scale.set(1);
|
|
3697
|
+
this.backdrop.clear().rect(0, 0, W, H).fill({ color: 0, alpha: 0.6 });
|
|
3698
|
+
this.backdrop.hitArea = new Rectangle(0, 0, W, H);
|
|
3699
|
+
const cardW = Math.min(W - PAD2 * 2, MAX_W);
|
|
3700
|
+
const cx = (W - cardW) / 2;
|
|
3701
|
+
const hy = PAD2;
|
|
3702
|
+
this.headerBg.clear().roundRect(cx, hy, cardW, HEADER_H2, HEADER_H2 / 2).fill({ color: HEADER_BG });
|
|
3703
|
+
this.title.position.set(W / 2, hy + HEADER_H2 / 2);
|
|
3704
|
+
this.close.position.set(cx + cardW - HEADER_H2 / 2, hy + HEADER_H2 / 2);
|
|
3705
|
+
const cardY = hy + HEADER_H2 + 12;
|
|
3706
|
+
const cardH = H - cardY - PAD2;
|
|
3707
|
+
this.card.clear().roundRect(cx, cardY, cardW, cardH, 22).fill({ color: CARD });
|
|
3708
|
+
const inset = 20;
|
|
3709
|
+
const vpX = cx + inset;
|
|
3710
|
+
const vpY = cardY + inset;
|
|
3711
|
+
const vpW = cardW - inset * 2;
|
|
3712
|
+
const vpH = cardH - inset * 2;
|
|
3713
|
+
this.viewport.position.set(vpX, vpY);
|
|
3714
|
+
this.viewportH = vpH;
|
|
3715
|
+
this.maskG.clear().rect(vpX, vpY, vpW, vpH).fill({ color: 16777215 });
|
|
3716
|
+
this.catcher.clear().rect(vpX, vpY, vpW, vpH).fill({ color: 16777215, alpha: 1e-4 });
|
|
3717
|
+
if (Math.abs(vpW - this.builtWidth) > 1) {
|
|
3718
|
+
this.content?.destroy({ children: true });
|
|
3719
|
+
this.content = this.opts.content?.(this.ui.theme, vpW) ?? this.fallback(vpW);
|
|
3720
|
+
this.viewport.addChild(this.content);
|
|
3721
|
+
this.builtWidth = vpW;
|
|
3722
|
+
}
|
|
3723
|
+
if (this.content) this.content.x = 0;
|
|
3724
|
+
this.contentH = this.content?.height ?? 0;
|
|
3725
|
+
this.clampScroll();
|
|
3726
|
+
}
|
|
3727
|
+
fallback(width) {
|
|
3728
|
+
const c = new Container();
|
|
3729
|
+
const t = new Text({ text: "No content provided.", style: { fontFamily: this.ui.theme.type.family, fontSize: 18, fill: INK, wordWrap: true, wordWrapWidth: width } });
|
|
3730
|
+
c.addChild(t);
|
|
3731
|
+
return c;
|
|
3732
|
+
}
|
|
3733
|
+
onDown = (e) => {
|
|
3734
|
+
this.dragging = true;
|
|
3735
|
+
this.lastY = e.global.y;
|
|
3736
|
+
};
|
|
3737
|
+
onMove = (e) => {
|
|
3738
|
+
if (!this.dragging) return;
|
|
3739
|
+
this.scrollY += e.global.y - this.lastY;
|
|
3740
|
+
this.lastY = e.global.y;
|
|
3741
|
+
this.clampScroll();
|
|
3742
|
+
};
|
|
3743
|
+
onUp = () => {
|
|
3744
|
+
this.dragging = false;
|
|
3745
|
+
};
|
|
3746
|
+
clampScroll() {
|
|
3747
|
+
const min = Math.min(0, this.viewportH - this.contentH);
|
|
3748
|
+
this.scrollY = Math.max(min, Math.min(0, this.scrollY));
|
|
3749
|
+
if (this.content) this.content.y = this.scrollY;
|
|
3750
|
+
}
|
|
3751
|
+
applyOpen(open) {
|
|
3752
|
+
this.visible = open;
|
|
3753
|
+
this.eventMode = open ? "static" : "none";
|
|
3754
|
+
this.alpha = open ? 1 : 0;
|
|
3755
|
+
if (open) {
|
|
3756
|
+
this.scrollY = 0;
|
|
3757
|
+
this.clampScroll();
|
|
3758
|
+
if (!this.wheelHandler) {
|
|
3759
|
+
this.wheelHandler = (e) => {
|
|
3760
|
+
this.scrollY -= e.deltaY;
|
|
3761
|
+
this.clampScroll();
|
|
3762
|
+
};
|
|
3763
|
+
window.addEventListener("wheel", this.wheelHandler, { passive: true });
|
|
3764
|
+
}
|
|
3765
|
+
} else if (this.wheelHandler) {
|
|
3766
|
+
window.removeEventListener("wheel", this.wheelHandler);
|
|
3767
|
+
this.wheelHandler = void 0;
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
dispose() {
|
|
3771
|
+
if (this.wheelHandler) window.removeEventListener("wheel", this.wheelHandler);
|
|
3772
|
+
this.close.dispose();
|
|
3773
|
+
super.dispose();
|
|
3774
|
+
}
|
|
3775
|
+
};
|
|
3776
|
+
var PanelBodyView = class extends ControlView {
|
|
3777
|
+
constructor(panelControl, controls, blocks, ui, ticker, opts = {}) {
|
|
3778
|
+
super(panelControl, ui);
|
|
3779
|
+
this.panelControl = panelControl;
|
|
3780
|
+
this.controls = controls;
|
|
3781
|
+
this.blocks = blocks;
|
|
3782
|
+
this.ticker = ticker;
|
|
3783
|
+
this.opts = opts;
|
|
3784
|
+
this.bodyW = opts.width ?? 360;
|
|
3785
|
+
this.addChild(this.backdrop, this.card, this.content);
|
|
3786
|
+
this.rebuild();
|
|
3787
|
+
this.applyVisibility();
|
|
3788
|
+
this.disposers.push(
|
|
3789
|
+
this.panelControl.state.subscribe(() => this.applyVisibility()),
|
|
3790
|
+
this.ui.locale.subscribe(() => {
|
|
3791
|
+
if (!this.destroyed) this.rebuild();
|
|
3792
|
+
})
|
|
3793
|
+
);
|
|
3794
|
+
if (this.panelControl.variant === "modal") {
|
|
3795
|
+
this.backdrop.eventMode = "static";
|
|
3796
|
+
this.backdrop.on("pointertap", () => this.panelControl.closePanel());
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
panelControl;
|
|
3800
|
+
controls;
|
|
3801
|
+
blocks;
|
|
3802
|
+
ticker;
|
|
3803
|
+
opts;
|
|
3804
|
+
backdrop = new Graphics();
|
|
3805
|
+
card = new Graphics();
|
|
3806
|
+
content = new Container();
|
|
3807
|
+
childViews = [];
|
|
3808
|
+
bodyW;
|
|
3809
|
+
rebuild() {
|
|
3810
|
+
for (const v of this.childViews) v.dispose();
|
|
3811
|
+
this.childViews.length = 0;
|
|
3812
|
+
for (const child of this.content.removeChildren()) child.destroy();
|
|
3813
|
+
const col = buildBlockColumn(this.blocks, this.controls, this.ui, this.ticker, this.bodyW, { controlSkins: this.opts.controlSkins });
|
|
3814
|
+
this.childViews = col.views;
|
|
3815
|
+
this.content.addChild(...col.content.removeChildren());
|
|
3816
|
+
this.content.position.set(0, -col.height / 2);
|
|
3817
|
+
this.drawChrome(this.bodyW, col.height);
|
|
3818
|
+
}
|
|
3819
|
+
drawChrome(width, height) {
|
|
3820
|
+
const t = this.ui.theme;
|
|
3821
|
+
this.card.clear().roundRect(-width / 2, -height / 2, width, height, t.radius.card).fill({ color: t.color.surface }).stroke({ width: 3, color: t.color.accent });
|
|
3822
|
+
this.backdrop.clear();
|
|
3823
|
+
if (this.panelControl.variant === "modal") {
|
|
3824
|
+
this.backdrop.rect(-3e3, -3e3, 6e3, 6e3).fill({ color: 0, alpha: 0.6 });
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
applyVisibility() {
|
|
3828
|
+
const open = this.panelControl.isOpen;
|
|
3829
|
+
this.visible = open;
|
|
3830
|
+
this.eventMode = open ? "auto" : "none";
|
|
3831
|
+
}
|
|
3832
|
+
dispose() {
|
|
3833
|
+
for (const v of this.childViews) v.dispose();
|
|
3834
|
+
this.childViews.length = 0;
|
|
3835
|
+
super.dispose();
|
|
3836
|
+
}
|
|
3837
|
+
};
|
|
3838
|
+
function mountHud(app, spec = {}, opts = {}) {
|
|
3839
|
+
const { hooks, ...pixiOpts } = opts;
|
|
3840
|
+
const ui = createUI(spec, hooks);
|
|
3841
|
+
const locales = spec.locale ? Array.from(/* @__PURE__ */ new Set([spec.locale.locale, ...Object.keys(spec.locale.messages)])) : [];
|
|
3842
|
+
const menu = pixiOpts.menu === false ? false : composeMenu(spec.menu, { locales, localeSelectId: spec.localeSelectId, rulesFallback: spec.rules });
|
|
3843
|
+
if (menu && spec.game && (spec.game.name || spec.game.version)) {
|
|
3844
|
+
menu.push({ kind: "legal", id: "openui-game-info", text: [spec.game.name, spec.game.version ? `v${spec.game.version}` : ""].filter(Boolean).join(" \xB7 ") });
|
|
3845
|
+
}
|
|
3846
|
+
const pixi = new OpenUIPixi(ui, { ...pixiOpts, menu, statusBar: pixiOpts.statusBar ?? spec.statusBar });
|
|
3847
|
+
pixi.mount(app);
|
|
3848
|
+
const extra = [];
|
|
3849
|
+
if (spec.panels?.length) {
|
|
3850
|
+
for (const ps of spec.panels) {
|
|
3851
|
+
const built = buildPanel(ps, ui.bus);
|
|
3852
|
+
ui.register(built.panel);
|
|
3853
|
+
for (const c of built.controls) ui.register(c);
|
|
3854
|
+
const view = new PanelBodyView(built.panel, built.controls, built.blocks, ui, app.ticker, {
|
|
3855
|
+
controlSkins: pixiOpts.controlSkins
|
|
3856
|
+
});
|
|
3857
|
+
pixi.root.addChild(view);
|
|
3858
|
+
view.applyLayout(ui.screen.get());
|
|
3859
|
+
extra.push(view);
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
const offRelayout = ui.screen.subscribe(() => {
|
|
3863
|
+
const s = ui.screen.get();
|
|
3864
|
+
for (const v of extra) v.applyLayout(s);
|
|
3865
|
+
});
|
|
3866
|
+
const teardown = () => {
|
|
3867
|
+
offRelayout();
|
|
3868
|
+
for (const v of extra) v.dispose();
|
|
3869
|
+
extra.length = 0;
|
|
3870
|
+
pixi.unmount();
|
|
3871
|
+
ui.dispose();
|
|
3872
|
+
};
|
|
3873
|
+
function on(type, fn) {
|
|
3874
|
+
return ui.on(type, fn);
|
|
3875
|
+
}
|
|
3876
|
+
return {
|
|
3877
|
+
ui,
|
|
3878
|
+
pixi,
|
|
3879
|
+
on,
|
|
3880
|
+
setBalance: (n) => ui.balance.set(n),
|
|
3881
|
+
setBet: (n) => ui.bet.set(n),
|
|
3882
|
+
setCurrency: (c) => {
|
|
3883
|
+
ui.balance.setCurrency(c);
|
|
3884
|
+
ui.bet.setCurrency(c);
|
|
3885
|
+
ui.netPosition.setCurrency(c);
|
|
3886
|
+
},
|
|
3887
|
+
applyJurisdiction: (j) => ui.applyJurisdiction(j),
|
|
3888
|
+
reportRound: (win, bet) => ui.reportRound(win, bet),
|
|
3889
|
+
setRtp: (p) => ui.rtp.set(p),
|
|
3890
|
+
setMuted: (m) => ui.setMuted(m),
|
|
3891
|
+
showNotice: (blocks, actions) => ui.showNotice(blocks, actions),
|
|
3892
|
+
showError: (message, opts2) => ui.showError(message, opts2),
|
|
3893
|
+
showRgsError: (code, opts2) => ui.showRgsError(code, opts2),
|
|
3894
|
+
showFatal: (message, opts2) => ui.showFatal(message, opts2),
|
|
3895
|
+
hideNotice: () => ui.hideNotice(),
|
|
3896
|
+
setSocial: (on2, coin) => ui.setSocial(on2, coin),
|
|
3897
|
+
setFreeSpins: (n) => ui.spin.setFreeSpins(n),
|
|
3898
|
+
setReplay: (on2) => ui.setReplay(on2),
|
|
3899
|
+
confirmBuy: (o) => {
|
|
3900
|
+
if (ui.isDisabled("buyFeature")) return;
|
|
3901
|
+
ui.showNotice(
|
|
3902
|
+
[
|
|
3903
|
+
{ kind: "heading", id: "buy-title", text: o.title ?? "openui.buyFeature.title" },
|
|
3904
|
+
{ kind: "callout", id: "buy-body", tone: "bonus", text: o.message ?? "openui.buyFeature.message" }
|
|
3905
|
+
],
|
|
3906
|
+
[
|
|
3907
|
+
{ label: o.cancelLabel ?? "openui.cancel", variant: "secondary" },
|
|
3908
|
+
{ label: o.confirmLabel ?? "openui.confirm", variant: "primary", onSelect: o.onConfirm }
|
|
3909
|
+
]
|
|
3910
|
+
);
|
|
3911
|
+
},
|
|
3912
|
+
showControls: () => pixi.setControlsVisible(true),
|
|
3913
|
+
hideControls: () => pixi.setControlsVisible(false),
|
|
3914
|
+
setControlsVisible: (v) => pixi.setControlsVisible(v),
|
|
3915
|
+
snapshot: () => ui.snapshot(),
|
|
3916
|
+
events: pixi.eventLog,
|
|
3917
|
+
inputLocked: ui.locked,
|
|
3918
|
+
lockInput: () => ui.lock(),
|
|
3919
|
+
unlockInput: () => ui.unlock(),
|
|
3920
|
+
unmount: teardown,
|
|
3921
|
+
dispose: teardown
|
|
3922
|
+
};
|
|
3923
|
+
}
|
|
3924
|
+
var ANCHOR_X = 100 / 203;
|
|
3925
|
+
var ANCHOR_Y = 100 / 213;
|
|
3926
|
+
var TARGET_DIAMETER = 220;
|
|
3927
|
+
function makeSprite(texture) {
|
|
3928
|
+
const s = new Sprite(texture);
|
|
3929
|
+
s.anchor.set(ANCHOR_X, ANCHOR_Y);
|
|
3930
|
+
s.scale.set(TARGET_DIAMETER / 200);
|
|
3931
|
+
return s;
|
|
3932
|
+
}
|
|
3933
|
+
function svgSpinSkin(textures) {
|
|
3934
|
+
const view = new Container();
|
|
3935
|
+
const def = makeSprite(textures.default);
|
|
3936
|
+
const auto = makeSprite(textures.auto);
|
|
3937
|
+
auto.visible = false;
|
|
3938
|
+
view.addChild(def, auto);
|
|
3939
|
+
return {
|
|
3940
|
+
view,
|
|
3941
|
+
update(state) {
|
|
3942
|
+
const isAuto = state === "auto";
|
|
3943
|
+
def.visible = !isAuto;
|
|
3944
|
+
auto.visible = isAuto;
|
|
3945
|
+
},
|
|
3946
|
+
destroy() {
|
|
3947
|
+
view.destroy({ children: true });
|
|
3948
|
+
}
|
|
3949
|
+
};
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
export { AutoplayDrawerView, AutoplayView, ButtonView, ControlView, DialogView, MenuView, OpenUIPixi, PanelBodyView, PanelView, PopoverView, ReadoutView, SelectView, SliderView, SpinView, StatusBarView, StepperView, TextCellRenderer, ToggleView, TurboView, Tweener, ValueDisplayView, buildBlockColumn, defaultSpinSkin, drawSpin, isDesktop, mountHud, svgSpinSkin };
|
|
3953
|
+
//# sourceMappingURL=index.js.map
|
|
3954
|
+
//# sourceMappingURL=index.js.map
|