mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-11 18:51:08 -04:00
CLOSES #1562, CLOSES #1804, CLOSES #1805, CLOSES #1810, CLOSES #1811, CLOSES #1814, CLOSES #1817, CLOSES #1818, CLOSES #1819, CLOSES #1821, CLOSES #1826, CLOSES #1827, CLOSES #1829, CLOSES #1833, CLOSES #1840, CLOSES #1842, CLOSES #1845, CLOSES #1846, CLOSES #1847, CLOSES #1848, CLOSES #1849, CLOSES #1853, CLOSES #1858, CLOSES #1862
This commit is contained in:
+85
-41
@@ -13,9 +13,21 @@ local Strings = require("src.core.Strings")
|
||||
|
||||
local BoxMenu = {}
|
||||
|
||||
local function monLabel(game, mon)
|
||||
-- PrintListMenuEntries prints the nickname at hlcoord 6,4 and PrintLevel
|
||||
-- one row down, 8 columns right (home/list_menu.asm:364-365, 459-461)
|
||||
local function monRow(game, mon, value)
|
||||
local def = game.data.pokemon[mon.species]
|
||||
return Strings("%s :L%d", mon.nickname or def.name, mon.level)
|
||||
return {
|
||||
label = mon.nickname or def.name,
|
||||
sub = Strings(":L%d", mon.level),
|
||||
value = value,
|
||||
}
|
||||
end
|
||||
|
||||
-- the $ff terminator's row (home/list_menu.asm:371-372, 523-528)
|
||||
local function withCancel(items)
|
||||
items[#items + 1] = { cancel = true, label = Strings("CANCEL") }
|
||||
return items
|
||||
end
|
||||
|
||||
local function monName(game, mon)
|
||||
@@ -61,14 +73,15 @@ local function withdraw(game)
|
||||
return
|
||||
end
|
||||
local items = {}
|
||||
for i, mon in ipairs(box) do
|
||||
table.insert(items, { label = monLabel(game, mon), value = i })
|
||||
end
|
||||
game.stack:push(ListMenu.new(game,
|
||||
Strings("BOX %d (WITHDRAW)", game.save.currentBox), items, {
|
||||
for i, mon in ipairs(box) do table.insert(items, monRow(game, mon, i)) end
|
||||
game.stack:push(ListMenu.new(game, nil, withCancel(items), {
|
||||
noSound = true, -- PCMainMenu holds BIT_NO_MENU_BUTTON_SOUND (#570)
|
||||
kind = "pc_box_withdraw",
|
||||
-- DisplayMonListMenu draws LIST_MENU_BOX over the PC menu, which stays
|
||||
-- visible around it (home/list_menu.asm:29-31)
|
||||
itemBox = true,
|
||||
onChoose = function(item, list)
|
||||
if item.cancel then list:close() return end
|
||||
local mon = box[item.value]
|
||||
if not mon then return end
|
||||
monSubmenu(game, "WITHDRAW", mon, function()
|
||||
@@ -111,12 +124,14 @@ local function deposit(game)
|
||||
end
|
||||
local items = {}
|
||||
for i, mon in ipairs(game.save.party) do
|
||||
table.insert(items, { label = monLabel(game, mon), value = i })
|
||||
table.insert(items, monRow(game, mon, i))
|
||||
end
|
||||
game.stack:push(ListMenu.new(game, "PARTY (DEPOSIT)", items, {
|
||||
game.stack:push(ListMenu.new(game, nil, withCancel(items), {
|
||||
noSound = true, -- PCMainMenu holds BIT_NO_MENU_BUTTON_SOUND (#570)
|
||||
kind = "pc_box_deposit",
|
||||
itemBox = true,
|
||||
onChoose = function(item, list)
|
||||
if item.cancel then list:close() return end
|
||||
local mon = game.save.party[item.value]
|
||||
if not mon then return end
|
||||
local Follower = require("src.world.PikachuFollower")
|
||||
@@ -163,14 +178,13 @@ local function release(game)
|
||||
return
|
||||
end
|
||||
local items = {}
|
||||
for i, mon in ipairs(box) do
|
||||
table.insert(items, { label = monLabel(game, mon), value = i })
|
||||
end
|
||||
game.stack:push(ListMenu.new(game,
|
||||
Strings("BOX %d (RELEASE)", game.save.currentBox), items, {
|
||||
for i, mon in ipairs(box) do table.insert(items, monRow(game, mon, i)) end
|
||||
game.stack:push(ListMenu.new(game, nil, withCancel(items), {
|
||||
noSound = true, -- PCMainMenu holds BIT_NO_MENU_BUTTON_SOUND (#570)
|
||||
kind = "pc_box_release",
|
||||
onChoose = function(_, list)
|
||||
itemBox = true,
|
||||
onChoose = function(item, list)
|
||||
if item.cancel then list:close() return end
|
||||
local mon = box[list.index]
|
||||
if not mon then return end
|
||||
local name = monName(game, mon)
|
||||
@@ -202,37 +216,67 @@ local function release(game)
|
||||
}))
|
||||
end
|
||||
|
||||
local function changeBox(game)
|
||||
-- DisplayChangeBoxMenu: engine/menus/save.asm:437-506
|
||||
local function changeBoxMenu(game)
|
||||
local boxes = Boxes.ensure(game.save)
|
||||
local items = {}
|
||||
for i = 1, Boxes.COUNT do
|
||||
local mark = i == game.save.currentBox and "*" or " "
|
||||
table.insert(items, {
|
||||
label = Strings("%sBOX %2d", mark, i),
|
||||
right = ("%d/%d"):format(#boxes[i], Boxes.CAPACITY),
|
||||
value = i,
|
||||
})
|
||||
items[i] = {
|
||||
label = Strings("BOX%2d", i),
|
||||
onSelect = function()
|
||||
game.save.currentBox = i
|
||||
if game.writeSave then game:writeSave() end
|
||||
-- ChangeBox (engine/menus/save.asm) rings SFX_SAVE after SaveGameData (#1044)
|
||||
require("src.core.Sound").play(game.data, "Save")
|
||||
end,
|
||||
}
|
||||
end
|
||||
game.stack:push(ListMenu.new(game, "CHANGE BOX", items, {
|
||||
noSound = true, -- PCMainMenu holds BIT_NO_MENU_BUTTON_SOUND (#570)
|
||||
kind = "pc_box_change",
|
||||
onChoose = function(item, list)
|
||||
-- the original asks BEFORE switching ("When you change a #MON
|
||||
-- BOX, data will be saved. OK?"); declining aborts the change
|
||||
game.stack:push(TextBox.new(game,
|
||||
Strings("When you change a\nPOKéMON BOX, data\nwill be saved. OK?"), nil, {
|
||||
noSound = true,
|
||||
choice = function(yes)
|
||||
if not yes then return end
|
||||
game.save.currentBox = item.value
|
||||
if game.writeSave then game:writeSave() end
|
||||
-- ChangeBox (engine/menus/save.asm) rings SFX_SAVE after SaveGameData (#1044)
|
||||
require("src.core.Sound").play(game.data, "Save")
|
||||
list:close()
|
||||
end,
|
||||
}))
|
||||
local menu = Menu.new(game, items, {
|
||||
tx = 11, ty = 0, tw = 9, th = 14, rowStep = 1, itemY = 1, noSound = true,
|
||||
})
|
||||
menu.kind = "pc_box_change" -- screen.render_visible identity
|
||||
menu.index = math.max(1, math.min(Boxes.COUNT, game.save.currentBox or 1))
|
||||
local t = game.data.text
|
||||
local baseDraw = menu.draw
|
||||
function menu:draw()
|
||||
-- ChooseABoxText goes to the standard box, over BillsPCMenu's "What?"
|
||||
Font.drawBox(0, 12, 20, 6)
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
local y = 112
|
||||
for line in ((t._ChooseABoxText or Strings("Choose a\nPOKéMON BOX."))
|
||||
.. "\n"):gmatch("([^\n]*)\n") do
|
||||
Font.draw(line, 8, y)
|
||||
y = y + 16
|
||||
end
|
||||
Font.drawBox(0, 0, 11, 4)
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
Font.draw(Strings("BOX No."), 8, 16)
|
||||
local n = game.save.currentBox or 1
|
||||
Font.draw(tostring(n), n >= 10 and 64 or 72, 16)
|
||||
baseDraw(self)
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
for i = 1, Boxes.COUNT do
|
||||
if #boxes[i] > 0 then ListMenu.drawBall(148, i * 8 + 4) end
|
||||
end
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
game.stack:push(menu)
|
||||
end
|
||||
|
||||
-- ChangeBox (engine/menus/save.asm:358-368) asks before showing the menu
|
||||
-- and returns to the PC menu on No.
|
||||
local function changeBox(game)
|
||||
local t = game.data.text
|
||||
local ask = TextBox.new(game, t._WhenYouChangeBoxText
|
||||
or Strings("When you change a\nPOKéMON BOX, data\vwill be saved.\fIs that okay?"),
|
||||
nil, {
|
||||
noSound = true,
|
||||
choice = function(yes)
|
||||
if yes then changeBoxMenu(game) end
|
||||
end,
|
||||
}))
|
||||
})
|
||||
ask.kind = "pc_box_change"
|
||||
game.stack:push(ask)
|
||||
end
|
||||
|
||||
-- bills_pc.asm BillsPCMenu chrome: What? text box + BOX No. overlay
|
||||
|
||||
Reference in New Issue
Block a user