Rewrote summary screen cursors, added cropping of relevant text in the summary screen, raised max lengths of player and Pokémon names to 12

This commit is contained in:
Maruno17
2024-08-30 19:34:58 +01:00
parent 9a7dfbb587
commit 89e6df6e06
7 changed files with 187 additions and 167 deletions

View File

@@ -54,7 +54,7 @@ module Settings
# The maximum amount of soot the player can have. # The maximum amount of soot the player can have.
MAX_SOOT = 9_999 MAX_SOOT = 9_999
# The maximum length, in characters, that the player's name can be. # The maximum length, in characters, that the player's name can be.
MAX_PLAYER_NAME_SIZE = 10 MAX_PLAYER_NAME_SIZE = 12
# A set of arrays each containing a trainer type followed by a Game Variable # A set of arrays each containing a trainer type followed by a Game Variable
# number. If the Variable isn't set to 0, then all trainers with the # number. If the Variable isn't set to 0, then all trainers with the
# associated trainer type will be named as whatever is in that Variable. # associated trainer type will be named as whatever is in that Variable.

View File

@@ -308,22 +308,24 @@ end
# Sprite class that stores multiple bitmaps, and displays only one at once. # Sprite class that stores multiple bitmaps, and displays only one at once.
#=============================================================================== #===============================================================================
class ChangelingSprite < Sprite class ChangelingSprite < Sprite
# Key is the mode (a symbol).
# Value is one of:
# filepath
# [filepath, src_x, src_y, src_width, src_height]
BITMAPS = {}
def initialize(x = 0, y = 0, viewport = nil) def initialize(x = 0, y = 0, viewport = nil)
super(viewport) super(viewport)
self.x = x self.x = x
self.y = y self.y = y
@bitmaps = {} @bitmaps = {}
@currentBitmap = nil @changeling_data = {}
@current_bitmap = nil
initialize_changeling_data
end end
def addBitmap(key, path) def initialize_changeling_data
@bitmaps[key]&.dispose self.class::BITMAPS.each_pair { |mode, data| add_bitmap(mode, data) }
@bitmaps[key] = AnimatedBitmap.new(path)
end
def changeBitmap(key)
@currentBitmap = @bitmaps[key]
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil
end end
def dispose def dispose
@@ -333,9 +335,37 @@ class ChangelingSprite < Sprite
super super
end end
#-----------------------------------------------------------------------------
def add_bitmap(mode, *data)
raise ArgumentError.new(_INTL("wrong number of arguments (given {1}, expected 2 or 6)", data.length + 1)) if ![1, 5].include?(data.length)
filepath = (data[0].is_a?(Array)) ? data[0][0] : data[0]
@bitmaps[filepath] = AnimatedBitmap.new(filepath) if !@bitmaps[filepath]
@changeling_data[mode] = (data[0].is_a?(Array) ? data[0].clone : [data[0]])
end
def change_bitmap(mode)
@current_mode = mode
if @current_mode && @changeling_data[@current_mode]
data = @changeling_data[@current_mode]
@current_bitmap = @bitmaps[data[0]]
self.bitmap = @current_bitmap.bitmap
if data.length > 1
self.src_rect.set(data[1], data[2], data[3], data[4])
else
self.src_rect.set(0, 0, self.bitmap.width, self.bitmap.height)
end
else
@current_bitmap = nil
self.bitmap = nil
end
end
#-----------------------------------------------------------------------------
def update def update
return if disposed? return if disposed?
@bitmaps.each_value { |bm| bm.update } @bitmaps.each_value { |bm| bm.update }
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil self.bitmap = @current_bitmap.bitmap if @current_bitmap
end end
end end

View File

@@ -94,7 +94,7 @@ class Pokemon
# Max EVs that a single stat can have # Max EVs that a single stat can have
EV_STAT_LIMIT = 252 EV_STAT_LIMIT = 252
# Maximum length a Pokémon's nickname can be # Maximum length a Pokémon's nickname can be
MAX_NAME_SIZE = 10 MAX_NAME_SIZE = 12
# Maximum number of moves a Pokémon can know at once # Maximum number of moves a Pokémon can know at once
MAX_MOVES = 4 MAX_MOVES = 4

View File

