mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 00:10:56 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user