fix: yes/no box popping up after the question text closes, not over it

several places (Commands.ask, the give-a-nickname prompt, PC box release/
change confirms, start menu save/quit) pushed a bare ChoiceBox after the
preceding text box already popped on an A press, instead of riding
TextBox's opts.choice like the rest of the engine. the YES/NO box now
comes up while the question is still on screen, matching the original.
This commit is contained in:
spiritsnails
2026-08-01 21:36:30 -06:00
parent f205464aa4
commit 2b92562538
5 changed files with 126 additions and 35 deletions
+10 -10
View File
@@ -164,18 +164,18 @@ local function release(game)
local mon = box[list.index]
if not mon then return end
local name = monName(game, mon)
local ChoiceBox = require("src.ui.ChoiceBox")
game.stack:push(TextBox.new(game,
Strings("Once released,\n%s is\ngone forever. OK?", name), function()
game.stack:push(ChoiceBox.new(game, function(yes)
Strings("Once released,\n%s is\ngone forever. OK?", name), nil, {
defaultNo = true, noSound = true,
choice = function(yes)
if not yes then return end
table.remove(box, list.index)
require("src.core.Sound").playCry(game.data, mon.species)
game.stack:push(TextBox.new(game,
Strings("%s was\nreleased outside.\fBye %s!", name, name)))
list:removeCurrent()
end, { defaultNo = true, noSound = true }))
end))
end,
}))
end,
}))
end
@@ -196,16 +196,16 @@ local function changeBox(game)
onChoose = function(item, list)
-- the original asks BEFORE switching ("When you change a #MON
-- BOX, data will be saved. OK?"); declining aborts the change
local ChoiceBox = require("src.ui.ChoiceBox")
game.stack:push(TextBox.new(game,
Strings("When you change a\nPOKéMON BOX, data\nwill be saved. OK?"), function()
game.stack:push(ChoiceBox.new(game, function(yes)
Strings("When you change a\nPOKéMON BOX, data\nwill be saved. OK?"), nil, {
noSound = true,
choice = function(yes)
if not yes then return end
game.save.currentBox = item.value
if game.writeSave then game:writeSave() end
list:close()
end, { noSound = true }))
end))
end,
}))
end,
}))
end
+9 -10
View File
@@ -53,7 +53,6 @@ function StartMenu.new(game)
-- (PrintSaveScreenText)
table.insert(items, { label = Strings("SAVE"), onSelect = function()
local TextBox = require("src.render.TextBox")
local ChoiceBox = require("src.ui.ChoiceBox")
local badges = require("src.inventory.Badges").count(game.data, game.save)
local owned = 0
for _ in pairs(game.save.pokedex and game.save.pokedex.owned or {}) do
@@ -64,8 +63,8 @@ function StartMenu.new(game)
game.save.player.name or "RED", badges, owned,
math.floor(t / 3600), math.floor(t / 60) % 60)
game.stack:push(TextBox.new(game,
panel .. Strings("\fWould you like to\nSAVE the game?"), function()
game.stack:push(ChoiceBox.new(game, function(yes)
panel .. Strings("\fWould you like to\nSAVE the game?"), nil, {
choice = function(yes)
if not yes then return end
-- "Now saving..." beat before the write (save.asm
-- NowSavingString), then GameSavedText + SFX_SAVE
@@ -75,8 +74,8 @@ function StartMenu.new(game)
game.stack:push(TextBox.new(game,
Strings("%s saved\nthe game!", game.save.player.name or "RED")))
end))
end))
end))
end,
}))
end })
table.insert(items, { label = Strings("OPTION"), onSelect = function()
@@ -105,12 +104,12 @@ function StartMenu.new(game)
-- to the title after a confirm (defaultNo guards accidental quits)
table.insert(items, { label = Strings("QUIT"), onSelect = function()
local TextBox = require("src.render.TextBox")
local ChoiceBox = require("src.ui.ChoiceBox")
game.stack:push(TextBox.new(game, Strings("RETURN TO MAIN\nMENU?"), function()
game.stack:push(ChoiceBox.new(game, function(yes)
game.stack:push(TextBox.new(game, Strings("RETURN TO MAIN\nMENU?"), nil, {
defaultNo = true,
choice = function(yes)
if yes then game:returnToTitle() end
end, { defaultNo = true }))
end))
end,
}))
end })
local hooked = Runtime.call("ui.start_menu.items", sameItems, game, items)