@energy8platform/shell 0.3.0 → 0.4.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/dist/pixi.cjs.js CHANGED
@@ -1168,8 +1168,31 @@ const DISCLAIMER_LOCALES = {
1168
1168
  [D.L5]: '奖金根据从 Remote Game Server 收到的金额结算,而非依据网页浏览器内的事件。',
1169
1169
  },
1170
1170
  };
1171
- /** Merge the base UI catalog with the separately-authored disclaimer lines, per language. */
1172
- const LOCALES = Object.fromEntries(Object.keys(BASE_LOCALES).map((l) => [l, { ...BASE_LOCALES[l], ...DISCLAIMER_LOCALES[l] }]));
1171
+ // ── Replay summary labels ──────────────────────────────────────────────────────────────────────
1172
+ // The replay modal (html + pixi) renders these row labels via host.t(); grouped here (merged into
1173
+ // LOCALES below) so the whole replay screen localizes. Terminology matches the base Bet/Win keys.
1174
+ const REPLAY_LOCALES = {
1175
+ da: { Mode: 'Tilstand', 'Base bet': 'Grundindsats', 'Cost multiplier': 'Omkostningsmultiplikator', 'Total cost': 'Samlede omkostninger', 'Win multiplier': 'Gevinstmultiplikator' },
1176
+ de: { Mode: 'Modus', 'Base bet': 'Grundeinsatz', 'Cost multiplier': 'Kostenmultiplikator', 'Total cost': 'Gesamtkosten', 'Win multiplier': 'Gewinnmultiplikator' },
1177
+ es: { Mode: 'Modo', 'Base bet': 'Apuesta base', 'Cost multiplier': 'Multiplicador de coste', 'Total cost': 'Coste total', 'Win multiplier': 'Multiplicador de premio' },
1178
+ fi: { Mode: 'Tila', 'Base bet': 'Peruspanos', 'Cost multiplier': 'Kustannuskerroin', 'Total cost': 'Kokonaiskustannus', 'Win multiplier': 'Voittokerroin' },
1179
+ fr: { Mode: 'Mode', 'Base bet': 'Mise de base', 'Cost multiplier': 'Multiplicateur de coût', 'Total cost': 'Coût total', 'Win multiplier': 'Multiplicateur de gain' },
1180
+ hi: { Mode: 'मोड', 'Base bet': 'आधार दांव', 'Cost multiplier': 'लागत गुणक', 'Total cost': 'कुल लागत', 'Win multiplier': 'जीत गुणक' },
1181
+ id: { Mode: 'Mode', 'Base bet': 'Taruhan dasar', 'Cost multiplier': 'Pengganda biaya', 'Total cost': 'Total biaya', 'Win multiplier': 'Pengganda kemenangan' },
1182
+ ja: { Mode: 'モード', 'Base bet': '基本ベット', 'Cost multiplier': 'コスト倍率', 'Total cost': '合計コスト', 'Win multiplier': '当選倍率' },
1183
+ ko: { Mode: '모드', 'Base bet': '기본 베팅', 'Cost multiplier': '비용 배수', 'Total cost': '총 비용', 'Win multiplier': '당첨 배수' },
1184
+ pl: { Mode: 'Tryb', 'Base bet': 'Zakład podstawowy', 'Cost multiplier': 'Mnożnik kosztu', 'Total cost': 'Całkowity koszt', 'Win multiplier': 'Mnożnik wygranej' },
1185
+ pt: { Mode: 'Modo', 'Base bet': 'Aposta base', 'Cost multiplier': 'Multiplicador de custo', 'Total cost': 'Custo total', 'Win multiplier': 'Multiplicador de ganho' },
1186
+ ru: { Mode: 'Режим', 'Base bet': 'Базовая ставка', 'Cost multiplier': 'Множитель стоимости', 'Total cost': 'Общая стоимость', 'Win multiplier': 'Множитель выигрыша' },
1187
+ tr: { Mode: 'Mod', 'Base bet': 'Temel bahis', 'Cost multiplier': 'Maliyet çarpanı', 'Total cost': 'Toplam maliyet', 'Win multiplier': 'Kazanç çarpanı' },
1188
+ vi: { Mode: 'Chế độ', 'Base bet': 'Cược cơ bản', 'Cost multiplier': 'Hệ số chi phí', 'Total cost': 'Tổng chi phí', 'Win multiplier': 'Hệ số thắng' },
1189
+ zh: { Mode: '模式', 'Base bet': '基础投注', 'Cost multiplier': '成本倍数', 'Total cost': '总成本', 'Win multiplier': '奖金倍数' },
1190
+ };
1191
+ /** Merge the base UI catalog with the separately-authored disclaimer + replay lines, per language. */
1192
+ const LOCALES = Object.fromEntries(Object.keys(BASE_LOCALES).map((l) => [
1193
+ l,
1194
+ { ...BASE_LOCALES[l], ...DISCLAIMER_LOCALES[l], ...REPLAY_LOCALES[l] },
1195
+ ]));
1173
1196
 
