Rewrote summary screen code

This commit is contained in:
Maruno17
2024-08-24 17:00:06 +01:00
parent 2c6fe70f0c
commit 45127be5b6
13 changed files with 1446 additions and 73 deletions

View File

@@ -465,9 +465,8 @@ class Battle::Scene
def pbForgetMove(pkmn, moveToLearn) def pbForgetMove(pkmn, moveToLearn)
ret = -1 ret = -1
pbFadeOutIn do pbFadeOutIn do
scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new([pkmn], 0, mode: :choose_move, new_move: moveToLearn)
screen = PokemonSummaryScreen.new(scene) ret = screen.result
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
end end
return ret return ret
end end

View File

@@ -63,9 +63,7 @@ module Battle::CatchAndStoreMixin
break break
when 2 # See X's summary when 2 # See X's summary
pbFadeOutIn do pbFadeOutIn do
summary_scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new(pkmn, mode: :in_battle)
summary_screen = PokemonSummaryScreen.new(summary_scene, true)
summary_screen.pbStartScreen([pkmn], 0)
end end
when 3 # Check party when 3 # Check party
@scene.pbPartyScreen(0, true, 2) @scene.pbPartyScreen(0, true, 2)

View File

@@ -632,9 +632,8 @@ end
def pbForgetMove(pkmn, moveToLearn) def pbForgetMove(pkmn, moveToLearn)
ret = -1 ret = -1
pbFadeOutIn do pbFadeOutIn do
scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new([pkmn], 0, mode: :choose_move, new_move: moveToLearn)
screen = PokemonSummaryScreen.new(scene) ret = screen.result
ret = screen.pbStartForgetScreen([pkmn], 0, moveToLearn)
end end
return ret return ret
end end

View File

@@ -702,9 +702,7 @@ class PokemonParty_Scene
def pbSummary(pkmnid, inbattle = false) def pbSummary(pkmnid, inbattle = false)
oldsprites = pbFadeOutAndHide(@sprites) oldsprites = pbFadeOutAndHide(@sprites)
scene = PokemonSummary_Scene.new UI::PokemonSummary.new(@party, pkmnid)
screen = PokemonSummaryScreen.new(scene, inbattle)
screen.pbStartScreen(@party, pkmnid)
yield if block_given? yield if block_given?
pbRefresh pbRefresh
pbFadeInAndShow(@sprites, oldsprites) pbFadeInAndShow(@sprites, oldsprites)

View File

@@ -1246,16 +1246,16 @@ class PokemonStorageScene
def pbSummary(selected, heldpoke) def pbSummary(selected, heldpoke)
oldsprites = pbFadeOutAndHide(@sprites) oldsprites = pbFadeOutAndHide(@sprites)
scene = PokemonSummary_Scene.new
screen = PokemonSummaryScreen.new(scene)
if heldpoke if heldpoke
screen.pbStartScreen([heldpoke], 0) UI::PokemonSummary.new(heldpoke)
elsif selected[0] == -1 elsif selected[0] == -1
@selection = screen.pbStartScreen(@storage.party, selected[1]) screen = UI::PokemonSummary.new(@storage.party, selected[1])
@selection = screen.result
pbPartySetArrow(@sprites["arrow"], @selection) pbPartySetArrow(@sprites["arrow"], @selection)
pbUpdateOverlay(@selection, @storage.party) pbUpdateOverlay(@selection, @storage.party)
else else
@selection = screen.pbStartScreen(@storage.boxes[selected[0]], selected[1]) screen = UI::PokemonSummary.new(@storage.boxes[selected[0]], selected[1])
@selection = screen.result
pbSetArrow(@sprites["arrow"], @selection) pbSetArrow(@sprites["arrow"], @selection)
pbUpdateOverlay(@selection) pbUpdateOverlay(@selection)
end end

View File

