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

@@ -248,23 +248,23 @@ def pbUseItem(bag, item, bag_screen = nil)
end end
# Only called when in the party screen and having chosen an item to be used on # Only called when in the party screen and having chosen an item to be used on
# the selected Pokémon. # the selected Pokémon. screen is the party screen.
# TODO: Replace all pbMessage and so on in here. scene is the party screen. def pbUseItemOnPokemon(item, pkmn, screen)
def pbUseItemOnPokemon(item, pkmn, scene)
item_data = GameData::Item.get(item) item_data = GameData::Item.get(item)
# TM or HM # TM or HM
if item_data.is_machine? if item_data.is_machine?
machine = item_data.move move = item_data.move
return false if !machine return false if !move
movename = GameData::Move.get(machine).name move_name = GameData::Move.get(move).name
if pkmn.shadowPokemon? if pkmn.shadowPokemon?
pbMessage(_INTL("Shadow Pokémon can't be taught any moves.")) { scene.pbUpdate } screen.show_message(_INTL("Shadow Pokémon can't be taught any moves."))
elsif !pkmn.compatible_with_move?(machine) elsif !pkmn.compatible_with_move?(move)
pbMessage(_INTL("{1} can't learn {2}.", pkmn.name, movename)) { scene.pbUpdate } screen.show_message(_INTL("{1} can't learn {2}.", pkmn.name, move_name))
else else
pbMessage("\\se[PC access]" + _INTL("You booted up the {1}.", item_data.portion_name) + "\1") { scene.pbUpdate } pbSEPlay("PC access")
if pbConfirmMessage(_INTL("Do you want to teach {1} to {2}?", movename, pkmn.name)) { scene.pbUpdate } screen.show_message(_INTL("You booted up the {1}.", item_data.portion_name) + "\1")
if pbLearnMove(pkmn, machine, false, true) { scene.pbUpdate } if screen.show_confirm_message(_INTL("Do you want to teach {1} to {2}?", move_name, pkmn.name))
if pbLearnMove(pkmn, move, false, true) { screen.update }
$bag.remove(item) if item_data.consumed_after_use? $bag.remove(item) if item_data.consumed_after_use?
return true return true
end end
@@ -277,19 +277,19 @@ def pbUseItemOnPokemon(item, pkmn, scene)
max_at_once = ItemHandlers.triggerUseOnPokemonMaximum(item, pkmn) max_at_once = ItemHandlers.triggerUseOnPokemonMaximum(item, pkmn)
max_at_once = [max_at_once, $bag.quantity(item)].min max_at_once = [max_at_once, $bag.quantity(item)].min
if max_at_once > 1 if max_at_once > 1
qty = scene.scene.pbChooseNumber( qty = screen.choose_number(
_INTL("How many {1} do you want to use?", item_data.portion_name_plural), max_at_once _INTL("How many {1} do you want to use?", item_data.portion_name_plural), max_at_once
) )
scene.set_help_text("") if scene.is_a?(UI::Party) screen.set_help_text("")
end end
return false if qty <= 0 return false if qty <= 0
ret = ItemHandlers.triggerUseOnPokemon(item, qty, pkmn, scene) ret = ItemHandlers.triggerUseOnPokemon(item, qty, pkmn, screen)
scene.clear_annotations screen.clear_annotations
scene.refresh screen.refresh
if ret && item_data.consumed_after_use? if ret && item_data.consumed_after_use?
$bag.remove(item, qty) $bag.remove(item, qty)
if !$bag.has?(item) if !$bag.has?(item)
pbMessage(_INTL("You used your last {1}.", item_data.portion_name)) { scene.pbUpdate } screen.show_message(_INTL("You used your last {1}.", item_data.portion_name))
end end
end end
return ret return ret
@@ -317,80 +317,91 @@ end
#=============================================================================== #===============================================================================
# Give an item to a Pokémon to hold, and take a held item from a Pokémon. # Give an item to a Pokémon to hold, and take a held item from a Pokémon.
#=============================================================================== #===============================================================================
# TODO: Replace all pbDisplay and so on in here. # screen is either the party screen or the summary screen.
def pbGiveItemToPokemon(item, pkmn, scene, pkmnid = 0) def pbGiveItemToPokemon(item, pkmn, screen, pkmnid = 0)
return false if item.nil? return false if item.nil?
newitemname = GameData::Item.get(item).portion_name # Check if the Pokémon can hold the item, or have its item removed if it's
# already holding one
if pkmn.egg? if pkmn.egg?
scene.pbDisplay(_INTL("Eggs can't hold items.")) screen.show_message(_INTL("Eggs can't hold items."))
return false return false
elsif pkmn.mail elsif pkmn.mail
scene.pbDisplay(_INTL("{1}'s mail must be removed before giving it an item.", pkmn.name)) screen.show_message(_INTL("{1}'s mail must be removed before giving it an item.", pkmn.name))
return false if !pbTakeItemFromPokemon(pkmn, scene) return false if !pbTakeItemFromPokemon(pkmn, screen)
end end
new_item_name = GameData::Item.get(item).portion_name
if pkmn.hasItem? if pkmn.hasItem?
olditemname = pkmn.item.portion_name # Swap existing held item with the new item
if olditemname.starts_with_vowel? old_item_name = pkmn.item.portion_name
scene.pbDisplay(_INTL("{1} is already holding an {2}.", pkmn.name, olditemname) + "\1") if old_item_name.starts_with_vowel?
screen.show_message(_INTL("{1} is already holding an {2}.", pkmn.name, old_item_name) + "\1")
else else
scene.pbDisplay(_INTL("{1} is already holding a {2}.", pkmn.name, olditemname) + "\1") screen.show_message(_INTL("{1} is already holding a {2}.", pkmn.name, old_item_name) + "\1")
end end
if scene.pbConfirm(_INTL("Would you like to switch the two items?")) if screen.show_confirm_message(_INTL("Would you like to switch the two items?"))
$bag.remove(item) $bag.remove(item)
if !$bag.add(pkmn.item) if !$bag.add(pkmn.item)
raise _INTL("Couldn't re-store deleted item in Bag somehow") if !$bag.add(item) raise _INTL("Couldn't re-store deleted item in Bag somehow") if !$bag.add(item)
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) screen.show_message(_INTL("The Bag is full. The Pokémon's item could not be removed."))
elsif GameData::Item.get(item).is_mail? elsif GameData::Item.get(item).is_mail?
if pbWriteMail(item, pkmn, pkmnid, scene) if pbWriteMail(item, pkmn, pkmnid, screen)
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) screen.show_message(_INTL("Took the {1} from {2} and gave it the {3}.", old_item_name, pkmn.name, new_item_name))
return true return true
elsif !$bag.add(item) elsif !$bag.add(item)
raise _INTL("Couldn't re-store deleted item in Bag somehow") raise _INTL("Couldn't re-store deleted item in Bag somehow")
end end
else else
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("Took the {1} from {2} and gave it the {3}.", olditemname, pkmn.name, newitemname)) screen.show_message(_INTL("Took the {1} from {2} and gave it the {3}.", old_item_name, pkmn.name, new_item_name))
return true return true
end end
end end
elsif !GameData::Item.get(item).is_mail? || pbWriteMail(item, pkmn, pkmnid, scene) elsif !GameData::Item.get(item).is_mail? || pbWriteMail(item, pkmn, pkmnid, screen)
# Give the new item
$bag.remove(item) $bag.remove(item)
pkmn.item = item pkmn.item = item
scene.pbDisplay(_INTL("{1} is now holding the {2}.", pkmn.name, newitemname)) screen.show_message(_INTL("{1} is now holding the {2}.", pkmn.name, new_item_name))
return true return true
end end
return false return false
end end
# TODO: Replace all pbDisplay and so on in here. # screen is either the party screen or the summary screen.
def pbTakeItemFromPokemon(pkmn, scene) def pbTakeItemFromPokemon(pkmn, screen)
ret = false ret = false
# Check if the Pokémon has an item to remove, and whether the item can be put
# in the Bag
if !pkmn.hasItem? if !pkmn.hasItem?
scene.pbDisplay(_INTL("{1} isn't holding anything.", pkmn.name)) screen.show_message(_INTL("{1} isn't holding anything.", pkmn.name))
return false
elsif !$bag.can_add?(pkmn.item) elsif !$bag.can_add?(pkmn.item)
scene.pbDisplay(_INTL("The Bag is full. The Pokémon's item could not be removed.")) screen.show_message(_INTL("The Bag is full. The Pokémon's item could not be removed."))
elsif pkmn.mail return false
if scene.pbConfirm(_INTL("Save the removed mail in your PC?")) end
if pkmn.mail
# Remove a mail item
if screen.show_confirm_message(_INTL("Save the removed mail in your PC?"))
if pbMoveToMailbox(pkmn) if pbMoveToMailbox(pkmn)
pkmn.item = nil pkmn.item = nil
scene.pbDisplay(_INTL("The mail was saved in your PC.")) screen.show_message(_INTL("The mail was saved in your PC."))
ret = true ret = true
else else
scene.pbDisplay(_INTL("Your PC's Mailbox is full.")) screen.show_message(_INTL("Your PC's Mailbox is full."))
end end
elsif scene.pbConfirm(_INTL("If the mail is removed, its message will be lost. OK?")) elsif screen.show_confirm_message(_INTL("If the mail is removed, its message will be lost. OK?"))
item_name = pkmn.item.portion_name item_name = pkmn.item.portion_name
$bag.add(pkmn.item) $bag.add(pkmn.item)
pkmn.item = nil pkmn.item = nil
scene.pbDisplay(_INTL("Received the {1} from {2}.", item_name, pkmn.name)) screen.show_message(_INTL("Received the {1} from {2}.", item_name, pkmn.name))
ret = true ret = true
end end
else else
# Remove a regular item
item_name = pkmn.item.portion_name item_name = pkmn.item.portion_name
$bag.add(pkmn.item) $bag.add(pkmn.item)
pkmn.item = nil pkmn.item = nil
scene.pbDisplay(_INTL("Received the {1} from {2}.", item_name, pkmn.name)) screen.show_message(_INTL("Received the {1} from {2}.", item_name, pkmn.name))
ret = true ret = true
end end
return ret return ret

