Return to the start menu when a pause submenu is cancelled (#270) (#300)

Selecting a start-menu row pops the start menu before the submenu is
pushed (Menu's generic A handler), so B in a submenu had no parent to
return to and dropped straight to the overworld.  pokered redisplays
the start menu instead (RedisplayStartMenu from the party/item/
trainer-card/option handlers), so give each vanilla submenu an
onCancel that re-opens the start menu; the saved cursor row
(wBattleAndStartSavedMenuItem) restores on re-entry.

- PokedexMenu/BagMenu forward opts.onCancel into their ListMenu
- TrainerCard dismisses back via onCancel on A or B
  (WaitForTextScrollButtonPress then RedisplayStartMenu)
- OptionsMenu fires onCancel from both B/START and the CANCEL row
- PlayerPC rows are keepOpen so B in WITHDRAW/DEPOSIT/TOSS returns to
  the PC root menu (players_pc.asm), matching the BoxMenu pattern

The SAVE flow is untouched: StartMenu_SaveReset falls through to
HoldTextDisplayOpen and never redisplays the menu.  Battle-opened
party/bag screens get no onCancel, so mid-battle cancel behavior is
unchanged.

Co-authored-by: johnjohto <johnjohto@users.noreply.github.com>
This commit is contained in:
johnjohto
2026-07-27 10:05:15 -04:00
committed by GitHub
parent ff90062741
commit 531a719794
7 changed files with 112 additions and 14 deletions
+10 -5
View File
@@ -19,10 +19,15 @@ function StartMenu.new(game)
local flags = game.save.flags or {}
local items = {}
-- vanilla start submenus return here on B (RedisplayStartMenu): the
-- generic Menu pops the start menu when a row is selected, so each
-- submenu gets an onCancel that re-opens it
local function reopen() Screens.push(game, "StartMenu") end
-- POKéDEX: only after Oak hands it over
if flags.EVENT_GOT_POKEDEX then
table.insert(items, { label = "POKéDEX", onSelect = function()
Screens.push(game, "PokedexMenu")
Screens.push(game, "PokedexMenu", { onCancel = reopen })
end })
end
@@ -30,17 +35,17 @@ function StartMenu.new(game)
-- an empty party; selecting it then just no-ops)
table.insert(items, { label = "POKéMON", onSelect = function()
if #game.save.party == 0 then return end
Screens.push(game, "PartyMenu")
Screens.push(game, "PartyMenu", { onCancel = reopen })
end })
table.insert(items, { label = "ITEM", onSelect = function()
Screens.push(game, "BagMenu")
Screens.push(game, "BagMenu", { onCancel = reopen })
end })
-- the player's name opens the trainer card (StartMenu_TrainerInfo)
table.insert(items, { label = game.save.player.name or "RED",
onSelect = function()
Screens.push(game, "TrainerCard")
Screens.push(game, "TrainerCard", { onCancel = reopen })
end })
-- SAVE shows the player/badges/dex/time panel then asks to confirm
@@ -74,7 +79,7 @@ function StartMenu.new(game)
end })
table.insert(items, { label = "OPTION", onSelect = function()
Screens.push(game, "OptionsMenu")
Screens.push(game, "OptionsMenu", { onCancel = reopen })
end })
-- LINK needs a party