mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Refactored code that draws the Pokémon info box in battle
This commit is contained in:
@@ -205,62 +205,87 @@ class Battle::Scene::PokemonDataBox < SpriteWrapper
|
||||
end
|
||||
end
|
||||
|
||||
def refresh
|
||||
self.bitmap.clear
|
||||
return if !@battler.pokemon
|
||||
textPos = []
|
||||
imagePos = []
|
||||
# Draw background panel
|
||||
def draw_background
|
||||
self.bitmap.blt(0, 0, @databoxBitmap.bitmap, Rect.new(0, 0, @databoxBitmap.width, @databoxBitmap.height))
|
||||
# Draw Pokémon's name
|
||||
end
|
||||
|
||||
def draw_name
|
||||
nameWidth = self.bitmap.text_size(@battler.name).width
|
||||
nameOffset = 0
|
||||
nameOffset = nameWidth - 116 if nameWidth > 116
|
||||
textPos.push([@battler.name, @spriteBaseX + 8 - nameOffset, 12, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR])
|
||||
# Draw Pokémon's gender symbol
|
||||
case @battler.displayGender
|
||||
when 0 # Male
|
||||
textPos.push([_INTL("♂"), @spriteBaseX + 126, 12, false, MALE_BASE_COLOR, MALE_SHADOW_COLOR])
|
||||
when 1 # Female
|
||||
textPos.push([_INTL("♀"), @spriteBaseX + 126, 12, false, FEMALE_BASE_COLOR, FEMALE_SHADOW_COLOR])
|
||||
end
|
||||
pbDrawTextPositions(self.bitmap, textPos)
|
||||
# Draw Pokémon's level
|
||||
imagePos.push(["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16])
|
||||
pbDrawTextPositions(self.bitmap,
|
||||
[[@battler.name, @spriteBaseX + 8 - nameOffset, 12, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR]]
|
||||
)
|
||||
end
|
||||
|
||||
def draw_level
|
||||
# "Lv" graphic
|
||||
pbDrawImagePositions(self.bitmap,
|
||||
[["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16]]
|
||||
)
|
||||
# Level number
|
||||
pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16)
|
||||
# Draw shiny icon
|
||||
if @battler.shiny?
|
||||
shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
|
||||
imagePos.push(["Graphics/Pictures/shiny", @spriteBaseX + shinyX, 36])
|
||||
end
|
||||
|
||||
def draw_gender
|
||||
gender = @battler.displayGender
|
||||
return if ![0, 1].include?(gender)
|
||||
gender_text = (gender == 0) ? _INTL("♂") : _INTL("♀")
|
||||
base_color = (gender == 0) ? MALE_BASE_COLOR : FEMALE_BASE_COLOR
|
||||
shadow_color = (gender == 0) ? MALE_SHADOW_COLOR : FEMALE_SHADOW_COLOR
|
||||
pbDrawTextPositions(self.bitmap, [[gender_text, @spriteBaseX + 126, 12, false, base_color, shadow_color]])
|
||||
end
|
||||
|
||||
def draw_status
|
||||
return if @battler.status == :NONE
|
||||
if @battler.status == :POISON && @battler.statusCount > 0 # Badly poisoned
|
||||
s = GameData::Status.count - 1
|
||||
else
|
||||
s = GameData::Status.get(@battler.status).icon_position
|
||||
end
|
||||
# Draw Mega Evolution/Primal Reversion icon
|
||||
return if s < 0
|
||||
pbDrawImagePositions(self.bitmap, [["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
|
||||
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT]])
|
||||
end
|
||||
|
||||
def draw_shiny_icon
|
||||
return if !@battler.shiny?
|
||||
shiny_x = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
|
||||
pbDrawImagePositions(self.bitmap, [["Graphics/Pictures/shiny", @spriteBaseX + shiny_x, 36]])
|
||||
end
|
||||
|
||||
def draw_special_form_icon
|
||||
# Mega Evolution/Primal Reversion icon
|
||||
if @battler.mega?
|
||||
imagePos.push(["Graphics/Pictures/Battle/icon_mega", @spriteBaseX + 8, 34])
|
||||
pbDrawImagePositions(self.bitmap, [["Graphics/Pictures/Battle/icon_mega", @spriteBaseX + 8, 34]])
|
||||
elsif @battler.primal?
|
||||
filename = nil
|
||||
if @battler.isSpecies?(:GROUDON)
|
||||
filename = "Graphics/Pictures/Battle/icon_primal_Groudon"
|
||||
elsif @battler.isSpecies?(:KYOGRE)
|
||||
filename = "Graphics/Pictures/Battle/icon_primal_Kyogre"
|
||||
end
|
||||
primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's
|
||||
if @battler.isSpecies?(:KYOGRE)
|
||||
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Kyogre", @spriteBaseX + primalX, 4])
|
||||
elsif @battler.isSpecies?(:GROUDON)
|
||||
imagePos.push(["Graphics/Pictures/Battle/icon_primal_Groudon", @spriteBaseX + primalX, 4])
|
||||
end
|
||||
pbDrawImagePositions(self.bitmap, [[filename, @spriteBaseX + primalX, 4]]) if filename
|
||||
end
|
||||
# Draw owned icon (foe Pokémon only)
|
||||
if @battler.owned? && @battler.opposes?(0)
|
||||
imagePos.push(["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36])
|
||||
end
|
||||
# Draw status icon
|
||||
if @battler.status != :NONE
|
||||
if @battler.status == :POISON && @battler.statusCount > 0 # Badly poisoned
|
||||
s = GameData::Status.count - 1
|
||||
else
|
||||
s = GameData::Status.get(@battler.status).icon_position
|
||||
end
|
||||
if s >= 0
|
||||
imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
|
||||
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT])
|
||||
end
|
||||
end
|
||||
pbDrawImagePositions(self.bitmap, imagePos)
|
||||
end
|
||||
|
||||
def draw_owned_icon
|
||||
return if !@battler.owned? || !@battler.opposes?(0) # Draw for foe Pokémon only
|
||||
pbDrawImagePositions(self.bitmap, [["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36]])
|
||||
end
|
||||
|
||||
def refresh
|
||||
self.bitmap.clear
|
||||
return if !@battler.pokemon
|
||||
draw_background
|
||||
draw_name
|
||||
draw_level
|
||||
draw_gender
|
||||
draw_status
|
||||
draw_shiny_icon
|
||||
draw_special_form_icon
|
||||
draw_owned_icon
|
||||
refreshHP
|
||||
refreshExp
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user