#===============================================================================
# ~** Window Scroll States **~
#-------------------------------------------------------------------------------
# Written by : Kain Nobel (originated from SephirothSpawn)
# Version : 0.0
# Last Update : 09.08.2008
#-------------------------------------------------------------------------------
# * Description :
#
# This script allows you to use Plane_ScrollStatus in any window with the
# draw_actor_state() method, because it is defined in Window_Base.
#===============================================================================
#-------------------------------------------------------------------------------
# * SDK Log
#-------------------------------------------------------------------------------
SDK.log('Window.ScrollStates', 'Kain Nobel', 0.0, '09.08.2008')
SDK.disable('Window.ScrollStates')
#-------------------------------------------------------------------------------
# * SDK Enabled Log - BEGIN
#-------------------------------------------------------------------------------
if SDK.enabled?('Window.ScrollStates') && defined?(MACL) && MACL.is_a?(Module)
#===============================================================================
# ** Plane_ScrollStatus
#-------------------------------------------------------------------------------
# This is an object scrolls the status display seamlessly.
#===============================================================================
class Plane_ScrollStatus < Plane
#--------------------------------------------------------------------------
# * Show Icons When Avialable
#--------------------------------------------------------------------------
Show_Icons = true
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actor
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(actor_index, x, y, w, h, z = 105)
v = Viewport.new(x, y, w, h)
v.z = z
super(v)
if actor_index.is_a?(Numeric) ; @actor = $game_party.actors[actor_index]
else ; @actor = actor_index
end
update
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
unless @states == @actor.states
@states = @actor.states.dup
unless self.bitmap.nil?
self.bitmap.dispose
self.bitmap = nil
end
s_names, i_names = [], []
for i in @states
if Show_Icons && $data_states[i].icon != nil
s_names << nil
i_names << $data_states[i].icon_name
next
end
s_names << $data_states[i].name
end
if s_names.empty?
if Show_Icons && RPG::State.normal_icon != nil
s_names << nil
i_names << RPG::State::Normal_Icon
else
s_names << 'Normal'
end
end
has_icons = i_names.size > 0
string = Show_Icons && has_icons ? '' : '['
for s in s_names
if s.nil?
string += " [#{i_names.shift}]"
next
end
string += " #{s}"
end
string += ' ]' unless Show_Icons && has_icons
if Show_Icons && has_icons
text, icons = Bitmap.string_to_text_icons(string)
ox = Bitmap.icon_text_sizes(text, icons)[3]
else ; ox = Bitmap.text_size(string).width
end
bitmap = Bitmap.new(ox + self.viewport.rect.width, 32)
if Show_Icons && has_icons
bitmap.draw_icon_text(0, 0, ox, 32, string)
else
bitmap.draw_text(0, 0, ox, 32, string)
end
self.bitmap = bitmap
end
self.ox += 1
end
end
#===============================================================================
# ** Window_Base
#-------------------------------------------------------------------------------
# This superclasses' normal methods have been enhanced to handle the Scroll
# Status display.
#===============================================================================
class Window_Base < Window
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias_method :scroll_states_window_base_update, :update
alias_method :scroll_states_window_base_dispose, :dispose
alias_method :scroll_states_draw_actor_state, :draw_actor_state
#-----------------------------------------------------------------------------
# * Update
#-----------------------------------------------------------------------------
def update
unless @scroll_states.nil?
@scroll_states.each {|state| state.update}
end
scroll_states_window_base_update
end
#-----------------------------------------------------------------------------
# * Dispose
#-----------------------------------------------------------------------------
def dispose
unless @scroll_states.nil?
@scroll_states.each {|state| state.dispose}
end
scroll_states_window_base_dispose
end
#-----------------------------------------------------------------------------
# * Draw Actor State
#-----------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 128, height = 32, z = 105)
if defined?(Plane_ScrollStatus)
@scroll_states = []
@scroll_states << Plane_ScrollStatus.new(actor, x, y, width, height, z)
else ; scroll_states_draw_actor_state(actor, x, y)
end
end
end
#-------------------------------------------------------------------------------
# * SDK Enabled Test - END
#-------------------------------------------------------------------------------
end