mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-20 20:50:21 +02:00
Keep WIDE battle visible beneath opaque menus
This commit is contained in:
+13
-9
@@ -423,13 +423,13 @@ function Game.uiAnchorsHeldInStack(stack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Where Game:draw starts drawing this frame. Normally the topmost opaque
|
-- Where Game:draw starts drawing this frame. Normally the topmost opaque
|
||||||
-- state (StateStack:visibleBase) -- but BATTLE BG "world" composes the battle
|
-- state (StateStack:visibleBase) -- but an opaque menu pushed over a WIDE
|
||||||
-- over the LIVE map, and an opaque state pushed on top of it (the party menu,
|
-- battle must not prevent that battle from drawing. Native WIDE battles own
|
||||||
-- the bag) becomes that base, cutting the overworld -- and with it the world
|
-- the 304x144 surround around a centred classic menu, while external arena
|
||||||
-- pass -- out of the frame entirely. The backdrop the battle established
|
-- providers establish their window-sized scene from BattleState:draw. If the
|
||||||
-- then collapses to endFrame's flat black clear for as long as the menu is
|
-- menu becomes the draw base, neither owner runs and the menu's white field
|
||||||
-- up. So a world-bg battle keeps the frame starting from underneath itself
|
-- replaces the whole presentation. BATTLE BG "world" additionally needs the
|
||||||
-- until it leaves the stack, the same hold uiFill and the dim already use.
|
-- overworld below the battle, as before.
|
||||||
--
|
--
|
||||||
-- Only the START of the draw moves. The clear stays keyed to the real
|
-- Only the START of the draw moves. The clear stays keyed to the real
|
||||||
-- visibleBase, so the menu still gets its opaque canvas and draws exactly as
|
-- visibleBase, so the menu still gets its opaque canvas and draws exactly as
|
||||||
@@ -440,9 +440,13 @@ function Game.drawBaseInStack(stack, visibleBase)
|
|||||||
local states = stack and stack.states or {}
|
local states = stack and stack.states or {}
|
||||||
for i = visibleBase - 1, 1, -1 do
|
for i = visibleBase - 1, 1, -1 do
|
||||||
local state = states[i]
|
local state = states[i]
|
||||||
if state and state.bgMode and state:bgMode() == "world" then
|
local worldBattle = state and state.bgMode and state:bgMode() == "world"
|
||||||
|
local wideBattle = state and state.isWideBattleLayout
|
||||||
|
and state:isWideBattleLayout()
|
||||||
|
if worldBattle or wideBattle then
|
||||||
-- restart the search from under the battle: the highest opaque state at
|
-- restart the search from under the battle: the highest opaque state at
|
||||||
-- or below it (the overworld), not the menu sitting over it
|
-- or below it (the battle itself for white/black WIDE, the overworld for
|
||||||
|
-- a non-opaque world-backed battle), not the menu sitting over it
|
||||||
for j = i, 1, -1 do
|
for j = i, 1, -1 do
|
||||||
if states[j].isOpaque then return j end
|
if states[j].isOpaque then return j end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
-- Visual regression coverage for Professor Oak's scripted Yellow capture Bag
|
||||||
|
-- over the WIDE + FIXED + EXTENDED + WORLD composition.
|
||||||
|
return function(game)
|
||||||
|
local U = dofile("tests/drivers/util.lua")
|
||||||
|
local DIR = os.getenv("SHOT_DIR") or "/tmp/shots"
|
||||||
|
local BattleState = require("src.battle.BattleState")
|
||||||
|
local Pokemon = require("src.pokemon.Pokemon")
|
||||||
|
|
||||||
|
love.window.setMode(2048, 1152, { resizable = true })
|
||||||
|
U.wait(3)
|
||||||
|
|
||||||
|
local options = game.save.options
|
||||||
|
options.battleLayout = "wide"
|
||||||
|
options.battleFit = "fixed"
|
||||||
|
options.battleHud = "extended"
|
||||||
|
options.battleBg = "world"
|
||||||
|
|
||||||
|
game.save.party = { Pokemon.new(game.data, "PIKACHU", 20) }
|
||||||
|
U.teleport(game, "ROUTE_1", 5, 5, "down")
|
||||||
|
U.wait(30)
|
||||||
|
|
||||||
|
local demo = BattleState.newWild(game, "CHARMANDER", 5)
|
||||||
|
demo:makeOldManDemo("PROF.OAK")
|
||||||
|
demo.onFinish = function() end
|
||||||
|
game.overworld:pushBattle(demo)
|
||||||
|
|
||||||
|
for _ = 1, 100 do
|
||||||
|
if demo.phase == "menu" and (demo.demoTimer or 0) > 5 then break end
|
||||||
|
U.tap(game, "a")
|
||||||
|
U.wait(4)
|
||||||
|
end
|
||||||
|
for _ = 1, 180 do
|
||||||
|
if game.stack:top() ~= demo then break end
|
||||||
|
U.wait(1)
|
||||||
|
end
|
||||||
|
U.wait(3)
|
||||||
|
|
||||||
|
local path = DIR .. "/fixed_extended_world_oak_charmander_bag.png"
|
||||||
|
os.remove(path)
|
||||||
|
local ok = game.stack:top() ~= demo and U.shot(game, path)
|
||||||
|
U.log(ok and "FIXED_EXTENDED_WORLD_BAG_PASS"
|
||||||
|
or "FIXED_EXTENDED_WORLD_BAG_FAIL")
|
||||||
|
love.event.quit(ok and 0 or 1)
|
||||||
|
end
|
||||||
@@ -92,6 +92,11 @@ local menu = { isOpaque = true } -- PartyMenu / ListMenu
|
|||||||
local whiteBattle = setmetatable(
|
local whiteBattle = setmetatable(
|
||||||
{ game = { save = { options = { battleBg = "white" } } } },
|
{ game = { save = { options = { battleBg = "white" } } } },
|
||||||
{ __index = BattleState })
|
{ __index = BattleState })
|
||||||
|
local wideWhiteBattle = setmetatable(
|
||||||
|
{ game = { save = { options = {
|
||||||
|
battleBg = "white", battleLayout = "wide",
|
||||||
|
} } } },
|
||||||
|
{ __index = BattleState })
|
||||||
local function stack(...) return { states = { ... },
|
local function stack(...) return { states = { ... },
|
||||||
visibleBase = function(self)
|
visibleBase = function(self)
|
||||||
for i = #self.states, 1, -1 do
|
for i = #self.states, 1, -1 do
|
||||||
@@ -111,7 +116,10 @@ T.eq(s2:visibleBase(), 1, "the battle alone already drew from the overworld")
|
|||||||
T.eq(Game.drawBaseInStack(s2, s2:visibleBase()), 1, "and still does")
|
T.eq(Game.drawBaseInStack(s2, s2:visibleBase()), 1, "and still does")
|
||||||
local s3 = stack(overworld, whiteBattle, menu)
|
local s3 = stack(overworld, whiteBattle, menu)
|
||||||
T.eq(Game.drawBaseInStack(s3, s3:visibleBase()), 3,
|
T.eq(Game.drawBaseInStack(s3, s3:visibleBase()), 3,
|
||||||
"a white-bg battle has no map to hold, so nothing moves")
|
"a classic white-bg battle has no presentation to hold, so nothing moves")
|
||||||
|
local s3wide = stack(overworld, wideWhiteBattle, menu)
|
||||||
|
T.eq(Game.drawBaseInStack(s3wide, s3wide:visibleBase()), 2,
|
||||||
|
"an opaque WIDE battle still draws beneath its classic menu")
|
||||||
local s4 = stack(overworld, menu)
|
local s4 = stack(overworld, menu)
|
||||||
T.eq(Game.drawBaseInStack(s4, s4:visibleBase()), 2,
|
T.eq(Game.drawBaseInStack(s4, s4:visibleBase()), 2,
|
||||||
"and a menu outside a battle is untouched")
|
"and a menu outside a battle is untouched")
|
||||||
|
|||||||
Reference in New Issue
Block a user