mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
Merge pull request #1062 from AverageConsumer/codex/mod-caught-marker-visibility
Mod API: allow opt-in caught markers in wild battle HUDs
This commit is contained in:
@@ -145,6 +145,17 @@ function BattleState:statusHUDVisible()
|
||||
self) ~= false
|
||||
end
|
||||
|
||||
function BattleState:caughtMarkerVisible()
|
||||
local dex = self.game and self.game.save and self.game.save.pokedex
|
||||
if not self.enemy or (self.kind ~= "wild" and self.kind ~= "safari")
|
||||
or not (dex and dex.owned and dex.owned[self.enemy.mon.species]) then
|
||||
return false
|
||||
end
|
||||
if not Runtime.wantsHook("battle.caught_marker_visible") then return false end
|
||||
return Runtime.call("battle.caught_marker_visible",
|
||||
function() return false end, self) == true
|
||||
end
|
||||
|
||||
function BattleState:moveGridNavigation()
|
||||
if self:wideLayout() then return true end
|
||||
if not Runtime.wantsHook("battle.move_grid_navigation") then return false end
|
||||
@@ -4793,7 +4804,7 @@ end
|
||||
-- Party pokeball row (SetupPokeballs tiles: ball / status ball /
|
||||
-- fainted ball / empty), 6 slots stepping dx from (x,y).
|
||||
local ballQuads
|
||||
function BattleState:drawBallRow(party, x, y, dx)
|
||||
local function balls()
|
||||
if ballQuads == nil then
|
||||
local ok, img = pcall(love.graphics.newImage, "assets/generated/battle/balls.png")
|
||||
if ok then
|
||||
@@ -4805,11 +4816,23 @@ function BattleState:drawBallRow(party, x, y, dx)
|
||||
ballQuads = false
|
||||
end
|
||||
end
|
||||
if not ballQuads then return end
|
||||
return ballQuads or nil
|
||||
end
|
||||
|
||||
function BattleState:drawCaughtBall(x, y)
|
||||
local quads = balls()
|
||||
if not quads then return end
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(quads.img, quads[0], x, y)
|
||||
end
|
||||
|
||||
function BattleState:drawBallRow(party, x, y, dx)
|
||||
local quads = balls()
|
||||
if not quads then return end
|
||||
for i = 1, 6 do
|
||||
local mon = party[i]
|
||||
local tile = not mon and 3 or mon.hp <= 0 and 2 or mon.status and 1 or 0
|
||||
love.graphics.draw(ballQuads.img, ballQuads[tile], x + (i - 1) * dx, y)
|
||||
love.graphics.draw(quads.img, quads[tile], x + (i - 1) * dx, y)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5525,7 +5548,12 @@ function BattleState:drawHUDs(slide)
|
||||
love.graphics.translate(hudShake, 0)
|
||||
end
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
Font.draw(self.enemy.name, nameX(1, self.enemy.name), 0)
|
||||
local enemyNameX = nameX(1, self.enemy.name)
|
||||
local enemyNameWidth = Font.draw(self.enemy.name, enemyNameX, 0)
|
||||
if self:caughtMarkerVisible() then
|
||||
self:drawCaughtBall(enemyNameX + enemyNameWidth, 0)
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
end
|
||||
if self.enemy.shownStatus then
|
||||
Font.draw(self:statusLabel({ status = self.enemy.shownStatus }), 40, 8)
|
||||
else
|
||||
|
||||
@@ -193,6 +193,26 @@ do
|
||||
"battle status HUD returns when the hook is removed")
|
||||
end
|
||||
|
||||
-- ------- battle.caught_marker_visible (caught wild marker)
|
||||
|
||||
do
|
||||
local BattleState = require("src.battle.BattleState")
|
||||
local state = { kind = "wild", enemy = { mon = { species = "RATTATA" } },
|
||||
game = { save = { pokedex = { owned = { RATTATA = true } } } } }
|
||||
check(not BattleState.caughtMarkerVisible(state),
|
||||
"caught marker is opt-in")
|
||||
local unsub = wrap("battle.caught_marker_visible", function() return true end)
|
||||
check(BattleState.caughtMarkerVisible(state),
|
||||
"a mod can show a caught wild marker")
|
||||
state.kind = "trainer"
|
||||
check(not BattleState.caughtMarkerVisible(state),
|
||||
"trainer battles never show a caught marker")
|
||||
state.kind, state.game.save.pokedex.owned.RATTATA = "wild", false
|
||||
check(not BattleState.caughtMarkerVisible(state),
|
||||
"uncaught wild Pokemon have no marker")
|
||||
unsub()
|
||||
end
|
||||
|
||||
-- ------- grid navigation ownership (alternate menu renderers)
|
||||
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user