@@ -95,7 +95,7 @@ class MoveRelearner_Scene
textpos.push([accuracy == 0 ? "---" : "#{accuracy}%", 468, 184, :center, textpos.push([accuracy == 0 ? "---" : "#{accuracy}%", 468, 184, :center,
Color.new(64, 64, 64), Color.new(176, 176, 176)]) Color.new(64, 64, 64), Color.new(176, 176, 176)])
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
imagepos.push(["Graphics/UI/category", 436, 116, 0, category * CATEGORY_ICON_SIZE[1], *CATEGORY_ICON_SIZE]) imagepos.push(["Graphics/UI/category", 436, 116, 0, category * GameData::Move::CATEGORY_ICON_SIZE[1], *GameData::Move::CATEGORY_ICON_SIZE])
if @sprites["commands"].index < @moves.length - 1 if @sprites["commands"].index < @moves.length - 1
imagepos.push(["Graphics/UI/Move Reminder/buttons", 48, 350, 0, 0, 76, 32]) imagepos.push(["Graphics/UI/Move Reminder/buttons", 48, 350, 0, 0, 76, 32])
end end

View File

@@ -1232,9 +1232,7 @@ class PurifyChamberScene
def pbSummary(pos, heldpkmn) def pbSummary(pos, heldpkmn)
if heldpkmn if heldpkmn
oldsprites = pbFadeOutAndHide(@sprites) oldsprites = pbFadeOutAndHide(@sprites)
scene = PokemonSummary_Scene.new UI::PokemonSummary.new(heldpkmn)
screen = PokemonSummaryScreen.new(scene)
screen.pbStartScreen([heldpkmn], 0)
pbFadeInAndShow(@sprites, oldsprites) pbFadeInAndShow(@sprites, oldsprites)
return return
end end
@@ -1251,9 +1249,8 @@ class PurifyChamberScene
end end
return if party.length == 0 return if party.length == 0
oldsprites = pbFadeOutAndHide(@sprites) oldsprites = pbFadeOutAndHide(@sprites)
scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new(party, startindex)
screen = PokemonSummaryScreen.new(scene) selection = screen.result
selection = screen.pbStartScreen(party, startindex)
@sprites["setview"].cursor = indexes[selection] @sprites["setview"].cursor = indexes[selection]
pbFadeInAndShow(@sprites, oldsprites) pbFadeInAndShow(@sprites, oldsprites)
end end

View File

