=begin
鼠标系统V1.0 by 浮云半仙
需要 [url]http://rpg.blue/thread-133018-1-1.html[/url] 这个脚本
请在Graphics/mouse下放入normal.png 作为光标的图案
已经滋瓷:
·鼠标启动事件
在允许鼠标启动的事件,事件页第一页,执行方式自动执行,内容
脚本: $game_map.events[@event_id].mouse_start = true
独立开关A = on
第二页开始真正的事件内容
·鼠标点击寻路
可配合我的spfa四方向寻路系统使用,如果没有这个脚本请把
USE_SPFA_FINDPATH设置为false。寻路系统地址
[url]https://rpg.blue/forum.php?mod=viewthread&tid=389467[/url]
未滋瓷:
·选项窗口还不滋瓷鼠标操作
·多种光标图案
敬请期待更新
=end
#命名空间
module FYBX
#
USE_SPFA_FINDPATH = true #是否使用鼠标自动寻路(配合我的spfa四方向寻路系统)
class Mouse
attr_accessor :cur_img
attr_accessor :x, :y
attr_accessor :map_x, :map_y
attr_reader :left_lock, :right_lock
GetCursorPos = Win32API.new("user32", "GetCursorPos", "p", "i")
ScreenToClient = Win32API.new("user32", "ScreenToClient", "lp", "i")
GetCursor = Win32API.new("user32", "GetCursor", "", "l")
DestroyCursor = Win32API.new("user32", "DestroyCursor", "l", "i")
ShowCursor = Win32API.new("user32", "ShowCursor", "i", "i")
GetKeyState = Win32API.new("user32", "GetKeyState", "i", "i")
HWND = get_hWnd
BUF = "\0"*8
PRESS_STATE = [-127, -128]
def initialize
ShowCursor.call 0
@x = @y = @map_x = @map_y = 0
@left_lock = @right_lock = false
end
def update_pos
GetCursorPos.call BUF
ScreenToClient.call HWND, BUF
@x, @y = BUF.unpack("ll")
@map_x = $game_map.display_x + @x/32
@map_y = $game_map.display_y + @y/32
end
def update_image
@cur_img.dispose if @cur_img
@cur_img = Sprite.new
@cur_img.bitmap = Bitmap.new("Graphics/mouse/normal.png")
@cur_img.x = @x
@cur_img.y = @y
@cur_img.z = 9999
end
def update_state
@left_lock = @right_lock = false
@left_lock = true if PRESS_STATE.include?(GetKeyState.call 0x01)
@right_lock = true if PRESS_STATE.include?(GetKeyState.call 0x02)
end
def update_events
if @left_lock
$game_map.events_xy(@map_x, @map_y).each {|e| e.start if e.mouse_start}
$game_map.update(true)
end
end
def update_findpath
if @left_lock
SceneManager.scene.fybx_force_player_stop_findpath if SceneManager.scene.is_a?(Scene_Map) rescue nil
FYBX::FindPath.find_path :target_x => @map_x, :target_y => @map_y
end
end
def update
update_state
update_pos
update_image
update_events
update_findpath if USE_SPFA_FINDPATH
end
end
#名字空间结束
end
#-----------
class Game_Event
attr_accessor :mouse_start
end
$mouse = FYBX::Mouse.new
module Graphics
Graphics.instance_eval do
alias :old_update :update
end
def self.update
self.old_update
$mouse.update
end
end