module LiTTleDRAgo
Font_Name = 'Calibri'
Hud_height, Hud_width = 128 +300 , 200 -30
Hud_x, Hud_y = 640-490 +300 , 4+30 -30
#--------------------------------------------------------------------------
# Below must not be changed
#--------------------------------------------------------------------------
Equip_x, Equip_y = 0 +000 , 22 -00
Hot_x, Hot_y = 132 +000 , 22 -00
Left_x, Left_y = 66 +000 , 22 -00
#--------------------------------------------------------------------------
end
#==============================================================================
# Equip Hud
#==============================================================================
class Equip_Hud < Sprite
include LiTTleDRAgo
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# create bitmap
self.bitmap = Bitmap.new(200, 70)
#self.bg = Bitmap.new(128, 64)
# set font
self.bitmap.font.name = LiTTleDRAgo::Font_Name
# set font size
self.bitmap.font.size = 14
# set font to bold
self.bitmap.font.bold = true
self.bitmap.font.italic = true
# set x and y coordinates
self.x, self.y = @hud_x, @hud_y
# set z coordinate
self.z = 1000
# draw basic HUD
draw_basic
# update
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@hud_height = LiTTleDRAgo::Hud_height
@hud_height = LiTTleDRAgo::Hud_height
@hud_width = LiTTleDRAgo::Hud_width
@hud_x = LiTTleDRAgo::Hud_x
@hud_y = LiTTleDRAgo::Hud_y
@equip_x = LiTTleDRAgo::Equip_x
@equip_y = LiTTleDRAgo::Equip_y
@hot_x = LiTTleDRAgo::Hot_x
@hot_y = LiTTleDRAgo::Hot_y
@left_x = LiTTleDRAgo::Left_x
@left_y = LiTTleDRAgo::Left_y
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
self.bitmap.fill_rect(0, 0, @hud_width, @hud_height,
Color.new(0, 0, 0, 0))
self.bitmap.font.size = 16
self.bitmap.font.color = Color.new(255, 128, 128, 255)
self.bitmap.draw_text(45, 4, 120, 16,"Equipment")
self.bitmap.font.size = 16
self.bitmap.font.name = LiTTleDRAgo::Font_Name
self.bitmap.font.color = Color.new(192, 192, 192, 255)
self.bitmap.draw_text(0, 50, 40, 16, "WPN")
self.bitmap.draw_text(64, 50, 40, 16, "ITEM")
self.bitmap.draw_text(132, 50, 40, 16, "SKILL")
end
#----------------------------------------------------------------------------
# draw_empty
# Draws the HP and SP display when actor doesn't exist.
#----------------------------------------------------------------------------
def draw_empty
@name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
@skills_left = @item = @items_left = @equip = nil
end
#----------------------------------------------------------------------------
# draw_equip
# Draws the equip display.
#----------------------------------------------------------------------------
def draw_equip
# set current variable
@equip = $data_weapons[$game_party.actors[0].weapon_id]
# remove old display
self.bitmap.fill_rect(@equip_x, @equip_y, 200, 28, Color.new(0, 0, 0, 0))
# set font color
self.bitmap.font.color = normal_color
self.bitmap.font.size = 14
# draw location
bitmap = RPG::Cache.icon($data_weapons[$game_party.actors[0].weapon_id].icon_name)
# draw bitmap
self.bitmap.blt(@equip_x, @equip_y, bitmap, Rect.new(0, 0, 24, 24))
end
def update
# if actor doesn't exist
if actor == nil
unless @empty_hud_drawn
draw_basic
draw_empty
@empty_hud_drawn = true
end
else
# if HUD needs refresh
if $game_temp.hud_refresh
# draw all data about actors
draw_equip
$game_temp.hud_refresh = nil
else
test_equip
end
@empty_hud_drawn = false
end
end
def test_equip
draw_equip if $data_weapons[$game_party.actors[0].weapon_id] != @equip
end
def actor
return $game_player.battler
end
end
class Skill_Hud < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# create bitmap
self.bitmap = Bitmap.new(200, 70)
#self.bg = Bitmap.new(128, 64)
# set font
self.bitmap.font.name = LiTTleDRAgo::Font_Name
# set font size
self.bitmap.font.size = 14
# set font to bold
self.bitmap.font.bold = true
# set x and y coordinates
self.x, self.y = @hud_x, @hud_y
# set z coordinate
self.z = 1000
# draw basic HUD
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@hud_height = LiTTleDRAgo::Hud_height
@hud_width = LiTTleDRAgo::Hud_width
@hud_x = LiTTleDRAgo::Hud_x
@hud_y = LiTTleDRAgo::Hud_y
@equip_x = LiTTleDRAgo::Equip_x
@equip_y = LiTTleDRAgo::Equip_y
@hot_x = LiTTleDRAgo::Hot_x
@hot_y = LiTTleDRAgo::Hot_y
@left_x = LiTTleDRAgo::Left_x
@left_y = LiTTleDRAgo::Left_y
end
def draw_hskill
@skill = actor.skill
self.bitmap.clear
self.bitmap.fill_rect(@hot_x-8, @hot_y, 24, 24, Color.new(255, 0, 0, 0))
if @skill != 0
bitmap = RPG::Cache.icon($data_skills[@skill].icon_name)
self.bitmap.blt(@hot_x-8, @hot_y, bitmap, Rect.new(0, 0, 24, 24))
end
self.bitmap.font.name = LiTTleDRAgo::Font_Name
self.bitmap.fill_rect(@hot_x+16, @hot_y+12, 24, 16, Color.new(0, 0, 0, 0))
@skills_left = get_skills_left
if @skill != nil && @skill > 0
if @skills_left >= 0
if @skills_left == 0
self.bitmap.font.color = Color.new(255, 0, 0)
elsif @skills_left <= 5
self.bitmap.font.color = Color.new(255, 255, 0)
else
self.bitmap.font.color = normal_color
end
self.bitmap.font.size += 2
self.bitmap.draw_text(@hot_x+12, @hot_y+12, 24, 16, @skills_left.to_s, 2)
self.bitmap.font.size -= 2
elsif @skills_left == -1
self.bitmap.font.color = Color.new(0, 255, 0)
self.bitmap.font.size += 2
self.bitmap.draw_text(@hot_x+12, @hot_y+12, 16, 20, '∞', 2)
self.bitmap.font.size -= 2
end
end
end
#----------------------------------------------------------------------------
# get_skills_left
# Gets the number of skill usages left.
#----------------------------------------------------------------------------
def get_skills_left
@sp = actor.sp
# if skill hot skill exists
if @skill != nil && @skill > 0
# if SP cost is zero
if $data_skills[@skill].sp_cost > 0
# get basic SP cost
sp_cost = $data_skills[@skill].sp_cost
# if using SP Cost Mod Status
if $tons_version != nil && $tons_version >= 6.54 &&
$game_system.SP_COST_MOD
# get modified cost
sp_cost = BlizzCFG.get_cost_mod(actor.states, sp_cost)
end
# infinite
return -1 if sp_cost == 0
# calculate skills left to use
return @sp / sp_cost
end
# set flag
return -1
end
# set flag
return -2
end
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
if actor != nil
if $game_temp.hud_refresh
draw_hskill
$game_temp.hud_refresh = nil
else
test_hskill
end
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_hskill
# Tests and draws the hskill.
#----------------------------------------------------------------------------
def test_hskill
draw_hskill if actor.skill != @skill || get_skills_left != @skills_left
end
def actor
return $game_player.battler
end
end
class Item_Hud < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# create bitmap
self.bitmap = Bitmap.new(200, 70)
#self.bg = Bitmap.new(128, 64)
# set font
self.bitmap.font.name = LiTTleDRAgo::Font_Name
# set font size
self.bitmap.font.size = 14
# set font to bold
self.bitmap.font.bold = true
# set x and y coordinates
self.x, self.y = @hud_x, @hud_y
# set z coordinate
self.z = 1000
# draw basic HUD
# update
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. This method can be aliased and the positions
# modified to create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@hud_height = LiTTleDRAgo::Hud_height
@hud_width = LiTTleDRAgo::Hud_width
@hud_x = LiTTleDRAgo::Hud_x
@hud_y = LiTTleDRAgo::Hud_y
@equip_x = LiTTleDRAgo::Equip_x
@equip_y = LiTTleDRAgo::Equip_y
@hot_x = LiTTleDRAgo::Hot_x
@hot_y = LiTTleDRAgo::Hot_y
@left_x = LiTTleDRAgo::Left_x
@left_y = LiTTleDRAgo::Left_y
end
#----------------------------------------------------------------------------
# draw_hitem
# Draws the hot item display.
#----------------------------------------------------------------------------
def draw_hitem
@item = actor.item
self.bitmap.clear
self.bitmap.fill_rect(@left_x-8, @left_y, 24, 24, Color.new(255, 0, 0, 0))
if @item != 0
bitmap = RPG::Cache.icon($data_items[@item].icon_name)
self.bitmap.blt(@left_x-8, @left_y, bitmap, Rect.new(0, 0, 24, 24))
end
@items_left = $game_party.item_number(@item)
self.bitmap.draw_text(@left_x+16, @left_y+12, 16, 16, "", 2)
self.bitmap.fill_rect(@left_x+16, @left_y+12, 16, 16, Color.new(255, 0, 0, 0))
if @item != nil && @item > 0
if $data_items[@item] != nil && !$data_items[@item].consumable
self.bitmap.font.color = Color.new(0, 255, 0)
self.bitmap.font.size += 2
self.bitmap.draw_text(@left_x+12, @left_y+12, 24, 20, '∞', 1)
self.bitmap.font.size -= 2
else
if @items_left == 0
self.bitmap.font.color = Color.new(255, 0, 0)
elsif @items_left <= 10
self.bitmap.font.color = Color.new(255, 255, 0)
else
self.bitmap.font.color = normal_color
end
self.bitmap.font.size += 2
self.bitmap.draw_text(@left_x+12, @left_y+12, 24, 20, @items_left.to_s, 1)
self.bitmap.font.size -= 2
end
end
end
#----------------------------------------------------------------------------
# update
# Checks if HUD needs refreshing.
#----------------------------------------------------------------------------
def update
if actor != nil
if $game_temp.hud_refresh
draw_hitem
$game_temp.hud_refresh = nil
else
test_hitem
end
@empty_hud_drawn = false
end
end
#----------------------------------------------------------------------------
# test_hitem
# Tests and draws the hitem.
#----------------------------------------------------------------------------
def test_hitem
# draw new item icon if assigned item has changed
draw_hitem if actor.item != @item || $game_party.item_number(@item) != @items_left
end
def actor
return $game_player.battler
end
end
class Scene_Map
#----------------------------------------------------------------------------
# override main
#----------------------------------------------------------------------------
alias scene_map_veryearlier main
def main
@equiphud = Equip_Hud.new if $game_system.equiphud
@skillhud = Skill_Hud.new if $game_system.skillhud
@itemhud = Item_Hud.new if $game_system.itemhud
scene_map_veryearlier
[@equiphud, @skillhud, @itemhud].each {|s| s.dispose if s != nil}
end
#----------------------------------------------------------------------------
# hud_update
# This method contains a couple of routine calls to handle with the HUD.
#----------------------------------------------------------------------------
def hud_update
# check activation of HUD parts
check_huds
# update minimap
update_minimap
# update hotkey assignment display
update_hotkeys
# iterate through all the HUD sprites
[@hud, @minimap, @hotkeys, @equiphud, @skillhud, @itemhud].each {|s|
# if sprite exists
if s != nil
# update sprite
s.update
# if player is on the same position as one of the sprites on the screen
if $game_player.screen_x < s.vx + s.vw + 16 &&
$game_player.screen_y < s.vy + s.vh + 48 &&
$game_player.screen_x > s.vx && $game_player.screen_y > s.vy &&
((s == @minimap) ? ($game_system.minimap < 2) : true)
# decrease opacity quickly if critical opacity not reached
s.opacity -= 25 if s.opacity > 80
# if not full opacity
elsif s.opacity <= 255
# increase opacity quickly if critical opacity not reached
s.opacity += 25
end
end}
end
#----------------------------------------------------------------------------
# check_huds
# This method handles enabling and disabling the HUD parts on the map.
#----------------------------------------------------------------------------
def check_huds
if $game_system.minimap_button && Input.trigger?(Input::Minimap)
$game_system.minimap = ($game_system.minimap + 1) % 3
end
if $game_system.hotkey_button && Input.trigger?(Input::Hotkey)
$game_system.hotkeys = (!$game_system.hotkeys)
end
if $game_system.hud_button && Input.trigger?(Input::Hud)
$game_system.hud = (!$game_system.hud)
$game_system.equiphud = (!$game_system.equiphud)
$game_system.skillhud = (!$game_system.skillhud)
$game_system.itemhud = (!$game_system.itemhud)
end
if $game_system.minimap == 0 && @minimap != nil
@minimap.dispose
@minimap = nil
elsif BlizzABS::Config::MINIMAP && $game_system.minimap > 0
@minimap = Minimap.new if @minimap == nil
end
if !$game_system.hotkeys && @hotkeys != nil
[@hotkeys, @exphud].each {|s| s.dispose if s != nil}
@hotkeys = @exphud = nil
elsif BlizzABS::Config::HOTKEYS && $game_system.hotkeys
@hotkeys = Hotkey_Assignment.new if @hotkeys == nil
end
if !$game_system.hud && @hud != nil
[@hud, @parhud, @equiphud, @skillhud, @itemhud].each {|s| s.dispose if s != nil}
@hud = @parhud = @equiphud = @skillhud = @itemhud = nil
elsif BlizzABS::Config::HUD_ENABLED && $game_system.hud
@hud = Hud.new if @hud == nil
@equiphud = Equip_Hud.new if @equiphud == nil
@skillhud = Skill_Hud.new if @skillhud == nil
@itemhud = Item_Hud.new if @itemhud == nil
end
end
end
#==============================================================================
# Game_System
#------------------------------------------------------------------------------
# This class was modified to support the party hud
#==============================================================================
class Game_System
attr_accessor :equiphud
attr_accessor :skillhud
attr_accessor :itemhud
attr_accessor :bar_style
attr_reader :bar_opacity
alias init_HUDFE_later initialize
def initialize
@equiphud = @skillhud = @itemhud = false
@minimap = 0
@bar_style = 2 # Configure this with 0-6 Default - 4
self.bar_opacity = 255 # Opacity of the bars: Default - 255
init_HUDFE_later
end
def bar_opacity=(alpha)
@bar_opacity = [[alpha, 0].max, 255].min
end
end