diff --git a/src/002-config/mousetrapConfig.js b/src/002-config/mousetrapConfig.js index da2641fb38a03b0b3aae3041456e9e0b7a941f50..dd39ff0c3d8b77d5ca4062e99907c29746b1c5b6 100644 --- a/src/002-config/mousetrapConfig.js +++ b/src/002-config/mousetrapConfig.js @@ -255,11 +255,43 @@ App.UI.Hotkeys = (function() { } } + function settingsPage() { + const f = document.createDocumentFragment(); + + App.UI.DOM.appendNewElement("h1", f, "Hotkey Settings"); + + const p = document.createElement("p"); + const ul = document.createElement("ul"); + + let li = document.createElement("li"); + li.append("On keyboard layouts other than the "); + const a = document.createElement("a"); + a.href = "https://en.wikipedia.org/wiki/File:KB_United_States.svg"; + a.target = "_blank"; + a.append("US-QWERTY layout"); + li.append(a, + "there may be keys or combinations of keys where the recorded key is different from the key used to listen to key events. You will have to find these keys yourself through trial and error."); + ul.append(li); + + App.UI.DOM.appendNewElement("li", ul, "Custom hotkeys are browser specific and are not part of your save."); + + li = document.createElement("li"); + li.append("While we try not to overwrite browser or OS level key combinations it is possible to do so with custom hotkeys. This also means that during recording of custom hotkeys no browser or OS level key combinations are available. There are however keys that cannot be overwritten, the ", + App.UI.DOM.makeElement("code", "Win key"), " on Windows is an example for this."); + ul.append(li); + + p.append(ul); + f.append(p); + + f.append(settingsMenu()); + return f; + } + return { add: addDefault, hotkeys: hotkeysForAction, init: init, - settings: settingsMenu, + settings: settingsPage, }; })(); diff --git a/src/004-base/domPassage.js b/src/004-base/domPassage.js new file mode 100644 index 0000000000000000000000000000000000000000..441a8a87ef71ae7eaec796f7b57030bc4ce44811 --- /dev/null +++ b/src/004-base/domPassage.js @@ -0,0 +1,26 @@ +/** + * A pure DOM Passage, the SugarCube Wikifier never gets invoked. + */ +App.DomPassage = class extends Passage { + /** + * @param {string} title + * @param {function():DocumentFragment|function():HTMLElement} callback + * @param {string[]} tags + */ + constructor(title, callback, tags = []) { + super(title, { + hasAttribute: a => a === "tags", + getAttribute: () => tags.join(" ") + }); + this.callback = callback; + + Story.add(this); + } + + /** + * @returns {DocumentFragment|HTMLElement} + */ + render() { + return this.callback(); + } +}; diff --git a/src/005-passages/options.js b/src/005-passages/options.js new file mode 100644 index 0000000000000000000000000000000000000000..ec6cf6a86d09225e9cc68b31c654cfde8b48b2de --- /dev/null +++ b/src/005-passages/options.js @@ -0,0 +1,59 @@ +new App.DomPassage("Options", + () => { + if (lastVisited("Slave Interact") === 1) { + V.storedLink = "Slave Interact"; + } else { + V.storedLink = "Main"; + } + + V.nextButton = "Back"; + V.nextLink = V.storedLink; + V.encyclopedia = "How to Play"; + + return App.UI.optionsPassage(); + }, ["jump-to-safe", "jump-from-safe"] +); + +new App.DomPassage("Description Options", + () => { + V.nextButton = "Back"; + if (V.storedLink !== "Slave Interact") { + if (lastVisited("Slave Interact") === 1) { + V.storedLink = "Slave Interact"; + } else { + V.storedLink = "Options"; + } + } + V.nextLink = V.storedLink; + + return App.UI.descriptionOptions(); + }, + ["jump-to-safe", "jump-from-safe"] +); + +new App.DomPassage("Summary Options", + () => { + V.nextButton = "Back"; + if (V.storedLink !== "Slave Interact" && V.storedLink !== "Main") { + if (lastVisited("Main") === 1) { + V.storedLink = "Main"; + } else { + V.storedLink = "Options"; + } + } + V.nextLink = V.storedLink; + V.passageSwitchHandler = App.EventHandlers.optionsChanged; + + return App.UI.summaryOptions(); + }, + ["jump-to-safe", "jump-from-safe"] +); + +new App.DomPassage("Hotkey Settings", + () => { + V.nextButton = "Back"; + V.nextLink = "Main"; + + return App.UI.Hotkeys.settings(); + }, ["jump-to-safe", "jump-from-safe"] +); diff --git a/src/gui/options/descriptionOptions.tw b/src/gui/options/descriptionOptions.tw deleted file mode 100644 index 5ac19a8fb4a8d1706591ea51f229b194ec813c73..0000000000000000000000000000000000000000 --- a/src/gui/options/descriptionOptions.tw +++ /dev/null @@ -1,13 +0,0 @@ -:: Description Options [nobr jump-to-safe jump-from-safe] - -<<set $nextButton = "Back">> -<<if $storedLink !== "Slave Interact">> - <<if lastVisited("Slave Interact") === 1>> - <<set $storedLink = "Slave Interact">> - <<else>> - <<set $storedLink = "Options">> - <</if>> -<</if>> -<<set $nextLink = $storedLink>> - -<<includeDOM App.UI.descriptionOptions()>> diff --git a/src/gui/options/hotkeySettings.tw b/src/gui/options/hotkeySettings.tw deleted file mode 100644 index b1bf6388eacc1f4df01bd3ee5d965dceab84e39e..0000000000000000000000000000000000000000 --- a/src/gui/options/hotkeySettings.tw +++ /dev/null @@ -1,27 +0,0 @@ -:: Hotkey Settings [nobr jump-to-safe jump-from-safe] - -<<set $nextButton = "Back", $nextLink = "Main">> - -<h1>Hotkey Settings</h1> - -<p> - <ul> - <li> - On keyboard layouts other than the <a href="https://en.wikipedia.org/wiki/File:KB_United_States.svg" - target="_blank">US-QWERTY layout</a> there may be keys or combinations of keys where the recorded key is - different from the key used to listen to key events. You will have to find these keys yourself through trial - and error. - </li> - <li> - Custom hotkeys are browser specific and are not part of your save. - </li> - <li> - While we try not to overwrite browser or OS level key combinations it is possible to do so with custom - hotkeys. This also means that during recording of custom hotkeys no browser or OS level key combinations are - available. There are however keys that cannot be overwritten, the <code>Win key</code> on Windows is an - example for this. - </li> - </ul> -</p> - -<<includeDOM App.UI.Hotkeys.settings()>> diff --git a/src/gui/options/options.tw b/src/gui/options/options.tw deleted file mode 100644 index ca66ab0ffb92b01a2d5066879ccc78c592c88172..0000000000000000000000000000000000000000 --- a/src/gui/options/options.tw +++ /dev/null @@ -1,11 +0,0 @@ -:: Options [nobr jump-to-safe jump-from-safe] - -<<if lastVisited("Slave Interact") === 1>> - <<set $storedLink = "Slave Interact">> -<<else>> - <<set $storedLink = "Main">> -<</if>> - -<<set $nextButton = "Back", $nextLink = $storedLink, $encyclopedia = "How to Play">> - -<<includeDOM App.UI.optionsPassage()>> \ No newline at end of file diff --git a/src/gui/options/summaryOptions.tw b/src/gui/options/summaryOptions.tw deleted file mode 100644 index a5fcb72e82afd398b58281ee7dc2ec44b94d0462..0000000000000000000000000000000000000000 --- a/src/gui/options/summaryOptions.tw +++ /dev/null @@ -1,14 +0,0 @@ -:: Summary Options [nobr jump-to-safe jump-from-safe] - -<<set $nextButton = "Back">> -<<if $storedLink !== "Slave Interact" && $storedLink !== "Main">> - <<if lastVisited("Main") === 1>> - <<set $storedLink = "Main">> - <<else>> - <<set $storedLink = "Options">> - <</if>> -<</if>> -<<set $nextLink = $storedLink>> -<<set $passageSwitchHandler = App.EventHandlers.optionsChanged>> - -<<includeDOM App.UI.summaryOptions()>> \ No newline at end of file diff --git a/src/interaction/siDescription.js b/src/interaction/siDescription.js index daeceffb745707c99d9a8ba818a6e2c1175b9f6d..86fddfb5659cd962e0907b9fb29e99188beb0898 100644 --- a/src/interaction/siDescription.js +++ b/src/interaction/siDescription.js @@ -34,7 +34,7 @@ App.UI.SlaveInteract.description = function(slave) { "Description Options", () => { jQuery("#description-link").empty().append(hideOptions()); - jQuery("#description-options").empty().append(App.UI.DOM.renderPassage("Description Options")); + jQuery("#description-options").empty().append(App.UI.descriptionOptions()); } ); }