@textadventures/quest-viva-wasmplayer 6.0.0-beta.50

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 (227) hide show
  1. package/.stamp +0 -0
  2. package/WasmPlayer.runtimeconfig.json +46 -0
  3. package/_framework/Common.wasm +0 -0
  4. package/_framework/Engine.wasm +0 -0
  5. package/_framework/ExtendedNumerics.BigDecimal.wasm +0 -0
  6. package/_framework/Legacy.wasm +0 -0
  7. package/_framework/Microsoft.CSharp.wasm +0 -0
  8. package/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.wasm +0 -0
  9. package/_framework/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
  10. package/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  11. package/_framework/Microsoft.VisualBasic.wasm +0 -0
  12. package/_framework/Microsoft.Win32.Primitives.wasm +0 -0
  13. package/_framework/Microsoft.Win32.Registry.wasm +0 -0
  14. package/_framework/NCalc.Async.wasm +0 -0
  15. package/_framework/NCalc.Core.wasm +0 -0
  16. package/_framework/NCalc.Domain.wasm +0 -0
  17. package/_framework/NCalc.Parser.wasm +0 -0
  18. package/_framework/Parlot.wasm +0 -0
  19. package/_framework/PlayerCore.wasm +0 -0
  20. package/_framework/System.AppContext.wasm +0 -0
  21. package/_framework/System.Buffers.wasm +0 -0
  22. package/_framework/System.Collections.Concurrent.wasm +0 -0
  23. package/_framework/System.Collections.Immutable.wasm +0 -0
  24. package/_framework/System.Collections.NonGeneric.wasm +0 -0
  25. package/_framework/System.Collections.Specialized.wasm +0 -0
  26. package/_framework/System.Collections.wasm +0 -0
  27. package/_framework/System.ComponentModel.Annotations.wasm +0 -0
  28. package/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
  29. package/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
  30. package/_framework/System.ComponentModel.Primitives.wasm +0 -0
  31. package/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  32. package/_framework/System.ComponentModel.wasm +0 -0
  33. package/_framework/System.Configuration.wasm +0 -0
  34. package/_framework/System.Console.wasm +0 -0
  35. package/_framework/System.Core.wasm +0 -0
  36. package/_framework/System.Data.Common.wasm +0 -0
  37. package/_framework/System.Data.DataSetExtensions.wasm +0 -0
  38. package/_framework/System.Data.wasm +0 -0
  39. package/_framework/System.Diagnostics.Contracts.wasm +0 -0
  40. package/_framework/System.Diagnostics.Debug.wasm +0 -0
  41. package/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
  42. package/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
  43. package/_framework/System.Diagnostics.Process.wasm +0 -0
  44. package/_framework/System.Diagnostics.StackTrace.wasm +0 -0
  45. package/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
  46. package/_framework/System.Diagnostics.Tools.wasm +0 -0
  47. package/_framework/System.Diagnostics.TraceSource.wasm +0 -0
  48. package/_framework/System.Diagnostics.Tracing.wasm +0 -0
  49. package/_framework/System.Drawing.Primitives.wasm +0 -0
  50. package/_framework/System.Drawing.wasm +0 -0
  51. package/_framework/System.Dynamic.Runtime.wasm +0 -0
  52. package/_framework/System.Formats.Asn1.wasm +0 -0
  53. package/_framework/System.Formats.Tar.wasm +0 -0
  54. package/_framework/System.Globalization.Calendars.wasm +0 -0
  55. package/_framework/System.Globalization.Extensions.wasm +0 -0
  56. package/_framework/System.Globalization.wasm +0 -0
  57. package/_framework/System.IO.Compression.Brotli.wasm +0 -0
  58. package/_framework/System.IO.Compression.FileSystem.wasm +0 -0
  59. package/_framework/System.IO.Compression.ZipFile.wasm +0 -0
  60. package/_framework/System.IO.Compression.wasm +0 -0
  61. package/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
  62. package/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
  63. package/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
  64. package/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
  65. package/_framework/System.IO.FileSystem.wasm +0 -0
  66. package/_framework/System.IO.IsolatedStorage.wasm +0 -0
  67. package/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
  68. package/_framework/System.IO.Pipelines.wasm +0 -0
  69. package/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
  70. package/_framework/System.IO.Pipes.wasm +0 -0
  71. package/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
  72. package/_framework/System.IO.wasm +0 -0
  73. package/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
  74. package/_framework/System.Linq.Expressions.wasm +0 -0
  75. package/_framework/System.Linq.Parallel.wasm +0 -0
  76. package/_framework/System.Linq.Queryable.wasm +0 -0
  77. package/_framework/System.Linq.wasm +0 -0
  78. package/_framework/System.Memory.wasm +0 -0
  79. package/_framework/System.Net.Http.Json.wasm +0 -0
  80. package/_framework/System.Net.Http.wasm +0 -0
  81. package/_framework/System.Net.HttpListener.wasm +0 -0
  82. package/_framework/System.Net.Mail.wasm +0 -0
  83. package/_framework/System.Net.NameResolution.wasm +0 -0
  84. package/_framework/System.Net.NetworkInformation.wasm +0 -0
  85. package/_framework/System.Net.Ping.wasm +0 -0
  86. package/_framework/System.Net.Primitives.wasm +0 -0
  87. package/_framework/System.Net.Quic.wasm +0 -0
  88. package/_framework/System.Net.Requests.wasm +0 -0
  89. package/_framework/System.Net.Security.wasm +0 -0
  90. package/_framework/System.Net.ServerSentEvents.wasm +0 -0
  91. package/_framework/System.Net.ServicePoint.wasm +0 -0
  92. package/_framework/System.Net.Sockets.wasm +0 -0
  93. package/_framework/System.Net.WebClient.wasm +0 -0
  94. package/_framework/System.Net.WebHeaderCollection.wasm +0 -0
  95. package/_framework/System.Net.WebProxy.wasm +0 -0
  96. package/_framework/System.Net.WebSockets.Client.wasm +0 -0
  97. package/_framework/System.Net.WebSockets.wasm +0 -0
  98. package/_framework/System.Net.wasm +0 -0
  99. package/_framework/System.Numerics.Vectors.wasm +0 -0
  100. package/_framework/System.Numerics.wasm +0 -0
  101. package/_framework/System.ObjectModel.wasm +0 -0
  102. package/_framework/System.Private.CoreLib.wasm +0 -0
  103. package/_framework/System.Private.DataContractSerialization.wasm +0 -0
  104. package/_framework/System.Private.Uri.wasm +0 -0
  105. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  106. package/_framework/System.Private.Xml.wasm +0 -0
  107. package/_framework/System.Reflection.DispatchProxy.wasm +0 -0
  108. package/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
  109. package/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
  110. package/_framework/System.Reflection.Emit.wasm +0 -0
  111. package/_framework/System.Reflection.Extensions.wasm +0 -0
  112. package/_framework/System.Reflection.Metadata.wasm +0 -0
  113. package/_framework/System.Reflection.Primitives.wasm +0 -0
  114. package/_framework/System.Reflection.TypeExtensions.wasm +0 -0
  115. package/_framework/System.Reflection.wasm +0 -0
  116. package/_framework/System.Resources.Reader.wasm +0 -0
  117. package/_framework/System.Resources.ResourceManager.wasm +0 -0
  118. package/_framework/System.Resources.Writer.wasm +0 -0
  119. package/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
  120. package/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
  121. package/_framework/System.Runtime.Extensions.wasm +0 -0
  122. package/_framework/System.Runtime.Handles.wasm +0 -0
  123. package/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  124. package/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
  125. package/_framework/System.Runtime.InteropServices.wasm +0 -0
  126. package/_framework/System.Runtime.Intrinsics.wasm +0 -0
  127. package/_framework/System.Runtime.Loader.wasm +0 -0
  128. package/_framework/System.Runtime.Numerics.wasm +0 -0
  129. package/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
  130. package/_framework/System.Runtime.Serialization.Json.wasm +0 -0
  131. package/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
  132. package/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
  133. package/_framework/System.Runtime.Serialization.wasm +0 -0
  134. package/_framework/System.Runtime.wasm +0 -0
  135. package/_framework/System.Security.AccessControl.wasm +0 -0
  136. package/_framework/System.Security.Claims.wasm +0 -0
  137. package/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
  138. package/_framework/System.Security.Cryptography.Cng.wasm +0 -0
  139. package/_framework/System.Security.Cryptography.Csp.wasm +0 -0
  140. package/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
  141. package/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
  142. package/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
  143. package/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
  144. package/_framework/System.Security.Cryptography.wasm +0 -0
  145. package/_framework/System.Security.Principal.Windows.wasm +0 -0
  146. package/_framework/System.Security.Principal.wasm +0 -0
  147. package/_framework/System.Security.SecureString.wasm +0 -0
  148. package/_framework/System.Security.wasm +0 -0
  149. package/_framework/System.ServiceModel.Web.wasm +0 -0
  150. package/_framework/System.ServiceProcess.wasm +0 -0
  151. package/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  152. package/_framework/System.Text.Encoding.Extensions.wasm +0 -0
  153. package/_framework/System.Text.Encoding.wasm +0 -0
  154. package/_framework/System.Text.Encodings.Web.wasm +0 -0
  155. package/_framework/System.Text.Json.wasm +0 -0
  156. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  157. package/_framework/System.Threading.AccessControl.wasm +0 -0
  158. package/_framework/System.Threading.Channels.wasm +0 -0
  159. package/_framework/System.Threading.Overlapped.wasm +0 -0
  160. package/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
  161. package/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
  162. package/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
  163. package/_framework/System.Threading.Tasks.wasm +0 -0
  164. package/_framework/System.Threading.Thread.wasm +0 -0
  165. package/_framework/System.Threading.ThreadPool.wasm +0 -0
  166. package/_framework/System.Threading.Timer.wasm +0 -0
  167. package/_framework/System.Threading.wasm +0 -0
  168. package/_framework/System.Transactions.Local.wasm +0 -0
  169. package/_framework/System.Transactions.wasm +0 -0
  170. package/_framework/System.ValueTuple.wasm +0 -0
  171. package/_framework/System.Web.HttpUtility.wasm +0 -0
  172. package/_framework/System.Web.wasm +0 -0
  173. package/_framework/System.Windows.wasm +0 -0
  174. package/_framework/System.Xml.Linq.wasm +0 -0
  175. package/_framework/System.Xml.ReaderWriter.wasm +0 -0
  176. package/_framework/System.Xml.Serialization.wasm +0 -0
  177. package/_framework/System.Xml.XDocument.wasm +0 -0
  178. package/_framework/System.Xml.XPath.XDocument.wasm +0 -0
  179. package/_framework/System.Xml.XPath.wasm +0 -0
  180. package/_framework/System.Xml.XmlDocument.wasm +0 -0
  181. package/_framework/System.Xml.XmlSerializer.wasm +0 -0
  182. package/_framework/System.Xml.wasm +0 -0
  183. package/_framework/System.wasm +0 -0
  184. package/_framework/WasmPlayer.wasm +0 -0
  185. package/_framework/WindowsBase.wasm +0 -0
  186. package/_framework/dotnet.boot.js +1003 -0
  187. package/_framework/dotnet.js +4 -0
  188. package/_framework/dotnet.native.js +6687 -0
  189. package/_framework/dotnet.native.wasm +0 -0
  190. package/_framework/dotnet.runtime.js +4 -0
  191. package/_framework/icudt_CJK.dat +0 -0
  192. package/_framework/icudt_EFIGS.dat +0 -0
  193. package/_framework/icudt_no_CJK.dat +0 -0
  194. package/_framework/mscorlib.wasm +0 -0
  195. package/_framework/netstandard.wasm +0 -0
  196. package/chrome.css +22 -0
  197. package/favicon.svg +1 -0
  198. package/grid.js +446 -0
  199. package/index.html +214 -0
  200. package/lib/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  201. package/lib/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  202. package/lib/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  203. package/lib/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  204. package/lib/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  205. package/lib/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  206. package/lib/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  207. package/lib/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  208. package/lib/images/ui-icons_217bc0_256x240.png +0 -0
  209. package/lib/images/ui-icons_2e83ff_256x240.png +0 -0
  210. package/lib/images/ui-icons_469bdd_256x240.png +0 -0
  211. package/lib/images/ui-icons_6da8d5_256x240.png +0 -0
  212. package/lib/images/ui-icons_cd0a0a_256x240.png +0 -0
  213. package/lib/images/ui-icons_d8e7f3_256x240.png +0 -0
  214. package/lib/images/ui-icons_f9bd01_256x240.png +0 -0
  215. package/lib/jquery-2.1.1.min.js +4 -0
  216. package/lib/jquery-ui.min.css +7 -0
  217. package/lib/jquery-ui.min.js +13 -0
  218. package/lib/jquery.multi-open-accordion-1.5.3.js +261 -0
  219. package/lib/paper.js +12848 -0
  220. package/logo.svg +1 -0
  221. package/package.json +13 -0
  222. package/player.js +258 -0
  223. package/playercore.css +293 -0
  224. package/playercore.htm +206 -0
  225. package/playercore.js +2639 -0
  226. package/quest-config.js +13 -0
  227. package/wasm-player.js +2024 -0
