#==============================================================================
# Hud
#------------------------------------------------------------------------------
# Modified for no SP bar but with XP bar ofr game_guy by Winkio (no credit needed)
#==============================================================================
class Hud < Sprite
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@original_height = @hud_height = 81
@name_x, @name_y, @level_x, @level_y = 4, 1, 112, 1
@hp_x, @hp_y, @exp_x, @exp_y = 4, 17, 4, 33
@hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
# fill with grey rectangle
self.bitmap.fill_rect(0, 0, self.bitmap.width, self.bitmap.height,
Color.new(0, 0, 0, 128))
# determine color depending on HUD style
color = case BlizzABS::Config::HUD_TYPE
when 0 then Color.new(255, 255, 255, 192)
when 1 then Color.new(0, 0, 0, 0)
end
# if color exists
if color.is_a?(Color)
# draw outline in color
self.bitmap.fill_rect(@hp_x+32, @hp_y+3, 116, 14, color)
# draw outline in color
self.bitmap.fill_rect(@exp_x+32, @exp_y+3, 116, 14, color)
end
# set font color
self.bitmap.font.color = system_color
# draw "LV"
self.bitmap.draw_text_full(@level_x, @level_y, 20, 20, 'LV')
# if direct hotkey option is turned off
unless BlizzABS::Config::DIRECT_HOTKEYS
# draw "Skill:"
self.bitmap.draw_text_full(@hot_x, @hot_y, 48, 20, 'Skill:')
# draw "Item:"
self.bitmap.draw_text_full(@hot_x+76, @hot_y, 48, 20, 'Item:')
end
# draw "HP"
self.bitmap.draw_text_full(@hp_x, @hp_y, 32, 20, $data_system.words.hp)
# draw "SP"
self.bitmap.draw_text_full(@exp_x, @exp_y, 32, 20, $data_system.words.sp)
end
#----------------------------------------------------------------------------
# draw_empty
# Draws the HP and SP display when actor doesn't exist.
#----------------------------------------------------------------------------
def draw_empty
# draw empty bars
self.bitmap.gradient_bar_hud(@hp_x+32, @hp_y+3, 114, 0, 'hud_green_bar', 1)
# draw empty bars
self.bitmap.gradient_bar_hud(@exp_x+32, @exp_y+3, 114, 0, 'hud_white_bar')
# set font color
self.bitmap.font.color = disabled_color
# draw empty HP
self.bitmap.draw_text_full(@hp_x+38, @hp_y, 48, 20, '0', 2)
self.bitmap.draw_text_full(@hp_x+86, @hp_y, 12, 20, '/', 1)
self.bitmap.draw_text_full(@hp_x+98, @hp_y, 48, 20, '0')
#draw empty EXP
self.bitmap.draw_text_full(@exp_x+54, @exp_y, 84, 20, actor.next_rest_exp_s, 2)
# reset all flag variables
@name = @level = @hp = @exp = @maxhp = @maxsp = @states = @skill =
@skills_left = @item = @items_left = @gold = nil
end
#----------------------------------------------------------------------------
# draw_exp
# Draws the EXP display.
#----------------------------------------------------------------------------
def draw_exp
@exp = actor.exp
rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
self.bitmap.gradient_bar_hud(@exp_x+32, @exp_y+3, 114, rate, 'hud_white_bar')
self.bitmap.font.color = normal_color
self.bitmap.draw_text_full(@exp_x+54, @exp_y, 84, 20, actor.next_rest_exp_s, 2)
end
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
# if actor doesn't exist
if actor == nil
# unless already drawn empty HUD
unless @empty_hud_drawn
# draw HUD template
draw_basic
# draw empty HP, SP and EXP bars
draw_empty
# empty HUD was drawn
@empty_hud_drawn = true
end
else
# if HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actor
draw_name
draw_level
draw_hp
draw_exp
unless BlizzABS::Config::DIRECT_HOTKEYS
draw_hskill
draw_lskill
draw_hitem
draw_litem
end
# remove flag
$game_temp.hud_refresh = nil
else
# draw data that needs to ve updated
test_name
test_level
test_hp
test_exp
unless BlizzABS::Config::DIRECT_HOTKEYS
test_hskill
test_lskill
test_hitem
test_litem
end
end
# empty HUD wasn't drawn
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_exp
# Tests and draws the EXP.
#----------------------------------------------------------------------------
def test_exp
draw_exp if actor.exp != @exp
end
end