#==============================================================================
# ** Kingdom_Hearts_2_HUD
#==============================================================================
module Kingdom_Hearts_2_HUD
#--------------------------------------------------------------------------
# * Faces Directory
#--------------------------------------------------------------------------
Face_Folder = 'Graphics/Pictures/'
#--------------------------------------------------------------------------
# * Faces Size: Rect.new(0, 0, width, height)
#--------------------------------------------------------------------------
Main_Face_Rect = Rect.new(0, 0, 96, 96)
Sub_Face_Rect = Rect.new(0, 0, 48, 48)
#--------------------------------------------------------------------------
# * Main HUD Dimensions
#--------------------------------------------------------------------------
Main_Minor_Diameter = 80
Main_Bar_Width = 16
Main_Bar_Border = 2
#--------------------------------------------------------------------------
# * Sub HUD Dimensions
#--------------------------------------------------------------------------
Sub_Minor_Diameter = 40
Sub_Bar_Width = 12
Sub_Bar_Border = 2
#--------------------------------------------------------------------------
# * Bar Colors
#--------------------------------------------------------------------------
Main_HP_Color = Color.green
Main_SP_Color = Color.blue
Sub_HP_Color = Color.green
Sub_SP_Color = Color.blue
#--------------------------------------------------------------------------
# * Gradient Colors
#--------------------------------------------------------------------------
Main_HP_Color2 = nil
Main_SP_Color2 = nil
Sub_HP_Color2 = nil
Sub_SP_Color2 = nil
#--------------------------------------------------------------------------
# * Background Bar Color
#--------------------------------------------------------------------------
Background_Color = Color.black
#--------------------------------------------------------------------------
# * Horizontal & Vertical Padding Between Bar & Edge
#--------------------------------------------------------------------------
Padding = 0
#--------------------------------------------------------------------------
# * Vertical Padding Between Sub HUDs
#--------------------------------------------------------------------------
Sub_Padding = 8
#--------------------------------------------------------------------------
# * Tail Lengths (HP > SP)
#--------------------------------------------------------------------------
HP_Tail_Length = 128
SP_Tail_Length = 96
#--------------------------------------------------------------------------
# * Visibility Switch
#--------------------------------------------------------------------------
Switch_ID = 1
#--------------------------------------------------------------------------
# * Load Face
#--------------------------------------------------------------------------
def self.face(actor)
return RPG::Cache.load_bitmap(Face_Folder,
actor.character_name, actor.character_hue)
end
end
#==============================================================================
# ** Kingdom_Hearts_2_HUD::Window_HUD
#==============================================================================
class Kingdom_Hearts_2_HUD::Window_HUD < Window_Base
#--------------------------------------------------------------------------
# * Include Constants
#--------------------------------------------------------------------------
include Kingdom_Hearts_2_HUD
#--------------------------------------------------------------------------
# * Position Math
#--------------------------------------------------------------------------
al = Main_Minor_Diameter + Main_Bar_Border * 2 + Main_Bar_Width * Math::PI * 4 / 3
HP_Arc_Percent = al / (al + HP_Tail_Length)
Main_Radius = Main_Minor_Diameter / 2 + Main_Bar_Width + Main_Bar_Border * 2
Sub_Radius = Sub_Minor_Diameter / 2 + Sub_Bar_Width + Sub_Bar_Border * 2
Main_Center_X = 608 - Padding - Main_Radius
Main_Center_Y = 448 - Padding - Main_Radius
Sub_Center_X = 608 - Padding - Sub_Radius
Sub_Center_Y = Main_Center_Y - Main_Radius - Sub_Padding - Sub_Radius
Main_to_Sub_Offset = Main_Radius + Sub_Radius + Sub_Padding
Sub_to_Sub_Offset = Sub_Radius * 2 + Sub_Padding
Main_Dest_Rect = Rect.new(Main_Center_X - Main_Face_Rect.width / 2,
Main_Center_Y - Main_Face_Rect.height / 2,
Main_Face_Rect.width, Main_Face_Rect.height)
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
@actors = []
update
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
self.visible = $game_switches[Switch_ID]
return unless self.visible
if $game_party.actors.size == 0
self.contents.clear
return
end
if actor_changed?($game_party.actors[0], @actors[0])
@actors[0] = $game_party.actors[0].dup
clear_main
draw_main_background
draw_main_hp_bar
draw_main_sp_bar
draw_main_face
end
for i in 1...$game_party.actors.size
if actor_changed?($game_party.actors[i], @actors[i])
@actors[i] = $game_party.actors[i].dup
clear_sub(i)
draw_sub_background(i)
draw_sub_hp_bar(i)
draw_sub_sp_bar(i)
draw_sub_face(i)
end
end
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def clear_main
# Get rect
rx = Main_Center_X - HP_Tail_Length - Main_Bar_Border
ry = Main_Center_Y - Main_Radius
rw = HP_Tail_Length + Main_Bar_Border + Main_Center_X
rh = Main_Radius * 2
# Clear area
self.contents.fill_rect(Rect.new(rx, ry, rw, rh), Color.clear)
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def draw_main_background
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def draw_main_hp_bar
actor = @actors[0]
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def draw_main_sp_bar
end
#--------------------------------------------------------------------------
# * Draw Main Face
#--------------------------------------------------------------------------
def draw_main_face
# Gets bitmap
bitmap = Kingdom_Hearts_2_HUD.face(@actors[0])
# Draws face
self.contents.stretch_blt(Main_Dest_Rect, bitmap, bitmap.rect)
end
#--------------------------------------------------------------------------
# * Draw Main Face
#--------------------------------------------------------------------------
def clear_sub(i)
# Get rect
rx = Sub_Center_X - Sub_Radius
ry = sub_y(i) - Sub_Radius
rw = rh = Sub_Radius * 2
# Clear area
self.contents.fill_rect(Rect.new(rx, ry, rw, rh), Color.clear)
end
#--------------------------------------------------------------------------
# * Draw Sub Background
#--------------------------------------------------------------------------
def draw_sub_background(i)
# Gets center
cx, cy = Sub_Center_X, sub_y(i)
# Draw outer circle
self.contents.draw_circle(cx, cy, Sub_Radius, Background_Color)
# Clear inner circle
self.contents.draw_circle(cx, cy, Sub_Minor_Diameter / 2, Color.clear)
end
#--------------------------------------------------------------------------
# * Draw Sub HP Bar
#--------------------------------------------------------------------------
def draw_sub_hp_bar(i)
# Get actor
a = @actors[i]
# Gets center
cx, cy = Sub_Center_X, sub_y(i)
# Gets minor and max radi
mnr = Sub_Minor_Diameter / 2 + Sub_Bar_Border
mxr = Sub_Radius - Sub_Bar_Border
# Draw arc region
self.contents.draw_cw_arc_region(cx, cy, mnr, mxr, 270, 90,
a.hp, a.maxhp, Sub_HP_Color)
end
#--------------------------------------------------------------------------
# * Draw Sub SP Bar
#--------------------------------------------------------------------------
def draw_sub_sp_bar(i)
# Get actor
a = @actors[i]
# Gets center
cx, cy = Sub_Center_X, sub_y(i)
# Gets minor and max radi
mnr = Sub_Minor_Diameter / 2 + Sub_Bar_Border
mxr = Sub_Radius - Sub_Bar_Border
# Draw arc region
# self.contents.draw_ccw_arc_region(cx, cy, mnr, mxr, 270, 90,
# a.sp, a.maxsp, Sub_SP_Color)
end
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
def draw_sub_face(i)
# Gets dest rect
dx = Sub_Center_X - Sub_Face_Rect.width / 2
dy = sub_y(i) - Sub_Face_Rect.height / 2
dest_rect = Rect.new(dx, dy, Sub_Face_Rect.width, Sub_Face_Rect.height)
# Gets bitmap
bitmap = Kingdom_Hearts_2_HUD.face(@actors[i])
# Draws face
self.contents.stretch_blt(dest_rect, bitmap, bitmap.rect)
end
#--------------------------------------------------------------------------
# * Sub Y
#--------------------------------------------------------------------------
def sub_y(i)
y = Sub_Center_Y
y -= (Sub_Padding + Sub_Radius * 2) * (i - 1)
end
#--------------------------------------------------------------------------
# * Actor Changed?
#--------------------------------------------------------------------------
def actor_changed?(a1, a2)
return true unless a2.is_a?(Game_Actor)
return a1.hp != a2.hp || a1.maxhp != a2.maxhp ||
a1.sp != a2.sp || a1.maxsp != a2.maxsp ||
a1.character_name != a2.character_name ||
a1.character_hue != a2.character_hue
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# *
#--------------------------------------------------------------------------
alias_method :seph_kh2hud_mw, :main_window
def main_window
seph_kh2hud_mw
@hud = Kingdom_Hearts_2_HUD::Window_HUD.new
end
end