#==============================
#系统cursor。不再闪烁
#==============================
#多了一个Window_SaveFile另类,只好Window_Base,不然可以把内容全放在Window_Selectable
#==============================
#通用窗口
#未重定义update_cursor_rect
#==============================
class Window_Base < Window
alias rgss1_init_for_cursor initialize unless method_defined? :rgss1_init_for_cursor
def initialize(*args)
rgss1_init_for_cursor(*args)
@cursor_sprite = Sprite.new(self.viewport)
@cursor_sprite.visible = false
@cursor_sprite.x = 16 + self.x
@cursor_sprite.y = 16 + self.y
@cursor_sprite.z = self.z + 1
end
alias rgss1_x_for_cursor x= unless method_defined? :rgss1_x_for_cursor
def x=(x)
rgss1_x_for_cursor(x)
return if @cursor_sprite.nil?
@cursor_sprite.x = 16 + x
end
alias rgss1_y_for_cursor y= unless method_defined? :rgss1_y_for_cursor
def y=(y)
rgss1_y_for_cursor(y)
return if @cursor_sprite.nil?
@cursor_sprite.y = 16 + y
end
alias rgss1_z_for_cursor z= unless method_defined? :rgss1_z_for_cursor
def z=(z)
rgss1_z_for_cursor(z)
return if @cursor_sprite.nil?
@cursor_sprite.z = 1 + z
end
alias rgss1_vis_for_cursor visible= unless method_defined? :rgss1_vis_for_cursor
def visible=(visible)
rgss1_vis_for_cursor(visible)
return if @cursor_sprite.nil?
@cursor_sprite.visible = false unless visible
end
alias rgss1_dis_for_cursor dispose unless method_defined? :rgss1_dis_for_cursor
def dispose
@cursor_sprite.dispose
rgss1_dis_for_cursor
end
def update_cursor_sprite
return if self.cursor_rect.width == 0 or self.cursor_rect.height == 0
if @index.is_a?(Integer)
if @index < 0 ; @cursor_sprite.visible = false ; return ; end
else
unless @selected ; @cursor_sprite.visible = false ; return ; end
end
cursor_x = self.cursor_rect.x
cursor_y = self.cursor_rect.y
cursor_width = self.cursor_rect.width
cursor_height = self.cursor_rect.height
self.cursor_rect.empty
if @cursor_sprite.bitmap.nil? or @cursor_sprite.bitmap.width != cursor_width or @cursor_sprite.bitmap.height != cursor_height
if @cursor_sprite.bitmap
@cursor_sprite.bitmap.dispose
@cursor_sprite.bitmap = nil
end
@cursor_sprite.bitmap = Bitmap.new(cursor_width, cursor_height)
dest_rect = Rect.new(0, 0, cursor_width, 1)
src_rect = Rect.new(128, 64, 32, 1)
@cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
dest_rect.set(0, cursor_height - 1, cursor_width, 1)
src_rect.set(128, 64, 32, 1)
@cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
dest_rect.set(0, 0, 1, cursor_height)
src_rect.set(128, 64, 1, 32)
@cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
dest_rect.set(cursor_width - 1, 0, 1, cursor_height)
src_rect.set(128, 64, 1, 32)
@cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
dest_rect.set(0, 0, cursor_width, cursor_height)
src_rect.set(130, 66, 28, 28)
@cursor_sprite.bitmap.stretch_blt(dest_rect, self.windowskin, src_rect)
end
@cursor_sprite.x = 16 + self.x + cursor_x
@cursor_sprite.y = 16 + self.y + cursor_y
@cursor_sprite.visible = true
end
end
class Window_Selectable < Window_Base
alias rgss1_index_for_cursor index= unless method_defined? :rgss1_index_for_cursor
def index=(index)
rgss1_index_for_cursor(index)
return if @cursor_sprite.nil?
@cursor_sprite.visible = false if index < 0
end
alias rgss1_active_for_cursor active= unless method_defined? :rgss1_active_for_cursor
def active=(active)
rgss1_active_for_cursor(active)
return if @cursor_sprite.nil?
@cursor_sprite.visible = false unless active
end
alias rgss1_upcur_for_cursor update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor
def update_cursor_rect
rgss1_upcur_for_cursor
update_cursor_sprite if self.active
end
end
#==============================
#一般窗口
#重定义了update_cursor_rect
#其他的窗口,照猫画虎就行了
#==============================
class Window_MenuStatus < Window_Selectable
alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
def update_cursor_rect
rgss1_upcur_for_cursor_subclass
update_cursor_sprite if self.active
end
end
class Window_Target < Window_Selectable
alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
def update_cursor_rect
rgss1_upcur_for_cursor_subclass
update_cursor_sprite if self.active
end
end
class Window_Message < Window_Selectable
alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
def update_cursor_rect
rgss1_upcur_for_cursor_subclass
update_cursor_sprite if self.active
end
end
class Window_PartyCommand < Window_Selectable
alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
def update_cursor_rect
rgss1_upcur_for_cursor_subclass
update_cursor_sprite if self.active
end
end
class Window_SaveFile < Window_Base
alias rgss1_sele_for_cursor selected= unless method_defined? :rgss1_sele_for_cursor
def selected=(selected)
rgss1_sele_for_cursor(selected)
@cursor_sprite.visible = false unless @selected
end
alias rgss1_upcur_for_cursor_subclass update_cursor_rect unless method_defined? :rgss1_upcur_for_cursor_subclass
def update_cursor_rect
rgss1_upcur_for_cursor_subclass
update_cursor_sprite
end
end