@@ -3,11 +3,11 @@ module UI
# The visuals class. # The visuals class.
#============================================================================= #=============================================================================
class BaseVisuals class BaseVisuals
UI_FOLDER = "Graphics/UI/" UI_FOLDER = "Graphics/UI/"
@@graphics_folder = "" # Subfolder in UI_FOLDER GRAPHICS_FOLDER = "" # Subfolder in UI_FOLDER
@@background_filename = "bg" BACKGROUND_FILENAME = "bg"
@@text_colors = { # These color themes are added to @sprites[:overlay] TEXT_COLOR_THEMES = { # These color themes are added to @sprites[:overlay]
:default => [Color.new(72, 72, 72), Color.new(160, 160, 160)] # Base and shadow colour :default => [Color.new(72, 172, 72), Color.new(160, 160, 160)] # Base and shadow colour
} }
def initialize def initialize
@@ -17,7 +17,8 @@ module UI
initialize_bitmaps initialize_bitmaps
initialize_background initialize_background
initialize_overlay initialize_overlay
# TODO: Initialize message box (and dialogue box?) for messages to use. initialize_message_box
# TODO: Initialize dialogue box for messages to use?
initialize_sprites initialize_sprites
refresh refresh
end end
@@ -31,19 +32,21 @@ module UI
end end
def initialize_background def initialize_background
addBackgroundPlane(@sprites, :background, @@graphics_folder + background_filename, @viewport) addBackgroundPlane(@sprites, :background, self.class::GRAPHICS_FOLDER + background_filename, @viewport)
@sprites[:background].z = -1000 @sprites[:background].z = -1000
end end
def background_filename def initialize_overlay
return gendered_filename(@@background_filename) add_overlay(:overlay)
end end
def initialize_overlay def initialize_message_box
@sprites[:overlay] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport) @sprites[:message_box] = Window_AdvancedTextPokemon.new("")
@sprites[:overlay].z = 1000 @sprites[:message_box].viewport = @viewport
@@text_colors.each_pair { |key, values| @sprites[:overlay].add_text_theme(key, *values) } @sprites[:message_box].z = 2000
pbSetSystemFont(@sprites[:overlay].bitmap) @sprites[:message_box].visible = false
@sprites[:message_box].letterbyletter = true
pbBottomLeftLines(@sprites[:message_box], 2)
end end
def initialize_sprites def initialize_sprites
@@ -51,6 +54,13 @@ module UI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def add_overlay(key)
@sprites[key] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites[key].z = 1000
self.class::TEXT_COLOR_THEMES.each_pair { |key, values| @sprites[key].add_text_theme(key, *values) }
pbSetSystemFont(@sprites[key].bitmap)
end
def add_icon_sprite(key, x, y, filename = nil) def add_icon_sprite(key, x, y, filename = nil)
@sprites[key] = IconSprite.new(x, y, @viewport) @sprites[key] = IconSprite.new(x, y, @viewport)
@sprites[key].setBitmap(filename) if filename @sprites[key].setBitmap(filename) if filename
@@ -77,7 +87,11 @@ module UI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def graphics_folder def graphics_folder
return UI_FOLDER + @@graphics_folder return UI_FOLDER + self.class::GRAPHICS_FOLDER
end
def background_filename
return gendered_filename(self.class::BACKGROUND_FILENAME)
end end
def gendered_filename(base_filename) def gendered_filename(base_filename)
@@ -96,21 +110,124 @@ module UI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def show_message(text) def show_message(text)
pbMessage(text) { update_visuals } @sprites[:message_box].text = text
@sprites[:message_box].visible = true
loop do
Graphics.update
Input.update
update_visuals
if @sprites[:message_box].busy?
if Input.trigger?(Input::USE)
pbPlayDecisionSE if @sprites[:message_box].pausing?
@sprites[:message_box].resume
end
elsif Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
break
end
end
@sprites[:message_box].visible = false
end end
def show_confirm_message(text) def show_confirm_message(text)
return pbConfirmMessage(text) { update_visuals } ret = false
@sprites[:message_box].text = text
@sprites[:message_box].visible = true
using(cmd_window = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) do
cmd_window.z = @viewport.z + 1
cmd_window.visible = false
pbBottomRight(cmd_window)
cmd_window.y -= @sprites[:message_box].height
loop do
Graphics.update
Input.update
update_visuals
cmd_window.visible = true if !@sprites[:message_box].busy?
cmd_window.update
if !@sprites[:message_box].busy?
if Input.trigger?(Input::BACK)
pbPlayCancelSE
ret = false
break
elsif Input.trigger?(Input::USE) && @sprites[:message_box].resume
pbPlayDecisionSE
ret = (cmd_window.index == 0)
break
end
end
end
end
@sprites[:message_box].visible = false
return ret
end end
def show_choice_message(text, options, cancel_index) def show_choice_message(text, options, index = 0)
return pbMessage(text, options, cancel_index) { update_visuals } ret = -1
commands = options
commands = options.values if options.is_a?(Hash)
@sprites[:message_box].text = text
@sprites[:message_box].visible = true
using(cmd_window = Window_CommandPokemon.new(commands)) do
cmd_window.z = @viewport.z + 1
cmd_window.visible = false
cmd_window.index = index
pbBottomRight(cmd_window)
cmd_window.y -= @sprites[:message_box].height
loop do
Graphics.update
Input.update
update_visuals
cmd_window.visible = true if !@sprites[:message_box].busy?
cmd_window.update
if !@sprites[:message_box].busy?
if Input.trigger?(Input::BACK)
pbPlayCancelSE
ret = -1
break
elsif Input.trigger?(Input::USE) && @sprites[:message_box].resume
pbPlayDecisionSE
ret = cmd_window.index
break
end
end
end
end
@sprites[:message_box].visible = false
ret = options.keys[ret] if options.is_a?(Hash)
return ret
end
def show_choice(options, index = 0)
ret = -1
commands = options
commands = options.values if options.is_a?(Hash)
using(cmd_window = Window_CommandPokemon.new(commands)) do
cmd_window.z = @viewport.z + 1
cmd_window.index = index
pbBottomRight(cmd_window)
loop do
Graphics.update
Input.update
update_visuals
cmd_window.update
if Input.trigger?(Input::BACK)
pbPlayCancelSE
ret = -1
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = cmd_window.index
break
end
end
end
ret = options.keys[ret] if options.is_a?(Hash)
return ret
end end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def draw_text(string, text_x, text_y, align: :left, theme: :default, outline: :shadow, overlay: :overlay) def draw_text(string, text_x, text_y, align: :left, theme: :default, outline: :shadow, overlay: :overlay)
@sprites[overlay].draw_themed_text(string, text_x, text_y, align, theme, outline) @sprites[overlay].draw_themed_text(string.to_s, text_x, text_y, align, theme, outline)
end end
def draw_image(filename, image_x, image_y, src_x = 0, src_y = 0, src_width = -1, src_height = -1, overlay: :overlay) def draw_image(filename, image_x, image_y, src_x = 0, src_y = 0, src_width = -1, src_height = -1, overlay: :overlay)
@@ -141,10 +258,10 @@ module UI
return nil return nil
end end
def update # def update
update_visuals # update_visuals
return update_input # return update_input
end # end
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -153,7 +270,8 @@ module UI
loop do loop do
Graphics.update Graphics.update
Input.update Input.update
ret = update update_visuals
ret = update_input
break if ret break if ret
end end
return ret return ret
@@ -164,9 +282,12 @@ module UI
# The logic class. # The logic class.
#============================================================================= #=============================================================================
class BaseScreen class BaseScreen
attr_reader :result
def initialize def initialize
@disposed = false @disposed = false
initialize_visuals initialize_visuals
# TODO: Call main separately, not here?
main main
end end
@@ -198,20 +319,32 @@ module UI
@visuals.show_message(text) @visuals.show_message(text)
end end
alias pbDisplay show_message
def show_confirm_message(text) def show_confirm_message(text)
return @visuals.show_confirm_message(text) return @visuals.show_confirm_message(text)
end end
def show_choice_message(text, options, cancel_index) alias pbConfirm show_confirm_message
return @visuals.show_choice_message(text, options, cancel_index)
def show_choice_message(text, options, initial_index = 0)
return @visuals.show_choice_message(text, options, initial_index)
end end
def show_choice(options, initial_index = 0)
return @visuals.show_choice(options, initial_index)
end
alias pbShowCommands show_choice
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
def refresh def refresh
@visuals.refresh @visuals.refresh
end end
#-----------------------------------------------------------------------------
def main def main
start_screen start_screen
loop do loop do

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,13 @@
# #
#=============================================================================== #===============================================================================
class UI::TrainerCardVisuals < UI::BaseVisuals class UI::TrainerCardVisuals < UI::BaseVisuals
@@graphics_folder = "Trainer Card/" # Subfolder in Graphics/UI GRAPHICS_FOLDER = "Trainer Card/" # Subfolder in Graphics/UI
BADGE_SIZE = [32, 32] # [width, height] of a Gym Badge
BADGE_SPACING = 16 # Size of gap between adjacent Gym Badges BADGE_SIZE = [32, 32] # [width, height] of a Gym Badge
FIRST_BADGE_X = 72 # Left edge of the first Gym Badge BADGE_SPACING = 16 # Size of gap between adjacent Gym Badges
FIRST_BADGE_Y = 310 # Top edge of the first Gym Badge FIRST_BADGE_X = 72 # Left edge of the first Gym Badge
BADGE_COUNT = 8 # Number of Gym Badges to show FIRST_BADGE_Y = 310 # Top edge of the first Gym Badge
BADGE_COUNT = 8 # Number of Gym Badges to show
def initialize_sprites def initialize_sprites
# Trainer card # Trainer card

