diff --git a/src/game/input.js b/src/game/input.js index 7eb23da..a786505 100644 --- a/src/game/input.js +++ b/src/game/input.js @@ -99,7 +99,6 @@ class KeyHandler { x *= multiplier; y *= multiplier; var direction; - console.log(x, y); if(x >= 0.5) { direction = "right"; } else if(x <= -0.5) { diff --git a/src/pages/dialog.svelte b/src/pages/dialog.svelte index cde089c..ae44bb0 100644 --- a/src/pages/dialog.svelte +++ b/src/pages/dialog.svelte @@ -29,10 +29,16 @@ var activeButton = -1; function select(i) { - console.log("Switching", i); if(!allowSwitch) return; var next; - if(d.buttons) { + if(d.flags && d.flags.includes("chapters")) { + const keys = Object.keys(chapters); + console.log(keys); + if(!keys[i]) return; + const key = keys[i]; + if(!chaptersDone.includes(key)) return; + next = dialog.findIndex(t => t.chapterStart === key); + } else if(d.buttons) { if(!d.buttons[i]) return; next = dialog.findIndex(t => t.name === d.buttons[i].next); } else { @@ -80,6 +86,7 @@ } } + /** @type {string[]}*/ var chaptersDone = JSON.parse(localStorage.getItem("chapters") || "[]"); function keydown(e) { @@ -92,11 +99,16 @@ case "ArrowRight": case "ArrowDown": activeButton++; - if(d.buttons && activeButton > d.buttons.length - 1) activeButton = d.buttons.length - 1; + if(d.flags && d.flags.includes("chapters")) { + if(activeButton > Object.keys(chapters).length - 1) activeButton = Object.keys(chapters).length - 1; + } else if(d.buttons && activeButton > d.buttons.length - 1) { + activeButton = d.buttons.length - 1; + } break; case "Enter": case " ": select(activeButton); + reset(); break; } } @@ -175,8 +187,8 @@ {/if} {#if d && d.flags && d.flags.includes("chapters") && chaptersDone.length}