Created module MenuHandlers for the contents of various menus

This commit is contained in:
Maruno17
2021-12-31 17:45:07 +00:00
parent 7da449aec3
commit 4cf13f2942
15 changed files with 1073 additions and 1124 deletions

View File

@@ -193,13 +193,6 @@ class HandlerHash2
return nil return nil
end end
def addIf(conditionProc, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
end
@add_ifs.push([conditionProc, handler || handlerBlock])
end
def add(sym, handler = nil, &handlerBlock) def add(sym, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given? if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)" raise ArgumentError, "#{self.class.name} for #{sym.inspect} has no valid handler (#{handler.inspect} was given)"
@@ -207,12 +200,21 @@ class HandlerHash2
@hash[sym] = handler || handlerBlock if sym @hash[sym] = handler || handlerBlock if sym
end end
def addIf(conditionProc, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
end
@add_ifs.push([conditionProc, handler || handlerBlock])
end
def copy(src, *dests) def copy(src, *dests)
handler = self[src] handler = self[src]
return if !handler return if !handler
dests.each do |dest| dests.each { |dest| add(dest, handler) }
self.add(dest, handler) end
end
def remove(key)
@hash.delete(key)
end end
def clear def clear
@@ -222,7 +224,7 @@ class HandlerHash2
def trigger(sym, *args) def trigger(sym, *args)
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id") sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
handler = self[sym] handler = self[sym]
return (handler) ? handler.call(sym, *args) : nil return handler&.call(sym, *args)
end end
end end
@@ -232,9 +234,8 @@ end
#=============================================================================== #===============================================================================
class HandlerHashBasic class HandlerHashBasic
def initialize def initialize
@ordered_keys = [] @hash = {}
@hash = {} @addIfs = []
@addIfs = []
end end
def [](entry) def [](entry)
@@ -248,16 +249,11 @@ class HandlerHashBasic
return ret return ret
end end
def each
@ordered_keys.each { |key| yield key, @hash[key] }
end
def add(entry, handler = nil, &handlerBlock) def add(entry, handler = nil, &handlerBlock)
if ![Proc, Hash].include?(handler.class) && !block_given? if ![Proc, Hash].include?(handler.class) && !block_given?
raise ArgumentError, "#{self.class.name} for #{entry.inspect} has no valid handler (#{handler.inspect} was given)" raise ArgumentError, "#{self.class.name} for #{entry.inspect} has no valid handler (#{handler.inspect} was given)"
end end
return if !entry || entry.empty? return if !entry || entry.empty?
@ordered_keys.push(entry) if !@ordered_keys.include?(entry)
@hash[entry] = handler || handlerBlock @hash[entry] = handler || handlerBlock
end end
@@ -271,17 +267,28 @@ class HandlerHashBasic
def copy(src, *dests) def copy(src, *dests)
handler = self[src] handler = self[src]
return if !handler return if !handler
dests.each { |dest| self.add(dest, handler) } dests.each { |dest| add(dest, handler) }
end
def remove(key)
@hash.delete(key)
end end
def clear def clear
@hash.clear @hash.clear
@ordered_keys.clear end
def each
@hash.each_pair { |key, value| yield key, value }
end
def keys
return @hash.keys.clone
end end
def trigger(entry, *args) def trigger(entry, *args)
handler = self[entry] handler = self[entry]
return (handler) ? handler.call(*args) : nil return handler&.call(*args)
end end
end end

View File

@@ -63,3 +63,59 @@ module EventHandlers
return @@events[event]&.trigger(*args) return @@events[event]&.trigger(*args)
end end
end end
#===============================================================================
# This module stores the contents of various menus. Each command in a menu is a
# hash of data (containing its name, relative order, code to run when chosen,
# etc.).
# Menus that use this module are:
#-------------------------------------------------------------------------------
# Pause menu
# Pokégear main menu
# PC main menu
# Various debug menus (main, Pokémon, battle, battle Pokémon)
#===============================================================================
module MenuHandlers
@@handlers = {}
def self.add(menu, option, hash)
@@handlers[menu] = HandlerHashBasic.new if !@@handlers.has_key?(menu)
@@handlers[menu].add(option, hash)
end
def self.remove(menu, option)
@@handlers[menu]&.remove(option)
end
def self.clear(menu)
@@handlers[menu]&.clear
end
def self.each(menu)
return if !@@handlers.has_key?(menu)
@@handlers[menu].each { |option, hash| yield option, hash }
end
def self.each_available(menu)
return if !@@handlers.has_key?(menu)
options = @@handlers[menu]
keys = options.keys
sorted_keys = keys.sort_by { |option| options[option]["order"] || keys.index(option) }
sorted_keys.each do |option|
hash = options[option]
next if hash["condition"] && !hash["condition"].call
if hash["name"].is_a?(Proc)
name = hash["name"].call
else
name = _INTL(hash["name"])
end
yield option, hash, name
end
end
def self.call(menu, option, function, *args)
option_hash = @@handlers[menu][option]
return nil if !option_hash || !option_hash[function]
return option_hash[function].call(*args)
end
end

View File

@@ -87,8 +87,8 @@ EventHandlers.add(:on_player_step_taken, :gain_happiness,
# Poison party Pokémon # Poison party Pokémon
EventHandlers.add(:on_player_step_taken_can_transfer, :poison_party, EventHandlers.add(:on_player_step_taken_can_transfer, :poison_party,
proc { |handled| proc { |handled|
# handled is an array: [nil]. If [true], a message has already been shown # handled is an array: [nil]. If [true], a transfer has happened because of
# because of this step, so don't do anything that might show another one # this event, so don't do anything that might cause another one
next if handled[0] next if handled[0]
next if !Settings::POISON_IN_FIELD || $PokemonGlobal.stepcount % 4 != 0 next if !Settings::POISON_IN_FIELD || $PokemonGlobal.stepcount % 4 != 0
flashed = false flashed = false

View File

@@ -467,25 +467,16 @@ end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class HallOfFamePC MenuHandlers.add(:pc_menu, :hall_of_fame, {
def shouldShow? "name" => _INTL("Hall of Fame"),
return $PokemonGlobal.hallOfFameLastNumber > 0 "order" => 40,
end "condition" => proc { next $PokemonGlobal.hallOfFameLastNumber > 0 },
"effect" => proc { |menu|
def name
return _INTL("Hall of Fame")
end
def access
pbMessage(_INTL("\\se[PC access]Accessed the Hall of Fame.")) pbMessage(_INTL("\\se[PC access]Accessed the Hall of Fame."))
pbHallOfFamePC pbHallOfFamePC
end next false
end }
})
#===============================================================================
#
#===============================================================================
PokemonPCList.registerPC(HallOfFamePC.new)
#=============================================================================== #===============================================================================
# #

View File

@@ -92,6 +92,8 @@ class PokemonPauseMenu
@scene.pbShowMenu @scene.pbShowMenu
end end
def pbShowInfo; end
def pbStartPokemonMenu def pbStartPokemonMenu
if !$player if !$player
if $DEBUG if $DEBUG
@@ -101,198 +103,218 @@ class PokemonPauseMenu
return return
end end
@scene.pbStartScene @scene.pbStartScene
endscene = true # Show extra info window if relevant
pbShowInfo
# Get all commands
command_list = []
commands = [] commands = []
cmdPokedex = -1 MenuHandlers.each_available(:pause_menu) do |option, hash, name|
cmdPokemon = -1 command_list.push(name)
cmdBag = -1 commands.push(hash)
cmdTrainer = -1
cmdSave = -1
cmdOption = -1
cmdPokegear = -1
cmdTownMap = -1
cmdDebug = -1
cmdQuit = -1
cmdEndGame = -1
if $player.has_pokedex && $player.pokedex.accessible_dexes.length > 0
commands[cmdPokedex = commands.length] = _INTL("Pokédex")
end end
commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $player.party_count > 0 # Main loop
commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest? end_scene = false
if $player.has_pokegear
commands[cmdPokegear = commands.length] = _INTL("Pokégear")
elsif $bag.has?(:TOWNMAP)
commands[cmdTownMap = commands.length] = _INTL("Town Map")
end
commands[cmdTrainer = commands.length] = $player.name
if pbInSafari?
if Settings::SAFARI_STEPS <= 0
@scene.pbShowInfo(_INTL("Balls: {1}", pbSafariState.ballcount))
else
@scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}",
pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount))
end
commands[cmdQuit = commands.length] = _INTL("Quit")
elsif pbInBugContest?
if pbBugContestState.lastPokemon
@scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}",
pbBugContestState.lastPokemon.speciesName,
pbBugContestState.lastPokemon.level,
pbBugContestState.ballcount))
else
@scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount))
end
commands[cmdQuit = commands.length] = _INTL("Quit Contest")
elsif $game_system && !$game_system.save_disabled
commands[cmdSave = commands.length] = _INTL("Save")
end
commands[cmdOption = commands.length] = _INTL("Options")
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmdEndGame = commands.length] = _INTL("Quit Game")
loop do loop do
command = @scene.pbShowCommands(commands) choice = @scene.pbShowCommands(command_list)
if cmdPokedex >= 0 && command == cmdPokedex if choice < 0
pbPlayDecisionSE
if Settings::USE_CURRENT_REGION_DEX
pbFadeOutIn {
scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
elsif $player.pokedex.accessible_dexes.length == 1
$PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0]
pbFadeOutIn {
scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
else
pbFadeOutIn {
scene = PokemonPokedexMenu_Scene.new
screen = PokemonPokedexMenuScreen.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
end
elsif cmdPokemon >= 0 && command == cmdPokemon
pbPlayDecisionSE
hiddenmove = nil
pbFadeOutIn {
sscene = PokemonParty_Scene.new
sscreen = PokemonPartyScreen.new(sscene, $player.party)
hiddenmove = sscreen.pbPokemonScreen
(hiddenmove) ? @scene.pbEndScene : @scene.pbRefresh
}
if hiddenmove
$game_temp.in_menu = false
pbUseHiddenMove(hiddenmove[0], hiddenmove[1])
return
end
elsif cmdBag >= 0 && command == cmdBag
pbPlayDecisionSE
item = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag)
item = screen.pbStartScreen
(item) ? @scene.pbEndScene : @scene.pbRefresh
}
if item
$game_temp.in_menu = false
pbUseKeyItemInField(item)
return
end
elsif cmdPokegear >= 0 && command == cmdPokegear
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonPokegear_Scene.new
screen = PokemonPokegearScreen.new(scene)
screen.pbStartScreen
($game_temp.fly_destination) ? @scene.pbEndScene : @scene.pbRefresh
}
return if pbFlyToNewLocation
elsif cmdTownMap >= 0 && command == cmdTownMap
pbFadeOutIn {
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
$game_temp.fly_destination = ret if ret
($game_temp.fly_destination) ? @scene.pbEndScene : @scene.pbRefresh
}
return if pbFlyToNewLocation
elsif cmdTrainer >= 0 && command == cmdTrainer
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonTrainerCard_Scene.new
screen = PokemonTrainerCardScreen.new(scene)
screen.pbStartScreen
@scene.pbRefresh
}
elsif cmdQuit >= 0 && command == cmdQuit
@scene.pbHideMenu
if pbInSafari?
if pbConfirmMessage(_INTL("Would you like to leave the Safari Game right now?"))
@scene.pbEndScene
pbSafariState.decision = 1
pbSafariState.pbGoToStart
return
else
pbShowMenu
end
elsif pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
@scene.pbEndScene
pbBugContestState.pbStartJudging
return
else
pbShowMenu
end
elsif cmdSave >= 0 && command == cmdSave
@scene.pbHideMenu
scene = PokemonSave_Scene.new
screen = PokemonSaveScreen.new(scene)
if screen.pbSaveScreen
@scene.pbEndScene
endscene = false
break
else
pbShowMenu
end
elsif cmdOption >= 0 && command == cmdOption
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
pbUpdateSceneMap
@scene.pbRefresh
}
elsif cmdDebug >= 0 && command == cmdDebug
pbPlayDecisionSE
pbFadeOutIn {
pbDebugMenu
@scene.pbRefresh
}
elsif cmdEndGame >= 0 && command == cmdEndGame
@scene.pbHideMenu
if pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
scene = PokemonSave_Scene.new
screen = PokemonSaveScreen.new(scene)
if screen.pbSaveScreen
@scene.pbEndScene
end
@scene.pbEndScene
$scene = nil
return
else
pbShowMenu
end
else
pbPlayCloseMenuSE pbPlayCloseMenuSE
end_scene = true
break break
end end
break if commands[choice]["effect"].call(@scene)
end end
@scene.pbEndScene if endscene @scene.pbEndScene if end_scene
end end
end end
#===============================================================================
# Pause menu commands.
#===============================================================================
MenuHandlers.add(:pause_menu, :pokedex, {
"name" => _INTL("Pokédex"),
"order" => 10,
"condition" => proc { next $player.has_pokedex && $player.pokedex.accessible_dexes.length > 0 },
"effect" => proc { |menu|
pbPlayDecisionSE
if Settings::USE_CURRENT_REGION_DEX
pbFadeOutIn {
scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen
menu.pbRefresh
}
elsif $player.pokedex.accessible_dexes.length == 1
$PokemonGlobal.pokedexDex = $player.pokedex.accessible_dexes[0]
pbFadeOutIn {
scene = PokemonPokedex_Scene.new
screen = PokemonPokedexScreen.new(scene)
screen.pbStartScreen
menu.pbRefresh
}
else
pbFadeOutIn {
scene = PokemonPokedexMenu_Scene.new
screen = PokemonPokedexMenuScreen.new(scene)
screen.pbStartScreen
menu.pbRefresh
}
end
next false
}
})
MenuHandlers.add(:pause_menu, :party, {
"name" => _INTL("Pokémon"),
"order" => 20,
"condition" => proc { next $player.party_count > 0 },
"effect" => proc { |menu|
pbPlayDecisionSE
hidden_move = nil
pbFadeOutIn {
sscene = PokemonParty_Scene.new
sscreen = PokemonPartyScreen.new(sscene, $player.party)
hidden_move = sscreen.pbPokemonScreen
(hidden_move) ? menu.pbEndScene : menu.pbRefresh
}
next false if !hidden_move
$game_temp.in_menu = false
pbUseHiddenMove(hidden_move[0], hidden_move[1])
next true
}
})
MenuHandlers.add(:pause_menu, :bag, {
"name" => _INTL("Bag"),
"order" => 30,
"condition" => proc { next !pbInBugContest? },
"effect" => proc { |menu|
pbPlayDecisionSE
item = nil
pbFadeOutIn {
scene = PokemonBag_Scene.new
screen = PokemonBagScreen.new(scene, $bag)
item = screen.pbStartScreen
(item) ? menu.pbEndScene : menu.pbRefresh
}
next false if !item
$game_temp.in_menu = false
pbUseKeyItemInField(item)
next true
}
})
MenuHandlers.add(:pause_menu, :pokegear, {
"name" => _INTL("Pokégear"),
"order" => 40,
"condition" => proc { next $player.has_pokegear },
"effect" => proc { |menu|
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonPokegear_Scene.new
screen = PokemonPokegearScreen.new(scene)
screen.pbStartScreen
($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh
}
next pbFlyToNewLocation
}
})
MenuHandlers.add(:pause_menu, :town_map, {
"name" => _INTL("Town Map"),
"order" => 40,
"condition" => proc { next !$player.has_pokegear && $bag.has?(:TOWNMAP) },
"effect" => proc { |menu|
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
$game_temp.fly_destination = ret if ret
($game_temp.fly_destination) ? menu.pbEndScene : menu.pbRefresh
}
next pbFlyToNewLocation
}
})
MenuHandlers.add(:pause_menu, :trainer_card, {
"name" => proc { next $player.name },
"order" => 50,
"effect" => proc { |menu|
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonTrainerCard_Scene.new
screen = PokemonTrainerCardScreen.new(scene)
screen.pbStartScreen
menu.pbRefresh
}
next false
}
})
MenuHandlers.add(:pause_menu, :save, {
"name" => _INTL("Save"),
"order" => 60,
"condition" => proc { next $game_system && !$game_system.save_disabled &&
!pbInSafari? && !pbInBugContest? },
"effect" => proc { |menu|
menu.pbHideMenu
scene = PokemonSave_Scene.new
screen = PokemonSaveScreen.new(scene)
if screen.pbSaveScreen
menu.pbEndScene
next true
end
menu.pbRefresh
menu.pbShowMenu
next false
}
})
MenuHandlers.add(:pause_menu, :options, {
"name" => _INTL("Options"),
"order" => 70,
"effect" => proc { |menu|
pbPlayDecisionSE
pbFadeOutIn {
scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen
pbUpdateSceneMap
menu.pbRefresh
}
next false
}
})
MenuHandlers.add(:pause_menu, :debug, {
"name" => _INTL("Debug"),
"order" => 80,
"condition" => proc { next $DEBUG },
"effect" => proc { |menu|
pbPlayDecisionSE
pbFadeOutIn {
pbDebugMenu
menu.pbRefresh
}
next false
}
})
MenuHandlers.add(:pause_menu, :quit_game, {
"name" => _INTL("Quit Game"),
"order" => 90,
"effect" => proc { |menu|
menu.pbHideMenu
if pbConfirmMessage(_INTL("Are you sure you want to quit the game?"))
scene = PokemonSave_Scene.new
screen = PokemonSaveScreen.new(scene)
screen.pbSaveScreen
menu.pbEndScene
$scene = nil
next true
end
menu.pbRefresh
menu.pbShowMenu
next false
}
})

