@textadventures/quest-viva-wasmplayer 6.0.4 → 6.1.0-beta.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.
Files changed (156) hide show
  1. package/_framework/Common.wasm +0 -0
  2. package/_framework/Engine.wasm +0 -0
  3. package/_framework/ExtendedNumerics.BigDecimal.wasm +0 -0
  4. package/_framework/Legacy.wasm +0 -0
  5. package/_framework/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
  6. package/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  7. package/_framework/NCalc.Core.wasm +0 -0
  8. package/_framework/NCalc.Domain.wasm +0 -0
  9. package/_framework/NCalc.Parser.wasm +0 -0
  10. package/_framework/Parlot.wasm +0 -0
  11. package/_framework/PlayerCore.wasm +0 -0
  12. package/_framework/System.Collections.Immutable.wasm +0 -0
  13. package/_framework/System.Collections.NonGeneric.wasm +0 -0
  14. package/_framework/System.Collections.Specialized.wasm +0 -0
  15. package/_framework/System.Collections.wasm +0 -0
  16. package/_framework/System.ComponentModel.Annotations.wasm +0 -0
  17. package/_framework/System.ComponentModel.Primitives.wasm +0 -0
  18. package/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  19. package/_framework/System.ComponentModel.wasm +0 -0
  20. package/_framework/System.IO.Compression.wasm +0 -0
  21. package/_framework/System.IO.Pipelines.wasm +0 -0
  22. package/_framework/System.Linq.Expressions.wasm +0 -0
  23. package/_framework/System.Linq.wasm +0 -0
  24. package/_framework/System.Memory.wasm +0 -0
  25. package/_framework/System.Net.Http.wasm +0 -0
  26. package/_framework/System.Net.Primitives.wasm +0 -0
  27. package/_framework/System.ObjectModel.wasm +0 -0
  28. package/_framework/System.Private.CoreLib.wasm +0 -0
  29. package/_framework/System.Private.Uri.wasm +0 -0
  30. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  31. package/_framework/System.Private.Xml.wasm +0 -0
  32. package/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  33. package/_framework/System.Runtime.Numerics.wasm +0 -0
  34. package/_framework/System.Security.Cryptography.wasm +0 -0
  35. package/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  36. package/_framework/System.Text.Encodings.Web.wasm +0 -0
  37. package/_framework/System.Text.Json.wasm +0 -0
  38. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  39. package/_framework/System.Xml.Linq.wasm +0 -0
  40. package/_framework/System.wasm +0 -0
  41. package/_framework/WasmPlayer.wasm +0 -0
  42. package/_framework/dotnet.js +328 -2
  43. package/_framework/dotnet.native.js +1919 -2049
  44. package/_framework/dotnet.native.wasm +0 -0
  45. package/_framework/dotnet.runtime.js +1 -1
  46. package/_framework/icudt_CJK.dat +0 -0
  47. package/_framework/icudt_EFIGS.dat +0 -0
  48. package/_framework/icudt_no_CJK.dat +0 -0
  49. package/chrome.css +20 -2
  50. package/export-manifest.json +1 -1
  51. package/fonts/courier-prime/LICENSE.txt +93 -0
  52. package/fonts/courier-prime/latin-400-italic.woff2 +0 -0
  53. package/fonts/courier-prime/latin-400-normal.woff2 +0 -0
  54. package/fonts/courier-prime/latin-700-italic.woff2 +0 -0
  55. package/fonts/courier-prime/latin-700-normal.woff2 +0 -0
  56. package/fonts/courier-prime/latin-ext-400-italic.woff2 +0 -0
  57. package/fonts/courier-prime/latin-ext-400-normal.woff2 +0 -0
  58. package/fonts/courier-prime/latin-ext-700-italic.woff2 +0 -0
  59. package/fonts/courier-prime/latin-ext-700-normal.woff2 +0 -0
  60. package/fonts/fonts.css +500 -0
  61. package/fonts/literata/LICENSE.txt +93 -0
  62. package/fonts/literata/cyrillic-400-italic.woff2 +0 -0
  63. package/fonts/literata/cyrillic-400-normal.woff2 +0 -0
  64. package/fonts/literata/cyrillic-700-italic.woff2 +0 -0
  65. package/fonts/literata/cyrillic-700-normal.woff2 +0 -0
  66. package/fonts/literata/cyrillic-ext-400-italic.woff2 +0 -0
  67. package/fonts/literata/cyrillic-ext-400-normal.woff2 +0 -0
  68. package/fonts/literata/cyrillic-ext-700-italic.woff2 +0 -0
  69. package/fonts/literata/cyrillic-ext-700-normal.woff2 +0 -0
  70. package/fonts/literata/greek-400-italic.woff2 +0 -0
  71. package/fonts/literata/greek-400-normal.woff2 +0 -0
  72. package/fonts/literata/greek-700-italic.woff2 +0 -0
  73. package/fonts/literata/greek-700-normal.woff2 +0 -0
  74. package/fonts/literata/greek-ext-400-italic.woff2 +0 -0
  75. package/fonts/literata/greek-ext-400-normal.woff2 +0 -0
  76. package/fonts/literata/greek-ext-700-italic.woff2 +0 -0
  77. package/fonts/literata/greek-ext-700-normal.woff2 +0 -0
  78. package/fonts/literata/latin-400-italic.woff2 +0 -0
  79. package/fonts/literata/latin-400-normal.woff2 +0 -0
  80. package/fonts/literata/latin-700-italic.woff2 +0 -0
  81. package/fonts/literata/latin-700-normal.woff2 +0 -0
  82. package/fonts/literata/latin-ext-400-italic.woff2 +0 -0
  83. package/fonts/literata/latin-ext-400-normal.woff2 +0 -0
  84. package/fonts/literata/latin-ext-700-italic.woff2 +0 -0
  85. package/fonts/literata/latin-ext-700-normal.woff2 +0 -0
  86. package/fonts/literata/vietnamese-400-italic.woff2 +0 -0
  87. package/fonts/literata/vietnamese-400-normal.woff2 +0 -0
  88. package/fonts/literata/vietnamese-700-italic.woff2 +0 -0
  89. package/fonts/literata/vietnamese-700-normal.woff2 +0 -0
  90. package/fonts/nunito/LICENSE.txt +93 -0
  91. package/fonts/nunito/cyrillic-400-italic.woff2 +0 -0
  92. package/fonts/nunito/cyrillic-400-normal.woff2 +0 -0
  93. package/fonts/nunito/cyrillic-700-italic.woff2 +0 -0
  94. package/fonts/nunito/cyrillic-700-normal.woff2 +0 -0
  95. package/fonts/nunito/cyrillic-ext-400-italic.woff2 +0 -0
  96. package/fonts/nunito/cyrillic-ext-400-normal.woff2 +0 -0
  97. package/fonts/nunito/cyrillic-ext-700-italic.woff2 +0 -0
  98. package/fonts/nunito/cyrillic-ext-700-normal.woff2 +0 -0
  99. package/fonts/nunito/latin-400-italic.woff2 +0 -0
  100. package/fonts/nunito/latin-400-normal.woff2 +0 -0
  101. package/fonts/nunito/latin-700-italic.woff2 +0 -0
  102. package/fonts/nunito/latin-700-normal.woff2 +0 -0
  103. package/fonts/nunito/latin-ext-400-italic.woff2 +0 -0
  104. package/fonts/nunito/latin-ext-400-normal.woff2 +0 -0
  105. package/fonts/nunito/latin-ext-700-italic.woff2 +0 -0
  106. package/fonts/nunito/latin-ext-700-normal.woff2 +0 -0
  107. package/fonts/nunito/vietnamese-400-italic.woff2 +0 -0
  108. package/fonts/nunito/vietnamese-400-normal.woff2 +0 -0
  109. package/fonts/nunito/vietnamese-700-italic.woff2 +0 -0
  110. package/fonts/nunito/vietnamese-700-normal.woff2 +0 -0
  111. package/fonts/special-elite/LICENSE.txt +201 -0
  112. package/fonts/special-elite/latin-400-normal.woff2 +0 -0
  113. package/fonts/special-elite/latin-ext-400-normal.woff2 +0 -0
  114. package/fonts/vt323/LICENSE.txt +93 -0
  115. package/fonts/vt323/latin-400-normal.woff2 +0 -0
  116. package/fonts/vt323/latin-ext-400-normal.woff2 +0 -0
  117. package/fonts/vt323/vietnamese-400-normal.woff2 +0 -0
  118. package/game-saver.js +211 -0
  119. package/index.html +140 -52
  120. package/legacy/adapter.js +107 -0
  121. package/{grid.js → legacy/grid.js} +3 -0
  122. package/{player.js → legacy/player.js} +37 -62
  123. package/{playercore.css → legacy/playercore.css} +115 -0
  124. package/{playercore.htm → legacy/playercore.htm} +14 -13
  125. package/{playercore.js → legacy/playercore.js} +188 -252
  126. package/legacy/questui.js +515 -0
  127. package/package.json +1 -1
  128. package/v2/map.js +1 -0
  129. package/v2/player.htm +59 -0
  130. package/v2/v2.css +1 -0
  131. package/v2/v2.js +1 -0
  132. package/wasm-player.js +1359 -284
  133. package/.stamp +0 -0
  134. package/WasmPlayer.runtimeconfig.json +0 -46
  135. package/_framework/System.Collections.Concurrent.wasm +0 -0
  136. package/_framework/dotnet.boot.js +0 -284
  137. /package/{lib → legacy/lib}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  138. /package/{lib → legacy/lib}/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  139. /package/{lib → legacy/lib}/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  140. /package/{lib → legacy/lib}/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  141. /package/{lib → legacy/lib}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  142. /package/{lib → legacy/lib}/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  143. /package/{lib → legacy/lib}/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  144. /package/{lib → legacy/lib}/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  145. /package/{lib → legacy/lib}/images/ui-icons_217bc0_256x240.png +0 -0
  146. /package/{lib → legacy/lib}/images/ui-icons_2e83ff_256x240.png +0 -0
  147. /package/{lib → legacy/lib}/images/ui-icons_469bdd_256x240.png +0 -0
  148. /package/{lib → legacy/lib}/images/ui-icons_6da8d5_256x240.png +0 -0
  149. /package/{lib → legacy/lib}/images/ui-icons_cd0a0a_256x240.png +0 -0
  150. /package/{lib → legacy/lib}/images/ui-icons_d8e7f3_256x240.png +0 -0
  151. /package/{lib → legacy/lib}/images/ui-icons_f9bd01_256x240.png +0 -0
  152. /package/{lib → legacy/lib}/jquery-2.1.1.min.js +0 -0
  153. /package/{lib → legacy/lib}/jquery-ui.min.css +0 -0
  154. /package/{lib → legacy/lib}/jquery-ui.min.js +0 -0
  155. /package/{lib → legacy/lib}/jquery.multi-open-accordion-1.5.3.js +0 -0
  156. /package/{lib → legacy/lib}/paper.js +0 -0
