diff --git a/src/ui/game3/rs/party_menu_data.lua b/src/ui/game3/rs/party_menu_data.lua index 78862ebb..5805a602 100644 --- a/src/ui/game3/rs/party_menu_data.lua +++ b/src/ui/game3/rs/party_menu_data.lua @@ -163,11 +163,23 @@ function Data.drawDescription(desc, x, y) love.graphics.draw(image, quad, x, y) end -local function prompt(id, width) +local function promptText(id, name) + local RomText = require("src.core.game3.rom_text") + local key = RomText.key("PartyMenuPromptTexts", id) + if RomText.has(key) then return RomText.plain(key, {stringVars = {name or ""}}) end + return assert(require("src.ui.game3.rse.scene_kit").manifest("rse/party").prompts[id + 1]) +end + +local function prompt(ui, anchor, id, width) + local memo = ui._rsPrompt + if not (memo and memo.anchor == anchor and memo.id == id) then + local mon = id == 5 and ui._party and ui._party[ui.cursor] + memo = {anchor = anchor, id = id, text = promptText(id, mon and require("src.core.game3.pokemon").displayName(mon))} + ui._rsPrompt = memo + end local Chrome = require("src.ui.game3.chrome") Chrome.stdFrame(1, 17, width, 2) - require("src.ui.game3.frlg_font").draw(assert(require("src.ui.game3.rse.scene_kit").manifest("rse/party").prompts[id + 1]), 8, 136, - require("src.ui.game3.rs.party_chrome").textOptions("menu")) + require("src.ui.game3.frlg_font").draw(memo.text, 8, 136, require("src.ui.game3.rs.party_chrome").textOptions("menu")) end function Data.drawActions(ui, item) @@ -177,7 +189,7 @@ function Data.drawActions(ui, item) local left = item and (30 - (width + 1)) or 19 local top = item and (20 - (count * 2 + 2)) or (18 - count * 2) 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) + prompt(ui, actions, 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) local texts = ui._actionTextsFor(actions) for i in ipairs(actions) do Font.draw(texts[i], (left + 1) * 8, (top + 1) * 8 + (i - 1) * 16, @@ -192,7 +204,7 @@ function Data.drawPrompt(ui) elseif ui.mode == "give" then id = 4 elseif ui.mode == "move_tutor" then id = 20 elseif ui.mode == "use" then id = require("src.core.game3.items_data").isTm(ui._item) and 2 or 3 end - prompt(id, 22) + prompt(ui, ui.mode, id, 22) end function Data.yesNoLabels() diff --git a/tests/engine/game3_rs_translation_runtime_test.lua b/tests/engine/game3_rs_translation_runtime_test.lua index 5984a2e7..9f859b2b 100644 --- a/tests/engine/game3_rs_translation_runtime_test.lua +++ b/tests/engine/game3_rs_translation_runtime_test.lua @@ -254,6 +254,16 @@ 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.core.game3.pokemon"].displayName = function(mon) return mon.nickname end +BUNDLE.text = { ["PartyMenuPromptTexts[5]"] = { { t = "text", s = "Que faire avec " }, { t = "strvar", n = 1 }, + { t = "text", s = "?" }, { t = "eos" } } } +drawn, menu.ACTIONS, menu._party, menu.cursor = {}, { "SUMMARY", "CANCEL" }, { { nickname = "POUSSIFEU" } }, 1 +PartyData.drawActions(menu, false) +check(drawn[1] == "Que faire avec POUSSIFEU?", "the action prompt reads the cache and names the POKeMON") +BUNDLE.text = {} +drawn = {} +PartyData.drawActions(menu, false) +check(drawn[1] == "Que faire avec POUSSIFEU?", "the prompt resolved for this menu is drawn again without a lookup") 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