Merge pull request #1553 from bryanthaboi/dev

fix stuff baby
This commit is contained in:
bryanthaboi
2026-08-19 06:10:44 -04:00
committed by GitHub
109 changed files with 11478 additions and 335 deletions
+3
View File
@@ -2311,6 +2311,7 @@ function BattleState:openParty(forced)
-- :2702; engine/pokemon/party_menu.asm:660-679). Only the voluntary list
-- carries BattleMonMenu; PickPartyMonInBattle has no submenu.
prompt = forced and "which" or "choose",
battle = true,
battleSubmenu = not forced,
onCancel = function()
stack:pop()
@@ -2783,6 +2784,7 @@ function BattleState:openShiftParty()
self.phase = "submenu"
Screens.push(self.game, "Gen2PartyMenu", {
prompt = "which",
battle = true,
onCancel = function()
stack:pop()
self.phase = "resolving"
@@ -3156,6 +3158,7 @@ function BattleState:useOnPartyMon(itemId, action)
self.phase = "submenu"
Screens.push(self.game, "Gen2PartyMenu", {
prompt = "useItem",
battle = true,
party = self.battle.party or (self.save and self.save.party),
onCancel = function()
stack:pop()
+2 -2
View File
@@ -28,7 +28,7 @@
-- covered by tests; the state at the bottom is the only part that draws.
local GbcPalette = require("src.render.GbcPalette")
local GameViewport = require("src.render.GameViewport")
local Playfield = require("src.render.Playfield")
local Palettes = require("src.world.gen2.Palettes")
local Runtime = require("src.mods.Runtime")
local SpriteAnims = require("src.ui.gen2.SpriteAnims")
@@ -510,7 +510,7 @@ function BattleTransition:blackAt(col, row)
end
function BattleTransition:draw()
local w, h = GameViewport.dimensions()
local w, h = Playfield.dimensions()
self:drawWidescreen(w, h)
end
+17 -4
View File
@@ -43,16 +43,29 @@ end
-- pixel rows out of glyphs. This is the same rule src/render/Renderer.lua
-- fitScale applies to the Gen 1 UI canvas; the surround a widescreen screen
-- paints still fills the window, the PANEL is what stays on the grid.
local function playfieldRect(winW, winH)
local ok, Playfield = pcall(require, "src.render.Playfield")
if ok and Playfield.rect then
local okv, x, y, w, h = pcall(Playfield.rect, winW, winH)
if okv and w and w >= 1 and h and h >= 1 then
return x, y, w, h
end
end
return 0, 0, winW or 0, winH or 0
end
function Chrome.fitScale(winW, winH)
return math.max(1, math.floor(math.min((winW or 0) / (Chrome.SCREEN_W * 8),
(winH or 0) / (Chrome.SCREEN_H * 8))))
local _, _, w, h = playfieldRect(winW, winH)
return math.max(1, math.floor(math.min(w / (Chrome.SCREEN_W * 8),
h / (Chrome.SCREEN_H * 8))))
end
-- The centred origin that goes with it, so a caller does not re-derive it.
function Chrome.fitOrigin(winW, winH, scale)
scale = scale or Chrome.fitScale(winW, winH)
return math.floor((winW - Chrome.SCREEN_W * 8 * scale) / 2),
math.floor((winH - Chrome.SCREEN_H * 8 * scale) / 2)
local x, y, w, h = playfieldRect(winW, winH)
return x + math.floor((w - Chrome.SCREEN_W * 8 * scale) / 2),
y + math.floor((h - Chrome.SCREEN_H * 8 * scale) / 2)
end
-- A bordered box, tile coords. Leaves the draw color black for text.
+37 -1
View File
@@ -76,6 +76,23 @@ local BATTLE_SUBMENU_LEFT, BATTLE_SUBMENU_TOP = 11, 11
-- HP bar is 6 tiles wide (48px) in the party list.
local function gridIndex(index, count, direction)
if count < 1 then return nil end
local row, col = math.floor((index - 1) / 2), (index - 1) % 2
if direction == "left" or direction == "right" then
local other = row * 2 + (1 - col) + 1
return other <= count and other or index
end
local step = direction == "up" and -1 or direction == "down" and 1
if not step then return nil end
local rows = math.ceil(count / 2)
for offset = 1, rows do
local other = ((row + step * offset) % rows) * 2 + col + 1
if other <= count then return other end
end
return index
end
function PartyMenu:wantsFillScale() return true end
function PartyMenu:drawsWidescreen() return true end
@@ -114,6 +131,7 @@ function PartyMenu.new(game, opts)
self.wantsSubmenu = opts.submenu == true
-- BattleMenu_PKMN's `callfar BattleMonMenu` (engine/battle/core.asm:4810).
self.wantsBattleSubmenu = opts.battleSubmenu == true
self.battle = opts.battle == true
self.submenu = nil
-- The held slot while SwitchPartyMons' second pick is open; nil otherwise.
self.switchFrom = nil
@@ -146,6 +164,13 @@ function PartyMenu:isCancel()
return self.index > #self.party
end
function PartyMenu:gridNavigation()
if not self.battle
or not Runtime.wantsHook("ui.party.grid_navigation") then return false end
return Runtime.call("ui.party.grid_navigation", function() return false end,
self) == true
end
-- ------------------------------------------------------------- mon submenu
-- GetMonSubmenuItems, in its own order: every field move the mon knows first,
@@ -477,7 +502,18 @@ function PartyMenu:update(_dt)
return
end
local total = self:count()
if input:wasPressed("up") then
local grid
if self:gridNavigation() then
local direction = input:wasPressed("left") and "left"
or input:wasPressed("right") and "right"
or input:wasPressed("up") and "up"
or input:wasPressed("down") and "down"
grid = gridIndex(self.index, #self.party, direction)
end
if grid then
self.index = grid
self:storeCursor()
elseif input:wasPressed("up") then
self.index = self.index > 1 and self.index - 1 or total
elseif input:wasPressed("down") then
self.index = self.index < total and self.index + 1 or 1