#==============================================================================
# Window Hud
#==============================================================================
module Crissaegrim_Hud
Background = "HUD-Background" # Imagem de fundo da hud
HP_Bar = "HP-Bar" # Imagem da barra de HP
MP_Bar = "MP-Bar" # Imagem da barra de MP
Base = "Bars-Base" # Imagm do fundo das barras
OnOff_Hud_Switch = 30 # Switch que ativa / desativa a HUD
Show_Hide_Button = Input::Tab # Tecla que mostra / esconde a HUD
end
#------------------------------------------------------------------------------
class Game_Map
attr_reader :map_id
def mpname
$mpname = load_data("Data/MapInfos.rvdata")
$mpname[@map_id].name
end
end
class Location_Hud < Window_Base
def initialize
super (395,0,150,60)
self.contents.font.size = 20
end
def update
self.contents.clear
refresh
end
def refresh
self.contents.font.bold = false
self.contents.font.color = text_color(12)
self.contents.draw_text(0, -12, 120, 32, "Location:", 4)
self.contents.font.color = normal_color
self.contents.draw_text(10, 3, 120, 32, $game_map.mpname.to_s, 4)
end
end
class Time_Hud < Window_Base
def initialize
super (395,61,150,60)
self.contents.font.size = 20
self.contents.font.bold = false
end
def refresh
self.contents.draw_text(-50, -10, 120, 32, $kts.getDayName, 2)
self.contents.draw_text(-50, 5, 120, 32, $kts.getTime, 2)
end
def update
self.contents.clear
refresh
end
end
class Window_CrissaegrimHud < Window_Base
def initialize
super(0,0,544,416)
self.opacity = 0
self.contents.font.size = 20
end
def update
self.contents.clear
refresh
end
def refresh
t = 0
for members in $game_party.members
@actor = members
y = (t * 48)
self.contents.font.bold = true
draw_actor_name(@actor, 0, y -5)
self.contents.font.bold = false
self.contents.draw_text(70, y - 5, 36, 24, "LVL:", 2)
self.contents.draw_text(85, y - 5, 36, 24, @actor.level.to_s, 2)
draw_char(@actor.character_name,@actor.character_index,15,y + 50)
draw_hp(members, 30, y + 11)
draw_mp(@actor, 30, y + 26)
#show_state(@actor, 130, members.id * 11)
t += 1
end
end
def draw_char(character_name, character_index, x, y)
return if character_name == nil
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch-10)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
def show_state(actor, x, y)
count = 0
for state in actor.states
draw_icon(state.icon_index, x, y + 24 * count)
count += 1
break if (24 * count > 76)
end
end
def show_icon(item, x, y)
if item != nil
draw_icon(item.icon_index, x, y)
end
end
def draw_hp(actor, x, y)
back = Cache.system(Crissaegrim_Hud::Base)
cw = back.width
ch = back.height
src_rect = Rect.new(0, 0, cw , ch)
self.contents.blt(x, y-ch+24, back, src_rect)
meter = Cache.system(Crissaegrim_Hud::HP_Bar)
cw = (meter.width - 26) * actor.hp / actor.maxhp
ch = meter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+5, y-ch+17, meter, src_rect)
self.contents.font.color = text_color(15)
self.contents.draw_text(21, y - 1, 44, WLH, actor.hp, 2)
self.contents.draw_text(65, y - 1, 11, WLH, "/", 2)
self.contents.draw_text(76, y - 1, 44, WLH, actor.maxhp, 2)
end
def draw_mp(actor, x, y)
back = Cache.system(Crissaegrim_Hud::Base)
cw = back.width
ch = back.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x, y-ch+24, back, src_rect)
meter = Cache.system(Crissaegrim_Hud::MP_Bar)
cw = (meter.width - 26) * actor.mp / actor.maxmp
ch = meter.height
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x+5, y-ch+17, meter, src_rect)
self.contents.draw_text(21, y -1, 44, WLH, actor.mp, 2)
self.contents.draw_text(65, y -1, 11, WLH, "/", 2)
self.contents.draw_text(76, y -1, 44, WLH, actor.maxmp, 2)
self.contents.font.color = normal_color
end
end
#------------------------------------------------------------------------------
class Scene_Map
alias crissaegrim_abs_hud_start start
alias crissaegrim_abs_hud_update update
alias crissaegrim_abs_hud_terminate terminate
def start
crissaegrim_abs_hud_start
@location = Location_Hud.new
@kts_window = Time_Hud.new
showing_hud
@show = true
end
def update
crissaegrim_abs_hud_update
@location.update
@kts_window.update
showing_hud
end
def terminate
crissaegrim_abs_hud_terminate
@location.dispose
@kts_window.dispose
end
def showing_hud
if Input.trigger?(Crissaegrim_Hud::Show_Hide_Button)
if @show == true
@show = false
else
@show = true
end
end
if Crissaegrim_Hud::OnOff_Hud_Switch == 31 or $game_switches[Crissaegrim_Hud::OnOff_Hud_Switch] == true
if @show == true
@location.visible = true
@kts_window.visible = true
elsif @show == false
@location.visible = false
@kts_window.visible = false
end
else
@location.visible = false
@kts_window.visible = false
end
end
end