Rewrote party screen debug code, misc code changes

This commit is contained in:
Maruno17
2024-10-01 19:10:34 +01:00
parent fc538a09f7
commit 61b6bb5aeb
14 changed files with 731 additions and 854 deletions

View File

@@ -159,7 +159,7 @@ module PokemonDebugMixin
# Main loop
command = 0
loop do
command = pbShowCommands(_INTL("Do what with {1}?", pkmn.name), commands.list, command)
command = show_menu(_INTL("Do what with {1}?", pkmn.name), commands.list, command)
if command < 0
parent = commands.getParent
break if !parent
@@ -422,8 +422,41 @@ end
#===============================================================================
#
#===============================================================================
class PokemonDebugPartyScreen
class UI::PartyDebugVisuals < UI::BaseVisuals
def initialize_background; end
def initialize_overlay; end
def choose_number(help_text, maximum, init_value = 1)
old_letter_by_letter = @sprites[:speech_box].letterbyletter
@sprites[:speech_box].letterbyletter = false
ret = super
@sprites[:speech_box].letterbyletter = old_letter_by_letter
return ret
end
end
class UI::PartyDebug < UI::BaseScreen
include PokemonDebugMixin
def initialize_visuals
@visuals = UI::PartyDebugVisuals.new
end
def choose_move(pkmn, message, index = 0)
# TODO: The move names can get rather wide, making the message box rather
# thin. It's just about acceptable, but maybe the choice window needs
# to be displayed above the message box instead of to the right of it.
move_names = []
pkmn.moves.each do |move|
next if !move || !move.id
if move.total_pp <= 0
move_names.push(_INTL("{1} (PP: ---)", move.name))
else
move_names.push(_INTL("{1} (PP: {2}/{3})", move.name, move.pp, move.total_pp))
end
end
return show_menu(message, move_names, index)
end
end
#===============================================================================

View File

@@ -354,9 +354,9 @@ MenuHandlers.add(:debug_menu, :test_wild_battle_advanced, {
end
else # Edit a Pokémon
if pbConfirmMessage(_INTL("Change this Pokémon?"))
scr = PokemonDebugPartyScreen.new
scr = UI::PartyDebug.new
scr.pokemon_debug_menu(pkmn[pkmnCmd], -1, nil, true)
scr.pbEndScreen
scr.silent_end_screen
elsif pbConfirmMessage(_INTL("Delete this Pokémon?"))
pkmn.delete_at(pkmnCmd)
size0 = [pkmn.length, 1].max

View File

@@ -762,134 +762,3 @@ def pbCheckTileValidity(tile_id, map, tilesets, passages)
end
return false
end
#===============================================================================
# Pseudo-party screen for editing Pokémon being set up for a wild battle.
# TODO: Rewrite this with the new UI code.
#===============================================================================
class PokemonDebugPartyScreen
def initialize
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@messageBox = Window_AdvancedTextPokemon.new("")
@messageBox.viewport = @viewport
@messageBox.visible = false
@messageBox.letterbyletter = true
pbBottomLeftLines(@messageBox, 2)
@helpWindow = Window_UnformattedTextPokemon.new("")
@helpWindow.viewport = @viewport
@helpWindow.visible = true
pbBottomLeftLines(@helpWindow, 1)
end
def pbEndScreen
@messageBox.dispose
@helpWindow.dispose
@viewport.dispose
end
def pbDisplay(text)
@messageBox.text = text
@messageBox.visible = true
@helpWindow.visible = false
pbPlayDecisionSE
loop do
Graphics.update
Input.update
pbUpdate
if @messageBox.busy?
if Input.trigger?(Input::USE)
pbPlayDecisionSE if @messageBox.pausing?
@messageBox.resume
end
else
if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
break
end
end
end
@messageBox.visible = false
@helpWindow.visible = true
end
def pbConfirm(text)
ret = -1
@messageBox.text = text
@messageBox.visible = true
@helpWindow.visible = false
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do
cmdwindow.visible = false
pbBottomRight(cmdwindow)
cmdwindow.y -= @messageBox.height
cmdwindow.z = @viewport.z + 1
loop do
Graphics.update
Input.update
cmdwindow.visible = true if !@messageBox.busy?
cmdwindow.update
pbUpdate
if !@messageBox.busy?
if Input.trigger?(Input::BACK)
ret = false
break
elsif Input.trigger?(Input::USE) && @messageBox.resume
ret = (cmdwindow.index == 0)
break
end
end
end
end
@messageBox.visible = false
@helpWindow.visible = true
return ret
end
def pbShowCommands(text, commands, index = 0)
ret = -1
@helpWindow.visible = true
using(cmdwindow = Window_CommandPokemonColor.new(commands)) do
cmdwindow.z = @viewport.z + 1
cmdwindow.index = index
pbBottomRight(cmdwindow)
@helpWindow.resizeHeightToFit(text, Graphics.width - cmdwindow.width)
@helpWindow.text = text
pbBottomLeft(@helpWindow)
loop do
Graphics.update
Input.update
cmdwindow.update
pbUpdate
if Input.trigger?(Input::BACK)
pbPlayCancelSE
ret = -1
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = cmdwindow.index
break
end
end
end
return ret
end
def pbChooseMove(pkmn, text, index = 0)
moveNames = []
pkmn.moves.each do |i|
if i.total_pp <= 0
moveNames.push(_INTL("{1} (PP: ---)", i.name))
else
moveNames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp))
end
end
return pbShowCommands(text, moveNames, index)
end
def pbRefreshSingle(index); end
def update
@messageBox.update
@helpWindow.update
end
alias pbUpdate update
end