Merge pull request #1378 from syybott/experiment/fixed-extended-world-alignment

This commit is contained in:
bryanthaboi
2026-08-16 22:04:28 -04:00
committed by GitHub
16 changed files with 726 additions and 33 deletions
@@ -0,0 +1,36 @@
local U = require("tests.drivers.util")
local OUT = os.getenv("SHOT_DIR") or "battle-hud-layout-lock"
local BEFORE = OUT .. "/battle_hud_wide_extended.png"
local AFTER = OUT .. "/battle_hud_og_locked_standard.png"
return function(game)
os.remove(BEFORE)
os.remove(AFTER)
local options = game.save.options
options.battleLayout = "wide"
options.battleHud = "extended"
local menu = require("src.ui.Screens").push(game, "OptionsMenu")
local layoutRow, hudRow
for _, row in ipairs(menu.rows) do
if row.id == "battleLayout" then layoutRow = row end
if row.id == "battleHud" then hudRow = row end
end
assert(layoutRow and hudRow, "battle layout/HUD rows are present")
menu.index = 6
menu.scroll = 3
assert(hudRow.value(game) == "EXTENDED", "WIDE displays EXTENDED")
assert(U.shot(game, BEFORE), "WIDE/EXTENDED screenshot was written")
layoutRow.step(game, 1)
assert(options.battleLayout == "og", "layout switched to OG")
assert(options.battleHud == "standard", "OG normalized HUD to STANDARD")
assert(hudRow.value(game) == "STANDARD", "OG displays STANDARD")
assert(U.shot(game, AFTER), "OG/STANDARD screenshot was written")
print("[driver] BATTLE_HUD_LAYOUT_LOCK_PASS")
game.driverDone = true
end
@@ -0,0 +1,53 @@
-- Visual and behavioral acceptance for the adaptive BATTLE BG menu rule.
return function(game)
local U = dofile("tests/drivers/util.lua")
local DIR = os.getenv("SHOT_DIR") or "/tmp/shots"
love.window.setMode(1920, 1080, { resizable = true })
U.wait(3)
local options = game.save.options
options.battleLayout = "wide"
options.battleFit = "fixed"
options.battleHud = "extended"
options.battleBg = "black"
local menu = require("src.ui.Screens").push(game, "OptionsMenu")
local fitRow, bgRow
local bgIndex
for i, row in ipairs(menu.rows) do
if row.id == "battleFit" then fitRow = row end
if row.id == "battleBg" then bgRow, bgIndex = row, i end
end
assert(fitRow and bgRow and bgIndex, "battle size/background rows are present")
fitRow.step(game, 1)
assert(options.battleFit == "fill", "battle size switched to FILL")
assert(options.battleBg == "white", "FILL + EXTENDED normalized background to WHITE")
assert(bgRow.value(game) == "AUTO", "adaptive background is labeled AUTO")
assert(bgRow.step(game, 1) == false, "AUTO background row is locked")
assert(options.battleBg == "white", "locked AUTO retains the WHITE value")
menu.index = bgIndex
menu.scroll = math.max(0, bgIndex - 5)
U.wait(2)
local autoPath = DIR .. "/fill_extended_auto_menu.png"
os.remove(autoPath)
local ok = U.shot(game, autoPath)
fitRow.step(game, -1)
assert(options.battleFit == "fixed", "battle size switched back to FIXED")
assert(bgRow.value(game) == "WHITE", "FIXED exposes the stored WHITE choice")
assert(bgRow.step(game, 1) == true and options.battleBg == "black",
"FIXED can select BLACK")
assert(bgRow.step(game, 1) == true and options.battleBg == "world",
"FIXED can select WORLD")
U.wait(2)
local fixedPath = DIR .. "/fixed_extended_background_choices.png"
os.remove(fixedPath)
ok = U.shot(game, fixedPath) and ok
U.log(ok and "FILL_EXTENDED_AUTO_MENU_PASS"
or "FILL_EXTENDED_AUTO_MENU_FAIL")
love.event.quit(ok and 0 or 1)
end
@@ -0,0 +1,64 @@
-- Visual acceptance driver for WIDE + FILL + EXTENDED + WHITE.
-- The full physical-window backing remains white while the four battle HUD
-- panels move to their approved window anchors.
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 = "fill"
options.battleHud = "extended"
options.battleBg = "white"
game.save.party = { Pokemon.new(game.data, "PIKACHU", 100) }
U.teleport(game, "ROUTE_1", 5, 5, "down")
U.wait(60)
local battle = BattleState.newWild(game, "PIDGEY", 3,
{ onFinish = function() end })
game.overworld:pushBattle(battle)
U.wait(360)
battle.introSlide = 0
battle.introBalls = nil
battle.showEnemyTrainer = false
battle.showPlayerBack = false
battle.enemySendingOut = false
battle.sendingOut = false
battle.phase = "menu"
battle.menuIndex = 1
U.wait(2)
assert(battle:extendedHUD(), "FILL/WHITE activates the approved extended HUD")
assert(not battle:extendedWorldHUD(), "FILL/WHITE does not use FIXED's paper band")
local path = DIR .. "/fill_extended_white_separate_layer.png"
os.remove(path)
local ok = U.shot(game, path)
love.window.setMode(960, 540, { resizable = true })
U.wait(5)
local smallPath = DIR .. "/fill_extended_white_small_16x9.png"
os.remove(smallPath)
ok = U.shot(game, smallPath) and ok
love.window.setMode(2048, 1152, { resizable = true })
U.wait(5)
local NamingScreen = require("src.ui.NamingScreen")
game.stack:push(NamingScreen.new(game, {
title = "NICKNAME?", maxLen = 10, onDone = function() end,
}))
U.wait(5)
local overlayPath = DIR .. "/fill_extended_white_naming_overlay.png"
os.remove(overlayPath)
ok = U.shot(game, overlayPath) and ok
U.log(ok and "FILL_EXTENDED_WHITE_PASS" or "FILL_EXTENDED_WHITE_FAIL")
love.event.quit(ok and 0 or 1)
end
@@ -0,0 +1,64 @@
local U = require("tests.drivers.util")
local OUT = os.getenv("SHOT_DIR") or "fixed-extended-black"
local FULL = OUT .. "/fixed_extended_black_full.png"
local SMALL = OUT .. "/fixed_extended_black_small_16x9.png"
local OVERLAY = OUT .. "/fixed_extended_black_overlay.png"
return function(game)
local BattleState = require("src.battle.BattleState")
local Pokemon = require("src.pokemon.Pokemon")
os.remove(FULL)
os.remove(SMALL)
os.remove(OVERLAY)
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 = "black"
game.save.party = { Pokemon.new(game.data, "PIKACHU", 100) }
U.teleport(game, "ROUTE_1", 5, 5, "down")
U.wait(60)
local battle = BattleState.newWild(game, "PIDGEY", 3,
{ onFinish = function() end })
game.overworld:pushBattle(battle)
U.wait(360)
battle.introSlide = 0
battle.introBalls = nil
battle.showEnemyTrainer = false
battle.showPlayerBack = false
battle.enemySendingOut = false
battle.sendingOut = false
battle.phase = "menu"
battle.menuIndex = 1
U.wait(2)
assert(battle:extendedHUD(), "BLACK activates the approved extended HUD")
assert(battle:extendedBlackHUD(), "BLACK activates the white vertical battle band")
assert(not battle:extendedWorldHUD(), "BLACK remains separate from WORLD")
assert(U.shot(game, FULL), "full black-background screenshot was written")
love.window.setMode(960, 540, { resizable = true })
U.wait(10)
assert(U.shot(game, SMALL), "small black-background screenshot was written")
love.window.setMode(2048, 1152, { resizable = true })
U.wait(10)
battle.blankForAskName = true
local naming = require("src.ui.NamingScreen").new(game, {
title = "NICKNAME?", maxLen = 10, onDone = function() end,
})
game.stack:push(naming)
U.wait(10)
assert(U.shot(game, OVERLAY), "black-background overlay screenshot was written")
print("[driver] FIXED_EXTENDED_BLACK_PASS")
love.event.quit(0)
end
@@ -0,0 +1,65 @@
local U = require("tests.drivers.util")
local OUT = os.getenv("SHOT_DIR") or "fixed-extended-white"
local FULL = OUT .. "/fixed_extended_white_full.png"
local SMALL = OUT .. "/fixed_extended_white_small_16x9.png"
local OVERLAY = OUT .. "/fixed_extended_white_overlay.png"
return function(game)
local BattleState = require("src.battle.BattleState")
local Pokemon = require("src.pokemon.Pokemon")
os.remove(FULL)
os.remove(SMALL)
os.remove(OVERLAY)
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 = "white"
game.save.party = { Pokemon.new(game.data, "PIKACHU", 100) }
U.teleport(game, "ROUTE_1", 5, 5, "down")
U.wait(60)
local battle = BattleState.newWild(game, "PIDGEY", 3,
{ onFinish = function() end })
game.overworld:pushBattle(battle)
U.wait(360)
battle.introSlide = 0
battle.introBalls = nil
battle.showEnemyTrainer = false
battle.showPlayerBack = false
battle.enemySendingOut = false
battle.sendingOut = false
battle.phase = "menu"
battle.menuIndex = 1
U.wait(2)
assert(battle:extendedHUD(), "WHITE activates the approved extended HUD")
assert(not battle:extendedWorldHUD(), "WHITE keeps its opaque paper field")
assert(U.shot(game, FULL), "full WHITE screenshot was written")
love.window.setMode(960, 540, { resizable = true })
U.wait(10)
assert(U.shot(game, SMALL), "small WHITE screenshot was written")
love.window.setMode(2048, 1152, { resizable = true })
U.wait(10)
battle.blankForAskName = true
local naming = require("src.ui.NamingScreen").new(game, {
title = "NICKNAME?",
maxLen = 10,
initial = "",
onDone = function() end,
})
game.stack:push(naming)
U.wait(10)
assert(U.shot(game, OVERLAY), "WHITE overlay screenshot was written")
print("[driver] FIXED_EXTENDED_WHITE_PASS")
love.event.quit(0)
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
@@ -0,0 +1,65 @@
-- Visual acceptance driver for the first EXTENDED HUD configuration only:
-- WIDE + FIXED + EXTENDED + WORLD.
-- POKEPORT_DRIVER=tests/drivers/fixed_extended_world_hud_test.lua \
-- POKEPORT_IDENTITY=fixed-extended-world POKEPORT_TOUCH=0 \
-- SHOT_DIR=/tmp/shots love .
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")
-- Match the 16:9 acceptance screenshot so the fixed 304x144 surface has
-- measurable space above and below it.
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", 100) }
U.teleport(game, "ROUTE_1", 5, 5, "down")
U.wait(60)
local battle = BattleState.newWild(game, "PIDGEY", 3,
{ onFinish = function() end })
game.overworld:pushBattle(battle)
U.wait(360)
battle.introSlide = 0
battle.introBalls = nil
battle.showEnemyTrainer = false
battle.showPlayerBack = false
battle.enemySendingOut = false
battle.sendingOut = false
battle.phase = "menu"
battle.menuIndex = 1
U.wait(2)
local path = DIR .. "/fixed_extended_world_separate_layer.png"
os.remove(path)
local ok = U.shot(game, path)
love.window.setMode(960, 540, { resizable = true })
U.wait(5)
local smallPath = DIR .. "/fixed_extended_world_small_16x9.png"
os.remove(smallPath)
ok = U.shot(game, smallPath) and ok
love.window.setMode(2048, 1152, { resizable = true })
U.wait(5)
local NamingScreen = require("src.ui.NamingScreen")
game.stack:push(NamingScreen.new(game, {
title = "NICKNAME?", maxLen = 10, onDone = function() end,
}))
U.wait(5)
local overlayPath = DIR .. "/fixed_extended_world_naming_overlay.png"
os.remove(overlayPath)
ok = U.shot(game, overlayPath) and ok
U.log(ok and "FIXED_EXTENDED_WORLD_PASS" or "FIXED_EXTENDED_WORLD_FAIL")
love.event.quit(ok and 0 or 1)
end
+9 -1
View File
@@ -92,6 +92,11 @@ local menu = { isOpaque = true } -- PartyMenu / ListMenu
local whiteBattle = setmetatable(
{ game = { save = { options = { battleBg = "white" } } } },
{ __index = BattleState })
local wideWhiteBattle = setmetatable(
{ game = { save = { options = {
battleBg = "white", battleLayout = "wide",
} } } },
{ __index = BattleState })
local function stack(...) return { states = { ... },
visibleBase = function(self)
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")
local s3 = stack(overworld, whiteBattle, menu)
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)
T.eq(Game.drawBaseInStack(s4, s4:visibleBase()), 2,
"and a menu outside a battle is untouched")
@@ -77,6 +77,7 @@ local function battleWith(fx, sprites)
statusHUDVisible = function() return true end,
bottomUIVisible = function() return true end,
caughtMarkerVisible = function() return false end,
extendedHUD = function() return false end,
}
end