From 117af9f40c02fe52c4b436cdb5be7449fefc3ee7 Mon Sep 17 00:00:00 2001 From: thibautbus <310327033+thibautbus@users.noreply.github.com> Date: Tue, 6 Oct 2026 16:53:29 +0200 Subject: [PATCH] Resolve Ruby and Sapphire's party menu actions once per menu Data.drawActions looked each action's text up in the script cache on every frame. It now draws the texts the party menu resolves once for each action list (action_texts, exposed as PartyMenu._actionTextsFor), as Emerald's and FireRed's menus already do. --- src/ui/game3/party_menu.lua | 1 + src/ui/game3/rs/party_menu_data.lua | 3 ++- tests/engine/game3_rs_translation_runtime_test.lua | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ui/game3/party_menu.lua b/src/ui/game3/party_menu.lua index 83cc27a7..7002fcf4 100644 --- a/src/ui/game3/party_menu.lua +++ b/src/ui/game3/party_menu.lua @@ -137,6 +137,7 @@ local function action_texts(list) PartyMenu._actionTexts = { list = list, texts = texts } return texts end +PartyMenu._actionTextsFor = action_texts local FR_INSETS = { msgX = 2, msgY = 2, actX = 9, actY = 2, cursorX = 1 } local function textInsets() diff --git a/src/ui/game3/rs/party_menu_data.lua b/src/ui/game3/rs/party_menu_data.lua index b44a3450..78862ebb 100644 --- a/src/ui/game3/rs/party_menu_data.lua +++ b/src/ui/game3/rs/party_menu_data.lua @@ -179,7 +179,8 @@ function Data.drawActions(ui, item) local Font = require("src.ui.game3.frlg_font") prompt(item and ui._submenuKind ~= "MAIL" and 13 or 5, item and (ui._submenuKind == "MAIL" and 18 or 21) or 17) require("src.ui.game3.chrome").stdFrame(left + 1, top + 1, width - 1, count * 2) - for i, action in ipairs(actions) do Font.draw(Data.actionText(action, ui._fieldMoveData), (left + 1) * 8, (top + 1) * 8 + (i - 1) * 16, + local texts = ui._actionTextsFor(actions) + for i in ipairs(actions) do Font.draw(texts[i], (left + 1) * 8, (top + 1) * 8 + (i - 1) * 16, require("src.ui.game3.rs.party_chrome").textOptions("menu")) end local cursor = item and ui.itemActionCursor or ui.actionCursor require("src.ui.game3.rs.menu_cursor").draw((left + 1) * 8, (top + 1) * 8 + (cursor - 1) * 16, (width - 1) * 8) diff --git a/tests/engine/game3_rs_translation_runtime_test.lua b/tests/engine/game3_rs_translation_runtime_test.lua index 5a95b2a1..5984a2e7 100644 --- a/tests/engine/game3_rs_translation_runtime_test.lua +++ b/tests/engine/game3_rs_translation_runtime_test.lua @@ -242,6 +242,20 @@ check(PartyData.actionText("SUMMARY") == "RESUME", "a party action reads the cac check(PartyData.actionText("TAKE_MAIL") == "PRENDRE", "the mail's TAKE reads its own label") check(PartyData.actionText("SWITCH") == "SWITCH", "an action missing from the cache keeps the pack's copy") check(PartyData.actionText("CUT", { index = { CUT = 0 }, moves = { 15 } }) == "COUPE", "a field move prints its move's name") +MANIFESTS["rse/party"] = { prompts = setmetatable({}, { __index = function() return "PROMPT" end }) } +local drawn, resolved = {}, 0 +local font, chrome, cursor, partyChrome = package.loaded["src.ui.game3.frlg_font"], package.loaded["src.ui.game3.chrome"], + package.loaded["src.ui.game3.rs.menu_cursor"], package.loaded["src.ui.game3.rs.party_chrome"] +package.loaded["src.ui.game3.frlg_font"] = { draw = function(text) drawn[#drawn + 1] = text end } +package.loaded["src.ui.game3.chrome"] = { stdFrame = function() end } +package.loaded["src.ui.game3.rs.menu_cursor"] = { draw = function() end } +package.loaded["src.ui.game3.rs.party_chrome"] = { textOptions = function() return {} end } +local menu = { ACTIONS = { "SUMMARY", "CANCEL" }, actionCursor = 1, + _actionTextsFor = function(list) resolved = resolved + 1 return { "RESUME", "RETOUR" } end } +PartyData.drawActions(menu, false) +check(drawn[2] == "RESUME" and drawn[3] == "RETOUR" and resolved == 1, "the action menu draws the texts resolved for its list") +package.loaded["src.ui.game3.frlg_font"], package.loaded["src.ui.game3.chrome"] = font, chrome +package.loaded["src.ui.game3.rs.menu_cursor"], package.loaded["src.ui.game3.rs.party_chrome"] = cursor, partyChrome if failed > 0 then print(failed .. " check(s) failed") os.exit(1)