This commit is contained in:
bryanthaboi
2026-08-06 06:36:46 -04:00
15 changed files with 1587 additions and 7 deletions
+6 -2
View File
@@ -16,6 +16,10 @@ local Screens = require("src.ui.Screens")
local Game = {}
local function renderVisible(stack, state)
return state and (not stack.renderVisible or stack:renderVisible(state))
end
-- dev-mode gate for the F5/backtick hotkeys; false keeps every src/dev
-- module unloaded, so a player boot never touches a byte of dev code
local devMode = os.getenv("POKEPORT_DEV") == "1" or _G.POKEPORT_DEV_MODE == true
@@ -460,7 +464,7 @@ function Game:draw()
local state = self.stack.states[i]
local wideState = state and state.isWideBattleLayout
and state:isWideBattleLayout()
if state and state.draw then
if renderVisible(self.stack, state) and state.draw then
if classicOffset ~= 0 and not wideState then
love.graphics.push()
love.graphics.translate(classicOffset, 0)
@@ -484,7 +488,7 @@ function Game:draw()
local zones, worldZones, zoneOwner
for i = #self.stack.states, 1, -1 do
local s = self.stack.states[i]
if s.sgbPalettes then
if renderVisible(self.stack, s) and s.sgbPalettes then
zones = s:sgbPalettes(self)
zoneOwner = s
break
+14 -2
View File
@@ -39,17 +39,29 @@ function StateStack:update(dt)
if top and top.update then top:update(dt) end
end
local function visibleByDefault() return true end
-- A mod may mirror a state elsewhere and hide only its main-screen render.
-- The state stays on the stack, so update and input ownership do not move.
function StateStack:renderVisible(state)
if not state then return false end
if not Runtime.wantsHook("screen.render_visible") then return true end
return Runtime.call("screen.render_visible", visibleByDefault, state) ~= false
end
-- index of the lowest state drawn this frame (highest opaque, else 1)
function StateStack:visibleBase()
for i = #self.states, 1, -1 do
if self.states[i].isOpaque then return i end
local state = self.states[i]
if self:renderVisible(state) and state.isOpaque then return i end
end
return 1
end
function StateStack:draw()
for i = self:visibleBase(), #self.states do
if self.states[i].draw then self.states[i]:draw() end
local state = self.states[i]
if self:renderVisible(state) and state.draw then state:draw() end
end
end