@open-slot-ui/pixi 0.1.0 → 0.2.0

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/index.cjs CHANGED
@@ -1513,7 +1513,7 @@ var TurboView = class extends ControlView {
1513
1513
  } else {
1514
1514
  this.art.addChild(this.bg);
1515
1515
  }
1516
- this.addChild(this.art, this.pips);
1516
+ this.addChild(this.art);
1517
1517
  this.eventMode = "static";
1518
1518
  this.cursor = "pointer";
1519
1519
  this.hitArea = new pixi_js.Circle(0, 0, (this.sprite ? this.target / 2 : this.radius) + 8);
@@ -1528,7 +1528,6 @@ var TurboView = class extends ControlView {
1528
1528
  turbo;
1529
1529
  art = new pixi_js.Container();
1530
1530
  bg = new pixi_js.Graphics();
1531
- pips = new pixi_js.Graphics();
1532
1531
  sprite;
1533
1532
  tween;
1534
1533
  modeTex;
@@ -1565,19 +1564,6 @@ var TurboView = class extends ControlView {
1565
1564
  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 });
1566
1565
  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 });
1567
1566
  }
1568
- this.pips.clear();
1569
- const steps = this.turbo.modeCount - 1;
1570
- if (steps >= 2) {
1571
- const baseR = this.sprite ? this.target / 2 : this.radius;
1572
- const gap = 16;
1573
- const total = (steps - 1) * gap;
1574
- const y = baseR + 14;
1575
- for (let s = 0; s < steps; s++) {
1576
- const x = -total / 2 + s * gap;
1577
- const on = s < i;
1578
- 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 });
1579
- }
1580
- }
1581
1567
  }
1582
1568
  play(t) {
1583
1569
  this.animating = true;
@@ -3247,73 +3233,6 @@ var DialogView = class extends ControlView {
3247
3233
  super.dispose();
3248
3234
  }
3249
3235
  };
3250
- var BAR_H = 26;
3251
- var StatusBarView = class _StatusBarView extends pixi_js.Container {
3252
- constructor(controls, ui, ticker, side) {
3253
- super();
3254
- this.ui = ui;
3255
- this.side = side;
3256
- this.zIndex = 300;
3257
- this.addChild(this.bg);
3258
- for (const c of controls) {
3259
- const view = new ReadoutView(c, ui, ticker, { inline: true, mono: true });
3260
- this.addChild(view);
3261
- this.items.push({ id: c.id, view });
3262
- }
3263
- this.disposers.push(
3264
- this.ui.on("visibilityChanged", ({ id }) => {
3265
- if (this.items.some((it) => it.id === id)) this.relayout();
3266
- })
3267
- );
3268
- }
3269
- ui;
3270
- side;
3271
- bg = new pixi_js.Graphics();
3272
- items = [];
3273
- screen;
3274
- disposers = [];
3275
- /** The strip's pixel height for the current screen (used for the HUD margin too). */
3276
- static heightFor(screen) {
3277
- const scale = Math.max(0.7, Math.min(1.4, screen.scale));
3278
- return Math.round(BAR_H * scale);
3279
- }
3280
- applyLayout(screen) {
3281
- this.screen = screen;
3282
- this.relayout();
3283
- }
3284
- relayout() {
3285
- const s = this.screen;
3286
- if (!s) return;
3287
- const W = s.width;
3288
- const H = s.height;
3289
- const scale = Math.max(0.7, Math.min(1.4, s.scale));
3290
- const barH = _StatusBarView.heightFor(s);
3291
- const y = this.side === "top" ? 0 : H - barH;
3292
- this.position.set(0, 0);
3293
- const visible = this.items.filter((it) => !this.ui.hidden.has(it.id));
3294
- for (const it of this.items) it.view.visible = !this.ui.hidden.has(it.id);
3295
- this.bg.clear();
3296
- this.visible = visible.length > 0;
3297
- if (!visible.length) return;
3298
- const edgeY = this.side === "top" ? barH - 1 : y;
3299
- this.bg.rect(0, y, W, barH).fill({ color: 789776, alpha: 0.92 }).rect(0, edgeY, W, 1).fill({ color: 16777215, alpha: 0.18 });
3300
- const n = visible.length;
3301
- const cy = y + barH / 2;
3302
- const pad = 18 * scale;
3303
- const usableW = Math.max(160, W - pad * 2);
3304
- visible.forEach((it, i) => {
3305
- it.view.position.set(pad + usableW * ((i + 0.5) / n), cy);
3306
- it.view.scale.set(scale);
3307
- });
3308
- }
3309
- dispose() {
3310
- for (const it of this.items) it.view.dispose();
3311
- this.items.length = 0;
3312
- for (const d of this.disposers) d();
3313
- this.disposers.length = 0;
3314
- if (!this.destroyed) this.destroy({ children: true });
3315
- }
3316
- };
3317
3236
 
