mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +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
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh
|
def draw_background
|
||||||
self.bitmap.clear
|
|
||||||
return if !@battler.pokemon
|
|
||||||
textPos = []
|
|
||||||
imagePos = []
|
|
||||||
# Draw background panel
|
|
||||||
self.bitmap.blt(0, 0, @databoxBitmap.bitmap, Rect.new(0, 0, @databoxBitmap.width, @databoxBitmap.height))
|
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
|
nameWidth = self.bitmap.text_size(@battler.name).width
|
||||||
nameOffset = 0
|
nameOffset = 0
|
||||||
nameOffset = nameWidth - 116 if nameWidth > 116
|
nameOffset = nameWidth - 116 if nameWidth > 116
|
||||||
textPos.push([@battler.name, @spriteBaseX + 8 - nameOffset, 12, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR])
|
pbDrawTextPositions(self.bitmap,
|
||||||
# Draw Pokémon's gender symbol
|
[[@battler.name, @spriteBaseX + 8 - nameOffset, 12, false, NAME_BASE_COLOR, NAME_SHADOW_COLOR]]
|
||||||
case @battler.displayGender
|
)
|
||||||
when 0 # Male
|
end
|
||||||
textPos.push([_INTL("♂"), @spriteBaseX + 126, 12, false, MALE_BASE_COLOR, MALE_SHADOW_COLOR])
|
|
||||||
when 1 # Female
|
def draw_level
|
||||||
textPos.push([_INTL("♀"), @spriteBaseX + 126, 12, false, FEMALE_BASE_COLOR, FEMALE_SHADOW_COLOR])
|
# "Lv" graphic
|
||||||
end
|
pbDrawImagePositions(self.bitmap,
|
||||||
pbDrawTextPositions(self.bitmap, textPos)
|
[["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16]]
|
||||||
# Draw Pokémon's level
|
)
|
||||||
imagePos.push(["Graphics/Pictures/Battle/overlay_lv", @spriteBaseX + 140, 16])
|
# Level number
|
||||||
pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16)
|
pbDrawNumber(@battler.level, self.bitmap, @spriteBaseX + 162, 16)
|
||||||
# Draw shiny icon
|
end
|
||||||
if @battler.shiny?
|
|
||||||
shinyX = (@battler.opposes?(0)) ? 206 : -6 # Foe's/player's
|
def draw_gender
|
||||||
imagePos.push(["Graphics/Pictures/shiny", @spriteBaseX + shinyX, 36])
|
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
|
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?
|
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?
|
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
|
primalX = (@battler.opposes?) ? 208 : -28 # Foe's/player's
|
||||||
if @battler.isSpecies?(:KYOGRE)
|
pbDrawImagePositions(self.bitmap, [[filename, @spriteBaseX + primalX, 4]]) if filename
|
||||||
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
|
|
||||||
end
|
end
|
||||||
# Draw owned icon (foe Pokémon only)
|
end
|
||||||
if @battler.owned? && @battler.opposes?(0)
|
|
||||||
imagePos.push(["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36])
|
def draw_owned_icon
|
||||||
end
|
return if !@battler.owned? || !@battler.opposes?(0) # Draw for foe Pokémon only
|
||||||
# Draw status icon
|
pbDrawImagePositions(self.bitmap, [["Graphics/Pictures/Battle/icon_own", @spriteBaseX + 8, 36]])
|
||||||
if @battler.status != :NONE
|
end
|
||||||
if @battler.status == :POISON && @battler.statusCount > 0 # Badly poisoned
|
|
||||||
s = GameData::Status.count - 1
|
def refresh
|
||||||
else
|
self.bitmap.clear
|
||||||
s = GameData::Status.get(@battler.status).icon_position
|
return if !@battler.pokemon
|
||||||
end
|
draw_background
|
||||||
if s >= 0
|
draw_name
|
||||||
imagePos.push(["Graphics/Pictures/Battle/icon_statuses", @spriteBaseX + 24, 36,
|
draw_level
|
||||||
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT])
|
draw_gender
|
||||||
end
|
draw_status
|
||||||
end
|
draw_shiny_icon
|
||||||
pbDrawImagePositions(self.bitmap, imagePos)
|
draw_special_form_icon
|
||||||
|
draw_owned_icon
|
||||||
refreshHP
|
refreshHP
|
||||||
refreshExp
|
refreshExp
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -364,9 +364,9 @@ class PokemonPartyPanel < SpriteWrapper
|
|||||||
@overlaysprite.bitmap&.clear
|
@overlaysprite.bitmap&.clear
|
||||||
draw_name
|
draw_name
|
||||||
draw_level
|
draw_level
|
||||||
|
draw_gender
|
||||||
draw_hp
|
draw_hp
|
||||||
draw_status
|
draw_status
|
||||||
draw_gender
|
|
||||||
draw_shiny_icon
|
draw_shiny_icon
|
||||||
draw_annotation
|
draw_annotation
|
||||||
end
|
end
|
||||||
@@ -388,6 +388,15 @@ class PokemonPartyPanel < SpriteWrapper
|
|||||||
pbSetSystemFont(@overlaysprite.bitmap)
|
pbSetSystemFont(@overlaysprite.bitmap)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draw_gender
|
||||||
|
return if @pokemon.egg? || @pokemon.genderless?
|
||||||
|
gender_text = (@pokemon.male?) ? _INTL("♂") : _INTL("♀")
|
||||||
|
base_color = (@pokemon.male?) ? Color.new(0, 112, 248) : Color.new(232, 32, 16)
|
||||||
|
shadow_color = (@pokemon.male?) ? Color.new(120, 184, 232) : Color.new(248, 168, 184)
|
||||||
|
pbDrawTextPositions(@overlaysprite.bitmap,
|
||||||
|
[[gender_text, 224, 22, 0, base_color, shadow_color]])
|
||||||
|
end
|
||||||
|
|
||||||
def draw_hp
|
def draw_hp
|
||||||
return if @pokemon.egg? || (@text && @text.length > 0)
|
return if @pokemon.egg? || (@text && @text.length > 0)
|
||||||
# HP numbers
|
# HP numbers
|
||||||
@@ -422,15 +431,6 @@ class PokemonPartyPanel < SpriteWrapper
|
|||||||
@overlaysprite.bitmap.blt(78, 68, @statuses.bitmap, statusrect)
|
@overlaysprite.bitmap.blt(78, 68, @statuses.bitmap, statusrect)
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw_gender
|
|
||||||
return if @pokemon.egg? || @pokemon.genderless?
|
|
||||||
gender_text = (@pokemon.male?) ? _INTL("♂") : _INTL("♀")
|
|
||||||
base_color = (@pokemon.male?) ? Color.new(0, 112, 248) : Color.new(232, 32, 16)
|
|
||||||
shadow_color = (@pokemon.male?) ? Color.new(120, 184, 232) : Color.new(248, 168, 184)
|
|
||||||
pbDrawTextPositions(@overlaysprite.bitmap,
|
|
||||||
[[gender_text, 224, 22, 0, base_color, shadow_color]])
|
|
||||||
end
|
|
||||||
|
|
||||||
def draw_shiny_icon
|
def draw_shiny_icon
|
||||||
return if @pokemon.egg? || !@pokemon.shiny?
|
return if @pokemon.egg? || !@pokemon.shiny?
|
||||||
pbDrawImagePositions(@overlaysprite.bitmap,
|
pbDrawImagePositions(@overlaysprite.bitmap,
|
||||||
|
|||||||
Reference in New Issue
Block a user