@@ -9,13 +9,13 @@ class PokemonPartyConfirmCancelSprite < Sprite
@refreshBitmap = true @refreshBitmap = true
@bgsprite = ChangelingSprite.new(0, 0, viewport) @bgsprite = ChangelingSprite.new(0, 0, viewport)
if narrowbox if narrowbox
@bgsprite.addBitmap("desel", "Graphics/UI/Party/icon_cancel_narrow") @bgsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_cancel_narrow")
@bgsprite.addBitmap("sel", "Graphics/UI/Party/icon_cancel_narrow_sel") @bgsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_cancel_narrow_sel")
else else
@bgsprite.addBitmap("desel", "Graphics/UI/Party/icon_cancel") @bgsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_cancel")
@bgsprite.addBitmap("sel", "Graphics/UI/Party/icon_cancel_sel") @bgsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_cancel_sel")
end end
@bgsprite.changeBitmap("desel") @bgsprite.change_bitmap(:desel)
@overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width, @bgsprite.bitmap.height, viewport) @overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width, @bgsprite.bitmap.height, viewport)
@overlaysprite.z = self.z + 1 @overlaysprite.z = self.z + 1
pbSetSystemFont(@overlaysprite.bitmap) pbSetSystemFont(@overlaysprite.bitmap)
@@ -61,7 +61,7 @@ class PokemonPartyConfirmCancelSprite < Sprite
def refresh def refresh
if @bgsprite && !@bgsprite.disposed? if @bgsprite && !@bgsprite.disposed?
@bgsprite.changeBitmap((@selected) ? "sel" : "desel") @bgsprite.change_bitmap((@selected) ? :sel : :desel)
@bgsprite.x = self.x @bgsprite.x = self.x
@bgsprite.y = self.y @bgsprite.y = self.y
@bgsprite.color = self.color @bgsprite.color = self.color
@@ -184,31 +184,31 @@ class PokemonPartyPanel < Sprite
@panelbgsprite = ChangelingSprite.new(0, 0, viewport) @panelbgsprite = ChangelingSprite.new(0, 0, viewport)
@panelbgsprite.z = self.z @panelbgsprite.z = self.z
if @active # Rounded panel if @active # Rounded panel
@panelbgsprite.addBitmap("able", "Graphics/UI/Party/panel_round") @panelbgsprite.add_bitmap(:able, "Graphics/UI/Party/panel_round")
@panelbgsprite.addBitmap("ablesel", "Graphics/UI/Party/panel_round_sel") @panelbgsprite.add_bitmap(:ablesel, "Graphics/UI/Party/panel_round_sel")
@panelbgsprite.addBitmap("fainted", "Graphics/UI/Party/panel_round_faint") @panelbgsprite.add_bitmap(:fainted, "Graphics/UI/Party/panel_round_faint")
@panelbgsprite.addBitmap("faintedsel", "Graphics/UI/Party/panel_round_faint_sel") @panelbgsprite.add_bitmap(:faintedsel, "Graphics/UI/Party/panel_round_faint_sel")
@panelbgsprite.addBitmap("swap", "Graphics/UI/Party/panel_round_swap") @panelbgsprite.add_bitmap(:swap, "Graphics/UI/Party/panel_round_swap")
@panelbgsprite.addBitmap("swapsel", "Graphics/UI/Party/panel_round_swap_sel") @panelbgsprite.add_bitmap(:swapsel, "Graphics/UI/Party/panel_round_swap_sel")
@panelbgsprite.addBitmap("swapsel2", "Graphics/UI/Party/panel_round_swap_sel2") @panelbgsprite.add_bitmap(:swapsel2, "Graphics/UI/Party/panel_round_swap_sel2")
else # Rectangular panel else # Rectangular panel
@panelbgsprite.addBitmap("able", "Graphics/UI/Party/panel_rect") @panelbgsprite.add_bitmap(:able, "Graphics/UI/Party/panel_rect")
@panelbgsprite.addBitmap("ablesel", "Graphics/UI/Party/panel_rect_sel") @panelbgsprite.add_bitmap(:ablesel, "Graphics/UI/Party/panel_rect_sel")
@panelbgsprite.addBitmap("fainted", "Graphics/UI/Party/panel_rect_faint") @panelbgsprite.add_bitmap(:fainted, "Graphics/UI/Party/panel_rect_faint")
@panelbgsprite.addBitmap("faintedsel", "Graphics/UI/Party/panel_rect_faint_sel") @panelbgsprite.add_bitmap(:faintedsel, "Graphics/UI/Party/panel_rect_faint_sel")
@panelbgsprite.addBitmap("swap", "Graphics/UI/Party/panel_rect_swap") @panelbgsprite.add_bitmap(:swap, "Graphics/UI/Party/panel_rect_swap")
@panelbgsprite.addBitmap("swapsel", "Graphics/UI/Party/panel_rect_swap_sel") @panelbgsprite.add_bitmap(:swapsel, "Graphics/UI/Party/panel_rect_swap_sel")
@panelbgsprite.addBitmap("swapsel2", "Graphics/UI/Party/panel_rect_swap_sel2") @panelbgsprite.add_bitmap(:swapsel2, "Graphics/UI/Party/panel_rect_swap_sel2")
end end
@hpbgsprite = ChangelingSprite.new(0, 0, viewport) @hpbgsprite = ChangelingSprite.new(0, 0, viewport)
@hpbgsprite.z = self.z + 1 @hpbgsprite.z = self.z + 1
@hpbgsprite.addBitmap("able", _INTL("Graphics/UI/Party/overlay_hp_back")) @hpbgsprite.add_bitmap(:able, _INTL("Graphics/UI/Party/overlay_hp_back"))
@hpbgsprite.addBitmap("fainted", _INTL("Graphics/UI/Party/overlay_hp_back_faint")) @hpbgsprite.add_bitmap(:fainted, _INTL("Graphics/UI/Party/overlay_hp_back_faint"))
@hpbgsprite.addBitmap("swap", _INTL("Graphics/UI/Party/overlay_hp_back_swap")) @hpbgsprite.add_bitmap(:swap, _INTL("Graphics/UI/Party/overlay_hp_back_swap"))
@ballsprite = ChangelingSprite.new(0, 0, viewport) @ballsprite = ChangelingSprite.new(0, 0, viewport)
@ballsprite.z = self.z + 1 @ballsprite.z = self.z + 1
@ballsprite.addBitmap("desel", "Graphics/UI/Party/icon_ball") @ballsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_ball")
@ballsprite.addBitmap("sel", "Graphics/UI/Party/icon_ball_sel") @ballsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_ball_sel")
@pkmnsprite = PokemonIconSprite.new(pokemon, viewport) @pkmnsprite = PokemonIconSprite.new(pokemon, viewport)
@pkmnsprite.setOffset(PictureOrigin::CENTER) @pkmnsprite.setOffset(PictureOrigin::CENTER)
@pkmnsprite.active = @active @pkmnsprite.active = @active
@@ -296,21 +296,21 @@ class PokemonPartyPanel < Sprite
return if !@panelbgsprite || @panelbgsprite.disposed? return if !@panelbgsprite || @panelbgsprite.disposed?
if self.selected if self.selected
if self.preselected if self.preselected
@panelbgsprite.changeBitmap("swapsel2") @panelbgsprite.change_bitmap(:swapsel2)
elsif @switching elsif @switching
@panelbgsprite.changeBitmap("swapsel") @panelbgsprite.change_bitmap(:swapsel)
elsif @pokemon.fainted? elsif @pokemon.fainted?
@panelbgsprite.changeBitmap("faintedsel") @panelbgsprite.change_bitmap(:faintedsel)
else else
@panelbgsprite.changeBitmap("ablesel") @panelbgsprite.change_bitmap(:ablesel)
end end
else else
if self.preselected if self.preselected
@panelbgsprite.changeBitmap("swap") @panelbgsprite.change_bitmap(:swap)
elsif @pokemon.fainted? elsif @pokemon.fainted?
@panelbgsprite.changeBitmap("fainted") @panelbgsprite.change_bitmap(:fainted)
else else
@panelbgsprite.changeBitmap("able") @panelbgsprite.change_bitmap(:able)
end end
end end
@panelbgsprite.x = self.x @panelbgsprite.x = self.x
@@ -323,11 +323,11 @@ class PokemonPartyPanel < Sprite
@hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length > 0)) @hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length > 0))
return if !@hpbgsprite.visible return if !@hpbgsprite.visible
if self.preselected || (self.selected && @switching) if self.preselected || (self.selected && @switching)
@hpbgsprite.changeBitmap("swap") @hpbgsprite.change_bitmap(:swap)
elsif @pokemon.fainted? elsif @pokemon.fainted?
@hpbgsprite.changeBitmap("fainted") @hpbgsprite.change_bitmap(:fainted)
else else
@hpbgsprite.changeBitmap("able") @hpbgsprite.change_bitmap(:able)
end end
@hpbgsprite.x = self.x + 96 @hpbgsprite.x = self.x + 96
@hpbgsprite.y = self.y + 50 @hpbgsprite.y = self.y + 50
@@ -336,7 +336,7 @@ class PokemonPartyPanel < Sprite
def refresh_ball_graphic def refresh_ball_graphic
return if !@ballsprite || @ballsprite.disposed? return if !@ballsprite || @ballsprite.disposed?
@ballsprite.changeBitmap((self.selected) ? "sel" : "desel") @ballsprite.change_bitmap((self.selected) ? :sel : :desel)
@ballsprite.x = self.x + 10 @ballsprite.x = self.x + 10
@ballsprite.y = self.y @ballsprite.y = self.y
@ballsprite.color = self.color @ballsprite.color = self.color

