mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
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:
@@ -54,7 +54,7 @@ module Settings
|
||||
# The maximum amount of soot the player can have.
|
||||
MAX_SOOT = 9_999
|
||||
# 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
|
||||
# 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.
|
||||
|
||||
@@ -308,22 +308,24 @@ end
|
||||
# Sprite class that stores multiple bitmaps, and displays only one at once.
|
||||
#===============================================================================
|
||||
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)
|
||||
super(viewport)
|
||||
self.x = x
|
||||
self.y = y
|
||||
@bitmaps = {}
|
||||
@currentBitmap = nil
|
||||
@changeling_data = {}
|
||||
@current_bitmap = nil
|
||||
initialize_changeling_data
|
||||
end
|
||||
|
||||
def addBitmap(key, path)
|
||||
@bitmaps[key]&.dispose
|
||||
@bitmaps[key] = AnimatedBitmap.new(path)
|
||||
end
|
||||
|
||||
def changeBitmap(key)
|
||||
@currentBitmap = @bitmaps[key]
|
||||
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil
|
||||
def initialize_changeling_data
|
||||
self.class::BITMAPS.each_pair { |mode, data| add_bitmap(mode, data) }
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -333,9 +335,37 @@ class ChangelingSprite < Sprite
|
||||
super
|
||||
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
|
||||
return if disposed?
|
||||
@bitmaps.each_value { |bm| bm.update }
|
||||
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil
|
||||
self.bitmap = @current_bitmap.bitmap if @current_bitmap
|
||||
end
|
||||
end
|
||||
|
||||
@@ -94,7 +94,7 @@ class Pokemon
|
||||
# Max EVs that a single stat can have
|
||||
EV_STAT_LIMIT = 252
|
||||
# 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
|
||||
MAX_MOVES = 4
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ class PokemonPartyConfirmCancelSprite < Sprite
|
||||
@refreshBitmap = true
|
||||
@bgsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
if narrowbox
|
||||
@bgsprite.addBitmap("desel", "Graphics/UI/Party/icon_cancel_narrow")
|
||||
@bgsprite.addBitmap("sel", "Graphics/UI/Party/icon_cancel_narrow_sel")
|
||||
@bgsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_cancel_narrow")
|
||||
@bgsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_cancel_narrow_sel")
|
||||
else
|
||||
@bgsprite.addBitmap("desel", "Graphics/UI/Party/icon_cancel")
|
||||
@bgsprite.addBitmap("sel", "Graphics/UI/Party/icon_cancel_sel")
|
||||
@bgsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_cancel")
|
||||
@bgsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_cancel_sel")
|
||||
end
|
||||
@bgsprite.changeBitmap("desel")
|
||||
@bgsprite.change_bitmap(:desel)
|
||||
@overlaysprite = BitmapSprite.new(@bgsprite.bitmap.width, @bgsprite.bitmap.height, viewport)
|
||||
@overlaysprite.z = self.z + 1
|
||||
pbSetSystemFont(@overlaysprite.bitmap)
|
||||
@@ -61,7 +61,7 @@ class PokemonPartyConfirmCancelSprite < Sprite
|
||||
|
||||
def refresh
|
||||
if @bgsprite && !@bgsprite.disposed?
|
||||
@bgsprite.changeBitmap((@selected) ? "sel" : "desel")
|
||||
@bgsprite.change_bitmap((@selected) ? :sel : :desel)
|
||||
@bgsprite.x = self.x
|
||||
@bgsprite.y = self.y
|
||||
@bgsprite.color = self.color
|
||||
@@ -184,31 +184,31 @@ class PokemonPartyPanel < Sprite
|
||||
@panelbgsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@panelbgsprite.z = self.z
|
||||
if @active # Rounded panel
|
||||
@panelbgsprite.addBitmap("able", "Graphics/UI/Party/panel_round")
|
||||
@panelbgsprite.addBitmap("ablesel", "Graphics/UI/Party/panel_round_sel")
|
||||
@panelbgsprite.addBitmap("fainted", "Graphics/UI/Party/panel_round_faint")
|
||||
@panelbgsprite.addBitmap("faintedsel", "Graphics/UI/Party/panel_round_faint_sel")
|
||||
@panelbgsprite.addBitmap("swap", "Graphics/UI/Party/panel_round_swap")
|
||||
@panelbgsprite.addBitmap("swapsel", "Graphics/UI/Party/panel_round_swap_sel")
|
||||
@panelbgsprite.addBitmap("swapsel2", "Graphics/UI/Party/panel_round_swap_sel2")
|
||||
@panelbgsprite.add_bitmap(:able, "Graphics/UI/Party/panel_round")
|
||||
@panelbgsprite.add_bitmap(:ablesel, "Graphics/UI/Party/panel_round_sel")
|
||||
@panelbgsprite.add_bitmap(:fainted, "Graphics/UI/Party/panel_round_faint")
|
||||
@panelbgsprite.add_bitmap(:faintedsel, "Graphics/UI/Party/panel_round_faint_sel")
|
||||
@panelbgsprite.add_bitmap(:swap, "Graphics/UI/Party/panel_round_swap")
|
||||
@panelbgsprite.add_bitmap(:swapsel, "Graphics/UI/Party/panel_round_swap_sel")
|
||||
@panelbgsprite.add_bitmap(:swapsel2, "Graphics/UI/Party/panel_round_swap_sel2")
|
||||
else # Rectangular panel
|
||||
@panelbgsprite.addBitmap("able", "Graphics/UI/Party/panel_rect")
|
||||
@panelbgsprite.addBitmap("ablesel", "Graphics/UI/Party/panel_rect_sel")
|
||||
@panelbgsprite.addBitmap("fainted", "Graphics/UI/Party/panel_rect_faint")
|
||||
@panelbgsprite.addBitmap("faintedsel", "Graphics/UI/Party/panel_rect_faint_sel")
|
||||
@panelbgsprite.addBitmap("swap", "Graphics/UI/Party/panel_rect_swap")
|
||||
@panelbgsprite.addBitmap("swapsel", "Graphics/UI/Party/panel_rect_swap_sel")
|
||||
@panelbgsprite.addBitmap("swapsel2", "Graphics/UI/Party/panel_rect_swap_sel2")
|
||||
@panelbgsprite.add_bitmap(:able, "Graphics/UI/Party/panel_rect")
|
||||
@panelbgsprite.add_bitmap(:ablesel, "Graphics/UI/Party/panel_rect_sel")
|
||||
@panelbgsprite.add_bitmap(:fainted, "Graphics/UI/Party/panel_rect_faint")
|
||||
@panelbgsprite.add_bitmap(:faintedsel, "Graphics/UI/Party/panel_rect_faint_sel")
|
||||
@panelbgsprite.add_bitmap(:swap, "Graphics/UI/Party/panel_rect_swap")
|
||||
@panelbgsprite.add_bitmap(:swapsel, "Graphics/UI/Party/panel_rect_swap_sel")
|
||||
@panelbgsprite.add_bitmap(:swapsel2, "Graphics/UI/Party/panel_rect_swap_sel2")
|
||||
end
|
||||
@hpbgsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@hpbgsprite.z = self.z + 1
|
||||
@hpbgsprite.addBitmap("able", _INTL("Graphics/UI/Party/overlay_hp_back"))
|
||||
@hpbgsprite.addBitmap("fainted", _INTL("Graphics/UI/Party/overlay_hp_back_faint"))
|
||||
@hpbgsprite.addBitmap("swap", _INTL("Graphics/UI/Party/overlay_hp_back_swap"))
|
||||
@hpbgsprite.add_bitmap(:able, _INTL("Graphics/UI/Party/overlay_hp_back"))
|
||||
@hpbgsprite.add_bitmap(:fainted, _INTL("Graphics/UI/Party/overlay_hp_back_faint"))
|
||||
@hpbgsprite.add_bitmap(:swap, _INTL("Graphics/UI/Party/overlay_hp_back_swap"))
|
||||
@ballsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@ballsprite.z = self.z + 1
|
||||
@ballsprite.addBitmap("desel", "Graphics/UI/Party/icon_ball")
|
||||
@ballsprite.addBitmap("sel", "Graphics/UI/Party/icon_ball_sel")
|
||||
@ballsprite.add_bitmap(:desel, "Graphics/UI/Party/icon_ball")
|
||||
@ballsprite.add_bitmap(:sel, "Graphics/UI/Party/icon_ball_sel")
|
||||
@pkmnsprite = PokemonIconSprite.new(pokemon, viewport)
|
||||
@pkmnsprite.setOffset(PictureOrigin::CENTER)
|
||||
@pkmnsprite.active = @active
|
||||
@@ -296,21 +296,21 @@ class PokemonPartyPanel < Sprite
|
||||
return if !@panelbgsprite || @panelbgsprite.disposed?
|
||||
if self.selected
|
||||
if self.preselected
|
||||
@panelbgsprite.changeBitmap("swapsel2")
|
||||
@panelbgsprite.change_bitmap(:swapsel2)
|
||||
elsif @switching
|
||||
@panelbgsprite.changeBitmap("swapsel")
|
||||
@panelbgsprite.change_bitmap(:swapsel)
|
||||
elsif @pokemon.fainted?
|
||||
@panelbgsprite.changeBitmap("faintedsel")
|
||||
@panelbgsprite.change_bitmap(:faintedsel)
|
||||
else
|
||||
@panelbgsprite.changeBitmap("ablesel")
|
||||
@panelbgsprite.change_bitmap(:ablesel)
|
||||
end
|
||||
else
|
||||
if self.preselected
|
||||
@panelbgsprite.changeBitmap("swap")
|
||||
@panelbgsprite.change_bitmap(:swap)
|
||||
elsif @pokemon.fainted?
|
||||
@panelbgsprite.changeBitmap("fainted")
|
||||
@panelbgsprite.change_bitmap(:fainted)
|
||||
else
|
||||
@panelbgsprite.changeBitmap("able")
|
||||
@panelbgsprite.change_bitmap(:able)
|
||||
end
|
||||
end
|
||||
@panelbgsprite.x = self.x
|
||||
@@ -323,11 +323,11 @@ class PokemonPartyPanel < Sprite
|
||||
@hpbgsprite.visible = (!@pokemon.egg? && !(@text && @text.length > 0))
|
||||
return if !@hpbgsprite.visible
|
||||
if self.preselected || (self.selected && @switching)
|
||||
@hpbgsprite.changeBitmap("swap")
|
||||
@hpbgsprite.change_bitmap(:swap)
|
||||
elsif @pokemon.fainted?
|
||||
@hpbgsprite.changeBitmap("fainted")
|
||||
@hpbgsprite.change_bitmap(:fainted)
|
||||
else
|
||||
@hpbgsprite.changeBitmap("able")
|
||||
@hpbgsprite.change_bitmap(:able)
|
||||
end
|
||||
@hpbgsprite.x = self.x + 96
|
||||
@hpbgsprite.y = self.y + 50
|
||||
@@ -336,7 +336,7 @@ class PokemonPartyPanel < Sprite
|
||||
|
||||
def refresh_ball_graphic
|
||||
return if !@ballsprite || @ballsprite.disposed?
|
||||
@ballsprite.changeBitmap((self.selected) ? "sel" : "desel")
|
||||
@ballsprite.change_bitmap((self.selected) ? :sel : :desel)
|
||||
@ballsprite.x = self.x + 10
|
||||
@ballsprite.y = self.y
|
||||
@ballsprite.color = self.color
|
||||
|
||||
@@ -156,15 +156,15 @@ class PokemonBoxArrow < Sprite
|
||||
@quickswap = false
|
||||
@heldpkmn = nil
|
||||
@handsprite = ChangelingSprite.new(0, 0, viewport)
|
||||
@handsprite.addBitmap("point1", "Graphics/UI/Storage/cursor_point_1")
|
||||
@handsprite.addBitmap("point2", "Graphics/UI/Storage/cursor_point_2")
|
||||
@handsprite.addBitmap("grab", "Graphics/UI/Storage/cursor_grab")
|
||||
@handsprite.addBitmap("fist", "Graphics/UI/Storage/cursor_fist")
|
||||
@handsprite.addBitmap("point1q", "Graphics/UI/Storage/cursor_point_1_q")
|
||||
@handsprite.addBitmap("point2q", "Graphics/UI/Storage/cursor_point_2_q")
|
||||
@handsprite.addBitmap("grabq", "Graphics/UI/Storage/cursor_grab_q")
|
||||
@handsprite.addBitmap("fistq", "Graphics/UI/Storage/cursor_fist_q")
|
||||
@handsprite.changeBitmap("fist")
|
||||
@handsprite.add_bitmap(:point1, "Graphics/UI/Storage/cursor_point_1")
|
||||
@handsprite.add_bitmap(:point2, "Graphics/UI/Storage/cursor_point_2")
|
||||
@handsprite.add_bitmap(:grab, "Graphics/UI/Storage/cursor_grab")
|
||||
@handsprite.add_bitmap(:fist, "Graphics/UI/Storage/cursor_fist")
|
||||
@handsprite.add_bitmap(:point1q, "Graphics/UI/Storage/cursor_point_1_q")
|
||||
@handsprite.add_bitmap(:point2q, "Graphics/UI/Storage/cursor_point_2_q")
|
||||
@handsprite.add_bitmap(:grabq, "Graphics/UI/Storage/cursor_grab_q")
|
||||
@handsprite.add_bitmap(:fistq, "Graphics/UI/Storage/cursor_fist_q")
|
||||
@handsprite.change_bitmap(:fist)
|
||||
@spriteX = self.x
|
||||
@spriteY = self.y
|
||||
end
|
||||
@@ -269,36 +269,36 @@ class PokemonBoxArrow < Sprite
|
||||
@holding = false if !heldpkmn
|
||||
if @grabbing_timer_start
|
||||
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)
|
||||
else
|
||||
@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)
|
||||
self.y = @spriteY + delta_y
|
||||
@grabbing_timer_start = nil if delta_y == 0
|
||||
end
|
||||
elsif @placing_timer_start
|
||||
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)
|
||||
else
|
||||
@holding = false
|
||||
@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)
|
||||
self.y = @spriteY + delta_y
|
||||
@placing_timer_start = nil if delta_y == 0
|
||||
end
|
||||
elsif holding?
|
||||
@handsprite.changeBitmap((@quickswap) ? "fistq" : "fist")
|
||||
@handsprite.change_bitmap((@quickswap) ? :fistq : :fist)
|
||||
else # Idling
|
||||
self.x = @spriteX
|
||||
self.y = @spriteY
|
||||
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
|
||||
@handsprite.changeBitmap((@quickswap) ? "point2q" : "point2")
|
||||
@handsprite.change_bitmap((@quickswap) ? :point2q : :point2)
|
||||
end
|
||||
end
|
||||
@updating = false
|
||||
|
||||
@@ -7,7 +7,7 @@ module UI
|
||||
GRAPHICS_FOLDER = "" # Subfolder in UI_FOLDER
|
||||
BACKGROUND_FILENAME = "bg"
|
||||
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
|
||||
@@ -18,7 +18,7 @@ module UI
|
||||
initialize_background
|
||||
initialize_overlay
|
||||
initialize_message_box
|
||||
# TODO: Initialize dialogue box for messages to use?
|
||||
# TODO: Initialize dialogue box for messages to use.
|
||||
initialize_sprites
|
||||
refresh
|
||||
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)
|
||||
@sprites[overlay].draw_themed_text(string.to_s, text_x, text_y, align, theme, outline)
|
||||
end
|
||||
|
||||
@@ -1,118 +1,79 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class UI::PokemonSummaryMoveCursor < Sprite
|
||||
attr_reader :index
|
||||
|
||||
class UI::PokemonSummaryMoveCursor < ChangelingSprite
|
||||
BITMAPS = {
|
||||
:normal => ["Graphics/UI/Summary/cursor_move", 0, 0, 252, 74],
|
||||
:selected => ["Graphics/UI/Summary/cursor_move", 0, 74, 252, 74]
|
||||
}
|
||||
CURSOR_THICKNESS = 6
|
||||
|
||||
def initialize(viewport = nil, preselected = false, new_move = false)
|
||||
super(viewport)
|
||||
@cursor_bitmap = AnimatedBitmap.new("Graphics/UI/Summary/cursor_move")
|
||||
@frame = 0
|
||||
@index = 0
|
||||
@preselected = preselected
|
||||
@new_move = new_move
|
||||
def initialize(viewport = nil, selected = false, extra_move = false)
|
||||
super(0, 0, viewport)
|
||||
change_bitmap((selected) ? :selected : :normal)
|
||||
@extra_move = extra_move
|
||||
self.z = 1600
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@cursor_bitmap.dispose
|
||||
super
|
||||
self.visible = false
|
||||
@index = 0
|
||||
end
|
||||
|
||||
def index=(value)
|
||||
@index = value
|
||||
refresh
|
||||
refresh_visibility
|
||||
refresh_position
|
||||
end
|
||||
|
||||
def refresh
|
||||
cursor_width = @cursor_bitmap.width
|
||||
cursor_height = @cursor_bitmap.height / 2
|
||||
def refresh_visibility
|
||||
self.visible = (@index >= 0)
|
||||
end
|
||||
|
||||
|
||||
def refresh_position
|
||||
return if @index < 0
|
||||
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_OFFSET_WHEN_NEW_MOVE if @new_move
|
||||
self.y += UI::PokemonSummaryVisuals::MOVE_LIST_NEW_MOVE_SPACING if @new_move && self.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
|
||||
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 @extra_move
|
||||
self.y += UI::PokemonSummaryVisuals::MOVE_LIST_NEW_MOVE_SPACING if @extra_move && @index == Pokemon::MAX_MOVES
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class UI::PokemonSummaryRibbonCursor < Sprite
|
||||
class UI::PokemonSummaryRibbonCursor < ChangelingSprite
|
||||
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
|
||||
|
||||
def initialize(viewport = nil, preselected = false)
|
||||
super(viewport)
|
||||
@cursor_bitmap = AnimatedBitmap.new("Graphics/UI/Summary/cursor_ribbon")
|
||||
@frame = 0
|
||||
@index = 0
|
||||
@preselected = preselected
|
||||
@updating = false
|
||||
@cursor_visible = true
|
||||
def initialize(viewport = nil, selected = false)
|
||||
super(0, 0, viewport)
|
||||
change_bitmap((selected) ? :selected : :normal)
|
||||
self.z = 1600
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@cursor_bitmap.dispose
|
||||
super
|
||||
self.visible = false
|
||||
@index = 0
|
||||
end
|
||||
|
||||
def index=(value)
|
||||
@index = value
|
||||
refresh
|
||||
refresh_visibility
|
||||
refresh_position
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
super
|
||||
@cursor_visible = value if !@updating
|
||||
def refresh_visibility
|
||||
self.visible = (@index >= 0 && @index < UI::PokemonSummaryVisuals::RIBBON_COLUMNS * UI::PokemonSummaryVisuals::RIBBON_ROWS)
|
||||
end
|
||||
|
||||
def recheck_visibility
|
||||
@updating = true
|
||||
self.visible = @cursor_visible && @index >= 0 &&
|
||||
@index < UI::PokemonSummaryVisuals::RIBBON_COLUMNS * UI::PokemonSummaryVisuals::RIBBON_ROWS
|
||||
@updating = false
|
||||
end
|
||||
|
||||
def refresh
|
||||
recheck_visibility
|
||||
def refresh_position
|
||||
return if @index < 0
|
||||
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 - CURSOR_THICKNESS + ((self.index % cols) * offset_x)
|
||||
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
|
||||
|
||||
@@ -305,7 +266,6 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
@sprites[:pokemon_icon].visible = (@mode == :choose_move)
|
||||
# Cursor to highlight a move selected to be swapped
|
||||
@sprites[:selected_move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, true)
|
||||
@sprites[:selected_move_cursor].visible = false
|
||||
# Cursor to highlight the currently selected move
|
||||
@sprites[:move_cursor] = UI::PokemonSummaryMoveCursor.new(@viewport, false, !@new_move.nil?)
|
||||
@sprites[:move_cursor].visible = (@mode == :choose_move)
|
||||
@@ -314,10 +274,8 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
def initialize_ribbon_page_sprites
|
||||
# Cursor to highlight a ribbon selected to be swapped
|
||||
@sprites[:selected_ribbon_cursor] = UI::PokemonSummaryRibbonCursor.new(@viewport, true)
|
||||
@sprites[:selected_ribbon_cursor].visible = false
|
||||
# Cursor to highlight the currently selected ribbon
|
||||
@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
|
||||
add_animated_arrow(:up_arrow, 350, 56, :up)
|
||||
@sprites[:up_arrow].z = 1700
|
||||
@@ -498,7 +456,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def draw_shiny_icon
|
||||
@@ -669,13 +629,16 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
|
||||
def draw_species
|
||||
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
|
||||
|
||||
def draw_original_trainer_details
|
||||
draw_text(_INTL("OT"), 238, 150)
|
||||
draw_text(_INTL("ID No."), 238, 182)
|
||||
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
|
||||
draw_text(owner_name, 428, 150, align: :center, theme: owner_theme)
|
||||
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
|
||||
draw_text(_INTL("Held Item"), 302, 230)
|
||||
# Write the held item's name
|
||||
if @pokemon.hasItem?
|
||||
draw_text(@pokemon.item.name, 302, 262, theme: :black)
|
||||
else
|
||||
draw_text(_INTL("None"), 302, 262, theme: :black)
|
||||
end
|
||||
item_name = (@pokemon.hasItem?) ? @pokemon.item.name : _INTL("None")
|
||||
item_name = crop_text(item_name, 192)
|
||||
draw_text(item_name, 302, 262, theme: :black)
|
||||
end
|
||||
|
||||
def draw_exp
|
||||
@@ -753,7 +714,9 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
draw_text(_INTL("Ability"), 224, 262)
|
||||
ability = @pokemon.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)
|
||||
end
|
||||
|
||||
@@ -777,6 +740,8 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
return
|
||||
end
|
||||
# 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 move type icon
|
||||
type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position
|
||||
@@ -934,8 +899,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
date = @pokemon.timeReceived.day
|
||||
month = pbGetMonthName(@pokemon.timeReceived.mon)
|
||||
year = @pokemon.timeReceived.year
|
||||
# TODO: Write this date the wrong way round for United States of Americans.
|
||||
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
|
||||
if System.user_language[3..4] == "US"
|
||||
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
|
||||
# Add map name Pokémon was received on to memo
|
||||
map_name = pbGetMapNameFromId(@pokemon.obtain_map)
|
||||
@@ -949,8 +917,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
date = @pokemon.timeEggHatched.day
|
||||
month = pbGetMonthName(@pokemon.timeEggHatched.mon)
|
||||
year = @pokemon.timeEggHatched.year
|
||||
# TODO: Write this date the wrong way round for United States of Americans.
|
||||
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
|
||||
if System.user_language[3..4] == "US"
|
||||
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
|
||||
map_name = pbGetMapNameFromId(@pokemon.hatched_map)
|
||||
map_name = _INTL("Faraway place") if nil_or_empty?(map_name)
|
||||
@@ -970,8 +941,11 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
date = @pokemon.timeReceived.day
|
||||
month = pbGetMonthName(@pokemon.timeReceived.mon)
|
||||
year = @pokemon.timeReceived.year
|
||||
# TODO: Write this date the wrong way round for United States of Americans.
|
||||
memo += black_text_tag + _INTL("{1} {2}, {3}", date, month, year) + "\n"
|
||||
if System.user_language[3..4] == "US"
|
||||
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
|
||||
# Add map name egg was received on to memo
|
||||
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]
|
||||
end
|
||||
@swap_move_index = -1
|
||||
@sprites[:selected_move_cursor].visible = false
|
||||
refresh_move_cursor
|
||||
refresh
|
||||
else
|
||||
# Start swapping moves
|
||||
@swap_move_index = @move_index
|
||||
@sprites[:selected_move_cursor].visible = true
|
||||
refresh_move_cursor
|
||||
end
|
||||
end
|
||||
@@ -1167,7 +1140,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
if @swap_move_index >= 0
|
||||
pbPlayCancelSE
|
||||
@swap_move_index = -1
|
||||
@sprites[:selected_move_cursor].visible = false
|
||||
refresh_move_cursor
|
||||
else
|
||||
pbPlayCloseMenuSE
|
||||
return true
|
||||
@@ -1245,13 +1218,12 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
end
|
||||
end
|
||||
@swap_ribbon_index = -1
|
||||
@sprites[:selected_ribbon_cursor].visible = false
|
||||
refresh_ribbon_cursor
|
||||
refresh
|
||||
elsif @pokemon.ribbons[@ribbon_index]
|
||||
# Start swapping ribbons
|
||||
pbPlayDecisionSE
|
||||
@swap_ribbon_index = @ribbon_index
|
||||
@sprites[:selected_ribbon_cursor].visible = true
|
||||
refresh_ribbon_cursor
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
@@ -1259,7 +1231,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
|
||||
if @swap_ribbon_index >= 0
|
||||
pbPlayCancelSE
|
||||
@swap_ribbon_index = -1
|
||||
@sprites[:selected_ribbon_cursor].visible = false
|
||||
refresh_ribbon_cursor
|
||||
else
|
||||
pbPlayCloseMenuSE
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user