mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 16:21:30 +02:00
G2 support
This commit is contained in:
+76
-1
@@ -13,6 +13,67 @@ local BUILTIN = {
|
||||
ManagerState = "src.mods.ManagerState",
|
||||
}
|
||||
|
||||
-- The Gen 2 (Gold) screens, which live under src/ui/gen2/. Half of them share
|
||||
-- a module name with a Gen 1 screen (PartyMenu, StartMenu, TitleState,
|
||||
-- OakSpeech, NamingScreen, PokedexMenu, OptionsMenu, TrainerCard, BoxMenu,
|
||||
-- SummaryMenu, BattleState, SlotMachine, Credits, HallOfFame), so the ids
|
||||
-- carry a "Gen2" prefix: one registry serves both generations, and a mod that
|
||||
-- replaces Gold's party menu must not also replace Red's. The prefix is the
|
||||
-- same namespace the Gold data tables use for the same collision
|
||||
-- (data.gen2Palettes, data.gen2Icons).
|
||||
--
|
||||
-- Everything listed is a stack state: `new(game, opts)`, pushed and popped.
|
||||
-- The drawing helpers sitting next to them in src/ui/gen2/ (Chrome, TileSheet,
|
||||
-- PackGfx, SpriteAnims, BattleAnimView, BattleHud) are not screens and get no
|
||||
-- id -- a mod reskins those through the asset search path, not through here.
|
||||
--
|
||||
-- Gen2HallOfFame is the screen; the roster behind it is src/core/gen2/
|
||||
-- HallOfFame.lua, which is a model and gets no id either.
|
||||
--
|
||||
-- The Game Corner's three PRIZE COUNTERS get no id for the same reason: on the
|
||||
-- cart they are map script and nothing else (GoldenrodGameCornerTMVendorScript
|
||||
-- and its Celadon twins are `loadmenu` / `verticalmenu` / `checkcoins` /
|
||||
-- `giveitem` / `givepoke` / `takecoins`, all of which src/script/gen2/Vm.lua
|
||||
-- runs), so a prize counter is reached by talking to the vendor and never by
|
||||
-- pushing a screen. The slot machine and card flip next door ARE engine
|
||||
-- screens and do have ids.
|
||||
local GEN2 = {
|
||||
"BankOfMom",
|
||||
"BattleState", "BattleTransition", "BoxMenu", "CardFlip",
|
||||
-- The Pokecenter PC's whose-PC top menu and the player's item PC behind it;
|
||||
-- Gen2PcMenu below is the storage system both BILL's PC rows open.
|
||||
"CenterPcMenu",
|
||||
"ContestMenu",
|
||||
"CopyrightSplash", "Credits", "DayCareMenu", "DecorationMenu", "Diploma",
|
||||
"EggHatchAnim", "ElevatorMenu", "EvolutionAnim",
|
||||
"GameFreakPresents", "GoldSilverIntro", "HallOfFame", "HeldItemMenu",
|
||||
-- Gen2InitClock is both timeset.asm screens: the new-game hour/minute pair
|
||||
-- OakSpeech opens with, and Mom's day-of-week wheel.
|
||||
"InitClock",
|
||||
"ItemPcMenu",
|
||||
"MagnetTrainRide",
|
||||
-- MAIL, four screens: the compose keyboard, the full-page reader, the
|
||||
-- READ/TAKE/QUIT row the party submenu opens, and the PC's MAILBOX.
|
||||
"MailCompose", "MailMenu", "MailRead", "MailboxMenu",
|
||||
-- Gen2MapRadio is the in-house wall radio (`special MapRadio`), not a card.
|
||||
"MapRadio",
|
||||
"MainMenu", "MartMenu", "MoveDeleter", "NamePick", "NamingScreen", "OakSpeech",
|
||||
"OptionsMenu", "PackMenu", "PartyMenu", "PcMenu", "PhotoStudio", "PokedexMenu",
|
||||
"Pokegear", "SaveMenu", "ScriptMenu", "SlotMachine",
|
||||
"StartMenu", "SummaryMenu", "TitleState", "TradeAnim", "TradeMenu",
|
||||
"TrainerCard",
|
||||
-- Gen2UnownPrinter is the ALPH RUINS STAMP viewer, not the print itself.
|
||||
"UnownPrinter", "UnownPuzzle",
|
||||
}
|
||||
|
||||
-- The full ids, in the same order, for tests and for the mod docs.
|
||||
Screens.GEN2_IDS = {}
|
||||
for _, name in ipairs(GEN2) do
|
||||
local id = "Gen2" .. name
|
||||
BUILTIN[id] = "src.ui.gen2." .. name
|
||||
Screens.GEN2_IDS[#Screens.GEN2_IDS + 1] = id
|
||||
end
|
||||
|
||||
local cache = {}
|
||||
|
||||
local function builtinFor(id)
|
||||
@@ -40,7 +101,12 @@ function Screens.get(game, id)
|
||||
return resolve(game, id)
|
||||
end
|
||||
|
||||
function Screens.push(game, id, ...)
|
||||
-- Resolve and construct, without touching the stack. Not every screen is
|
||||
-- stacked the moment it is built: the Gen 1 battle queue defers its UI rows,
|
||||
-- and Gold's mart holds a PACK instance for the whole sell flow
|
||||
-- (src/ui/gen2/MartMenu.lua). Those composers need the registry lookup, the
|
||||
-- screenId stamp and the same degrade a push gets, so both paths share this.
|
||||
local function build(game, id, ...)
|
||||
local factory = resolve(game, id)
|
||||
local inst
|
||||
if factory.__modOwned then
|
||||
@@ -58,6 +124,15 @@ function Screens.push(game, id, ...)
|
||||
inst = factory.new(game, ...)
|
||||
end
|
||||
inst.screenId = inst.screenId or id
|
||||
return inst
|
||||
end
|
||||
|
||||
function Screens.build(game, id, ...)
|
||||
return build(game, id, ...)
|
||||
end
|
||||
|
||||
function Screens.push(game, id, ...)
|
||||
local inst = build(game, id, ...)
|
||||
game.stack:push(inst)
|
||||
return inst
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user