@energy8platform/shell 0.6.5 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html.cjs.js +11 -9
- package/dist/html.cjs.js.map +1 -1
- package/dist/html.d.ts +11 -6
- package/dist/html.esm.js +11 -9
- package/dist/html.esm.js.map +1 -1
- package/dist/index.cjs.js +7 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -5
- package/dist/index.esm.js +7 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/pixi.cjs.js +14 -8
- package/dist/pixi.cjs.js.map +1 -1
- package/dist/pixi.d.ts +11 -6
- package/dist/pixi.esm.js +14 -8
- package/dist/pixi.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/core/ShellController.ts +7 -5
- package/src/core/renderer.ts +4 -2
- package/src/core/version.ts +1 -1
- package/src/ui/html/HtmlRenderer.ts +4 -4
- package/src/ui/pixi/PixiRenderer.ts +9 -7
package/package.json
CHANGED
|
@@ -304,9 +304,9 @@ export class ShellController extends EventEmitter<ShellEvents> implements ShellH
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
// ── game-facing public API (mirrors GameShell/PixiGameShell) ───────────────────
|
|
307
|
-
private money(field: 'balance' | 'win', from: number, to: number): void {
|
|
307
|
+
private money(field: 'balance' | 'win', from: number, to: number, durationMs?: number): void {
|
|
308
308
|
this.renderer.renderBar();
|
|
309
|
-
if (to !== from) this.renderer.animateMoney(field, from, to);
|
|
309
|
+
if (to !== from) this.renderer.animateMoney(field, from, to, durationMs);
|
|
310
310
|
}
|
|
311
311
|
setBalance(n: number): void {
|
|
312
312
|
const from = this.prevBalance;
|
|
@@ -316,8 +316,10 @@ export class ShellController extends EventEmitter<ShellEvents> implements ShellH
|
|
|
316
316
|
}
|
|
317
317
|
/** Set the WIN readout. Counts up/down from the previous value by default. Pass
|
|
318
318
|
* `{ animate: false }` to SNAP instantly (renderBar cancels any in-flight count-up) — used by the
|
|
319
|
-
* host to clear WIN to 0 at spin start, where an animated count-DOWN would look wrong.
|
|
320
|
-
|
|
319
|
+
* host to clear WIN to 0 at spin start, where an animated count-DOWN would look wrong.
|
|
320
|
+
* `{ durationMs }` shortens/lengthens the count-up (default 450ms) — a scene reporting a win per
|
|
321
|
+
* cascade step passes its step length so each count-up finishes before the next step lands. */
|
|
322
|
+
setWin(n: number, opts?: { animate?: boolean; durationMs?: number }): void {
|
|
321
323
|
const from = this.prevWin;
|
|
322
324
|
this.state.win = n;
|
|
323
325
|
this.prevWin = n;
|
|
@@ -325,7 +327,7 @@ export class ShellController extends EventEmitter<ShellEvents> implements ShellH
|
|
|
325
327
|
this.renderer.renderBar(); // instant repaint from state; cancels running money anims
|
|
326
328
|
return;
|
|
327
329
|
}
|
|
328
|
-
this.money('win', from, n);
|
|
330
|
+
this.money('win', from, n, opts?.durationMs);
|
|
329
331
|
}
|
|
330
332
|
setBet(n: number): void {
|
|
331
333
|
this.state.bet = n;
|
package/src/core/renderer.ts
CHANGED
|
@@ -18,8 +18,10 @@ export interface ShellRenderer {
|
|
|
18
18
|
setLayout(layout: ShellLayoutMode): void;
|
|
19
19
|
/** Apply colour tokens (CSS vars in DOM / repaint in Pixi). */
|
|
20
20
|
applyTheme(tokens: ShellTokens): void;
|
|
21
|
-
/** Count a money readout from→to on the freshly-rendered bar (DOM rAF / Pixi ticker).
|
|
22
|
-
|
|
21
|
+
/** Count a money readout from→to on the freshly-rendered bar (DOM rAF / Pixi ticker).
|
|
22
|
+
* `durationMs` overrides the renderer's default count-up length — a cascade/tumble scene
|
|
23
|
+
* reporting a win per step needs each count-up to fit inside its step. */
|
|
24
|
+
animateMoney(field: 'balance' | 'win', from: number, to: number, durationMs?: number): void;
|
|
23
25
|
/** Build + show an overlay from a controller-supplied model; return a handle for key routing
|
|
24
26
|
* and programmatic close. Returns void when nothing was shown. */
|
|
25
27
|
openOverlay(req: OverlayRequest): OverlayHandle | void;
|
package/src/core/version.ts
CHANGED
|
@@ -19,10 +19,10 @@ const REMOVE_FADE_MS = 300;
|
|
|
19
19
|
|
|
20
20
|
/** Count-up the value span (.ge-rd-val) of a readout, leaving its label untouched.
|
|
21
21
|
* Returns the count-up canceler so the renderer can stop it before the node is replaced. */
|
|
22
|
-
function animateReadout(el: HTMLElement, from: number, to: number, fmt: (n: number) => string): () => void {
|
|
22
|
+
function animateReadout(el: HTMLElement, from: number, to: number, fmt: (n: number) => string, durationMs?: number): () => void {
|
|
23
23
|
const val = el.querySelector('.ge-rd-val') as HTMLElement | null;
|
|
24
24
|
if (!val) { el.textContent = fmt(to); return () => {}; }
|
|
25
|
-
return countUp(val, from, to, fmt);
|
|
25
|
+
return durationMs == null ? countUp(val, from, to, fmt) : countUp(val, from, to, fmt, durationMs);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export class HtmlRenderer implements ShellRenderer {
|
|
@@ -87,10 +87,10 @@ export class HtmlRenderer implements ShellRenderer {
|
|
|
87
87
|
this.renderBar();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
animateMoney(field: 'balance' | 'win', from: number, to: number): void {
|
|
90
|
+
animateMoney(field: 'balance' | 'win', from: number, to: number, durationMs?: number): void {
|
|
91
91
|
const fmt = (n: number) => this.host.formatCurrency(n, field === 'win');
|
|
92
92
|
const el = this.barHost.querySelector(`[data-ge="${field}"]`) as HTMLElement | null;
|
|
93
|
-
if (el) this.moneyAnims.push(animateReadout(el, from, to, fmt));
|
|
93
|
+
if (el) this.moneyAnims.push(animateReadout(el, from, to, fmt, durationMs));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
openOverlay(req: OverlayRequest): OverlayHandle | void {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
RenderTexture,
|
|
7
7
|
Sprite,
|
|
8
8
|
type Application,
|
|
9
|
+
type Text,
|
|
9
10
|
type Ticker,
|
|
10
11
|
} from 'pixi.js';
|
|
11
12
|
import type { ShellRenderer, ShellHost, OverlayRequest, OverlayHandle } from '@/core/renderer';
|
|
@@ -109,16 +110,17 @@ export class PixiRenderer implements ShellRenderer {
|
|
|
109
110
|
|
|
110
111
|
/** Count a money readout from→to on the freshly-rendered bar's value Text node. Mirrors
|
|
111
112
|
* PixiGameShell.animateMoney (which counted on the just-built bar's value Texts). */
|
|
112
|
-
animateMoney(field: 'balance' | 'win', from: number, to: number): void {
|
|
113
|
+
animateMoney(field: 'balance' | 'win', from: number, to: number, durationMs?: number): void {
|
|
113
114
|
if (!this.bar) return;
|
|
115
|
+
// countUpText defaults durationMs to 450 — pass it only when the caller overrode it.
|
|
116
|
+
const count = (text: Text, fmt: (n: number) => string) =>
|
|
117
|
+
durationMs == null
|
|
118
|
+
? countUpText(this.ticker, text, from, to, fmt)
|
|
119
|
+
: countUpText(this.ticker, text, from, to, fmt, durationMs);
|
|
114
120
|
if (field === 'balance' && this.bar.balanceValue) {
|
|
115
|
-
this.moneyAnims.push(
|
|
116
|
-
countUpText(this.ticker, this.bar.balanceValue, from, to, (n) => this.ctx.fmt(n)),
|
|
117
|
-
);
|
|
121
|
+
this.moneyAnims.push(count(this.bar.balanceValue, (n) => this.ctx.fmt(n)));
|
|
118
122
|
} else if (field === 'win' && this.bar.winValue) {
|
|
119
|
-
this.moneyAnims.push(
|
|
120
|
-
countUpText(this.ticker, this.bar.winValue, from, to, (n) => this.ctx.fmtWin(n)),
|
|
121
|
-
);
|
|
123
|
+
this.moneyAnims.push(count(this.bar.winValue, (n) => this.ctx.fmtWin(n)));
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
126
|
|