View File

@@ -1,3 +1,4 @@
=begin
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
@@ -75,12 +76,23 @@ class RibbonSelectionSprite < MoveSelectionSprite
@spriteVisible = value if !@updating @spriteVisible = value if !@updating
end end
def recheck_visibility
@updating = true
self.visible = @spriteVisible && @index >= 0 &&
@index < UI::PokemonSummaryVisuals::RIBBON_COLUMNS * UI::PokemonSummaryVisuals::RIBBON_ROWS
@updating = false
end
def refresh def refresh
recheck_visibility
cols = UI::PokemonSummaryVisuals::RIBBON_COLUMNS
offset_x = UI::PokemonSummaryVisuals::RIBBON_SIZE[0] + UI::PokemonSummaryVisuals::RIBBON_SPACING_X
offset_y = UI::PokemonSummaryVisuals::RIBBON_SIZE[1] + UI::PokemonSummaryVisuals::RIBBON_SPACING_Y
self.x = UI::PokemonSummaryVisuals::RIBBON_X - 2 + ((self.index % cols) * offset_x)
self.y = UI::PokemonSummaryVisuals::RIBBON_Y - 2 + ((self.index / cols) * offset_y)
self.bitmap = @movesel.bitmap
w = @movesel.width w = @movesel.width
h = @movesel.height / 2 h = @movesel.height / 2
self.x = 228 + ((self.index % 4) * 68)
self.y = 76 + ((self.index / 4).floor * 68)
self.bitmap = @movesel.bitmap
if self.preselected if self.preselected
self.src_rect.set(0, h, w, h) self.src_rect.set(0, h, w, h)
else else
@@ -89,11 +101,9 @@ class RibbonSelectionSprite < MoveSelectionSprite
end end
def update def update
@updating = true
super super
self.visible = @spriteVisible && @index >= 0 && @index < 12 recheck_visibility
@movesel.update @movesel.update
@updating = false
refresh refresh
end end
end end
@@ -839,7 +849,7 @@ class PokemonSummary_Scene
pbDrawTextPositions(overlay, textpos) pbDrawTextPositions(overlay, textpos)
# Draw selected move's damage category icon # Draw selected move's damage category icon
imagepos = [["Graphics/UI/category", 166, 124, imagepos = [["Graphics/UI/category", 166, 124,
0, selected_move.display_category(@pokemon) * CATEGORY_ICON_SIZE[1], *CATEGORY_ICON_SIZE]] 0, selected_move.display_category(@pokemon) * GameData::Move::CATEGORY_ICON_SIZE[1], *GameData::Move::CATEGORY_ICON_SIZE]]
pbDrawImagePositions(overlay, imagepos) pbDrawImagePositions(overlay, imagepos)
# Draw selected move's description # Draw selected move's description
drawTextEx(overlay, 4, 224, 230, 5, selected_move.description, base, shadow) drawTextEx(overlay, 4, 224, 230, 5, selected_move.description, base, shadow)
@@ -1367,6 +1377,7 @@ class PokemonSummaryScreen
return ret return ret
end end
# Unused.
def pbStartChooseMoveScreen(party, partyindex, message) def pbStartChooseMoveScreen(party, partyindex, message)
ret = -1 ret = -1
@scene.pbStartForgetScene(party, partyindex, nil) @scene.pbStartForgetScene(party, partyindex, nil)
@@ -1388,9 +1399,8 @@ def pbChooseMove(pokemon, variableNumber, nameVarNumber)
return if !pokemon return if !pokemon
ret = -1 ret = -1
pbFadeOutIn do pbFadeOutIn do
scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new(pokemon, mode: :choose_move)
screen = PokemonSummaryScreen.new(scene) ret = screen.result
ret = screen.pbStartForgetScreen([pokemon], 0, nil)
end end
$game_variables[variableNumber] = ret $game_variables[variableNumber] = ret
if ret >= 0 if ret >= 0
@@ -1400,3 +1410,4 @@ def pbChooseMove(pokemon, variableNumber, nameVarNumber)
end end
$game_map.need_refresh = true if $game_map $game_map.need_refresh = true if $game_map
end end
=end