View File

@@ -368,7 +368,8 @@ ItemHandlers::UseFromBag.addIf(:move_machines,
item_data = GameData::Item.get(item) item_data = GameData::Item.get(item)
move = item_data.move move = item_data.move
next 0 if !move next 0 if !move
pbMessage("\\se[PC access]" + _INTL("You booted up the {1}.", item_data.name) + "\1") pbSEPlay("PC access")
pbMessage(_INTL("You booted up the {1}.", item_data.portion_name) + "\1")
next 0 if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?", next 0 if !pbConfirmMessage(_INTL("Do you want to teach {1} to a Pokémon?",
GameData::Move.get(move).name)) GameData::Move.get(move).name))
next 1 if pbMoveTutorChoose(move, nil, true, item_data.is_TR?) next 1 if pbMoveTutorChoose(move, nil, true, item_data.is_TR?)

View File

@@ -59,6 +59,14 @@ class Pokemon
@gender = new_gender @gender = new_gender
end end
def male?
return @gender == 0
end
def female?
return @gender == 1
end
# @param new_language [Integer] new owner language # @param new_language [Integer] new owner language
def language=(new_language) def language=(new_language)
validate new_language => Integer validate new_language => Integer

View File

@@ -226,7 +226,7 @@ def pbRefreshMGCommands(master, online)
elsif gift[1] > 0 elsif gift[1] > 0
itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1]) itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1])
end end
ontext = ["[ ]", "[X]"][(online.include?(gift[0])) ? 1 : 0] ontext = ["[ ]", "[Y]"][(online.include?(gift[0])) ? 1 : 0]
commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname)) commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname))
end end
commands.push(_INTL("Export selected to file")) commands.push(_INTL("Export selected to file"))

