#=============================================================================
# FRLG UI
# Battle Scene Script
# WIP ~Swdfm 2024-12-12
#=============================================================================
class Battle::Scene
# Text colors
MESSAGE_BASE_COLOR = Color.new(248, 248, 248)
MESSAGE_SHADOW_COLOR = Color.new(104, 88, 112)
end
#===============================================================================
# Base class for all three menu classes below
#===============================================================================
class Battle::Scene::MenuBase
# NOTE: Button width is half the width of the graphic containing them all.
BUTTON_HEIGHT = 46 # TODO CHECK!
TEXT_BASE_COLOR = Color.new(80, 80, 88)
TEXT_SHADOW_COLOR = Color.new(160, 160, 168)
end
#===============================================================================
# Command menu (Fight/Pokémon/Bag/Run)
#===============================================================================
class Battle::Scene::CommandMenu < Battle::Scene::MenuBase
# If true, displays graphics from Graphics/UI/Battle/overlay_command.png
# and Graphics/UI/Battle/cursor_command.png.
# If false, just displays text and the command window over the graphic
# Graphics/UI/Battle/overlay_message.png. You will need to edit def
# pbShowWindow to make the graphic appear while the command menu is being
# displayed.
USE_GRAPHICS = false
=begin
# Lists of which button graphics to use in different situations/types of battle.
MODES = [
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug-Catching Contest
]
=end
end
#===============================================================================
# Fight menu (choose a move)
#===============================================================================
class Battle::Scene::FightMenu < Battle::Scene::MenuBase
GET_MOVE_TEXT_COLOR_FROM_MOVE_BUTTON = false
# If true, displays graphics from Graphics/UI/Battle/overlay_fight.png
# and Graphics/UI/Battle/cursor_fight.png.
# If false, just displays text and the command window over the graphic
# Graphics/UI/Battle/overlay_message.png. You will need to edit def
# pbShowWindow to make the graphic appear while the command menu is being
# displayed.
USE_GRAPHICS = false
TYPE_ICON_HEIGHT = 28 # TODO CHECK!
end
#===============================================================================
# Target menu (choose a move's target)
# NOTE: Unlike the command and fight menus, this one doesn't have a textbox-only
# version.
#===============================================================================
class Battle::Scene::TargetMenu < Battle::Scene::MenuBase
# Lists of which button graphics to use in different situations/types of battle.
=begin
MODES = [
[0, 2, 1, 3], # 0 = Regular battle
[0, 2, 1, 9], # 1 = Regular battle with "Cancel" instead of "Run"
[0, 2, 1, 4], # 2 = Regular battle with "Call" instead of "Run"
[5, 7, 6, 3], # 3 = Safari Zone
[0, 8, 1, 3] # 4 = Bug-Catching Contest
]
=end
#CMD_BUTTON_WIDTH_SMALL = 170
#TEXT_BASE_COLOR = Color.new(240, 248, 224)
#TEXT_SHADOW_COLOR = Color.new(64, 64, 64)
end
#===============================================================================
# Makes a side's party bar and balls appear
#===============================================================================
class Battle::Scene::Animation::LineupAppear < Battle::Scene::Animation
BAR_DISPLAY_WIDTH = 200 # 248
#-------------------------------
# Changes made here ~Swdfm
def resetGraphics(sprites)
bar = sprites["partyBar_#{@side}"]
case @side
when 0 # Player's lineup
barX = Graphics.width - BAR_DISPLAY_WIDTH
barY = Graphics.height - 132 # 142
ballX = barX + 40 # 44
ballY = barY - 16 # 30
when 1 # Opposing lineup
barX = BAR_DISPLAY_WIDTH
barY = 100 # 114
ballX = barX - 44 - 16 # 16 is width of ball icon, was 30
ballY = barY - 16 # 30
barX -= bar.bitmap.width
end
ballXdiff = 20 * (1 - (2 * @side)) # was 32 as first number
bar.x = barX
bar.y = barY
bar.opacity = 255
bar.visible = false
Battle::Scene::NUM_BALLS.times do |i|
ball = sprites["partyBall_#{@side}_#{i}"]
ball.x = ballX
ball.y = ballY
ball.opacity = 255
ball.visible = false
ballX += ballXdiff
end
end
end
#===============================================================================
# Data box for regular battles
#===============================================================================
class Battle::Scene::PokemonDataBox < Sprite
# Text colors
NAME_BASE_COLOR = Color.new(64, 64, 64) # ~Swdfm
NAME_SHADOW_COLOR = Color.new(216, 208, 176) # ~Swdfm
=begin
def initializeDataBoxGraphic(sideSize)
onPlayerSide = @battler.index.even?
# Get the data box graphic and set whether the HP numbers/Exp bar are shown
if sideSize == 1 # One Pokémon on side, use the regular dara box BG
bgFilename = [_INTL("Graphics/UI/Battle/databox_normal"),
_INTL("Graphics/UI/Battle/databox_normal_foe")][@battler.index % 2]
if onPlayerSide
@show_hp_numbers = true
@show_exp_bar = true
end
else # Multiple Pokémon on side, use the thin dara box BG
bgFilename = [_INTL("Graphics/UI/Battle/databox_thin"),
_INTL("Graphics/UI/Battle/databox_thin_foe")][@battler.index % 2]
end
@databoxBitmap&.dispose
@databoxBitmap = AnimatedBitmap.new(bgFilename)
# Determine the co-ordinates of the data box and the left edge padding width
end
=end
#-------------------------------
# NOTE: Many parts were originally in PokeBattle_SceneConstants section!
# Changes made here! ~Swdfm
# NOTE: No triples in vanilla so kept as is
alias frlg_init_data_box_graphic initializeDataBoxGraphic
def initializeDataBoxGraphic(sideSize)
frlg_init_data_box_graphic(sideSize)
onPlayerSide = @battler.index.even?
@spriteBaseX_hp = 0
@spritebaseY_hp = 0
@spriteBaseX_stat = 0
@spritebaseY_stat = 0
if onPlayerSide
@spriteX = Graphics.width - 244 # same!
@spriteY = Graphics.height - 172 # 192
@spriteBaseX = 34 # same
@spritebaseY = 0
else
@spriteX = 26 # -16
@spriteY = 36 # same!
@spriteBaseX = 8 # 16
@spritebaseY = -14
@spriteBaseX_hp = 8
end
case sideSize
when 2
@spriteX += [20, 0, 44, -24][@battler.index]
@spriteY += [-22, -26, 26, 22][@battler.index]
@spriteBaseX_hp += [-2, 0][@battler.index % 2]
@spritebaseY_hp += -2
@spriteBaseX_stat += [-10, 0][@battler.index % 2]
@spritebaseY_stat += [-16, -2][@battler.index % 2]
end
end
#-------------------------------
def initializeOtherGraphics(viewport)
# Create other bitmaps
@numbersBitmap = AnimatedBitmap.new("Graphics/UI/Battle/icon_numbers")
@hpBarBitmap = AnimatedBitmap.new("Graphics/UI/Battle/overlay_hp")
@expBarBitmap = AnimatedBitmap.new("Graphics/UI/Battle/overlay_exp")
# Create sprite to draw HP numbers on
@hpNumbers = BitmapSprite.new(124, 16, viewport)
pbSetSmallFont(@hpNumbers.bitmap)
@sprites["hpNumbers"] = @hpNumbers
# Create sprite wrapper that displays HP bar
@hpBar = Sprite.new(viewport)
#-------------------------------
# ~Swdfm
# @hpBar.bitmap = @hpBarBitmap.bitmap
@hpBar.src_rect.height = @hpBarBitmap.height / 3
@sprites["hpBar"] = @hpBar
# Create sprite wrapper that displays Exp bar
@expBar = Sprite.new(viewport)
#-------------------------------
# ~Swdfm
# @expBar.bitmap = @expBarBitmap.bitmap
@sprites["expBar"] = @expBar
# Create sprite wrapper that displays everything except the above
@contents = Bitmap.new(@databoxBitmap.width, @databoxBitmap.height)
self.bitmap = @contents
self.visible = false
self.z = 150 + ((@battler.index / 2) * 5)
pbSetSystemFont(self.bitmap)
end
def initialize(battler, sideSize, viewport = nil)
super(viewport)
@battler = battler
@sprites = {}
@spriteX = 0
@spriteY = 0
@spriteBaseX = 0
@selected = 0
@show_hp_numbers = false
@show_exp_bar = false
initializeDataBoxGraphic(sideSize)
initializeOtherGraphics(viewport)
refresh
end
def refresh
self.bitmap.clear
return if [email protected]
draw_background
draw_name
draw_level
draw_gender
draw_status
draw_shiny_icon
draw_special_form_icon
draw_owned_icon
refresh_hp
refresh_exp
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
return if s < 0
#-------------------------------
# Changes made here! ~Swdfm
pbDrawImagePositions(self.bitmap, [[
_INTL("Graphics/UI/Battle/icon_statuses"),
@spriteBaseX - 2 + @spriteBaseX_stat,
@spritebaseY + 44 + @spritebaseY_stat,
0, s * STATUS_ICON_HEIGHT, -1, STATUS_ICON_HEIGHT
]])
end
def refresh_hp
@hpNumbers.bitmap.clear
return if [email protected]
# Show HP numbers
if @show_hp_numbers
pbDrawNumber(self.hp, @hpNumbers.bitmap, 54, 2, :right)
pbDrawNumber(-1, @hpNumbers.bitmap, 54, 2) # / char
pbDrawNumber(@battler.totalhp, @hpNumbers.bitmap, 70, 2)
end
# Resize HP bar
w = 0
#-------------------------------
# Changes made here! ~Swdfm
if self.hp > 0
w = 96.0 * self.hp / @battler.totalhp
w = 1 if w < 1
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w / 2.0).round) * 2
end
hp_zone = 0 # Green bar
hp_zone = 1 if self.hp <= @battler.totalhp / 2 # Yellow bar
hp_zone = 2 if self.hp <= @battler.totalhp / 4 # Red bar
hp_colours = [
[Color.new(88, 208, 128), Color.new(112, 248, 168)], # Green
[Color.new(200, 168, 8), Color.new(248, 224, 56)], # Yellow
[Color.new(168, 64, 72), Color.new(248, 88, 56)] # Red
][hp_zone]
# fill with black (shows what the HP used to be)
hp_gauge_x = 62 + @spriteBaseX_hp
hp_gauge_y = 34 + @spritebaseY_hp
# fill with HP color
self.bitmap.fill_rect(@spriteBaseX + hp_gauge_x, hp_gauge_y, 96.0, 6, Color.black)
self.bitmap.fill_rect(@spriteBaseX + hp_gauge_x, hp_gauge_y, w, 2, hp_colours[0])
self.bitmap.fill_rect(@spriteBaseX + hp_gauge_x, hp_gauge_y + 2, w, 4, hp_colours[1])
end
#-------------------------------
# Changes made here! ~Swdfm
def refresh_exp
return if !@show_exp_bar
w = exp_fraction * 130
# NOTE: The line below snaps the bar's width to the nearest 2 pixels, to
# fit in with the rest of the graphics which are doubled in size.
w = ((w / 2).round) * 2
# fill with EXP color
exp_gauge_x = 30
exp_gauge_y = 66
self.bitmap.fill_rect(@spriteBaseX + exp_gauge_x, exp_gauge_y, w, 2, Color.new(64, 200, 248))
self.bitmap.fill_rect(@spriteBaseX + exp_gauge_x, exp_gauge_y + 2, w, 2, Color.new(64, 200, 248))
end
end
#-------------------------------
# ~Swdfm
class Battle::Scene::SafariDataBox < Sprite
alias frlg_init initialize
def initialize(battle, viewport = nil)
@frlg_initiating = true
frlg_init(battle, viewport)
@frlg_initiating = false
end
def refresh
if @frlg_initiating
self.x = Graphics.width - 228
self.y = Graphics.height - 174
end
self.bitmap.clear
self.bitmap.blt(0, 0, @databox.bitmap, Rect.new(0, 0, @databox.width, @databox.height))
base = Color.new(64, 64, 64) # Color.new(72, 72, 72)
shadow = Color.new(216, 208, 176) # Color.new(184, 184, 184)
textpos = []
textpos.push([_INTL("Safari Balls"), 30, 8, :left, base, shadow]) # 8 was 14
textpos.push([_INTL("Left: {1}", @battle.ballCount), 30, 38, :left, base, shadow]) # 38 was 44
pbDrawTextPositions(self.bitmap, textpos)
end
end