View File

@@ -146,9 +146,8 @@ class BattleSwapScene
def pbSummary(list, index) def pbSummary(list, index)
visibleSprites = pbFadeOutAndHide(@sprites) { pbUpdate } visibleSprites = pbFadeOutAndHide(@sprites) { pbUpdate }
scene = PokemonSummary_Scene.new screen = UI::PokemonSummary.new(list, index)
screen = PokemonSummaryScreen.new(scene) @sprites["list"].index = screen.result
@sprites["list"].index = screen.pbStartScreen(list, index)
pbFadeInAndShow(@sprites, visibleSprites) { pbUpdate } pbFadeInAndShow(@sprites, visibleSprites) { pbUpdate }
end end

View File

@@ -335,9 +335,7 @@ def pbDebugDayCare
[_INTL("Summary"), _INTL("Withdraw"), _INTL("Cancel")], 3) [_INTL("Summary"), _INTL("Withdraw"), _INTL("Cancel")], 3)
when 0 # Summary when 0 # Summary
pbFadeOutIn do pbFadeOutIn do
scene = PokemonSummary_Scene.new UI::PokemonSummary.new(pkmn)
screen = PokemonSummaryScreen.new(scene, false)
screen.pbStartScreen([pkmn], 0)
need_refresh = true need_refresh = true
end end
when 1 # Withdraw when 1 # Withdraw