@open-slot-ui/pixi 0.8.2 → 0.8.3
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 +85 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +85 -68
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4269,6 +4269,63 @@ var OHM_CSS = `
|
|
|
4269
4269
|
.ohm-group { margin: 8px 0; }
|
|
4270
4270
|
`;
|
|
4271
4271
|
|
|
4272
|
+
// src/confirmModal.ts
|
|
4273
|
+
var esc2 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
4274
|
+
function showConfirm(ui, opts) {
|
|
4275
|
+
return new Promise((resolve) => {
|
|
4276
|
+
const host2 = document.createElement("div");
|
|
4277
|
+
host2.className = "osc-confirm";
|
|
4278
|
+
host2.style.setProperty("--font", ui.theme.type.family);
|
|
4279
|
+
const title = ui.t(opts.title ?? "Buy Feature");
|
|
4280
|
+
const yes = ui.t(opts.confirmLabel ?? "openui.confirm");
|
|
4281
|
+
const no = ui.t(opts.cancelLabel ?? "openui.cancel");
|
|
4282
|
+
host2.innerHTML = `
|
|
4283
|
+
<div class="osc-confirm-backdrop" data-no></div>
|
|
4284
|
+
<div class="osc-confirm-card" role="dialog" aria-modal="true">
|
|
4285
|
+
${title ? `<h3 class="osc-confirm-title">${esc2(title)}</h3>` : ""}
|
|
4286
|
+
<p class="osc-confirm-msg">${esc2(opts.message)}</p>
|
|
4287
|
+
<div class="osc-confirm-row">
|
|
4288
|
+
<button class="osc-confirm-btn osc-confirm-no" data-no>${esc2(no)}</button>
|
|
4289
|
+
<button class="osc-confirm-btn osc-confirm-yes" data-yes>${esc2(yes)}</button>
|
|
4290
|
+
</div>
|
|
4291
|
+
</div>`;
|
|
4292
|
+
const style = document.createElement("style");
|
|
4293
|
+
style.textContent = CONFIRM_CSS;
|
|
4294
|
+
host2.appendChild(style);
|
|
4295
|
+
document.body.appendChild(host2);
|
|
4296
|
+
let settled = false;
|
|
4297
|
+
const close = (val) => {
|
|
4298
|
+
if (settled) return;
|
|
4299
|
+
settled = true;
|
|
4300
|
+
window.removeEventListener("keydown", onKey);
|
|
4301
|
+
host2.remove();
|
|
4302
|
+
resolve(val);
|
|
4303
|
+
};
|
|
4304
|
+
const onKey = (e) => {
|
|
4305
|
+
if (e.key === "Escape") close(false);
|
|
4306
|
+
else if (e.key === "Enter") close(true);
|
|
4307
|
+
};
|
|
4308
|
+
host2.querySelectorAll("[data-no]").forEach((b) => b.addEventListener("click", () => close(false)));
|
|
4309
|
+
host2.querySelector("[data-yes]")?.addEventListener("click", () => close(true));
|
|
4310
|
+
window.addEventListener("keydown", onKey);
|
|
4311
|
+
});
|
|
4312
|
+
}
|
|
4313
|
+
var CONFIRM_CSS = `
|
|
4314
|
+
.osc-confirm { position: fixed; inset: 0; z-index: 12000; display: grid; place-items: center; font-family: var(--font); }
|
|
4315
|
+
.osc-confirm *, .osc-confirm *::before, .osc-confirm *::after { box-sizing: border-box; }
|
|
4316
|
+
.osc-confirm-backdrop { position: absolute; inset: 0; background: rgba(8,6,4,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
|
|
4317
|
+
.osc-confirm-card { position: relative; width: min(90vw, 420px); background: #ffffff; color: #181b20; border: 3px solid #000; border-radius: 14px; padding: 24px; box-shadow: 0 24px 60px rgba(0,0,0,.55); text-align: center; }
|
|
4318
|
+
.osc-confirm-title { margin: 0 0 12px; font-size: 22px; font-weight: 800; letter-spacing: .3px; }
|
|
4319
|
+
.osc-confirm-msg { margin: 0 0 22px; font-size: 19px; font-weight: 700; line-height: 1.4; }
|
|
4320
|
+
.osc-confirm-row { display: flex; gap: 14px; }
|
|
4321
|
+
.osc-confirm-btn { flex: 1; padding: 14px 10px; border-radius: 12px; border: 3px solid #000; font-size: 15px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; cursor: pointer; transition: transform .1s, background .12s; }
|
|
4322
|
+
.osc-confirm-btn:active { transform: scale(.96); }
|
|
4323
|
+
.osc-confirm-no { background: #ffffff; color: #181b20; }
|
|
4324
|
+
.osc-confirm-no:hover { background: #eef1f6; }
|
|
4325
|
+
.osc-confirm-yes { background: #d99000; color: #1a1200; }
|
|
4326
|
+
.osc-confirm-yes:hover { filter: brightness(1.05); }
|
|
4327
|
+
`;
|
|
4328
|
+
|
|
4272
4329
|
// src/mountHud.ts
|
|
4273
4330
|
function showReplayModal(ui, info, buttonKey, onSelect) {
|
|
4274
4331
|
const cur = info.currency ?? ui.balance.currency.get();
|
|
@@ -4387,17 +4444,15 @@ function mountHud(app, spec = {}, opts = {}) {
|
|
|
4387
4444
|
o.onConfirm();
|
|
4388
4445
|
return;
|
|
4389
4446
|
}
|
|
4390
|
-
const message = o.message ?? (o.name ? ui.t("openui.buyFeature.confirm", { name: ui.t(o.name), price: o.price ?? "" }) : "openui.buyFeature.message");
|
|
4391
|
-
ui
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
]
|
|
4400
|
-
);
|
|
4447
|
+
const message = o.message ?? (o.name ? ui.t("openui.buyFeature.confirm", { name: ui.t(o.name), price: o.price ?? "" }) : ui.t("openui.buyFeature.message"));
|
|
4448
|
+
void showConfirm(ui, {
|
|
4449
|
+
title: o.title ?? "openui.buyFeature.title",
|
|
4450
|
+
message,
|
|
4451
|
+
confirmLabel: o.confirmLabel,
|
|
4452
|
+
cancelLabel: o.cancelLabel
|
|
4453
|
+
}).then((ok) => {
|
|
4454
|
+
if (ok) o.onConfirm();
|
|
4455
|
+
});
|
|
4401
4456
|
},
|
|
4402
4457
|
showControls: () => pixi.setControlsVisible(true),
|
|
4403
4458
|
hideControls: () => pixi.setControlsVisible(false),
|
|
@@ -4414,7 +4469,7 @@ function mountHud(app, spec = {}, opts = {}) {
|
|
|
4414
4469
|
function money(amount, cur) {
|
|
4415
4470
|
return core.formatAmount(amount, cur);
|
|
4416
4471
|
}
|
|
4417
|
-
var
|
|
4472
|
+
var esc3 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
4418
4473
|
function mountBuyFeatureModal(_app, hud, features, opts = {}) {
|
|
4419
4474
|
const ui = hud.ui;
|
|
4420
4475
|
const tr = (k) => ui.t(k);
|
|
@@ -4440,23 +4495,14 @@ function mountBuyFeatureModal(_app, hud, features, opts = {}) {
|
|
|
4440
4495
|
<button class="bfm-x" data-close aria-label="Close">\u2715</button>
|
|
4441
4496
|
<div class="bfm-panel" role="dialog" aria-modal="true">
|
|
4442
4497
|
<div class="bfm-fit" id="bfm-fit">
|
|
4443
|
-
<h2 class="bfm-title" data-t="Buy Feature">${
|
|
4498
|
+
<h2 class="bfm-title" data-t="Buy Feature">${esc3(tr("Buy Feature"))}</h2>
|
|
4444
4499
|
<div class="bfm-bet">
|
|
4445
4500
|
<button class="bfm-step" id="bfm-minus" aria-label="Decrease">\u2212</button>
|
|
4446
|
-
<div class="bfm-betbox"><span class="bfm-betlabel" data-t="Bet">${
|
|
4501
|
+
<div class="bfm-betbox"><span class="bfm-betlabel" data-t="Bet">${esc3(tr("Bet"))}</span><b id="bfm-betval">\u2014</b></div>
|
|
4447
4502
|
<button class="bfm-step" id="bfm-plus" aria-label="Increase">+</button>
|
|
4448
4503
|
</div>
|
|
4449
4504
|
<div class="bfm-cards" id="bfm-cards"></div>
|
|
4450
4505
|
</div>
|
|
4451
|
-
</div>
|
|
4452
|
-
<div class="bfm-confirm" id="bfm-confirm">
|
|
4453
|
-
<div class="bfm-confirm-card">
|
|
4454
|
-
<p class="bfm-confirm-msg" id="bfm-confirm-msg"></p>
|
|
4455
|
-
<div class="bfm-confirm-row">
|
|
4456
|
-
<button class="bfm-confirm-btn bfm-confirm-no" id="bfm-confirm-no" data-t="openui.cancel">${esc2(tr("openui.cancel"))}</button>
|
|
4457
|
-
<button class="bfm-confirm-btn bfm-confirm-yes" id="bfm-confirm-yes" data-t="openui.confirm">${esc2(tr("openui.confirm"))}</button>
|
|
4458
|
-
</div>
|
|
4459
|
-
</div>
|
|
4460
4506
|
</div>`;
|
|
4461
4507
|
const style = document.createElement("style");
|
|
4462
4508
|
style.textContent = BFM_CSS;
|
|
@@ -4467,29 +4513,11 @@ function mountBuyFeatureModal(_app, hud, features, opts = {}) {
|
|
|
4467
4513
|
const fitEl = $("#bfm-fit");
|
|
4468
4514
|
const cardsEl = $("#bfm-cards");
|
|
4469
4515
|
const betValEl = $("#bfm-betval");
|
|
4470
|
-
const
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
const hideConfirm = () => {
|
|
4476
|
-
confirmEl.classList.remove("show");
|
|
4477
|
-
pendingConfirm = null;
|
|
4478
|
-
};
|
|
4479
|
-
confirmNo.addEventListener("click", hideConfirm);
|
|
4480
|
-
confirmYes.addEventListener("click", () => {
|
|
4481
|
-
const fn = pendingConfirm;
|
|
4482
|
-
hideConfirm();
|
|
4483
|
-
fn?.();
|
|
4484
|
-
});
|
|
4485
|
-
const askConfirm = (totalCost, name, price, onYes) => {
|
|
4486
|
-
if (!hud.shouldConfirmBuy(totalCost)) {
|
|
4487
|
-
onYes();
|
|
4488
|
-
return;
|
|
4489
|
-
}
|
|
4490
|
-
confirmMsg.textContent = ui.t("openui.buyFeature.confirm", { name: ui.t(name), price });
|
|
4491
|
-
pendingConfirm = onYes;
|
|
4492
|
-
confirmEl.classList.add("show");
|
|
4516
|
+
const askConfirm = (name, price, onYes) => {
|
|
4517
|
+
const message = ui.t("openui.buyFeature.confirm", { name: ui.t(name), price });
|
|
4518
|
+
void showConfirm(ui, { title: "Buy Feature", message }).then((ok) => {
|
|
4519
|
+
if (ok) onYes();
|
|
4520
|
+
});
|
|
4493
4521
|
};
|
|
4494
4522
|
const layout = () => {
|
|
4495
4523
|
const vw = window.innerWidth;
|
|
@@ -4521,11 +4549,11 @@ function mountBuyFeatureModal(_app, hud, features, opts = {}) {
|
|
|
4521
4549
|
<div class="bfm-cardimg"${img}></div>
|
|
4522
4550
|
<div class="bfm-strip"></div>
|
|
4523
4551
|
<div class="bfm-cardbody">
|
|
4524
|
-
<span class="bfm-name">${
|
|
4525
|
-
<b class="bfm-price">${
|
|
4552
|
+
<span class="bfm-name">${esc3(tr(f.name))}</span>
|
|
4553
|
+
<b class="bfm-price">${esc3(price)}</b>
|
|
4526
4554
|
</div>
|
|
4527
4555
|
</div>
|
|
4528
|
-
<button class="${cls}" data-id="${f.id}" data-variant="${f.variant}"${buyBlocked ? " disabled" : ""}>${
|
|
4556
|
+
<button class="${cls}" data-id="${f.id}" data-variant="${f.variant}"${buyBlocked ? " disabled" : ""}>${esc3(label)}</button>
|
|
4529
4557
|
</div>`;
|
|
4530
4558
|
}).join("");
|
|
4531
4559
|
betValEl.textContent = money(bet, cur);
|
|
@@ -4553,11 +4581,11 @@ function mountBuyFeatureModal(_app, hud, features, opts = {}) {
|
|
|
4553
4581
|
return;
|
|
4554
4582
|
}
|
|
4555
4583
|
const total = 1 + (f?.cost ?? 0);
|
|
4556
|
-
askConfirm(
|
|
4584
|
+
askConfirm(f?.name ?? id, money(total * bet, cur), commit);
|
|
4557
4585
|
} else {
|
|
4558
4586
|
if (blocksBuy && boosts.size > 0) return;
|
|
4559
4587
|
const cost = (f?.cost ?? 0) * bet;
|
|
4560
|
-
askConfirm(f?.
|
|
4588
|
+
askConfirm(f?.name ?? id, money(cost, cur), () => {
|
|
4561
4589
|
ui.bus.emit("cardActivated", { id });
|
|
4562
4590
|
close();
|
|
4563
4591
|
opts.onBuy?.(id, cost);
|
|
@@ -4626,22 +4654,11 @@ var BFM_CSS = `
|
|
|
4626
4654
|
.bfm-action.is-active { background: var(--accent); color: var(--accent-text); border-color: #000; }
|
|
4627
4655
|
.bfm-action.is-blocked, .bfm-action:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
|
|
4628
4656
|
.bfm-action.is-blocked:hover, .bfm-action:disabled:hover { background: var(--surface); }
|
|
4629
|
-
.bfm-confirm { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .16s ease; }
|
|
4630
|
-
.bfm-confirm.show { opacity: 1; pointer-events: auto; }
|
|
4631
|
-
.bfm-confirm::before { content: ""; position: absolute; inset: 0; background: rgba(8,6,4,.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
|
|
4632
|
-
.bfm-confirm-card { position: relative; width: min(90%, 420px); background: var(--surface); color: var(--text); border: 3px solid #000; border-radius: 14px; padding: 26px 24px 22px; box-shadow: 0 24px 60px rgba(0,0,0,.55); text-align: center; }
|
|
4633
|
-
.bfm-confirm-msg { margin: 0 0 22px; font-size: 19px; font-weight: 700; line-height: 1.4; color: var(--text); }
|
|
4634
|
-
.bfm-confirm-row { display: flex; gap: 14px; }
|
|
4635
|
-
.bfm-confirm-btn { flex: 1; padding: 14px 10px; border-radius: 12px; border: 3px solid #000; font-size: 15px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; cursor: pointer; transition: transform .1s, background .12s; }
|
|
4636
|
-
.bfm-confirm-btn:active { transform: scale(.96); }
|
|
4637
|
-
.bfm-confirm-no { background: var(--surface); color: var(--text); }
|
|
4638
|
-
.bfm-confirm-no:hover { background: var(--surface-alt); }
|
|
4639
|
-
.bfm-confirm-yes { background: var(--accent); color: var(--accent-text); }
|
|
4640
4657
|
`;
|
|
4641
4658
|
|
|
4642
4659
|
// src/bootError.ts
|
|
4643
4660
|
var host = null;
|
|
4644
|
-
var
|
|
4661
|
+
var esc4 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
4645
4662
|
function showBootError(opts = {}) {
|
|
4646
4663
|
const title = opts.title ?? "Connection lost";
|
|
4647
4664
|
const message = opts.message ?? "The game could not reach the game server. Please reload to reconnect and continue.";
|
|
@@ -4655,10 +4672,10 @@ function showBootError(opts = {}) {
|
|
|
4655
4672
|
<div class="openui-be-icon" aria-hidden="true">
|
|
4656
4673
|
<svg viewBox="0 0 48 48" width="48" height="48"><path d="M24 4 3 42h42L24 4Z" fill="none" stroke="#ffc935" stroke-width="3" stroke-linejoin="round"/><rect x="22" y="18" width="4" height="12" rx="2" fill="#ffc935"/><circle cx="24" cy="35" r="2.4" fill="#ffc935"/></svg>
|
|
4657
4674
|
</div>
|
|
4658
|
-
<h1 class="openui-be-title">${
|
|
4659
|
-
<p class="openui-be-msg">${
|
|
4660
|
-
${opts.detail ? `<p class="openui-be-detail">${
|
|
4661
|
-
${showReload ? `<button class="openui-be-reload" type="button">${
|
|
4675
|
+
<h1 class="openui-be-title">${esc4(title)}</h1>
|
|
4676
|
+
<p class="openui-be-msg">${esc4(message)}</p>
|
|
4677
|
+
${opts.detail ? `<p class="openui-be-detail">${esc4(opts.detail)}</p>` : ""}
|
|
4678
|
+
${showReload ? `<button class="openui-be-reload" type="button">${esc4(opts.reloadLabel ?? "Reload")}</button>` : ""}
|
|
4662
4679
|
</div>
|
|
4663
4680
|
<style>
|
|
4664
4681
|
.openui-boot-error { position: fixed; inset: 0; z-index: 2147483000; display: grid; place-items: center;
|
|
@@ -4742,6 +4759,7 @@ exports.mountBuyFeatureModal = mountBuyFeatureModal;
|
|
|
4742
4759
|
exports.mountHud = mountHud;
|
|
4743
4760
|
exports.mountInfoMenu = mountInfoMenu;
|
|
4744
4761
|
exports.showBootError = showBootError;
|
|
4762
|
+
exports.showConfirm = showConfirm;
|
|
4745
4763
|
exports.svgSpinSkin = svgSpinSkin;
|
|
4746
4764
|
//# sourceMappingURL=index.cjs.map
|
|
4747
4765
|
//# sourceMappingURL=index.cjs.map
|