Skip to content

Commit ee23451

Browse files
committed
questlog: added missing options
1 parent 01c95f0 commit ee23451

File tree

2 files changed

+138
-1
lines changed

2 files changed

+138
-1
lines changed

public/script/questlog.tsx

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "./questlog/types";
1515
import { createField } from "./questlog/field";
1616
import { removeNode } from "./util";
17+
import { SOUNDS } from "./questlog/data";
1718

1819
const jszip = import("jszip");
1920
const hljs: Promise<{
@@ -565,6 +566,119 @@ document.addEventListener("DOMContentLoaded", () => {
565566
}
566567
}
567568
)}
569+
{createField(
570+
{
571+
key: "sound_completed",
572+
type: "input",
573+
description: <>The sound to play when the quest is completed.</>,
574+
name: "Completion Sound",
575+
optional: true,
576+
autocomplete: SOUNDS,
577+
},
578+
() => questObject.display.sound?.completed,
579+
(_, value) => {
580+
if (value) {
581+
questObject.display.sound ??= {};
582+
questObject.display.sound.completed = value as string;
583+
} else {
584+
delete questObject.display.sound?.completed;
585+
if (Object.keys(questObject.display.sound ?? {}).length === 0) {
586+
delete questObject.display.sound;
587+
}
588+
}
589+
}
590+
)}
591+
{createField(
592+
{
593+
key: "sound_triggered",
594+
type: "input",
595+
description: <>The sound to play when the quest is triggered.</>,
596+
name: "Trigger Sound",
597+
optional: true,
598+
autocomplete: SOUNDS,
599+
},
600+
() => questObject.display.sound?.triggered,
601+
(_, value) => {
602+
if (value) {
603+
questObject.display.sound ??= {};
604+
questObject.display.sound.triggered = value as string;
605+
} else {
606+
delete questObject.display.sound?.triggered;
607+
if (Object.keys(questObject.display.sound ?? {}).length === 0) {
608+
delete questObject.display.sound;
609+
}
610+
}
611+
}
612+
)}
613+
{createField(
614+
{
615+
key: "popup",
616+
type: "boolean",
617+
description: (
618+
<>
619+
Determines whether to show a popup on trigger instead of a toast.
620+
<br />
621+
Read more in the wiki.
622+
</>
623+
),
624+
name: "Should popup?",
625+
optional: true,
626+
},
627+
() => questObject.display.notification?.popup || false,
628+
(_, value) => {
629+
if (value) {
630+
questObject.display.notification ??= {};
631+
questObject.display.notification.popup = true;
632+
} else {
633+
delete questObject.display.notification?.popup;
634+
if (Object.keys(questObject.display.notification ?? {}).length === 0) {
635+
delete questObject.display.notification;
636+
}
637+
}
638+
}
639+
)}
640+
{createField(
641+
{
642+
key: "toastOnTrigger",
643+
type: "boolean",
644+
description: <>Enables "Quest Added!" toast</>,
645+
name: "Trigger Toast",
646+
optional: true,
647+
},
648+
() => questObject.display.notification?.toastOnTrigger || true,
649+
(_, value) => {
650+
if (!value) {
651+
questObject.display.notification ??= {};
652+
questObject.display.notification.toastOnTrigger = false;
653+
} else {
654+
delete questObject.display.notification?.toastOnTrigger;
655+
if (Object.keys(questObject.display.notification ?? {}).length === 0) {
656+
delete questObject.display.notification;
657+
}
658+
}
659+
}
660+
)}
661+
{createField(
662+
{
663+
key: "toastOnComplete",
664+
type: "boolean",
665+
description: <>Enables "Quest Completed!" toast</>,
666+
name: "Completion Toast",
667+
optional: true,
668+
},
669+
() => questObject.display.notification?.toastOnComplete || true,
670+
(_, value) => {
671+
if (!value) {
672+
questObject.display.notification ??= {};
673+
questObject.display.notification.toastOnComplete = false;
674+
} else {
675+
delete questObject.display.notification?.toastOnComplete;
676+
if (Object.keys(questObject.display.notification ?? {}).length === 0) {
677+
delete questObject.display.notification;
678+
}
679+
}
680+
}
681+
)}
568682
</form>
569683
</div>
570684
</div>
@@ -1146,6 +1260,29 @@ document.addEventListener("DOMContentLoaded", () => {
11461260
updateCodePreview();
11471261
}
11481262
)}
1263+
{createField(
1264+
{
1265+
key: "sound",
1266+
type: "input",
1267+
description: (
1268+
<>
1269+
The sound to play when the reward is collected.
1270+
<br />
1271+
This is optional, and additional sounds on other rewards will play simultaneously.
1272+
</>
1273+
),
1274+
name: "Sound",
1275+
optional: true,
1276+
autocomplete: SOUNDS,
1277+
},
1278+
() => selectedReward.display?.sound?.claimed,
1279+
(_, value) => {
1280+
selectedReward.display ??= {} as RewardDisplay;
1281+
selectedReward.display.sound ??= {};
1282+
selectedReward.display.sound.claimed = value as string;
1283+
updateCodePreview();
1284+
}
1285+
)}
11491286
{createField(
11501287
{
11511288
key: "type",

public/script/questlog/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ fetchAndAppend("./assets/data/dimensions.json", DIMENSIONS);
3131
fetchAndAppend("./assets/data/effects.json", EFFECTS);
3232
fetchAndAppend("./assets/data/enchantments.json", ENCHANTMENTS);
3333
fetchAndAppend("./assets/data/loot_tables.json", LOOT_TABLES);
34-
// fetchAndAppend("./assets/data/sounds.json", SOUNDS);
34+
fetchAndAppend("./assets/data/sounds.json", SOUNDS);
3535
fetchAndAppend("./assets/data/stats.json", STATS);

0 commit comments

Comments
 (0)