mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-18 03:35:56 +02:00
Fix hidden battle UI overlay backgrounds
This commit is contained in:
@@ -27,6 +27,7 @@ local Timing = require("src.core.Timing")
|
||||
local TrainerAI = require("src.battle.TrainerAI")
|
||||
local TurnOrder = require("src.battle.TurnOrder")
|
||||
local TypeChart = require("src.battle.TypeChart")
|
||||
local UIVisibility = require("src.battle.UIVisibility")
|
||||
local RomText = require("src.core.RomText")
|
||||
local Strings = require("src.core.Strings")
|
||||
local WideBattle = require("src.battle.WideBattle")
|
||||
@@ -134,9 +135,7 @@ function BattleState:sgbPalettes()
|
||||
end
|
||||
|
||||
function BattleState:bottomUIVisible()
|
||||
if not Runtime.wantsHook("battle.bottom_ui_visible") then return true end
|
||||
return Runtime.call("battle.bottom_ui_visible", function() return true end,
|
||||
self) ~= false
|
||||
return UIVisibility.bottomVisible(self, true)
|
||||
end
|
||||
|
||||
function BattleState:statusHUDVisible()
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
-- Shared visibility rules for battle-owned UI states. Text and choice
|
||||
-- overlays live above BattleState on the state stack, but they are still part
|
||||
-- of its bottom UI layer and must inherit that layer's visibility.
|
||||
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
|
||||
local UIVisibility = {}
|
||||
|
||||
local function enclosingBattle(state)
|
||||
local stack = state and state.game and state.game.stack
|
||||
local states = stack and stack.states
|
||||
local found = false
|
||||
for i = #(states or {}), 1, -1 do
|
||||
local candidate = states[i]
|
||||
if candidate == state then found = true end
|
||||
if found and candidate and candidate.isBattle then return candidate end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- queryState keeps the existing TextBox contract: a mod may still decide
|
||||
-- visibility for that individual box. ChoiceBox only inherits the enclosing
|
||||
-- battle decision, so field YES/NO prompts never become battle-hook states.
|
||||
function UIVisibility.bottomVisible(state, queryState)
|
||||
if not Runtime.wantsHook("battle.bottom_ui_visible") then return true end
|
||||
local battle = enclosingBattle(state)
|
||||
if battle and battle ~= state
|
||||
and Runtime.call("battle.bottom_ui_visible",
|
||||
function() return true end, battle) == false then
|
||||
return false
|
||||
end
|
||||
if queryState or battle == state then
|
||||
return Runtime.call("battle.bottom_ui_visible",
|
||||
function() return true end, state) ~= false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return UIVisibility
|
||||
@@ -7,7 +7,7 @@
|
||||
-- the text is exhausted and A is pressed, then calls onDone.
|
||||
|
||||
local Font = require("src.render.Font")
|
||||
local Runtime = require("src.mods.Runtime")
|
||||
local UIVisibility = require("src.battle.UIVisibility")
|
||||
local Theme = require("src.ui.Theme")
|
||||
local Timing = require("src.core.Timing")
|
||||
|
||||
@@ -346,11 +346,7 @@ function TextBox:update(dt)
|
||||
end
|
||||
|
||||
function TextBox:draw()
|
||||
if Runtime.wantsHook("battle.bottom_ui_visible")
|
||||
and Runtime.call("battle.bottom_ui_visible", function() return true end,
|
||||
self) == false then
|
||||
return
|
||||
end
|
||||
if not UIVisibility.bottomVisible(self, true) then return end
|
||||
-- The dialogue box belongs against the bottom of the screen, not floating
|
||||
-- in the middle of a zoomed-out letterbox. Declared per frame; the
|
||||
-- renderer blits this region to the screen edge and the rest of the UI
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
-- YES/NO choice box (InitYesNoTextBoxParameters: above the text box, right).
|
||||
|
||||
local Font = require("src.render.Font")
|
||||
local UIVisibility = require("src.battle.UIVisibility")
|
||||
local Theme = require("src.ui.Theme")
|
||||
local Strings = require("src.core.Strings")
|
||||
local Timing = require("src.core.Timing")
|
||||
@@ -67,6 +68,7 @@ function ChoiceBox:update(dt)
|
||||
end
|
||||
|
||||
function ChoiceBox:draw()
|
||||
if not UIVisibility.bottomVisible(self, false) then return end
|
||||
local tx, ty, tw, th = self.tx, self.ty, self.tw, self.th
|
||||
-- rides the same bottom anchor as the dialogue box it sits above, so the
|
||||
-- pair travels together (the anchor keeps each element's gap from the edge)
|
||||
|
||||
Reference in New Issue
Block a user