#==============================================================================
# [XP] <+ [Neo Gauge] ENGINE -> by Woratana
#------------------------------------------------------------------------------
# ? by Woratana [[email protected]]
# ? 3 New Methods: 1 Window_Base, 2 Bitmap
# ? Released on: 13/04/2008 (D-M-Y)
# ? Version: 1.0
# ? Special Thanks: Dubalex & Tsunokiette for
# gradient_fill_rect algorithm
#---------------------------------------------------------------------------
#### [FEATURES] ####
# - Draw 3 colors gradient & user can choose spot to draw second color
# - Easy to setting gauge style
# - 2 New methods to help edit bitmap, and 2 methods from VX
#------------------------------------------------------------------------------
# [Window_Base: 1 New Method]
# => Draw Neo Gauge: Draw Gauge with 3 Colors & Outline
# Setting Neo Gauge in # NEO GAUGE SETTING # below
#==============================================================================
class Window_Base < Window
#==========================================================================
# NEO GAUGE SETTING #
#==========================================================================
GAUGE_GLOW_EFFECT = true # Use glow effect?
GAUGE_GLOW_COLOR = Color.new(255, 255, 255, 160) # Transparent White
GAUGE_OUTSIDE_BORDER = true # Use outside border?
GAUGE_OUTSIDE_BORDER_COLOR = Color.new(0, 0, 0)
GAUGE_OUTSIDE_BORDER_COLOR2 = Color.new(0, 0, 0)
GAUGE_CLEAR_CORNER_OUTSIDE_BORDER = true
GAUGE_INSIDE_BORDER = false # Use inside border?
GAUGE_INSIDE_BORDER_COLOR = Color.new(255, 255, 255)
GAUGE_INSIDE_BORDER_COLOR2 = Color.new(0, 0, 0)
#==========================================================================
#--------------------------------------------------------------------------
# * Draw Neo Gauge: Draw Gauge with 3 Colors & Outline
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : gauge width
# height : gauge height
# color1 : first color (left side)
# color2 : second color (center)
# color3 : last color (right side)
# vertical : vertical gauge? (true: vertical | false: horizontal)
# outline : draw glow & outline? (true: draw | false: draw only gradient)
# max_width : max_width that gradient will draw before cut to width
# (max_width will becomes max_height in vertical gauge)
# color2_spot = spot to draw color 2 [1:Left <- (default)50:Center -> 100:Right]
#-------------------------------------------------------------------------
def draw_neo_gauge(x, y, width, height, color1, color2, color3, vertical = false,
outline = true, max_width = nil, color2_spot = 50)
if max_width == nil
max_width = vertical ? height : width
end
glow = GAUGE_GLOW_EFFECT # Set glow effect
dx = x; dy = y # Store draw spot X/Y
x = y = 0 # Change x, y for temp. bitmap
bitmap = Bitmap.new(max_width, height) # Create temp. bitmap to draw gauge
if glow # If GLOW
if outline # If drawing outline
# Create Glow rect
if vertical; rect = Rect.new(x, y, width, max_width)
else; rect = Rect.new(x, y, max_width, height)
end
bitmap.fill_rect(rect, GAUGE_GLOW_COLOR) # Draw Glow
bitmap.neo_clear_corner(rect.x, rect.y, rect.width, rect.height) # Clear Corner
else # Not drawing outline
height -= 2; width -= 2; x += 1; y += 1
if GAUGE_INSIDE_BORDER
height -= 2; width -= 2; x += 1; y += 1
end; end; end # End Draw Glow0
# Set Position/Size for Gradient
if vertical # If drawing vertical bar
if glow; gx = gx2 = x + 1; gy = y + 1 # If GLOW
else; gx = gx2 = x; gy = y # If NOT GLOW
end
gy2 = gy - 1 + ((color2_spot*max_width)/100)
gw = gw2 = width - 2; gh = ((color2_spot*max_width)/100)
gh2 = max_width - gh - 2
# Draw Vertical Gradient Bar
bitmap.gradient_fill_rect(gx, gy, gw, gh, color1, color2, true)
bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, color2, color3, true)
gh = (gh + gh2) # Change gauge height for draw border
else # Drawing horizontal bar
if glow; gx = x; gy = gy2 = y # If GLOW
gx = x + 1; gy = gy2 = y + 1;
else; gx = x; gy = gy2 = y # If NOT GLOW
end
gx2 = gx - 1 + ((color2_spot*max_width)/100)
gw = ((color2_spot*max_width)/100); gh = gh2 = (height - 2)
gw2 = max_width - gw - 2
# Draw Horizontal Gradient Bar
bitmap.gradient_fill_rect(gx, gy, gw, gh, color1, color2)
bitmap.gradient_fill_rect(gx2, gy2, gw2, gh2, color2, color3)
gw = (gw + gw2) # Change gauge width for draw border
end
if outline # If user want outline, draw borders
if GAUGE_OUTSIDE_BORDER # Draw outside border
bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_OUTSIDE_BORDER_COLOR, GAUGE_OUTSIDE_BORDER_COLOR2)
bitmap.neo_clear_corner(gx, gy, gw, gh) if GAUGE_CLEAR_CORNER_OUTSIDE_BORDER
end
if GAUGE_INSIDE_BORDER # Draw inside border
gx += 1; gy += 1; gw -= 2; gh -= 2
bitmap.draw_neo_border(gx, gy, gw, gh, GAUGE_INSIDE_BORDER_COLOR, GAUGE_INSIDE_BORDER_COLOR2)
end
end
# Cut gauge's width from 'max_width' to 'width'
rect = Rect.new(0, 0, width, bitmap.height)
self.contents.blt(dx, dy, bitmap, rect)
bitmap.dispose # Delete bitmap
end
end
#==============================================================================
# [Bitmap: 4 New Methods] by Woratana
# => Draw Neo Border: Draw border around specific area
# => Neo Clear Corner: Clear 4 corners of specific area
#------------------------------------------------------------------------------
class Bitmap
#--------------------------------------------------------------------------
# * Draw Neo Border: Draw gradient border around specific area
# x : area x-coordinate
# y : area y-coordinate
# width : area width
# height : area height
# color : border color (left side)
# color2 : border color (right side)
# size : border size (default is 1)
#--------------------------------------------------------------------------
def draw_neo_border(x, y, width, height, color, color2 = color, size = 1)
gradient_fill_rect(x, y, width, size, color, color2) # Top
fill_rect(x, y, size, height, color) # Left
fill_rect(x + width - size, y, size, height, color2) # Right
gradient_fill_rect(x, y + height - size, width, size, color, color2) # Down
end
#--------------------------------------------------------------------------
# * Neo Clear Corner: Clear 4 corners of specific area
# x : area x-coordinate
# y : area y-coordinate
# width : area width
# height : area height
# size : area (size * size) that will be clear from corners
#--------------------------------------------------------------------------
def neo_clear_corner(x, y, width, height, size = 1)
clear_rect(x, y, size, size)
clear_rect(x + width - size, y, size, size)
clear_rect(x, y + height - size, size, size)
clear_rect(x + width - size, y + height - size, size, size)
end
#--------------------------------------------------------------------------
# * Gradient Fill Rect: Draw Gradient
# Same as VX's gradient_fill_rect,
# gradient_fill_rect(rect, color1, color2) or
# gradient_fill_rect(x, y, width, height, color1, color2)
# * This method can't draw vertical gradient
# credit: Dubalex & Tsunokiette
#--------------------------------------------------------------------------
def gradient_fill_rect(*args)
case args.size
when 3 # (rect, color1, color2)
x, y, width, height, color1, color2 =
args[0].x, args[0].y, args[0].width, args[0].height, args[1], args[2]
when 6 # (x, y, width, height, color1, color2)
x, y, width, height, color1, color2 =
args[0], args[1], args[2], args[3], args[4], args[5]
end
(0..width-1).each do |i|
r = color1.red * (width - i) / width + color2.red * i / width
g = color1.green * (width - i) / width + color2.green * i / width
b = color1.blue * (width - i) / width + color2.blue * i / width
a = color1.alpha * (width - i) / width + color2.alpha * i / width
fill_rect(x + i, y, 1, height, Color.new(r, g, b, a))
end
end
#--------------------------------------------------------------------------
# * Clear Rect: Clear color in specific area
# This can be done by just fill rect with Color.new(0,0,0,0)
# but I make this due to my laziness to change main script :p
# Same as VX's clear_rect,
# clear_rect(rect)
# clear_rect(x, y, width, height)
#--------------------------------------------------------------------------
def clear_rect(*args)
transparent_color = Color.new(0,0,0,0)
case args.size
when 1 # (rect)
fill_rect(args[0], transparent_color)
when 4 # (x, y, width, height)
fill_rect(args[0], args[1], args[2], args[3], transparent_color)
end
end
end
#===============================================================
# ? [XP] ? Neo HP/MP Gauge ? ?
#--------------------------------------------------------------
# ? by Woratana [[email protected]]
# ? Released on: 23/04/2008 (D-M-Y)
# ? Version: 1.0
# ? Special Thanks: RBG Color Table from:
# http://web.njit.edu/~kevin/rgb.txt.html
#--------------------------------------------------------------
class Window_Base < Window
#=============================================================
# NEO HP/MP GAUGE SETTING #
# (+) positive number | (+,-) positive or negative number
#=============================================================
HPMP_GAUGE_HEIGHT = 8 # gauge height (+) (minumum: 6)
# Strongly recommend to use HPMP_GAUGE_HEIGHT at least 8
# if you're using GAUGE_INSIDE_BORDER in Neo-Gauge
HPMP_GAUGE_X_PLUS = 0 # Move gauge horizontally (+,-)
HPMP_GAUGE_Y_PLUS = 0 # Move gauge vertically (+,-)
#------------------------------------------------------------
# * Neo Gauge Back Color: Return back colors
# Set Gauge back color here~ #
#------------------------------------------------------------
def neo_gauge_back_color
c1 = Color.new(0, 0, 0) # Black [Color1]
c2 = Color.new(100, 100, 100) # Dark Gray [Color2]
c3 = Color.new(200, 200, 200) # Light Gray [Color3]
return c1, c2, c3
end
#===================================================================
#--------------------------------------------------------------------------
# [Rewrite] * Draw HP gauge
#--------------------------------------------------------------------------
def draw_actor_hp_gauge(actor, x, y, width = 120)
gwidth = width * actor.hp / actor.maxhp
cg = neo_gauge_back_color
c1, c2, c3 = cg[0], cg[1], cg[2]
draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + HPMP_GAUGE_Y_PLUS, width,
HPMP_GAUGE_HEIGHT, c1, c2, c3)
c1 = Color.new(139,0,0) # Dark Red
c2 = Color.new(255,0,0) # Pure Red
c3 = Color.new(255,255,0) # Pure Yellow
draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT,
c1, c2, c3, false, false, width, 30)
end
#--------------------------------------------------------------------------
# [Rewrite] * Draw MP Gauge
#--------------------------------------------------------------------------
def draw_actor_mp_gauge(actor, x, y, width = 120)
gwidth = width * actor.sp / [actor.maxsp, 1].max
cg = neo_gauge_back_color
c1, c2, c3 = cg[0], cg[1], cg[2]
draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + HPMP_GAUGE_Y_PLUS, width,
HPMP_GAUGE_HEIGHT, c1, c2, c3)
c1 = Color.new(0,0,128) # Dark Blue
c2 = Color.new(0,191,255) # Blue
c3 = Color.new(152,251,152) # Light Green
draw_neo_gauge(x + HPMP_GAUGE_X_PLUS, y + HPMP_GAUGE_Y_PLUS, gwidth, HPMP_GAUGE_HEIGHT,
c1, c2, c3, false, false, width, 40)
end
#--------------------------------------------------------------------------
# [2 Alias] * Draw Actor HP / * Draw Actor MP
#--------------------------------------------------------------------------
alias wor_neog_winbase_draw_achp draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
draw_actor_hp_gauge(actor, x, y, width)
wor_neog_winbase_draw_achp(actor, x, y, width)
end
alias wor_neog_winbase_draw_acsp draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
draw_actor_mp_gauge(actor, x, y, width)
wor_neog_winbase_draw_acsp(actor, x, y, width)
end
end