@textadventures/quest-viva-wasmplayer 6.0.0-beta.58 → 6.0.0-beta.59

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.
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,7 +1,7 @@
1
1
  export const config = /*json-start*/{
2
2
  "mainAssemblyName": "WasmPlayer.dll",
3
3
  "resources": {
4
- "hash": "sha256-Yr09rmXNYGN6LcUDHJDg8OAU0PZSyBfmT1qNKu+62lE=",
4
+ "hash": "sha256-JR2RaJFHW87NQvu3H/puPdda+cgxLVtr3snkTNVAGNQ=",
5
5
  "jsModuleNative": [
6
6
  {
7
7
  "name": "dotnet.native.js"
@@ -939,27 +939,27 @@ export const config = /*json-start*/{
939
939
  {
940
940
  "virtualPath": "Common.wasm",
941
941
  "name": "Common.wasm",
942
- "hash": "sha256-m6pByI3t+ZrZagdIA53USHNp4tIfWIQAhqdgbfKaj3w="
942
+ "hash": "sha256-2weqQwAVEV2TCiE2wkZtlMeUpRRECS0qh5gomoENIjk="
943
943
  },
944
944
  {
945
945
  "virtualPath": "Engine.wasm",
946
946
  "name": "Engine.wasm",
947
- "hash": "sha256-L0mtyQI1/XB93G/9yGkhHszg1DxVKm+ZxKyxe3zljb0="
947
+ "hash": "sha256-kP8DveYxBZmLh0UH4A1n/+mCO4Nc7asdXM8hu5DBTus="
948
948
  },
949
949
  {
950
950
  "virtualPath": "Legacy.wasm",
951
951
  "name": "Legacy.wasm",
952
- "hash": "sha256-W+XViOuDToAx7QgTzts0p92LeUke1ElkiI/fwNRLbFM="
952
+ "hash": "sha256-8olPp51wGZYjz5bYSNzX7XajdoYMJwicXXgo8Gl9iqM="
953
953
  },
954
954
  {
955
955
  "virtualPath": "PlayerCore.wasm",
956
956
  "name": "PlayerCore.wasm",
957
- "hash": "sha256-KSuWIsi9gMvS2f5fOMm+S1Mkg2hVwyrsCDjRVaL/O4U="
957
+ "hash": "sha256-X3wtjTH8L8zy+MgD24EK8/Xj+y54ZGxY4PW593EYkkY="
958
958
  },
959
959
  {
960
960
  "virtualPath": "WasmPlayer.wasm",
961
961
  "name": "WasmPlayer.wasm",
962
- "hash": "sha256-Xxdi8yATS8X6Gfj2zGg5lXZ7itn9PMp3tNIRxCvSviE="
962
+ "hash": "sha256-TAend3zTIYs+Us7ReKDqNhmZT0SaheVCHXyT3yTRvNw="
963
963
  }
964
964
  ],
965
965
  "assembly": []
package/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Quest Viva</title>
7
- <link rel="icon" type="image/svg+xml" href="favicon.svg?v=6.0.0-beta.58" />
7
+ <link rel="icon" type="image/svg+xml" href="favicon.svg?v=6.0.0-beta.59" />
8
8
  <!-- Lets the preload scanner start the runtime loader before the parser has
9
9
  even reached wasm-player.js, which as the last script in this head only
10
10
  executes once jQuery/jQuery UI/paper.js have all downloaded *and* run.
@@ -14,8 +14,8 @@
14
14
  here (scripts/inject-version.mjs), which is also what makes the
15
15
  preload and wasm-player.js's own import() agree on one URL and share a
16
16
  single fetch. -->
17
- <link rel="modulepreload" href="_framework/dotnet.js?v=6.0.0-beta.58" />
18
- <script type="text/javascript" src="quest-config.js?v=6.0.0-beta.58"></script>
17
+ <link rel="modulepreload" href="_framework/dotnet.js?v=6.0.0-beta.59" />
18
+ <script type="text/javascript" src="quest-config.js?v=6.0.0-beta.59"></script>
19
19
  <script type="text/javascript">
20
20
  // Runs before the start screen is parsed, so when a game is specified via the
21
21
  // URL (or a defaultGameUrl is configured) we paint straight into the loading
@@ -33,28 +33,28 @@
33
33
  html.qv-booting #qv-pickers { display: none; }
34
34
  html.qv-booting #qv-loading-msg { display: flex; }
35
35
  </style>
36
- <script type="text/javascript" src="lib/jquery-2.1.1.min.js?v=6.0.0-beta.58"></script>
37
- <script type="text/javascript" src="lib/jquery-ui.min.js?v=6.0.0-beta.58"></script>
38
- <script type="text/javascript" src="lib/jquery.multi-open-accordion-1.5.3.js?v=6.0.0-beta.58"></script>
39
- <link rel="stylesheet" type="text/css" href="lib/jquery-ui.min.css?v=6.0.0-beta.58" />
40
- <link rel="stylesheet" type="text/css" href="playercore.css?v=6.0.0-beta.58" />
36
+ <script type="text/javascript" src="lib/jquery-2.1.1.min.js?v=6.0.0-beta.59"></script>
37
+ <script type="text/javascript" src="lib/jquery-ui.min.js?v=6.0.0-beta.59"></script>
38
+ <script type="text/javascript" src="lib/jquery.multi-open-accordion-1.5.3.js?v=6.0.0-beta.59"></script>
39
+ <link rel="stylesheet" type="text/css" href="lib/jquery-ui.min.css?v=6.0.0-beta.59" />
40
+ <link rel="stylesheet" type="text/css" href="playercore.css?v=6.0.0-beta.59" />
41
41
  <!-- App-chrome styles (start screen, debugger, save-slot manager). Built from
42
42
  styles/chrome.css via `npm run build` — see WasmPlayer/package.json. All of
43
43
  its rules are contained to `.qv-chrome` subtrees so they can't affect the
44
44
  game UI above (playercore.css / jQuery UI). -->
45
- <link rel="stylesheet" type="text/css" href="chrome.css?v=6.0.0-beta.58" />
46
- <script type="text/javascript" src="playercore.js?v=6.0.0-beta.58"></script>
47
- <script type="text/javascript" src="player.js?v=6.0.0-beta.58"></script>
48
- <script type="text/javascript" src="lib/paper.js?v=6.0.0-beta.58"></script>
49
- <script>window.QuestVivaVersion = "6.0.0-beta.58";</script>
50
- <script type="text/javascript" src="wasm-player.js?v=6.0.0-beta.58"></script>
45
+ <link rel="stylesheet" type="text/css" href="chrome.css?v=6.0.0-beta.59" />
46
+ <script type="text/javascript" src="playercore.js?v=6.0.0-beta.59"></script>
47
+ <script type="text/javascript" src="player.js?v=6.0.0-beta.59"></script>
48
+ <script type="text/javascript" src="lib/paper.js?v=6.0.0-beta.59"></script>
49
+ <script>window.QuestVivaVersion = "6.0.0-beta.59";</script>
50
+ <script type="text/javascript" src="wasm-player.js?v=6.0.0-beta.59"></script>
51
51
  </head>
52
52
  <body>
53
53
  <div id="qv-start" class="qv-chrome">
54
54
  <div class="card preset-filled-surface-100-900 w-full max-w-md p-8 space-y-6" data-theme="wintry">
55
55
  <div>
56
56
  <h1 class="h2 flex items-center gap-4">
57
- <img src="logo.svg?v=6.0.0-beta.58" alt="" class="h-7" />
57
+ <img src="logo.svg?v=6.0.0-beta.59" alt="" class="h-7" />
58
58
  Quest Viva
59
59
  </h1>
60
60
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textadventures/quest-viva-wasmplayer",
3
- "version": "6.0.0-beta.58",
3
+ "version": "6.0.0-beta.59",
4
4
  "private": false,
5
5
  "description": "Quest Viva WasmPlayer runtime (browser-WASM text adventure player), published for CDN-linked single-file game exports.",
6
6
  "license": "MIT",
package/player.js CHANGED
@@ -41,6 +41,7 @@ var _menuSelection = "";
41
41
  function showMenu(title, options, allowCancel) {
42
42
  $("#dialogOptions").empty();
43
43
  var firstOption = true;
44
+ var optionCount = 0;
44
45
  $.each(options, function (key, value) {
45
46
  // Explicitly mark the first <option> selected - a <select> visually
46
47
  // shows its first option as selected by default, but jQuery's .val()
@@ -51,13 +52,23 @@ function showMenu(title, options, allowCancel) {
51
52
  $("<option/>").attr("value", key).text(value).prop("selected", firstOption)
52
53
  );
53
54
  firstOption = false;
55
+ optionCount++;
54
56
  });
55
57
 
58
+ // Show every option at once where we can - the markup's fallback size of 3
59
+ // meant a menu of more than three options was scrolled by default, with no
60
+ // hint that there was anything below the fold.
61
+ $("#dialogOptions").attr("size", Math.min(Math.max(optionCount, 3), 10));
62
+
56
63
  $("#dialogCaption").html(title);
57
64
 
58
65
  var dialogOptions = {
59
66
  modal: true,
60
67
  autoOpen: false,
68
+ // Size to the widest option rather than jQuery UI's default 300px,
69
+ // which clipped longer options. playercore.css caps how far this can
70
+ // grow so it can't overflow the window.
71
+ width: "auto",
61
72
  buttons: [{
62
73
  text: "Select",
63
74
  click: function () {
package/playercore.css CHANGED
@@ -80,12 +80,27 @@ div#gamePanes {
80
80
  }
81
81
 
82
82
  div#qv-status {
83
- height: 30px;
83
+ /* A border-box total (box-sizing below): 30px of bar plus
84
+ .ui-widget-header's 1px border top and bottom. */
85
+ height: 32px;
84
86
  position: fixed;
85
87
  top: 0px;
86
88
  z-index: 100;
87
- width: 100%;
88
- max-width: 948px;
89
+ /* Anchored to the viewport rather than left to its static position inside
90
+ #gameBorder. It's position: fixed, so a plain "width: 100%" resolved
91
+ against the viewport while the bar still started at #gameBorder's 1px
92
+ left border - and with .ui-widget-header's own 1px borders sitting
93
+ outside a content-box width, the bar overran the window by 3px and
94
+ clipped its rightmost button on a phone. left/right/margin: auto centres
95
+ it on the viewport instead, which is where #gameBorder centres too, so
96
+ the wide layout is unchanged. */
97
+ left: 0;
98
+ right: 0;
99
+ width: auto;
100
+ /* A border-box total, matching #gameBorder's content width - see
101
+ setGameWidth() in playercore.js, which caps this at runtime. */
102
+ box-sizing: border-box;
103
+ max-width: 950px;
89
104
  margin-left: auto;
90
105
  margin-right: auto;
91
106
  font-size: 14pt;
@@ -111,6 +126,25 @@ div#controlButtons {
111
126
  display: none;
112
127
  }
113
128
 
129
+ /* showMenu() opens the menu dialog with width: "auto" so that long options
130
+ aren't clipped, so it's the options themselves that decide how wide the
131
+ dialog gets. Keep that within the window, keep a long caption wrapping
132
+ instead of stretching the dialog out on its own, and let the options list
133
+ shrink rather than overflow once the cap is reached. */
134
+ .ui-dialog {
135
+ max-width: 95vw;
136
+ }
137
+
138
+ #dialogCaption {
139
+ max-width: 60ch;
140
+ }
141
+
142
+ #dialogOptions {
143
+ min-width: 100%;
144
+ max-width: 100%;
145
+ box-sizing: border-box;
146
+ }
147
+
114
148
  #msgbox {
115
149
  display: none;
116
150
  }
@@ -316,4 +350,156 @@ div.jj_menu_item_hover {
316
350
 
317
351
  #cmdShowPanes {
318
352
  display: none;
319
- }
353
+ }
354
+
355
+ /* ---------------------------------------------------------------------------
356
+ Narrow-window (phone/tablet) sizing - see issue #2181.
357
+
358
+ doLayout() in playercore.js owns the single narrow/wide threshold (the
359
+ window is narrower than the game width, so the panes have collapsed behind
360
+ the hamburger button) and publishes it as body.qv-narrow. Keying these rules
361
+ off that class rather than a media query of their own keeps one source of
362
+ truth: setGameWidth() can move the threshold at runtime, which a media query
363
+ couldn't follow.
364
+
365
+ The sizes here target WCAG 2.2's 44x44 CSS px pointer target (2.5.5 Target
366
+ Size (Enhanced)) and lift chrome text to 16px, matching the 12pt default
367
+ body text rather than sitting well below it.
368
+ --------------------------------------------------------------------------- */
369
+
370
+ .qv-narrow {
371
+ --qv-sidebar-width: min(320px, 85vw);
372
+ }
373
+
374
+ /* The status bar is a fixed 32px when wide, which can't hold a 44px button.
375
+ updateStatusVisibility() measures whatever height this ends up being rather
376
+ than assuming, so #gamePanel/#gridPanel/#gamePanes stay directly below it. */
377
+ .qv-narrow div#qv-status {
378
+ height: auto;
379
+ min-height: 50px;
380
+ }
381
+
382
+ .qv-narrow div#controlButtons {
383
+ padding-top: 2px;
384
+ }
385
+
386
+ .qv-narrow div#controlButtons .ui-button {
387
+ font-size: 16px !important;
388
+ min-height: 44px;
389
+ min-width: 44px;
390
+ /* jQuery UI puts the padding on the inner .ui-button-text span, so the
391
+ label sits at the top of a min-height-stretched button unless the button
392
+ itself centres it. */
393
+ display: inline-flex;
394
+ align-items: center;
395
+ justify-content: center;
396
+ }
397
+
398
+ .qv-narrow div#location {
399
+ padding-top: 12px;
400
+ }
401
+
402
+ /* Side pane: 12px text in 15px rows, inside a 220px overlay.
403
+
404
+ The overlay is anchored between the status bar (updateStatusVisibility()
405
+ sets its top from the bar's measured height, so it can't end up underneath
406
+ it) and the bottom of the window. "height: 100%" would instead run the
407
+ overlay's bottom edge off the screen by however far down its top starts,
408
+ putting the end of a long pane out of reach. */
409
+ .qv-narrow #sidebar {
410
+ width: var(--qv-sidebar-width);
411
+ box-sizing: border-box;
412
+ height: auto;
413
+ bottom: 0;
414
+ }
415
+
416
+ /* In the wide layout #gamePanes is a fixed, floated column positioned against
417
+ the viewport. Inside the narrow overlay it should simply be the overlay's
418
+ content: laying it out in flow is what lets #sidebar's own overflow-y scroll
419
+ it, which a fixed (out-of-flow) child left it unable to do - so a pane taller
420
+ than the screen had nothing to scroll and its lower half was unreachable.
421
+ float: none because a float would shrink-wrap instead of filling the width,
422
+ and min-height: 0 because a 100% of the overlay plus its padding is always
423
+ fractionally too tall, leaving the overlay permanently scrollable by a few
424
+ pixels. */
425
+ .qv-narrow div#gamePanes {
426
+ position: static;
427
+ float: none;
428
+ width: auto;
429
+ min-height: 0;
430
+ }
431
+
432
+ .qv-narrow #gamePanes .ui-widget {
433
+ font-size: 16px;
434
+ }
435
+
436
+ .qv-narrow .ui-accordion-header {
437
+ font-size: 16px;
438
+ }
439
+
440
+ .qv-narrow button.accordion-header-text {
441
+ min-height: 44px;
442
+ }
443
+
444
+ .qv-narrow .elementList li {
445
+ display: flex;
446
+ align-items: center;
447
+ min-height: 44px;
448
+ padding: 0 6px;
449
+ box-sizing: border-box;
450
+ }
451
+
452
+ /* Six 44px rows rather than the ten 15px ones the 200px cap used to hold. */
453
+ .qv-narrow .elementListWrapper {
454
+ max-height: 264px;
455
+ }
456
+
457
+ /* The multi-open accordion's expand/collapse arrow is a bare .ui-icon, not the
458
+ .ui-accordion-header-icon that jQuery UI's own centring rule targets, so it
459
+ keeps its static position at the top-left of the header's padding box - which
460
+ left it stranded against the top of a header now 44px tall. Centre it on the
461
+ header and scale the 16px sprite up to match the rest of the touch chrome
462
+ (transform rather than background-size, so the sprite's per-icon background
463
+ position doesn't have to be recomputed). */
464
+ .qv-narrow .ui-accordion-header > .ui-icon {
465
+ top: 50%;
466
+ margin-top: -8px;
467
+ transform: scale(1.5);
468
+ }
469
+
470
+ /* The compass lives in the same pane, and its buttons are 35px. */
471
+ .qv-narrow .compassbutton {
472
+ height: 44px;
473
+ width: 44px;
474
+ }
475
+
476
+ /* playercore.js pins the direction icon at an inline left: 0.8em, which centres
477
+ it in a 35px button but not a 44px one - hand centring back to jQuery UI's
478
+ own rule for it. */
479
+ .qv-narrow .compassbutton span.ui-icon {
480
+ left: 50% !important;
481
+ margin-left: -8px;
482
+ }
483
+
484
+ .qv-narrow #compassTable .ui-button {
485
+ font-size: 14px !important;
486
+ }
487
+
488
+ .qv-narrow .verbButtons .ui-button {
489
+ font-size: 14px !important;
490
+ min-height: 44px;
491
+ display: inline-flex;
492
+ align-items: center;
493
+ justify-content: center;
494
+ }
495
+
496
+ /* Hyperlink pop-up menu. The font size itself is the game's to choose (see
497
+ SetMenuFontSize in playercore.js, which applies a floor here rather than
498
+ overriding it outright), so only the row height is set from CSS. */
499
+ .qv-narrow div.jj_menu_item span {
500
+ display: flex;
501
+ align-items: center;
502
+ min-height: 44px;
503
+ padding: 4px 10px;
504
+ box-sizing: border-box;
505
+ }
package/playercore.js CHANGED
@@ -232,6 +232,13 @@ function initPlayerUI() {
232
232
  const doLayout = () => {
233
233
  let isWide = isWindowWide();
234
234
 
235
+ // Published as a class so playercore.css can hang its larger touch
236
+ // targets off the same threshold this function already owns, instead
237
+ // of duplicating it as a media query - which setGameWidth() would then
238
+ // have no way to move. See issue #2181.
239
+ document.body.classList.toggle("qv-narrow", !isWide);
240
+ refreshMenuFontSize();
241
+
235
242
  if (isWide && arePanesVisible) {
236
243
  sidebar.style.display = "block";
237
244
  sidebar.style.background = "initial";
@@ -263,14 +270,18 @@ function initPlayerUI() {
263
270
  if (window.paper && paper.view) paper.view.viewSize.width = Math.min(window.innerWidth, gameWidth);
264
271
  }
265
272
 
266
- const newPanelImageMaxHeight = `${(window.innerHeight - 30) * 0.5}px`;
267
- updatePanelImageMaxHeight(newPanelImageMaxHeight);
268
-
269
273
  // cmdShowPanes.style.display was just set above - recompute #qv-status's own
270
274
  // visibility now in case resizing past the narrow-window threshold is what
271
275
  // just made (or unmade) the hamburger button #qv-status's only visible child.
272
276
  updateStatusVisibility();
273
277
 
278
+ // Budget the sticky picture frame against however tall the status bar
279
+ // actually ended up - it used to subtract a hard-coded 30, which is
280
+ // neither its narrow-layout height nor right at all when it isn't
281
+ // showing. updateStatusVisibility() has just settled both, hence the
282
+ // ordering here.
283
+ updatePanelImageMaxHeight(`${(window.innerHeight - statusBarHeight()) * 0.5}px`);
284
+
274
285
  wasWide = isWide;
275
286
  }
276
287
 
@@ -280,8 +291,12 @@ function initPlayerUI() {
280
291
  const gameBorder = document.getElementById("gameBorder");
281
292
  gameBorder.style.maxWidth = width + "px";
282
293
 
294
+ // playercore.css gives #qv-status box-sizing: border-box, so this cap is
295
+ // the bar's whole width including its 1px borders - matching #gameBorder's
296
+ // content box, which is what "width" is there (it's content-box, with its
297
+ // own 1px borders outside that).
283
298
  const status = document.getElementById("qv-status");
284
- status.style.maxWidth = (width - 2) + "px";
299
+ status.style.maxWidth = width + "px";
285
300
 
286
301
  gameWidth = width;
287
302
  doLayout();
@@ -393,6 +408,13 @@ function setGameName(text) {
393
408
  var _waitMode = false;
394
409
  var _pauseMode = false;
395
410
 
411
+ // True between endPause() and pauseEnded(), i.e. while the command bar is
412
+ // hidden only because a finished pause hasn't been able to restore it yet.
413
+ // Anything that snapshots the command bar's current visibility to restore it
414
+ // later (playSound's synchronous branch) has to count that as visible, or the
415
+ // pause's pending restore is swallowed and the command bar never comes back.
416
+ var _pauseRestorePending = false;
417
+
396
418
  // Mirrors the engine's WorldModel._pendingCallbackCount > 0: true whenever
397
419
  // anything is suspended inside a TaskCompletionSource continuation (wait(),
398
420
  // get input(), ask, show menu, pause) that a save/reload can't reconstruct -
@@ -422,15 +444,35 @@ function beginPause(ms) {
422
444
  }
423
445
 
424
446
  function endPause() {
447
+ if (!_pauseMode) return;
425
448
  _pauseMode = false;
426
- $("#txtCommandDiv").show();
449
+ // The command bar deliberately stays hidden until pauseEnded() - showing it
450
+ // here made it flash into view for the length of the round trip whenever the
451
+ // resumed script went straight into another pause (same bug as endWait()).
452
+ _pauseRestorePending = true;
427
453
 
428
454
  // TODO: This is WebPlayer-specific, so shouldn't be in this shared file
429
455
  window.setTimeout(async function () {
430
- await WebPlayer.uiEndPause();
456
+ try {
457
+ await WebPlayer.uiEndPause();
458
+ } finally {
459
+ pauseEnded();
460
+ }
431
461
  }, 100);
432
462
  }
433
463
 
464
+ // Called once the engine has resumed the paused turn and run on to its next
465
+ // stopping point, so anything that turn did to the command bar has already
466
+ // happened: another pause (beginPause), the end of the game (disableInterface)
467
+ // or a synchronous sound (playSound), each of which owns the command bar until
468
+ // it restores it itself.
469
+ function pauseEnded() {
470
+ _pauseRestorePending = false;
471
+ if (_pauseMode || _gameFinished || _waitingForSoundToFinish) return;
472
+ $("#txtCommandDiv").show();
473
+ focusCommandInput();
474
+ }
475
+
434
476
  function commandKey(e) {
435
477
  if (_waitMode) return false;
436
478
  switch (keyPressCode(e)) {
@@ -556,16 +598,40 @@ function updateStatusVisibility() {
556
598
  || isElementVisible("#cmdDebug") || isElementVisible("#cmdShowPanes");
557
599
  if (anyVisible) {
558
600
  $("#qv-status").show();
559
- $("#divOutput").css("margin-top", "20px");
560
- $("#gamePanes").css("top", "24px");
561
- $("#gridPanel").css("top", "32px");
562
- $("#gamePanel").css("top", "32px");
601
+ // #qv-status is no longer a fixed height - on a narrow window it grows
602
+ // to fit 44px touch targets (see playercore.css's .qv-narrow rules), so
603
+ // measure its real bottom edge rather than repeating the height as a
604
+ // constant here. Its 32px on the desktop layout is what the old 24/32
605
+ // constants were describing: the panels sat flush with the bar's bottom
606
+ // edge, and #gamePanes deliberately tucked 8px up under it.
607
+ var statusHeight = statusBarHeight();
608
+ // #qv-status is position: fixed, so it takes up no space in flow and
609
+ // this margin is the whole of what holds the game text clear of it.
610
+ // The 20px it used to be was picked against the 32px desktop bar,
611
+ // leaving 18px of daylight - which a 50px narrow-layout bar closed to
612
+ // nothing, running the text right up under it. Tracking the bar keeps
613
+ // that daylight constant. It's expressed as an offset from the bar's
614
+ // own height rather than computed from #gameContent's padding, so a
615
+ // game setting its own custompaddingtop keeps exactly the spacing it
616
+ // has today.
617
+ $("#divOutput").css("margin-top", (statusHeight - 12) + "px");
618
+ $("#gamePanes").css("top", (statusHeight - 8) + "px");
619
+ $("#gridPanel").css("top", statusHeight + "px");
620
+ $("#gamePanel").css("top", statusHeight + "px");
621
+ // The narrow layout's pane overlay, which is opaque and would otherwise
622
+ // sit over the bottom of the bar it drops down from. (In the wide
623
+ // layout it's a transparent container and this is the 32px it already
624
+ // had.) #gamePanes is laid out inside it there rather than positioned,
625
+ // so this is what actually places the panes on a narrow window - its
626
+ // own "top" above is only read by the wide layout.
627
+ $("#sidebar").css("top", statusHeight + "px");
563
628
  } else {
564
629
  $("#qv-status").hide();
565
630
  $("#divOutput").css("margin-top", "0px");
566
631
  $("#gamePanes").css("top", "0px");
567
632
  $("#gridPanel").css("top", "0px");
568
633
  $("#gamePanel").css("top", "0px");
634
+ $("#sidebar").css("top", "0px");
569
635
  }
570
636
  }
571
637
 
@@ -573,6 +639,20 @@ function isElementVisible(element) {
573
639
  return $(element).css("display") != "none";
574
640
  }
575
641
 
642
+ // doLayout() publishes its narrow/wide threshold as a class on <body> - see
643
+ // playercore.css's .qv-narrow rules.
644
+ function isNarrowLayout() {
645
+ return document.body.classList.contains("qv-narrow");
646
+ }
647
+
648
+ // #qv-status's on-screen height, or 0 when it isn't showing at all. 32px on the
649
+ // desktop layout, but it grows to hold 44px touch targets on a narrow one, so
650
+ // nothing downstream should be assuming a number for it.
651
+ function statusBarHeight() {
652
+ var $status = $("#qv-status");
653
+ return ($status.length && isElementVisible($status)) ? $status.outerHeight() : 0;
654
+ }
655
+
576
656
  var _animateScroll = true;
577
657
 
578
658
  // The page's own scrollable content sits behind #qv-status (fixed) and
@@ -693,7 +773,12 @@ function scrollToTurnStart(turnStart, allowBackward) {
693
773
  // jumped straight to the document's bottom, undoing every calculation above.
694
774
  // {preventScroll: true} keeps the input usable (typing still works
695
775
  // immediately) without fighting the scroll position we just computed.
776
+ //
777
+ // Also guards against focusing the input while it's genuinely hidden (mid
778
+ // wait()/pause()) — needed by waitEnded()/pauseEnded(), which share this
779
+ // same function to restore focus once the command bar comes back.
696
780
  function focusCommandInput() {
781
+ if (!isElementVisible("#txtCommandDiv") || !isElementVisible("#txtCommand")) return;
697
782
  document.getElementById("txtCommand")?.focus({preventScroll: true});
698
783
  }
699
784
 
@@ -941,14 +1026,26 @@ function beginWait() {
941
1026
 
942
1027
  function endWait() {
943
1028
  if (!_waitMode) return;
1029
+ // Leave wait mode and hide the Continue link straight away: that's the
1030
+ // click's immediate feedback, and it also stops a second click/keypress
1031
+ // firing a second FinishWait while the engine is resuming. The command
1032
+ // input deliberately stays hidden until waitEnded() - see below.
1033
+ _waitMode = false;
1034
+ $("#endWaitLink").hide();
944
1035
  sendEndWait();
945
1036
  }
946
1037
 
1038
+ // Called by the platform's sendEndWait() once the engine has resumed the
1039
+ // suspended turn and run on to its next stopping point. If that turn started
1040
+ // another wait(), beginWait() has already re-hidden the command input and
1041
+ // re-shown the Continue link, so leave both alone: restoring the input
1042
+ // unconditionally (as this used to, synchronously at click time) is what made
1043
+ // it flash into view for the length of the round trip between chained waits.
947
1044
  function waitEnded() {
948
- _waitMode = false;
949
- $("#endWaitLink").hide();
1045
+ if (_waitMode) return;
950
1046
  $("#txtCommand").show();
951
1047
  $("#txtCommandPrompt").show();
1048
+ focusCommandInput();
952
1049
  }
953
1050
 
954
1051
  function gameFinished() {
@@ -1299,39 +1396,63 @@ function AddVimeo(id) {
1299
1396
  }
1300
1397
 
1301
1398
  function SetMenuBackground(color) {
1302
- var css = getCSSRule("div.jj_menu_item");
1399
+ var css = addCSSRule("div.jj_menu_item");
1303
1400
  css.style.backgroundColor = color;
1304
1401
  }
1305
1402
 
1306
1403
  function SetMenuForeground(color) {
1307
- var css = getCSSRule("div.jj_menu_item");
1404
+ var css = addCSSRule("div.jj_menu_item");
1308
1405
  css.style.color = color;
1309
1406
  }
1310
1407
 
1311
1408
  function SetMenuHoverBackground(color) {
1312
- var css = getCSSRule("div.jj_menu_item_hover");
1409
+ var css = addCSSRule("div.jj_menu_item_hover");
1313
1410
  css.style.backgroundColor = color;
1314
1411
  }
1315
1412
 
1316
1413
  function SetMenuHoverForeground(color) {
1317
- var css = getCSSRule("div.jj_menu_item_hover");
1414
+ var css = addCSSRule("div.jj_menu_item_hover");
1318
1415
  css.style.color = color;
1319
1416
  }
1320
1417
 
1321
1418
  function SetMenuFontName(font) {
1322
- var css = getCSSRule("div.jjmenu");
1419
+ var css = addCSSRule("div.jjmenu");
1323
1420
  css.style.fontFamily = font;
1324
1421
  }
1325
1422
 
1423
+ // game.menufontsize defaults to 9pt (12px), and - like every other Core
1424
+ // library value - is inlined into each game at publish time, so an already
1425
+ // published game calls SetMenuFontSize("9pt") on startup no matter what this
1426
+ // stylesheet's own default says. Rather than ignoring the game outright, treat
1427
+ // its value as a request with a floor under it on a narrow window: an author
1428
+ // who asked for something larger (theme_retro asks for 14pt) still gets
1429
+ // exactly what they asked for. max() does the comparison in CSS, so "9pt"
1430
+ // doesn't have to be converted to px here; in a browser without support the
1431
+ // assignment is simply dropped and the stylesheet's own div.jjmenu size
1432
+ // stands, exactly as it did before. See issue #2181.
1433
+ function menuFontSizeWithFloor(size) {
1434
+ return isNarrowLayout() ? "max(" + size + ", 16px)" : size;
1435
+ }
1436
+
1437
+ // The size the game last asked for, before any narrow-window floor, so the
1438
+ // floor can be re-evaluated when the window crosses the threshold.
1439
+ var _requestedMenuFontSize = null;
1440
+
1326
1441
  function SetMenuFontSize(size) {
1327
1442
  if (_allowMenuFontSizeChange) {
1328
- var css = getCSSRule("div.jjmenu");
1329
- css.style.fontSize = size;
1443
+ var css = addCSSRule("div.jjmenu");
1444
+ css.style.fontSize = menuFontSizeWithFloor(size);
1445
+ _requestedMenuFontSize = size;
1330
1446
  }
1331
1447
  }
1332
1448
 
1449
+ function refreshMenuFontSize() {
1450
+ if (_requestedMenuFontSize == null) return;
1451
+ addCSSRule("div.jjmenu").style.fontSize = menuFontSizeWithFloor(_requestedMenuFontSize);
1452
+ }
1453
+
1333
1454
  function TurnOffHyperlinksUnderline() {
1334
- var css = getCSSRule("a.cmdlink");
1455
+ var css = addCSSRule("a.cmdlink");
1335
1456
  css.style.textDecoration = "none";
1336
1457
  }
1337
1458
 
package/wasm-player.js CHANGED
@@ -246,10 +246,20 @@ function stageAdjacentFiles(files) {
246
246
  function ui_init() { }
247
247
 
248
248
  function sendEndWait() {
249
+ // The short delay lets the browser paint endWait()'s hidden Continue link
250
+ // before the engine resumes and (in the WASM build, which runs it on the
251
+ // one UI thread) blocks painting for the rest of the turn.
249
252
  window.setTimeout(async function () {
250
- await WebPlayer.uiEndWait();
253
+ try {
254
+ await WebPlayer.uiEndWait();
255
+ } finally {
256
+ // uiEndWait only resolves once the resumed turn has reached its
257
+ // next stopping point and flushed its UI calls, so by now
258
+ // beginWait() has already run for a chained wait() - which is
259
+ // exactly what waitEnded() checks before restoring the input.
260
+ waitEnded();
261
+ }
251
262
  }, 100);
252
- waitEnded();
253
263
  }
254
264
 
255
265
  function afterSendCommand() { }
@@ -259,7 +269,10 @@ function playSound(url, synchronous, looped) {
259
269
  _audio = new Audio(url);
260
270
  if (looped) _audio.loop = true;
261
271
  if (synchronous) {
262
- var showCmdDiv = isElementVisible("#txtCommandDiv");
272
+ // Counts a pause whose restore is still pending as visible - see
273
+ // _pauseRestorePending, otherwise finishSync() below leaves the command
274
+ // bar hidden for good.
275
+ var showCmdDiv = isElementVisible("#txtCommandDiv") || _pauseRestorePending;
263
276
  _waitingForSoundToFinish = true;
264
277
  $("#txtCommandDiv").hide();
265
278
  _audio.addEventListener('ended', function () { finishSync(showCmdDiv); });