mirror of
https://github.com/danbulant/heaventaker
synced 2026-06-21 15:51:57 +00:00
proper chapter loading
This commit is contained in:
parent
ff37f5b6f9
commit
aaaa87899b
3 changed files with 33 additions and 7 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
<div class="chapters">
|
||||
{#each Object.keys(chapters) as chapter}
|
||||
<div class="chapter" class:active={chaptersDone && chaptersDone.includes(chapter)}>
|
||||
{#each Object.keys(chapters) as chapter, i}
|
||||
<div class="chapter" class:selected={i === activeButton} on:click={() => select(i)} class:active={chaptersDone && chaptersDone.includes(chapter)}>
|
||||
{toRoman(chapters[chapter])}
|
||||
</div>
|
||||
{/each}
|
||||
|
|
@ -203,6 +215,9 @@
|
|||
margin: 3px;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.chapter.selected, .chapter:hover {
|
||||
box-shadow: 0 0 2px 1px rgba(255, 255, 255, 0.705);
|
||||
}
|
||||
.chapter.active {
|
||||
cursor: pointer;
|
||||
border-color: red;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export const chapters = {
|
|||
* pose?: string,
|
||||
* map?: string,
|
||||
* chapter?: keyof typeof chapters,
|
||||
* chapterStart?: keyof typeof chapters,
|
||||
* buttons: { text: string, next: string }[],
|
||||
* flags?: string[]
|
||||
* }[]}
|
||||
|
|
@ -41,6 +42,12 @@ export const dialog = [{
|
|||
character: "Hadraniel",
|
||||
text: "Wait where are you going? That's not the way to the main gate-",
|
||||
next: "uriel_entrance"
|
||||
}, {
|
||||
name: "restart",
|
||||
background: "/sprite/menu.webp",
|
||||
character: "Hadraniel",
|
||||
text: "Welcome back. What do you desire now?",
|
||||
next: "menu"
|
||||
}, {
|
||||
name: "menu",
|
||||
background: "/sprite/menu.webp",
|
||||
|
|
@ -64,6 +71,7 @@ export const dialog = [{
|
|||
flags: ["chapters", "nosave"]
|
||||
}, {
|
||||
name: "uriel_entrance",
|
||||
chapterStart: "uriel",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Uriel",
|
||||
pose: "side_normal",
|
||||
|
|
@ -101,6 +109,7 @@ export const dialog = [{
|
|||
next: "michael_heretic"
|
||||
}, {
|
||||
name: "michael_heretic",
|
||||
chapterStart: "michael",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Michael",
|
||||
text: "How did you... You know what I don't even care. Heretic like you needs to be punished.",
|
||||
|
|
@ -133,6 +142,7 @@ export const dialog = [{
|
|||
name: "uziel_start",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Uziel",
|
||||
chapterStart: "uziel",
|
||||
text: "(she appear out of nowhere and suddenly approaches you.)",
|
||||
buttons: [{
|
||||
text: "oh, you're approaching me? Had you heard of my harem proposal.",
|
||||
|
|
@ -162,6 +172,7 @@ export const dialog = [{
|
|||
name: "gabriel_start",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Gabriel",
|
||||
chapterStart: "gabriel",
|
||||
text: "Hello sir. My name is Gabriel, Heaven's administration department. How may I help you?",
|
||||
buttons: [{
|
||||
text: "You look tired, how about let me help you instead.",
|
||||
|
|
@ -202,6 +213,7 @@ export const dialog = [{
|
|||
name: "azrael_start",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Azrael",
|
||||
chapterStart: "azrael",
|
||||
text: "Oh my my, what do we have here a lost soul wandering around heaven with an intent lust for angel.",
|
||||
buttons: [{
|
||||
text: "You're god damn right.",
|
||||
|
|
@ -221,7 +233,7 @@ export const dialog = [{
|
|||
}, {
|
||||
name: "azrael_win",
|
||||
chapter: "azrael",
|
||||
next: "menu",
|
||||
next: "restart",
|
||||
background: "/sprite/backg.webp",
|
||||
character: "Azrael",
|
||||
pose: "happy",
|
||||
|
|
|
|||
Loading…
Reference in a new issue