mirror of
https://github.com/danbulant/heaventaker
synced 2026-07-08 12:40:39 +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;
|
x *= multiplier;
|
||||||
y *= multiplier;
|
y *= multiplier;
|
||||||
var direction;
|
var direction;
|
||||||
console.log(x, y);
|
|
||||||
if(x >= 0.5) {
|
if(x >= 0.5) {
|
||||||
direction = "right";
|
direction = "right";
|
||||||
} else if(x <= -0.5) {
|
} else if(x <= -0.5) {
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,16 @@
|
||||||
|
|
||||||
var activeButton = -1;
|
var activeButton = -1;
|
||||||
function select(i) {
|
function select(i) {
|
||||||
console.log("Switching", i);
|
|
||||||
if(!allowSwitch) return;
|
if(!allowSwitch) return;
|
||||||
var next;
|
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;
|
if(!d.buttons[i]) return;
|
||||||
next = dialog.findIndex(t => t.name === d.buttons[i].next);
|
next = dialog.findIndex(t => t.name === d.buttons[i].next);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -80,6 +86,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @type {string[]}*/
|
||||||
var chaptersDone = JSON.parse(localStorage.getItem("chapters") || "[]");
|
var chaptersDone = JSON.parse(localStorage.getItem("chapters") || "[]");
|
||||||
|
|
||||||
function keydown(e) {
|
function keydown(e) {
|
||||||
|
|
@ -92,11 +99,16 @@
|
||||||
case "ArrowRight":
|
case "ArrowRight":
|
||||||
case "ArrowDown":
|
case "ArrowDown":
|
||||||
activeButton++;
|
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;
|
break;
|
||||||
case "Enter":
|
case "Enter":
|
||||||
case " ":
|
case " ":
|
||||||
select(activeButton);
|
select(activeButton);
|
||||||
|
reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,8 +187,8 @@
|
||||||
{/if}
|
{/if}
|
||||||
{#if d && d.flags && d.flags.includes("chapters") && chaptersDone.length}
|
{#if d && d.flags && d.flags.includes("chapters") && chaptersDone.length}
|
||||||
<div class="chapters">
|
<div class="chapters">
|
||||||
{#each Object.keys(chapters) as chapter}
|
{#each Object.keys(chapters) as chapter, i}
|
||||||
<div class="chapter" class:active={chaptersDone && chaptersDone.includes(chapter)}>
|
<div class="chapter" class:selected={i === activeButton} on:click={() => select(i)} class:active={chaptersDone && chaptersDone.includes(chapter)}>
|
||||||
{toRoman(chapters[chapter])}
|
{toRoman(chapters[chapter])}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
@ -203,6 +215,9 @@
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
.chapter.selected, .chapter:hover {
|
||||||
|
box-shadow: 0 0 2px 1px rgba(255, 255, 255, 0.705);
|
||||||
|
}
|
||||||
.chapter.active {
|
.chapter.active {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-color: red;
|
border-color: red;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export const chapters = {
|
||||||
* pose?: string,
|
* pose?: string,
|
||||||
* map?: string,
|
* map?: string,
|
||||||
* chapter?: keyof typeof chapters,
|
* chapter?: keyof typeof chapters,
|
||||||
|
* chapterStart?: keyof typeof chapters,
|
||||||
* buttons: { text: string, next: string }[],
|
* buttons: { text: string, next: string }[],
|
||||||
* flags?: string[]
|
* flags?: string[]
|
||||||
* }[]}
|
* }[]}
|
||||||
|
|
@ -41,6 +42,12 @@ export const dialog = [{
|
||||||
character: "Hadraniel",
|
character: "Hadraniel",
|
||||||
text: "Wait where are you going? That's not the way to the main gate-",
|
text: "Wait where are you going? That's not the way to the main gate-",
|
||||||
next: "uriel_entrance"
|
next: "uriel_entrance"
|
||||||
|
}, {
|
||||||
|
name: "restart",
|
||||||
|
background: "/sprite/menu.webp",
|
||||||
|
character: "Hadraniel",
|
||||||
|
text: "Welcome back. What do you desire now?",
|
||||||
|
next: "menu"
|
||||||
}, {
|
}, {
|
||||||
name: "menu",
|
name: "menu",
|
||||||
background: "/sprite/menu.webp",
|
background: "/sprite/menu.webp",
|
||||||
|
|
@ -64,6 +71,7 @@ export const dialog = [{
|
||||||
flags: ["chapters", "nosave"]
|
flags: ["chapters", "nosave"]
|
||||||
}, {
|
}, {
|
||||||
name: "uriel_entrance",
|
name: "uriel_entrance",
|
||||||
|
chapterStart: "uriel",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Uriel",
|
character: "Uriel",
|
||||||
pose: "side_normal",
|
pose: "side_normal",
|
||||||
|
|
@ -101,6 +109,7 @@ export const dialog = [{
|
||||||
next: "michael_heretic"
|
next: "michael_heretic"
|
||||||
}, {
|
}, {
|
||||||
name: "michael_heretic",
|
name: "michael_heretic",
|
||||||
|
chapterStart: "michael",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Michael",
|
character: "Michael",
|
||||||
text: "How did you... You know what I don't even care. Heretic like you needs to be punished.",
|
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",
|
name: "uziel_start",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Uziel",
|
character: "Uziel",
|
||||||
|
chapterStart: "uziel",
|
||||||
text: "(she appear out of nowhere and suddenly approaches you.)",
|
text: "(she appear out of nowhere and suddenly approaches you.)",
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: "oh, you're approaching me? Had you heard of my harem proposal.",
|
text: "oh, you're approaching me? Had you heard of my harem proposal.",
|
||||||
|
|
@ -162,6 +172,7 @@ export const dialog = [{
|
||||||
name: "gabriel_start",
|
name: "gabriel_start",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Gabriel",
|
character: "Gabriel",
|
||||||
|
chapterStart: "gabriel",
|
||||||
text: "Hello sir. My name is Gabriel, Heaven's administration department. How may I help you?",
|
text: "Hello sir. My name is Gabriel, Heaven's administration department. How may I help you?",
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: "You look tired, how about let me help you instead.",
|
text: "You look tired, how about let me help you instead.",
|
||||||
|
|
@ -202,6 +213,7 @@ export const dialog = [{
|
||||||
name: "azrael_start",
|
name: "azrael_start",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Azrael",
|
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.",
|
text: "Oh my my, what do we have here a lost soul wandering around heaven with an intent lust for angel.",
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: "You're god damn right.",
|
text: "You're god damn right.",
|
||||||
|
|
@ -221,7 +233,7 @@ export const dialog = [{
|
||||||
}, {
|
}, {
|
||||||
name: "azrael_win",
|
name: "azrael_win",
|
||||||
chapter: "azrael",
|
chapter: "azrael",
|
||||||
next: "menu",
|
next: "restart",
|
||||||
background: "/sprite/backg.webp",
|
background: "/sprite/backg.webp",
|
||||||
character: "Azrael",
|
character: "Azrael",
|
||||||
pose: "happy",
|
pose: "happy",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue