def draw_sp
@sp, @maxsp = actor.sp, actor.maxsp
rate = (@maxsp > 0 ? @sp.to_f / @maxsp : 0)
picPath = 'HUD/'
if BlizzCFG::UNIQUE_ACTOR_GRAPHICS == true
name = BlizzCFG.actor_SP(actor.id)
picPath = picPath + 'actor/' + name + '_' if name != nil
if (@prev_actor != actor.id && @prev_actor && @prev_actor != -1)
b1.dispose
b2.dispose
end
end
b1 = RPG::Cache.picture(picPath + BlizzCFG::Z_SP_FILE)
b2 = RPG::Cache.picture(picPath + BlizzCFG::Z_SP_FILE_EMPTY)
@prev_actor = actor.id
if BlizzCFG::Z_SP_TILING
tiles = @maxsp / BlizzCFG::Z_SP_PER_TILE
rows = (tiles.to_f / BlizzCFG::Z_SP_TILE_COLUMNS).ceil
w, h = b1.width, b1.height
self.bitmap.fill_rect(x, y, w, h, Color.new(0,0,0,0))
self.bitmap.fill_rect(@sp_x, @sp_y, w * BlizzCFG::Z_SP_TILE_COLUMNS,
h * rows, Color.new(0, 0, 0, 0))
full_tiles = (rate * tiles).to_i
semi_full = ((rate * tiles != full_tiles) ? 1 : 0)
(0...full_tiles).each {|i|
x = @sp_x + (i % BlizzCFG::Z_SP_TILE_COLUMNS) * w
y = @sp_y + (i / BlizzCFG::Z_SP_TILE_COLUMNS) * h
self.bitmap.blt(x, y, b1, Rect.new(0, 0, w, h))}
if semi_full > 0
x = @sp_x + (full_tiles % BlizzCFG::Z_SP_TILE_COLUMNS) * w
y = @sp_y + (full_tiles / BlizzCFG::Z_SP_TILE_COLUMNS) * h
if BlizzCFG::Z_SP_FILL_UP
h2 = ((1 - rate * tiles + full_tiles) * h).to_i
self.bitmap.blt(x, y, b2, Rect.new(0, 0, w, h2))
self.bitmap.blt(x, y + h2, b1, Rect.new(0, h2, w, h - h2))
else
w2 = ((rate * tiles - full_tiles) * w).to_i
self.bitmap.blt(x, y, b1, Rect.new(0, 0, w2, h))
self.bitmap.blt(x + w2, y, b2, Rect.new(w2, 0, w - w2, h))
end
end
((full_tiles + semi_full)...tiles).each {|i|
x = @sp_x + (i % BlizzCFG::Z_SP_TILE_COLUMNS) * w
y = @sp_y + (i / BlizzCFG::Z_SP_TILE_COLUMNS) * h
self.bitmap.blt(x, y, b2, Rect.new(0, 0, w, h))}
else
w, h = b1.width, b1.height
x, y = @sp_x, @sp_y
h2 = ((1 - rate) * h).to_i
self.bitmap.fill_rect(x, y, w, h, Color.new(0,0,0,0))
self.bitmap.fill_rect(@sp_x, @sp_y, w * BlizzCFG::Z_SP_TILE_COLUMNS,
h * rows, Color.new(0, 0, 0, 0))
self.bitmap.blt(x, y, b2, Rect.new(0, 0, w, h2))
self.bitmap.blt(x, y + h2, b1, Rect.new(0, h2, w, h - h2))
end
end