View File

@@ -128,43 +128,71 @@ class PokemonPokegearScreen
end end
def pbStartScreen def pbStartScreen
# Get all commands
command_list = []
commands = [] commands = []
cmdMap = -1 MenuHandlers.each_available(:pokegear_menu) do |option, hash, name|
cmdPhone = -1 command_list.push([hash["icon_name"] || "", name])
cmdJukebox = -1 commands.push(hash)
commands[cmdMap = commands.length] = ["map", _INTL("Map")]
if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length > 0
commands[cmdPhone = commands.length] = ["phone", _INTL("Phone")]
end end
commands[cmdJukebox = commands.length] = ["jukebox", _INTL("Jukebox")] @scene.pbStartScene(command_list)
@scene.pbStartScene(commands) # Main loop
end_scene = false
loop do loop do
cmd = @scene.pbScene choice = @scene.pbScene
if cmd < 0 if choice < 0
end_scene = true
break break
elsif cmdMap >= 0 && cmd == cmdMap
pbFadeOutIn {
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
next 99999 # Ugly hack to make Pokégear scene not reappear if flying
end
}
break if $game_temp.fly_destination
elsif cmdPhone >= 0 && cmd == cmdPhone
pbFadeOutIn {
PokemonPhoneScene.new.start
}
elsif cmdJukebox >= 0 && cmd == cmdJukebox
pbFadeOutIn {
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
}
end end
break if commands[choice]["effect"].call(@scene)
end end
($game_temp.fly_destination) ? @scene.dispose : @scene.pbEndScene @scene.pbEndScene if end_scene
end end
end end
#===============================================================================
#
#===============================================================================
MenuHandlers.add(:pokegear_menu, :map, {
"name" => _INTL("Map"),
"icon_name" => "map",
"order" => 10,
"effect" => proc { |menu|
pbFadeOutIn {
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
menu.dispose
next 99999
end
}
next $game_temp.fly_destination
}
})
MenuHandlers.add(:pokegear_menu, :phone, {
"name" => _INTL("Phone"),
"icon_name" => "phone",
"order" => 20,
"condition" => proc { next $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length > 0 },
"effect" => proc { |menu|
pbFadeOutIn { PokemonPhoneScene.new.start }
next false
}
})
MenuHandlers.add(:pokegear_menu, :jukebox, {
"name" => _INTL("Jukebox"),
"icon_name" => "jukebox",
"order" => 30,
"effect" => proc { |menu|
pbFadeOutIn {
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
}
next false
}
})

View File

@@ -1,116 +1,6 @@
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class TrainerPC
def shouldShow?
return true
end
def name
return _INTL("{1}'s PC", $player.name)
end
def access
pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.", $player.name))
pbTrainerPCMenu
end
end
#===============================================================================
#
#===============================================================================
class StorageSystemPC
def shouldShow?
return true
end
def name
if $player.seen_storage_creator
return _INTL("{1}'s PC", pbGetStorageCreator)
else
return _INTL("Someone's PC")
end
end
def access
pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
command = 0
loop do
command = pbShowCommandsWithHelp(nil,
[_INTL("Organize Boxes"),
_INTL("Withdraw Pokémon"),
_INTL("Deposit Pokémon"),
_INTL("See ya!")],
[_INTL("Organize the Pokémon in Boxes and in your party."),
_INTL("Move Pokémon stored in Boxes to your party."),
_INTL("Store Pokémon in your party in Boxes."),
_INTL("Return to the previous menu.")], -1, command)
if command >= 0 && command < 3
case command
when 1 # Withdraw
if $PokemonStorage.party_full?
pbMessage(_INTL("Your party is full!"))
next
end
when 2 # Deposit
count = 0
$PokemonStorage.party.each do |p|
count += 1 if p && !p.egg? && p.hp > 0
end
if count <= 1
pbMessage(_INTL("Can't deposit the last Pokémon!"))
next
end
end
pbFadeOutIn {
scene = PokemonStorageScene.new
screen = PokemonStorageScreen.new(scene, $PokemonStorage)
screen.pbStartScreen(command)
}
else
break
end
end
end
end
#===============================================================================
#
#===============================================================================
module PokemonPCList
@@pclist = []
def self.registerPC(pc)
@@pclist.push(pc)
end
def self.getCommandList
commands = []
@@pclist.each do |pc|
commands.push(pc.name) if pc.shouldShow?
end
commands.push(_INTL("Log Off"))
return commands
end
def self.callCommand(cmd)
return false if cmd < 0 || cmd >= @@pclist.length
i = 0
@@pclist.each do |pc|
next if !pc.shouldShow?
if i == cmd
pc.access
return true
end
i += 1
end
return false
end
end
#===============================================================================
# PC menus
#===============================================================================
def pbPCItemStorage def pbPCItemStorage
command = 0 command = 0
loop do loop do
@@ -162,6 +52,9 @@ def pbPCItemStorage
end end
end end
#===============================================================================
#
#===============================================================================
def pbPCMailbox def pbPCMailbox
if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length == 0 if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length == 0
pbMessage(_INTL("There's no Mail here.")) pbMessage(_INTL("There's no Mail here."))
@@ -211,6 +104,15 @@ def pbPCMailbox
end end
end end
#===============================================================================
#
#===============================================================================
def pbTrainerPC
pbMessage(_INTL("\\se[PC open]{1} booted up the PC.", $player.name))
pbTrainerPCMenu
pbSEPlay("PC close")
end
def pbTrainerPCMenu def pbTrainerPCMenu
command = 0 command = 0
loop do loop do
@@ -226,20 +128,27 @@ def pbTrainerPCMenu
end end
end end
def pbTrainerPC #===============================================================================
pbMessage(_INTL("\\se[PC open]{1} booted up the PC.", $player.name)) #
pbTrainerPCMenu #===============================================================================
pbSEPlay("PC close")
end
def pbPokeCenterPC def pbPokeCenterPC
pbMessage(_INTL("\\se[PC open]{1} booted up the PC.", $player.name)) pbMessage(_INTL("\\se[PC open]{1} booted up the PC.", $player.name))
# Get all commands
command_list = []
commands = []
MenuHandlers.each_available(:pc_menu) do |option, hash, name|
command_list.push(name)
commands.push(hash)
end
# Main loop
command = 0 command = 0
loop do loop do
commands = PokemonPCList.getCommandList choice = pbMessage(_INTL("Which PC should be accessed?"), command_list, -1, nil, command)
command = pbMessage(_INTL("Which PC should be accessed?"), commands, if choice < 0
commands.length, nil, command) pbPlayCloseMenuSE
break if !PokemonPCList.callCommand(command) break
end
break if commands[choice]["effect"].call
end end
pbSEPlay("PC close") pbSEPlay("PC close")
end end
@@ -251,5 +160,65 @@ end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
PokemonPCList.registerPC(StorageSystemPC.new) MenuHandlers.add(:pc_menu, :pokemon_storage, {
PokemonPCList.registerPC(TrainerPC.new) "name" => proc {
next ($player.seen_storage_creator) ? _INTL("{1}'s PC", pbGetStorageCreator) : _INTL("Someone's PC")
},
"order" => 10,
"effect" => proc { |menu|
pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
command = 0
loop do
command = pbShowCommandsWithHelp(nil,
[_INTL("Organize Boxes"),
_INTL("Withdraw Pokémon"),
_INTL("Deposit Pokémon"),
_INTL("See ya!")],
[_INTL("Organize the Pokémon in Boxes and in your party."),
_INTL("Move Pokémon stored in Boxes to your party."),
_INTL("Store Pokémon in your party in Boxes."),
_INTL("Return to the previous menu.")], -1, command)
break if command < 0
case command
when 1 # Withdraw
if $PokemonStorage.party_full?
pbMessage(_INTL("Your party is full!"))
next
end
when 2 # Deposit
count = 0
$PokemonStorage.party.each do |p|
count += 1 if p && !p.egg? && p.hp > 0
end
if count <= 1
pbMessage(_INTL("Can't deposit the last Pokémon!"))
next
end
end
pbFadeOutIn {
scene = PokemonStorageScene.new
screen = PokemonStorageScreen.new(scene, $PokemonStorage)
screen.pbStartScreen(command)
}
end
next false
}
})
MenuHandlers.add(:pc_menu, :player_pc, {
"name" => proc { next _INTL("{1}'s PC", $player.name) },
"order" => 20,
"effect" => proc { |menu|
pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.", $player.name))
pbTrainerPCMenu
next false
}
})
MenuHandlers.add(:pc_menu, :close, {
"name" => _INTL("Log off"),
"order" => 100,
"effect" => proc { |menu|
next true
}
})

View File