1174
1197
  // Social-casino language. English is the source (and, for now, the only) language; `socialize`
1175
1198
  // rewrites the restricted gambling vocabulary into social-safe phrasing while preserving case.
@@ -1416,7 +1439,7 @@ class KeyboardController {
1416
1439
 
1417
1440
  // AUTO-GENERATED by scripts/gen-version.mjs — do not edit. Mirrors package.json "version".
1418
1441
  /** The @energy8platform/shell package version, stamped into the game-info footer. */
1419
- const PACKAGE_VERSION = '0.3.0';
1442
+ const PACKAGE_VERSION = '0.4.1';
1420
1443
 
1421
1444
  /** Apply defaults to the raw config (the mount target lives on the renderer, not here). */
1422
1445
  function resolveConfig(config) {
@@ -4058,28 +4081,69 @@ function sectionHotkeys(host, title, width) {
4058
4081
  visible.forEach((r, i) => {
4059
4082
  if (i > 0)
4060
4083
  sec.add(hairline$1(host, inner));
4061
- sec.add(hkRow(host, r));
4084
+ sec.add(hkRow(host, r, inner));
4062
4085
  });
4063
4086
  return sec;
4064
4087
  }
4065
- /** Render a single hotkey row: keycap chip(s) on the left, action name on the right. */
4088
+ /** Render a single hotkey row: keycap chip(s) on the left, action name on the right. The row is
4089
+ * constrained to `inner` (chips left, label right). On narrow widths the chip combos stack onto
4090
+ * their own lines and the label wraps within the leftover width, so nothing clips past the plaque
4091
+ * — the Pixi analogue of the HTML `.ge-gi-hk-chips { flex:0 1 auto; flex-wrap }` + label wrap. */
4066
4092
  function hkRow(host, r, inner) {
4067
- const row = new FlexBox({ direction: 'row', align: 'center', gap: 14, padding: { top: 8, bottom: 8 } });
4068
- // Build chips container
4069
- const chipsCol = new FlexBox({ direction: 'row', align: 'center', gap: 4 });
4093
+ const GAP = 14;
4094
+ const LABEL_MIN = 92; // reserve at least this much for the action label before wrapping the chips
4070
4095
  const chipKeys = buildChipKeys(r);
4096
+ // Lay the chips on one line and measure. If that leaves too little room for the label, stack the
4097
+ // combos (split at the '/') onto their own lines so the chips give up horizontal width.
4098
+ let chips = chipLine(host, chipKeys);
4099
+ let chipsW = chips.measureSize().w;
4100
+ if (chipsW > inner - GAP - LABEL_MIN) {
4101
+ chips = chipCombos(host, chipKeys);
4102
+ chipsW = chips.measureSize().w;
4103
+ }
4104
+ // The label takes the leftover width and WRAPS within it (never clips); right-aligned to sit
4105
+ // against the plaque edge like the DOM `.ge-gi-hk-tx`.
4106
+ const labelW = Math.max(LABEL_MIN, inner - chipsW - GAP);
4107
+ const nameText = makeText(host.t(r.name), { size: 15, weight: '700', color: '#ffffff', wrapWidth: labelW, align: 'right' });
4108
+ const row = new FlexBox({ direction: 'row', align: 'center', justify: 'space-between', gap: GAP, padding: { top: 8, bottom: 8 }, width: inner });
4109
+ row.add(chips);
4110
+ row.add(nameText);
4111
+ return row;
4112
+ }
4113
+ /** Chips on a single row, with '/' separators between the combos (as flattened by buildChipKeys). */
4114
+ function chipLine(host, chipKeys) {
4115
+ const line = new FlexBox({ direction: 'row', align: 'center', gap: 4 });
4116
+ for (const key of chipKeys) {
4117
+ if (key === '/')
4118
+ line.add(makeText('/', { size: 12, weight: '500', color: host.tokens.plaqueLabel }));
4119
+ else
4120
+ line.add(keycap(host, key));
4121
+ }
4122
+ return line;
4123
+ }
4124
+ /** Chips stacked as combos — split at the '/' separators, one combo per line (drops the inline
4125
+ * '/', which reads as a line break once the combos are stacked). */
4126
+ function chipCombos(host, chipKeys) {
4127
+ const col = new FlexBox({ direction: 'column', align: 'start', gap: 4 });
4128
+ let line = new FlexBox({ direction: 'row', align: 'center', gap: 4 });
4129
+ let filled = false;
4130
+ const flush = () => {
4131
+ if (!filled)
4132
+ return;
4133
+ col.add(line);
4134
+ line = new FlexBox({ direction: 'row', align: 'center', gap: 4 });
4135
+ filled = false;
4136
+ };
4071
4137
  for (const key of chipKeys) {
4072
4138
  if (key === '/') {
4073
- chipsCol.add(makeText('/', { size: 12, weight: '500', color: host.tokens.plaqueLabel }));
4074
- }
4075
- else {
4076
- chipsCol.add(keycap(host, key));
4139
+ flush();
4140
+ continue;
4077
4141
  }
4142
+ line.add(keycap(host, key));
4143
+ filled = true;
4078
4144
  }
4079
- const nameText = makeText(host.t(r.name), { size: 15, weight: '700', color: '#ffffff' });
4080
- row.add(chipsCol);
4081
- row.add(nameText);
4082
- return row;
4145
+ flush();
4146
+ return col;
4083
4147
  }
4084
4148
  /** Flatten a row's chip list into display tokens — for bet rows, produce: Shift ↑ / Shift = style. */
4085
4149
  function buildChipKeys(r) {
@@ -5245,8 +5309,27 @@ class PickerModal extends CardModal {
5245
5309
  }
5246
5310
  }
5247
5311
  /** A centred picker (chips grid + accent Confirm) on the shared card modal. */
5312
+ /** A ScrollBox that reports a fixed box to the FlexBox layout — so a capped, scrolling grid slots
5313
+ * into the card body like any other sized child (measured/positioned by its viewport, not its
5314
+ * full content bounds). */
5315
+ class SizedScrollBox extends ScrollBox {
5316
+ boxW;
5317
+ boxH;
5318
+ constructor(boxW, boxH, canvas) {
5319
+ super(canvas);
5320
+ this.boxW = boxW;
5321
+ this.boxH = boxH;
5322
+ this.setViewport(boxW, boxH);
5323
+ }
5324
+ measureSize() {
5325
+ return { w: this.boxW, h: this.boxH };
5326
+ }
5327
+ setLayoutSize() {
5328
+ /* fixed viewport — ignore layout-imposed sizing */
5329
+ }
5330
+ }
5248
5331
  function buildSheet(host, opts) {
5249
- const columns = typeof opts.columns === 'number'
5332
+ const maxColumns = typeof opts.columns === 'number'
5250
5333
  ? opts.columns
5251
5334
  : host.layout === 'mobile' ? opts.columns.mobile : opts.columns.wide;
5252
5335
  let selected = opts.selected;
@@ -5298,27 +5381,51 @@ function buildSheet(host, opts) {
5298
5381
  const em = modal.emSize;
5299
5382
  const gap = 0.65 * em;
5300
5383
  const innerW = modal.cardWidth - 2.4 * em;
5384
+ // Build the chips first (at natural width) so autoFit can measure the widest label.
5385
+ for (let i = 0; i < opts.choices.length; i++) {
5386
+ const c = opts.choices[i];
5387
+ const chipIndex = i;
5388
+ chips.push(new Chip(host, c.id, c.label, chipIndex === focusIndex, em, (id) => {
5389
+ const idx = opts.choices.findIndex((ch) => ch.id === id);
5390
+ if (idx >= 0)
5391
+ setHighlight(idx);
5392
+ }));
5393
+ }
5394
+ // Column count: with autoFit, drop below the max until the widest label fits. Short labels
5395
+ // (a normal currency) exceed the max and clamp back to it — so the compact 6-wide layout is
5396
+ // preserved and only wide currencies reflow to fewer columns.
5397
+ let columns = maxColumns;
5398
+ if (opts.autoFit) {
5399
+ const widest = chips.reduce((m, ch) => Math.max(m, ch.measureSize().w), 0);
5400
+ const fitCols = Math.floor((innerW + gap) / (widest + gap));
5401
+ columns = Math.max(1, Math.min(maxColumns, fitCols));
5402
+ }
5301
5403
  const colW = (innerW - gap * (columns - 1)) / columns;
5302
5404
  const grid = new FlexBox({ direction: 'column', align: 'start', gap });
5303
- for (let i = 0; i < opts.choices.length; i += columns) {
5304
- const rowChoices = opts.choices.slice(i, i + columns);
5405
+ for (let i = 0; i < chips.length; i += columns) {
5305
5406
  const row = new FlexBox({ direction: 'row', align: 'center', gap });
5306
- for (let j = 0; j < rowChoices.length; j++) {
5307
- const c = rowChoices[j];
5308
- const chipIndex = i + j;
5309
- const chip = new Chip(host, c.id, c.label, chipIndex === focusIndex, em, (id) => {
5310
- const idx = opts.choices.findIndex((ch) => ch.id === id);
5311
- if (idx >= 0)
5312
- setHighlight(idx);
5313
- });
5407
+ for (let j = 0; j < columns && i + j < chips.length; j++) {
5408
+ const chip = chips[i + j];
5314
5409
  chip.setLayoutSize(colW, undefined);
5315
- chips.push(chip);
5316
5410
  row.add(chip);
5317
5411
  }
5318
- row.layout();
5319
5412
  grid.add(row);
5320
5413
  }
5321
- modal.body.add(grid);
5414
+ // Cap the grid height and scroll when the ladder overflows — the Pixi analogue of the HTML
5415
+ // shell's `max-height:min(50vh,28em); overflow-y:auto`. (Mask hit-testing clips to the viewport
5416
+ // but still lets clicks through to chips inside it — verified against pixi.js 8.16's
5417
+ // EventBoundary.) When it fits, drop the scroll box entirely so nothing is masked needlessly.
5418
+ const gridH = grid.measureSize().h;
5419
+ const maxGridH = Math.min(host.screenH * 0.5, 28 * em);
5420
+ if (opts.autoFit && gridH > maxGridH) {
5421
+ const scroll = new SizedScrollBox(innerW, maxGridH, host.canvas);
5422
+ scroll.content.addChild(grid);
5423
+ scroll.refresh();
5424
+ modal.body.add(scroll);
5425
+ }
5426
+ else {
5427
+ modal.body.add(grid);
5428
+ }
5322
5429
  modal.setActions([
5323
5430
  {
5324
5431
  label: opts.confirmLabel,
@@ -5335,6 +5442,7 @@ function openBetPicker(host) {
5335
5442
  tag: 'bet-modal',
5336
5443
  title: host.t('Bet'),
5337
5444
  columns: { wide: 6, mobile: 3 },
5445
+ autoFit: true, // reflow columns + scroll when a wide currency makes the labels grow
5338
5446
  maxEm: 44, // wider card to fit 6 chips/row
5339
5447
  confirmLabel: host.t('Confirm'),
5340
5448
  choices: host.state.availableBets.map((b) => ({ id: String(b), label: host.fmt(b) })),