mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 11:11:10 +02:00
Merge branch 'dev' of https://github.com/bryanthaboi/gen1recomp into dev
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -12,6 +12,7 @@ local MODULES = {
|
||||
QuantityBox = "src.ui.QuantityBox",
|
||||
NamingScreen = "src.ui.NamingScreen",
|
||||
PicBox = "src.ui.PicBox",
|
||||
PokemonIcon = "src.ui.PokemonIcon",
|
||||
TextBox = "src.render.TextBox",
|
||||
Font = "src.render.Font",
|
||||
Theme = "src.ui.Theme",
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
-- Public read-only Pokemon icon presentation for detached summaries.
|
||||
-- Resolution and rendering deliberately stay engine-owned: PartyMenu already
|
||||
-- composes content icon registrations, per-species definitions, asset
|
||||
-- overrides, and the pokemon.icon hook in one canonical path.
|
||||
|
||||
local PartyMenu = require("src.ui.PartyMenu")
|
||||
|
||||
local PokemonIcon = {}
|
||||
|
||||
local function finite(value)
|
||||
return type(value) == "number" and value == value
|
||||
and value ~= math.huge and value ~= -math.huge
|
||||
end
|
||||
|
||||
local function integer(value, minimum)
|
||||
return finite(value) and value % 1 == 0 and value >= minimum
|
||||
end
|
||||
|
||||
function PokemonIcon.draw(game, summary, x, y, opts)
|
||||
opts = type(opts) == "table" and opts or {}
|
||||
if type(game) ~= "table" or type(summary) ~= "table"
|
||||
or type(summary.species) ~= "string" or summary.species == ""
|
||||
or not integer(summary.hp, 0) or not integer(summary.maxHp, 1)
|
||||
or summary.hp > summary.maxHp or not finite(x) or not finite(y)
|
||||
or (opts.selected ~= nil and type(opts.selected) ~= "boolean")
|
||||
or (opts.counter ~= nil and not finite(opts.counter)) then
|
||||
return false, "invalid_pokemon_preview",
|
||||
"Pokemon icon presentation needs species and valid captured HP values."
|
||||
end
|
||||
local ok, message = pcall(PartyMenu.drawIcon, game, {
|
||||
species = summary.species,
|
||||
hp = summary.hp,
|
||||
stats = { hp = summary.maxHp },
|
||||
}, x, y, opts.selected == true, opts.counter or 0)
|
||||
if not ok then
|
||||
return false, "pokemon_icon_failed", tostring(message)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return PokemonIcon
|
||||
Reference in New Issue
Block a user