Port the options screen
Checks / web (push) Canceled after 0s

OPTION in the start menu runs _Option with the ROM's labels and settings,
OptionsControl's cursor wrapping and each option's bit handling. The four
option bytes live in the script state and saves, defaulting to
DefaultOptions. The battle style now decides whether a trainer's next
Pokémon brings an offer to switch, and the menu account whether the start
menu describes its items; the other settings are kept for later.

Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-10-02 10:47:11 +02:00
1 parent 47698565ab
commit c4cc0e756c
19 files changed
+732 -21

No files matched your search

+37 -2
View File
@@ -54,6 +54,7 @@ function showWorld(world: GameWorld) {
showStatsScreen(world);
showPokegear(world);
showTrainerCard(world);
showOptions(world);
get("town-map-view").hidden = !world.townMap;
if (world.townMap)
drawTownMap(get<HTMLCanvasElement>("town-map-canvas"), world);
@@ -70,6 +71,7 @@ function showWorld(world: GameWorld) {
// The Pokégear's map and radio cards have no textbox.
(dialogue.choice?.kind === "pokegear" && !dialogue.pages[dialogue.index]) ||
dialogue.choice?.kind === "trainercard" ||
dialogue.choice?.kind === "options" ||
Boolean(mart) ||
world.townMap ||
Boolean(world.statsScreen);
@@ -123,8 +125,13 @@ function showChoice(choice: Choice | undefined) {
return element;
};
if (!choice) container.replaceChildren();
else if (choice.kind === "pokegear" || choice.kind === "trainercard") {
// The Pokégear and the trainer card read the controls directly.
else if (
choice.kind === "pokegear" ||
choice.kind === "trainercard" ||
choice.kind === "options"
) {
// The Pokégear, the trainer card and the options read the controls
// directly.
container.replaceChildren();
container.hidden = true;
} else if (choice.kind === "yesno")
@@ -952,6 +959,34 @@ function showPokegear(world: GameWorld) {
} else body.replaceChildren();
}
let optionsKey = "";
/** _Option's screen: each option with its setting, and the ▶ cursor. */
function showOptions(world: GameWorld) {
const choice = world.dialogue?.choice;
const view = choice?.kind === "options" ? choice.view : undefined;
get("options").hidden = !view;
if (!view) {
optionsKey = "";
return;
}
const key = JSON.stringify(view);
if (key === optionsKey) return;
optionsKey = key;
get("options-list").replaceChildren(
...view.rows.map((row, index) => {
const item = document.createElement("li"),
label = document.createElement("span"),
value = document.createElement("strong");
label.textContent = row.label;
value.textContent = row.value;
item.append(label, value);
item.dataset.mark = index === view.cursor ? "▶" : " ";
if (index === view.cursor) item.setAttribute("aria-current", "true");
return item;
}),
);
}
let trainerCardKey = "";
/** TrainerCard (engine/menus/trainer_card.asm): the top half with the
* name, ID, money and card picture, then page 1's Pokédex count and play