@@ -13,12 +13,11 @@ var beginningOfCurrentTurnScrollPosition = 0;
13
13
  // that hasn't been saved anywhere (slot or file) yet, so an accidental
14
14
  // refresh/close can warn before silently discarding it (see beforeunload
15
15
  // listener below). canSave mirrors the last value passed to
16
- // WebPlayer.setCanSave (both playerweb.js's and wasm-player.js's versions
17
- // keep this in sync) — if saving isn't even offered, there's nothing the
18
- // player could do about unsaved progress, so the warning is pointless. This
19
- // is what keeps the legacy editor's preview page (Editor.razor's
20
- // EnableSave="false") and WasmPlayer's editor-preview mode — both of which
21
- // reload on every edit — from being nagged by the warning on every reload.
16
+ // WebPlayer.setCanSave (wasm-player.js keeps this in sync) — if saving isn't
17
+ // even offered, there's nothing the player could do about unsaved progress,
18
+ // so the warning is pointless. This is what keeps WasmPlayer's editor-preview
19
+ // mode, which reloads on every edit, from being nagged by the warning on
20
+ // every reload.
22
21
  var hasUnsavedProgress = false;
23
22
  var canSave = true;
24
23
 
@@ -40,12 +39,18 @@ function initPlayerUI() {
40
39
  const gameBorder = document.getElementById("gameBorder");
41
40
  gameBorder.style.display = "block";
42
41
 
42
+ // The verb menus' classic Arial at 9pt. 610 Core leaves the menu font out when a game
43
+ // doesn't set one, so v2 can use its interface font (#2725); a game's own, from its tokens or
44
+ // an older Core, replaces this.
45
+ SetMenuFontName("Arial");
46
+ SetMenuFontSize("9pt");
47
+
43
48
  addPaperScript();
44
49
 
45
50
  $("#txtCommand").bind("inview", function (event, visible) {
46
51
  // allows spacebar to scroll browser when txtCommand is not visible
47
52
  if (visible == true) {
48
- if (!_touchedElsewhere) $("#txtCommand").focus();
53
+ if (!_touchedElsewhere && !verbMenuHasFocus()) $("#txtCommand").focus();
49
54
  } else {
50
55
  $("#txtCommand").blur();
51
56
  }
@@ -75,25 +80,8 @@ function initPlayerUI() {
75
80
  await GameSaver.save();
76
81
  }));
77
82
 
78
- const cmdDebug = document.getElementById("cmdDebug");
79
- cmdDebug.addEventListener("click", () => {
80
- const dialog = document.getElementById("questVivaDebugger");
81
- dialog.showModal();
82
- });
83
-
84
- $("#lstInventory").selectable({
85
- selected: function (event, ui) {
86
- $(ui.selected).siblings().removeClass("ui-selected");
87
- updateVerbButtons($(ui.selected), inventoryVerbs, "cmdInventory");
88
- }
89
- });
90
-
91
- $("#lstPlacesObjects").selectable({
92
- selected: function (event, ui) {
93
- $(ui.selected).siblings().removeClass("ui-selected");
94
- updateVerbButtons($(ui.selected), placesObjectsVerbs, "cmdPlacesObjects");
95
- }
96
- });
83
+ initElementList("#lstInventory", "inventoryLabel", function () { return inventoryVerbs; }, "cmdInventory");
84
+ initElementList("#lstPlacesObjects", "placesObjectsLabel", function () { return placesObjectsVerbs; }, "cmdPlacesObjects");
97
85
 
98
86
  $("#cmdCompassNW").button({
99
87
  icons: {primary: "ui-icon-arrowthick-1-nw"}
@@ -159,7 +147,7 @@ function initPlayerUI() {
159
147
 
160
148
  $(document).on("click", ".commandlink", function () {
161
149
  var $this = $(this);
162
- if (!$this.hasClass("disabled") && canSendCommand) {
150
+ if (!$this.hasClass("disabled") && canSendCommand && !_dialogPending) {
163
151
  if ($this.data("deactivateonclick")) {
164
152
  $this.addClass("disabled");
165
153
  $this.data("deactivated", true);
@@ -254,7 +242,9 @@ function initPlayerUI() {
254
242
  if (wasWide) {
255
243
  sidebar.style.display = "none";
256
244
  }
257
- sidebar.style.background = "#fff";
245
+ // The drawer takes a pane colour scheme's background (setPanes), so a dark one
246
+ // isn't a white panel with dark panes inside it (#2359).
247
+ sidebar.style.background = _sidebarBackground || "#fff";
258
248
  sidebar.style.boxShadow = "-2px 0 5px rgba(0,0,0,0.5)";
259
249
  cmdShowPanes.style.display = arePanesVisible ? "inline" : "none";
260
250
  gamePanes.style.left = "initial";
@@ -312,6 +302,7 @@ function initPlayerUI() {
312
302
  $("#gamePanes").hide();
313
303
  }
314
304
  doLayout();
305
+ updateExitStrip();
315
306
  };
316
307
 
317
308
  const updatePanelImageMaxHeight = (newMaxHeight) => {
@@ -415,7 +406,8 @@ var _pauseMode = false;
415
406
  // pause's pending restore is swallowed and the command bar never comes back.
416
407
  var _pauseRestorePending = false;
417
408
 
418
- // Mirrors the engine's WorldModel._pendingCallbackCount > 0: true whenever
409
+ // Mirrors the v5+ engine's WorldModel._pendingCallbackCount > 0 (or a legacy
410
+ // game's outstanding wait/enter in V4Game): true whenever
419
411
  // anything is suspended inside a TaskCompletionSource continuation (wait(),
420
412
  // get input(), ask, show menu, pause) that a save/reload can't reconstruct -
421
413
  // only world-model data is serialized, not "what the interpreter was doing".
@@ -438,11 +430,13 @@ function updateSaveButtonEnabled() {
438
430
  function setTurnPending(pending) {
439
431
  _turnPending = pending;
440
432
  updateSaveButtonEnabled();
433
+ updateExitStrip();
441
434
  }
442
435
 
443
436
  function beginPause(ms) {
444
437
  _pauseMode = true;
445
438
  $("#txtCommandDiv").hide();
439
+ updateExitStrip();
446
440
  window.setTimeout(function () {
447
441
  endPause()
448
442
  }, ms);
@@ -455,24 +449,17 @@ function endPause() {
455
449
  // here made it flash into view for the length of the round trip whenever the
456
450
  // resumed script went straight into another pause (same bug as endWait()).
457
451
  _pauseRestorePending = true;
458
-
459
- // TODO: This is WebPlayer-specific, so shouldn't be in this shared file
460
- window.setTimeout(async function () {
461
- try {
462
- await WebPlayer.uiEndPause();
463
- } finally {
464
- pauseEnded();
465
- }
466
- }, 100);
452
+ sendEndPause();
467
453
  }
468
454
 
469
- // Called once the engine has resumed the paused turn and run on to its next
470
- // stopping point, so anything that turn did to the command bar has already
471
- // happened: another pause (beginPause), the end of the game (disableInterface)
455
+ // Called by the platform's sendEndPause() once the engine has resumed the
456
+ // paused turn and run on to its next stopping point, so anything that turn did
457
+ // to the command bar has already happened: another pause (beginPause), the end of the game (disableInterface)
472
458
  // or a synchronous sound (playSound), each of which owns the command bar until
473
459
  // it restores it itself.
474
460
  function pauseEnded() {
475
461
  _pauseRestorePending = false;
462
+ updateExitStrip();
476
463
  if (_pauseMode || _gameFinished || _waitingForSoundToFinish) return;
477
464
  $("#txtCommandDiv").show();
478
465
  focusCommandInput();
@@ -506,7 +493,7 @@ function commandKey(e) {
506
493
 
507
494
  function runCommand() {
508
495
  var command = $("#txtCommand").val();
509
- if (command.length > 0 && canSendCommand) {
496
+ if (command.length > 0 && canSendCommand && !_dialogPending) {
510
497
  numCommands++;
511
498
  commandsList[numCommands] = command;
512
499
  thisCommand = numCommands + 1;
@@ -548,6 +535,7 @@ function openMsgbox(options) {
548
535
  }
549
536
 
550
537
  function showQuestion(title) {
538
+ dialogOpened();
551
539
  $("#msgboxCaption").html(title);
552
540
 
553
541
  var msgboxOptions = {
@@ -583,6 +571,7 @@ function uiShow(element) {
583
571
  $(element).show();
584
572
  updateStatusVisibility();
585
573
  }
574
+ updateExitStrip();
586
575
  }
587
576
 
588
577
  function uiHide(element) {
@@ -592,6 +581,7 @@ function uiHide(element) {
592
581
  $(element).hide();
593
582
  updateStatusVisibility();
594
583
  }
584
+ updateExitStrip();
595
585
  }
596
586
 
597
587
  function updateStatusVisibility() {
@@ -797,10 +787,21 @@ document.addEventListener("pointerdown", function (e) {
797
787
  // same function to restore focus once the command bar comes back.
798
788
  function focusCommandInput() {
799
789
  if (_touchedElsewhere) return;
790
+ if (verbMenuHasFocus()) return;
800
791
  if (!isElementVisible("#txtCommandDiv") || !isElementVisible("#txtCommand")) return;
801
792
  document.getElementById("txtCommand")?.focus({preventScroll: true});
802
793
  }
803
794
 
795
+ // True while the player is in an open verb menu. Nothing the game does by itself
796
+ // (a turn ending, a picture finishing loading and re-scrolling, the command bar
797
+ // scrolling into view) should take focus out of one: the menu's keys (arrows,
798
+ // Enter, Escape) only work while one of its items has focus, so a game that had just
799
+ // loaded could leave the player in a menu they can't close from the keyboard.
800
+ function verbMenuHasFocus() {
801
+ var active = document.activeElement;
802
+ return !!(active && active.closest && active.closest("div[id^=jjmenu]"));
803
+ }
804
+
804
805
  // beginningOfCurrentTurnScrollPosition is set by markScrollPosition() before
805
806
  // the turn began (see its own doc comment).
806
807
  function scrollToEnd() {
@@ -912,6 +913,8 @@ var _compassDirs = ["northwest", "north", "northeast", "west", "east", "southwes
912
913
 
913
914
  function updateCompass(listData) {
914
915
  var directions = listData.split("/");
916
+ _exitStripDirections = directions;
917
+ updateExitStrip();
915
918
  updateDir(directions, "NW", _compassDirs[0]);
916
919
  updateDir(directions, "N", _compassDirs[1]);
917
920
  updateDir(directions, "NE", _compassDirs[2]);
@@ -934,6 +937,55 @@ function updateDir(directions, label, dir) {
934
937
  }
935
938
  }
936
939
 
940
+ // On a narrow window the compass is tucked away in the hamburger overlay, so
941
+ // every move meant opening it, scrolling down to the compass and closing it
942
+ // again to read what happened. #qv-exits repeats just the available exits as a
943
+ // row of buttons under the transcript instead (issue #2183).
944
+ //
945
+ // It's a separate element rather than the compass itself moved into place:
946
+ // published games carry their own copy of Core.aslx, which hides the compass,
947
+ // reorders it and recolours its buttons by these exact ids, so the compass DOM
948
+ // has to stay where it is. The strip follows it instead - shown only while the
949
+ // compass would be (not turned off, panes showing, game not over), and only
950
+ // between turns, so a tap can't be swallowed as the answer to a get input or
951
+ // menu. playercore.css only shows it on the narrow layout.
952
+ var _exitStripDirections = [];
953
+ var _exitStripArrows = ["\u2196", "\u2191", "\u2197", "\u2190", "\u2192", "\u2199", "\u2193", "\u2198", "\u21A5", "\u21A7", "", ""];
954
+ var _exitStripButtonIds = ["NW", "N", "NE", "W", "E", "SW", "S", "SE", "U", "D", "In", "Out"];
955
+
956
+ function updateExitStrip() {
957
+ var strip = document.getElementById("qv-exits");
958
+ if (!strip) return;
959
+ strip.replaceChildren();
960
+ var compassShowing = isElementVisible("#gamePanes") && isElementVisible("#gamePanesRunning")
961
+ && isElementVisible("#compassLabel");
962
+ var betweenTurns = !_turnPending && !_waitMode && !_pauseMode && !_gameFinished;
963
+ if (compassShowing && betweenTurns) {
964
+ _compassDirs.forEach(function (dir, i) {
965
+ if ($.inArray(dir, _exitStripDirections) == -1) return;
966
+ var button = document.createElement("button");
967
+ button.type = "button";
968
+ button.className = "qv-exit";
969
+ // "in"/"out" have their own interface strings for the label, which
970
+ // can differ from the command (setInterfaceString's In/OutButtonLabel).
971
+ var label = (i >= 10 && $("#cmdCompass" + _exitStripButtonIds[i]).text().trim()) || dir;
972
+ if (_exitStripArrows[i]) {
973
+ var arrow = document.createElement("span");
974
+ arrow.className = "qv-exit-arrow";
975
+ arrow.setAttribute("aria-hidden", "true");
976
+ arrow.textContent = _exitStripArrows[i];
977
+ button.appendChild(arrow);
978
+ }
979
+ button.appendChild(document.createTextNode(label));
980
+ button.addEventListener("click", function () {
981
+ compassClick(_compassDirs[i]);
982
+ });
983
+ strip.appendChild(button);
984
+ });
985
+ }
986
+ strip.classList.toggle("qv-exits-active", strip.childElementCount > 0);
987
+ }
988
+
937
989
  function paneButtonClick(target, button) {
938
990
  var selectedListItem = $(target + " .ui-selected");
939
991
  var selectedObject = selectedListItem.text();
@@ -997,6 +1049,51 @@ function respondToGridClicks(flag) {
997
1049
  _respondToGridClicks = flag;
998
1050
  }
999
1051
 
1052
+ // The Inventory and Places and Objects lists, as listboxes the keyboard can reach (#2358). The
1053
+ // list is one Tab stop; the arrow keys, Home and End move through it and select as they go, which
1054
+ // shows that item's verb buttons. Enter or Space selects the item and moves on to its first verb
1055
+ // button. The mouse still selects with jQuery UI's selectable.
1056
+ function initElementList(listSelector, labelId, getVerbs, buttonPrefix) {
1057
+ var $list = $(listSelector);
1058
+ $list.attr({ role: "listbox", "aria-labelledby": labelId });
1059
+
1060
+ $list.selectable({
1061
+ selected: function (event, ui) {
1062
+ selectListItem($(ui.selected), getVerbs(), buttonPrefix);
1063
+ }
1064
+ });
1065
+
1066
+ $list.on("keydown", "li", function (e) {
1067
+ var $items = $list.children("li");
1068
+ var index = $items.index(this);
1069
+ var next = -1;
1070
+ switch (e.key) {
1071
+ case "ArrowDown": next = Math.min(index + 1, $items.length - 1); break;
1072
+ case "ArrowUp": next = Math.max(index - 1, 0); break;
1073
+ case "Home": next = 0; break;
1074
+ case "End": next = $items.length - 1; break;
1075
+ case "Enter":
1076
+ case " ":
1077
+ e.preventDefault();
1078
+ selectListItem($(this), getVerbs(), buttonPrefix);
1079
+ $("[id^=" + buttonPrefix + "]:visible").first().trigger("focus");
1080
+ return;
1081
+ default:
1082
+ return;
1083
+ }
1084
+ e.preventDefault();
1085
+ var $next = $items.eq(next);
1086
+ selectListItem($next, getVerbs(), buttonPrefix);
1087
+ $next.trigger("focus");
1088
+ });
1089
+ }
1090
+
1091
+ function selectListItem($item, verbsArray, buttonPrefix) {
1092
+ $item.siblings().removeClass("ui-selected").attr({ "aria-selected": "false", tabindex: "-1" });
1093
+ $item.addClass("ui-selected").attr({ "aria-selected": "true", tabindex: "0" });
1094
+ updateVerbButtons($item, verbsArray, buttonPrefix);
1095
+ }
1096
+
1000
1097
  function updateList(listName, listData) {
1001
1098
  var listElement = "";
1002
1099
  var buttonPrefix = "";
@@ -1023,6 +1120,7 @@ function updateList(listName, listData) {
1023
1120
  previousSelectionKey = $selected.first().data("key");
1024
1121
  }
1025
1122
 
1123
+ var listHadFocus = $.contains($(listElement)[0], document.activeElement);
1026
1124
  $(listElement).empty();
1027
1125
  var count = 0;
1028
1126
  $.each(listData, function (key, value) {
@@ -1041,9 +1139,10 @@ function updateList(listName, listData) {
1041
1139
  verbsArray.push(data);
1042
1140
 
1043
1141
  if (listName == "inventory" || $.inArray(objectDisplayName, _compassDirs) == -1) {
1044
- var $newItem = $("<li/>").data("key", key).data("elementid", data["ElementId"]).data("elementname", data["ElementName"]).data("index", count).html(objectDisplayName);
1142
+ var $newItem = $("<li/>").data("key", key).data("elementid", data["ElementId"]).data("elementname", data["ElementName"]).data("index", count).html(objectDisplayName)
1143
+ .attr({ role: "option", tabindex: "-1", "aria-selected": "false" });
1045
1144
  if (objectDisplayName == previousSelectionText && key == previousSelectionKey) {
1046
- $newItem.addClass("ui-selected");
1145
+ $newItem.addClass("ui-selected").attr("aria-selected", "true");
1047
1146
  foundPreviousSelection = true;
1048
1147
  updateVerbButtons($newItem, verbsArray, idPrefix);
1049
1148
  }
@@ -1052,6 +1151,14 @@ function updateList(listName, listData) {
1052
1151
  }
1053
1152
  });
1054
1153
 
1154
+ // The list is one Tab stop: the selected item, or the first. If the list had focus, it stays
1155
+ // in the list rather than dropping to the page when the old items go.
1156
+ var $items = $(listElement).children("li");
1157
+ var $current = $items.filter(".ui-selected").first();
1158
+ if (!$current.length) $current = $items.first();
1159
+ $current.attr("tabindex", "0");
1160
+ if (listHadFocus && $current.length) $current.trigger("focus");
1161
+
1055
1162
  var selectSize = count;
1056
1163
  if (selectSize < 3) selectSize = 3;
1057
1164
  if (selectSize > 12) selectSize = 12;
@@ -1087,6 +1194,7 @@ function beginWait() {
1087
1194
  $("#txtCommand").hide();
1088
1195
  $("#txtCommandPrompt").hide();
1089
1196
  $("#endWaitLink").show();
1197
+ updateExitStrip();
1090
1198
  markScrollPosition();
1091
1199
  }
1092
1200
 
@@ -1108,6 +1216,7 @@ function endWait() {
1108
1216
  // unconditionally (as this used to, synchronously at click time) is what made
1109
1217
  // it flash into view for the length of the round trip between chained waits.
1110
1218
  function waitEnded() {
1219
+ updateExitStrip();
1111
1220
  if (_waitMode) return;
1112
1221
  $("#txtCommand").show();
1113
1222
  $("#txtCommandPrompt").show();
@@ -1118,6 +1227,7 @@ function gameFinished() {
1118
1227
  _gameFinished = true;
1119
1228
  updateSaveButtonEnabled();
1120
1229
  disableInterface();
1230
+ updateExitStrip();
1121
1231
  }
1122
1232
 
1123
1233
  function disableInterface() {
@@ -1129,6 +1239,18 @@ function disableInterface() {
1129
1239
  function setCommandBarStyle(style) {
1130
1240
  var hidden = $("#txtCommand").is(":hidden") && $("#txtCommand").parent().is(":visible");
1131
1241
  $("#txtCommand").attr("style", style);
1242
+ // Core's command bar format carries the game's background. As an inline style it would beat
1243
+ // the borderless command box's "#txtCommand { background-color:transparent }" rule, which
1244
+ // Core adds after it, so "Use a cursor instead of a box" showed a box in the page colour over
1245
+ // a colour blend or background image (#2359). As a :where() rule it loses to any #txtCommand
1246
+ // rule, from Core or the game's own CSS, and still beats the browser's white.
1247
+ var command = document.getElementById("txtCommand");
1248
+ if (command) {
1249
+ var background = command.style.backgroundColor;
1250
+ command.style.removeProperty("background");
1251
+ command.style.removeProperty("background-color");
1252
+ setCommandBarBackground(background);
1253
+ }
1132
1254
  if (hidden) {
1133
1255
  $("#txtCommand").hide();
1134
1256
  } else {
@@ -1136,6 +1258,19 @@ function setCommandBarStyle(style) {
1136
1258
  }
1137
1259
  }
1138
1260
 
1261
+ function setCommandBarBackground(colour) {
1262
+ var rule = document.getElementById("qv-command-bar-background");
1263
+ if (!rule) {
1264
+ rule = document.createElement("style");
1265
+ rule.id = "qv-command-bar-background";
1266
+ // First in <head>, not last: it's created lazily, after the host has put the game's own
1267
+ // stylesheet (#qv-game-stylesheet) last, and must not land after it. It's only meant to
1268
+ // beat the browser's defaults, which any author style does wherever it is.
1269
+ document.head.insertBefore(rule, document.head.firstChild);
1270
+ }
1271
+ rule.textContent = colour ? ":where(#txtCommand) { background-color: " + colour + "; }" : "";
1272
+ }
1273
+
1139
1274
  function addTextAndScroll(text) {
1140
1275
  addText(text);
1141
1276
  scrollToEnd();
@@ -1403,16 +1538,6 @@ function keyPressCode(e) {
1403
1538
  return keynum;
1404
1539
  }
1405
1540
 
1406
- function addExternalStylesheet(source) {
1407
- var link = $("<link>");
1408
- link.attr({
1409
- type: "text/css",
1410
- rel: "stylesheet",
1411
- href: source
1412
- });
1413
- $("head").append(link);
1414
- }
1415
-
1416
1541
  function setInterfaceString(name, text) {
1417
1542
  switch (name) {
1418
1543
  case "InventoryLabel":
@@ -1426,12 +1551,15 @@ function setInterfaceString(name, text) {
1426
1551
  break;
1427
1552
  case "CompassLabel":
1428
1553
  $("#compassLabel button.accordion-header-text").html(text);
1554
+ $("#qv-exits").attr("aria-label", $("<div>").html(text).text());
1429
1555
  break;
1430
1556
  case "InButtonLabel":
1431
1557
  $("#cmdCompassIn span").html(text);
1558
+ updateExitStrip();
1432
1559
  break;
1433
1560
  case "OutButtonLabel":
1434
1561
  $("#cmdCompassOut span").html(text);
1562
+ updateExitStrip();
1435
1563
  break;
1436
1564
  case "EmptyListLabel":
1437
1565
  break;
@@ -1877,6 +2005,8 @@ function setCompass(name, fore, back) {
1877
2005
  el.css('border', '2px solid ' + fore);
1878
2006
  }
1879
2007
 
2008
+ var _sidebarBackground = "";
2009
+
1880
2010
  function setPanes(fore, back, secFore, secBack, highlight) {
1881
2011
  if (arguments.length == 2) {
1882
2012
  secFore = back;
@@ -1886,6 +2016,10 @@ function setPanes(fore, back, secFore, secBack, highlight) {
1886
2016
  highlight = 'orange'
1887
2017
  }
1888
2018
  commandColour = fore;
2019
+ _sidebarBackground = back;
2020
+ if (document.body.classList.contains("qv-narrow")) {
2021
+ document.getElementById("sidebar").style.background = back;
2022
+ }
1889
2023
  for (i = 0; i < elements.length; i++) {
1890
2024
  setElement(elements[i], fore, back);
1891
2025
  }
@@ -2838,201 +2972,3 @@ function whereAmI() {
2838
2972
  }
2839
2973
 
2840
2974
  var platform = "desktop";
2841
-
2842
- // Applies a resolved chrome-strings dictionary (see ChromeStrings.Resolve in
2843
- // PlayerCore, surfaced via WebPlayer.setChromeStrings/Bridge.GetChromeStringsJson,
2844
- // or a save's snapshot - see GameSaver.save below) to every chrome element
2845
- // tagged with a data-chrome-key* attribute, e.g. the #cmdSave button and the
2846
- // #qv-saves/Slots dialog. dict is always fully populated (every key defaults
2847
- // to English), so a missing key here just means dict itself is null/undefined
2848
- // (no game loaded, no snapshot available) - existing markup is left untouched
2849
- // in that case. Shared by both players (playercore.htm's chrome is common to
2850
- // both), called from wasm-player.js and from WebPlayer.setChromeStrings below.
2851
- function applyChromeStrings(dict) {
2852
- if (!dict) return;
2853
- document.querySelectorAll('[data-chrome-key]').forEach(el => {
2854
- const value = dict[el.dataset.chromeKey];
2855
- if (value) el.textContent = value;
2856
- });
2857
- document.querySelectorAll('[data-chrome-key-placeholder]').forEach(el => {
2858
- const value = dict[el.dataset.chromeKeyPlaceholder];
2859
- if (value) el.placeholder = value;
2860
- });
2861
- document.querySelectorAll('[data-chrome-key-aria-label]').forEach(el => {
2862
- const value = dict[el.dataset.chromeKeyAriaLabel];
2863
- if (value) el.setAttribute('aria-label', value);
2864
- });
2865
- }
2866
-
2867
- const GameSaver = (() => {
2868
- // Electron: file storage under userData rather than IndexedDB, since
2869
- // this window's origin (a local loopback port) isn't guaranteed to stay
2870
- // the same across restarts — see save-store.ts. window.electronGameSaves
2871
- // is bridged by player-preload.ts for every player window.
2872
- function useElectronGameSaves() {
2873
- return navigator.userAgent.includes('Electron/') && !!window.electronGameSaves;
2874
- }
2875
-
2876
- function openDatabase() {
2877
- return new Promise((resolve, reject) => {
2878
- const request = indexedDB.open('quest-viva-saves', 1);
2879
-
2880
- request.onupgradeneeded = () => {
2881
- const db = request.result;
2882
- if (!db.objectStoreNames.contains('saves')) {
2883
- db.createObjectStore('saves', {keyPath: ['gameId', 'slotIndex']});
2884
- }
2885
- };
2886
-
2887
- request.onsuccess = () => resolve(request.result);
2888
- request.onerror = () => reject(request.error);
2889
- });
2890
- }
2891
-
2892
- async function ensurePersistentStorage() {
2893
- if (navigator.storage && navigator.storage.persist) {
2894
- const isPersisted = await navigator.storage.persisted();
2895
- if (isPersisted) {
2896
- console.log('Storage is already persistent.');
2897
- return true;
2898
- }
2899
-
2900
- const granted = await navigator.storage.persist();
2901
- if (granted) {
2902
- console.log('Storage permission granted: persistent!');
2903
- } else {
2904
- console.warn('Persistent storage request was denied.');
2905
- }
2906
- return granted;
2907
- } else {
2908
- console.warn('StorageManager API not supported.');
2909
- return false;
2910
- }
2911
- }
2912
-
2913
- async function saveGame(gameId, slotIndex, dataUint8Array, name) {
2914
- const chromeStrings = window.WebPlayer?.chromeStrings ?? null;
2915
- if (useElectronGameSaves()) {
2916
- await window.electronGameSaves.save(gameId, slotIndex, dataUint8Array, name || null, chromeStrings);
2917
- return;
2918
- }
2919
- const db = await openDatabase();
2920
- const tx = db.transaction('saves', 'readwrite');
2921
- const store = tx.objectStore('saves');
2922
-
2923
- const entry = {
2924
- gameId,
2925
- slotIndex,
2926
- data: dataUint8Array,
2927
- name,
2928
- timestamp: new Date(),
2929
- // Snapshot of the game's own chrome-string translations at the moment
2930
- // it was saved - lets the boot-time "Continue your game?" prompt show
2931
- // the right language next session, before anything is parsed into a
2932
- // WorldModel (see WebPlayer.setChromeStrings / Bridge.GetChromeStringsJson).
2933
- chromeStrings
2934
- };
2935
-
2936
- store.put(entry);
2937
-
2938
- return tx.complete || tx.done || new Promise((res, rej) => {
2939
- tx.oncomplete = res;
2940
- tx.onerror = rej;
2941
- });
2942
- }
2943
-
2944
- async function listSaves(gameId) {
2945
- if (useElectronGameSaves()) {
2946
- return await window.electronGameSaves.list(gameId);
2947
- }
2948
- const db = await openDatabase();
2949
- const tx = db.transaction('saves', 'readonly');
2950
- const store = tx.objectStore('saves');
2951
-
2952
- const request = store.getAll();
2953
-
2954
- return new Promise((resolve, reject) => {
2955
- request.onsuccess = () => {
2956
- const slots = request.result
2957
- .filter(entry => entry.gameId === gameId)
2958
- .map(entry => ({
2959
- slotIndex: entry.slotIndex,
2960
- name: entry.name || null,
2961
- timestamp: entry.timestamp || null,
2962
- chromeStrings: entry.chromeStrings || null,
2963
- }));
2964
-
2965
- resolve(slots);
2966
- };
2967
- request.onerror = () => reject(request.error);
2968
- });
2969
- }
2970
-
2971
- async function loadGame(gameId, slotIndex) {
2972
- if (useElectronGameSaves()) {
2973
- return await window.electronGameSaves.load(gameId, slotIndex);
2974
- }
2975
- const db = await openDatabase();
2976
- const tx = db.transaction('saves', 'readonly');
2977
- const store = tx.objectStore('saves');
2978
- const request = store.get([gameId, slotIndex]);
2979
-
2980
- return new Promise((resolve, reject) => {
2981
- request.onsuccess = () => resolve(request.result?.data || null);
2982
- request.onerror = () => reject(request.error);
2983
- });
2984
- }
2985
-
2986
- async function deleteSaveSlot(gameId, slotIndex) {
2987
- if (useElectronGameSaves()) {
2988
- await window.electronGameSaves.delete(gameId, slotIndex);
2989
- return;
2990
- }
2991
- const db = await openDatabase();
2992
- const tx = db.transaction('saves', 'readwrite');
2993
- const store = tx.objectStore('saves');
2994
- store.delete([gameId, slotIndex]);
2995
-
2996
- return tx.complete || tx.done || new Promise((res, rej) => {
2997
- tx.oncomplete = res;
2998
- tx.onerror = rej;
2999
- });
3000
- }
3001
-
3002
- async function nextSlotIndex(gameId) {
3003
- const existing = await listSaves(gameId);
3004
- return existing.length ? Math.max(...existing.map(s => s.slotIndex)) + 1 : 0;
3005
- }
3006
-
3007
- let persistenceRequested = false;
3008
-
3009
- return {
3010
- save: async (name) => {
3011
- const gameId = WebPlayer.gameId;
3012
- const saveData = $("#divOutput").html();
3013
- const result = await WebPlayer.uiSaveGame(saveData);
3014
- const slotIndex = await nextSlotIndex(gameId);
3015
- // Locale-formatted (not ISO) so it reads naturally wherever it's shown —
3016
- // WebPlayer's Slots list shows only the name, with no separate timestamp.
3017
- const labelTemplate = window.WebPlayer?.chromeStrings?.SavedGameDefaultLabel || "Saved game — [timestamp]";
3018
- const label = name || labelTemplate.replace('[timestamp]', new Date().toLocaleString());
3019
- await saveGame(gameId, slotIndex, result, label);
3020
- addText("Game saved.<br>");
3021
- clearUnsavedProgress();
3022
- if (!persistenceRequested) {
3023
- await ensurePersistentStorage();
3024
- persistenceRequested = true;
3025
- }
3026
- return {slotIndex, name: label};
3027
- },
3028
- listSaves: async (gameId = WebPlayer.gameId) => {
3029
- return await listSaves(gameId);
3030
- },
3031
- load: async (slotIndex, gameId = WebPlayer.gameId) => {
3032
- return await loadGame(gameId, slotIndex);
3033
- },
3034
- deleteSlot: async (slotIndex, gameId = WebPlayer.gameId) => {
3035
- return await deleteSaveSlot(gameId, slotIndex);
3036
- }
3037
- }
3038
- })();