#==============================================================================
# ■ RGSS3 滚动状态 Ver1.00 by 星潟
#------------------------------------------------------------------------------
# 默认战斗中显示状态数量有限,状态数量很多时玩家无法知道全部状态。
# 此脚本让所有状态滚动显示。
#
# 此外,会在强化能力、弱化能力中显示数字,表示等级数。
#
# 对于非默认战斗系统兼容性可能较差。
#==============================================================================
module BattleStateScroll
#附加/解除状态时
#设定不透明度变化的数值。
#数值越大,不透明度变化越快。
#数值建议在1~255之间。
FadeIn = 16
end
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_actor_icons_sprites initialize
def initialize
@icons_sprites = []
initialize_actor_icons_sprites
end
#--------------------------------------------------------------------------
# リフレッシュ
#--------------------------------------------------------------------------
alias refresh_actor_icons_sprites refresh
def refresh
i1 = $game_party.battle_members.size
if i1 > 0
@icons_sprites.each_with_index {|s,i2|
s.dispose if i2 >= i1}
@icons_sprites.delete_if {|s| s.disposed?}
else
@icons_sprites.each {|s,i2| s.dispose}
@icons_sprites = []
end
refresh_actor_icons_sprites
end
#--------------------------------------------------------------------------
# ステートおよび強化/弱体のアイコンを描画
#--------------------------------------------------------------------------
def draw_actor_icons(actor, x, y, width = 96)
i = actor.index
@icons_sprites[i] ||= Sprite_StatesIcons.new(self,i,width / 24,self.viewport)
icons = (actor.state_icons + actor.buff_icons)
ib = Cache.system("IconSet")
if width / 24 < icons.size
ic = icons.clone
(width / 24).times {icons.push(ic.shift)}
end
data_hash = {:icons => icons}
flag1 = defined? draw_actor_icons_rest_draw
if flag1
rest_array = actor.state_rest_array + actor.buff_rest_array
if width / 24 < icons.size
rac = rest_array.clone
(width / 24).times {rest_array.push(rac.shift)}
end
data_hash[:rest] = rest_array
end
flag2 = defined? draw_actor_icons_level_draw
if flag2
level_array = actor.state_level_array
if width / 24 < level_array.size
lac = level_array.clone
(width / 24).times {level_array.push(lac.shift)}
end
data_hash[:level] = level_array
end
if @icons_sprites[i].data_hash != data_hash
@icons_sprites[i].bitmap.dispose if @icons_sprites[i].bitmap && !@icons_sprites[i].bitmap.disposed?
all_reset = (!@icons_sprites[i].data_hash or (@icons_sprites[i].data_hash[:icons] != data_hash[:icons]))
@icons_sprites[i].data_hash = data_hash
is = icons.size
b = Bitmap.new((is > 0 ? is : 1) * 24,24)
icons.each_with_index {|n, i|
rect = Rect.new(n % 16 * 24, n / 16 * 24, 24, 24)
b.blt(i * 24, 0, ib, rect)}
if flag1
font_data = b.font.clone
b.font.size = ST_B_REST::FSIZE
ca1 = ST_B_REST::COLOR
b.font.color = Color.new(ca1[0],ca1[1],ca1[2],ca1[3])
ca2 = ST_B_REST::O_CLR
b.font.out_color = Color.new(ca2[0],ca2[1],ca2[2],ca2[3])
b.font.shadow = ST_B_REST::SHADOW
rest_array.each_with_index {|n, i| b.draw_text(24 * i + ST_B_REST::X_POS, ST_B_REST::Y_POS, 24, 24, n, 2) }
b.font = font_data
end
if flag2
font_data = b.font.clone
b.font.size = StateLevel::FSIZE
ca1 = StateLevel::COLOR
b.font.color = Color.new(ca1[0],ca1[1],ca1[2],ca1[3])
ca2 = StateLevel::O_CLR
b.font.out_color = Color.new(ca2[0],ca2[1],ca2[2],ca2[3])
b.font.shadow = StateLevel::SHADOW
level_array.each_with_index {|n, i| b.draw_text(24 * i + StateLevel::X_POS, StateLevel::Y_POS, 24, 24, n, 2) }
b.font = font_data
end
if all_reset
@icons_sprites[i].bitmap = b
@icons_sprites[i].opacity = 0
@icons_sprites[i].src_rect = Rect.new(0,0,width,96)
else
src_rect = @icons_sprites[i].src_rect.clone
@icons_sprites[i].bitmap = b
@icons_sprites[i].src_rect = src_rect
end
end
@icons_sprites[i].add_x = x
@icons_sprites[i].add_y = y
end
#--------------------------------------------------------------------------
# 更新
#--------------------------------------------------------------------------
unless method_defined?(:update_actor_icons_sprites)
alias update_actor_icons_sprites update
def update
update_actor_icons_sprites
@icons_sprites.each {|s| s.update}
end
end
#--------------------------------------------------------------------------
# 解放
#--------------------------------------------------------------------------
unless method_defined?(:dispose_actor_icons_sprites)
alias dispose_actor_icons_sprites dispose
def dispose
@icons_sprites.each {|s| s.dispose}
@icons_sprites.clear
dispose_actor_icons_sprites
end
end
end
class Sprite_StatesIcons < Sprite
attr_accessor :add_x
attr_accessor :add_y
attr_accessor :data_hash
#--------------------------------------------------------------------------
# 初期化
#--------------------------------------------------------------------------
def initialize(window,index,max_width,viewport = nil)
@window = window
@index = index
@max_width = max_width
@add_x = 0
@add_y = 0
super(viewport)
end
#--------------------------------------------------------------------------
# 更新
#--------------------------------------------------------------------------
def update
super
self.viewport = @window.viewport if self.viewport != @window.viewport
self.x = @window.x + @window.standard_padding + add_x
self.y = @window.y + @window.standard_padding + add_y
self.z = @window.z
if @window.close? or !@window.visible
self.visible = false
return
else
self.visible = true
end
self.opacity += BattleStateScroll::FadeIn if self.opacity < 255
if self.bitmap
self.src_rect.x += 1 if self.bitmap.width / 24 > @max_width
self.src_rect.x = 0 if (self.bitmap.width - self.src_rect.x) / 24 - @max_width < 0
end
end
#--------------------------------------------------------------------------
# 解放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose if self.bitmap && !self.bitmap.disposed?
super
end
end