fix: keep move details modal

This commit is contained in:
AverageConsumer
2026-08-25 18:54:52 +02:00
parent f88100053c
commit 8cf44fa558
2 changed files with 28 additions and 17 deletions
+11 -14
View File
@@ -6004,34 +6004,31 @@ return function(mod)
end)
mod.hooks:wrap("input.step", function(next, stepGame, dt)
if moveInfo or battleInfoDetail or displayRuntime.guideDetail then
local modalMoveInfo = moveInfo ~= nil
if modalMoveInfo or battleInfoDetail or displayRuntime.guideDetail then
local queue = stepGame and stepGame.input
and stepGame.input.pressQueue
local consumed
for i = #(queue or {}), 1, -1 do
if queue[i] == "b" then
if queue[i] == "b" then consumed = true end
if modalMoveInfo or queue[i] == "b" then
table.remove(queue, i)
consumed = true
end
end
if consumed then back() end
if modalMoveInfo then return next(stepGame, dt) end
end
pollTriggerTabs()
local swapPressed, infoPressed, overlayPressed = pollScreenSwap()
if infoPressed and assist("move_details")
and currentBattleUIMode() ~= "info" then
if moveInfo then
moveInfo = nil
dirty = true
else
moveInfo = displayRuntime.learningMoveInfo()
if not moveInfo and battle and battle.prompt == "moves" then
local raw = battleState()
local index = raw and raw.moveIndex or battle.moveIndex or 1
moveInfo = battle.moves and battle.moves[index]
end
dirty = moveInfo ~= nil or dirty
moveInfo = displayRuntime.learningMoveInfo()
if not moveInfo and battle and battle.prompt == "moves" then
local raw = battleState()
local index = raw and raw.moveIndex or battle.moveIndex or 1
moveInfo = battle.moves and battle.moves[index]
end
dirty = moveInfo ~= nil or dirty
end
if active and (inlineDisplay() or hasDisplay()) and swapPressed then
displayRuntime.swapped = not displayRuntime.swapped
+17 -3
View File
@@ -827,11 +827,21 @@ do
swapPressed = false
run.loader.hooks:call("input.step", function() end, game, 1 / 60)
swapPressed = previousSwapPressed
T.eq(table.concat(game.input.pressQueue, ","), "a",
"B closes move info without leaking into the battle menu")
T.eq(#game.input.pressQueue, 0,
"move info consumes every input queued behind its closing B")
local _, openMoveInfo = debug.getupvalue(inputHook, moveInfoUpvalue)
T.eq(openMoveInfo, nil, "B closes the move-info overlay")
debug.setupvalue(inputHook, moveInfoUpvalue, { name = "TACKLE" })
game.input = { pressQueue = { "a", "down" } }
run.loader.hooks:call("input.step", function() end, game, 1 / 60)
_, openMoveInfo = debug.getupvalue(inputHook, moveInfoUpvalue)
T.eq(#game.input.pressQueue, 0,
"move info consumes selection and navigation inputs")
T.eq(openMoveInfo.name, "TACKLE",
"inputs other than B leave move info open")
debug.setupvalue(inputHook, moveInfoUpvalue, nil)
local battleUpvalue
for i = 1, debug.getinfo(inputHook, "u").nups do
if debug.getupvalue(inputHook, i) == "battle" then
@@ -858,7 +868,11 @@ do
infoPressed = true
run.loader.hooks:call("input.step", function() end, game, 1 / 60)
_, openMoveInfo = debug.getupvalue(inputHook, moveInfoUpvalue)
T.eq(openMoveInfo, nil, "pressing X again closes move details")
T.eq(openMoveInfo.id, "TACKLE", "only B closes move details")
game.input = { pressQueue = { "b" } }
run.loader.hooks:call("input.step", function() end, game, 1 / 60)
_, openMoveInfo = debug.getupvalue(inputHook, moveInfoUpvalue)
T.eq(openMoveInfo, nil, "B closes details opened with X")
infoPressed = false
swapPressed = previousSwapPressed
debug.setupvalue(inputHook, battleUpvalue, previousBattle)