View File

@@ -156,15 +156,15 @@ class PokemonBoxArrow < Sprite
@quickswap = false @quickswap = false
@heldpkmn = nil @heldpkmn = nil
@handsprite = ChangelingSprite.new(0, 0, viewport) @handsprite = ChangelingSprite.new(0, 0, viewport)
@handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1") @handsprite.add_bitmap(:point1, "Graphics/UI/Storage/cursor_point_1")
@handsprite.addBitmap("point2", "Graphics/UI/Storage/cursor_point_2") @handsprite.add_bitmap(:point2, "Graphics/UI/Storage/cursor_point_2")
@handsprite.addBitmap("grab", "Graphics/UI/Storage/cursor_grab") @handsprite.add_bitmap(:grab, "Graphics/UI/Storage/cursor_grab")
@handsprite.addBitmap("fist", "Graphics/UI/Storage/cursor_fist") @handsprite.add_bitmap(:fist, "Graphics/UI/Storage/cursor_fist")
@handsprite.addBitmap("point1q", "Graphics/UI/Storage/cursor_point_1_q") @handsprite.add_bitmap(:point1q, "Graphics/UI/Storage/cursor_point_1_q")
@handsprite.addBitmap("point2q", "Graphics/UI/Storage/cursor_point_2_q") @handsprite.add_bitmap(:point2q, "Graphics/UI/Storage/cursor_point_2_q")
@handsprite.addBitmap("grabq", "Graphics/UI/Storage/cursor_grab_q") @handsprite.add_bitmap(:grabq, "Graphics/UI/Storage/cursor_grab_q")
@handsprite.addBitmap("fistq", "Graphics/UI/Storage/cursor_fist_q") @handsprite.add_bitmap(:fistq, "Graphics/UI/Storage/cursor_fist_q")
@handsprite.changeBitmap("fist") @handsprite.change_bitmap(:fist)
@spriteX = self.x @spriteX = self.x
@spriteY = self.y @spriteY = self.y
end end
@@ -269,36 +269,36 @@ class PokemonBoxArrow < Sprite
@holding = false if !heldpkmn @holding = false if !heldpkmn
if @grabbing_timer_start if @grabbing_timer_start
if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2 if System.uptime - @grabbing_timer_start <= GRAB_TIME / 2
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab") @handsprite.change_bitmap((@quickswap) ? :grabq : :grab)
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime) self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @grabbing_timer_start, System.uptime)
else else
@holding = true @holding = true
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist") @handsprite.change_bitmap((@quickswap) ? :fistq : :fist)
delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime) delta_y = lerp(16, 0, GRAB_TIME / 2, @grabbing_timer_start + (GRAB_TIME / 2), System.uptime)
self.y = @spriteY + delta_y self.y = @spriteY + delta_y
@grabbing_timer_start = nil if delta_y == 0 @grabbing_timer_start = nil if delta_y == 0
end end
elsif @placing_timer_start elsif @placing_timer_start
if System.uptime - @placing_timer_start <= GRAB_TIME / 2 if System.uptime - @placing_timer_start <= GRAB_TIME / 2
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist") @handsprite.change_bitmap((@quickswap) ? :fistq : :fist)
self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime) self.y = @spriteY + lerp(0, 16, GRAB_TIME / 2, @placing_timer_start, System.uptime)
else else
@holding = false @holding = false
@heldpkmn = nil @heldpkmn = nil
@handsprite.changeBitmap((@quickswap) ? "grabq" : "grab") @handsprite.change_bitmap((@quickswap) ? :grabq : :grab)
delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime) delta_y = lerp(16, 0, GRAB_TIME / 2, @placing_timer_start + (GRAB_TIME / 2), System.uptime)
self.y = @spriteY + delta_y self.y = @spriteY + delta_y
@placing_timer_start = nil if delta_y == 0 @placing_timer_start = nil if delta_y == 0
end end
elsif holding? elsif holding?
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist") @handsprite.change_bitmap((@quickswap) ? :fistq : :fist)
else # Idling else # Idling
self.x = @spriteX self.x = @spriteX
self.y = @spriteY self.y = @spriteY
if (System.uptime / 0.5).to_i.even? # Changes every 0.5 seconds if (System.uptime / 0.5).to_i.even? # Changes every 0.5 seconds
@handsprite.changeBitmap((@quickswap) ? "point1q" : "point1") @handsprite.change_bitmap((@quickswap) ? :point1q : :point1)
else else
@handsprite.changeBitmap((@quickswap) ? "point2q" : "point2") @handsprite.change_bitmap((@quickswap) ? :point2q : :point2)
end end
end end
@updating = false @updating = false

