Code:
#==============================================================================
# Requiem HUD
#==============================================================================
OnOff_Switch = 0 # Switch ID that show or hide the HUD
Skills_Text = "Skills" # Text displayed on skills window
Items_Text = "Items" # Text displayed on items window
Ammo_Text = "Munition" # Text displayed on ammunitions window
#------------------------------------------------------------------------------
if Requiem_Masterpiece.enabled?("Requiem ABS", 5.0)
#------------------------------------------------------------------------------
Requiem_Masterpiece.register("Requiem HUD", 1.1, "06/05/2009")
#------------------------------------------------------------------------------
class Requiem_HUD1 < Window_Base
def initialize
super(-32, -32, 224, 140)
self.opacity = 0
@actor = $game_party.members[0]
@old_hp = @actor.hp if @actor != nil
@old_mp = @actor.mp if @actor != nil
@old_exp = @actor.exp if @actor != nil
update
refresh
end
def update
return if $game_party.members.size <= 0
@actor = $game_party.members[0] if @actor != $game_party.members[0]
return unless @old_hp != @actor.hp or @old_mp != @actor.mp or @old_exp != @actor.exp
@old_hp = @actor.hp
@old_mp = @actor.mp
@old_exp = @actor.exp
refresh
end
def refresh
return if $game_party.members.size <= 0
self.contents.clear
draw_hpbar(@actor, 42, 16)
draw_mpbar(@actor, 42, 38)
draw_expbar(@actor, 42, 60) if @actor.next_exp > 0
self.contents.font.size = 16
self.contents.draw_outlined_text(18, 14, 24, 24, Vocab::hp_a)
self.contents.draw_outlined_text(18, 36, 24, 24, Vocab::mp_a)
self.contents.draw_outlined_text(18, 56, 24, 24, "Exp") if @actor.next_exp > 0
end
def draw_hpbar(actor, x, y)
base = Cache.system("Base")
self.contents.blt(x, y, base, base.rect)
bar = Cache.system("HP Bar")
meter = Rect.new(0, 0, base.width * actor.hp / actor.maxhp, base.height)
self.contents.blt(x, y, bar, meter)
end
def draw_mpbar(actor, x, y)
base = Cache.system("Base")
self.contents.blt(x, y, base, base.rect)
bar = Cache.system("MP Bar")
meter = Rect.new(0, 0, base.width * actor.mp / actor.maxmp, base.height)
self.contents.blt(x, y, bar, meter)
end
def draw_expbar(actor, x, y)
base = Cache.system("Base")
self.contents.blt(x, y, base, base.rect)
bar = Cache.system("Exp Bar")
meter = Rect.new(0, 0, base.width * actor.current_exp / actor.next_exp, base.height)
self.contents.blt(x, y, bar, meter)
end
end
#------------------------------------------------------------------------------
class Requiem_HUD2 < Window_Base
def initialize
super(-32, -32, 608, 480)
self.opacity = 0
@actor = $game_party.members[0]
@skills = (@actor.nil? ? nil : @actor.skill_hotkeys.values)
@items = (@actor.nil? ? nil : @actor.item_hotkeys.values)
refresh
end
def update
return if $game_party.members.size <= 0
refresh if something_changed?
end
def something_changed?
return true if @actor != $game_party.members[0]
return true if @actor != nil and @skills != @actor.skill_hotkeys.values
return true if @actor != nil and @items != @actor.item_hotkeys.values
return false
end
def refresh
return if $game_party.members.size <= 0
@actor = $game_party.members[0]
@skills = @actor.skill_hotkeys.values
@items = @actor.item_hotkeys.values
self.contents.clear
self.contents.font.size = 16
bitmap = Cache.system("HUD")
rect = Rect.new(0, 0, 544, 416)
self.contents.blt(16, 16, bitmap, rect)
draw_skills(464, 28)
draw_items(464, 396)
draw_ammo(32, 396)
end
def draw_skills(x, y)
count = 0
@actor.skill_hotkeys.each { |key, value|
next if value.nil?
skill = $data_skills[value]
next if skill.nil?
draw_icon(skill.icon_index, (32*count)+x-4, y)
self.contents.draw_outlined_text((32*count)+x+5, y+17, 64, 24, Keys.name(key))
count += 1
}
self.contents.draw_outlined_text(x-7, y-15, 96, 24, Skills_Text, 1)
end
def draw_items(x, y)
count = 0
@actor.item_hotkeys.each { |key, value|
next if value.nil?
item = $data_items[value]
next if item.nil?
draw_icon(item.icon_index, (32*count)+x-4, y)
self.contents.draw_outlined_text((32*count)+x+5, y+17, 64, 24, Keys.name(key))
count += 1
}
self.contents.draw_outlined_text(x-7, y-15, 96, 24, Items_Text, 1)
end
def draw_ammo(x, y)
if @actor.weapons[0] != nil and @actor.weapons[0].ranged?
if @actor.weapons[0].ammo1 != nil
draw_icon(@actor.equips[0].ammo1.icon_index, x-4, y) if @actor.equips[0].ammo1 != nil
end
if @actor.weapons[0].ammo2 != nil
draw_icon(@actor.equips[0].ammo2.icon_index, x+28, y) if @actor.equips[0].ammo2 != nil
end
self.contents.draw_outlined_text(x+5, y+17, 32, 24, Keys.name($Requiem_ABS.attack_key1))
self.contents.draw_outlined_text(x+37, y+17, 32, 24, Keys.name($Requiem_ABS.attack_key2))
end
self.contents.draw_outlined_text(x-7, y-16, 64, 24, Ammo_Text, 1)
end
end
#------------------------------------------------------------------------------
class Scene_Map < Scene_Base
alias requiem_hud_start start
alias requiem_hud_update update
alias requiem_hud_terminate terminate
def start
requiem_hud_start
@hud_window1 = Requiem_HUD1.new
@hud_window2 = Requiem_HUD2.new
@hud_window1.visible = false
@hud_window2.visible = false
showing_hud
end
def update
requiem_hud_update
showing_hud
@hud_window1.update if @hud_window1.visible
@hud_window2.update if @hud_window2.visible
end
def terminate
requiem_hud_terminate
@hud_window1.dispose
@hud_window2.dispose
end
def showing_hud
if OnOff_Switch <= 0 or $game_switches[OnOff_Switch]
@hud_window1.visible = true
@hud_window2.visible = true
else
@hud_window1.visible = false
@hud_window2.visible = false
end
end
end
#------------------------------------------------------------------------------
end