@open-slot-ui/pixi 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1333,6 +1333,7 @@ var ValueDisplayView = class extends ControlView {
1333
1333
  super.dispose();
1334
1334
  }
1335
1335
  };
1336
+ var TAP_SLOP = 24;
1336
1337
  var GLYPH_SVG = {
1337
1338
  speaker: '<svg viewBox="0 0 22.5 22.5" xmlns="http://www.w3.org/2000/svg"><path d="M13.6745 5.01252C13.9316 4.84399 14.2647 4.8292 14.5397 4.97456C14.8146 5.1199 14.9868 5.40142 14.9872 5.706L15.0007 16.8107C15.0011 17.1153 14.8296 17.3934 14.555 17.5333C14.2804 17.6731 13.9472 17.6517 13.6897 17.4781L10.4454 15.2905L8.61605 15.2722C6.76074 15.2537 5.25495 13.7655 5.25266 11.9484L5.25073 10.3739C5.2486 8.55679 6.75081 7.09863 8.6061 7.11714L10.4355 7.13539L13.6745 5.01252Z" fill="none" stroke="black" stroke-width="1.5" stroke-linejoin="round"/><path d="M16.1933 9.375C16.6252 10.4652 16.6015 11.654 16.1257 12.75" fill="none" stroke="black" stroke-width="3" stroke-linecap="round"/></svg>',
1338
1339
  "speaker-mute": '<svg viewBox="0 0 22.5 22.5" xmlns="http://www.w3.org/2000/svg"><path d="M13.6745 5.01252C13.9316 4.84399 14.2647 4.8292 14.5397 4.97456C14.8146 5.1199 14.9868 5.40142 14.9872 5.706L15.0007 16.8107C15.0011 17.1153 14.8296 17.3934 14.555 17.5333C14.2804 17.6731 13.9472 17.6517 13.6897 17.4781L10.4454 15.2905L8.61605 15.2722C6.76074 15.2537 5.25495 13.7655 5.25266 11.9484L5.25073 10.3739C5.2486 8.55679 6.75081 7.09863 8.6061 7.11714L10.4355 7.13539L13.6745 5.01252Z" fill="none" stroke="black" stroke-width="1.5" stroke-linejoin="round"/><path d="M15.5 8.5L19.5 13.5M19.5 8.5L15.5 13.5" fill="none" stroke="black" stroke-width="1.8" stroke-linecap="round"/></svg>',
@@ -1430,17 +1431,26 @@ var ButtonView = class extends ControlView {
1430
1431
  this.sprite.scale.set(1);
1431
1432
  this.sprite.scale.set(this.iconTarget / this.sprite.height);
1432
1433
  }
1433
- onDown = () => {
1434
- if (this.btn.interactable) this.btn.setState("pressed");
1434
+ /** Screen position of the current press, for the tap-slop check on release. */
1435
+ downPt = null;
1436
+ onDown = (e) => {
1437
+ if (!this.btn.interactable) return;
1438
+ this.btn.setState("pressed");
1439
+ this.downPt = { x: e.global.x, y: e.global.y };
1435
1440
  };
1436
1441
  onUp = () => {
1437
1442
  if (this.btn.current === "pressed") {
1438
1443
  this.btn.setState("idle");
1439
1444
  this.btn.activate();
1440
1445
  }
1446
+ this.downPt = null;
1441
1447
  };
1442
- onUpOutside = () => {
1443
- if (this.btn.current === "pressed") this.btn.setState("idle");
1448
+ onUpOutside = (e) => {
1449
+ const p = this.downPt;
1450
+ this.downPt = null;
1451
+ if (this.btn.current !== "pressed") return;
1452
+ this.btn.setState("idle");
1453
+ if (p && Math.hypot(e.global.x - p.x, e.global.y - p.y) <= TAP_SLOP) this.btn.activate();
1444
1454
  };
1445
1455
  updateHit() {
1446
1456
  if (this.sprite) {
@@ -3985,6 +3995,30 @@ var PanelBodyView = class extends ControlView {
3985
3995
  super.dispose();
3986
3996
  }
3987
3997
  };
3998
+ function showReplayModal(ui, info, buttonKey, onSelect) {
3999
+ const cur = info.currency ?? ui.balance.currency.get();
4000
+ const money = (n) => core.formatAmount(n, cur);
4001
+ ui.showNotice(
4002
+ [
4003
+ { kind: "heading", id: "openui-replay-h", text: "openui.replay.title" },
4004
+ {
4005
+ kind: "stat-grid",
4006
+ id: "openui-replay-g",
4007
+ items: [
4008
+ { label: "openui.replay.baseBet", value: money(info.baseBet) },
4009
+ { label: "openui.replay.costMultiplier", value: `${info.costMultiplier}\xD7` },
4010
+ { label: "openui.replay.payoutMultiplier", value: `${info.payoutMultiplier}\xD7` },
4011
+ { label: "openui.replay.amount", value: money(info.amount) }
4012
+ ]
4013
+ }
4014
+ ],
4015
+ [{ label: buttonKey, variant: "primary", onSelect: () => {
4016
+ ui.hideNotice();
4017
+ onSelect();
4018
+ } }],
4019
+ { blocking: true }
4020
+ );
4021
+ }
3988
4022
  function mountHud(app, spec = {}, opts = {}) {
3989
4023
  const { hooks, ...pixiOpts } = opts;
3990
4024
  const ui = core.createUI(spec, hooks);
@@ -4050,30 +4084,10 @@ function mountHud(app, spec = {}, opts = {}) {
4050
4084
  setReplay: (on2) => ui.setReplay(on2),
4051
4085
  replayStart: (info, onPlay) => {
4052
4086
  ui.setReplay(true);
4053
- const cur = info.currency ?? ui.balance.currency.get();
4054
- const money = (n) => core.formatAmount(n, cur);
4055
- ui.showNotice(
4056
- [
4057
- { kind: "heading", id: "openui-replay-h", text: "openui.replay.title" },
4058
- {
4059
- kind: "stat-grid",
4060
- id: "openui-replay-g",
4061
- items: [
4062
- { label: "openui.replay.baseBet", value: money(info.baseBet) },
4063
- { label: "openui.replay.costMultiplier", value: `${info.costMultiplier}\xD7` },
4064
- { label: "openui.replay.payoutMultiplier", value: `${info.payoutMultiplier}\xD7` },
4065
- { label: "openui.replay.amount", value: money(info.amount) }
4066
- ]
4067
- }
4068
- ],
4069
- [{ label: "openui.replay.play", variant: "primary", onSelect: onPlay }]
4070
- );
4087
+ showReplayModal(ui, info, "openui.replay.play", () => onPlay?.());
4071
4088
  },
4072
- replayEnd: (onReplay) => {
4073
- ui.showNotice(
4074
- [{ kind: "heading", id: "openui-replay-end", text: "openui.replay.title" }],
4075
- [{ label: "openui.replay.again", variant: "primary", onSelect: onReplay }]
4076
- );
4089
+ replayEnd: (info, onReplay) => {
4090
+ showReplayModal(ui, info, "openui.replay.again", onReplay);
4077
4091
  },
4078
4092
  confirmBuy: (o) => {
4079
4093
  if (ui.isDisabled("buyFeature")) return;