Merge pull request #1055 from AverageConsumer/codex/mod-grid-navigation-hooks

Mod API: allow alternate battle grids to own navigation
This commit is contained in:
bryanthaboi
2026-08-10 17:08:24 -04:00
committed by GitHub
3 changed files with 81 additions and 3 deletions
+36
View File
@@ -12,6 +12,7 @@ local Zoom = require("src.render.Zoom")
local ListMenu = require("src.ui.ListMenu")
local NamingScreen = require("src.ui.NamingScreen")
local TextBox = require("src.render.TextBox")
local PartyMenu = require("src.ui.PartyMenu")
local Player = require("src.world.Player")
local Music = require("src.core.Music")
@@ -192,6 +193,41 @@ do
"battle status HUD returns when the hook is removed")
end
-- ------- grid navigation ownership (alternate menu renderers)
do
local BattleState = require("src.battle.BattleState")
local battle = { wideLayout = function() return false end }
check(not BattleState.moveGridNavigation(battle),
"classic move navigation stays a list without a mod")
local unsub = wrap("battle.move_grid_navigation", function() return true end)
check(BattleState.moveGridNavigation(battle),
"a mod can opt the classic move menu into grid navigation")
unsub()
battle.wideLayout = function() return true end
check(BattleState.moveGridNavigation(battle),
"the native wide move grid remains enabled without a mod")
local game = {
save = { party = { {}, {}, {}, {}, {}, {} } },
input = { wasPressed = function(_, key) return key == "down" end },
}
local field = PartyMenu.new(game)
unsub = wrap("ui.party.grid_navigation", function() return true end)
field:update(0)
check(field.index == 2,
"field party navigation remains a native list when the hook is active")
game.partyMenuSavedIndex = nil
local menu = PartyMenu.new(game, { battle = {} })
menu:update(0)
check(menu.index == 3 and game.partyMenuSavedIndex == 3,
"a battle party can follow and remember a companion grid")
unsub()
menu:update(0)
check(menu.index == 4,
"removing the hook restores native list navigation immediately")
end
-- ------- music.volume (distance / indoor muffling)
do