View File

@@ -7,7 +7,7 @@ module UI
GRAPHICS_FOLDER = "" # Subfolder in UI_FOLDER GRAPHICS_FOLDER = "" # Subfolder in UI_FOLDER
BACKGROUND_FILENAME = "bg" BACKGROUND_FILENAME = "bg"
TEXT_COLOR_THEMES = { # These color themes are added to @sprites[:overlay] TEXT_COLOR_THEMES = { # These color themes are added to @sprites[:overlay]
:default => [Color.new(72, 172, 72), Color.new(160, 160, 160)] # Base and shadow colour :default => [Color.new(72, 72, 72), Color.new(160, 160, 160)] # Base and shadow colour
} }
def initialize def initialize
@@ -18,7 +18,7 @@ module UI
initialize_background initialize_background
initialize_overlay initialize_overlay
initialize_message_box initialize_message_box
# TODO: Initialize dialogue box for messages to use? # TODO: Initialize dialogue box for messages to use.
initialize_sprites initialize_sprites
refresh refresh
end end
@@ -243,6 +243,24 @@ module UI
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# NOTE: max_width should include the width of the text shadow at the end of
# the string (because characters in the font have a blank 2 pixels
# after them for the shadow to occupy).
def crop_text(string, max_width, continue_string = "", overlay: :overlay)
return string if max_width <= 0
return string if @sprites[overlay].bitmap.text_size(string).width <= max_width
ret = string
continue_width = @sprites[overlay].bitmap.text_size(continue_string).width
loop do
ret = ret[0...-1]
break if @sprites[overlay].bitmap.text_size(ret).width <= max_width - continue_width
end
ret += continue_string
return ret
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.to_s, text_x, text_y, align, theme, outline) @sprites[overlay].draw_themed_text(string.to_s, text_x, text_y, align, theme, outline)
end end

