module Cache
#--------------------------------------------------------------------------
# * Get Hud Graphic
#--------------------------------------------------------------------------
def self.hud(filename, hue=0)
load_bitmap("Graphics/System/Hud/", filename, hue)
end
end
class ZeldaHearts < Window_Base
#--------------------------------------------------------------------------
# * Changeable Area
#--------------------------------------------------------------------------
def switch
90
end
def hud_x
0
end
def hud_y
0
end
def hud_width
400
end
def hud_height
240
end
def heart_file
"hearts"
end
def heart_width
24
end
def heart_padding
-10
end
def heart_rowheight
-10
end
def heart_row
10
end
def hp_per_heart
4
end
def heart_pieces
4
end
#--------------------------------------------------------------------------
# * Fixed Area
#--------------------------------------------------------------------------
def initialize
super(hud_x, hud_y, hud_width, hud_height)
self.windowskin = nil
@bitmap = Cache.hud(heart_file)
@switch = $game_switches[switch]
if @switch
draw_hearts
end
end
def draw_hearts
@lhearts = @hearts
@lmaxHearts = @maxHearts
@hearts = calc_hearts(get_hp)
@maxHearts = calc_hearts(get_maxhp).to_i
fullHearts = @hearts.to_i
partHearts = @hearts - fullHearts
i = 0
if fullHearts
for i in 0..@maxHearts-1 do
if i < fullHearts
get_heart_image(i, heart_pieces)
elsif i == fullHearts
get_heart_image(i, (partHearts*heart_pieces).round(0))
else
get_heart_image(i,0)
end
end
end
end
def get_heart_image(heartIndex, fileIndex)
rect = Rect.new(fileIndex * heart_width, 0, @bitmap.width/(heart_pieces+1), @bitmap.height)
contents.blt(heartIndex.modulo(heart_row)*(heart_width+heart_padding), (heartIndex/heart_row)*(@bitmap.height+heart_rowheight), @bitmap, rect, 255)
end
def get_hp
$game_party.members[0].hp
end
def get_maxhp
$game_party.members[0].mhp
end
def calc_hearts(hp)
Float hearts = hp.to_f / hp_per_heart
hearts.round(2)
end
def refresh
self.contents.clear
contents.clear
draw_hearts
end
def update
super
if @switch
refresh
end
end
def change
if @switch != $game_switches[switch]
if $game_switches[switch]
update
else
contents.clear
self.contents.clear
end
@switch = $game_switches[switch]
end
if @lhearts == @hearts && @lmaxHearts == @maxHearts
return
else
update
end
end
def dispose
super
@bitmap.dispose
end
end
class Scene_Map < Scene_Base
alias start_window start
alias term_window terminate
alias update_window update
def start
start_window
@hearthud = ZeldaHearts.new
@manahud = ZeldaMana.new
update
end
def terminate
@hearthud.dispose
@manahud.dispose
term_window
end
def update
update_window
@hearthud.change
@manahud.change
end
end
#~ Mana Addon:
class ZeldaMana < Window_Base
#--------------------------------------------------------------------------
# * Changeable Area
#--------------------------------------------------------------------------
def switch
90
end
def hud_x
0
end
def hud_y
0
end
def hud_width
400
end
def hud_height
240
end
def mana_file
"mana"
end
def mana_width
24
end
def mana_padding
-10
end
def mana_rowheight
-10
end
def mana_row
10
end
def mp_per_mana
4
end
def mana_pieces
4
end
#--------------------------------------------------------------------------
# * Fixed Area
#--------------------------------------------------------------------------
def initialize
super(hud_x, hud_y, hud_width, hud_height)
self.windowskin = nil
@bitmap = Cache.hud(mana_file)
@switch = $game_switches[switch]
if @switch
draw_mana
end
end
def draw_mana
@lmana = @mana
@lmaxMana = @maxMana
@mana = calc_mana(get_mp)
@maxMana = calc_mana(get_maxmp).to_i
fullMana = @mana.to_i
partMana = @mana - fullMana
i = 0
if fullMana
for i in 0..@maxMana-1 do
if i < fullMana
get_mana_image(i, mana_pieces)
elsif i == fullMana
get_mana_image(i, (partMana*mana_pieces).round(0))
else
get_mana_image(i,0)
end
end
end
end
def get_mana_image(manaIndex, fileIndex)
rect = Rect.new(fileIndex * mana_width, 0, @bitmap.width/(mana_pieces+1), @bitmap.height)
contents.blt(manaIndex.modulo(mana_row)*(mana_width+mana_padding), (manaIndex/mana_row)*(@bitmap.height+mana_rowheight), @bitmap, rect, 255)
end
def get_mp
$game_party.members[0].mp
end
def get_maxmp
$game_party.members[0].mmp
end
def calc_mana(mp)
Float mana = mp.to_f / mp_per_mana
mana.round(2)
end
def refresh
self.contents.clear
contents.clear
draw_mana
end
def update
super
if @switch
refresh
end
end
def change
if @switch != $game_switches[switch]
if $game_switches[switch]
update
else
contents.clear
self.contents.clear
end
@switch = $game_switches[switch]
end
if @lmana == @mana && @lmaxMana == @maxMana
return
else
update
end
end
def dispose
super
@bitmap.dispose
end
end