View File

@@ -361,11 +361,15 @@ module UI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def fade_in 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 end
def fade_out 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 end
def dispose def dispose
@@ -490,7 +494,9 @@ module UI
end end
end end
@sprites[:speech_box].visible = false @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 return ret
end end

View File

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

View File

@@ -358,10 +358,13 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
break if i == @party_index break if i == @party_index
@visible_index += 1 @visible_index += 1
end 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 pages = all_pages
if !pages.include?(@page)
new_page_index = old_page_index.clamp(0, pages.length - 1) new_page_index = old_page_index.clamp(0, pages.length - 1)
@page = pages[new_page_index] @page = pages[new_page_index]
end
# Set the Pokémon's sprite # Set the Pokémon's sprite
@sprites[:pokemon].setPokemonBitmap(@pokemon) @sprites[:pokemon].setPokemonBitmap(@pokemon)
@ribbon_offset = 0 @ribbon_offset = 0
@@ -568,6 +571,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
bar_total_width = 128 bar_total_width = 128
bar_width = [@pokemon.hp * bar_total_width / @pokemon.totalhp.to_f, 1.0].max 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 = ((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 = 0 # Green
hp_zone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor # Yellow hp_zone = 1 if @pokemon.hp <= (@pokemon.totalhp / 2).floor # Yellow
hp_zone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor # Red hp_zone = 2 if @pokemon.hp <= (@pokemon.totalhp / 4).floor # Red
@@ -1075,13 +1079,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
pbPlayDecisionSE pbPlayDecisionSE
return :navigate_moves return :navigate_moves
when :ribbons when :ribbons
pbPlayDecisionSE
return :navigate_ribbons return :navigate_ribbons
else else
if @mode != :in_battle return :interact_menu if @mode != :in_battle
pbPlayDecisionSE
return :interact_menu
end
end end
when Input::ACTION when Input::ACTION
@pokemon.play_cry if !@pokemon.egg? @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, { UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_moves, {
:returns_value => true, :returns_value => true,
:effect => proc { |screen| :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 move_index = screen.visuals.navigate_moves
next move_index if screen.mode == :choose_move next move_index if screen.mode == :choose_move
screen.refresh screen.refresh
@@ -1468,6 +1470,7 @@ UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_moves, {
UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_ribbons, { UIActionHandlers.add(UI::PokemonSummary::SCREEN_ID, :navigate_ribbons, {
:effect => proc { |screen| :effect => proc { |screen|
pbPlayDecisionSE
screen.visuals.navigate_ribbons screen.visuals.navigate_ribbons
screen.refresh screen.refresh
} }

View File

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

View File

@@ -281,10 +281,6 @@ class PokemonMart_Scene
end end
def pbStartSellScene2(bag, adapter) def pbStartSellScene2(bag, adapter)
# TODO: Don't have a subscene. Make a new BagVisuals class for choosing an
# item to sell, and open that. It can inherit from class
# UI::BagVisuals and add the money window (that may be all that needs
# adding).
@subscene = PokemonBag_Scene.new @subscene = PokemonBag_Scene.new
@adapter = adapter @adapter = adapter
@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height) @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)

View File

@@ -60,6 +60,11 @@ def pbGetLanguage
return 2 # Use 'English' by default return 2 # Use 'English' by default
end end
def pbChooseLanguage
commands = Settings::LANGUAGES.map { |val| val[0] }
return pbShowCommands(nil, commands)
end
# Converts a Celsius temperature to Fahrenheit. # Converts a Celsius temperature to Fahrenheit.
def toFahrenheit(celsius) def toFahrenheit(celsius)
return (celsius * 9.0 / 5.0).round + 32 return (celsius * 9.0 / 5.0).round + 32
@@ -595,14 +600,6 @@ def pbLoadRpgxpScene(scene)
Graphics.transition Graphics.transition
end end
def pbChooseLanguage
commands = []
Settings::LANGUAGES.each do |lang|
commands.push(lang[0])
end
return pbShowCommands(nil, commands)
end
def pbScreenCapture def pbScreenCapture
t = Time.now t = Time.now
filestart = t.strftime("[%Y-%m-%d] %H_%M_%S.%L") filestart = t.strftime("[%Y-%m-%d] %H_%M_%S.%L")

View File

@@ -159,7 +159,7 @@ module PokemonDebugMixin
# Main loop # Main loop
command = 0 command = 0
loop do 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 if command < 0
parent = commands.getParent parent = commands.getParent
break if !parent 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 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 end
#=============================================================================== #===============================================================================

View File

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

View File

@@ -762,134 +762,3 @@ def pbCheckTileValidity(tile_id, map, tilesets, passages)
end end
return false return false
end 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