View File

@@ -1,118 +1,79 @@
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class UI::PokemonSummaryMoveCursor < Sprite class UI::PokemonSummaryMoveCursor < ChangelingSprite
attr_reader :index BITMAPS = {
:normal => ["Graphics/UI/Summary/cursor_move", 0, 0, 252, 74],
:selected => ["Graphics/UI/Summary/cursor_move", 0, 74, 252, 74]
}
CURSOR_THICKNESS = 6 CURSOR_THICKNESS = 6
def initialize(viewport = nil, preselected = false, new_move = false) def initialize(viewport = nil, selected = false, extra_move = false)
super(viewport) super(0, 0, viewport)
@cursor_bitmap = AnimatedBitmap.new("Graphics/UI/Summary/cursor_move") change_bitmap((selected) ? :selected : :normal)
@frame = 0 @extra_move = extra_move
@index = 0
@preselected = preselected
@new_move = new_move
self.z = 1600 self.z = 1600
refresh self.visible = false
end @index = 0
def dispose
@cursor_bitmap.dispose
super
end end
def index=(value) def index=(value)
@index = value @index = value
refresh refresh_visibility
refresh_position
end end
def refresh def refresh_visibility
cursor_width = @cursor_bitmap.width self.visible = (@index >= 0)
cursor_height = @cursor_bitmap.height / 2 end
def refresh_position
return if @index < 0
self.x = UI::PokemonSummaryVisuals::MOVE_LIST_X_DETAILED - CURSOR_THICKNESS self.x = UI::PokemonSummaryVisuals::MOVE_LIST_X_DETAILED - CURSOR_THICKNESS
self.y = UI::PokemonSummaryVisuals::MOVE_LIST_Y - CURSOR_THICKNESS + (self.index * UI::PokemonSummaryVisuals::MOVE_LIST_SPACING) self.y = UI::PokemonSummaryVisuals::MOVE_LIST_Y - CURSOR_THICKNESS + (@index * UI::PokemonSummaryVisuals::MOVE_LIST_SPACING)
self.y += UI::PokemonSummaryVisuals::MOVE_LIST_OFFSET_WHEN_NEW_MOVE if @new_move self.y += UI::PokemonSummaryVisuals::MOVE_LIST_OFFSET_WHEN_NEW_MOVE if @extra_move
self.y += UI::PokemonSummaryVisuals::MOVE_LIST_NEW_MOVE_SPACING if @new_move && self.index == Pokemon::MAX_MOVES self.y += UI::PokemonSummaryVisuals::MOVE_LIST_NEW_MOVE_SPACING if @extra_move && @index == Pokemon::MAX_MOVES
self.bitmap = @cursor_bitmap.bitmap
if @preselected
self.src_rect.set(0, cursor_height, cursor_width, cursor_height)
else
self.src_rect.set(0, 0, cursor_width, cursor_height)
end
end
def update
super
@cursor_bitmap.update
refresh
end end
end end
#=============================================================================== #===============================================================================
# #
#=============================================================================== #===============================================================================
class UI::PokemonSummaryRibbonCursor < Sprite class UI::PokemonSummaryRibbonCursor < ChangelingSprite
attr_reader :index attr_reader :index
BITMAPS = {
:normal => ["Graphics/UI/Summary/cursor_ribbon", 0, 0, 68, 68],
:selected => ["Graphics/UI/Summary/cursor_ribbon", 0, 68, 68, 68]
}
CURSOR_THICKNESS = 2 CURSOR_THICKNESS = 2
def initialize(viewport = nil, preselected = false) def initialize(viewport = nil, selected = false)
super(viewport) super(0, 0, viewport)
@cursor_bitmap = AnimatedBitmap.new("Graphics/UI/Summary/cursor_ribbon") change_bitmap((selected) ? :selected : :normal)
@frame = 0
@index = 0
@preselected = preselected
@updating = false
@cursor_visible = true
self.z = 1600 self.z = 1600
refresh self.visible = false
end @index = 0
def dispose
@cursor_bitmap.dispose
super
end end
def index=(value) def index=(value)
@index = value @index = value
refresh refresh_visibility
refresh_position
end end
def visible=(value) def refresh_visibility
super self.visible = (@index >= 0 && @index < UI::PokemonSummaryVisuals::RIBBON_COLUMNS * UI::PokemonSummaryVisuals::RIBBON_ROWS)
@cursor_visible = value if !@updating
end end
def recheck_visibility def refresh_position
@updating = true return if @index < 0
self.visible = @cursor_visible && @index >= 0 &&
@index < UI::PokemonSummaryVisuals::RIBBON_COLUMNS * UI::PokemonSummaryVisuals::RIBBON_ROWS
@updating = false
end
def refresh
recheck_visibility
cols = UI::PokemonSummaryVisuals::RIBBON_COLUMNS cols = UI::PokemonSummaryVisuals::RIBBON_COLUMNS
offset_x = UI::PokemonSummaryVisuals::RIBBON_SIZE[0] + UI::PokemonSummaryVisuals::RIBBON_SPACING_X offset_x = UI::PokemonSummaryVisuals::RIBBON_SIZE[0] + UI::PokemonSummaryVisuals::RIBBON_SPACING_X
offset_y = UI::PokemonSummaryVisuals::RIBBON_SIZE[1] + UI::PokemonSummaryVisuals::RIBBON_SPACING_Y offset_y = UI::PokemonSummaryVisuals::RIBBON_SIZE[1] + UI::PokemonSummaryVisuals::RIBBON_SPACING_Y
self.x = UI::PokemonSummaryVisuals::RIBBON_X - CURSOR_THICKNESS + ((self.index % cols) * offset_x) self.x = UI::PokemonSummaryVisuals::RIBBON_X - CURSOR_THICKNESS + ((self.index % cols) * offset_x)
self.y = UI::PokemonSummaryVisuals::RIBBON_Y - CURSOR_THICKNESS + ((self.index / cols) * offset_y) self.y = UI::PokemonSummaryVisuals::RIBBON_Y - CURSOR_THICKNESS + ((self.index / cols) * offset_y)
self.bitmap = @cursor_bitmap.bitmap
w = @cursor_bitmap.width
h = @cursor_bitmap.height / 2
if @preselected
self.src_rect.set(0, h, w, h)
else
self.src_rect.set(0, 0, w, h)
end
end
def update
super
recheck_visibility
@cursor_bitmap.update
refresh
end end
end end
@@ -305,7 +266,6 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
@sprites[:pokemon_icon].visible = (@mode == :choose_move) @sprites[:pokemon_icon].visible = (@mode == :choose_move)
# Cursor to highlight a move selected to be swapped # Cursor to highlight a move selected to be swapped
@sprites[:selected_move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, true) @sprites[:selected_move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, true)
@sprites[:selected_move_cursor].visible = false
# Cursor to highlight the currently selected move # Cursor to highlight the currently selected move
@sprites[:move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, false, !@new_move.nil?) @sprites[:move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, false, !@new_move.nil?)
@sprites[:move_cursor].visible = (@mode == :choose_move) @sprites[:move_cursor].visible = (@mode == :choose_move)
@@ -314,10 +274,8 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
def initialize_ribbon_page_sprites def initialize_ribbon_page_sprites
# Cursor to highlight a ribbon selected to be swapped # Cursor to highlight a ribbon selected to be swapped
@sprites[:selected_ribbon_cursor] = UI::PokemonSummaryRibbonCursor.new(@viewport, true) @sprites[:selected_ribbon_cursor] = UI::PokemonSummaryRibbonCursor.new(@viewport, true)
@sprites[:selected_ribbon_cursor].visible = false
# Cursor to highlight the currently selected ribbon # Cursor to highlight the currently selected ribbon
@sprites[:ribbon_cursor] = UI::PokemonSummaryRibbonCursor.new(@viewport) @sprites[:ribbon_cursor] = UI::PokemonSummaryRibbonCursor.new(@viewport)
@sprites[:ribbon_cursor].visible = false
# Arrow to indicate more ribbons are above the ones visible when navigating ribbons # Arrow to indicate more ribbons are above the ones visible when navigating ribbons
add_animated_arrow(:up_arrow, 350, 56, :up) add_animated_arrow(:up_arrow, 350, 56, :up)
@sprites[:up_arrow].z = 1700 @sprites[:up_arrow].z = 1700
@@ -498,7 +456,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
end end
def draw_pokemon_name def draw_pokemon_name
draw_text(@pokemon.name, 42, 68) pokemon_name = @pokemon.name
pokemon_name = crop_text(pokemon_name, 152)
draw_text(pokemon_name, 42, 68)
end end
def draw_shiny_icon def draw_shiny_icon
@@ -669,13 +629,16 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
def draw_species def draw_species
draw_text(_INTL("Species"), 238, 118) draw_text(_INTL("Species"), 238, 118)
draw_text(@pokemon.speciesName, 428, 118, align: :center, theme: :black) species_name = @pokemon.speciesName
species_name = crop_text(species_name, 144)
draw_text(species_name, 428, 118, align: :center, theme: :black)
end end
def draw_original_trainer_details def draw_original_trainer_details
draw_text(_INTL("OT"), 238, 150) draw_text(_INTL("OT"), 238, 150)
draw_text(_INTL("ID No."), 238, 182) draw_text(_INTL("ID No."), 238, 182)
owner_name = (@pokemon.owner.name.empty?) ? _INTL("RENTAL") : @pokemon.owner.name owner_name = (@pokemon.owner.name.empty?) ? _INTL("RENTAL") : @pokemon.owner.name
owner_name = crop_text(owner_name, 144)
owner_theme = [:male, :female][@pokemon.owner.gender || 99] || :black owner_theme = [:male, :female][@pokemon.owner.gender || 99] || :black
draw_text(owner_name, 428, 150, align: :center, theme: owner_theme) draw_text(owner_name, 428, 150, align: :center, theme: owner_theme)
owner_number = (@pokemon.owner.name.empty?) ? "?????" : sprintf("%05d", @pokemon.owner.public_id) owner_number = (@pokemon.owner.name.empty?) ? "?????" : sprintf("%05d", @pokemon.owner.public_id)
@@ -687,11 +650,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
@sprites[:held_item_icon].item = @pokemon.item_id @sprites[:held_item_icon].item = @pokemon.item_id
draw_text(_INTL("Held Item"), 302, 230) draw_text(_INTL("Held Item"), 302, 230)
# Write the held item's name # Write the held item's name
if @pokemon.hasItem? item_name = (@pokemon.hasItem?) ? @pokemon.item.name : _INTL("None")
draw_text(@pokemon.item.name, 302, 262, theme: :black) item_name = crop_text(item_name, 192)
else draw_text(item_name, 302, 262, theme: :black)
draw_text(_INTL("None"), 302, 262, theme: :black)
end
end end
def draw_exp def draw_exp
@@ -753,7 +714,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
draw_text(_INTL("Ability"), 224, 262) draw_text(_INTL("Ability"), 224, 262)
ability = @pokemon.ability ability = @pokemon.ability
return if !ability return if !ability
draw_text(ability.name, 332, 262, theme: :black) ability_name = ability.name
ability_name = crop_text(ability_name, 182)
draw_text(ability_name, 328, 262, theme: :black)
draw_paragraph_text(ability.description, 224, 294, 284, 3, theme: :black) draw_paragraph_text(ability.description, 224, 294, 284, 3, theme: :black)
end end
@@ -777,6 +740,8 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
return return
end end
# Draw move name # Draw move name
move_name = move.name
move_name = crop_text(move_name, (showing_detailed_move_page?) ? 230 : 262)
draw_text(move.name, x + 8, y + 6, theme: :black) draw_text(move.name, x + 8, y + 6, theme: :black)
# Draw move type icon # Draw move type icon
type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position
@@ -934,8 +899,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
date = @pokemon.timeReceived.day date = @pokemon.timeReceived.day
month = pbGetMonthName(@pokemon.timeReceived.mon) month = pbGetMonthName(@pokemon.timeReceived.mon)
year = @pokemon.timeReceived.year year = @pokemon.timeReceived.year
# TODO: Write this date the wrong way round for United States of Americans. if System.user_language[3..4] == "US"
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n" memo += black_text_tag + _INTL("{1} {2}, {3}", month, date, year) + "\n"
else
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
end
end end
# Add map name Pokémon was received on to memo # Add map name Pokémon was received on to memo
map_name = pbGetMapNameFromId(@pokemon.obtain_map) map_name = pbGetMapNameFromId(@pokemon.obtain_map)
@@ -949,8 +917,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
date = @pokemon.timeEggHatched.day date = @pokemon.timeEggHatched.day
month = pbGetMonthName(@pokemon.timeEggHatched.mon) month = pbGetMonthName(@pokemon.timeEggHatched.mon)
year = @pokemon.timeEggHatched.year year = @pokemon.timeEggHatched.year
# TODO: Write this date the wrong way round for United States of Americans. if System.user_language[3..4] == "US"
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n" memo += black_text_tag + _INTL("{1} {2}, {3}", month, date, year) + "\n"
else
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
end
end end
map_name = pbGetMapNameFromId(@pokemon.hatched_map) map_name = pbGetMapNameFromId(@pokemon.hatched_map)
map_name = _INTL("Faraway place") if nil_or_empty?(map_name) map_name = _INTL("Faraway place") if nil_or_empty?(map_name)
@@ -970,8 +941,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
date = @pokemon.timeReceived.day date = @pokemon.timeReceived.day
month = pbGetMonthName(@pokemon.timeReceived.mon) month = pbGetMonthName(@pokemon.timeReceived.mon)
year = @pokemon.timeReceived.year year = @pokemon.timeReceived.year
# TODO: Write this date the wrong way round for United States of Americans. if System.user_language[3..4] == "US"
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n" memo += black_text_tag + _INTL("{1} {2}, {3}", month, date, year) + "\n"
else
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
end
end end
# Add map name egg was received on to memo # Add map name egg was received on to memo
map_name = pbGetMapNameFromId(@pokemon.obtain_map) map_name = pbGetMapNameFromId(@pokemon.obtain_map)
@@ -1148,12 +1122,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
@pokemon.moves[@move_index], @pokemon.moves[@swap_move_index] = @pokemon.moves[@swap_move_index], @pokemon.moves[@move_index] @pokemon.moves[@move_index], @pokemon.moves[@swap_move_index] = @pokemon.moves[@swap_move_index], @pokemon.moves[@move_index]
end end
@swap_move_index = -1 @swap_move_index = -1
@sprites[:selected_move_cursor].visible = false refresh_move_cursor
refresh refresh
else else
# Start swapping moves # Start swapping moves
@swap_move_index = @move_index @swap_move_index = @move_index
@sprites[:selected_move_cursor].visible = true
refresh_move_cursor refresh_move_cursor
end end
end end
@@ -1167,7 +1140,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
if @swap_move_index >= 0 if @swap_move_index >= 0
pbPlayCancelSE pbPlayCancelSE
@swap_move_index = -1 @swap_move_index = -1
@sprites[:selected_move_cursor].visible = false refresh_move_cursor
else else
pbPlayCloseMenuSE pbPlayCloseMenuSE
return true return true
@@ -1245,13 +1218,12 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
end end
end end
@swap_ribbon_index = -1 @swap_ribbon_index = -1
@sprites[:selected_ribbon_cursor].visible = false refresh_ribbon_cursor
refresh refresh
elsif @pokemon.ribbons[@ribbon_index] elsif @pokemon.ribbons[@ribbon_index]
# Start swapping ribbons # Start swapping ribbons
pbPlayDecisionSE pbPlayDecisionSE
@swap_ribbon_index = @ribbon_index @swap_ribbon_index = @ribbon_index
@sprites[:selected_ribbon_cursor].visible = true
refresh_ribbon_cursor refresh_ribbon_cursor
end end
elsif Input.trigger?(Input::BACK) elsif Input.trigger?(Input::BACK)
@@ -1259,7 +1231,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
if @swap_ribbon_index >= 0 if @swap_ribbon_index >= 0
pbPlayCancelSE pbPlayCancelSE
@swap_ribbon_index = -1 @swap_ribbon_index = -1
@sprites[:selected_ribbon_cursor].visible = false refresh_ribbon_cursor
else else
pbPlayCloseMenuSE pbPlayCloseMenuSE
return true return true