@@ -1314,22 +1314,13 @@ end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class PurifyChamberPC MenuHandlers.add(:pc_menu, :purify_chamber, {
def shouldShow? "name" => _INTL("Purify Chamber"),
return $player.seen_purify_chamber "order" => 30,
end "condition" => proc { next $player.seen_purify_chamber },
"effect" => proc { |menu|
def name
return _INTL("Purify Chamber")
end
def access
pbMessage(_INTL("\\se[PC access]Accessed the Purify Chamber.")) pbMessage(_INTL("\\se[PC access]Accessed the Purify Chamber."))
pbPurifyChamber pbPurifyChamber
end next false
end }
})
#===============================================================================
#
#===============================================================================
PokemonPCList.registerPC(PurifyChamberPC.new)

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class SafariState class SafariState
attr_accessor :ballcount attr_accessor :ballcount
attr_accessor :captures attr_accessor :captures
@@ -53,14 +56,9 @@ class SafariState
end end
end end
#===============================================================================
#
EventHandlers.add(:on_enter_map, :end_safari_game, #===============================================================================
proc { |_old_map_id|
pbSafariState.pbEnd if !pbInSafari?
}
)
def pbInSafari? def pbInSafari?
if pbSafariState.inProgress? if pbSafariState.inProgress?
# Reception map is handled separately from safari map since the reception # Reception map is handled separately from safari map since the reception
@@ -77,10 +75,19 @@ def pbSafariState
return $PokemonGlobal.safariState return $PokemonGlobal.safariState
end end
#===============================================================================
#
#===============================================================================
EventHandlers.add(:on_enter_map, :end_safari_game,
proc { |_old_map_id|
pbSafariState.pbEnd if !pbInSafari?
}
)
EventHandlers.add(:on_player_step_taken_can_transfer, :safari_game_counter, EventHandlers.add(:on_player_step_taken_can_transfer, :safari_game_counter,
proc { |handled| proc { |handled|
# handled is an array: [nil]. If [true], a message has already been shown # handled is an array: [nil]. If [true], a transfer has happened because of
# because of this step, so don't do anything that might show another one # this event, so don't do anything that might cause another one
next if handled[0] next if handled[0]
next if Settings::SAFARI_STEPS == 0 || !pbInSafari? || pbSafariState.decision != 0 next if Settings::SAFARI_STEPS == 0 || !pbInSafari? || pbSafariState.decision != 0
pbSafariState.steps -= 1 pbSafariState.steps -= 1
@@ -93,6 +100,9 @@ EventHandlers.add(:on_player_step_taken_can_transfer, :safari_game_counter,
} }
) )
#===============================================================================
#
#===============================================================================
EventHandlers.add(:on_calling_wild_battle, :safari_battle, EventHandlers.add(:on_calling_wild_battle, :safari_battle,
proc { |species, level, handled| proc { |species, level, handled|
# handled is an array: [nil]. If [true] or [false], the battle has already # handled is an array: [nil]. If [true] or [false], the battle has already
@@ -149,3 +159,39 @@ def pbSafariBattle(species, level)
# Return the outcome of the battle # Return the outcome of the battle
return decision return decision
end end
#===============================================================================
#
#===============================================================================
class PokemonPauseMenu
alias __safari_pbShowInfo pbShowInfo unless method_defined?(:__safari_pbShowInfo)
def pbShowInfo
__safari_pbShowInfo
return if !pbInSafari?
if Settings::SAFARI_STEPS <= 0
@scene.pbShowInfo(_INTL("Balls: {1}", pbSafariState.ballcount))
else
@scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}",
pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount))
end
end
end
MenuHandlers.add(:pause_menu, :quit_safari_game, {
"name" => _INTL("Quit"),
"order" => 60,
"condition" => proc { next pbInSafari? },
"effect" => proc { |menu|
menu.pbHideMenu
if pbConfirmMessage(_INTL("Would you like to leave the Safari Game right now?"))
menu.pbEndScene
pbSafariState.decision = 1
pbSafariState.pbGoToStart
next true
end
menu.pbRefresh
menu.pbShowMenu
next false
}
})

View File

@@ -1,3 +1,6 @@
#===============================================================================
#
#===============================================================================
class BugContestState class BugContestState
attr_accessor :ballcount attr_accessor :ballcount
attr_accessor :decision attr_accessor :decision
@@ -214,8 +217,9 @@ class BugContestState
end end
end end
#===============================================================================
#
#===============================================================================
class TimerDisplay # :nodoc: class TimerDisplay # :nodoc:
def initialize(start, maxtime) def initialize(start, maxtime)
@timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64) @timer = Window_AdvancedTextPokemon.newWithSize("", Graphics.width - 120, 0, 120, 64)
@@ -247,8 +251,9 @@ class TimerDisplay # :nodoc:
end end
end end
#===============================================================================
#
#===============================================================================
# Returns a score for this Pokemon in the Bug Catching Contest. # Returns a score for this Pokemon in the Bug Catching Contest.
# Not exactly the HGSS calculation, but it should be decent enough. # Not exactly the HGSS calculation, but it should be decent enough.
def pbBugContestScore(pkmn) def pbBugContestScore(pkmn)
@@ -286,12 +291,18 @@ def pbBugContestDecided?
return pbBugContestState.decided? return pbBugContestState.decided?
end end
EventHandlers.add(:on_enter_map, :end_bug_contest, def pbBugContestStartOver
proc { |_old_map_id| $player.party.each do |pkmn|
pbBugContestState.pbClearIfEnded pkmn.heal
} pkmn.makeUnmega
) pkmn.makeUnprimal
end
pbBugContestState.pbStartJudging
end
#===============================================================================
#
#===============================================================================
EventHandlers.add(:on_map_or_spriteset_change, :show_bug_contest_timer, EventHandlers.add(:on_map_or_spriteset_change, :show_bug_contest_timer,
proc { |scene, _map_changed| proc { |scene, _map_changed|
next if !pbInBugContest? || pbBugContestState.decision != 0 || BugContestState::TIME_ALLOWED == 0 next if !pbInBugContest? || pbBugContestState.decision != 0 || BugContestState::TIME_ALLOWED == 0
@@ -313,6 +324,12 @@ EventHandlers.add(:on_frame_update, :bug_contest_counter,
} }
) )
EventHandlers.add(:on_enter_map, :end_bug_contest,
proc { |_old_map_id|
pbBugContestState.pbClearIfEnded
}
)
EventHandlers.add(:on_leave_map, :end_bug_contest, EventHandlers.add(:on_leave_map, :end_bug_contest,
proc { |new_map_id, new_map| proc { |new_map_id, new_map|
next if !pbInBugContest? || !pbBugContestState.pbOffLimits?(new_map_id) next if !pbInBugContest? || !pbBugContestState.pbOffLimits?(new_map_id)
@@ -321,15 +338,9 @@ EventHandlers.add(:on_leave_map, :end_bug_contest,
} }
) )
def pbBugContestStartOver #===============================================================================
$player.party.each do |pkmn| #
pkmn.heal #===============================================================================
pkmn.makeUnmega
pkmn.makeUnprimal
end
pbBugContestState.pbStartJudging
end
EventHandlers.add(:on_calling_wild_battle, :bug_contest_battle, EventHandlers.add(:on_calling_wild_battle, :bug_contest_battle,
proc { |species, level, handled| proc { |species, level, handled|
# handled is an array: [nil]. If [true] or [false], the battle has already # handled is an array: [nil]. If [true] or [false], the battle has already
@@ -397,3 +408,40 @@ def pbBugContestBattle(species, level)
# Return false if the player lost or drew the battle, and true if any other result # Return false if the player lost or drew the battle, and true if any other result
return (decision != 2 && decision != 5) return (decision != 2 && decision != 5)
end end
#===============================================================================
#
#===============================================================================
class PokemonPauseMenu
alias __bug_contest_pbShowInfo pbShowInfo unless method_defined?(:__bug_contest_pbShowInfo)
def pbShowInfo
__bug_contest_pbShowInfo
return if !pbInBugContest?
if pbBugContestState.lastPokemon
@scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}",
pbBugContestState.lastPokemon.speciesName,
pbBugContestState.lastPokemon.level,
pbBugContestState.ballcount))
else
@scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount))
end
end
end
MenuHandlers.add(:pause_menu, :quit_bug_contest, {
"name" => _INTL("Quit Contest"),
"order" => 60,
"condition" => proc { next pbInBugContest? },
"effect" => proc { |menu|
menu.pbHideMenu
if pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
menu.pbEndScene
pbBugContestState.pbStartJudging
next true
end
menu.pbRefresh
menu.pbShowMenu
next false
}
})

View File

@@ -6,11 +6,11 @@ class CommandMenuList
def initialize def initialize
@commands = [] @commands = []
@currentList = "main" @currentList = :main
end end
def add(option, hash) def add(option, hash, name = nil, description = nil)
@commands.push([option, hash["parent"], hash["name"], hash["description"]]) @commands.push([option, hash["parent"], name || hash["name"], description || hash["description"]])
end end
def list def list
@@ -67,10 +67,18 @@ end
# #
#=============================================================================== #===============================================================================
def pbDebugMenu(show_all = true) def pbDebugMenu(show_all = true)
# Get all commands
commands = CommandMenuList.new commands = CommandMenuList.new
DebugMenuCommands.each do |option, hash| MenuHandlers.each_available(:debug_menu) do |option, hash, name|
commands.add(option, hash) if show_all || hash["always_show"] next if !show_all && !hash["always_show"].nil? && !hash["always_show"]
if hash["description"].is_a?(Proc)
description = hash["description"].call
elsif !hash["description"].nil?
description = _INTL(hash["description"])
end
commands.add(option, hash, name, description)
end end
# Setup windows
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999 viewport.z = 99999
sprites = {} sprites = {}
@@ -86,6 +94,7 @@ def pbDebugMenu(show_all = true)
cmdwindow.visible = true cmdwindow.visible = true
sprites["textbox"].text = commands.getDesc(cmdwindow.index) sprites["textbox"].text = commands.getDesc(cmdwindow.index)
pbFadeInAndShow(sprites) pbFadeInAndShow(sprites)
# Main loop
ret = -1 ret = -1
refresh = true refresh = true
loop do loop do
@@ -123,10 +132,10 @@ def pbDebugMenu(show_all = true)
cmdwindow.commands = commands.list cmdwindow.commands = commands.list
cmdwindow.index = 0 cmdwindow.index = 0
refresh = true refresh = true
elsif cmd == "warp" elsif cmd == :warp
return if DebugMenuCommands.call("effect", cmd, sprites, viewport) return if MenuHandlers.call(:debug_menu, cmd, "effect", sprites, viewport)
else else
DebugMenuCommands.call("effect", cmd) MenuHandlers.call(:debug_menu, cmd, "effect")
end end
end end
pbPlayCloseMenuSE pbPlayCloseMenuSE
@@ -141,27 +150,27 @@ end
#=============================================================================== #===============================================================================
module PokemonDebugMixin module PokemonDebugMixin
def pbPokemonDebug(pkmn, pkmnid, heldpoke = nil, settingUpBattle = false) def pbPokemonDebug(pkmn, pkmnid, heldpoke = nil, settingUpBattle = false)
command = 0 # Get all commands
commands = CommandMenuList.new commands = CommandMenuList.new
PokemonDebugMenuCommands.each do |option, hash| MenuHandlers.each_available(:pokemon_debug_menu) do |option, hash, name|
commands.add(option, hash) if !settingUpBattle || hash["always_show"] next if settingUpBattle && !hash["always_show"].nil? && !hash["always_show"]
commands.add(option, hash, name)
end end
# Main loop
command = 0
loop do loop do
command = pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands.list, command) command = pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands.list, command)
if command < 0 if command < 0
parent = commands.getParent parent = commands.getParent
if parent break if !parent
commands.currentList = parent[0] commands.currentList = parent[0]
command = parent[1] command = parent[1]
else
break
end
else else
cmd = commands.getCommand(command) cmd = commands.getCommand(command)
if commands.hasSubMenu?(cmd) if commands.hasSubMenu?(cmd)
commands.currentList = cmd commands.currentList = cmd
command = 0 command = 0
elsif PokemonDebugMenuCommands.call("effect", cmd, pkmn, pkmnid, heldpoke, settingUpBattle, self) elsif MenuHandlers.call(:pokemon_debug_menu, cmd, "effect", pkmn, pkmnid, heldpoke, settingUpBattle, self)
break break
end end
end end
@@ -174,10 +183,18 @@ end
#=============================================================================== #===============================================================================
module Battle::DebugMixin module Battle::DebugMixin
def pbBattleDebug(battle, show_all = true) def pbBattleDebug(battle, show_all = true)
# Get all commands
commands = CommandMenuList.new commands = CommandMenuList.new
BattleDebugMenuCommands.each do |option, hash| MenuHandlers.each_available(:battle_debug_menu) do |option, hash, name|
commands.add(option, hash) if show_all || hash["always_show"] next if !show_all && !hash["always_show"].nil? && !hash["always_show"]
if hash["description"].is_a?(Proc)
description = hash["description"].call
elsif !hash["description"].nil?
description = _INTL(hash["description"])
end
commands.add(option, hash, name, description)
end end
# Setup windows
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999 viewport.z = 99999
sprites = {} sprites = {}
@@ -191,6 +208,7 @@ module Battle::DebugMixin
cmdwindow.viewport = viewport cmdwindow.viewport = viewport
cmdwindow.visible = true cmdwindow.visible = true
sprites["textbox"].text = commands.getDesc(cmdwindow.index) sprites["textbox"].text = commands.getDesc(cmdwindow.index)
# Main loop
ret = -1 ret = -1
refresh = true refresh = true
loop do loop do
@@ -229,7 +247,7 @@ module Battle::DebugMixin
cmdwindow.index = 0 cmdwindow.index = 0
refresh = true refresh = true
else else
BattleDebugMenuCommands.call("effect", cmd, battle) MenuHandlers.call(:battle_debug_menu, cmd, "effect", battle)
end end
end end
pbPlayCloseMenuSE pbPlayCloseMenuSE
@@ -325,12 +343,14 @@ module Battle::DebugMixin
end end
def pbBattlePokemonDebug(pkmn, battler = nil) def pbBattlePokemonDebug(pkmn, battler = nil)
# Get all commands
commands = CommandMenuList.new commands = CommandMenuList.new
BattlePokemonDebugMenuCommands.each do |option, hash| MenuHandlers.each_available(:battle_pokemon_debug_menu) do |option, hash, name|
next if battler && hash["usage"] == :pokemon next if battler && hash["usage"] == :pokemon
next if !battler && hash["usage"] == :battler next if !battler && hash["usage"] == :battler
commands.add(option, hash) commands.add(option, hash, name)
end end
# Setup windows
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999 viewport.z = 99999
sprites = {} sprites = {}
@@ -346,6 +366,7 @@ module Battle::DebugMixin
sprites["dummywindow"].y = Graphics.height sprites["dummywindow"].y = Graphics.height
sprites["dummywindow"].width = Graphics.width sprites["dummywindow"].width = Graphics.width
sprites["dummywindow"].height = 0 sprites["dummywindow"].height = 0
# Main loop
need_refresh = true need_refresh = true
cmd = 0 cmd = 0
loop do loop do
@@ -373,7 +394,7 @@ module Battle::DebugMixin
commands.currentList = real_cmd commands.currentList = real_cmd
cmd = 0 cmd = 0
else else
BattlePokemonDebugMenuCommands.call("effect", real_cmd, pkmn, battler, self) MenuHandlers.call(:battle_pokemon_debug_menu, real_cmd, "effect", pkmn, battler, self)
need_refresh = true need_refresh = true
end end
end end

View File

