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

@@ -361,11 +361,15 @@ module UI
#---------------------------------------------------------------------------
def fade_in
pbFadeInAndShow(@sprites)# { update_visuals }
# TODO: pbFadeInAndShow changes the colour of all sprites. Make it instead
# change the opacity of @viewport like def pbFadeOutIn.
pbFadeInAndShow(@sprites)
end
def fade_out
pbFadeOutAndHide(@sprites)# { update_visuals }
# TODO: pbFadeOutAndHide changes the colour of all sprites. Make it
# instead change the opacity of @viewport like def pbFadeOutIn.
pbFadeOutAndHide(@sprites)
end
def dispose
@@ -490,7 +494,9 @@ module UI
end
end
@sprites[:speech_box].visible = false
ret = options.keys[ret] if options.is_a?(Hash)
if options.is_a?(Hash)
ret = (ret < 0) ? nil : options.keys[ret]
end
return ret
end

View File

@@ -1,6 +1,6 @@
# TODO: Rewrite def pbUseItemOnPokemon and all the ItemHandlers to stop using
# pbDisplay and whatnot, and ensure they do whatever is appropriate when
# being called with a screen of UI::Party.
# TODO: Rewrite all the ItemHandlers to stop using pbDisplay and whatnot, and
# ensure they do whatever is appropriate when being called with a screen
# of UI::Party.
#===============================================================================
#
#===============================================================================
@@ -223,6 +223,7 @@ class UI::PartyVisualsPanel < UI::SpriteContainer
bar_total_width = 96
bar_width = [@pokemon.hp * bar_total_width / @pokemon.totalhp.to_f, 1.0].max
bar_width = ((bar_width / 2).round) * 2 # Make the bar's length a multiple of 2 pixels
bar_width -= 2 if bar_width == bar_total_width && @pokemon.hp < @pokemon.totalhp
hp_zone = 0 # Green
hp_zone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor # Yellow
hp_zone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor # Red
@@ -344,8 +345,8 @@ class UI::PartyVisuals < UI::BaseVisuals
def initialize_message_box
super
@sprites[:help_window] = Window_AdvancedTextPokemon.new("")
@sprites[:help_window].viewport = @viewport
@sprites[:help_window].z = 1500
@sprites[:help_window].viewport = @viewport
@sprites[:help_window].z = 1500
@sprites[:help_window].setSkin(MessageConfig.pbGetSpeechFrame)
pbBottomLeftLines(@sprites[:help_window], 1, 396)
end
@@ -657,13 +658,9 @@ class UI::PartyVisuals < UI::BaseVisuals
pbPlayCloseMenuSE
return :quit
elsif @sub_mode == :switch_pokemon
pbPlayDecisionSE
return :switch_pokemon_start
elsif @sub_mode == :switch_items
if @party[@index].hasItem?
pbPlayDecisionSE
return :item_move
end
return :item_move if @party[@index].hasItem?
end
pbPlayDecisionSE
return :interact_menu
@@ -673,13 +670,8 @@ class UI::PartyVisuals < UI::BaseVisuals
return :screen_menu
end
when Input::BACK
if switching?
pbPlayCancelSE
return :switch_pokemon_cancel
elsif (@sub_mode || :normal) != :normal
pbPlayCancelSE
return :clear_sub_mode
end
return :switch_pokemon_cancel if switching?
return :clear_sub_mode if (@sub_mode || :normal) != :normal
pbPlayCloseMenuSE
return :quit
end
@@ -714,13 +706,9 @@ class UI::PartyVisuals < UI::BaseVisuals
case input
when Input::USE
if @index == Settings::MAX_PARTY_SIZE
if @multi_select # Confirm
pbPlayDecisionSE
return :confirm
else # Cancel
(switching?) ? pbPlayCancelSE : pbPlayCloseMenuSE
return :quit
end
return :confirm if @multi_select # Confirm
(switching?) ? pbPlayCancelSE : pbPlayCloseMenuSE
return :quit
elsif @index == Settings::MAX_PARTY_SIZE + 1 # Cancel
(switching?) ? pbPlayCancelSE : pbPlayCloseMenuSE
return :quit
@@ -764,8 +752,6 @@ class UI::Party < UI::BaseScreen
# :battle_use_item For battle.
# :use_item Like :choose_pokemon but with a different help text
# :teach_pokemon Like :choose_pokemon but with a different help text
# :choose_entry_order Battle Frontier thing
def initialize(party, mode: :normal)
@party = (party.is_a?(Array)) ? party : [party]
@@ -1002,7 +988,6 @@ class UI::Party < UI::BaseScreen
end
if (@able_proc && !@able_proc.call(pokemon)) ||
(@able_proc2 && !@able_proc2.call(pokemon))
pbPlayDecisionSE
if pokemon.egg?
show_message(_INTL("This egg can't be chosen."))
else
@@ -1063,7 +1048,6 @@ class UI::Party < UI::BaseScreen
command = @visuals.navigate_choose_pokemon
case command
when :chosen
pbPlayDecisionSE
commands = {}
commands[:enter] = _INTL("Entry") if (statuses[index] || 0) == 1 # Not entered yet
commands[:not_enter] = _INTL("No Entry") if (statuses[index] || 0) > 2 # Already entered
@@ -1153,6 +1137,7 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :debug, {
UIActionHandlers.add(UI::Party::SCREEN_ID, :switch_pokemon_start, {
:effect => proc { |screen|
pbPlayDecisionSE
screen.start_switching
}
})
@@ -1165,6 +1150,7 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :switch_pokemon_end, {
UIActionHandlers.add(UI::Party::SCREEN_ID, :switch_pokemon_cancel, {
:effect => proc { |screen|
pbPlayCancelSE
screen.end_switching
}
})
@@ -1225,8 +1211,7 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :item_give, {
UIActionHandlers.add(UI::Party::SCREEN_ID, :item_take, {
:effect => proc { |screen|
pkmn = screen.pokemon
next if !pbTakeItemFromPokemon(pkmn, screen)
screen.refresh
screen.refresh if pbTakeItemFromPokemon(pkmn, screen)
}
})
@@ -1234,6 +1219,7 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :item_take, {
# (here) has the whole switching process in this handler. Be consistent.
UIActionHandlers.add(UI::Party::SCREEN_ID, :item_move, {
:effect => proc { |screen|
pbPlayDecisionSE
old_pkmn = screen.pokemon
old_item = old_pkmn.item
old_item_name = old_item.name
@@ -1248,7 +1234,6 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :item_move, {
screen.end_switching
break
end
pbPlayDecisionSE
new_pkmn = screen.party[new_party_idx]
if new_pkmn.egg?
screen.show_message(_INTL("Eggs can't hold items."))
@@ -1307,14 +1292,13 @@ UIActionHandlers.add(UI::Party::SCREEN_ID, :mail_read, {
UIActionHandlers.add(UI::Party::SCREEN_ID, :mail_take, {
:effect => proc { |screen|
if pbTakeItemFromPokemon(screen.pokemon, screen)
screen.refresh
end
screen.refresh if pbTakeItemFromPokemon(screen.pokemon, screen)
}
})
UIActionHandlers.add(UI::Party::SCREEN_ID, :clear_sub_mode, {
:effect => proc { |screen|
pbPlayCancelSE
screen.set_sub_mode(:normal)
}
})

View File

@@ -358,10 +358,13 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
break if i == @party_index
@visible_index += 1
end
# Want to stay on the nth page, or the closest available one
# Want to stay on the same page, or the nth page if that no longer exists,
# or the closest available one
pages = all_pages
new_page_index = old_page_index.clamp(0, pages.length - 1)
@page = pages[new_page_index]
if !pages.include?(@page)
new_page_index = old_page_index.clamp(0, pages.length - 1)
@page = pages[new_page_index]
end
# Set the Pokémon's sprite
@sprites[:pokemon].setPokemonBitmap(@pokemon)
@ribbon_offset = 0
@@ -568,6 +571,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
bar_total_width = 128
bar_width = [@pokemon.hp * bar_total_width / @pokemon.totalhp.to_f, 1.0].max
bar_width = ((bar_width / 2).round) * 2 # Make the bar's length a multiple of 2 pixels
bar_width -= 2 if bar_width == bar_total_width && @pokemon.hp < @pokemon.totalhp
hp_zone = 0 # Green
hp_zone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor # Yellow
hp_zone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor # Red
@@ -1075,13 +1079,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
pbPlayDecisionSE
return :navigate_moves
when :ribbons
pbPlayDecisionSE
return :navigate_ribbons
else
if @mode != :in_battle
pbPlayDecisionSE
return :interact_menu
end
return :interact_menu if @mode != :in_battle
end
when Input::ACTION
@pokemon.play_cry if !@pokemon.egg?
@@ -1459,6 +1459,8 @@ UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :go_to_next_pokemon, {
UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_moves, {
:returns_value => true,
:effect => proc { |screen|
# NOTE: Doesn't have pbPlayDecisionSE here because this is also called by
# def choose_move, which plays its own SE at the same time.
move_index = screen.visuals.navigate_moves
next move_index if screen.mode == :choose_move
screen.refresh
@@ -1468,6 +1470,7 @@ UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_moves, {
UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_ribbons, {
:effect => proc { |screen|
pbPlayDecisionSE
screen.visuals.navigate_ribbons
screen.refresh
}

View File

@@ -648,13 +648,9 @@ class UI::BagVisuals < UI::BaseVisuals
def update_interaction(input)
case input
when Input::USE
if switching?
pbPlayDecisionSE
return :switch_item_end
elsif @sub_mode == :rearrange_items && item && pocket_sortable?
pbPlayDecisionSE
return :switch_item_start
elsif !item # "CLOSE BAG"
return :switch_item_end if switching?
return :switch_item_start if @sub_mode == :rearrange_items && item && pocket_sortable?
if !item # "CLOSE BAG"
pbPlayCloseMenuSE
return :quit
end
@@ -662,10 +658,8 @@ class UI::BagVisuals < UI::BaseVisuals
return :interact_menu
when Input::ACTION
if item
if switching?
pbPlayDecisionSE
return :switch_item_end
elsif @pocket == :Machines
return :switch_item_end if switching?
if @pocket == :Machines
pbPlayDecisionSE
@show_move_details = !@show_move_details
refresh_move_details
@@ -676,13 +670,8 @@ class UI::BagVisuals < UI::BaseVisuals
end
end
when Input::BACK
if switching?
pbPlayCancelSE
return :switch_item_cancel
elsif (@sub_mode || :normal) != :normal && pocket_sortable?
pbPlayCancelSE
return :clear_sub_mode
end
return :switch_item_cancel if switching?
return :clear_sub_mode if (@sub_mode || :normal) != :normal && pocket_sortable?
pbPlayCloseMenuSE
return :quit
end
@@ -719,12 +708,9 @@ class UI::BagVisuals < UI::BaseVisuals
def update_interaction_choose_item(input)
case input
when Input::USE
if !item # "CLOSE BAG"
pbPlayCloseMenuSE
return :quit
end
pbPlayDecisionSE
return :chosen
return :chosen if item
pbPlayCloseMenuSE
return :quit
when Input::ACTION
if item && @pocket == :Machines
pbPlayDecisionSE
@@ -829,8 +815,12 @@ class UI::Bag < UI::BaseScreen
loop do
on_start_main_loop
chosen_item = choose_item_core
if chosen_item && block_given?
next if !yield chosen_item
if chosen_item
if block_given?
next if !yield chosen_item
else
pbPlayDecisionSE
end
end
@result = chosen_item
break
@@ -859,18 +849,21 @@ UIActionHandlers.add(UI::Bag::SCREEN_ID, :screen_menu, {
UIActionHandlers.add(UI::Bag::SCREEN_ID, :switch_item_start, {
:effect => proc { |screen|
pbPlayDecisionSE
screen.start_switching
}
})
UIActionHandlers.add(UI::Bag::SCREEN_ID, :switch_item_end, {
:effect => proc { |screen|
pbPlayDecisionSE
screen.switch_items(screen.switch_index, screen.index)
}
})
UIActionHandlers.add(UI::Bag::SCREEN_ID, :switch_item_cancel, {
:effect => proc { |screen|
pbPlayCancelSE
screen.cancel_switching
}
})
@@ -883,6 +876,7 @@ UIActionHandlers.add(UI::Bag::SCREEN_ID, :rearrange_items_mode, {
UIActionHandlers.add(UI::Bag::SCREEN_ID, :clear_sub_mode, {
:effect => proc { |screen|
pbPlayCancelSE
screen.set_sub_mode(:normal)
}
})