module Hud_Config
HP = 'HP'
MP = 'MP'
EXP = 'EXP'
Empty = 'Empty'
EmptyExp = 'Empty_Exp'
Back = 'Back'
MapBack = 'Map_Back'
EmptyExt = 'Empty_'
end
#==============================================================================
# Hud
#------------------------------------------------------------------------------
# This class was modified to support SR display and modify the number of
# skills left to use.
#==============================================================================
$map_infos = load_data('Data/MapInfos.rxdata')
$map_infos.keys.each {|key| $map_infos[key] = $map_infos[key].name}
class Hud < Sprite
#----------------------------------------------------------------------------
# Initialization
# viewport - the viewport for the sprite
#----------------------------------------------------------------------------
def initialize(viewport = nil)
# call superclass method
super
# create positions
create_positions
# get height
h = @hud_height
$game_system.minimap = 1
$game_system.hotkeys = true
@name = Player_Name.new(self)
@lvl = Player_Lvl.new(self)
@gold = Party_Gold.new(self)
# create bitmap
self.bitmap = Bitmap.new(@hud_width, h)
# set font
self.bitmap.font.name = 'Arial'
# set font size
self.bitmap.font.size = 12
# set font to bold
self.bitmap.font.bold = true
# set x, y position depending on which HUD mode
self.y = 480 - (h)
# set z coordinate
self.z = 1000
# draw basic HUD
draw_basic
# update
update
end
#----------------------------------------------------------------------------
# create_positions
# Sets drawing positions. Can be aliased and the positions modified to
# create a different HUD.
#----------------------------------------------------------------------------
def create_positions
@original_width = @hud_width = 474
@original_height = @hud_height = 54
@hp_x, @hp_y, @sp_x, @sp_y = 3, 15, 3, 35
@hot_x, @hot_y, @left_x, @left_y = 4, 49, 8, 63
@exp_x,@exp_y,@gold_x,@gold_y = 175, 0, 0, 0
end
#----------------------------------------------------------------------------
# draw_basic
# Draws the HUD template.
#----------------------------------------------------------------------------
def draw_basic
# fill with grey rectangle
bitmap = RPG::Cache.picture('HUD/'+Hud_Config::Back)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.bitmap.blt(0,0, bitmap, src_rect)
# 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, @hp_y+3, 116, 14, color)
# draw outline in color
self.bitmap.fill_rect(@sp_x, @sp_y+3, 116, 14, color)
end
# set font color
self.bitmap.font.color = system_color
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, @hp_y+3, 114, 0, 'hud_red_bar', 1)
# draw empty bars
self.bitmap.gradient_bar_hud(@sp_x, @sp_y+3, 114, 0, 'hud_blue_bar', 2)
# draw empty bars
self.bitmap.gradient_bar_hud(@exp_x, @exp_y+3, 200,0, 'hud_green_bar', 3)
# set font color
self.bitmap.font.color = disabled_color
# draw empty HP
self.bitmap.draw_text_full(@hp_x + 6, @hp_y, 48, 20, '0', 2)
self.bitmap.draw_text_full(@hp_x + 54, @hp_y, 12, 20, '/', 1)
self.bitmap.draw_text_full(@hp_x + 66, @hp_y, 48, 20, '0')
# draw empty SP
self.bitmap.draw_text_full(@sp_x + 6, @sp_y, 48, 20, '0', 2)
self.bitmap.draw_text_full(@sp_x + 54, @sp_y, 12, 20, '/', 1)
self.bitmap.draw_text_full(@sp_x + 66, @sp_y, 48, 20, '0')
# draw empty EXP
self.bitmap.draw_text_full(@exp_x + 54, @exp_y, 84, 20, '0.0', 2)
# reset all flag variables
@name = @level = @hp = @sp = @maxhp = @maxsp = @exp = @states = @skill =
@skills_left = @item = @items_left = @gold = @exp = nil
end
#----------------------------------------------------------------------------
# draw_hp
# Draws the HP display.
#----------------------------------------------------------------------------
def draw_hp
# set current variables
@hp, @maxhp = actor.hp, actor.maxhp
# set fill rate
rate = (@maxhp > 0 ? @hp.to_f / @maxhp : 0)
# draw gradient bar
self.bitmap.picture_bar(@hp_x, @hp_y+3,rate,Hud_Config::HP)
# set font color depending on how many HP left
self.bitmap.font.color = @hp == 0 ? knockout_color :
@hp <= @maxhp / 4 ? crisis_color : normal_color
# draw HP
self.bitmap.draw_text_full(@hp_x+6, @hp_y, 48, 20, @hp.to_s, 2)
# set color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@hp_x+54, @hp_y, 12, 20, '/', 1)
# draw max HP
self.bitmap.draw_text_full(@hp_x+66, @hp_y, 48, 20, @maxhp.to_s)
self.bitmap.draw_text_full(@hp_x+2, @hp_y, 32, 20, $data_system.words.hp)
end
#----------------------------------------------------------------------------
# draw_sp
# Draws the SP display.
#----------------------------------------------------------------------------
def draw_sp
# set current variables
@sp, @maxsp = actor.sp, actor.maxsp
# set fill rate
rate = (@maxsp > 0 ? @sp.to_f / @maxsp : 0)
# draw gradient bar
self.bitmap.picture_bar(@sp_x, @sp_y+3,rate,Hud_Config::MP)
# set font color depending on how many SP left
self.bitmap.font.color = @sp == 0 ? knockout_color :
@sp <= @maxsp / 4 ? crisis_color : normal_color
# draw SP
self.bitmap.draw_text_full(@sp_x+6, @sp_y, 48, 20, @sp.to_s, 2)
# set font color
self.bitmap.font.color = normal_color
# draw "/"
self.bitmap.draw_text_full(@sp_x+54, @sp_y, 12, 20, '/', 1)
# draw max SP
self.bitmap.draw_text_full(@sp_x+66, @sp_y, 48, 20, @maxsp.to_s)
self.bitmap.draw_text_full(@sp_x+2, @sp_y, 32, 20, $data_system.words.sp)
end
#----------------------------------------------------------------------------
# draw_exp
# Draws the EXP display.
#----------------------------------------------------------------------------
def draw_exp
# set current variables
@exp = actor.exp
# set fill rate
rate = (actor.next_exp != 0 ? actor.now_exp.to_f / actor.next_exp : 1)
# draw gradient bar
self.bitmap.picture_bar(@exp_x, @exp_y+3,rate,Hud_Config::EXP)
self.bitmap.font.color = normal_color
percent = (rate * 100).to_i
self.bitmap.draw_text_full(@exp_x+60, @exp_y, 200, 18,
"#{actor.cur_exp} / #{actor.max_exp}")
self.bitmap.draw_text_full(@exp_x+195, @exp_y, 145, 18,percent.to_s)
self.bitmap.draw_text_full(@exp_x+210, @exp_y, 150, 18,'%')
self.bitmap.draw_text_full(@exp_x+2, @exp_y, 32, 18, 'EXP')
end
def draw_name
end
def draw_level
end
alias hud_update update
def update
draw_basic if $game_temp.hud_refresh
$game_temp.hud_refresh ? draw_exp : test_exp if actor != nil
@gold.update
@name.update
@lvl.update
hud_update
end
def dispose
super
@name.dispose
@lvl.dispose
@gold.dispose
end
def test_exp
draw_exp if actor.exp != @exp
end
def test_name
return
end
def test_level
return
end
end
class Hotkey_Assignment < Sprite
def initialize(viewport = nil)
# call superclass
super
# create bitmap
self.bitmap = Bitmap.new(320, 32)
# set font to bold
self.bitmap.font.bold = true
# decrease font size
self.bitmap.font.size -= 8
# set font color
self.bitmap.font.color = system_color
# set x and y position
self.x, self.y, self.z = 174, 448, 1100
# skill IDs on hotkeys
@skills = BlizzABS::Cache::EmptyKeys
# item IDs on hotkeys
@items = BlizzABS::Cache::EmptyKeys
# update display
update
end
def draw(index = nil)
# iterate through all hotkeys
(index == nil ? BlizzABS::Cache::HotkeyRange : [index]).each {|i|
# if hotkey is skill hotkey
if $game_player.skill_hotkeys[i%10] != 0
# temporary object
object = $data_skills[$game_player.skill_hotkeys[i%10]]
# if hotkey is item hotkey
elsif $game_player.item_hotkeys[i%10] != 0
# temporary object
object = $data_items[$game_player.item_hotkeys[i%10]]
end
# if any change applied (10 is used for 0)
if @items[i%10] != $game_player.item_hotkeys[i%10] ||
@skills[i%10] != $game_player.skill_hotkeys[i%10]
# remove this icon
self.bitmap.fill_rect(30*(i-1), 0, 24, 24, Color.new(0, 0, 0, 0))
# if object exists
if object != nil
# load bitmap
bitmap = RPG::Cache.icon(object.icon_name)
# draw bitmap
self.bitmap.blt(30*(i-1), 0, bitmap, Rect.new(0, 0, 24, 24))
end
# draw hotkey number
self.bitmap.draw_text_full(30*(i-1), 10, 30, 32, (i%10).to_s, 2)
end}
# set new items
@items = $game_player.item_hotkeys.clone
# set new skills
@skills = $game_player.skill_hotkeys.clone
end
alias hud_update update
def update
$game_system.hotkeys = ($game_system.hud)
hud_update
end
end
class Minimap < Sprite
def initialize
# call superclass method
super(Viewport.new(478, 359, 160, 120))
# get autotile image from Blizz-ABS Cache
@autotile = $BlizzABS.cache.image('minimap_autotile')
# creates the passable floor map
@map_back = Map_Back.new(self)
create_passable_floor
# set x and y position
self.x = self.y = 0
# set z position
viewport.z = 5000
# store events
@events, @names = check_events
# create sprites for events
create_sevents
@map_name = Map_Name.new(self)
# set all sprites visible
self.visible = true
# update
update
end
alias hud_update update
def update(con=false)
hud_update(con)
@map_back.update
@map_name.update
end
def dispose
destroy_sevents
@map_back.dispose
@map_name.dispose
super
end
end
class Scene_Hotkeys
#----------------------------------------------------------------------------
# main
# The main processing method.
#----------------------------------------------------------------------------
def main
# create spriteset
@spriteset = Spriteset_Map.new
# create viewport
@view = Viewport.new(0, 0, 0, 0)
# set tone to current screen tone
@view.tone = @tone.clone
# create HUD if HUD is turned on and HUD active
@hud = Hud.new if BlizzABS::Config::HUD_ENABLED && $game_system.hud
# if ASSIGNMENT is turned
if BlizzABS::Config::HOTKEYS
# create assignment display
@hotkeys = Hotkey_Assignment.new
# set z position
@hotkeys.z = 5000
end
# if MINIMAP is turned on and minimap active
if BlizzABS::Config::MINIMAP && $game_system.minimap > 0
# create minimap
@minimap = Minimap.new
end
# create sprite
@choice = Sprite.new
# create bitmap
@choice.bitmap = $BlizzABS.cache.image('menu_arrow')
@choice.angle = 180
# set x, y and z positions
@choice.x, @choice.y, @choice.z, @choice.opacity = 204, 448, 5001, 108
# set x position offset
@choice.ox = -8
# set active flag
@active = true
# set index
@index = 0
# set up mode flag
@up_mode = true
# create modified skill window
@skill_window = Window_Skill_Hotkey.new($game_player.battler)
@skill_window.y -= 66
@skill_window.height -= 70
# create modified item window
@item_window = Window_Item_Hotkey.new
@item_window.y -= 66
@item_window.height -= 70
# set last active
@last_active = true
# transtition
Graphics.transition
# loop
loop do
# update game screen
Graphics.update
# update input
Input.update
# frame update
update
# stop if chosen an option
break if $scene != self
end
# freeze screen
Graphics.freeze
# delete spriteset
@spriteset.dispose
# delete HUD elements that exist
[@hud, @hotkeys, @minimap].each {|s| s.dispose if s != nil}
# delete choice sprite
@choice.dispose
# delete skill window
@skill_window.dispose
# delete item window
@item_window.dispose
# delete viewport
@view.dispose
# while real leader is not first actor in party
while @party_leader != $game_party.actors[0]
# switch to next actor
$BlizzABS.player.switch_leader
end
end
def update_choice
# set x position
@choice.x = 204 + @index * 30
# if pressed B
if Input.trigger?(Input::B)
# play cancel sound
$game_system.se_play($data_system.cancel_se)
# create map scene
$scene = Scene_Map.new
# if C is pressed
elsif Input.trigger?(Input::C)
# play sound
$game_system.se_play($data_system.decision_se)
# not active
@active = false
# the one that was active the last time is now active
@skill_window.active = @last_active
@item_window.active = (!@last_active)
# if RIGHT is being pressed
elsif Input.repeat?(Input::RIGHT)
# if RIGHT is pressed or index is less than 9
if Input.trigger?(Input::RIGHT) || @index < 9
# play sound
$game_system.se_play($data_system.cursor_se)
# set new index
@index = (@index + 1) % 10
end
# if LEFT is being pressed
elsif Input.repeat?(Input::LEFT)
# if LEFT is pressed or index is equal or greater than 1
if Input.trigger?(Input::LEFT) || @index >= 1
# play sound
$game_system.se_play($data_system.cursor_se)
# set new index
@index = (@index + 9) % 10
end
end
end
end
class Map_Back < Sprite
def initialize(map)
super()
self.x ,self.y, self.z = 474, 356, 4999
self.bitmap = RPG::Cache.picture('HUD/'+Hud_Config::MapBack)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
self.bitmap.blt(0, 0, bitmap, src_rect)
@map = map
end
def update
self.opacity = @map.opacity
if $game_system.minimap != 1
self.visible = false
end
end
end
class Map_Name < Sprite
def initialize(map)
super()
self.x ,self.y, self.z = 474, 456, 5001
self.bitmap = Bitmap.new(120,32)
self.bitmap.font.color = Color.new(255,255,255)
self.bitmap.font.size = 16
draw_map_name
@map = map
end
def draw_map_name
self.bitmap.clear
@map_id = $game_map.map_id
self.bitmap.draw_text_full(0,0, 160, 20, $map_infos[@map_id],1)
end
def update
super
self.opacity = @map.opacity
if $game_system.minimap != 1
self.visible = false
end
draw_map_name if @map_id != $game_map.map_id
end
end
class Player_Name < Sprite
def initialize(hud)
super()
self.x ,self.y, self.z = 123, 441, 5001
self.bitmap = Bitmap.new(120,32)
self.bitmap.font.color = Color.new(255,255,255)
self.bitmap.font.size = 14
@hud = hud
draw_text
end
def draw_text
self.bitmap.clear
@actor = @hud.actor
self.bitmap.font.color = Color.new(255, 255, 255)
self.bitmap.draw_text_full(0,0, 120, 20, @actor.name)
end
def update
super
self.opacity = @hud.opacity
draw_text if @actor != @hud.actor
end
end
class Player_Lvl < Sprite
def initialize(hud)
super()
self.x ,self.y, self.z = 123, 461, 5001
self.bitmap = Bitmap.new(120,32)
self.bitmap.font.color = Color.new(255,255,255)
self.bitmap.font.size = 12
@hud = hud
draw_text
end
def draw_text
self.bitmap.clear
@level = @hud.actor.level
self.bitmap.font.color = system_color
self.bitmap.draw_text_full(0,0, 20, 20, 'LV')
self.bitmap.font.color = normal_color
self.bitmap.draw_text_full(15,0, 20, 20, @level.to_s,2)
end
def update
super
self.opacity = @hud.opacity
draw_text if @level != @hud.actor.level
end
end
class Party_Gold < Sprite
def initialize(hud)
super()
self.x ,self.y, self.z = 336, 409, 5001
self.bitmap = Bitmap.new(140,32)
self.bitmap.font.size = 16
@hud = hud
draw_text
end
def draw_text
self.bitmap.clear
@gold = $game_party.gold
self.bitmap.font.color = normal_color
self.bitmap.draw_text_full(125,0, 20, 20, $data_system.words.gold)
self.bitmap.font.color = Color.new(193,172,81)
self.bitmap.draw_text_full(2,0, 120, 20,@gold.to_s,2)
end
def update
super
self.opacity = @hud.opacity
draw_text if @gold != $game_party.gold
end
end
class Game_Actor < Game_Battler
def cur_exp
return (@exp - @exp_list[@level] > 0 ? @exp - @exp_list[@level] : 0)
end
def max_exp
return (@exp_list[@level] - @exp_list[@level+1]).abs
end
end
class Bitmap
def picture_bar(x,y,r,image)
empty_bar = RPG::Cache.picture('HUD/'+Hud_Config::EmptyExt+image)
bar = RPG::Cache.picture('HUD/'+image)
h = bar.height
w = bar.width
self.blt(x,y,empty_bar,Rect.new(0,0,w,h))
self.blt(x,y,bar,Rect.new(0,0,w*r,h))
end
end