@@ -1,85 +1,46 @@
#===============================================================================
#
#===============================================================================
module DebugMenuCommands
@@commands = HandlerHashBasic.new
def self.register(option, hash)
@@commands.add(option, hash)
end
def self.registerIf(condition, hash)
@@commands.addIf(condition, hash)
end
def self.copy(option, *new_options)
@@commands.copy(option, *new_options)
end
def self.each
@@commands.each { |key, hash| yield key, hash }
end
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
option_hash = @@commands[option]
return (option_hash && option_hash[function]) ? option_hash[function] : nil
end
def self.call(function, option, *args)
option_hash = @@commands[option]
return nil if !option_hash || !option_hash[function]
return (option_hash[function].call(*args) == true)
end
end
#=============================================================================== #===============================================================================
# Field options # Field options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("field_menu", { MenuHandlers.add(:debug_menu, :field_menu, {
"parent" => "main", "name" => _INTL("Field Options..."),
"name" => _INTL("Field options..."), "parent" => :main,
"description" => _INTL("Warp to maps, edit switches/variables, use the PC, edit Day Care, etc.") "description" => _INTL("Warp to maps, edit switches/variables, use the PC, edit Day Care, etc."),
"always_show" => false
}) })
DebugMenuCommands.register("warp", { MenuHandlers.add(:debug_menu, :warp, {
"parent" => "field_menu",
"name" => _INTL("Warp to Map"), "name" => _INTL("Warp to Map"),
"parent" => :field_menu,
"description" => _INTL("Instantly warp to another map of your choice."), "description" => _INTL("Instantly warp to another map of your choice."),
"effect" => proc { |sprites, viewport| "effect" => proc { |sprites, viewport|
map = pbWarpToMap map = pbWarpToMap
if map next false if !map
pbFadeOutAndHide(sprites) pbFadeOutAndHide(sprites)
pbDisposeMessageWindow(sprites["textbox"]) pbDisposeMessageWindow(sprites["textbox"])
pbDisposeSpriteHash(sprites) pbDisposeSpriteHash(sprites)
viewport.dispose viewport.dispose
if $scene.is_a?(Scene_Map) if $scene.is_a?(Scene_Map)
$game_temp.player_new_map_id = map[0] $game_temp.player_new_map_id = map[0]
$game_temp.player_new_x = map[1] $game_temp.player_new_x = map[1]
$game_temp.player_new_y = map[2] $game_temp.player_new_y = map[2]
$game_temp.player_new_direction = 2 $game_temp.player_new_direction = 2
$scene.transfer_player $scene.transfer_player
else else
pbCancelVehicles pbCancelVehicles
$map_factory.setup(map[0]) $map_factory.setup(map[0])
$game_player.moveto(map[1], map[2]) $game_player.moveto(map[1], map[2])
$game_player.turn_down $game_player.turn_down
$game_map.update $game_map.update
$game_map.autoplay $game_map.autoplay
end
$game_map.refresh
next true # Closes the debug menu to allow the warp
end end
$game_map.refresh
next true # Closes the debug menu to allow the warp
} }
}) })
DebugMenuCommands.register("refresh_map", { MenuHandlers.add(:debug_menu, :refresh_map, {
"parent" => "field_menu",
"name" => _INTL("Refresh Map"), "name" => _INTL("Refresh Map"),
"parent" => :field_menu,
"description" => _INTL("Make all events on this map, and common events, refresh themselves."), "description" => _INTL("Make all events on this map, and common events, refresh themselves."),
"effect" => proc { "effect" => proc {
$game_map.need_refresh = true $game_map.need_refresh = true
@@ -87,36 +48,36 @@ DebugMenuCommands.register("refresh_map", {
} }
}) })
DebugMenuCommands.register("switches", { MenuHandlers.add(:debug_menu, :switches, {
"parent" => "field_menu",
"name" => _INTL("Switches"), "name" => _INTL("Switches"),
"parent" => :field_menu,
"description" => _INTL("Edit all Game Switches (except Script Switches)."), "description" => _INTL("Edit all Game Switches (except Script Switches)."),
"effect" => proc { "effect" => proc {
pbDebugVariables(0) pbDebugVariables(0)
} }
}) })
DebugMenuCommands.register("variables", { MenuHandlers.add(:debug_menu, :variables, {
"parent" => "field_menu",
"name" => _INTL("Variables"), "name" => _INTL("Variables"),
"parent" => :field_menu,
"description" => _INTL("Edit all Game Variables. Can set them to numbers or text."), "description" => _INTL("Edit all Game Variables. Can set them to numbers or text."),
"effect" => proc { "effect" => proc {
pbDebugVariables(1) pbDebugVariables(1)
} }
}) })
DebugMenuCommands.register("use_pc", { MenuHandlers.add(:debug_menu, :use_pc, {
"parent" => "field_menu",
"name" => _INTL("Use PC"), "name" => _INTL("Use PC"),
"parent" => :field_menu,
"description" => _INTL("Use a PC to access Pokémon storage and player's PC."), "description" => _INTL("Use a PC to access Pokémon storage and player's PC."),
"effect" => proc { "effect" => proc {
pbPokeCenterPC pbPokeCenterPC
} }
}) })
DebugMenuCommands.register("toggle_wallpapers", { MenuHandlers.add(:debug_menu, :storage_wallpapers, {
"parent" => "field_menu",
"name" => _INTL("Toggle Storage Wallpapers"), "name" => _INTL("Toggle Storage Wallpapers"),
"parent" => :field_menu,
"description" => _INTL("Unlock and lock special wallpapers used in Pokémon storage."), "description" => _INTL("Unlock and lock special wallpapers used in Pokémon storage."),
"effect" => proc { "effect" => proc {
w = $PokemonStorage.allWallpapers w = $PokemonStorage.allWallpapers
@@ -152,18 +113,18 @@ DebugMenuCommands.register("toggle_wallpapers", {
} }
}) })
DebugMenuCommands.register("day_care", { MenuHandlers.add(:debug_menu, :day_care, {
"parent" => "field_menu",
"name" => _INTL("Day Care"), "name" => _INTL("Day Care"),
"parent" => :field_menu,
"description" => _INTL("View Pokémon in the Day Care and edit them."), "description" => _INTL("View Pokémon in the Day Care and edit them."),
"effect" => proc { "effect" => proc {
pbDebugDayCare pbDebugDayCare
} }
}) })
DebugMenuCommands.register("skip_credits", { MenuHandlers.add(:debug_menu, :skip_credits, {
"parent" => "field_menu",
"name" => _INTL("Skip Credits"), "name" => _INTL("Skip Credits"),
"parent" => :field_menu,
"description" => _INTL("Toggle whether credits can be ended early by pressing the Use input."), "description" => _INTL("Toggle whether credits can be ended early by pressing the Use input."),
"effect" => proc { "effect" => proc {
$PokemonGlobal.creditsPlayed = !$PokemonGlobal.creditsPlayed $PokemonGlobal.creditsPlayed = !$PokemonGlobal.creditsPlayed
@@ -172,18 +133,18 @@ DebugMenuCommands.register("skip_credits", {
} }
}) })
DebugMenuCommands.register("relic_stone", { MenuHandlers.add(:debug_menu, :relic_stone, {
"parent" => "field_menu",
"name" => _INTL("Use Relic Stone"), "name" => _INTL("Use Relic Stone"),
"parent" => :field_menu,
"description" => _INTL("Shadow Pokémon. Choose a Pokémon to show to the Relic Stone for purification."), "description" => _INTL("Shadow Pokémon. Choose a Pokémon to show to the Relic Stone for purification."),
"effect" => proc { "effect" => proc {
pbRelicStone pbRelicStone
} }
}) })
DebugMenuCommands.register("purify_chamber", { MenuHandlers.add(:debug_menu, :purify_chamber, {
"parent" => "field_menu",
"name" => _INTL("Use Purify Chamber"), "name" => _INTL("Use Purify Chamber"),
"parent" => :field_menu,
"description" => _INTL("Shadow Pokémon. Open the Purify Chamber for purification."), "description" => _INTL("Shadow Pokémon. Open the Purify Chamber for purification."),
"effect" => proc { "effect" => proc {
pbPurifyChamber pbPurifyChamber
@@ -193,15 +154,16 @@ DebugMenuCommands.register("purify_chamber", {
#=============================================================================== #===============================================================================
# Battle options # Battle options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("battle_menu", { MenuHandlers.add(:debug_menu, :battle_menu, {
"parent" => "main", "name" => _INTL("Battle Options..."),
"name" => _INTL("Battle options..."), "parent" => :main,
"description" => _INTL("Start battles, reset this map's trainers, ready rematches, edit roamers, etc.") "description" => _INTL("Start battles, reset this map's trainers, ready rematches, edit roamers, etc."),
"always_show" => false
}) })
DebugMenuCommands.register("test_wild_battle", { MenuHandlers.add(:debug_menu, :test_wild_battle, {
"parent" => "battle_menu",
"name" => _INTL("Test Wild Battle"), "name" => _INTL("Test Wild Battle"),
"parent" => :battle_menu,
"description" => _INTL("Start a single battle against a wild Pokémon. You choose the species/level."), "description" => _INTL("Start a single battle against a wild Pokémon. You choose the species/level."),
"effect" => proc { "effect" => proc {
species = pbChooseSpeciesList species = pbChooseSpeciesList
@@ -221,9 +183,9 @@ DebugMenuCommands.register("test_wild_battle", {
} }
}) })
DebugMenuCommands.register("test_wild_battle_advanced", { MenuHandlers.add(:debug_menu, :test_wild_battle_advanced, {
"parent" => "battle_menu",
"name" => _INTL("Test Wild Battle Advanced"), "name" => _INTL("Test Wild Battle Advanced"),
"parent" => :battle_menu,
"description" => _INTL("Start a battle against 1 or more wild Pokémon. Battle size is your choice."), "description" => _INTL("Start a battle against 1 or more wild Pokémon. Battle size is your choice."),
"effect" => proc { "effect" => proc {
pkmn = [] pkmn = []
@@ -285,9 +247,9 @@ DebugMenuCommands.register("test_wild_battle_advanced", {
} }
}) })
DebugMenuCommands.register("test_trainer_battle", { MenuHandlers.add(:debug_menu, :test_trainer_battle, {
"parent" => "battle_menu",
"name" => _INTL("Test Trainer Battle"), "name" => _INTL("Test Trainer Battle"),
"parent" => :battle_menu,
"description" => _INTL("Start a single battle against a trainer of your choice."), "description" => _INTL("Start a single battle against a trainer of your choice."),
"effect" => proc { "effect" => proc {
trainerdata = pbListScreen(_INTL("SINGLE TRAINER"), TrainerBattleLister.new(0, false)) trainerdata = pbListScreen(_INTL("SINGLE TRAINER"), TrainerBattleLister.new(0, false))
@@ -298,9 +260,9 @@ DebugMenuCommands.register("test_trainer_battle", {
} }
}) })
DebugMenuCommands.register("test_trainer_battle_advanced", { MenuHandlers.add(:debug_menu, :test_trainer_battle_advanced, {
"parent" => "battle_menu",
"name" => _INTL("Test Trainer Battle Advanced"), "name" => _INTL("Test Trainer Battle Advanced"),
"parent" => :battle_menu,
"description" => _INTL("Start a battle against 1 or more trainers with a battle size of your choice."), "description" => _INTL("Start a battle against 1 or more trainers with a battle size of your choice."),
"effect" => proc { "effect" => proc {
trainers = [] trainers = []
@@ -389,9 +351,9 @@ DebugMenuCommands.register("test_trainer_battle_advanced", {
} }
}) })
DebugMenuCommands.register("toggle_logging", { MenuHandlers.add(:debug_menu, :toggle_logging, {
"parent" => "battle_menu",
"name" => _INTL("Toggle Battle Logging"), "name" => _INTL("Toggle Battle Logging"),
"parent" => :battle_menu,
"description" => _INTL("Record debug logs for battles in Data/debuglog.txt."), "description" => _INTL("Record debug logs for battles in Data/debuglog.txt."),
"effect" => proc { "effect" => proc {
$INTERNAL = !$INTERNAL $INTERNAL = !$INTERNAL
@@ -400,9 +362,9 @@ DebugMenuCommands.register("toggle_logging", {
} }
}) })
DebugMenuCommands.register("reset_trainers", { MenuHandlers.add(:debug_menu, :reset_trainers, {
"parent" => "battle_menu",
"name" => _INTL("Reset Map's Trainers"), "name" => _INTL("Reset Map's Trainers"),
"parent" => :battle_menu,
"description" => _INTL("Turn off Self Switches A and B for all events with \"Trainer\" in their name."), "description" => _INTL("Turn off Self Switches A and B for all events with \"Trainer\" in their name."),
"effect" => proc { "effect" => proc {
if $game_map if $game_map
@@ -420,9 +382,9 @@ DebugMenuCommands.register("reset_trainers", {
} }
}) })
DebugMenuCommands.register("ready_rematches", { MenuHandlers.add(:debug_menu, :ready_rematches, {
"parent" => "battle_menu",
"name" => _INTL("Ready All Phone Rematches"), "name" => _INTL("Ready All Phone Rematches"),
"parent" => :battle_menu,
"description" => _INTL("Make all trainers in the phone ready for rematches."), "description" => _INTL("Make all trainers in the phone ready for rematches."),
"effect" => proc { "effect" => proc {
if !$PokemonGlobal.phoneNumbers || $PokemonGlobal.phoneNumbers.length == 0 if !$PokemonGlobal.phoneNumbers || $PokemonGlobal.phoneNumbers.length == 0
@@ -438,18 +400,18 @@ DebugMenuCommands.register("ready_rematches", {
} }
}) })
DebugMenuCommands.register("roamers", { MenuHandlers.add(:debug_menu, :roamers, {
"parent" => "battle_menu",
"name" => _INTL("Roaming Pokémon"), "name" => _INTL("Roaming Pokémon"),
"parent" => :battle_menu,
"description" => _INTL("Toggle and edit all roaming Pokémon."), "description" => _INTL("Toggle and edit all roaming Pokémon."),
"effect" => proc { "effect" => proc {
pbDebugRoamers pbDebugRoamers
} }
}) })
DebugMenuCommands.register("encounter_version", { MenuHandlers.add(:debug_menu, :encounter_version, {
"parent" => "battle_menu",
"name" => _INTL("Set Encounters Version"), "name" => _INTL("Set Encounters Version"),
"parent" => :battle_menu,
"description" => _INTL("Choose which version of wild encounters should be used."), "description" => _INTL("Choose which version of wild encounters should be used."),
"effect" => proc { "effect" => proc {
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -466,15 +428,16 @@ DebugMenuCommands.register("encounter_version", {
#=============================================================================== #===============================================================================
# Item options # Item options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("items_menu", { MenuHandlers.add(:debug_menu, :items_menu, {
"parent" => "main", "name" => _INTL("Item Options..."),
"name" => _INTL("Item options..."), "parent" => :main,
"description" => _INTL("Give and take items.") "description" => _INTL("Give and take items."),
"always_show" => false
}) })
DebugMenuCommands.register("add_item", { MenuHandlers.add(:debug_menu, :add_item, {
"parent" => "items_menu",
"name" => _INTL("Add Item"), "name" => _INTL("Add Item"),
"parent" => :items_menu,
"description" => _INTL("Choose an item and a quantity of it to add to the Bag."), "description" => _INTL("Choose an item and a quantity of it to add to the Bag."),
"effect" => proc { "effect" => proc {
pbListScreenBlock(_INTL("ADD ITEM"), ItemLister.new) { |button, item| pbListScreenBlock(_INTL("ADD ITEM"), ItemLister.new) { |button, item|
@@ -494,9 +457,9 @@ DebugMenuCommands.register("add_item", {
} }
}) })
DebugMenuCommands.register("fill_bag", { MenuHandlers.add(:debug_menu, :fill_bag, {
"parent" => "items_menu",
"name" => _INTL("Fill Bag"), "name" => _INTL("Fill Bag"),
"parent" => :items_menu,
"description" => _INTL("Empties the Bag and then fills it with a certain number of every item."), "description" => _INTL("Empties the Bag and then fills it with a certain number of every item."),
"effect" => proc { "effect" => proc {
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -523,9 +486,9 @@ DebugMenuCommands.register("fill_bag", {
} }
}) })
DebugMenuCommands.register("empty_bag", { MenuHandlers.add(:debug_menu, :empty_bag, {
"parent" => "items_menu",
"name" => _INTL("Empty Bag"), "name" => _INTL("Empty Bag"),
"parent" => :items_menu,
"description" => _INTL("Remove all items from the Bag."), "description" => _INTL("Remove all items from the Bag."),
"effect" => proc { "effect" => proc {
$bag.clear $bag.clear
@@ -536,15 +499,16 @@ DebugMenuCommands.register("empty_bag", {
#=============================================================================== #===============================================================================
# Pokémon options # Pokémon options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("pokemon_menu", { MenuHandlers.add(:debug_menu, :pokemon_menu, {
"parent" => "main", "name" => _INTL("Pokémon Options..."),
"name" => _INTL("Pokémon options..."), "parent" => :main,
"description" => _INTL("Give Pokémon, heal party, fill/empty PC storage, etc.") "description" => _INTL("Give Pokémon, heal party, fill/empty PC storage, etc."),
"always_show" => false
}) })
DebugMenuCommands.register("add_pokemon", { MenuHandlers.add(:debug_menu, :add_pokemon, {
"parent" => "pokemon_menu",
"name" => _INTL("Add Pokémon"), "name" => _INTL("Add Pokémon"),
"parent" => :pokemon_menu,
"description" => _INTL("Give yourself a Pokémon of a chosen species/level. Goes to PC if party is full."), "description" => _INTL("Give yourself a Pokémon of a chosen species/level. Goes to PC if party is full."),
"effect" => proc { "effect" => proc {
species = pbChooseSpeciesList species = pbChooseSpeciesList
@@ -559,9 +523,9 @@ DebugMenuCommands.register("add_pokemon", {
} }
}) })
DebugMenuCommands.register("give_demo_party", { MenuHandlers.add(:debug_menu, :give_demo_party, {
"parent" => "pokemon_menu",
"name" => _INTL("Give Demo Party"), "name" => _INTL("Give Demo Party"),
"parent" => :pokemon_menu,
"description" => _INTL("Give yourself 6 preset Pokémon. They overwrite the current party."), "description" => _INTL("Give yourself 6 preset Pokémon. They overwrite the current party."),
"effect" => proc { "effect" => proc {
party = [] party = []
@@ -602,9 +566,9 @@ DebugMenuCommands.register("give_demo_party", {
} }
}) })
DebugMenuCommands.register("heal_party", { MenuHandlers.add(:debug_menu, :heal_party, {
"parent" => "pokemon_menu",
"name" => _INTL("Heal Party"), "name" => _INTL("Heal Party"),
"parent" => :pokemon_menu,
"description" => _INTL("Fully heal the HP/status/PP of all Pokémon in the party."), "description" => _INTL("Fully heal the HP/status/PP of all Pokémon in the party."),
"effect" => proc { "effect" => proc {
$player.party.each { |pkmn| pkmn.heal } $player.party.each { |pkmn| pkmn.heal }
@@ -612,9 +576,9 @@ DebugMenuCommands.register("heal_party", {
} }
}) })
DebugMenuCommands.register("quick_hatch_party_eggs", { MenuHandlers.add(:debug_menu, :quick_hatch_party_eggs, {
"parent" => "pokemon_menu",
"name" => _INTL("Quick Hatch"), "name" => _INTL("Quick Hatch"),
"parent" => :pokemon_menu,
"description" => _INTL("Make all eggs in the party require just one more step to hatch."), "description" => _INTL("Make all eggs in the party require just one more step to hatch."),
"effect" => proc { "effect" => proc {
$player.party.each { |pkmn| pkmn.steps_to_hatch = 1 if pkmn.egg? } $player.party.each { |pkmn| pkmn.steps_to_hatch = 1 if pkmn.egg? }
@@ -622,9 +586,9 @@ DebugMenuCommands.register("quick_hatch_party_eggs", {
} }
}) })
DebugMenuCommands.register("fill_boxes", { MenuHandlers.add(:debug_menu, :fill_boxes, {
"parent" => "pokemon_menu",
"name" => _INTL("Fill Storage Boxes"), "name" => _INTL("Fill Storage Boxes"),
"parent" => :pokemon_menu,
"description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."), "description" => _INTL("Add one Pokémon of each species (at Level 50) to storage."),
"effect" => proc { "effect" => proc {
added = 0 added = 0
@@ -669,9 +633,9 @@ DebugMenuCommands.register("fill_boxes", {
} }
}) })
DebugMenuCommands.register("clear_boxes", { MenuHandlers.add(:debug_menu, :clear_boxes, {
"parent" => "pokemon_menu",
"name" => _INTL("Clear Storage Boxes"), "name" => _INTL("Clear Storage Boxes"),
"parent" => :pokemon_menu,
"description" => _INTL("Remove all Pokémon in storage."), "description" => _INTL("Remove all Pokémon in storage."),
"effect" => proc { "effect" => proc {
$PokemonStorage.maxBoxes.times do |i| $PokemonStorage.maxBoxes.times do |i|
@@ -683,9 +647,9 @@ DebugMenuCommands.register("clear_boxes", {
} }
}) })
DebugMenuCommands.register("open_storage", { MenuHandlers.add(:debug_menu, :open_storage, {
"parent" => "pokemon_menu",
"name" => _INTL("Access Pokémon Storage"), "name" => _INTL("Access Pokémon Storage"),
"parent" => :pokemon_menu,
"description" => _INTL("Opens the Pokémon storage boxes in Organize Boxes mode."), "description" => _INTL("Opens the Pokémon storage boxes in Organize Boxes mode."),
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbFadeOutIn {
@@ -699,15 +663,16 @@ DebugMenuCommands.register("open_storage", {
#=============================================================================== #===============================================================================
# Player options # Player options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("player_menu", { MenuHandlers.add(:debug_menu, :player_menu, {
"parent" => "main", "name" => _INTL("Player Options..."),
"name" => _INTL("Player options..."), "parent" => :main,
"description" => _INTL("Set money, badges, Pokédexes, player's appearance and name, etc.") "description" => _INTL("Set money, badges, Pokédexes, player's appearance and name, etc."),
"always_show" => false
}) })
DebugMenuCommands.register("set_badges", { MenuHandlers.add(:debug_menu, :set_badges, {
"parent" => "player_menu",
"name" => _INTL("Set Badges"), "name" => _INTL("Set Badges"),
"parent" => :player_menu,
"description" => _INTL("Toggle possession of each Gym Badge."), "description" => _INTL("Toggle possession of each Gym Badge."),
"effect" => proc { "effect" => proc {
badgecmd = 0 badgecmd = 0
@@ -732,9 +697,9 @@ DebugMenuCommands.register("set_badges", {
} }
}) })
DebugMenuCommands.register("set_money", { MenuHandlers.add(:debug_menu, :set_money, {
"parent" => "player_menu",
"name" => _INTL("Set Money"), "name" => _INTL("Set Money"),
"parent" => :player_menu,
"description" => _INTL("Edit how much money you have."), "description" => _INTL("Edit how much money you have."),
"effect" => proc { "effect" => proc {
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -745,9 +710,9 @@ DebugMenuCommands.register("set_money", {
} }
}) })
DebugMenuCommands.register("set_coins", { MenuHandlers.add(:debug_menu, :set_coins, {
"parent" => "player_menu",
"name" => _INTL("Set Coins"), "name" => _INTL("Set Coins"),
"parent" => :player_menu,
"description" => _INTL("Edit how many Game Corner Coins you have."), "description" => _INTL("Edit how many Game Corner Coins you have."),
"effect" => proc { "effect" => proc {
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -758,9 +723,9 @@ DebugMenuCommands.register("set_coins", {
} }
}) })
DebugMenuCommands.register("set_bp", { MenuHandlers.add(:debug_menu, :set_bp, {
"parent" => "player_menu",
"name" => _INTL("Set Battle Points"), "name" => _INTL("Set Battle Points"),
"parent" => :player_menu,
"description" => _INTL("Edit how many Battle Points you have."), "description" => _INTL("Edit how many Battle Points you have."),
"effect" => proc { "effect" => proc {
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -771,9 +736,9 @@ DebugMenuCommands.register("set_bp", {
} }
}) })
DebugMenuCommands.register("toggle_running_shoes", { MenuHandlers.add(:debug_menu, :toggle_running_shoes, {
"parent" => "player_menu",
"name" => _INTL("Toggle Running Shoes"), "name" => _INTL("Toggle Running Shoes"),
"parent" => :player_menu,
"description" => _INTL("Toggle possession of running shoes."), "description" => _INTL("Toggle possession of running shoes."),
"effect" => proc { "effect" => proc {
$player.has_running_shoes = !$player.has_running_shoes $player.has_running_shoes = !$player.has_running_shoes
@@ -782,9 +747,9 @@ DebugMenuCommands.register("toggle_running_shoes", {
} }
}) })
DebugMenuCommands.register("toggle_pokegear", { MenuHandlers.add(:debug_menu, :toggle_pokegear, {
"parent" => "player_menu",
"name" => _INTL("Toggle Pokégear"), "name" => _INTL("Toggle Pokégear"),
"parent" => :player_menu,
"description" => _INTL("Toggle possession of the Pokégear."), "description" => _INTL("Toggle possession of the Pokégear."),
"effect" => proc { "effect" => proc {
$player.has_pokegear = !$player.has_pokegear $player.has_pokegear = !$player.has_pokegear
@@ -793,9 +758,9 @@ DebugMenuCommands.register("toggle_pokegear", {
} }
}) })
DebugMenuCommands.register("toggle_pokedex", { MenuHandlers.add(:debug_menu, :toggle_pokedex, {
"parent" => "player_menu",
"name" => _INTL("Toggle Pokédex and Dexes"), "name" => _INTL("Toggle Pokédex and Dexes"),
"parent" => :player_menu,
"description" => _INTL("Toggle possession of the Pokédex, and edit Regional Dex accessibility."), "description" => _INTL("Toggle possession of the Pokédex, and edit Regional Dex accessibility."),
"effect" => proc { "effect" => proc {
dexescmd = 0 dexescmd = 0
@@ -822,9 +787,9 @@ DebugMenuCommands.register("toggle_pokedex", {
} }
}) })
DebugMenuCommands.register("set_player_character", { MenuHandlers.add(:debug_menu, :set_player_character, {
"parent" => "player_menu",
"name" => _INTL("Set Player Character"), "name" => _INTL("Set Player Character"),
"parent" => :player_menu,
"description" => _INTL("Edit the player's character, as defined in \"metadata.txt\"."), "description" => _INTL("Edit the player's character, as defined in \"metadata.txt\"."),
"effect" => proc { "effect" => proc {
index = 0 index = 0
@@ -847,9 +812,9 @@ DebugMenuCommands.register("set_player_character", {
} }
}) })
DebugMenuCommands.register("change_outfit", { MenuHandlers.add(:debug_menu, :change_outfit, {
"parent" => "player_menu",
"name" => _INTL("Set Player Outfit"), "name" => _INTL("Set Player Outfit"),
"parent" => :player_menu,
"description" => _INTL("Edit the player's outfit number."), "description" => _INTL("Edit the player's outfit number."),
"effect" => proc { "effect" => proc {
oldoutfit = $player.outfit oldoutfit = $player.outfit
@@ -861,9 +826,9 @@ DebugMenuCommands.register("change_outfit", {
} }
}) })
DebugMenuCommands.register("rename_player", { MenuHandlers.add(:debug_menu, :rename_player, {
"parent" => "player_menu",
"name" => _INTL("Set Player Name"), "name" => _INTL("Set Player Name"),
"parent" => :player_menu,
"description" => _INTL("Rename the player."), "description" => _INTL("Rename the player."),
"effect" => proc { "effect" => proc {
trname = pbEnterPlayerName("Your name?", 0, Settings::MAX_PLAYER_NAME_SIZE, $player.name) trname = pbEnterPlayerName("Your name?", 0, Settings::MAX_PLAYER_NAME_SIZE, $player.name)
@@ -881,9 +846,9 @@ DebugMenuCommands.register("rename_player", {
} }
}) })
DebugMenuCommands.register("random_id", { MenuHandlers.add(:debug_menu, :random_id, {
"parent" => "player_menu",
"name" => _INTL("Randomize Player ID"), "name" => _INTL("Randomize Player ID"),
"parent" => :player_menu,
"description" => _INTL("Generate a random new ID for the player."), "description" => _INTL("Generate a random new ID for the player."),
"effect" => proc { "effect" => proc {
$player.id = rand(2**16) | (rand(2**16) << 16) $player.id = rand(2**16) | (rand(2**16) << 16)
@@ -894,118 +859,106 @@ DebugMenuCommands.register("random_id", {
#=============================================================================== #===============================================================================
# Information editors # Information editors
#=============================================================================== #===============================================================================
DebugMenuCommands.register("editors_menu", { MenuHandlers.add(:debug_menu, :editors_menu, {
"parent" => "main", "name" => _INTL("Information Editors..."),
"name" => _INTL("Information editors..."), "parent" => :main,
"description" => _INTL("Edit information in the PBS files, terrain tags, battle animations, etc."), "description" => _INTL("Edit information in the PBS files, terrain tags, battle animations, etc.")
"always_show" => true
}) })
DebugMenuCommands.register("set_metadata", { MenuHandlers.add(:debug_menu, :set_metadata, {
"parent" => "editors_menu",
"name" => _INTL("Edit Metadata"), "name" => _INTL("Edit Metadata"),
"parent" => :editors_menu,
"description" => _INTL("Edit global metadata and player character metadata."), "description" => _INTL("Edit global metadata and player character metadata."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbMetadataScreen pbMetadataScreen
} }
}) })
DebugMenuCommands.register("set_map_metadata", { MenuHandlers.add(:debug_menu, :set_map_metadata, {
"parent" => "editors_menu",
"name" => _INTL("Edit Map Metadata"), "name" => _INTL("Edit Map Metadata"),
"parent" => :editors_menu,
"description" => _INTL("Edit map metadata."), "description" => _INTL("Edit map metadata."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbMapMetadataScreen(pbDefaultMap) pbMapMetadataScreen(pbDefaultMap)
} }
}) })
DebugMenuCommands.register("set_map_connections", { MenuHandlers.add(:debug_menu, :set_map_connections, {
"parent" => "editors_menu",
"name" => _INTL("Edit Map Connections"), "name" => _INTL("Edit Map Connections"),
"parent" => :editors_menu,
"description" => _INTL("Connect maps using a visual interface. Can also edit map encounters/metadata."), "description" => _INTL("Connect maps using a visual interface. Can also edit map encounters/metadata."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbConnectionsEditor } pbFadeOutIn { pbConnectionsEditor }
} }
}) })
DebugMenuCommands.register("set_terrain_tags", { MenuHandlers.add(:debug_menu, :set_terrain_tags, {
"parent" => "editors_menu",
"name" => _INTL("Edit Terrain Tags"), "name" => _INTL("Edit Terrain Tags"),
"parent" => :editors_menu,
"description" => _INTL("Edit the terrain tags of tiles in tilesets. Required for tags 8+."), "description" => _INTL("Edit the terrain tags of tiles in tilesets. Required for tags 8+."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbTilesetScreen } pbFadeOutIn { pbTilesetScreen }
} }
}) })
DebugMenuCommands.register("set_encounters", { MenuHandlers.add(:debug_menu, :set_encounters, {
"parent" => "editors_menu",
"name" => _INTL("Edit Wild Encounters"), "name" => _INTL("Edit Wild Encounters"),
"parent" => :editors_menu,
"description" => _INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered."), "description" => _INTL("Edit the wild Pokémon that can be found on maps, and how they are encountered."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbEncountersEditor } pbFadeOutIn { pbEncountersEditor }
} }
}) })
DebugMenuCommands.register("set_trainer_types", { MenuHandlers.add(:debug_menu, :set_trainer_types, {
"parent" => "editors_menu",
"name" => _INTL("Edit Trainer Types"), "name" => _INTL("Edit Trainer Types"),
"parent" => :editors_menu,
"description" => _INTL("Edit the properties of trainer types."), "description" => _INTL("Edit the properties of trainer types."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbTrainerTypeEditor } pbFadeOutIn { pbTrainerTypeEditor }
} }
}) })
DebugMenuCommands.register("set_trainers", { MenuHandlers.add(:debug_menu, :set_trainers, {
"parent" => "editors_menu",
"name" => _INTL("Edit Individual Trainers"), "name" => _INTL("Edit Individual Trainers"),
"parent" => :editors_menu,
"description" => _INTL("Edit individual trainers, their Pokémon and items."), "description" => _INTL("Edit individual trainers, their Pokémon and items."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbTrainerBattleEditor } pbFadeOutIn { pbTrainerBattleEditor }
} }
}) })
DebugMenuCommands.register("set_items", { MenuHandlers.add(:debug_menu, :set_items, {
"parent" => "editors_menu",
"name" => _INTL("Edit Items"), "name" => _INTL("Edit Items"),
"parent" => :editors_menu,
"description" => _INTL("Edit item data."), "description" => _INTL("Edit item data."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbItemEditor } pbFadeOutIn { pbItemEditor }
} }
}) })
DebugMenuCommands.register("set_species", { MenuHandlers.add(:debug_menu, :set_species, {
"parent" => "editors_menu", "name" => _INTL("Edit Pokémon Species"),
"name" => _INTL("Edit Pokémon"), "parent" => :editors_menu,
"description" => _INTL("Edit Pokémon species data."), "description" => _INTL("Edit Pokémon species data."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbPokemonEditor } pbFadeOutIn { pbPokemonEditor }
} }
}) })
DebugMenuCommands.register("set_pokedex_lists", { MenuHandlers.add(:debug_menu, :set_pokedex_lists, {
"parent" => "editors_menu",
"name" => _INTL("Edit Regional Dexes"), "name" => _INTL("Edit Regional Dexes"),
"parent" => :editors_menu,
"description" => _INTL("Create, rearrange and delete Regional Pokédex lists."), "description" => _INTL("Create, rearrange and delete Regional Pokédex lists."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbRegionalDexEditorMain } pbFadeOutIn { pbRegionalDexEditorMain }
} }
}) })
DebugMenuCommands.register("position_sprites", { MenuHandlers.add(:debug_menu, :position_sprites, {
"parent" => "editors_menu",
"name" => _INTL("Edit Pokémon Sprite Positions"), "name" => _INTL("Edit Pokémon Sprite Positions"),
"parent" => :editors_menu,
"description" => _INTL("Reposition Pokémon sprites in battle."), "description" => _INTL("Reposition Pokémon sprites in battle."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbFadeOutIn {
sp = SpritePositioner.new sp = SpritePositioner.new
@@ -1015,11 +968,10 @@ DebugMenuCommands.register("position_sprites", {
} }
}) })
DebugMenuCommands.register("auto_position_sprites", { MenuHandlers.add(:debug_menu, :auto_position_sprites, {
"parent" => "editors_menu", "name" => _INTL("Auto-Position All Pokémon Sprites"),
"name" => _INTL("Auto-Position All Sprites"), "parent" => :editors_menu,
"description" => _INTL("Automatically reposition all Pokémon sprites in battle. Don't use lightly."), "description" => _INTL("Automatically reposition all Pokémon sprites in battle. Don't use lightly."),
"always_show" => true,
"effect" => proc { "effect" => proc {
if pbConfirmMessage(_INTL("Are you sure you want to reposition all sprites?")) if pbConfirmMessage(_INTL("Are you sure you want to reposition all sprites?"))
msgwindow = pbCreateMessageWindow msgwindow = pbCreateMessageWindow
@@ -1031,41 +983,37 @@ DebugMenuCommands.register("auto_position_sprites", {
} }
}) })
DebugMenuCommands.register("animation_editor", { MenuHandlers.add(:debug_menu, :animation_editor, {
"parent" => "editors_menu",
"name" => _INTL("Battle Animation Editor"), "name" => _INTL("Battle Animation Editor"),
"parent" => :editors_menu,
"description" => _INTL("Edit the battle animations."), "description" => _INTL("Edit the battle animations."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbAnimationEditor } pbFadeOutIn { pbAnimationEditor }
} }
}) })
DebugMenuCommands.register("animation_organiser", { MenuHandlers.add(:debug_menu, :animation_organiser, {
"parent" => "editors_menu",
"name" => _INTL("Battle Animation Organiser"), "name" => _INTL("Battle Animation Organiser"),
"parent" => :editors_menu,
"description" => _INTL("Rearrange/add/delete battle animations."), "description" => _INTL("Rearrange/add/delete battle animations."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbFadeOutIn { pbAnimationsOrganiser } pbFadeOutIn { pbAnimationsOrganiser }
} }
}) })
DebugMenuCommands.register("import_animations", { MenuHandlers.add(:debug_menu, :import_animations, {
"parent" => "editors_menu",
"name" => _INTL("Import All Battle Animations"), "name" => _INTL("Import All Battle Animations"),
"parent" => :editors_menu,
"description" => _INTL("Import all battle animations from the \"Animations\" folder."), "description" => _INTL("Import all battle animations from the \"Animations\" folder."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbImportAllAnimations pbImportAllAnimations
} }
}) })
DebugMenuCommands.register("export_animations", { MenuHandlers.add(:debug_menu, :export_animations, {
"parent" => "editors_menu",
"name" => _INTL("Export All Battle Animations"), "name" => _INTL("Export All Battle Animations"),
"parent" => :editors_menu,
"description" => _INTL("Export all battle animations individually to the \"Animations\" folder."), "description" => _INTL("Export all battle animations individually to the \"Animations\" folder."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbExportAllAnimations pbExportAllAnimations
} }
@@ -1074,48 +1022,43 @@ DebugMenuCommands.register("export_animations", {
#=============================================================================== #===============================================================================
# Other options # Other options
#=============================================================================== #===============================================================================
DebugMenuCommands.register("other_menu", { MenuHandlers.add(:debug_menu, :other_menu, {
"parent" => "main", "name" => _INTL("Other Options..."),
"name" => _INTL("Other options..."), "parent" => :main,
"description" => _INTL("Mystery Gifts, translations, compile data, etc."), "description" => _INTL("Mystery Gifts, translations, compile data, etc.")
"always_show" => true
}) })
DebugMenuCommands.register("mystery_gift", { MenuHandlers.add(:debug_menu, :mystery_gift, {
"parent" => "other_menu",
"name" => _INTL("Manage Mystery Gifts"), "name" => _INTL("Manage Mystery Gifts"),
"parent" => :other_menu,
"description" => _INTL("Edit and enable/disable Mystery Gifts."), "description" => _INTL("Edit and enable/disable Mystery Gifts."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbManageMysteryGifts pbManageMysteryGifts
} }
}) })
DebugMenuCommands.register("extract_text", { MenuHandlers.add(:debug_menu, :extract_text, {
"parent" => "other_menu",
"name" => _INTL("Extract Text"), "name" => _INTL("Extract Text"),
"parent" => :other_menu,
"description" => _INTL("Extract all text in the game to a single file for translating."), "description" => _INTL("Extract all text in the game to a single file for translating."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbExtractText pbExtractText
} }
}) })
DebugMenuCommands.register("compile_text", { MenuHandlers.add(:debug_menu, :compile_text, {
"parent" => "other_menu",
"name" => _INTL("Compile Text"), "name" => _INTL("Compile Text"),
"parent" => :other_menu,
"description" => _INTL("Import text and converts it into a language file."), "description" => _INTL("Import text and converts it into a language file."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbCompileTextUI pbCompileTextUI
} }
}) })
DebugMenuCommands.register("compile_data", { MenuHandlers.add(:debug_menu, :compile_data, {
"parent" => "other_menu",
"name" => _INTL("Compile Data"), "name" => _INTL("Compile Data"),
"parent" => :other_menu,
"description" => _INTL("Fully compile all data."), "description" => _INTL("Fully compile all data."),
"always_show" => true,
"effect" => proc { "effect" => proc {
msgwindow = pbCreateMessageWindow msgwindow = pbCreateMessageWindow
Compiler.compile_all(true) Compiler.compile_all(true)
@@ -1124,11 +1067,10 @@ DebugMenuCommands.register("compile_data", {
} }
}) })
DebugMenuCommands.register("create_pbs_files", { MenuHandlers.add(:debug_menu, :create_pbs_files, {
"parent" => "other_menu",
"name" => _INTL("Create PBS File(s)"), "name" => _INTL("Create PBS File(s)"),
"parent" => :other_menu,
"description" => _INTL("Choose one or all PBS files and create it."), "description" => _INTL("Choose one or all PBS files and create it."),
"always_show" => true,
"effect" => proc { "effect" => proc {
cmd = 0 cmd = 0
cmds = [ cmds = [
@@ -1185,21 +1127,19 @@ DebugMenuCommands.register("create_pbs_files", {
} }
}) })
DebugMenuCommands.register("fix_invalid_tiles", { MenuHandlers.add(:debug_menu, :fix_invalid_tiles, {
"parent" => "other_menu",
"name" => _INTL("Fix Invalid Tiles"), "name" => _INTL("Fix Invalid Tiles"),
"parent" => :other_menu,
"description" => _INTL("Scans all maps and erases non-existent tiles."), "description" => _INTL("Scans all maps and erases non-existent tiles."),
"always_show" => true,
"effect" => proc { "effect" => proc {
pbDebugFixInvalidTiles pbDebugFixInvalidTiles
} }
}) })
DebugMenuCommands.register("rename_files", { MenuHandlers.add(:debug_menu, :rename_files, {
"parent" => "other_menu",
"name" => _INTL("Rename Outdated Files"), "name" => _INTL("Rename Outdated Files"),
"parent" => :other_menu,
"description" => _INTL("Check for files with outdated names and rename/move them. Can alter map data."), "description" => _INTL("Check for files with outdated names and rename/move them. Can alter map data."),
"always_show" => true,
"effect" => proc { "effect" => proc {
if pbConfirmMessage(_INTL("Are you sure you want to automatically rename outdated files?")) if pbConfirmMessage(_INTL("Are you sure you want to automatically rename outdated files?"))
FilenameUpdater.rename_files FilenameUpdater.rename_files
@@ -1208,11 +1148,10 @@ DebugMenuCommands.register("rename_files", {
} }
}) })
DebugMenuCommands.register("reload_system_cache", { MenuHandlers.add(:debug_menu, :reload_system_cache, {
"parent" => "other_menu",
"name" => _INTL("Reload System Cache"), "name" => _INTL("Reload System Cache"),
"parent" => :other_menu,
"description" => _INTL("Refreshes the system's file cache. Use if you change a file while playing."), "description" => _INTL("Refreshes the system's file cache. Use if you change a file while playing."),
"always_show" => true,
"effect" => proc { "effect" => proc {
System.reload_cache System.reload_cache
pbMessage(_INTL("Done.")) pbMessage(_INTL("Done."))

View File

@@ -1,56 +1,15 @@
#===============================================================================
#
#===============================================================================
module PokemonDebugMenuCommands
@@commands = HandlerHashBasic.new
def self.register(option, hash)
@@commands.add(option, hash)
end
def self.registerIf(condition, hash)
@@commands.addIf(condition, hash)
end
def self.copy(option, *new_options)
@@commands.copy(option, *new_options)
end
def self.each
@@commands.each { |key, hash| yield key, hash }
end
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
option_hash = @@commands[option]
return (option_hash && option_hash[function]) ? option_hash[function] : nil
end
def self.call(function, option, *args)
option_hash = @@commands[option]
return nil if !option_hash || !option_hash[function]
return (option_hash[function].call(*args) == true)
end
end
#=============================================================================== #===============================================================================
# HP/Status options # HP/Status options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("hp_status_menu", { MenuHandlers.add(:pokemon_debug_menu, :hp_status_menu, {
"parent" => "main", "name" => _INTL("HP/Status..."),
"name" => _INTL("HP/Status..."), "parent" => :main
"always_show" => true
}) })
PokemonDebugMenuCommands.register("set_hp", { MenuHandlers.add(:pokemon_debug_menu, :set_hp, {
"parent" => "hp_status_menu", "name" => _INTL("Set HP"),
"name" => _INTL("Set HP"), "parent" => :hp_status_menu,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else else
@@ -69,11 +28,10 @@ PokemonDebugMenuCommands.register("set_hp", {
} }
}) })
PokemonDebugMenuCommands.register("set_status", { MenuHandlers.add(:pokemon_debug_menu, :set_status, {
"parent" => "hp_status_menu", "name" => _INTL("Set status"),
"name" => _INTL("Set status"), "parent" => :hp_status_menu,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
elsif pkmn.hp <= 0 elsif pkmn.hp <= 0
@@ -123,11 +81,10 @@ PokemonDebugMenuCommands.register("set_status", {
} }
}) })
PokemonDebugMenuCommands.register("full_heal", { MenuHandlers.add(:pokemon_debug_menu, :full_heal, {
"parent" => "hp_status_menu", "name" => _INTL("Fully heal"),
"name" => _INTL("Fully heal"), "parent" => :hp_status_menu,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else else
@@ -139,11 +96,10 @@ PokemonDebugMenuCommands.register("full_heal", {
} }
}) })
PokemonDebugMenuCommands.register("make_fainted", { MenuHandlers.add(:pokemon_debug_menu, :make_fainted, {
"parent" => "hp_status_menu", "name" => _INTL("Make fainted"),
"name" => _INTL("Make fainted"), "parent" => :hp_status_menu,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else else
@@ -154,11 +110,10 @@ PokemonDebugMenuCommands.register("make_fainted", {
} }
}) })
PokemonDebugMenuCommands.register("set_pokerus", { MenuHandlers.add(:pokemon_debug_menu, :set_pokerus, {
"parent" => "hp_status_menu", "name" => _INTL("Set Pokérus"),
"name" => _INTL("Set Pokérus"), "parent" => :hp_status_menu,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0 pokerus = (pkmn.pokerus) ? pkmn.pokerus : 0
@@ -193,17 +148,15 @@ PokemonDebugMenuCommands.register("set_pokerus", {
#=============================================================================== #===============================================================================
# Level/stats options # Level/stats options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("level_stats", { MenuHandlers.add(:pokemon_debug_menu, :level_stats, {
"parent" => "main", "name" => _INTL("Level/stats..."),
"name" => _INTL("Level/stats..."), "parent" => :main
"always_show" => true
}) })
PokemonDebugMenuCommands.register("set_level", { MenuHandlers.add(:pokemon_debug_menu, :set_level, {
"parent" => "level_stats", "name" => _INTL("Set level"),
"name" => _INTL("Set level"), "parent" => :level_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else else
@@ -223,11 +176,10 @@ PokemonDebugMenuCommands.register("set_level", {
} }
}) })
PokemonDebugMenuCommands.register("set_exp", { MenuHandlers.add(:pokemon_debug_menu, :set_exp, {
"parent" => "level_stats", "name" => _INTL("Set Exp"),
"name" => _INTL("Set Exp"), "parent" => :level_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.egg? if pkmn.egg?
screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name)) screen.pbDisplay(_INTL("{1} is an egg.", pkmn.name))
else else
@@ -253,11 +205,10 @@ PokemonDebugMenuCommands.register("set_exp", {
} }
}) })
PokemonDebugMenuCommands.register("hidden_values", { MenuHandlers.add(:pokemon_debug_menu, :hidden_values, {
"parent" => "level_stats", "name" => _INTL("EV/IV/pID..."),
"name" => _INTL("EV/IV/pID..."), "parent" => :level_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
persid = sprintf("0x%08X", pkmn.personalID) persid = sprintf("0x%08X", pkmn.personalID)
@@ -367,11 +318,10 @@ PokemonDebugMenuCommands.register("hidden_values", {
} }
}) })
PokemonDebugMenuCommands.register("set_happiness", { MenuHandlers.add(:pokemon_debug_menu, :set_happiness, {
"parent" => "level_stats", "name" => _INTL("Set happiness"),
"name" => _INTL("Set happiness"), "parent" => :level_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.happiness) params.setDefaultValue(pkmn.happiness)
@@ -386,17 +336,15 @@ PokemonDebugMenuCommands.register("set_happiness", {
} }
}) })
PokemonDebugMenuCommands.register("contest_stats", { MenuHandlers.add(:pokemon_debug_menu, :contest_stats, {
"parent" => "level_stats", "name" => _INTL("Contest stats..."),
"name" => _INTL("Contest stats..."), "parent" => :level_stats
"always_show" => true
}) })
PokemonDebugMenuCommands.register("set_beauty", { MenuHandlers.add(:pokemon_debug_menu, :set_beauty, {
"parent" => "contest_stats", "name" => _INTL("Set Beauty"),
"name" => _INTL("Set Beauty"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.beauty) params.setDefaultValue(pkmn.beauty)
@@ -411,11 +359,10 @@ PokemonDebugMenuCommands.register("set_beauty", {
} }
}) })
PokemonDebugMenuCommands.register("set_cool", { MenuHandlers.add(:pokemon_debug_menu, :set_cool, {
"parent" => "contest_stats", "name" => _INTL("Set Cool"),
"name" => _INTL("Set Cool"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.cool) params.setDefaultValue(pkmn.cool)
@@ -430,11 +377,10 @@ PokemonDebugMenuCommands.register("set_cool", {
} }
}) })
PokemonDebugMenuCommands.register("set_cute", { MenuHandlers.add(:pokemon_debug_menu, :set_cute, {
"parent" => "contest_stats", "name" => _INTL("Set Cute"),
"name" => _INTL("Set Cute"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.cute) params.setDefaultValue(pkmn.cute)
@@ -449,11 +395,10 @@ PokemonDebugMenuCommands.register("set_cute", {
} }
}) })
PokemonDebugMenuCommands.register("set_smart", { MenuHandlers.add(:pokemon_debug_menu, :set_smart, {
"parent" => "contest_stats", "name" => _INTL("Set Smart"),
"name" => _INTL("Set Smart"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.smart) params.setDefaultValue(pkmn.smart)
@@ -468,11 +413,10 @@ PokemonDebugMenuCommands.register("set_smart", {
} }
}) })
PokemonDebugMenuCommands.register("set_tough", { MenuHandlers.add(:pokemon_debug_menu, :set_tough, {
"parent" => "contest_stats", "name" => _INTL("Set Tough"),
"name" => _INTL("Set Tough"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.tough) params.setDefaultValue(pkmn.tough)
@@ -487,11 +431,10 @@ PokemonDebugMenuCommands.register("set_tough", {
} }
}) })
PokemonDebugMenuCommands.register("set_sheen", { MenuHandlers.add(:pokemon_debug_menu, :set_sheen, {
"parent" => "contest_stats", "name" => _INTL("Set Sheen"),
"name" => _INTL("Set Sheen"), "parent" => :contest_stats,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
params = ChooseNumberParams.new params = ChooseNumberParams.new
params.setRange(0, 255) params.setRange(0, 255)
params.setDefaultValue(pkmn.sheen) params.setDefaultValue(pkmn.sheen)
@@ -509,17 +452,15 @@ PokemonDebugMenuCommands.register("set_sheen", {
#=============================================================================== #===============================================================================
# Moves options # Moves options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("moves", { MenuHandlers.add(:pokemon_debug_menu, :moves, {
"parent" => "main", "name" => _INTL("Moves..."),
"name" => _INTL("Moves..."), "parent" => :main
"always_show" => true
}) })
PokemonDebugMenuCommands.register("teach_move", { MenuHandlers.add(:pokemon_debug_menu, :teach_move, {
"parent" => "moves", "name" => _INTL("Teach move"),
"name" => _INTL("Teach move"), "parent" => :moves,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
move = pbChooseMoveList move = pbChooseMoveList
if move if move
pbLearnMove(pkmn, move) pbLearnMove(pkmn, move)
@@ -529,11 +470,10 @@ PokemonDebugMenuCommands.register("teach_move", {
} }
}) })
PokemonDebugMenuCommands.register("forget_move", { MenuHandlers.add(:pokemon_debug_menu, :forget_move, {
"parent" => "moves", "name" => _INTL("Forget move"),
"name" => _INTL("Forget move"), "parent" => :moves,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
moveindex = screen.pbChooseMove(pkmn, _INTL("Choose move to forget.")) moveindex = screen.pbChooseMove(pkmn, _INTL("Choose move to forget."))
if moveindex >= 0 if moveindex >= 0
movename = pkmn.moves[moveindex].name movename = pkmn.moves[moveindex].name
@@ -545,11 +485,10 @@ PokemonDebugMenuCommands.register("forget_move", {
} }
}) })
PokemonDebugMenuCommands.register("reset_moves", { MenuHandlers.add(:pokemon_debug_menu, :reset_moves, {
"parent" => "moves", "name" => _INTL("Reset moves"),
"name" => _INTL("Reset moves"), "parent" => :moves,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pkmn.reset_moves pkmn.reset_moves
screen.pbDisplay(_INTL("{1}'s moves were reset.", pkmn.name)) screen.pbDisplay(_INTL("{1}'s moves were reset.", pkmn.name))
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
@@ -557,11 +496,10 @@ PokemonDebugMenuCommands.register("reset_moves", {
} }
}) })
PokemonDebugMenuCommands.register("set_move_pp", { MenuHandlers.add(:pokemon_debug_menu, :set_move_pp, {
"parent" => "moves", "name" => _INTL("Set move PP"),
"name" => _INTL("Set move PP"), "parent" => :moves,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
commands = [] commands = []
@@ -621,11 +559,10 @@ PokemonDebugMenuCommands.register("set_move_pp", {
} }
}) })
PokemonDebugMenuCommands.register("set_initial_moves", { MenuHandlers.add(:pokemon_debug_menu, :set_initial_moves, {
"parent" => "moves", "name" => _INTL("Reset initial moves"),
"name" => _INTL("Reset initial moves"), "parent" => :moves,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pkmn.record_first_moves pkmn.record_first_moves
screen.pbDisplay(_INTL("{1}'s moves were set as its first-known moves.", pkmn.name)) screen.pbDisplay(_INTL("{1}'s moves were set as its first-known moves.", pkmn.name))
screen.pbRefreshSingle(pkmnid) screen.pbRefreshSingle(pkmnid)
@@ -636,11 +573,10 @@ PokemonDebugMenuCommands.register("set_initial_moves", {
#=============================================================================== #===============================================================================
# Other options # Other options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("set_item", { MenuHandlers.add(:pokemon_debug_menu, :set_item, {
"parent" => "main", "name" => _INTL("Set item"),
"name" => _INTL("Set item"), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
commands = [ commands = [
_INTL("Change item"), _INTL("Change item"),
@@ -674,11 +610,10 @@ PokemonDebugMenuCommands.register("set_item", {
} }
}) })
PokemonDebugMenuCommands.register("set_ability", { MenuHandlers.add(:pokemon_debug_menu, :set_ability, {
"parent" => "main", "name" => _INTL("Set ability"),
"name" => _INTL("Set ability"), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
commands = [ commands = [
_INTL("Set possible ability"), _INTL("Set possible ability"),
@@ -723,11 +658,10 @@ PokemonDebugMenuCommands.register("set_ability", {
} }
}) })
PokemonDebugMenuCommands.register("set_nature", { MenuHandlers.add(:pokemon_debug_menu, :set_nature, {
"parent" => "main", "name" => _INTL("Set nature"),
"name" => _INTL("Set nature"), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
commands = [] commands = []
ids = [] ids = []
GameData::Nature.each do |nature| GameData::Nature.each do |nature|
@@ -766,11 +700,10 @@ PokemonDebugMenuCommands.register("set_nature", {
} }
}) })
PokemonDebugMenuCommands.register("set_gender", { MenuHandlers.add(:pokemon_debug_menu, :set_gender, {
"parent" => "main", "name" => _INTL("Set gender"),
"name" => _INTL("Set gender"), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if pkmn.singleGendered? if pkmn.singleGendered?
screen.pbDisplay(_INTL("{1} is single-gendered or genderless.", pkmn.speciesName)) screen.pbDisplay(_INTL("{1} is single-gendered or genderless.", pkmn.speciesName))
else else
@@ -804,11 +737,10 @@ PokemonDebugMenuCommands.register("set_gender", {
} }
}) })
PokemonDebugMenuCommands.register("species_and_form", { MenuHandlers.add(:pokemon_debug_menu, :species_and_form, {
"parent" => "main", "name" => _INTL("Species/form..."),
"name" => _INTL("Species/form..."), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
msg = [_INTL("Species {1}, form {2}.", pkmn.speciesName, pkmn.form), msg = [_INTL("Species {1}, form {2}.", pkmn.speciesName, pkmn.form),
@@ -867,17 +799,15 @@ PokemonDebugMenuCommands.register("species_and_form", {
#=============================================================================== #===============================================================================
# Cosmetic options # Cosmetic options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("cosmetic", { MenuHandlers.add(:pokemon_debug_menu, :cosmetic, {
"parent" => "main", "name" => _INTL("Cosmetic info..."),
"name" => _INTL("Cosmetic info..."), "parent" => :main
"always_show" => true
}) })
PokemonDebugMenuCommands.register("set_shininess", { MenuHandlers.add(:pokemon_debug_menu, :set_shininess, {
"parent" => "cosmetic", "name" => _INTL("Set shininess"),
"name" => _INTL("Set shininess"), "parent" => :cosmetic,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
msg_idx = pkmn.shiny? ? (pkmn.super_shiny? ? 1 : 0) : 2 msg_idx = pkmn.shiny? ? (pkmn.super_shiny? ? 1 : 0) : 2
@@ -905,11 +835,10 @@ PokemonDebugMenuCommands.register("set_shininess", {
} }
}) })
PokemonDebugMenuCommands.register("set_pokeball", { MenuHandlers.add(:pokemon_debug_menu, :set_pokeball, {
"parent" => "cosmetic", "name" => _INTL("Set Poké Ball"),
"name" => _INTL("Set Poké Ball"), "parent" => :cosmetic,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
commands = [] commands = []
balls = [] balls = []
GameData::Item.each do |item_data| GameData::Item.each do |item_data|
@@ -933,11 +862,10 @@ PokemonDebugMenuCommands.register("set_pokeball", {
} }
}) })
PokemonDebugMenuCommands.register("set_ribbons", { MenuHandlers.add(:pokemon_debug_menu, :set_ribbons, {
"parent" => "cosmetic", "name" => _INTL("Set ribbons"),
"name" => _INTL("Set ribbons"), "parent" => :cosmetic,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
commands = [] commands = []
@@ -969,11 +897,10 @@ PokemonDebugMenuCommands.register("set_ribbons", {
} }
}) })
PokemonDebugMenuCommands.register("set_nickname", { MenuHandlers.add(:pokemon_debug_menu, :set_nickname, {
"parent" => "cosmetic", "name" => _INTL("Set nickname"),
"name" => _INTL("Set nickname"), "parent" => :cosmetic,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
speciesname = pkmn.speciesName speciesname = pkmn.speciesName
@@ -997,11 +924,10 @@ PokemonDebugMenuCommands.register("set_nickname", {
} }
}) })
PokemonDebugMenuCommands.register("ownership", { MenuHandlers.add(:pokemon_debug_menu, :ownership, {
"parent" => "cosmetic", "name" => _INTL("Ownership..."),
"name" => _INTL("Ownership..."), "parent" => :cosmetic,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
gender = [_INTL("Male"), _INTL("Female"), _INTL("Unknown")][pkmn.owner.gender] gender = [_INTL("Male"), _INTL("Female"), _INTL("Unknown")][pkmn.owner.gender]
@@ -1044,11 +970,10 @@ PokemonDebugMenuCommands.register("ownership", {
#=============================================================================== #===============================================================================
# Can store/release/trade # Can store/release/trade
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("set_discardable", { MenuHandlers.add(:pokemon_debug_menu, :set_discardable, {
"parent" => "main", "name" => _INTL("Set discardable"),
"name" => _INTL("Set discardable"), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
msg = _INTL("Click option to toggle.") msg = _INTL("Click option to toggle.")
@@ -1074,10 +999,10 @@ PokemonDebugMenuCommands.register("set_discardable", {
#=============================================================================== #===============================================================================
# Other options # Other options
#=============================================================================== #===============================================================================
PokemonDebugMenuCommands.register("set_egg", { MenuHandlers.add(:pokemon_debug_menu, :set_egg, {
"parent" => "main",
"name" => _INTL("Set egg"), "name" => _INTL("Set egg"),
"always_show" => true, "parent" => :main,
"always_show" => false,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
@@ -1116,11 +1041,10 @@ PokemonDebugMenuCommands.register("set_egg", {
} }
}) })
PokemonDebugMenuCommands.register("shadow_pkmn", { MenuHandlers.add(:pokemon_debug_menu, :shadow_pkmn, {
"parent" => "main", "name" => _INTL("Shadow Pkmn..."),
"name" => _INTL("Shadow Pkmn..."), "parent" => :main,
"always_show" => true, "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
cmd = 0 cmd = 0
loop do loop do
msg = [_INTL("Not a Shadow Pokémon."), msg = [_INTL("Not a Shadow Pokémon."),
@@ -1158,65 +1082,64 @@ PokemonDebugMenuCommands.register("shadow_pkmn", {
} }
}) })
PokemonDebugMenuCommands.register("mystery_gift", { MenuHandlers.add(:pokemon_debug_menu, :mystery_gift, {
"parent" => "main",
"name" => _INTL("Mystery Gift"), "name" => _INTL("Mystery Gift"),
"parent" => :main,
"always_show" => false,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
pbCreateMysteryGift(0, pkmn) pbCreateMysteryGift(0, pkmn)
next false next false
} }
}) })
PokemonDebugMenuCommands.register("duplicate", { MenuHandlers.add(:pokemon_debug_menu, :duplicate, {
"parent" => "main",
"name" => _INTL("Duplicate"), "name" => _INTL("Duplicate"),
"parent" => :main,
"always_show" => false,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if screen.pbConfirm(_INTL("Are you sure you want to copy this Pokémon?")) next false if !screen.pbConfirm(_INTL("Are you sure you want to copy this Pokémon?"))
clonedpkmn = pkmn.clone clonedpkmn = pkmn.clone
case screen case screen
when PokemonPartyScreen when PokemonPartyScreen
pbStorePokemon(clonedpkmn) pbStorePokemon(clonedpkmn)
screen.pbHardRefresh screen.pbHardRefresh
screen.pbDisplay(_INTL("The Pokémon was duplicated.")) screen.pbDisplay(_INTL("The Pokémon was duplicated."))
when PokemonStorageScreen when PokemonStorageScreen
if screen.storage.pbMoveCaughtToParty(clonedpkmn) if screen.storage.pbMoveCaughtToParty(clonedpkmn)
if pkmnid[0] != -1 if pkmnid[0] != -1
screen.pbDisplay(_INTL("The duplicated Pokémon was moved to your party.")) screen.pbDisplay(_INTL("The duplicated Pokémon was moved to your party."))
end end
else else
oldbox = screen.storage.currentBox oldbox = screen.storage.currentBox
newbox = screen.storage.pbStoreCaught(clonedpkmn) newbox = screen.storage.pbStoreCaught(clonedpkmn)
if newbox < 0 if newbox < 0
screen.pbDisplay(_INTL("All boxes are full.")) screen.pbDisplay(_INTL("All boxes are full."))
elsif newbox != oldbox elsif newbox != oldbox
screen.pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"", screen.storage[newbox].name)) screen.pbDisplay(_INTL("The duplicated Pokémon was moved to box \"{1}.\"", screen.storage[newbox].name))
screen.storage.currentBox = oldbox screen.storage.currentBox = oldbox
end
end end
screen.pbHardRefresh
end end
next true screen.pbHardRefresh
end end
next false next true
} }
}) })
PokemonDebugMenuCommands.register("delete", { MenuHandlers.add(:pokemon_debug_menu, :delete, {
"parent" => "main",
"name" => _INTL("Delete"), "name" => _INTL("Delete"),
"parent" => :main,
"always_show" => false,
"effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen| "effect" => proc { |pkmn, pkmnid, heldpoke, settingUpBattle, screen|
if screen.pbConfirm(_INTL("Are you sure you want to delete this Pokémon?")) next false if !screen.pbConfirm(_INTL("Are you sure you want to delete this Pokémon?"))
case screen case screen
when PokemonPartyScreen when PokemonPartyScreen
screen.party.delete_at(pkmnid) screen.party.delete_at(pkmnid)
screen.pbHardRefresh screen.pbHardRefresh
when PokemonStorageScreen when PokemonStorageScreen
screen.scene.pbRelease(pkmnid, heldpoke) screen.scene.pbRelease(pkmnid, heldpoke)
(heldpoke) ? screen.heldpkmn = nil : screen.storage.pbDelete(pkmnid[0], pkmnid[1]) (heldpoke) ? screen.heldpkmn = nil : screen.storage.pbDelete(pkmnid[0], pkmnid[1])
screen.scene.pbRefresh screen.scene.pbRefresh
end
next true
end end
next false next true
} }
}) })

View File

@@ -20,60 +20,19 @@ Choose each battler's next action.
=end =end
#===============================================================================
#
#===============================================================================
module BattleDebugMenuCommands
@@commands = HandlerHashBasic.new
def self.register(option, hash)
@@commands.add(option, hash)
end
def self.registerIf(condition, hash)
@@commands.addIf(condition, hash)
end
def self.copy(option, *new_options)
@@commands.copy(option, *new_options)
end
def self.each
@@commands.each { |key, hash| yield key, hash }
end
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
option_hash = @@commands[option]
return (option_hash && option_hash[function]) ? option_hash[function] : nil
end
def self.call(function, option, *args)
option_hash = @@commands[option]
return nil if !option_hash || !option_hash[function]
return (option_hash[function].call(*args) == true)
end
end
#=============================================================================== #===============================================================================
# Battler Options # Battler Options
#=============================================================================== #===============================================================================
BattleDebugMenuCommands.register("battlers", { MenuHandlers.add(:battle_debug_menu, :battlers, {
"parent" => "main",
"name" => _INTL("Battlers..."), "name" => _INTL("Battlers..."),
"description" => _INTL("Look at Pokémon in battle and change their properties."), "parent" => :main,
"always_show" => true "description" => _INTL("Look at Pokémon in battle and change their properties.")
}) })
BattleDebugMenuCommands.register("list_player_battlers", { MenuHandlers.add(:battle_debug_menu, :list_player_battlers, {
"parent" => "battlers",
"name" => _INTL("Player-Side Battlers"), "name" => _INTL("Player-Side Battlers"),
"parent" => :battlers,
"description" => _INTL("Edit Pokémon on the player's side of battle."), "description" => _INTL("Edit Pokémon on the player's side of battle."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
battlers = [] battlers = []
cmds = [] cmds = []
@@ -96,11 +55,10 @@ BattleDebugMenuCommands.register("list_player_battlers", {
} }
}) })
BattleDebugMenuCommands.register("list_foe_battlers", { MenuHandlers.add(:battle_debug_menu, :list_foe_battlers, {
"parent" => "battlers",
"name" => _INTL("Foe-Side Battlers"), "name" => _INTL("Foe-Side Battlers"),
"parent" => :battlers,
"description" => _INTL("Edit Pokémon on the opposing side of battle."), "description" => _INTL("Edit Pokémon on the opposing side of battle."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
battlers = [] battlers = []
cmds = [] cmds = []
@@ -120,18 +78,16 @@ BattleDebugMenuCommands.register("list_foe_battlers", {
#=============================================================================== #===============================================================================
# Field Options # Field Options
#=============================================================================== #===============================================================================
BattleDebugMenuCommands.register("field", { MenuHandlers.add(:battle_debug_menu, :field, {
"parent" => "main",
"name" => _INTL("Field Effects..."), "name" => _INTL("Field Effects..."),
"parent" => :main,
"description" => _INTL("Effects that apply to the whole battlefield."), "description" => _INTL("Effects that apply to the whole battlefield."),
"always_show" => true
}) })
BattleDebugMenuCommands.register("weather", { MenuHandlers.add(:battle_debug_menu, :weather, {
"parent" => "field",
"name" => _INTL("Weather"), "name" => _INTL("Weather"),
"parent" => :field,
"description" => _INTL("Set weather and duration."), "description" => _INTL("Set weather and duration."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
weather_types = [] weather_types = []
weather_cmds = [] weather_cmds = []
@@ -190,11 +146,10 @@ BattleDebugMenuCommands.register("weather", {
} }
}) })
BattleDebugMenuCommands.register("terrain", { MenuHandlers.add(:battle_debug_menu, :terrain, {
"parent" => "field",
"name" => _INTL("Terrain"), "name" => _INTL("Terrain"),
"parent" => :field,
"description" => _INTL("Set terrain and duration."), "description" => _INTL("Set terrain and duration."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
terrain_types = [] terrain_types = []
terrain_cmds = [] terrain_cmds = []
@@ -253,11 +208,10 @@ BattleDebugMenuCommands.register("terrain", {
} }
}) })
BattleDebugMenuCommands.register("environment", { MenuHandlers.add(:battle_debug_menu, :environment_time, {
"parent" => "field",
"name" => _INTL("Environment/Time"), "name" => _INTL("Environment/Time"),
"parent" => :field,
"description" => _INTL("Set the battle's environment and time of day."), "description" => _INTL("Set the battle's environment and time of day."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
environment_types = [] environment_types = []
environment_cmds = [] environment_cmds = []
@@ -292,11 +246,10 @@ BattleDebugMenuCommands.register("environment", {
} }
}) })
BattleDebugMenuCommands.register("backdrop", { MenuHandlers.add(:battle_debug_menu, :backdrop, {
"parent" => "field",
"name" => _INTL("Backdrop Names"), "name" => _INTL("Backdrop Names"),
"parent" => :field,
"description" => _INTL("Set the names of the backdrop and base graphics."), "description" => _INTL("Set the names of the backdrop and base graphics."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
loop do loop do
cmd = pbMessage("\\ts[]" + _INTL("Set which backdrop name?"), cmd = pbMessage("\\ts[]" + _INTL("Set which backdrop name?"),
@@ -317,11 +270,10 @@ BattleDebugMenuCommands.register("backdrop", {
} }
}) })
BattleDebugMenuCommands.register("set_field_effects", { MenuHandlers.add(:battle_debug_menu, :set_field_effects, {
"parent" => "field",
"name" => _INTL("Other Field Effects..."), "name" => _INTL("Other Field Effects..."),
"parent" => :field,
"description" => _INTL("View/set other effects that apply to the whole battlefield."), "description" => _INTL("View/set other effects that apply to the whole battlefield."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
editor = Battle::DebugSetEffects.new(battle, :field) editor = Battle::DebugSetEffects.new(battle, :field)
editor.update editor.update
@@ -329,11 +281,10 @@ BattleDebugMenuCommands.register("set_field_effects", {
} }
}) })
BattleDebugMenuCommands.register("player_side", { MenuHandlers.add(:battle_debug_menu, :player_side, {
"parent" => "field",
"name" => _INTL("Player's Side Effects..."), "name" => _INTL("Player's Side Effects..."),
"parent" => :field,
"description" => _INTL("Effects that apply to the side the player is on."), "description" => _INTL("Effects that apply to the side the player is on."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
editor = Battle::DebugSetEffects.new(battle, :side, 0) editor = Battle::DebugSetEffects.new(battle, :side, 0)
editor.update editor.update
@@ -341,11 +292,10 @@ BattleDebugMenuCommands.register("player_side", {
} }
}) })
BattleDebugMenuCommands.register("opposing_side", { MenuHandlers.add(:battle_debug_menu, :opposing_side, {
"parent" => "field",
"name" => _INTL("Foe's Side Effects..."), "name" => _INTL("Foe's Side Effects..."),
"parent" => :field,
"description" => _INTL("Effects that apply to the opposing side."), "description" => _INTL("Effects that apply to the opposing side."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
editor = Battle::DebugSetEffects.new(battle, :side, 1) editor = Battle::DebugSetEffects.new(battle, :side, 1)
editor.update editor.update
@@ -356,18 +306,16 @@ BattleDebugMenuCommands.register("opposing_side", {
#=============================================================================== #===============================================================================
# Trainer Options # Trainer Options
#=============================================================================== #===============================================================================
BattleDebugMenuCommands.register("trainers", { MenuHandlers.add(:battle_debug_menu, :trainers, {
"parent" => "main",
"name" => _INTL("Trainer Options..."), "name" => _INTL("Trainer Options..."),
"description" => _INTL("Variables that apply to trainers."), "parent" => :main,
"always_show" => true "description" => _INTL("Variables that apply to trainers.")
}) })
BattleDebugMenuCommands.register("mega_evolution", { MenuHandlers.add(:battle_debug_menu, :mega_evolution, {
"parent" => "trainers",
"name" => _INTL("Mega Evolution"), "name" => _INTL("Mega Evolution"),
"parent" => :trainers,
"description" => _INTL("Whether each trainer is allowed to Mega Evolve."), "description" => _INTL("Whether each trainer is allowed to Mega Evolve."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
cmd = 0 cmd = 0
loop do loop do
@@ -399,11 +347,10 @@ BattleDebugMenuCommands.register("mega_evolution", {
} }
}) })
BattleDebugMenuCommands.register("speed_order", { MenuHandlers.add(:battle_debug_menu, :speed_order, {
"parent" => "main",
"name" => _INTL("Battler Speed Order"), "name" => _INTL("Battler Speed Order"),
"parent" => :main,
"description" => _INTL("Show all battlers in order from fastest to slowest."), "description" => _INTL("Show all battlers in order from fastest to slowest."),
"always_show" => true,
"effect" => proc { |battle| "effect" => proc { |battle|
battlers = battle.allBattlers.map { |b| [b, b.pbSpeed] } battlers = battle.allBattlers.map { |b| [b, b.pbSpeed] }
battlers.sort! { |a, b| b[1] <=> a[1] } battlers.sort! { |a, b| b[1] <=> a[1] }

View File

@@ -8,57 +8,18 @@ Actual stats? @attack, @defense, etc.
=end =end
#===============================================================================
#
#===============================================================================
module BattlePokemonDebugMenuCommands
@@commands = HandlerHashBasic.new
def self.register(option, hash)
@@commands.add(option, hash)
end
def self.registerIf(condition, hash)
@@commands.addIf(condition, hash)
end
def self.copy(option, *new_options)
@@commands.copy(option, *new_options)
end
def self.each
@@commands.each { |key, hash| yield key, hash }
end
def self.hasFunction?(option, function)
option_hash = @@commands[option]
return option_hash&.has_key?(function)
end
def self.getFunction(option, function)
option_hash = @@commands[option]
return (option_hash && option_hash[function]) ? option_hash[function] : nil
end
def self.call(function, option, *args)
option_hash = @@commands[option]
return nil if !option_hash || !option_hash[function]
return (option_hash[function].call(*args) == true)
end
end
#=============================================================================== #===============================================================================
# HP/Status options # HP/Status options
#=============================================================================== #===============================================================================
BattlePokemonDebugMenuCommands.register("hp_status_menu", { MenuHandlers.add(:battle_pokemon_debug_menu, :hp_status_menu, {
"parent" => "main",
"name" => _INTL("HP/Status..."), "name" => _INTL("HP/Status..."),
"parent" => :main,
"usage" => :both "usage" => :both
}) })
BattlePokemonDebugMenuCommands.register("set_hp", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_hp, {
"parent" => "hp_status_menu",
"name" => _INTL("Set HP"), "name" => _INTL("Set HP"),
"parent" => :hp_status_menu,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -79,9 +40,9 @@ BattlePokemonDebugMenuCommands.register("set_hp", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_status", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_status, {
"parent" => "hp_status_menu",
"name" => _INTL("Set status"), "name" => _INTL("Set status"),
"parent" => :hp_status_menu,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -156,9 +117,9 @@ BattlePokemonDebugMenuCommands.register("set_status", {
} }
}) })
BattlePokemonDebugMenuCommands.register("full_heal", { MenuHandlers.add(:battle_pokemon_debug_menu, :full_heal, {
"parent" => "hp_status_menu",
"name" => _INTL("Heal HP and status"), "name" => _INTL("Heal HP and status"),
"parent" => :hp_status_menu,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -178,15 +139,15 @@ BattlePokemonDebugMenuCommands.register("full_heal", {
#=============================================================================== #===============================================================================
# Level/stats options # Level/stats options
#=============================================================================== #===============================================================================
BattlePokemonDebugMenuCommands.register("level_stats", { MenuHandlers.add(:battle_pokemon_debug_menu, :level_stats, {
"parent" => "main",
"name" => _INTL("Stats/level..."), "name" => _INTL("Stats/level..."),
"parent" => :main,
"usage" => :both "usage" => :both
}) })
BattlePokemonDebugMenuCommands.register("set_stat_stages", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_stat_stages, {
"parent" => "level_stats",
"name" => _INTL("Set stat stages"), "name" => _INTL("Set stat stages"),
"parent" => :level_stats,
"usage" => :battler, "usage" => :battler,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -223,9 +184,9 @@ BattlePokemonDebugMenuCommands.register("set_stat_stages", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_level", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_level, {
"parent" => "level_stats",
"name" => _INTL("Set level"), "name" => _INTL("Set level"),
"parent" => :level_stats,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -246,9 +207,9 @@ BattlePokemonDebugMenuCommands.register("set_level", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_exp", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_exp, {
"parent" => "level_stats",
"name" => _INTL("Set Exp"), "name" => _INTL("Set Exp"),
"parent" => :level_stats,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.egg? if pkmn.egg?
@@ -271,9 +232,9 @@ BattlePokemonDebugMenuCommands.register("set_exp", {
} }
}) })
BattlePokemonDebugMenuCommands.register("hidden_values", { MenuHandlers.add(:battle_pokemon_debug_menu, :hidden_values, {
"parent" => "level_stats",
"name" => _INTL("EV/IV..."), "name" => _INTL("EV/IV..."),
"parent" => :level_stats,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -378,9 +339,9 @@ BattlePokemonDebugMenuCommands.register("hidden_values", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_happiness", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_happiness, {
"parent" => "level_stats",
"name" => _INTL("Set happiness"), "name" => _INTL("Set happiness"),
"parent" => :level_stats,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
params = ChooseNumberParams.new params = ChooseNumberParams.new
@@ -394,9 +355,9 @@ BattlePokemonDebugMenuCommands.register("set_happiness", {
#=============================================================================== #===============================================================================
# Types # Types
#=============================================================================== #===============================================================================
BattlePokemonDebugMenuCommands.register("set_types", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_types, {
"parent" => "main",
"name" => _INTL("Set types"), "name" => _INTL("Set types"),
"parent" => :main,
"usage" => :battler, "usage" => :battler,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
max_main_types = 2 # The most types a Pokémon can have normally max_main_types = 2 # The most types a Pokémon can have normally
@@ -443,15 +404,15 @@ BattlePokemonDebugMenuCommands.register("set_types", {
#=============================================================================== #===============================================================================
# Moves options # Moves options
#=============================================================================== #===============================================================================
BattlePokemonDebugMenuCommands.register("moves", { MenuHandlers.add(:battle_pokemon_debug_menu, :moves, {
"parent" => "main",
"name" => _INTL("Moves..."), "name" => _INTL("Moves..."),
"parent" => :main,
"usage" => :both "usage" => :both
}) })
BattlePokemonDebugMenuCommands.register("teach_move", { MenuHandlers.add(:battle_pokemon_debug_menu, :teach_move, {
"parent" => "moves",
"name" => _INTL("Teach move"), "name" => _INTL("Teach move"),
"parent" => :moves,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.numMoves >= Pokemon::MAX_MOVES if pkmn.numMoves >= Pokemon::MAX_MOVES
@@ -472,9 +433,9 @@ BattlePokemonDebugMenuCommands.register("teach_move", {
} }
}) })
BattlePokemonDebugMenuCommands.register("forget_move", { MenuHandlers.add(:battle_pokemon_debug_menu, :forget_move, {
"parent" => "moves",
"name" => _INTL("Forget move"), "name" => _INTL("Forget move"),
"parent" => :moves,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
move_names = [] move_names = []
@@ -497,9 +458,9 @@ BattlePokemonDebugMenuCommands.register("forget_move", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_move_pp", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_move_pp, {
"parent" => "moves",
"name" => _INTL("Set move PP"), "name" => _INTL("Set move PP"),
"parent" => :moves,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -575,9 +536,9 @@ BattlePokemonDebugMenuCommands.register("set_move_pp", {
#=============================================================================== #===============================================================================
# Other options # Other options
#=============================================================================== #===============================================================================
BattlePokemonDebugMenuCommands.register("set_item", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_item, {
"parent" => "main",
"name" => _INTL("Set item"), "name" => _INTL("Set item"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -610,9 +571,9 @@ BattlePokemonDebugMenuCommands.register("set_item", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_ability", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_ability, {
"parent" => "main",
"name" => _INTL("Set ability"), "name" => _INTL("Set ability"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -651,9 +612,9 @@ BattlePokemonDebugMenuCommands.register("set_ability", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_nature", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_nature, {
"parent" => "main",
"name" => _INTL("Set nature"), "name" => _INTL("Set nature"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
commands = [] commands = []
@@ -693,9 +654,9 @@ BattlePokemonDebugMenuCommands.register("set_nature", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_gender", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_gender, {
"parent" => "main",
"name" => _INTL("Set gender"), "name" => _INTL("Set gender"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
if pkmn.singleGendered? if pkmn.singleGendered?
@@ -722,9 +683,9 @@ BattlePokemonDebugMenuCommands.register("set_gender", {
} }
}) })
BattlePokemonDebugMenuCommands.register("form", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_form, {
"parent" => "main",
"name" => _INTL("Set form"), "name" => _INTL("Set form"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -759,9 +720,9 @@ BattlePokemonDebugMenuCommands.register("form", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_shininess", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_shininess, {
"parent" => "main",
"name" => _INTL("Set shininess"), "name" => _INTL("Set shininess"),
"parent" => :main,
"usage" => :both, "usage" => :both,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
cmd = 0 cmd = 0
@@ -791,9 +752,9 @@ BattlePokemonDebugMenuCommands.register("set_shininess", {
} }
}) })
BattlePokemonDebugMenuCommands.register("set_effects", { MenuHandlers.add(:battle_pokemon_debug_menu, :set_effects, {
"parent" => "main",
"name" => _INTL("Set effects"), "name" => _INTL("Set effects"),
"parent" => :main,
"usage" => :battler, "usage" => :battler,
"effect" => proc { |pkmn, battler, battle| "effect" => proc { |pkmn, battler, battle|
editor = Battle::DebugSetEffects.new(battle, :battler, battler.index) editor = Battle::DebugSetEffects.new(battle, :battler, battler.index)