3318
3237
  // src/OpenUIPixi.ts
3319
3238
  function easeInOutCubic(p) {
@@ -3396,11 +3315,10 @@ var OpenUIPixi = class {
3396
3315
  const fullscreenView = new ButtonView(this.ui.fullscreenButton, this.ui, ticker, { shape: "circle", radius: 30, glyph: "fullscreen", iconTarget: 60, mono: true });
3397
3316
  muteView.zIndex = 65;
3398
3317
  fullscreenView.zIndex = 65;
3399
- const statusBarSide = this.opts.statusBar;
3400
3318
  const roOpts = { prefix: true, fill: this.opts.readoutColor };
3401
- const rtpView = statusBarSide ? void 0 : new ReadoutView(this.ui.rtp, this.ui, ticker, roOpts);
3402
- const netView = statusBarSide ? void 0 : new ReadoutView(this.ui.netPosition, this.ui, ticker, roOpts);
3403
- const timerView = statusBarSide ? void 0 : new ReadoutView(this.ui.sessionTimer, this.ui, ticker, roOpts);
3319
+ const rtpView = new ReadoutView(this.ui.rtp, this.ui, ticker, roOpts);
3320
+ const netView = new ReadoutView(this.ui.netPosition, this.ui, ticker, roOpts);
3321
+ const timerView = new ReadoutView(this.ui.sessionTimer, this.ui, ticker, roOpts);
3404
3322
  const entries = [
3405
3323
  [this.ui.spin.id, spinView],
3406
3324
  [this.ui.balance.id, balanceView],
@@ -3414,9 +3332,9 @@ var OpenUIPixi = class {
3414
3332
  [this.ui.muteButton.id, muteView],
3415
3333
  [this.ui.fullscreenButton.id, fullscreenView]
3416
3334
  ];
3417
- if (rtpView) entries.push([this.ui.rtp.id, rtpView]);
3418
- if (netView) entries.push([this.ui.netPosition.id, netView]);
3419
- if (timerView) entries.push([this.ui.sessionTimer.id, timerView]);
3335
+ entries.push([this.ui.rtp.id, rtpView]);
3336
+ entries.push([this.ui.netPosition.id, netView]);
3337
+ entries.push([this.ui.sessionTimer.id, timerView]);
3420
3338
  const viewById = /* @__PURE__ */ new Map();
3421
3339
  const idByView = /* @__PURE__ */ new Map();
3422
3340
  for (const [id, view] of entries) {
@@ -3477,28 +3395,22 @@ var OpenUIPixi = class {
3477
3395
  const dialog = new DialogView(this.ui.noticePanel, this.ui.noticeBlocks, this.ui.noticeActions, this.ui, ticker, { controlSkins: this.opts.controlSkins });
3478
3396
  this.root.addChild(dialog);
3479
3397
  this.overlays.push(dialog);
3480
- if (statusBarSide) {
3481
- const bar = new StatusBarView([this.ui.netPosition, this.ui.rtp, this.ui.sessionTimer], this.ui, ticker, statusBarSide);
3482
- this.root.addChild(bar);
3483
- this.overlays.push(bar);
3484
- } else {
3485
- const vignette = new pixi_js.Graphics();
3486
- vignette.zIndex = -1;
3487
- this.root.addChild(vignette);
3488
- this.overlays.push({
3489
- applyLayout: (s) => {
3490
- const r = 200 * s.scale;
3491
- vignette.clear();
3492
- for (let i = 0; i < 14; i++) {
3493
- const t = i / 14;
3494
- vignette.circle(0, 0, r * (1 - t)).fill({ color: 0, alpha: 0.5 / 14 });
3495
- }
3496
- },
3497
- dispose: () => {
3498
- if (!vignette.destroyed) vignette.destroy();
3398
+ const vignette = new pixi_js.Graphics();
3399
+ vignette.zIndex = -1;
3400
+ this.root.addChild(vignette);
3401
+ this.overlays.push({
3402
+ applyLayout: (s) => {
3403
+ const r = 200 * s.scale;
3404
+ vignette.clear();
3405
+ for (let i = 0; i < 14; i++) {
3406
+ const t = i / 14;
3407
+ vignette.circle(0, 0, r * (1 - t)).fill({ color: 0, alpha: 0.5 / 14 });
3499
3408
  }
3500
- });
3501
- }
3409
+ },
3410
+ dispose: () => {
3411
+ if (!vignette.destroyed) vignette.destroy();
3412
+ }
3413
+ });
3502
3414
  const replayBadge = new pixi_js.Container();
3503
3415
  const replayBg = new pixi_js.Graphics();
3504
3416
  const replayText = new pixi_js.Text({ text: this.ui.t("openui.replay").toUpperCase(), style: { fontFamily: this.ui.theme.type.family, fontSize: 16, fontWeight: "800", fill: 16777215, letterSpacing: 2 } });
@@ -3512,8 +3424,7 @@ var OpenUIPixi = class {
3512
3424
  const w = replayText.width + 36;
3513
3425
  const h = 32;
3514
3426
  replayBg.clear().roundRect(-w / 2, -h / 2, w, h, h / 2).fill({ color: 789776 }).stroke({ width: 2, color: 16777215 });
3515
- const top = statusBarSide === "top" ? StatusBarView.heightFor(s) + 28 : 40;
3516
- replayBadge.position.set(s.width / 2, top);
3427
+ replayBadge.position.set(s.width / 2, 40);
3517
3428
  },
3518
3429
  dispose: () => {
3519
3430
  if (!replayBadge.destroyed) replayBadge.destroy({ children: true });
@@ -3529,16 +3440,11 @@ var OpenUIPixi = class {
3529
3440
  );
3530
3441
  const applyLayout = () => {
3531
3442
  const screen = this.ui.screen.get();
3532
- const barH = statusBarSide ? StatusBarView.heightFor(screen) : 0;
3533
3443
  this.slideBaseY.clear();
3534
3444
  this.slideSign.clear();
3535
3445
  for (const v of this.views) {
3536
3446
  v.applyLayout(screen);
3537
3447
  const anchor = this.ui.control(idByView.get(v) ?? "")?.layout.anchor ?? "bottom-center";
3538
- if (barH) {
3539
- if (statusBarSide === "top" && anchor.startsWith("top")) v.y += barH;
3540
- else if (statusBarSide === "bottom" && anchor.startsWith("bottom")) v.y -= barH;
3541
- }
3542
3448
  this.slideBaseY.set(v, v.y);
3543
3449
  this.slideSign.set(v, anchor.startsWith("top") ? -1 : 1);
3544
3450
  }
@@ -3951,7 +3857,7 @@ function mountHud(app, spec = {}, opts = {}) {
3951
3857
  if (menu && spec.game && (spec.game.name || spec.game.version)) {
3952
3858
  menu.push({ kind: "legal", id: "openui-game-info", text: [spec.game.name, spec.game.version ? `v${spec.game.version}` : ""].filter(Boolean).join(" \xB7 ") });
3953
3859
  }
3954
- const pixi = new OpenUIPixi(ui, { ...pixiOpts, menu, statusBar: pixiOpts.statusBar ?? spec.statusBar });
3860
+ const pixi = new OpenUIPixi(ui, { ...pixiOpts, menu });
3955
3861
  pixi.mount(app);
3956
3862
  const extra = [];
3957
3863
  if (spec.panels?.length) {
@@ -4009,7 +3915,7 @@ function mountHud(app, spec = {}, opts = {}) {
4009
3915
  ui.showNotice(
4010
3916
  [
4011
3917
  { kind: "heading", id: "buy-title", text: o.title ?? "openui.buyFeature.title" },
4012
- { kind: "callout", id: "buy-body", tone: "bonus", text: o.message ?? "openui.buyFeature.message" }
3918
+ { kind: "text", id: "buy-body", text: o.message ?? "openui.buyFeature.message" }
4013
3919
  ],
4014
3920
  [
4015
3921
  { label: o.cancelLabel ?? "openui.cancel", variant: "secondary" },
@@ -4071,7 +3977,6 @@ exports.ReadoutView = ReadoutView;
4071
3977
  exports.SelectView = SelectView;
4072
3978
  exports.SliderView = SliderView;
4073
3979
  exports.SpinView = SpinView;
4074
- exports.StatusBarView = StatusBarView;
4075
3980
  exports.StepperView = StepperView;
4076
3981
  exports.TextCellRenderer = TextCellRenderer;
4077
3982
  exports.ToggleView = ToggleView;