package/playercore.js ADDED
@@ -0,0 +1,2639 @@
1
+ var _allowMenuFontSizeChange = true;
2
+ var _showGrid = false;
3
+ var _outputSections = new Array();
4
+ var numCommands = 0;
5
+ var thisCommand = 0;
6
+ var commandsList = new Array();
7
+ var inventoryVerbs = null;
8
+ var placesObjectsVerbs = null;
9
+ var verbButtonCount = 9;
10
+ var beginningOfCurrentTurnScrollPosition = 0;
11
+
12
+ // Tracks whether the player has made progress since the game started/loaded
13
+ // that hasn't been saved anywhere (slot or file) yet, so an accidental
14
+ // refresh/close can warn before silently discarding it (see beforeunload
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.
22
+ var hasUnsavedProgress = false;
23
+ var canSave = true;
24
+
25
+ function markUnsavedProgress() {
26
+ hasUnsavedProgress = true;
27
+ }
28
+
29
+ function clearUnsavedProgress() {
30
+ hasUnsavedProgress = false;
31
+ }
32
+
33
+ window.addEventListener("beforeunload", function (e) {
34
+ if (!hasUnsavedProgress || !canSave) return;
35
+ e.preventDefault();
36
+ e.returnValue = "";
37
+ });
38
+
39
+ function initPlayerUI() {
40
+ const gameBorder = document.getElementById("gameBorder");
41
+ gameBorder.style.display = "block";
42
+
43
+ addPaperScript();
44
+
45
+ $("#txtCommand").bind("inview", function (event, visible) {
46
+ // allows spacebar to scroll browser when txtCommand is not visible
47
+ if (visible == true) {
48
+ $("#txtCommand").focus();
49
+ } else {
50
+ $("#txtCommand").blur();
51
+ }
52
+ });
53
+
54
+ $("body").keydown(function (e) {
55
+ if (_waitMode) {
56
+ endWait();
57
+ }
58
+ });
59
+
60
+ $("#gameBorder button").button();
61
+ $("#gamePanesRunning").multiOpenAccordion({active: [0, 1, 2, 3]});
62
+ showStatusVisible(false);
63
+
64
+ const cmdSave = document.getElementById("cmdSave");
65
+ cmdSave.addEventListener("click", window.WebPlayer?.onSaveClick ?? (async () => {
66
+ await GameSaver.save();
67
+ }));
68
+
69
+ const cmdDebug = document.getElementById("cmdDebug");
70
+ cmdDebug.addEventListener("click", () => {
71
+ const dialog = document.getElementById("questVivaDebugger");
72
+ dialog.showModal();
73
+ });
74
+
75
+ $("#lstInventory").selectable({
76
+ selected: function (event, ui) {
77
+ $(ui.selected).siblings().removeClass("ui-selected");
78
+ updateVerbButtons($(ui.selected), inventoryVerbs, "cmdInventory");
79
+ }
80
+ });
81
+
82
+ $("#lstPlacesObjects").selectable({
83
+ selected: function (event, ui) {
84
+ $(ui.selected).siblings().removeClass("ui-selected");
85
+ updateVerbButtons($(ui.selected), placesObjectsVerbs, "cmdPlacesObjects");
86
+ }
87
+ });
88
+
89
+ $("#cmdCompassNW").button({
90
+ icons: {primary: "ui-icon-arrowthick-1-nw"}
91
+ });
92
+ $("#cmdCompassN").button({
93
+ icons: {primary: "ui-icon-arrowthick-1-n"}
94
+ });
95
+ $("#cmdCompassNE").button({
96
+ icons: {primary: "ui-icon-arrowthick-1-ne"}
97
+ });
98
+ $("#cmdCompassW").button({
99
+ icons: {primary: "ui-icon-arrowthick-1-w"}
100
+ });
101
+ $("#cmdCompassE").button({
102
+ icons: {primary: "ui-icon-arrowthick-1-e"}
103
+ });
104
+ $("#cmdCompassSW").button({
105
+ icons: {primary: "ui-icon-arrowthick-1-sw"}
106
+ });
107
+ $("#cmdCompassS").button({
108
+ icons: {primary: "ui-icon-arrowthick-1-s"}
109
+ });
110
+ $("#cmdCompassSE").button({
111
+ icons: {primary: "ui-icon-arrowthick-1-se"}
112
+ });
113
+ $("#cmdCompassU").button({
114
+ icons: {primary: "ui-icon-triangle-1-n"}
115
+ });
116
+ $("#cmdCompassD").button({
117
+ icons: {primary: "ui-icon-triangle-1-s"}
118
+ });
119
+ // fix to make compass button icons centred
120
+ $(".compassbutton span").css("left", "0.8em");
121
+
122
+ $("#txtCommand").bind('webkitspeechchange', function () {
123
+ sendCommand($("#txtCommand").val());
124
+ $("#txtCommand").val("");
125
+ });
126
+
127
+ $(document).on("click", "a", function (e) {
128
+ var href = $(this).attr("href");
129
+ if (href) {
130
+ goUrl(href);
131
+ }
132
+ e.preventDefault();
133
+ });
134
+
135
+ $(document).on("click", ".elementmenu", function (event) {
136
+ if (!$(this).hasClass("disabled")) {
137
+ event.preventDefault();
138
+ event.stopPropagation();
139
+ $(this).jjmenu_popup();
140
+ $(this).blur();
141
+ return false;
142
+ }
143
+ });
144
+
145
+ $(document).on("click", ".exitlink", function () {
146
+ if (!$(this).hasClass("disabled")) {
147
+ sendCommand($(this).attr("data-command"));
148
+ }
149
+ });
150
+
151
+ $(document).on("click", ".commandlink", function () {
152
+ var $this = $(this);
153
+ if (!$this.hasClass("disabled") && canSendCommand) {
154
+ if ($this.data("deactivateonclick")) {
155
+ $this.addClass("disabled");
156
+ $this.data("deactivated", true);
157
+ }
158
+ sendCommand($this.attr("data-command"));
159
+ }
160
+ });
161
+
162
+ // ShowMenu (and anything built on it - Ask, disambiguation) renders each
163
+ // choice as a bare <a class="cmdlink" onclick="ASLEvent(...)"> baked into the
164
+ // game's own compiled script - unlike .commandlink, it gets no client-side
165
+ // disable until the engine round-trip finishes and calls back
166
+ // disableMenuOutputSection. That's invisible on a fast round-trip, but on a
167
+ // slow one (e.g. WasmPlayer on an underpowered device) it leaves a long
168
+ // window where an impatient second click fires another ASLEvent after the
169
+ // engine has already cleared game.menucallback for the first, surfacing as
170
+ // "Unexpected menu response". This runs after the clicked link's own inline
171
+ // onclick (which fires at the target phase, before bubbling reaches this
172
+ // document-level delegate), so it can't stop that first click, but it does
173
+ // disable every live menu link before any subsequent click can be
174
+ // processed. Exact-match selector so it only catches bare ShowMenu-style
175
+ // links, not the compound-class .elementmenu/.exitlink/.commandlink ones
176
+ // that are meant to stay clickable across multiple turns. Scoped to
177
+ // #divOutput (where createNewDiv/msg append everything ShowMenu prints)
178
+ // rather than the whole document - #endWaitLink is also a bare
179
+ // class="cmdlink" for its styling, but lives in the static #endWaitDiv
180
+ // chrome outside #divOutput and must stay clickable across repeated
181
+ // wait()s; disabling it after the first would silently break every wait
182
+ // after it. Living here (rather than in the aslx ShowMenu template) means
183
+ // it protects every already-published game, not just ones re-exported
184
+ // after a library fix.
185
+ $(document).on("click", "#divOutput a[class=\"cmdlink\"]", function () {
186
+ $("#divOutput a[class=\"cmdlink\"]").addClass("disabled").attr("onclick", null);
187
+ });
188
+
189
+ const sidebar = document.getElementById("sidebar");
190
+ const cmdShowPanes = document.getElementById("cmdShowPanes");
191
+ const gamePanes = document.getElementById("gamePanes");
192
+ const gameContent = document.getElementById("gameContent");
193
+ const gamePanel = document.getElementById("gamePanel");
194
+ const gridPanel = document.getElementById("gridPanel");
195
+
196
+ cmdShowPanes.addEventListener("click", function () {
197
+ sidebar.style.display = (sidebar.style.display === "block") ? "none" : "block";
198
+ });
199
+
200
+ let gameWidth = 950;
201
+ let arePanesVisible = true;
202
+
203
+ const isWindowWide = () => window.innerWidth > gameWidth;
204
+ let wasWide = isWindowWide();
205
+
206
+ const doLayout = () => {
207
+ let isWide = isWindowWide();
208
+
209
+ if (isWide && arePanesVisible) {
210
+ sidebar.style.display = "block";
211
+ sidebar.style.background = "initial";
212
+ sidebar.style.boxShadow = "initial";
213
+ cmdShowPanes.style.display = "none";
214
+ gamePanes.style.left = "50%";
215
+ gamePanes.style.marginLeft = (gameWidth / 2 - 220) + "px";
216
+ gameContent.style.width = (gameWidth - 250) + "px";
217
+ gamePanel.style.width = (gameWidth - 220) + "px";
218
+ gridPanel.style.width = (gameWidth - 220) + "px";
219
+ if (window.paper && paper.view) paper.view.viewSize.width = gameWidth - 220;
220
+ } else {
221
+ if (wasWide) {
222
+ sidebar.style.display = "none";
223
+ }
224
+ sidebar.style.background = "#fff";
225
+ sidebar.style.boxShadow = "-2px 0 5px rgba(0,0,0,0.5)";
226
+ cmdShowPanes.style.display = arePanesVisible ? "inline" : "none";
227
+ gamePanes.style.left = "initial";
228
+ gamePanes.style.marginLeft = "0";
229
+ gameContent.style.width = "initial";
230
+ gamePanel.style.width = "100%";
231
+ gridPanel.style.width = "100%";
232
+ // "100%" here resolves to whichever is smaller: the actual window
233
+ // (narrow/mobile) or #gameBorder's max-width cap (a wide window with
234
+ // panes hidden, e.g. no places/inventory to show) — window.innerWidth
235
+ // alone ignored that cap and stretched the paper.js view past the
236
+ // visible (overflow: hidden) panel, throwing off its centering.
237
+ if (window.paper && paper.view) paper.view.viewSize.width = Math.min(window.innerWidth, gameWidth);
238
+ }
239
+
240
+ const newPanelImageMaxHeight = `${(window.innerHeight - 30) * 0.5}px`;
241
+ updatePanelImageMaxHeight(newPanelImageMaxHeight);
242
+
243
+ wasWide = isWide;
244
+ }
245
+
246
+ window.addEventListener("resize", doLayout);
247
+
248
+ window.setGameWidth = function (width) {
249
+ const gameBorder = document.getElementById("gameBorder");
250
+ gameBorder.style.maxWidth = width + "px";
251
+
252
+ const status = document.getElementById("qv-status");
253
+ status.style.maxWidth = (width - 2) + "px";
254
+
255
+ gameWidth = width;
256
+ doLayout();
257
+ };
258
+
259
+ window.panesVisible = function (visible) {
260
+ arePanesVisible = visible;
261
+ var screenWidth = $("#gameBorder").width();
262
+
263
+ if (visible) {
264
+ $("#gamePanes").show();
265
+ } else {
266
+ $("#gamePanes").hide();
267
+ }
268
+ doLayout();
269
+ };
270
+
271
+ const updatePanelImageMaxHeight = (newMaxHeight) => {
272
+ for (const sheet of document.styleSheets) {
273
+ try {
274
+ for (const rule of sheet.cssRules) {
275
+ if (rule.selectorText === 'div#gamePanel img') {
276
+ rule.style.maxHeight = newMaxHeight;
277
+ return;
278
+ }
279
+ }
280
+ } catch (e) {
281
+
282
+ }
283
+ }
284
+ };
285
+
286
+ // Fires from the picture frame's <img onload> (SetFramePicture/
287
+ // JS.setPanelContents) once the image has actually finished loading and
288
+ // #gamePanel has its real, final height — before that, stickyOverlayHeight()
289
+ // only sees whatever height an unloaded <img> renders at (effectively 0),
290
+ // so the turn's own scrollToEnd() call (fired the moment its text and the
291
+ // <img> tag are added, well before the image itself has loaded) can
292
+ // under-count the frame and land the turn's opening line where the
293
+ // picture is about to appear. Re-targets scrollToTurnStart() at
294
+ // lastScrollTurnStart — a snapshot of whichever turn start that original
295
+ // call used — rather than re-reading beginningOfCurrentTurnScrollPosition,
296
+ // which markScrollPosition() has typically already advanced to the next
297
+ // turn's start by the time a real image finishes loading.
298
+ window.setPanelHeight = function () {
299
+ if (_showGrid) return;
300
+ setTimeout(function () {
301
+ scrollToTurnStart(lastScrollTurnStart);
302
+ }, 100);
303
+ };
304
+
305
+ doLayout();
306
+ ui_init();
307
+ updateStatusVisibility();
308
+
309
+ if (document.layers) document.captureEvents(Event.MOUSEDOWN);
310
+
311
+ $("#txtCommand").focus();
312
+ }
313
+
314
+ function loadHtml(html) {
315
+ $("#divOutput").html(html);
316
+ // The injected HTML carries its own divOutputAlign<N> ids from whenever the
317
+ // game was saved, but _currentDiv/_divCount (used by addText/createNewDiv)
318
+ // are untouched by the line above. If a div was already created before this
319
+ // ran (e.g. WasmPlayer's in-session restore resets output and creates div 1
320
+ // before loadHtml overwrites #divOutput with the restored transcript),
321
+ // _currentDiv keeps pointing at that now-detached node — every future
322
+ // addText() call then silently appends to an invisible div instead of the
323
+ // page, even though the command that produced it succeeded. Resetting here
324
+ // makes the next addText() start a fresh div (via its getCurrentDiv()==null
325
+ // check), numbered past whatever the restored transcript already used.
326
+ _currentDiv = null;
327
+ var maxDivId = 0;
328
+ $("#divOutput [id^='divOutputAlign']").each(function () {
329
+ var n = parseInt(this.id.slice("divOutputAlign".length), 10);
330
+ if (n > maxDivId) maxDivId = n;
331
+ });
332
+ setDivCount(maxDivId);
333
+ }
334
+
335
+ function showStatusVisible(visible) {
336
+ if (visible) {
337
+ $("#statusVars").show();
338
+ $("#statusVarsAccordion").show();
339
+ $("#statusVarsLabel").show();
340
+ } else {
341
+ $("#statusVars").hide();
342
+ $("#statusVarsAccordion").hide();
343
+ $("#statusVarsLabel").hide();
344
+ }
345
+ }
346
+
347
+ function markScrollPosition() {
348
+ beginningOfCurrentTurnScrollPosition = $("#gameContent").height();
349
+ }
350
+
351
+ // Variable added by KV
352
+ var gameName = document.title;
353
+
354
+ function setGameName(text) {
355
+ $("#gameTitle").remove();
356
+ document.title = text;
357
+ // Added by KV
358
+ gameName = text;
359
+ }
360
+
361
+ var _waitMode = false;
362
+ var _pauseMode = false;
363
+
364
+ // Mirrors the engine's WorldModel._pendingCallbackCount > 0: true whenever
365
+ // anything is suspended inside a TaskCompletionSource continuation (wait(),
366
+ // get input(), ask, show menu, pause) that a save/reload can't reconstruct -
367
+ // only world-model data is serialized, not "what the interpreter was doing".
368
+ // Starts true (Save disabled) until the engine's first setTurnPending(false)
369
+ // confirms a turn has genuinely finished with nothing outstanding, including
370
+ // chained/nested wait()s at game start - previously Save flickered briefly
371
+ // enabled between each one, since it was only gated on the narrower _waitMode.
372
+ var _turnPending = true;
373
+ var _gameFinished = false;
374
+
375
+ function updateSaveButtonEnabled() {
376
+ $("#cmdSave").button((_turnPending || _gameFinished) ? "disable" : "enable");
377
+ }
378
+
379
+ function setTurnPending(pending) {
380
+ _turnPending = pending;
381
+ updateSaveButtonEnabled();
382
+ }
383
+
384
+ function beginPause(ms) {
385
+ _pauseMode = true;
386
+ $("#txtCommandDiv").hide();
387
+ window.setTimeout(function () {
388
+ endPause()
389
+ }, ms);
390
+ }
391
+
392
+ function endPause() {
393
+ _pauseMode = false;
394
+ $("#txtCommandDiv").show();
395
+
396
+ // TODO: This is WebPlayer-specific, so shouldn't be in this shared file
397
+ window.setTimeout(async function () {
398
+ await WebPlayer.uiEndPause();
399
+ }, 100);
400
+ }
401
+
402
+ function commandKey(e) {
403
+ if (_waitMode) return false;
404
+ switch (keyPressCode(e)) {
405
+ case 13:
406
+ runCommand();
407
+ return false;
408
+ case 38:
409
+ thisCommand--;
410
+ if (thisCommand == 0) thisCommand = numCommands;
411
+ $("#txtCommand").val(commandsList[thisCommand]);
412
+ e.preventDefault();
413
+ break;
414
+ case 40:
415
+ thisCommand++;
416
+ if (thisCommand > numCommands) thisCommand = 1;
417
+ $("#txtCommand").val(commandsList[thisCommand]);
418
+ e.preventDefault();
419
+ break;
420
+ case 27:
421
+ thisCommand = numCommands + 1;
422
+ $("#txtCommand").val("");
423
+ e.preventDefault();
424
+ break;
425
+ }
426
+ }
427
+
428
+ function runCommand() {
429
+ var command = $("#txtCommand").val();
430
+ if (command.length > 0 && canSendCommand) {
431
+ numCommands++;
432
+ commandsList[numCommands] = command;
433
+ thisCommand = numCommands + 1;
434
+ sendCommand(command);
435
+ $("#txtCommand").val("");
436
+ }
437
+ }
438
+
439
+ function showQuestion(title) {
440
+ $("#msgboxCaption").html(title);
441
+
442
+ var msgboxOptions = {
443
+ modal: true,
444
+ autoOpen: false,
445
+ buttons: [
446
+ {
447
+ text: "Yes",
448
+ click: function () {
449
+ msgboxSubmit(true);
450
+ }
451
+ },
452
+ {
453
+ text: "No",
454
+ click: function () {
455
+ msgboxSubmit(false);
456
+ }
457
+ }
458
+ ],
459
+ closeOnEscape: false,
460
+ open: function (event, ui) {
461
+ $(".ui-dialog-titlebar-close").hide();
462
+ } // suppresses "close" button
463
+ };
464
+
465
+ $("#msgbox").dialog(msgboxOptions);
466
+ $("#msgbox").dialog("open");
467
+ }
468
+
469
+ function uiShow(element) {
470
+ if (element == "#gamePanes") {
471
+ panesVisible(true);
472
+ } else {
473
+ $(element).show();
474
+ updateStatusVisibility();
475
+ }
476
+ }
477
+
478
+ function uiHide(element) {
479
+ if (element == "#gamePanes") {
480
+ panesVisible(false);
481
+ } else {
482
+ $(element).hide();
483
+ updateStatusVisibility();
484
+ }
485
+ }
486
+
487
+ function updateStatusVisibility() {
488
+ var anyVisible = isElementVisible("#location") || isElementVisible("#cmdSave");
489
+ if (anyVisible) {
490
+ $("#qv-status").show();
491
+ $("#divOutput").css("margin-top", "20px");
492
+ $("#gamePanes").css("top", "24px");
493
+ $("#gridPanel").css("top", "32px");
494
+ $("#gamePanel").css("top", "32px");
495
+ } else {
496
+ $("#qv-status").hide();
497
+ $("#divOutput").css("margin-top", "0px");
498
+ $("#gamePanes").css("top", "0px");
499
+ $("#gridPanel").css("top", "0px");
500
+ $("#gamePanel").css("top", "0px");
501
+ }
502
+ }
503
+
504
+ function isElementVisible(element) {
505
+ return $(element).css("display") != "none";
506
+ }
507
+
508
+ var _animateScroll = true;
509
+
510
+ // The page's own scrollable content sits behind #qv-status (fixed) and
511
+ // whichever of #gamePanel/#gridPanel (sticky — the static picture frame
512
+ // feature, e.g. "The Shack") is showing a picture. Once scrolled past their
513
+ // natural flow position they float on top of whatever's beneath them, so a
514
+ // scroll target that ignores them can land content behind the frame instead
515
+ // of below it. #gamePanel/#gridPanel's own "top" CSS already accounts for
516
+ // #qv-status's height (see updateStatusVisibility()), so taking the deepest
517
+ // bottom edge of the three — rather than summing them — avoids double
518
+ // counting #qv-status when a picture is also showing.
519
+ function stickyOverlayHeight() {
520
+ var bottom = 0;
521
+ ["#qv-status", "#gamePanel", "#gridPanel"].forEach(function (selector) {
522
+ var $el = $(selector);
523
+ if ($el.length && isElementVisible($el)) {
524
+ bottom = Math.max(bottom, (parseFloat($el.css("top")) || 0) + $el.outerHeight());
525
+ }
526
+ });
527
+ return bottom;
528
+ }
529
+
530
+ // Snapshot of whichever turn-start position the most recent scrollToEnd()
531
+ // call actually used, kept separately from beginningOfCurrentTurnScrollPosition
532
+ // — see setPanelHeight()'s doc comment (above, in initPlayerUI()) for why.
533
+ var lastScrollTurnStart = 0;
534
+
535
+ // Scrolls just far enough that turnStart (the top of some turn's output)
536
+ // lands below the fixed/sticky chrome at the top of the viewport, rather than
537
+ // jumping straight to the bottom of the document — otherwise a long turn's
538
+ // opening lines scroll off the top (or behind the status bar/picture frame)
539
+ // before the player can read them. Never scrolls backward past wherever the
540
+ // player currently is (e.g. if they've scrolled up to reread), and never
541
+ // past the true bottom of the document.
542
+ //
543
+ // A turn can emit several OutputText calls, each triggering scrollToEnd(),
544
+ // and — for a walkthrough or any other rapid burst of turns — the next one
545
+ // can easily land while the previous call's animation is still running.
546
+ // easeInOutCubic decelerates to a near-stop at the end of every animation;
547
+ // restarting that curve from scratch on each interruption made the scroll
548
+ // visibly stutter (slow down, barely move, speed up, slow down again) rather
549
+ // than glide, with the final leg then covering whatever distance was left in
550
+ // one comparatively large jump once nothing interrupted it further. Only the
551
+ // very first call in a burst (starting from a stationary page) gets the
552
+ // eased curve; anything that interrupts an already-running scroll continues
553
+ // at the same steady rate instead of re-decelerating and re-accelerating.
554
+ //
555
+ // allowBackward (default false) lets the target move the scroll position
556
+ // *up*, not just down — normally refused so that a manual scroll-up to
557
+ // reread history doesn't get yanked back down by an unrelated later turn.
558
+ // clearScreen() passes true: a turn that clears the screen can still hit an
559
+ // ordinary turn-boundary scrollToEnd() call using the *pre-clear* turn start
560
+ // (SignalTurnSuspended's own call, queued before the script that called
561
+ // ClearScreen has necessarily finished, can still be based on wherever the
562
+ // old, now-discarded page happened to end) — clamped against the old,
563
+ // now-irrelevant document height, that can scroll to a wrong, much-too-far
564
+ // position before clearScreen's own correction below runs. Since the entire
565
+ // point of a clear is "nothing before this matters any more", its own
566
+ // correction must be allowed to override that, forward or backward.
567
+ function scrollToTurnStart(turnStart, allowBackward) {
568
+ lastScrollTurnStart = turnStart;
569
+
570
+ // A picture frame image that hasn't finished loading yet (successfully
571
+ // or not) doesn't have its real size yet — #gamePanel/#gridPanel's
572
+ // height right now is whatever an unloaded <img> renders at
573
+ // (effectively 0), so any target computed against it would undercount
574
+ // the frame and visibly place content where the picture is about to
575
+ // appear, needing a jump to fix once it loads. Skip for now instead:
576
+ // setPanelContents() wires up a load/error listener on every panel
577
+ // image (on top of SetFramePicture's own <img onload>) that calls back
578
+ // into here once the frame's real height is known, so this is never
579
+ // left stuck — just deferred until the answer is actually right.
580
+ var pendingImg = $("#gamePanel:visible img, #gridPanel:visible img").filter(function () {
581
+ return !this.complete;
582
+ })[0];
583
+ if (pendingImg) {
584
+ return;
585
+ }
586
+
587
+ if (!_animateScroll) {
588
+ // Used while fast-forwarding a walkthrough — always jump straight to
589
+ // the true end rather than following the turn-by-turn target below.
590
+ $('html,body').stop(true, false).scrollTop(document.body.scrollHeight);
591
+ focusCommandInput();
592
+ return;
593
+ }
594
+
595
+ var headerHeight = stickyOverlayHeight();
596
+ // turnStart is measured relative to #gameContent's own top (its height()
597
+ // when markScrollPosition() ran), not the page's — #gameContent isn't
598
+ // necessarily at page-top itself, since #gamePanel/#gridPanel (sticky,
599
+ // but still flow-participating) reserve real layout space above it
600
+ // whenever a picture is showing. Skipping this offset used to cancel out
601
+ // by accident whenever the frame was already showing before the turn
602
+ // started (its contribution to both this offset and headerHeight above
603
+ // were equal), which is why it went unnoticed until the frame's size
604
+ // changed *after* the turn had already been positioned.
605
+ var pageTurnStart = $("#gameContent").offset().top + turnStart;
606
+ var maxScrollTop = Math.max($(document).height() - $(window).height(), 0);
607
+ var target = Math.min(Math.max(pageTurnStart - headerHeight - 20, 0), maxScrollTop);
608
+ var currentScrollTop = Math.max($("body").scrollTop(), $("html").scrollTop());
609
+
610
+ if (target !== currentScrollTop && (allowBackward || target > currentScrollTop)) {
611
+ var wasAlreadyScrolling = $('html,body').is(":animated");
612
+ var distance = Math.abs(target - currentScrollTop);
613
+ var duration = Math.min(distance / 0.4, 2000);
614
+ var easing = wasAlreadyScrolling ? "linear" : "easeInOutCubic";
615
+ $('html,body').stop(true, false).animate({scrollTop: target}, duration, easing);
616
+ }
617
+ focusCommandInput();
618
+ }
619
+
620
+ // Plain jQuery .focus() calls the native HTMLElement.focus(), which — for an
621
+ // element not already focused — asks the browser to scroll it into view.
622
+ // #txtCommand sits right after all of #divOutput, so whenever it isn't
623
+ // already focused (page just loaded, on mobile before the on-screen keyboard
624
+ // has been tapped, focus lost to a click/selection elsewhere) that silently
625
+ // jumped straight to the document's bottom, undoing every calculation above.
626
+ // {preventScroll: true} keeps the input usable (typing still works
627
+ // immediately) without fighting the scroll position we just computed.
628
+ function focusCommandInput() {
629
+ document.getElementById("txtCommand")?.focus({preventScroll: true});
630
+ }
631
+
632
+ // beginningOfCurrentTurnScrollPosition is set by markScrollPosition() before
633
+ // the turn began (see its own doc comment).
634
+ function scrollToEnd() {
635
+ scrollToTurnStart(beginningOfCurrentTurnScrollPosition);
636
+ }
637
+
638
+ function SetAnimateScroll(value) {
639
+ _animateScroll = value;
640
+ }
641
+
642
+ var _backgroundOpacity = 1;
643
+
644
+ function SetBackgroundOpacity(opacity) {
645
+ _backgroundOpacity = opacity;
646
+ }
647
+
648
+ function setBackground(col) {
649
+ /* If '#rgb', convert to '#rrggbb'*/
650
+ /* https://github.com/textadventures/quest/issues/1052 */
651
+ if (col.charAt(0) === "#" && col.length == 4) {
652
+ var colBak = "" + col + "";
653
+ newCol = col.replace(/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/, '#$1$1$2$2$3$3');
654
+ col = newCol || col;
655
+ }
656
+ colNameToHex = colourNameToHex(col);
657
+ if (colNameToHex) col = colNameToHex;
658
+ rgbCol = hexToRgb(col);
659
+ var cssBackground = "rgba(" + rgbCol.r + "," + rgbCol.g + "," + rgbCol.b + "," + _backgroundOpacity + ")";
660
+ $("#gameBorder").css("background-color", cssBackground);
661
+ $("#gamePanel").css("background-color", col);
662
+ $("#gridPanel").css("background-color", col);
663
+ }
664
+
665
+ function setPanelContents(html) {
666
+ if (html.length > 0) {
667
+ $("#gamePanel").show()
668
+ } else {
669
+ $("#gamePanel").hide()
670
+ }
671
+ $("#gamePanel").html(html);
672
+ // Belt-and-braces alongside SetFramePicture's own <img onload="setPanelHeight()">
673
+ // markup: guarantees a retry once any image here finishes loading (success
674
+ // or failure) even for panel HTML set directly via JS.setPanelContents that
675
+ // doesn't happen to include that onload itself — scrollToTurnStart() below
676
+ // relies on one of these eventually firing to know it's safe to scroll.
677
+ $("#gamePanel img").one("load error", setPanelHeight);
678
+ setPanelHeight();
679
+ }
680
+
681
+ function setGamePadding(top, bottom, left, right) {
682
+ $("#gameContent").css("padding-top", top);
683
+ $("#gameContent").css("padding-bottom", bottom);
684
+ $("#gameContent").css("padding-left", left);
685
+ $("#gameContent").css("padding-right", right);
686
+ }
687
+
688
+ function hideBorder() {
689
+ $("#gameBorder").css("border", "none");
690
+ }
691
+
692
+ var _compassDirs = ["northwest", "north", "northeast", "west", "east", "southwest", "south", "southeast", "up", "down", "in", "out"];
693
+
694
+ function updateCompass(listData) {
695
+ var directions = listData.split("/");
696
+ updateDir(directions, "NW", _compassDirs[0]);
697
+ updateDir(directions, "N", _compassDirs[1]);
698
+ updateDir(directions, "NE", _compassDirs[2]);
699
+ updateDir(directions, "W", _compassDirs[3]);
700
+ updateDir(directions, "E", _compassDirs[4]);
701
+ updateDir(directions, "SW", _compassDirs[5]);
702
+ updateDir(directions, "S", _compassDirs[6]);
703
+ updateDir(directions, "SE", _compassDirs[7]);
704
+ updateDir(directions, "U", _compassDirs[8]);
705
+ updateDir(directions, "D", _compassDirs[9]);
706
+ updateDir(directions, "In", _compassDirs[10]);
707
+ updateDir(directions, "Out", _compassDirs[11]);
708
+ }
709
+
710
+ function updateDir(directions, label, dir) {
711
+ if ($.inArray(dir, directions) == -1) {
712
+ $("#cmdCompass" + label).button("disable");
713
+ } else {
714
+ $("#cmdCompass" + label).button("enable");
715
+ }
716
+ }
717
+
718
+ function paneButtonClick(target, button) {
719
+ var selectedListItem = $(target + " .ui-selected");
720
+ var selectedObject = selectedListItem.text();
721
+ var selectedElementId = selectedListItem.data("elementid");
722
+ var selectedElementName = selectedListItem.data("elementname");
723
+ var verb = button.data("verb");
724
+ var metadata = {};
725
+ metadata[selectedElementName] = selectedElementId;
726
+
727
+ if (selectedObject.length > 0) {
728
+ var cmd = verb.toLowerCase() + " " + selectedElementName;
729
+ sendCommand(cmd, metadata);
730
+ }
731
+ }
732
+
733
+ function compassClick(direction) {
734
+ sendCommand(direction);
735
+ }
736
+
737
+ function updateStatus(text) {
738
+ if (text.length > 0) {
739
+ showStatusVisible(true);
740
+ $("#statusVars").html(text.replace(/\n/g, "<br/>"));
741
+ } else {
742
+ showStatusVisible(false);
743
+ }
744
+ }
745
+
746
+ function setForeground(col) {
747
+ }
748
+
749
+ function setCompassDirections(directions) {
750
+ if (typeof directions === "string") {
751
+ _compassDirs = directions.split(";")
752
+ } else {
753
+ _compassDirs = directions;
754
+ }
755
+ $("#cmdCompassNW").attr("title", _compassDirs[0]);
756
+ $("#cmdCompassN").attr("title", _compassDirs[1]);
757
+ $("#cmdCompassNE").attr("title", _compassDirs[2]);
758
+ $("#cmdCompassW").attr("title", _compassDirs[3]);
759
+ $("#cmdCompassE").attr("title", _compassDirs[4]);
760
+ $("#cmdCompassSW").attr("title", _compassDirs[5]);
761
+ $("#cmdCompassS").attr("title", _compassDirs[6]);
762
+ $("#cmdCompassSE").attr("title", _compassDirs[7]);
763
+ $("#cmdCompassU").attr("title", _compassDirs[8]);
764
+ $("#cmdCompassD").attr("title", _compassDirs[9]);
765
+ $("#cmdCompassIn").attr("title", _compassDirs[10]);
766
+ $("#cmdCompassOut").attr("title", _compassDirs[11]);
767
+ }
768
+
769
+ function updateLocation(text) {
770
+ $("#location").html(text);
771
+ }
772
+
773
+
774
+ // Used in grid.js, but defined here so it can be set during startup
775
+ _respondToGridClicks = false;
776
+
777
+ function respondToGridClicks(flag) {
778
+ _respondToGridClicks = flag;
779
+ }
780
+
781
+ function updateList(listName, listData) {
782
+ var listElement = "";
783
+ var buttonPrefix = "";
784
+
785
+ if (listName == "inventory") {
786
+ listElement = "#lstInventory";
787
+ inventoryVerbs = new Array();
788
+ buttonPrefix = "cmdInventory";
789
+ }
790
+
791
+ if (listName == "placesobjects") {
792
+ listElement = "#lstPlacesObjects";
793
+ placesObjectsVerbs = new Array();
794
+ buttonPrefix = "cmdPlacesObjects";
795
+ }
796
+
797
+ var previousSelectionText = "";
798
+ var previousSelectionKey = "";
799
+ var foundPreviousSelection = false;
800
+
801
+ var $selected = $(listElement + " .ui-selected");
802
+ if ($selected.length > 0) {
803
+ previousSelectionText = $selected.first().text();
804
+ previousSelectionKey = $selected.first().data("key");
805
+ }
806
+
807
+ $(listElement).empty();
808
+ var count = 0;
809
+ $.each(listData, function (key, value) {
810
+ var data = JSON.parse(value);
811
+ var objectDisplayName = data["Text"];
812
+ var verbsArray, idPrefix;
813
+
814
+ if (listName == "inventory") {
815
+ verbsArray = inventoryVerbs;
816
+ idPrefix = "cmdInventory";
817
+ } else {
818
+ verbsArray = placesObjectsVerbs;
819
+ idPrefix = "cmdPlacesObjects";
820
+ }
821
+
822
+ verbsArray.push(data);
823
+
824
+ if (listName == "inventory" || $.inArray(objectDisplayName, _compassDirs) == -1) {
825
+ var $newItem = $("<li/>").data("key", key).data("elementid", data["ElementId"]).data("elementname", data["ElementName"]).data("index", count).html(objectDisplayName);
826
+ if (objectDisplayName == previousSelectionText && key == previousSelectionKey) {
827
+ $newItem.addClass("ui-selected");
828
+ foundPreviousSelection = true;
829
+ updateVerbButtons($newItem, verbsArray, idPrefix);
830
+ }
831
+ $(listElement).append($newItem);
832
+ count++;
833
+ }
834
+ });
835
+
836
+ var selectSize = count;
837
+ if (selectSize < 3) selectSize = 3;
838
+ if (selectSize > 12) selectSize = 12;
839
+ $(listElement).attr("size", selectSize);
840
+
841
+ if (!foundPreviousSelection) {
842
+ for (var i = 1; i <= verbButtonCount; i++) {
843
+ var target = $("#" + buttonPrefix + i);
844
+ target.hide();
845
+ }
846
+ }
847
+ }
848
+
849
+ function updateVerbButtons(selectedItem, verbsArray, idprefix) {
850
+ var selectedIndex = selectedItem.data("index");
851
+ var verbs = verbsArray[selectedIndex]["Verbs"];
852
+ var count = 1;
853
+ $.each(verbs, function (index, value) {
854
+ $("#" + idprefix + count + " span").html(value);
855
+ var target = $("#" + idprefix + count);
856
+ target.data("verb", value);
857
+ target.show();
858
+ count++;
859
+ });
860
+ for (var i = count; i <= verbButtonCount; i++) {
861
+ var target = $("#" + idprefix + i);
862
+ target.hide();
863
+ }
864
+ }
865
+
866
+ function beginWait() {
867
+ _waitMode = true;
868
+ $("#txtCommand").hide();
869
+ $("#txtCommandPrompt").hide();
870
+ $("#endWaitLink").show();
871
+ markScrollPosition();
872
+ }
873
+
874
+ function endWait() {
875
+ if (!_waitMode) return;
876
+ sendEndWait();
877
+ }
878
+
879
+ function waitEnded() {
880
+ _waitMode = false;
881
+ $("#endWaitLink").hide();
882
+ $("#txtCommand").show();
883
+ $("#txtCommandPrompt").show();
884
+ }
885
+
886
+ function gameFinished() {
887
+ _gameFinished = true;
888
+ updateSaveButtonEnabled();
889
+ disableInterface();
890
+ }
891
+
892
+ function disableInterface() {
893
+ $("#txtCommandDiv").hide();
894
+ $("#gamePanesRunning").hide();
895
+ $("#gamePanesFinished").show();
896
+ }
897
+
898
+ function setCommandBarStyle(style) {
899
+ var hidden = $("#txtCommand").is(":hidden") && $("#txtCommand").parent().is(":visible");
900
+ $("#txtCommand").attr("style", style);
901
+ if (hidden) {
902
+ $("#txtCommand").hide();
903
+ } else {
904
+ $("#txtCommand").show();
905
+ }
906
+ }
907
+
908
+ function addTextAndScroll(text) {
909
+ addText(text);
910
+ scrollToEnd();
911
+ }
912
+
913
+ // Added by KV for the transcript
914
+ var savingTranscript = false;
915
+ var noTranscript = false;
916
+ var transcriptString = ""; /* Added in Quest 5.8, but never worked properly */
917
+
918
+
919
+ // This function altered for the transcript
920
+ function addText(text) {
921
+ if (getCurrentDiv() == null) {
922
+ createNewDiv("left");
923
+ }
924
+ if (savingTranscript && !noTranscript) {
925
+ writeToTranscript(text);
926
+ }
927
+ getCurrentDiv().append(text);
928
+ $("#divOutput").css("min-height", $("#divOutput").height());
929
+ }
930
+
931
+ function createNewDiv(alignment) {
932
+ var classes = _outputSections.join(" ");
933
+ setDivCount(getDivCount() + 1);
934
+ $("<div/>", {
935
+ id: "divOutputAlign" + getDivCount(),
936
+ style: "text-align: " + alignment,
937
+ "class": classes
938
+ }).appendTo("#divOutput");
939
+ setCurrentDiv("#divOutputAlign" + getDivCount());
940
+ }
941
+
942
+ var _currentDiv = null;
943
+
944
+ function getCurrentDiv() {
945
+ if (_currentDiv) return _currentDiv;
946
+
947
+ var divId = $("#outputData").attr("data-currentdiv");
948
+ if (divId) {
949
+ _currentDiv = $(divId);
950
+ return _currentDiv;
951
+ }
952
+
953
+ return null;
954
+ }
955
+
956
+ function setCurrentDiv(div) {
957
+ _currentDiv = $(div);
958
+ $("#outputData").attr("data-currentdiv", div);
959
+ }
960
+
961
+ var _divCount = -1;
962
+
963
+ function getDivCount() {
964
+ if (_divCount < 1) {
965
+ _divCount = parseInt($("#outputData").attr("data-divcount")) || 0;
966
+ }
967
+ return _divCount;
968
+ }
969
+
970
+ function setDivCount(count) {
971
+ _divCount = count;
972
+ $("#outputData").attr("data-divcount", _divCount);
973
+ }
974
+
975
+ function bindMenu(linkid, verbs, text, elementId) {
976
+ var options = buildMenuOptions(verbs, text, elementId);
977
+ $("#" + linkid).jjmenu(options);
978
+ }
979
+
980
+ function buildMenuOptions(verbs, text, elementId) {
981
+ var verbsList = verbs ? verbs.split("/") : [];
982
+ var options = [];
983
+ var metadata = {};
984
+ metadata[text] = elementId;
985
+
986
+ $.each(verbsList, function (key, value) {
987
+ options = options.concat({
988
+ title: value,
989
+ action: {
990
+ callback: function (selectedValue) {
991
+ sendCommand(selectedValue.toLowerCase() + " " + text, metadata);
992
+ }
993
+ }
994
+ });
995
+ });
996
+
997
+ return options;
998
+ }
999
+
1000
+ function updateObjectLinks(data) {
1001
+ $(".elementmenu").each(function (index, e) {
1002
+ var $e = $(e);
1003
+ var verbs = data[$e.data("elementid")];
1004
+ if (verbs) {
1005
+ $e.removeClass("disabled");
1006
+ $e.data("verbs", verbs);
1007
+ // also set attribute so verbs are persisted to savegame
1008
+ $e.attr("data-verbs", verbs);
1009
+ } else {
1010
+ $e.addClass("disabled");
1011
+ }
1012
+ });
1013
+ }
1014
+
1015
+ function updateExitLinks(data) {
1016
+ $(".exitlink").each(function (index, e) {
1017
+ var $e = $(e);
1018
+ var exitid = $e.data("elementid");
1019
+ var available = $.inArray(exitid, data) > -1;
1020
+ if (available) {
1021
+ $e.removeClass("disabled");
1022
+ } else {
1023
+ $e.addClass("disabled");
1024
+ }
1025
+ });
1026
+ }
1027
+
1028
+ function updateCommandLinks(data) {
1029
+ $(".commandlink").each(function (index, e) {
1030
+ var $e = $(e);
1031
+ if (!$(e).data("deactivated")) {
1032
+ var elementid = $e.data("elementid");
1033
+ var available = $.inArray(elementid, data) > -1 || elementid.length == 0;
1034
+ if (available) {
1035
+ $e.removeClass("disabled");
1036
+ } else {
1037
+ $e.addClass("disabled");
1038
+ }
1039
+ }
1040
+ });
1041
+ }
1042
+
1043
+ function disableAllCommandLinks() {
1044
+ $(".commandlink").each(function (index, e) {
1045
+ $(e).addClass("disabled");
1046
+ $(e).data("deactivated", true);
1047
+ });
1048
+ }
1049
+
1050
+ var saveClearedText = false;
1051
+ var clearedOnce = false;
1052
+
1053
+ function clearScreen() {
1054
+ $("#outputData").appendTo($("body"));
1055
+ if (!saveClearedText) {
1056
+ $("#divOutput").css("min-height", 0);
1057
+ $("#divOutput").html("");
1058
+ createNewDiv("left");
1059
+ beginningOfCurrentTurnScrollPosition = 0;
1060
+ // scrollToTurnStart(0), not a bare scrollTop(0) — the new page's
1061
+ // content starts at #gameContent height 0, but #gameContent itself
1062
+ // isn't necessarily at the very top of the *page*: a static picture
1063
+ // frame (#gamePanel/#gridPanel, e.g. "The Shack") reserves real flow
1064
+ // space above it, and jumping to page-scrollTop 0 only clears that
1065
+ // frame if the frame is shorter than the viewport — on a small/mobile
1066
+ // screen it very often isn't, leaving the new page's opening line
1067
+ // rendered behind the frame. This fires on every gamebook page
1068
+ // transition (DoPage → ClearScreen when game.clearlastpage), which
1069
+ // includes game start (the player's first changedparent).
1070
+ setTimeout(function () {
1071
+ scrollToTurnStart(0, true);
1072
+ }, 100);
1073
+ } else {
1074
+ $("#divOutput").append("<hr class='clearedAbove' />");
1075
+ if (!clearedOnce) {
1076
+ addText('<style>#divOutput > .clearedScreen { display: none; }</style>');
1077
+ }
1078
+ clearedOnce = true;
1079
+ $('#divOutput').children().addClass('clearedScreen');
1080
+ $('.clearedScreen').attr('id', null);
1081
+ $('#divOutput').css('min-height', 0);
1082
+ createNewDiv('left');
1083
+ beginningOfCurrentTurnScrollPosition = 0;
1084
+ setTimeout(function () {
1085
+ scrollToTurnStart(0, true);
1086
+ }, 100);
1087
+ }
1088
+ $("#outputData").appendTo($("#divOutput"));
1089
+ }
1090
+
1091
+ // Hard-resets output/transcript state so a different game/save can start
1092
+ // clean without a full page reload (used by WasmPlayer's in-game Load,
1093
+ // where _currentDiv/_divCount would otherwise still point at divs from the
1094
+ // game that just got torn down).
1095
+ function resetGameOutput() {
1096
+ _outputSections = [];
1097
+ _currentDiv = null;
1098
+ _divCount = -1;
1099
+ saveClearedText = false;
1100
+ clearedOnce = false;
1101
+ beginningOfCurrentTurnScrollPosition = 0;
1102
+ $("#divOutput").css("min-height", 0).html("");
1103
+ createNewDiv("left");
1104
+ clearUnsavedProgress();
1105
+ }
1106
+
1107
+ // Scrollback functions added by KV
1108
+
1109
+ function showScrollback() {
1110
+ var scrollbackDivString = '<div id="scrollback-dialog" style="display:none;"><div id="scrollbackdata"></div></div>';
1111
+ addText(scrollbackDivString);
1112
+ var scrollbackDialog = $("#scrollback-dialog").dialog({
1113
+ autoOpen: false,
1114
+ width: (window.innerWidth || document.documentElement.clientWidth ||
1115
+ document.body.clientWidth) - 100,
1116
+ height: (window.innerHeight || document.documentElement.clientHeight ||
1117
+ document.body.clientHeight) - 100,
1118
+ title: "Scrollback",
1119
+ buttons: {
1120
+ Ok: function () {
1121
+ $(this).dialog("close");
1122
+ $(this).remove();
1123
+ $("#scrollback-dialog,#scrollbackdata").remove();
1124
+ },
1125
+ Print: function () {
1126
+ printScrollbackDiv();
1127
+ },
1128
+ },
1129
+ show: {effect: "fadeIn", duration: 500},
1130
+ modal: true,
1131
+ });
1132
+ $('#scrollbackdata').html($('#divOutput').html());
1133
+ $("#scrollbackdata a").addClass("disabled");
1134
+ scrollbackDialog.dialog("open");
1135
+ setTimeout(function () {
1136
+ $("#scrollbackdata a").addClass("disabled");
1137
+ }, 1);
1138
+ }
1139
+
1140
+ function printScrollbackDiv() {
1141
+ var iframe = document.createElement('iframe');
1142
+ document.body.appendChild(iframe);
1143
+ iframe.contentWindow.document.write($("#scrollbackdata").html());
1144
+ iframe.contentWindow.print();
1145
+ document.body.removeChild(iframe);
1146
+ $("#scrollback-dialog").dialog("close");
1147
+ $("#scrollback-dialog").remove();
1148
+ }
1149
+
1150
+ function keyPressCode(e) {
1151
+ var keynum
1152
+ if (window.event) {
1153
+ keynum = e.keyCode
1154
+ } else if (e.which) {
1155
+ keynum = e.which
1156
+ }
1157
+ return keynum;
1158
+ }
1159
+
1160
+ function addExternalStylesheet(source) {
1161
+ var link = $("<link>");
1162
+ link.attr({
1163
+ type: "text/css",
1164
+ rel: "stylesheet",
1165
+ href: source
1166
+ });
1167
+ $("head").append(link);
1168
+ }
1169
+
1170
+ function setInterfaceString(name, text) {
1171
+ switch (name) {
1172
+ case "InventoryLabel":
1173
+ $("#inventoryLabel span.accordion-header-text").html(text);
1174
+ break;
1175
+ case "StatusLabel":
1176
+ $("#statusVarsLabel span.accordion-header-text").html(text);
1177
+ break;
1178
+ case "PlacesObjectsLabel":
1179
+ $("#placesObjectsLabel span.accordion-header-text").html(text);
1180
+ break;
1181
+ case "CompassLabel":
1182
+ $("#compassLabel span.accordion-header-text").html(text);
1183
+ break;
1184
+ case "InButtonLabel":
1185
+ $("#cmdCompassIn span").html(text);
1186
+ break;
1187
+ case "OutButtonLabel":
1188
+ $("#cmdCompassOut span").html(text);
1189
+ break;
1190
+ case "EmptyListLabel":
1191
+ break;
1192
+ case "NothingSelectedLabel":
1193
+ break;
1194
+ case "TypeHereLabel":
1195
+ $("#txtCommand").prop("placeholder", text);
1196
+ break;
1197
+ case "ContinueLabel":
1198
+ $("#endWaitLink").html(text);
1199
+ break;
1200
+ }
1201
+ }
1202
+
1203
+ function AddYouTube(id) {
1204
+ var url = "https://www.youtube.com/embed/" + id + "?autoplay=1&rel=0";
1205
+ var embedHTML = "<iframe width=\"425\" height=\"344\" src=\"" + url + "\" frameborder=\"0\" allowfullscreen></iframe>";
1206
+ addText(embedHTML);
1207
+ }
1208
+
1209
+ function AddVimeo(id) {
1210
+ var url = "https://player.vimeo.com/video/" + id + "?autoplay=1";
1211
+ var embedHTML = "<iframe sandbox=\"allow-same-origin allow-scripts allow-popups\" src=\"" + url + "\" width=\"500\" height=\"281\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
1212
+ addText(embedHTML);
1213
+ }
1214
+
1215
+ function SetMenuBackground(color) {
1216
+ var css = getCSSRule("div.jj_menu_item");
1217
+ css.style.backgroundColor = color;
1218
+ }
1219
+
1220
+ function SetMenuForeground(color) {
1221
+ var css = getCSSRule("div.jj_menu_item");
1222
+ css.style.color = color;
1223
+ }
1224
+
1225
+ function SetMenuHoverBackground(color) {
1226
+ var css = getCSSRule("div.jj_menu_item_hover");
1227
+ css.style.backgroundColor = color;
1228
+ }
1229
+
1230
+ function SetMenuHoverForeground(color) {
1231
+ var css = getCSSRule("div.jj_menu_item_hover");
1232
+ css.style.color = color;
1233
+ }
1234
+
1235
+ function SetMenuFontName(font) {
1236
+ var css = getCSSRule("div.jjmenu");
1237
+ css.style.fontFamily = font;
1238
+ }
1239
+
1240
+ function SetMenuFontSize(size) {
1241
+ if (_allowMenuFontSizeChange) {
1242
+ var css = getCSSRule("div.jjmenu");
1243
+ css.style.fontSize = size;
1244
+ }
1245
+ }
1246
+
1247
+ function TurnOffHyperlinksUnderline() {
1248
+ var css = getCSSRule("a.cmdlink");
1249
+ css.style.textDecoration = "none";
1250
+ }
1251
+
1252
+ function SetBackgroundImage(url) {
1253
+ $("body").css("background-image", "url(" + url + ")");
1254
+ }
1255
+
1256
+ function StartOutputSection(name) {
1257
+ if ($.inArray(name, _outputSections) == -1) {
1258
+ _outputSections.push(name);
1259
+ createNewDiv("left");
1260
+ }
1261
+ }
1262
+
1263
+ function EndOutputSection(name) {
1264
+ var index = $.inArray(name, _outputSections);
1265
+ if (index != -1) {
1266
+ _outputSections.splice(index, 1);
1267
+ createNewDiv("left");
1268
+ }
1269
+ }
1270
+
1271
+ function HideOutputSection(name) {
1272
+ EndOutputSection(name);
1273
+ $("." + name + " a").attr("onclick", "");
1274
+ setTimeout(function () {
1275
+ $("." + name).hide(250, function () {
1276
+ $(this).remove();
1277
+ });
1278
+ // Added by The Pixie, 04/Oct/17
1279
+ // This should close the gap when the menu is hidden
1280
+ $("#divOutput").animate({'min-height': 0}, 250);
1281
+ }, 250);
1282
+ }
1283
+
1284
+ var TextFX = new function () {
1285
+ var fxCount = 0;
1286
+
1287
+ function addFx(text, font, color, size) {
1288
+ fxCount++;
1289
+ var style = "font-family:" + font + ";color:" + color + ";font-size:" + size + "pt";
1290
+ var html = "<span id=\"fx" + fxCount + "\" style=\"" + style + "\">" + text + " </span><br />";
1291
+ addText(html);
1292
+ return $("#fx" + fxCount);
1293
+ }
1294
+
1295
+ this.Typewriter = function (text, speed, font, color, size) {
1296
+ var el = addFx(text, font, color, size);
1297
+ el.typewriter(speed);
1298
+ }
1299
+
1300
+ this.Unscramble = function (text, speed, reveal, font, color, size) {
1301
+ var el = addFx(text, font, color, size);
1302
+ el.unscramble(speed, reveal);
1303
+ }
1304
+ }
1305
+
1306
+ function colourNameToHex(colour) {
1307
+ var colours = {
1308
+ "aliceblue": "#f0f8ff",
1309
+ "antiquewhite": "#faebd7",
1310
+ "aqua": "#00ffff",
1311
+ "aquamarine": "#7fffd4",
1312
+ "azure": "#f0ffff",
1313
+ "beige": "#f5f5dc",
1314
+ "bisque": "#ffe4c4",
1315
+ "black": "#000000",
1316
+ "blanchedalmond": "#ffebcd",
1317
+ "blue": "#0000ff",
1318
+ "blueviolet": "#8a2be2",
1319
+ "brown": "#a52a2a",
1320
+ "burlywood": "#deb887",
1321
+ "cadetblue": "#5f9ea0",
1322
+ "chartreuse": "#7fff00",
1323
+ "chocolate": "#d2691e",
1324
+ "coral": "#ff7f50",
1325
+ "cornflowerblue": "#6495ed",
1326
+ "cornsilk": "#fff8dc",
1327
+ "crimson": "#dc143c",
1328
+ "cyan": "#00ffff",
1329
+ "darkblue": "#00008b",
1330
+ "darkcyan": "#008b8b",
1331
+ "darkgoldenrod": "#b8860b",
1332
+ "darkgray": "#a9a9a9",
1333
+ "darkgreen": "#006400",
1334
+ "darkkhaki": "#bdb76b",
1335
+ "darkmagenta": "#8b008b",
1336
+ "darkolivegreen": "#556b2f",
1337
+ "darkorange": "#ff8c00",
1338
+ "darkorchid": "#9932cc",
1339
+ "darkred": "#8b0000",
1340
+ "darksalmon": "#e9967a",
1341
+ "darkseagreen": "#8fbc8f",
1342
+ "darkslateblue": "#483d8b",
1343
+ "darkslategray": "#2f4f4f",
1344
+ "darkturquoise": "#00ced1",
1345
+ "darkviolet": "#9400d3",
1346
+ "deeppink": "#ff1493",
1347
+ "deepskyblue": "#00bfff",
1348
+ "dimgray": "#696969",
1349
+ "dodgerblue": "#1e90ff",
1350
+ "firebrick": "#b22222",
1351
+ "floralwhite": "#fffaf0",
1352
+ "forestgreen": "#228b22",
1353
+ "fuchsia": "#ff00ff",
1354
+ "gainsboro": "#dcdcdc",
1355
+ "ghostwhite": "#f8f8ff",
1356
+ "gold": "#ffd700",
1357
+ "goldenrod": "#daa520",
1358
+ "gray": "#808080",
1359
+ "green": "#008000",
1360
+ "greenyellow": "#adff2f",
1361
+ "honeydew": "#f0fff0",
1362
+ "hotpink": "#ff69b4",
1363
+ "indianred ": "#cd5c5c",
1364
+ "indigo ": "#4b0082",
1365
+ "ivory": "#fffff0",
1366
+ "khaki": "#f0e68c",
1367
+ "lavender": "#e6e6fa",
1368
+ "lavenderblush": "#fff0f5",
1369
+ "lawngreen": "#7cfc00",
1370
+ "lemonchiffon": "#fffacd",
1371
+ "lightblue": "#add8e6",
1372
+ "lightcoral": "#f08080",
1373
+ "lightcyan": "#e0ffff",
1374
+ "lightgoldenrodyellow": "#fafad2",
1375
+ "lightgrey": "#d3d3d3",
1376
+ "lightgreen": "#90ee90",
1377
+ "lightpink": "#ffb6c1",
1378
+ "lightsalmon": "#ffa07a",
1379
+ "lightseagreen": "#20b2aa",
1380
+ "lightskyblue": "#87cefa",
1381
+ "lightslategray": "#778899",
1382
+ "lightsteelblue": "#b0c4de",
1383
+ "lightyellow": "#ffffe0",
1384
+ "lime": "#00ff00",
1385
+ "limegreen": "#32cd32",
1386
+ "linen": "#faf0e6",
1387
+ "magenta": "#ff00ff",
1388
+ "maroon": "#800000",
1389
+ "mediumaquamarine": "#66cdaa",
1390
+ "mediumblue": "#0000cd",
1391
+ "mediumorchid": "#ba55d3",
1392
+ "mediumpurple": "#9370d8",
1393
+ "mediumseagreen": "#3cb371",
1394
+ "mediumslateblue": "#7b68ee",
1395
+ "mediumspringgreen": "#00fa9a",
1396
+ "mediumturquoise": "#48d1cc",
1397
+ "mediumvioletred": "#c71585",
1398
+ "midnightblue": "#191970",
1399
+ "mintcream": "#f5fffa",
1400
+ "mistyrose": "#ffe4e1",
1401
+ "moccasin": "#ffe4b5",
1402
+ "navajowhite": "#ffdead",
1403
+ "navy": "#000080",
1404
+ "oldlace": "#fdf5e6",
1405
+ "olive": "#808000",
1406
+ "olivedrab": "#6b8e23",
1407
+ "orange": "#ffa500",
1408
+ "orangered": "#ff4500",
1409
+ "orchid": "#da70d6",
1410
+ "palegoldenrod": "#eee8aa",
1411
+ "palegreen": "#98fb98",
1412
+ "paleturquoise": "#afeeee",
1413
+ "palevioletred": "#d87093",
1414
+ "papayawhip": "#ffefd5",
1415
+ "peachpuff": "#ffdab9",
1416
+ "peru": "#cd853f",
1417
+ "pink": "#ffc0cb",
1418
+ "plum": "#dda0dd",
1419
+ "powderblue": "#b0e0e6",
1420
+ "purple": "#800080",
1421
+ "red": "#ff0000",
1422
+ "rosybrown": "#bc8f8f",
1423
+ "royalblue": "#4169e1",
1424
+ "saddlebrown": "#8b4513",
1425
+ "salmon": "#fa8072",
1426
+ "sandybrown": "#f4a460",
1427
+ "seagreen": "#2e8b57",
1428
+ "seashell": "#fff5ee",
1429
+ "sienna": "#a0522d",
1430
+ "silver": "#c0c0c0",
1431
+ "skyblue": "#87ceeb",
1432
+ "slateblue": "#6a5acd",
1433
+ "slategray": "#708090",
1434
+ "snow": "#fffafa",
1435
+ "springgreen": "#00ff7f",
1436
+ "steelblue": "#4682b4",
1437
+ "tan": "#d2b48c",
1438
+ "teal": "#008080",
1439
+ "thistle": "#d8bfd8",
1440
+ "tomato": "#ff6347",
1441
+ "turquoise": "#40e0d0",
1442
+ "violet": "#ee82ee",
1443
+ "wheat": "#f5deb3",
1444
+ "white": "#ffffff",
1445
+ "whitesmoke": "#f5f5f5",
1446
+ "yellow": "#ffff00",
1447
+ "yellowgreen": "#9acd32"
1448
+ };
1449
+
1450
+ if (typeof colours[colour.toLowerCase()] != 'undefined')
1451
+ return colours[colour.toLowerCase()];
1452
+
1453
+ return false;
1454
+ }
1455
+
1456
+ function hexToRgb(hex) {
1457
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
1458
+ return result ? {
1459
+ r: parseInt(result[1], 16),
1460
+ g: parseInt(result[2], 16),
1461
+ b: parseInt(result[3], 16)
1462
+ } : null;
1463
+ }
1464
+
1465
+ function getCSSRule(ruleName, deleteFlag) {
1466
+ ruleName = ruleName.toLowerCase();
1467
+ if (document.styleSheets) {
1468
+ for (var i = 0; i < document.styleSheets.length; i++) {
1469
+ var styleSheet = document.styleSheets[i];
1470
+ var ii = 0;
1471
+ var cssRule = false;
1472
+ try {
1473
+ do {
1474
+ if (styleSheet.cssRules) {
1475
+ cssRule = styleSheet.cssRules[ii];
1476
+ } else if (styleSheet.rules) {
1477
+ cssRule = styleSheet.rules[ii];
1478
+ }
1479
+ if (cssRule) {
1480
+ if (typeof cssRule.selectorText != "undefined") {
1481
+ if (cssRule.selectorText.toLowerCase() == ruleName) {
1482
+ if (deleteFlag == 'delete') {
1483
+ if (styleSheet.cssRules) {
1484
+ styleSheet.deleteRule(ii);
1485
+ } else {
1486
+ styleSheet.removeRule(ii);
1487
+ }
1488
+ return true;
1489
+ } else {
1490
+ return cssRule;
1491
+ }
1492
+ }
1493
+ }
1494
+ }
1495
+ ii++;
1496
+ } while (cssRule)
1497
+ } catch (e) {
1498
+ // Firefox throws a SecurityError if you try reading
1499
+ // a cross-domain stylesheet
1500
+ if (e.name !== "SecurityError") {
1501
+ throw e;
1502
+ }
1503
+ }
1504
+ }
1505
+ }
1506
+ return false;
1507
+ }
1508
+
1509
+ function killCSSRule(ruleName) {
1510
+ return getCSSRule(ruleName, 'delete');
1511
+ }
1512
+
1513
+ function addCSSRule(ruleName) {
1514
+ if (document.styleSheets) {
1515
+ if (!getCSSRule(ruleName)) {
1516
+ if (document.styleSheets[0].addRule) {
1517
+ document.styleSheets[0].addRule(ruleName, null, 0);
1518
+ } else {
1519
+ document.styleSheets[0].insertRule(ruleName + ' { }', 0);
1520
+ }
1521
+ }
1522
+ }
1523
+ return getCSSRule(ruleName);
1524
+ }
1525
+
1526
+ function ShowGrid(height) {
1527
+ _showGrid = (height > 0);
1528
+ $("#gridPanel").show();
1529
+ $("#gridPanel").height(height);
1530
+ $("#gridCanvas").prop("height", height);
1531
+ paper.view.viewSize.height = height;
1532
+ }
1533
+
1534
+
1535
+ // ----------------------------------
1536
+ // Section added by The Pixie
1537
+
1538
+ function endsWith(str, suffix) {
1539
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
1540
+ }
1541
+
1542
+ // TODO: Stop calling this function from Core.aslx, I don't think the core libraries should depend on or manipulate
1543
+ // interface details like this - at least not while playercore.htm is part of the runtime instead of being supplied
1544
+ // by the library.
1545
+ function setCss(element, cssString) {
1546
+ el = $(element);
1547
+ ary = cssString.split(";");
1548
+ for (i = 0; i < ary.length; i++) {
1549
+ ary2 = ary[i].split(':');
1550
+ el.css(ary2[0], ary2[1]);
1551
+ }
1552
+ }
1553
+
1554
+ function addScript(text) {
1555
+ $('body').prepend(text);
1556
+ }
1557
+
1558
+ function colourBlend(colour1, colour2) {
1559
+ $('#gamePanes').css('background-color', 'transparent');
1560
+ $('#gameBorder').css('background-color', 'transparent');
1561
+ body = $('body');
1562
+ body.css('background-color', colour1);
1563
+ body.css('background-image', 'linear-gradient(to bottom, ' + colour1 + ', ' + colour2 + ')');
1564
+ body.css('background-image', '-webkit-linear-gradient(top, ' + colour1 + ', ' + colour2 + ')');
1565
+ body.css('background-attachment', 'fixed');
1566
+ body.css('background-position', 'left bottom');
1567
+ }
1568
+
1569
+
1570
+ elements = [
1571
+ '#statusVarsLabel', '#statusVarsAccordion',// '#statusVars',
1572
+ '#inventoryLabel', '#inventoryAccordion', '#inventoryAccordion.ui-widget-content',
1573
+ '#placesObjectsLabel', '#placesObjectsAccordion', '#placesObjectsAccordion.ui-widget-content',
1574
+ '#compassLabel', '#compassAccordion', '.ui-button', //'.ui-button-text',
1575
+ '#commandPane', '#customStatusPane'
1576
+ ];
1577
+
1578
+ dirs = ['N', 'E', 'S', 'W', 'NW', 'NE', 'SW', 'SE', 'U', 'In', 'D', 'Out'];
1579
+
1580
+ commandColour = 'orange'
1581
+
1582
+ function setElement(name, fore, back) {
1583
+ el = $(name);
1584
+ el.css('background', back);
1585
+ el.css('color', fore);
1586
+ el.css('border', 'solid 1px ' + fore);
1587
+ if (endsWith(name, "Accordion")) {
1588
+ el.css('border-top', 'none');
1589
+ }
1590
+ }
1591
+
1592
+ function setCompass(name, fore, back) {
1593
+ el = $('#cmdCompass' + name);
1594
+ el.css('background', back);
1595
+ el.css('border', '2px solid ' + fore);
1596
+ }
1597
+
1598
+ function setPanes(fore, back, secFore, secBack, highlight) {
1599
+ if (arguments.length == 2) {
1600
+ secFore = back;
1601
+ secBack = fore;
1602
+ }
1603
+ if (arguments.length < 5) {
1604
+ highlight = 'orange'
1605
+ }
1606
+ commandColour = fore;
1607
+ for (i = 0; i < elements.length; i++) {
1608
+ setElement(elements[i], fore, back);
1609
+ }
1610
+ for (i = 0; i < dirs.length; i++) {
1611
+ setElement(dirs[i], fore, back);
1612
+ }
1613
+
1614
+ var head = $('head');
1615
+ head.append('<style>.ui-button-text { color: ' + fore + ';}</style>');
1616
+ head.append('<style>.ui-state-active { color: ' + fore + ';}</style>');
1617
+ head.append('<style>.ui-widget-content { color: ' + fore + ';}</style>');
1618
+ head.append('<style>.ui-widget-header .ui-state-default { background-color: ' + secBack + ';}</style>');
1619
+ head.append('<style>.ui-selecting { color: ' + secFore + '; background-color: ' + highlight + ';}</style>');
1620
+ head.append('<style>.ui-selected { color: ' + secFore + '; background-color: ' + secBack + ';}</style>');
1621
+
1622
+ //$('.ui-button-text').css('color', fore);
1623
+ //$('.ui-state-active').css('color', fore);
1624
+ //$('.ui-widget-content').css('color', fore);
1625
+
1626
+ }
1627
+
1628
+ function setCommands(s, colour) {
1629
+ if (arguments.length == 2) commandColour = colour;
1630
+ ary = s.split(";");
1631
+ el = $('#commandPaneHeading');
1632
+ el.empty();
1633
+ for (i = 0; i < ary.length; i++) {
1634
+ ary2 = ary[i].split(":");
1635
+ comm = ary2[0];
1636
+ commLower = ary2[0].toLowerCase().replace(/ /g, "_");
1637
+ commComm = (ary2.length == 2 ? ary2[1] : ary2[0]).toLowerCase();
1638
+ //alert("ary[i]=" + ary[i] + ", Comm=" + comm + ", commComm=" + commComm + ", ary2[0].length=" + ary2.length);
1639
+ el.append(' <span id="' + commLower + '_command_button" class="accordion-header-text" style="padding:5px;"><a id="verblink' + commLower + '" class="cmdlink commandlink" style="text-decoration:none;color:' + commandColour + ';font-size:12pt;" data-elementid="" data-command="' + commComm + '">' + comm + '</a></span> ');
1640
+ }
1641
+ }
1642
+
1643
+ function setCustomStatus(s) {
1644
+ el = $('#customStatusPane');
1645
+ el.html(s);
1646
+ }
1647
+
1648
+
1649
+ // ----------------------------------
1650
+
1651
+
1652
+ $(function () {
1653
+ $("#gridPanel").mousewheel(function (e, delta) {
1654
+ gridApi.zoomIn(delta);
1655
+ return false;
1656
+ });
1657
+ });
1658
+
1659
+ // ***********
1660
+ // Section added by KV
1661
+
1662
+
1663
+ function isMobilePlayer() {
1664
+ if (typeof (currentTab) === 'string') {
1665
+ return true;
1666
+ }
1667
+ return false;
1668
+ }
1669
+
1670
+ function showPopup(title, text) {
1671
+ $('#msgboxCaption').html(text);
1672
+
1673
+ var msgboxOptions = {
1674
+ modal: true,
1675
+ autoOpen: false,
1676
+ title: title,
1677
+ buttons: [
1678
+ {
1679
+ text: 'OK',
1680
+ click: function () {
1681
+ $(this).dialog('close');
1682
+ }
1683
+ },
1684
+ ],
1685
+ closeOnEscape: false,
1686
+ };
1687
+
1688
+ $('#msgbox').dialog(msgboxOptions);
1689
+ $('#msgbox').dialog('open');
1690
+ }
1691
+
1692
+ function showPopupCustomSize(title, text, width, height) {
1693
+ $('#msgboxCaption').html(text);
1694
+
1695
+ var msgboxOptions = {
1696
+ modal: true,
1697
+ autoOpen: false,
1698
+ title: title,
1699
+ width: width,
1700
+ height: height,
1701
+ buttons: [
1702
+ {
1703
+ text: 'OK',
1704
+ click: function () {
1705
+ $(this).dialog('close');
1706
+ }
1707
+ },
1708
+ ],
1709
+ closeOnEscape: false,
1710
+ };
1711
+
1712
+ $('#msgbox').dialog(msgboxOptions);
1713
+ $('#msgbox').dialog('open');
1714
+ }
1715
+
1716
+ function showPopupFullscreen(title, text) {
1717
+ $('#msgboxCaption').html(text);
1718
+
1719
+ var msgboxOptions = {
1720
+ modal: true,
1721
+ autoOpen: false,
1722
+ title: title,
1723
+ width: $(window).width(),
1724
+ height: $(window).height(),
1725
+ buttons: [
1726
+ {
1727
+ text: 'OK',
1728
+ click: function () {
1729
+ $(this).dialog('close');
1730
+ }
1731
+ },
1732
+ ],
1733
+ closeOnEscape: false,
1734
+ };
1735
+
1736
+ $('#msgbox').dialog(msgboxOptions);
1737
+ $('#msgbox').dialog('open');
1738
+ }
1739
+
1740
+ // Log functions
1741
+ // In-game HTML log introduced in 5.8. Deprecated in 5.9
1742
+ // Its functions and variables are only here to avoid errors
1743
+
1744
+ var logVar = "";
1745
+
1746
+ function addLogEntry(data) {
1747
+ // Do nothing.
1748
+ }
1749
+
1750
+ var displayedInGameLogWarning = false;
1751
+
1752
+ function showLog() {
1753
+ // In-game HTML log introduced in 5.8. Removed in 5.9
1754
+ if (!displayedInGameLogWarning) {
1755
+ console.warning("The in-game HTML log feature has been removed.")
1756
+ displayedInGameLogWarning = true;
1757
+ }
1758
+ // Do nothing.
1759
+ }
1760
+
1761
+ function setupLogDiv() {
1762
+ // Do nothing.
1763
+ }
1764
+
1765
+ function showLogDiv() {
1766
+ // Do nothing.
1767
+ }
1768
+
1769
+ function hideLogDiv() {
1770
+ // Do nothing.
1771
+ }
1772
+
1773
+ function printLogDiv() {
1774
+ // Do nothing.
1775
+ }
1776
+
1777
+ function saveLog() {
1778
+ // Do nothing.
1779
+ }
1780
+
1781
+ // The transcript uses this function.
1782
+ function getTimeAndDateForLog() {
1783
+ var date = new Date();
1784
+ var currentDateTime = date.toLocaleString('en-US', {timeZoneName: 'short'}).replace(/,/g, "").replace(/[A-Z][A-Z][A-Z].*/g, "");
1785
+ return currentDateTime;
1786
+ }
1787
+
1788
+ // **********************************
1789
+ // TRANSCRIPT FUNCTIONS
1790
+
1791
+ function writeToTranscript(text) {
1792
+ if (!noTranscript && savingTranscript) {
1793
+ var faker = document.createElement('div');
1794
+ faker.innerHTML = text;
1795
+ text = faker.innerHTML;
1796
+ for (var key in Object.keys(faker.getElementsByTagName('img'))) {
1797
+ var elem = faker.getElementsByTagName('img')[key];
1798
+ if (elem != null) {
1799
+ var altProp = $(faker.getElementsByTagName('img')[key]).attr('alt') || "";
1800
+ text = text.replace(elem.outerHTML, altProp) || text;
1801
+ }
1802
+ }
1803
+ for (var key in Object.keys(faker.getElementsByTagName('area'))) {
1804
+ var elem = faker.getElementsByTagName('area')[key];
1805
+ if (elem != null) {
1806
+ var altProp = $(faker.getElementsByTagName('area')[key]).attr('alt') || "";
1807
+ text = text.replace(elem.outerHTML, altProp) || text;
1808
+ }
1809
+ }
1810
+ for (var key in Object.keys(faker.getElementsByTagName('input'))) {
1811
+ var elem = faker.getElementsByTagName('input')[key];
1812
+ if (elem != null) {
1813
+ var altProp = $(faker.getElementsByTagName('input')[key]).attr('alt') || "";
1814
+ text = text.replace(elem.outerHTML, altProp) || text;
1815
+ }
1816
+ }
1817
+ WriteToTranscript(transcriptName + "___SCRIPTDATA___" + $("<div>" + text.replace(/<br\/>/g, "@@@NEW_LINE@@@").replace(/<br>/g, "@@@NEW_LINE@@@").replace(/<br \/>/g, "@@@NEW_LINE@@@").replace("&nbsp;", " ") + "</div>").text());
1818
+ }
1819
+ }
1820
+
1821
+ function enableTranscript(name) {
1822
+ if (noTranscript) return;
1823
+ transcriptName = name || transcriptName || gameName;
1824
+ savingTranscript = true;
1825
+ }
1826
+
1827
+ function disableTranscript() {
1828
+ savingTranscript = false;
1829
+ }
1830
+
1831
+ function killTranscript() {
1832
+ noTranscript = true;
1833
+ disableTranscript();
1834
+ }
1835
+
1836
+ function setTranscriptStatus(status) {
1837
+ switch (status) {
1838
+ case "enabled":
1839
+ var name = transcriptName || gameName;
1840
+ enableTranscript(name);
1841
+ break;
1842
+ case "disabled":
1843
+ disableTranscript();
1844
+ break;
1845
+ case "prohibited":
1846
+ case "none":
1847
+ case "killed":
1848
+ killTranscript();
1849
+ break;
1850
+ case "allowed":
1851
+ noTranscript = false;
1852
+ }
1853
+ }
1854
+
1855
+ var showedSaveTranscriptWarning = false;
1856
+
1857
+ /*
1858
+ * This function was missing from the webplayer in Quest 5.8.0
1859
+ * Leaving this here as a fallback
1860
+ */
1861
+ function SaveTranscript(text) {
1862
+ if (!showedSaveTranscriptWarning) {
1863
+ console.log("[QUEST]: SaveTranscript has been deprecated. Using writeToTranscript instead.");
1864
+ showedSaveTranscriptWarning = true;
1865
+ }
1866
+ writeToTranscript(text);
1867
+ }
1868
+
1869
+ var transcriptUrl = 'TranscriptViewer/index.html';
1870
+
1871
+ // Another fallback to avoid errors
1872
+ function showTranscript() {
1873
+ addTextAndScroll('Your transcripts are saved to the localStorage in your browser. You can view, download, or delete them here: <a href="' + transcriptUrl + '" target="_blank">Your Transcripts</a><br/>');
1874
+ }
1875
+
1876
+ function replaceTranscriptString(data) {
1877
+ // Added in 5.8, and never worked properly.
1878
+ // Do nothing.
1879
+ }
1880
+
1881
+ function printTranscriptDiv() {
1882
+ // Added in 5.8, and never worked properly.
1883
+ // Do nothing.
1884
+ }
1885
+
1886
+ function reviveTranscript() {
1887
+ noTranscript = false;
1888
+ }
1889
+
1890
+ function getDateAndTimeForTranscript() {
1891
+ return new Date().toLocaleString(navigator.language, {timeZoneName: 'short'});
1892
+ }
1893
+
1894
+ function printTranscriptDateAndTime() {
1895
+ addTextAndScroll('<b>DATE AND TIME:</b> ' + getDateAndTimeForTranscript());
1896
+ }
1897
+
1898
+ function loadTranscriptNameInputVal() {
1899
+ $('input#txtCommand').val(transcriptName);
1900
+ }
1901
+
1902
+ // ***********************************
1903
+
1904
+ function disableMenuOutputSection(el) {
1905
+ $('.' + el + ' .cmdlink').addClass('disabled').attr('onclick', null);
1906
+ }
1907
+
1908
+
1909
+ // GRID FUNCTIONS ***********************************************************************************************************************
1910
+
1911
+ // gridApi is global for interop between PaperScript and JavaScript - a workaround until
1912
+ // this tutorial exists: http://paperjs.org/tutorials/getting-started/paperscript-interoperability/
1913
+
1914
+ window.gridApi = {};
1915
+ window.gridApi.onLoad = function () {
1916
+ };
1917
+
1918
+ _canvasSupported = (window.HTMLCanvasElement);
1919
+
1920
+ function Grid_DrawGridLines(minX, minY, maxX, maxY, border) {
1921
+ if (!_canvasSupported) return;
1922
+ gridApi.drawGrid(parseInt(minX), parseInt(minY), parseInt(maxX), parseInt(maxY), border);
1923
+ }
1924
+
1925
+ function Grid_SetScale(scale) {
1926
+ if (!_canvasSupported) return;
1927
+ gridApi.setScale(parseInt(scale));
1928
+ }
1929
+
1930
+ function Grid_DrawBox(x, y, z, width, height, border, borderWidth, fill, sides) {
1931
+ if (!_canvasSupported) return;
1932
+ gridApi.drawBox(parseFloat(x), parseFloat(y), parseFloat(z), parseInt(width), parseInt(height), border, parseInt(borderWidth), fill, parseInt(sides));
1933
+ }
1934
+
1935
+ function Grid_DrawLine(x1, y1, x2, y2, border, borderWidth) {
1936
+ if (!_canvasSupported) return;
1937
+ gridApi.drawLine(parseFloat(x1), parseFloat(y1), parseFloat(x2), parseFloat(y2), border, parseInt(borderWidth));
1938
+ }
1939
+
1940
+ function Grid_DrawArrow(id, x1, y1, x2, y2, border, borderWidth) {
1941
+ if (!_canvasSupported) return;
1942
+ gridApi.drawArrow(id, parseFloat(x1), parseFloat(y1), parseFloat(x2), parseFloat(y2), border, parseInt(borderWidth));
1943
+ }
1944
+
1945
+ function Grid_DrawPlayer(x, y, z, radius, border, borderWidth, fill) {
1946
+ if (!_canvasSupported) return;
1947
+ gridApi.drawPlayer(parseFloat(x), parseFloat(y), parseFloat(z), parseInt(radius), border, parseInt(borderWidth), fill);
1948
+ }
1949
+
1950
+ function Grid_DrawLabel(x, y, z, text, col) {
1951
+ if (col === undefined) col = "black";
1952
+ if (!_canvasSupported) return;
1953
+ gridApi.drawLabel(parseFloat(x), parseFloat(y), parseFloat(z), text, col);
1954
+ }
1955
+
1956
+ function Grid_ShowCustomLayer(visible) {
1957
+ if (!_canvasSupported) return;
1958
+ gridApi.showCustomLayer(visible == "true");
1959
+ }
1960
+
1961
+ function Grid_ClearCustomLayer() {
1962
+ if (!_canvasSupported) return;
1963
+ gridApi.clearCustomLayer();
1964
+ }
1965
+
1966
+ function Grid_ClearAllLayers() {
1967
+ if (!_canvasSupported) return;
1968
+ gridApi.clearAllLayers();
1969
+ }
1970
+
1971
+ function Grid_SetCentre(x, y) {
1972
+ if (!_canvasSupported) return;
1973
+ gridApi.setCentre(parseFloat(x), parseFloat(y));
1974
+ }
1975
+
1976
+ function Grid_DrawSquare(id, x, y, width, height, text, fill) {
1977
+ if (!_canvasSupported) return;
1978
+ gridApi.drawCustomLayerSquare(id, parseInt(x), parseInt(y), parseInt(width), parseInt(height), text, fill);
1979
+ }
1980
+
1981
+ function Grid_LoadSvg(data, id) {
1982
+ if (!_canvasSupported) return;
1983
+ gridApi.loadSvg(data, id);
1984
+ }
1985
+
1986
+ function Grid_DrawSvg(id, symbolId, x, y, width, height) {
1987
+ if (!_canvasSupported) return;
1988
+ gridApi.drawCustomLayerSvg(id, symbolId, parseInt(x), parseInt(y), parseInt(width), parseInt(height));
1989
+ }
1990
+
1991
+ function Grid_DrawImage(id, url, x, y, width, height) {
1992
+ if (!_canvasSupported) return;
1993
+ gridApi.drawCustomLayerImage(id, url, parseInt(x), parseInt(y), parseInt(width), parseInt(height));
1994
+ }
1995
+
1996
+ function Grid_AddNewShapePoint(x, y) {
1997
+ if (!_canvasSupported) return;
1998
+ gridApi.addNewShapePoint(x, y);
1999
+ }
2000
+
2001
+ function Grid_DrawShape(id, border, fill, opacity) {
2002
+ if (!_canvasSupported) return;
2003
+ gridApi.drawShape(id, border, fill, opacity);
2004
+ }
2005
+
2006
+ // JQUERY.MOUSEWEHEEL.JS ****************************************************************************************************************
2007
+ // https://github.com/brandonaaron/jquery-mousewheel
2008
+
2009
+ /*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
2010
+ * Licensed under the MIT License (LICENSE.txt).
2011
+ *
2012
+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
2013
+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
2014
+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
2015
+ *
2016
+ * Version: 3.0.6
2017
+ *
2018
+ * Requires: 1.2.2+
2019
+ */
2020
+
2021
+ (function ($) {
2022
+
2023
+ var types = ['DOMMouseScroll', 'mousewheel'];
2024
+
2025
+ if ($.event.fixHooks) {
2026
+ for (var i = types.length; i;) {
2027
+ $.event.fixHooks[types[--i]] = $.event.mouseHooks;
2028
+ }
2029
+ }
2030
+
2031
+ $.event.special.mousewheel = {
2032
+ setup: function () {
2033
+ if (this.addEventListener) {
2034
+ for (var i = types.length; i;) {
2035
+ this.addEventListener(types[--i], handler, false);
2036
+ }
2037
+ } else {
2038
+ this.onmousewheel = handler;
2039
+ }
2040
+ },
2041
+
2042
+ teardown: function () {
2043
+ if (this.removeEventListener) {
2044
+ for (var i = types.length; i;) {
2045
+ this.removeEventListener(types[--i], handler, false);
2046
+ }
2047
+ } else {
2048
+ this.onmousewheel = null;
2049
+ }
2050
+ }
2051
+ };
2052
+
2053
+ $.fn.extend({
2054
+ mousewheel: function (fn) {
2055
+ return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
2056
+ },
2057
+
2058
+ unmousewheel: function (fn) {
2059
+ return this.unbind("mousewheel", fn);
2060
+ }
2061
+ });
2062
+
2063
+
2064
+ function handler(event) {
2065
+ var orgEvent = event || window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = true,
2066
+ deltaX = 0, deltaY = 0;
2067
+ event = $.event.fix(orgEvent);
2068
+ event.type = "mousewheel";
2069
+
2070
+ // Old school scrollwheel delta
2071
+ if (orgEvent.wheelDelta) {
2072
+ delta = orgEvent.wheelDelta / 120;
2073
+ }
2074
+ if (orgEvent.detail) {
2075
+ delta = -orgEvent.detail / 3;
2076
+ }
2077
+
2078
+ // New school multidimensional scroll (touchpads) deltas
2079
+ deltaY = delta;
2080
+
2081
+ // Gecko
2082
+ if (orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
2083
+ deltaY = 0;
2084
+ deltaX = -1 * delta;
2085
+ }
2086
+
2087
+ // Webkit
2088
+ if (orgEvent.wheelDeltaY !== undefined) {
2089
+ deltaY = orgEvent.wheelDeltaY / 120;
2090
+ }
2091
+ if (orgEvent.wheelDeltaX !== undefined) {
2092
+ deltaX = -1 * orgEvent.wheelDeltaX / 120;
2093
+ }
2094
+
2095
+ // Add event and delta to the front of the arguments
2096
+ args.unshift(event, delta, deltaX, deltaY);
2097
+
2098
+ return ($.event.dispatch || $.event.handle).apply(this, args);
2099
+ }
2100
+
2101
+ })(jQuery);
2102
+
2103
+ // JQUERY.TEXT-EFFECTS.JS ***************************************************************************************************************
2104
+ // https://github.com/jaz303/jquery-grab-bag/blob/master/javascripts/jquery.text-effects.js
2105
+
2106
+ // (c) 2008 Jason Frame (jason@onehackoranother.com)
2107
+ // Released under The MIT License.
2108
+
2109
+ (function ($) {
2110
+
2111
+ function shuffle(a) {
2112
+ var i = a.length, j;
2113
+ while (i) {
2114
+ var j = Math.floor((i--) * Math.random());
2115
+ var t = a[i];
2116
+ a[i] = a[j];
2117
+ a[j] = t;
2118
+ }
2119
+ }
2120
+
2121
+ function randomAlphaNum() {
2122
+ var rnd = Math.floor(Math.random() * 62);
2123
+ if (rnd >= 52) return String.fromCharCode(rnd - 4);
2124
+ else if (rnd >= 26) return String.fromCharCode(rnd + 71);
2125
+ else return String.fromCharCode(rnd + 65);
2126
+ }
2127
+
2128
+ $.fn.rot13 = function () {
2129
+ this.each(function () {
2130
+ $(this).text($(this).text().replace(/[a-z0-9]/ig, function (chr) {
2131
+ var cc = chr.charCodeAt(0);
2132
+ if (cc >= 65 && cc <= 90) cc = 65 + ((cc - 52) % 26);
2133
+ else if (cc >= 97 && cc <= 122) cc = 97 + ((cc - 84) % 26);
2134
+ else if (cc >= 48 && cc <= 57) cc = 48 + ((cc - 43) % 10);
2135
+ return String.fromCharCode(cc);
2136
+ }));
2137
+ });
2138
+ return this;
2139
+ };
2140
+
2141
+ $.fn.scrambledWriter = function () {
2142
+ this.each(function () {
2143
+ var $ele = $(this), str = $ele.text(), progress = 0, replace = /[^\s]/g,
2144
+ random = randomAlphaNum, inc = 3;
2145
+ $ele.text('');
2146
+ var timer = setInterval(function () {
2147
+ $ele.text(str.substring(0, progress) + str.substring(progress, str.length).replace(replace, random));
2148
+ progress += inc
2149
+ if (progress >= str.length + inc) clearInterval(timer);
2150
+ }, 100);
2151
+ });
2152
+ return this;
2153
+ };
2154
+
2155
+ $.fn.typewriter = function (speed) {
2156
+ this.each(function () {
2157
+ var $ele = $(this), str = $ele.text(), progress = 0;
2158
+ $ele.text('');
2159
+ var timer = setInterval(function () {
2160
+ $ele.text(str.substring(0, progress++) + ((progress & 1) && progress < str.length ? '_' : ''));
2161
+ if (progress >= str.length) clearInterval(timer);
2162
+ }, speed);
2163
+ });
2164
+ return this;
2165
+ };
2166
+
2167
+ $.fn.unscramble = function (speed, reveal) {
2168
+ this.each(function () {
2169
+ var $ele = $(this), str = $ele.text(), replace = /[^\s]/,
2170
+ state = [], choose = [], random = randomAlphaNum;
2171
+
2172
+ for (var i = 0; i < str.length; i++) {
2173
+ if (str.charAt(i).match(replace)) {
2174
+ state.push(random());
2175
+ choose.push(i);
2176
+ } else {
2177
+ state.push(str.charAt(i));
2178
+ }
2179
+ }
2180
+
2181
+ shuffle(choose);
2182
+ $ele.text(state.join(''));
2183
+
2184
+ var timer = setInterval(function () {
2185
+ var i, r = reveal;
2186
+ while (r-- && choose.length) {
2187
+ i = choose.pop();
2188
+ state[i] = str.charAt(i);
2189
+ }
2190
+ for (i = 0; i < choose.length; i++) state[choose[i]] = random();
2191
+ $ele.text(state.join(''));
2192
+ if (choose.length == 0) clearInterval(timer);
2193
+ }, speed);
2194
+ });
2195
+ return this;
2196
+ };
2197
+
2198
+ })(jQuery);
2199
+
2200
+ // JQUERY.INVIEW.JS *********************************************************************************************************************
2201
+
2202
+ /**
2203
+ * author Christopher Blum
2204
+ * - based on the idea of Remy Sharp, http://remysharp.com/2009/01/26/element-in-view-event-plugin/
2205
+ * - forked from http://github.com/zuk/jquery.inview/
2206
+ */
2207
+ (function ($) {
2208
+ var inviewObjects = {}, viewportSize, viewportOffset,
2209
+ d = document, w = window, documentElement = d.documentElement, expando = $.expando, timer;
2210
+
2211
+ $.event.special.inview = {
2212
+ add: function (data) {
2213
+ inviewObjects[data.guid + "-" + this[expando]] = {data: data, $element: $(this)};
2214
+
2215
+ // Use setInterval in order to also make sure this captures elements within
2216
+ // "overflow:scroll" elements or elements that appeared in the dom tree due to
2217
+ // dom manipulation and reflow
2218
+ // old: $(window).scroll(checkInView);
2219
+ //
2220
+ // By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays
2221
+ // intervals while the user scrolls. Therefore the inview event might fire a bit late there
2222
+ //
2223
+ // Don't waste cycles with an interval until we get at least one element that
2224
+ // has bound to the inview event.
2225
+ if (!timer && !$.isEmptyObject(inviewObjects)) {
2226
+ timer = setInterval(checkInView, 250);
2227
+ }
2228
+ },
2229
+
2230
+ remove: function (data) {
2231
+ try {
2232
+ delete inviewObjects[data.guid + "-" + this[expando]];
2233
+ } catch (e) {
2234
+ }
2235
+
2236
+ // Clear interval when we no longer have any elements listening
2237
+ if ($.isEmptyObject(inviewObjects)) {
2238
+ clearInterval(timer);
2239
+ timer = null;
2240
+ }
2241
+ }
2242
+ };
2243
+
2244
+ function getViewportSize() {
2245
+ var mode, domObject, size = {height: w.innerHeight, width: w.innerWidth};
2246
+
2247
+ // if this is correct then return it. iPad has compat Mode, so will
2248
+ // go into check clientHeight/clientWidth (which has the wrong value).
2249
+ if (!size.height) {
2250
+ mode = d.compatMode;
2251
+ if (mode || !$.support.boxModel) { // IE, Gecko
2252
+ domObject = mode === 'CSS1Compat' ?
2253
+ documentElement : // Standards
2254
+ d.body; // Quirks
2255
+ size = {
2256
+ height: domObject.clientHeight,
2257
+ width: domObject.clientWidth
2258
+ };
2259
+ }
2260
+ }
2261
+
2262
+ return size;
2263
+ }
2264
+
2265
+ function getViewportOffset() {
2266
+ return {
2267
+ top: w.pageYOffset || documentElement.scrollTop || d.body.scrollTop,
2268
+ left: w.pageXOffset || documentElement.scrollLeft || d.body.scrollLeft
2269
+ };
2270
+ }
2271
+
2272
+ function checkInView() {
2273
+ var $elements = $(), elementsLength, i = 0;
2274
+
2275
+ $.each(inviewObjects, function (i, inviewObject) {
2276
+ var selector = inviewObject.data.selector,
2277
+ $element = inviewObject.$element;
2278
+ $elements = $elements.add(selector ? $element.find(selector) : $element);
2279
+ });
2280
+
2281
+ elementsLength = $elements.length;
2282
+ if (elementsLength) {
2283
+ viewportSize = viewportSize || getViewportSize();
2284
+ viewportOffset = viewportOffset || getViewportOffset();
2285
+
2286
+ for (; i < elementsLength; i++) {
2287
+ // Ignore elements that are not in the DOM tree
2288
+ if (!$.contains(documentElement, $elements[i])) {
2289
+ continue;
2290
+ }
2291
+
2292
+ var $element = $($elements[i]),
2293
+ elementSize = {height: $element.height(), width: $element.width()},
2294
+ elementOffset = $element.offset(),
2295
+ inView = $element.data('inview'),
2296
+ visiblePartX,
2297
+ visiblePartY,
2298
+ visiblePartsMerged;
2299
+
2300
+ // Don't ask me why because I haven't figured out yet:
2301
+ // viewportOffset and viewportSize are sometimes suddenly null in Firefox 5.
2302
+ // Even though it sounds weird:
2303
+ // It seems that the execution of this function is interferred by the onresize/onscroll event
2304
+ // where viewportOffset and viewportSize are unset
2305
+ if (!viewportOffset || !viewportSize) {
2306
+ return;
2307
+ }
2308
+
2309
+ if (elementOffset.top + elementSize.height > viewportOffset.top &&
2310
+ elementOffset.top < viewportOffset.top + viewportSize.height &&
2311
+ elementOffset.left + elementSize.width > viewportOffset.left &&
2312
+ elementOffset.left < viewportOffset.left + viewportSize.width) {
2313
+ visiblePartX = (viewportOffset.left > elementOffset.left ?
2314
+ 'right' : (viewportOffset.left + viewportSize.width) < (elementOffset.left + elementSize.width) ?
2315
+ 'left' : 'both');
2316
+ visiblePartY = (viewportOffset.top > elementOffset.top ?
2317
+ 'bottom' : (viewportOffset.top + viewportSize.height) < (elementOffset.top + elementSize.height) ?
2318
+ 'top' : 'both');
2319
+ visiblePartsMerged = visiblePartX + "-" + visiblePartY;
2320
+ if (!inView || inView !== visiblePartsMerged) {
2321
+ $element.data('inview', visiblePartsMerged).trigger('inview', [true, visiblePartX, visiblePartY]);
2322
+ }
2323
+ } else if (inView) {
2324
+ $element.data('inview', false).trigger('inview', [false]);
2325
+ }
2326
+ }
2327
+ }
2328
+ }
2329
+
2330
+ $(w).bind("scroll resize scrollstop", function () {
2331
+ viewportSize = viewportOffset = null;
2332
+ });
2333
+
2334
+ // IE < 9 scrolls to focused elements without firing the "scroll" event
2335
+ if (!documentElement.addEventListener && documentElement.attachEvent) {
2336
+ documentElement.attachEvent("onfocusin", function () {
2337
+ viewportOffset = null;
2338
+ });
2339
+ }
2340
+ })(jQuery);
2341
+
2342
+ // JJMENU.JS ****************************************************************************************************************************
2343
+
2344
+ /* Heavily modified, based on jjmenu 1.1.2 by Jacek Jursza (okhan.pl@gmail.com)
2345
+ * http://jursza.net/dev/jjmenu/
2346
+ *
2347
+ * copyright (c) 2009 Jacek Jursza (http://jursza.net/)
2348
+ * licence MIT [http://www.opensource.org/licenses/mit-license.php]
2349
+ */
2350
+
2351
+ (function ($) {
2352
+
2353
+ $(document).click(function (event) {
2354
+ if (event.button != 2) $("div[id^=jjmenu]").remove();
2355
+ });
2356
+
2357
+ $.fn.jjmenu = function (param) {
2358
+ this.click(function (event) {
2359
+ event.preventDefault();
2360
+ event.stopPropagation();
2361
+ $(this).jjmenu_popup(param);
2362
+ $(this).blur();
2363
+ return false;
2364
+ });
2365
+ };
2366
+
2367
+ $.fn.jjmenu_popup = function (param) {
2368
+ var el = this;
2369
+
2370
+ if (typeof param === "undefined") {
2371
+ var verbs = el.data("verbs");
2372
+ if (!verbs) {
2373
+ // No live verb data for this element yet (or it was never made
2374
+ // available server-side) - nothing to show, so bail out rather
2375
+ // than crashing on an undefined verb list.
2376
+ return;
2377
+ }
2378
+ var text = el.html();
2379
+ var elementId = el.data("elementid");
2380
+ param = buildMenuOptions(verbs, text, elementId);
2381
+ }
2382
+
2383
+ $("div[id^=jjmenu_main]").remove();
2384
+
2385
+ var m = document.createElement('div');
2386
+ var ms = document.createElement('span');
2387
+ $(m).append(ms);
2388
+
2389
+ m.className = "jjmenu";
2390
+ m.id = "jjmenu_main";
2391
+ $(m).css({display: 'none'});
2392
+ $(document.body).append(m);
2393
+
2394
+ positionMenu();
2395
+
2396
+ for (var i in param) {
2397
+ putItem(param[i]);
2398
+ }
2399
+
2400
+ checkPosition();
2401
+ showMenu();
2402
+
2403
+ function positionMenu() {
2404
+ var pos = $(el).offset();
2405
+ var t = pos.top;
2406
+ var l = pos.left;
2407
+ $(m).css({position: "absolute", top: t + "px", left: l + "px"});
2408
+ }
2409
+
2410
+ function checkPosition() {
2411
+
2412
+ var isHidden = $(m).css("display") == "none";
2413
+ if (isHidden) $(m).show();
2414
+
2415
+ var positionTop = $(m).offset().top;
2416
+ var positionLeft = $(m).offset().left;
2417
+ if (isHidden) $(m).hide();
2418
+
2419
+ var xPos = positionTop - $(window).scrollTop();
2420
+
2421
+ $(m).css({left: "0px"});
2422
+ var menuHeight = $(m).outerHeight();
2423
+ var menuWidth = $(m).outerWidth();
2424
+ $(m).css({left: positionLeft + "px"});
2425
+
2426
+ var nleft = positionLeft;
2427
+ if (positionLeft + menuWidth > $(window).width()) {
2428
+ nleft = $(window).width() - menuWidth;
2429
+ }
2430
+
2431
+ var spaceBottom = true;
2432
+
2433
+ if (xPos + menuHeight + $(el).outerHeight() > $(window).height()) {
2434
+ spaceBottom = false;
2435
+ }
2436
+
2437
+ var spaceTop = true;
2438
+
2439
+ if (positionTop - menuHeight < 0) {
2440
+ spaceTop = false;
2441
+ }
2442
+
2443
+ var ntop;
2444
+
2445
+ if (!spaceBottom && spaceTop) {
2446
+ // top orientation
2447
+ ntop = parseInt(positionTop, 10) - parseInt(menuHeight, 10);
2448
+ $(m).addClass("topOriented");
2449
+
2450
+ } else {
2451
+ // bottom orientation
2452
+ $(m).addClass("bottomOriented");
2453
+ positionTop = positionTop + $(el).outerHeight();
2454
+ ntop = parseInt(positionTop, 10);
2455
+ }
2456
+
2457
+ $(m).css({"top": ntop + "px", "left": nleft + "px"});
2458
+ }
2459
+
2460
+ function showMenu() {
2461
+ var speed = 100;
2462
+ $(m).fadeIn(speed);
2463
+ }
2464
+
2465
+ function putItem(n) {
2466
+ var item = document.createElement('div');
2467
+ $(item).hover(function () {
2468
+ $(this).addClass("jj_menu_item_hover");
2469
+ },
2470
+ function () {
2471
+ $(this).removeClass("jj_menu_item_hover");
2472
+ });
2473
+
2474
+ $(item).click(function (event) {
2475
+ event.stopPropagation();
2476
+ $("div[id^=jjmenu]").remove();
2477
+ n.action.callback(n.title);
2478
+ });
2479
+
2480
+ var span = document.createElement('span');
2481
+ $(item).append(span);
2482
+
2483
+ item.className = "jj_menu_item";
2484
+
2485
+ $(span).html(n.title);
2486
+ $(ms).append(item);
2487
+ }
2488
+ }
2489
+
2490
+ })(jQuery);
2491
+
2492
+ function whereAmI() {
2493
+ ASLEvent("WhereAmI", platform);
2494
+ }
2495
+
2496
+ var platform = "desktop";
2497
+
2498
+ const GameSaver = (() => {
2499
+ function openDatabase() {
2500
+ return new Promise((resolve, reject) => {
2501
+ const request = indexedDB.open('quest-viva-saves', 1);
2502
+
2503
+ request.onupgradeneeded = () => {
2504
+ const db = request.result;
2505
+ if (!db.objectStoreNames.contains('saves')) {
2506
+ db.createObjectStore('saves', {keyPath: ['gameId', 'slotIndex']});
2507
+ }
2508
+ };
2509
+
2510
+ request.onsuccess = () => resolve(request.result);
2511
+ request.onerror = () => reject(request.error);
2512
+ });
2513
+ }
2514
+
2515
+ async function ensurePersistentStorage() {
2516
+ if (navigator.storage && navigator.storage.persist) {
2517
+ const isPersisted = await navigator.storage.persisted();
2518
+ if (isPersisted) {
2519
+ console.log('Storage is already persistent.');
2520
+ return true;
2521
+ }
2522
+
2523
+ const granted = await navigator.storage.persist();
2524
+ if (granted) {
2525
+ console.log('Storage permission granted: persistent!');
2526
+ } else {
2527
+ console.warn('Persistent storage request was denied.');
2528
+ }
2529
+ return granted;
2530
+ } else {
2531
+ console.warn('StorageManager API not supported.');
2532
+ return false;
2533
+ }
2534
+ }
2535
+
2536
+ async function saveGame(gameId, slotIndex, dataUint8Array, name) {
2537
+ const db = await openDatabase();
2538
+ const tx = db.transaction('saves', 'readwrite');
2539
+ const store = tx.objectStore('saves');
2540
+
2541
+ const entry = {
2542
+ gameId,
2543
+ slotIndex,
2544
+ data: dataUint8Array,
2545
+ name,
2546
+ timestamp: new Date()
2547
+ };
2548
+
2549
+ store.put(entry);
2550
+
2551
+ return tx.complete || tx.done || new Promise((res, rej) => {
2552
+ tx.oncomplete = res;
2553
+ tx.onerror = rej;
2554
+ });
2555
+ }
2556
+
2557
+ async function listSaves(gameId) {
2558
+ const db = await openDatabase();
2559
+ const tx = db.transaction('saves', 'readonly');
2560
+ const store = tx.objectStore('saves');
2561
+
2562
+ const request = store.getAll();
2563
+
2564
+ return new Promise((resolve, reject) => {
2565
+ request.onsuccess = () => {
2566
+ const slots = request.result
2567
+ .filter(entry => entry.gameId === gameId)
2568
+ .map(entry => ({
2569
+ slotIndex: entry.slotIndex,
2570
+ name: entry.name || null,
2571
+ timestamp: entry.timestamp || null,
2572
+ }));
2573
+
2574
+ resolve(slots);
2575
+ };
2576
+ request.onerror = () => reject(request.error);
2577
+ });
2578
+ }
2579
+
2580
+ async function loadGame(gameId, slotIndex) {
2581
+ const db = await openDatabase();
2582
+ const tx = db.transaction('saves', 'readonly');
2583
+ const store = tx.objectStore('saves');
2584
+ const request = store.get([gameId, slotIndex]);
2585
+
2586
+ return new Promise((resolve, reject) => {
2587
+ request.onsuccess = () => resolve(request.result?.data || null);
2588
+ request.onerror = () => reject(request.error);
2589
+ });
2590
+ }
2591
+
2592
+ async function deleteSaveSlot(gameId, slotIndex) {
2593
+ const db = await openDatabase();
2594
+ const tx = db.transaction('saves', 'readwrite');
2595
+ const store = tx.objectStore('saves');
2596
+ store.delete([gameId, slotIndex]);
2597
+
2598
+ return tx.complete || tx.done || new Promise((res, rej) => {
2599
+ tx.oncomplete = res;
2600
+ tx.onerror = rej;
2601
+ });
2602
+ }
2603
+
2604
+ async function nextSlotIndex(gameId) {
2605
+ const existing = await listSaves(gameId);
2606
+ return existing.length ? Math.max(...existing.map(s => s.slotIndex)) + 1 : 0;
2607
+ }
2608
+
2609
+ let persistenceRequested = false;
2610
+
2611
+ return {
2612
+ save: async (name) => {
2613
+ const gameId = WebPlayer.gameId;
2614
+ const saveData = $("#divOutput").html();
2615
+ const result = await WebPlayer.uiSaveGame(saveData);
2616
+ const slotIndex = await nextSlotIndex(gameId);
2617
+ // Locale-formatted (not ISO) so it reads naturally wherever it's shown —
2618
+ // WebPlayer's Slots list shows only the name, with no separate timestamp.
2619
+ const label = name || "Saved game — " + new Date().toLocaleString();
2620
+ await saveGame(gameId, slotIndex, result, label);
2621
+ addText("Game saved.<br>");
2622
+ clearUnsavedProgress();
2623
+ if (!persistenceRequested) {
2624
+ await ensurePersistentStorage();
2625
+ persistenceRequested = true;
2626
+ }
2627
+ return {slotIndex, name: label};
2628
+ },
2629
+ listSaves: async (gameId = WebPlayer.gameId) => {
2630
+ return await listSaves(gameId);
2631
+ },
2632
+ load: async (slotIndex, gameId = WebPlayer.gameId) => {
2633
+ return await loadGame(gameId, slotIndex);
2634
+ },
2635
+ deleteSlot: async (slotIndex, gameId = WebPlayer.gameId) => {
2636
+ return await deleteSaveSlot(gameId, slotIndex);
2637
+ }
2638
+ }
2639
+ })();