# 鼠标指针变换功能 v2.2 (2014.1.24)
# ·需· 鼠标系统(SionMouseSystem)v2.1+
# 说明:
# 鼠标指针图片参考 Grpahics\System\VariableCursor.png
# 单个指针图片大小默认是64x64,图片的中心为鼠标坐标
#
# 事件中添加注释: 鼠标指针i
# 鼠标移动到此事件上时鼠标指针自动切换到对应图片
# 可以参考范例里的事件注释
#
#
class << Mouse
CursorSize = 64 #单个图标大小
def create_cursor(vp)
dispose_cursor if @sprite
@sprite = Sprite.new(vp)
@sprite.z = 9999
if File.exist?('Graphics/System/VariableCursor.png')
@sprite.bitmap = Cache.system('VariableCursor')
else
msgbox("Graphics/System/VariableCursor.png 缺失")
exit
end
@sprite.src_rect.set(0, 0, CursorSize, CursorSize)
@sprite.ox = CursorSize / 2
@sprite.oy = CursorSize / 2
update_cursor
end
def change_cursor(i)
@sprite.src_rect.x = i * CursorSize
end
end
class Scene_Map
alias_method :change_cursor_update_mouse_action, :update_mouse_action
def update_mouse_action
Mouse.change_cursor(0)
$game_map.events_xy($game_map.mouse_map_x, \
$game_map.mouse_map_y).each {|event|
if event.mouse_start?
break Mouse.change_cursor(1)
elsif event.cursor_index
break Mouse.change_cursor(event.cursor_index)
end
}
change_cursor_update_mouse_action
end
alias_method :change_cursor_sion_mouse_call_menu, :call_menu
def call_menu
Mouse.change_cursor(0)
change_cursor_sion_mouse_call_menu
end
end
class Game_Event
attr_reader :locked, :cursor_index
alias_method :change_cursor_lock, :lock
def lock
Mouse.change_cursor(0)
change_cursor_lock
end
alias_method :change_cursor_sion_mouse_start, :sion_mouse_start
def sion_mouse_start
Mouse.change_cursor(0)
change_cursor_sion_mouse_start
end
def sion_mouse_read_event_notes
@mouse_start = false
@cursor_index = nil
@list.each {|cmd| break if sion_mouse_scan_list(cmd)} unless empty?
end
def sion_mouse_scan_list(cmd) # 覆盖
return false unless cmd.code == 108 || cmd.code == 408
text = cmd.parameters[0]
if text.include?("鼠标启动")
@mouse_start = true
@cursor_index = 1 #设置鼠标启动对应的鼠标指针索引
elsif /鼠标指针(\d+)/ =~ text
@cursor_index = $1.to_i
end
return @cursor_index
end
end
class Game_Player < Game_Character
alias_method :change_cursor_make_encounter_count, :make_encounter_count
def make_encounter_count
Mouse.change_cursor(0)
change_cursor_make_encounter_count
end
end