设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1645|回复: 2
打印 上一主题 下一主题

[已经过期] 鼠标不能用

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3191
在线时间
1864 小时
注册时间
2010-6-19
帖子
1205
跳转到指定楼层
1
发表于 2022-11-5 22:19:39 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 黑米馒头 于 2022-11-5 22:36 编辑

RGU如何支持鼠标,用了RGU之后,原先的鼠标脚本都不能用了,
一进游戏就脚本错误,RGU的作者修改了Game.exe.导致不支持Win32API.new,
有没有大佬能解决这个问题。。。。,或者有用不到Win32API.new的鼠标脚本






RUBY 代码复制
  1. #==============================================================================
  2. # ■ 完整鼠标系统(八方向)
  3. #------------------------------------------------------------------------------
  4. #  使用时务必配合专用寻路算法
  5. #   By whbm
  6. #==============================================================================
  7. #下面做一下介绍与使用说明:
  8. #    在屏幕上单击鼠标的时候,会自动进行寻路,这里为了速度更快并且为了进行迷
  9. #宫时的难度寻路被限定在当时的屏幕内部。(否则玩家直接点到终点,呵呵....知道
  10. #后果了吧)
  11. #    在角色移动过程中再次单击鼠标(即双击)并在单击第二次鼠标的时候不松手,
  12. #角色将会跟随鼠标方向移动。(这个应该好理解,不用多说吧)当角色贴着欲被启动
  13. #的事件的时候,单击NPC即可启动事件。若未贴着,将会产生自动寻路到NPC附近的某
  14. #点,那时在单击NPC即可。
  15. #    当鼠标停在某些事件上时候会发现有不同的图标,设置方法为:宝箱事件请在事
  16. #件的执行内容中添加 注释,注释内容为 Item 注意大小写。NPC事件请在事件的执行
  17. #内容中添加 注释注释内容为 NPC 注意大小写。若不箱改变某事件的图标,则不要写
  18. #那两个注释。
  19. #    当把脚本转到您工程的时候千万别忘了那个寻路用的脚本。
  20. #==============================================================================
  21. class Game_Event
  22.   attr_accessor :flag
  23. end
  24.  
  25. #==============================================================================
  26. # ■ Game_Map
  27. #------------------------------------------------------------------------------
  28. #  处理地图的类。包含卷动以及可以通行的判断功能。
  29. # 本类的实例请参考 $game_map 。
  30. #==============================================================================
  31. class Game_Map
  32.   def show_rate(event)
  33.     return 1
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 检查鼠标处是否有自定义的事件并返回类型
  37.   #--------------------------------------------------------------------------
  38.   def check_event_custom(mouse_x, mouse_y)
  39.     for event in $game_map.events.values #循环所有事件检查
  40.       rate =  show_rate(event)
  41.       # 修改#####################################
  42.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  43.       ###########################################
  44.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  45.       # 增加一个判定,当行走图名字带★的
  46.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  47.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  48.       ###########################################
  49.       # 调整鼠标点击时图片距离的判定
  50.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  51.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  52.         for i in 0...event.list.size
  53.           if event.list[i].parameters[0] == "Item" #类型判断
  54.             event.flag = 1
  55.           elsif event.list[i].parameters[0] == "Npc" #类型判断
  56.             event.flag = 2
  57.           else
  58.             event.flag = 0 if $game_player.get_mouse_sta != 2 #无标志
  59.           end
  60.           return event.flag #返回事件类型标志
  61.         end
  62.       end
  63.     end
  64.     return 0 if $game_player.get_mouse_sta != 2 #如果不是在跟随鼠标状态,则返回无标志
  65.     return $mouse_icon_id #使鼠标图不变化
  66.   end
  67.   #--------------------------------------------------------------------------
  68.   # ● 检查鼠标处是否有事件可以开启
  69.   #--------------------------------------------------------------------------
  70.   def check_event_custom_start(mouse_x, mouse_y)
  71.     for event in $game_map.events.values #循环所有事件检查
  72.       #事件角色图片宽度、高度
  73.       rate =  show_rate(event)
  74.       # 修改#####################################
  75.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  76.       ###########################################
  77.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  78.       # 增加一个判定,当行走图名字带★的
  79.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  80.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  81.       #判断是否鼠标在事件上
  82.       ###########################################
  83.       # 调整鼠标点击时图片距离的判定
  84.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  85.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  86.         way_x = $game_player.x - event.x
  87.         way_y = $game_player.y - event.y
  88.         if [1,0,-1].include?($game_player.x-event.x) and [1,0,-1].include?($game_player.y-event.y)
  89.           for i in 0...event.list.size
  90.             if ["Item","Npc"].include?(event.list[i].parameters[0]) #当事件属于自定义事件
  91.               #判断主角朝向
  92.               if way_x == -1
  93.                 p_direction = 1 if way_y == -1  # 右下
  94.                 p_direction = 6 if way_y == 0   # 右
  95.                 p_direction = 7 if way_y == 1   # 右上
  96.               elsif way_x == 0
  97.                 p_direction = 2 if way_y == -1  # 下
  98.                 p_direction = 8 if way_y == 1   # 上
  99.               else
  100.                 p_direction = 3 if way_y == -1  # 左下
  101.                 p_direction = 4 if way_y == 0   # 左
  102.                 p_direction = 9 if way_y == 1   # 左上
  103.               end
  104.               event.start #开启事件
  105.               return 1, p_direction #返回即将开启事件以及角色朝向
  106.             end
  107.           end
  108.         end
  109.       end
  110.     end
  111.     return 0, 5 #返回不会开启事件以及角色朝向不变
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ● 检查鼠标处是否存在自定义事件 for 寻路
  115.   #--------------------------------------------------------------------------
  116.   def check_event_custom_exist(mouse_x, mouse_y)
  117.     for event in $game_map.events.values #循环所有事件检查
  118.       #事件角色图片宽度、高度
  119.       rate =  show_rate(event)
  120.       # 修改#####################################
  121.       # 调整鼠标点击NPC的时获取图片范围的宽和高
  122.       ###########################################
  123.       event_width = (RPG::Cache.character(event.character_name,event.character_hue).width / $c3_每一步的帧数) * rate
  124.       # 增加一个判定,当行走图名字带★的
  125.       event_height_rate = event.character_name.include?("★") ?  33 : 15
  126.       event_height = (RPG::Cache.character(event.character_name,event.character_hue).height / event_height_rate) * rate
  127.       ###########################################
  128.       # 调整鼠标点击时图片距离的判定
  129.       # 图片宽度 + 图片X坐标 + 图片高度+ 图片Y坐标
  130.       if mouse_x > event.screen_x - event_width / 8 - 16 and mouse_x < event.screen_x + event_width / 8 - 16 and mouse_y > event.screen_y - event_height / 2 - 64 and mouse_y < event.screen_y + event_height / 4 - 30
  131.         for i in 0...event.list.size
  132.           return 1, event if ["Item", "Npc"].include?(event.list[i].parameters[0]) #返回存在自定义事件以及事件体
  133.         end
  134.       end
  135.     end
  136.     return 0, event #返回不存在自定义事件,以及事件体
  137.   end
  138. end
  139. #=================以下两个用来调整战斗时的手感问题,可以自己试试。
  140. $敌人选框扩大 = 60
  141. $角色选框扩大 = 60
  142.  
  143.  
  144. #==============================================================================
  145. # ● API调用
  146. #==============================================================================
  147. $ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
  148. $GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
  149. $ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
  150. $GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
  151. $Window_HWND = $GetActiveWindow.call
  152. $GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
  153. module Mouse  
  154. LEFT = 0x01
  155. RIGHT = 0x02
  156.  
  157. def self.init(sprite = nil)
  158.    $ShowCursor.call(0)
  159.  
  160.    @show_cursor = false
  161.  
  162.    @mouse_sprite = Sprite.new
  163.    @mouse_sprite.z = 99999
  164.    @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/鼠标指针')
  165.  
  166.    @left_press = false
  167.    @right_press = false
  168.    @left_trigger = false
  169.    @right_trigger = false
  170.    @left_repeat = false
  171.    @right_repeat = false
  172.    @click_lock = false
  173.  
  174.    update
  175. end
  176. def self.exit
  177.    @mouse_sprite.bitmap.dispose
  178.    @mouse_sprite.dispose
  179.    @show_cursor = true
  180.    $ShowCursor.call(1)
  181. end
  182. def self.mouse_debug
  183.    return @mouse_debug.bitmap
  184. end
  185. def self.update
  186.    left_down = $GetKeyState.call(0x01)
  187.    right_down = $GetKeyState.call(0x02)
  188.    if Graphics.frame_count * 3 / Graphics.frame_rate != @total_sec
  189.      @total_sec = Graphics.frame_count * 3 / Graphics.frame_rate
  190.      @a = !@a
  191.    end
  192.    if $scene.is_a?(Scene_Map) == false
  193.      $mouse_icon_id = 0
  194.    end
  195.    if $mouse_icon_id != $mouse_icon_id_last
  196.      case $mouse_icon_id
  197.      when 1
  198.        if @a
  199.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/GetItem1')
  200.        else
  201.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/GetItem2')
  202.        end
  203.      when 2
  204.        if @a
  205.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/TalkTo1')
  206.        else
  207.          @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/TalkTo2')
  208.        end
  209.      when 11
  210.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LOWER_LEFT')
  211.      when 12
  212.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_DOWN')
  213.      when 13
  214.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LOWER_RIGHT')
  215.      when 14
  216.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_LEFT')
  217.      when 16
  218.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_RIGHT')
  219.      when 17
  220.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UPPER_LEFT')
  221.      when 18
  222.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UP')
  223.      when 19
  224.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/Mouse_UPPER_RIGHT')
  225.      when 0
  226.        @mouse_sprite.bitmap = Bitmap.new('Graphics/Icons/鼠标图片/鼠标指针')
  227.      end
  228.      $mouse_icon_id_last = $mouse_icon_id
  229.    end
  230.    @click_lock = false
  231.    mouse_x, mouse_y = self.get_mouse_pos
  232.    if @mouse_sprite != nil
  233.      @mouse_sprite.x = mouse_x
  234.      @mouse_sprite.y = mouse_y
  235.    end
  236.    if left_down[7] == 1
  237.      @left_repeat = (not @left_repeat)
  238.      @left_trigger = (not @left_press)
  239.      @left_press = true
  240.    else
  241.      @left_press = false
  242.      @left_trigger = false
  243.      @left_repeat = false
  244.    end
  245.    if right_down[7] == 1
  246.      @right_repeat = (not @right_repeat)
  247.      @right_trigger = (not @right_press)
  248.      @right_press = true
  249.    else
  250.      @right_press = false
  251.      @right_trigger = false
  252.      @right_repeat = false
  253.    end
  254. end
  255. def self.get_mouse_pos
  256.    point_var = [0, 0].pack('ll')
  257.    if $GetCursorPos.call(point_var) != 0
  258.      if $ScreenToClient.call($Window_HWND, point_var) != 0
  259.        x, y = point_var.unpack('ll')
  260.        if (x < 0) or (x > 1500) then x = 0 end # 鼠标可以超出窗口的距离,默认10000
  261.        if (y < 0) or (y > 1500) then y = 0 end # 鼠标可以超出窗口的距离,默认10000
  262.  
  263.        # 修改###############################
  264.        #####################################
  265.        if x > 1024 then x = 1024 end # 调整屏幕范围 宽度 默认640
  266.        if y > 768 then y = 768 end   # 调整屏幕范围 长度 默认480
  267.        return x, y
  268.      else
  269.        return 0, 0
  270.      end
  271.    else
  272.      return 0, 0
  273.    end
  274. end
  275. def self.press?(mouse_code)
  276.    if mouse_code == LEFT
  277.      if @click_lock
  278.        return false
  279.      else
  280.        return @left_press
  281.      end
  282.    elsif mouse_code == RIGHT
  283.      return @right_press
  284.    else
  285.      return false
  286.    end
  287. end
  288. def self.trigger?(mouse_code)
  289.    if mouse_code == LEFT
  290.      if @click_lock
  291.        return false
  292.      else
  293.        return @left_trigger
  294.      end
  295.    elsif mouse_code == RIGHT
  296.      return @right_trigger
  297.    else
  298.      return false
  299.    end
  300. end
  301. def self.repeat?(mouse_code)
  302.    if mouse_code == LEFT
  303.      if @click_lock
  304.        return false
  305.      else
  306.        return @left_repeat
  307.      end
  308.    elsif mouse_code == RIGHT
  309.      return @right_repeat
  310.    else
  311.      return false
  312.    end
  313. end
  314. def self.click_lock?
  315.    return @click_lock
  316. end
  317. def self.click_lock
  318.    @click_lock = true
  319. end
  320. def self.click_unlock
  321.    @click_lock = false
  322. end
  323. end
  324. module Input
  325. if @self_update == nil
  326.    @self_update = method('update')
  327.    @self_press = method('press?')
  328.    @self_trigger = method('trigger?')
  329.    @self_repeat = method('repeat?')
  330. end
  331. def self.update
  332.    @self_update.call
  333.    Mouse.update
  334. end
  335. def self.press?(key_code)
  336.    if @self_press.call(key_code)
  337.      return true
  338.    end
  339.    if key_code == C
  340.      return Mouse.press?(Mouse::LEFT)
  341.    elsif key_code == B
  342.      return Mouse.press?(Mouse::RIGHT)
  343.    else
  344.      return @self_press.call(key_code)
  345.    end
  346. end
  347. def self.trigger?(key_code)
  348.    if @self_trigger.call(key_code)
  349.      return true
  350.    end
  351.    if key_code == C
  352.      return Mouse.trigger?(Mouse::LEFT)
  353.    elsif key_code == B
  354.      return Mouse.trigger?(Mouse::RIGHT)
  355.    else
  356.      return @self_trigger.call(key_code)
  357.    end
  358. end
  359. def self.repeat?(key_code)
  360.    if @self_repeat.call(key_code)
  361.      return true
  362.    end
  363.    if key_code == C
  364.      return Mouse.repeat?(Mouse::LEFT)
  365.    elsif key_code == B
  366.      return Mouse.repeat?(Mouse::RIGHT)
  367.    else
  368.      return @self_repeat.call(key_code)
  369.    end
  370. end
  371. end
  372. class Window_Selectable
  373. if @self_alias == nil
  374.    alias self_update update
  375.    @self_alias = true
  376. end
  377. def update
  378.    self_update
  379.    if self.active and @item_max > 0
  380.      index_var = @index
  381.      tp_index = @index
  382.      mouse_x, mouse_y = Mouse.get_mouse_pos
  383.      mouse_not_in_rect = true
  384.      for i in 0...@item_max
  385.        @index = i
  386.        update_cursor_rect
  387.        top_x = self.cursor_rect.x + self.x + 16
  388.        top_y = self.cursor_rect.y + self.y + 16
  389.        bottom_x = top_x + self.cursor_rect.width
  390.        bottom_y = top_y + self.cursor_rect.height
  391.        if (mouse_x > top_x) and (mouse_y > top_y) and
  392.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  393.          mouse_not_in_rect = false
  394.          if tp_index != @index
  395.            tp_index = @index
  396.            $game_system.se_play($data_system.cursor_se)
  397.          end
  398.          break
  399.        end
  400.      end
  401.      if mouse_not_in_rect
  402.        @index = index_var
  403.        update_cursor_rect
  404.        Mouse.click_lock
  405.      else
  406.        Mouse.click_unlock               
  407.      end
  408.    end
  409. end
  410. end
  411. class Window_NameInput
  412. if @self_alias == nil
  413.    alias self_update update
  414.    @self_alias = true
  415. end
  416. def update
  417.    self_update
  418.    if self.active
  419.      index_var = @index
  420.      mouse_x, mouse_y = Mouse.get_mouse_pos
  421.      mouse_not_in_rect = true
  422.      for i in (0...CHARACTER_TABLE.size).to_a.push(180)
  423.        @index = i
  424.        update_cursor_rect
  425.        top_x = self.cursor_rect.x + self.x + 16
  426.        top_y = self.cursor_rect.y + self.y + 16
  427.        bottom_x = top_x + self.cursor_rect.width
  428.        bottom_y = top_y + self.cursor_rect.height
  429.        if (mouse_x > top_x) and (mouse_y > top_y) and
  430.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  431.          mouse_not_in_rect = false
  432.          break
  433.        end
  434.      end
  435.      if mouse_not_in_rect
  436.        @index = index_var
  437.        update_cursor_rect
  438.        Mouse.click_lock
  439.      else
  440.        Mouse.click_unlock
  441.      end
  442.    end
  443. end
  444. end
  445.  
  446. ##########################################################
  447. # 角色分类 和 物品栏 支持光标移动
  448. class Window_Selectable_Item
  449. if @self_alias == nil
  450.    alias self_update update
  451.    @self_alias = true
  452. end
  453. def update
  454.    self_update
  455.    if self.active and @item_max > 0
  456.      index_var = @index
  457.      tp_index = @index
  458.      mouse_x, mouse_y = Mouse.get_mouse_pos
  459.      mouse_not_in_rect = true
  460.      for i in 0...@item_max
  461.        @index = i
  462.        update_cursor_rect
  463.        top_x = self.cursor_rect.x + self.x + 16
  464.        top_y = self.cursor_rect.y + self.y + 16
  465.        bottom_x = top_x + self.cursor_rect.width
  466.        bottom_y = top_y + self.cursor_rect.height
  467.        if (mouse_x > top_x) and (mouse_y > top_y) and
  468.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  469.          mouse_not_in_rect = false
  470.          if tp_index != @index
  471.            tp_index = @index
  472.            $game_system.se_play($data_system.cursor_se)
  473.          end
  474.          break
  475.        end
  476.      end
  477.      if mouse_not_in_rect
  478.        @index = index_var
  479.        update_cursor_rect
  480.        Mouse.click_lock
  481.      else
  482.        Mouse.click_unlock               
  483.      end
  484.    end
  485. end
  486. end
  487.  
  488. ##########################################################
  489. # 角色装备栏支持鼠标光标移动
  490. class Window_Selectable_Item_w
  491. if @self_alias == nil
  492.    alias self_update update
  493.    @self_alias = true
  494. end
  495. def update
  496.    self_update
  497.    if self.active and @item_max > 0
  498.      index_var = @index
  499.      tp_index = @index
  500.      mouse_x, mouse_y = Mouse.get_mouse_pos
  501.      mouse_not_in_rect = true
  502.      for i in 0...@item_max
  503.        @index = i
  504.        update_cursor_rect
  505.        top_x = self.cursor_rect.x + self.x + 16
  506.        top_y = self.cursor_rect.y + self.y + 16
  507.        bottom_x = top_x + self.cursor_rect.width
  508.        bottom_y = top_y + self.cursor_rect.height
  509.        if (mouse_x > top_x) and (mouse_y > top_y) and
  510.           (mouse_x < bottom_x) and (mouse_y < bottom_y)
  511.          mouse_not_in_rect = false
  512.          if tp_index != @index
  513.            tp_index = @index
  514.            $game_system.se_play($data_system.cursor_se)
  515.          end
  516.          break
  517.        end
  518.      end
  519.      if mouse_not_in_rect
  520.        @index = index_var
  521.        update_cursor_rect
  522.        Mouse.click_lock
  523.      else
  524.        Mouse.click_unlock               
  525.      end
  526.    end
  527. end
  528. end
  529. ##########################################################
  530.  
  531. class Window_InputNumber
  532. if @self_alias == nil
  533.    alias self_update update
  534.    @self_alias = true
  535. end
  536. def update
  537.    self_update
  538.    mouse_x, mouse_y = Mouse.get_mouse_pos
  539.    if self.active and @digits_max > 0
  540.      index_var = @index
  541.      mouse_not_in_rect = true
  542.      for i in 0...@digits_max
  543.        @index = i
  544.        update_cursor_rect
  545.        top_x = self.cursor_rect.x + self.x + 16
  546.        bottom_x = top_x + self.cursor_rect.width
  547.        if (mouse_x > top_x) and (mouse_x < bottom_x)
  548.          mouse_not_in_rect = false
  549.          break
  550.        end
  551.      end
  552.      if mouse_not_in_rect
  553.        @index = index_var
  554.        update_cursor_rect
  555.        Mouse.click_lock
  556.      else
  557.        Mouse.click_unlock
  558.      end
  559.    end
  560.    if @last_mouse_y == nil
  561.      @last_mouse_y = mouse_y
  562.    end
  563.    check_pos = (@last_mouse_y - mouse_y).abs
  564.    if check_pos > 10
  565.      $game_system.se_play($data_system.cursor_se)
  566.      place = 10 ** (@digits_max - 1 - @index)
  567.      n = @number / place % 10
  568.      @number -= n * place
  569.      n = (n + 1) % 10 if mouse_y < @last_mouse_y
  570.      n = (n + 9) % 10 if mouse_y > @last_mouse_y
  571.      @number += n * place
  572.      refresh
  573.      @last_mouse_y = mouse_y
  574.    end
  575. end
  576. end
  577.  
  578. class Scene_File
  579. if @self_alias == nil
  580.    alias self_update update
  581.    @self_alias = true
  582. end
  583. def update
  584.    mouse_x, mouse_y = Mouse.get_mouse_pos
  585.    Mouse.click_lock
  586.    idx = 0
  587.    for i in @savefile_windows
  588.      top_x = i.x + 16
  589.      top_y = i.y + 16
  590.      bottom_x = top_x + i.width
  591.      bottom_y = top_y + i.height
  592.      if (mouse_x > top_x) and (mouse_y > top_y) and
  593.         (mouse_x < bottom_x) and (mouse_y < bottom_y)
  594.        i.selected = true
  595.        if @file_index != idx
  596.          @file_index = idx
  597.          $game_system.se_play($data_system.cursor_se)
  598.        end            
  599.        Mouse.click_unlock
  600.      else
  601.        i.selected = false
  602.      end
  603.      idx += 1
  604.    end
  605.    self_update
  606. end
  607. end
  608.  
  609. class Arrow_Enemy
  610. if @self_alias == nil
  611.    alias self_update update
  612.    @self_alias = true
  613. end
  614. def update
  615.    mouse_x, mouse_y = Mouse.get_mouse_pos
  616.    idx = 0
  617.    for i in $game_troop.enemies do
  618.      if i.exist?
  619.        top_x = i.screen_x - self.ox
  620.        top_y = i.screen_y - self.oy
  621.        bottom_x = top_x + self.src_rect.width
  622.        bottom_y = top_y + self.src_rect.height
  623.           # 战斗时 鼠标获取 敌人战斗图的 宽 和 高
  624.        if (mouse_x > top_x - $敌人选框扩大) and (mouse_y > top_y - $敌人选框扩大 - 10) and
  625.           # 战斗时 鼠标获取 敌人X,Y坐标位置
  626.           (mouse_x < bottom_x + $敌人选框扩大) and (mouse_y < bottom_y + $敌人选框扩大 - 30)
  627.          if @index != idx
  628.            $game_system.se_play($data_system.cursor_se)
  629.            @index = idx
  630.          end
  631.        end
  632.      end
  633.      idx += 1
  634.    end
  635.    self_update
  636. end
  637. end
  638. class Arrow_Actor
  639. if @self_alias == nil
  640.    alias self_update update
  641.    @self_alias = true
  642. end
  643. def update
  644.    mouse_x, mouse_y = Mouse.get_mouse_pos
  645.    idx = 0
  646.    for i in $game_party.actors do
  647.      if i.exist?
  648.        top_x = i.screen_x - self.ox
  649.        top_y = i.screen_y - self.oy
  650.        bottom_x = top_x + self.src_rect.width
  651.        bottom_y = top_y + self.src_rect.height
  652.        # 战斗时 鼠标获取 角色战斗图的 宽 和 高
  653.        if (mouse_x > top_x - $角色选框扩大) and (mouse_y > top_y - $角色选框扩大 - 50) and
  654.          # 战斗时 鼠标获取 角色X,Y坐标位置
  655.           (mouse_x < bottom_x + $角色选框扩大) and (mouse_y < bottom_y + $角色选框扩大 - 30)
  656.          if @index != idx
  657.            $game_system.se_play($data_system.cursor_se)
  658.            @index = idx
  659.          end
  660.        end
  661.      end
  662.      idx += 1
  663.    end
  664.    self_update
  665. end
  666. end
  667. #==============================================================================
  668. # ■ Game_Player
  669. #------------------------------------------------------------------------------
  670. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  671. # 本类的实例请参考 $game_player。
  672. #   鼠标控制角色的主程序
  673. #==============================================================================
  674. class Game_Player
  675. if @self_alias == nil
  676.    alias self_update update
  677.    @self_alias = true
  678. end
  679. #--------------------------------------------------------------------------
  680. # ● 得到鼠标的状态
  681. #--------------------------------------------------------------------------
  682. def get_mouse_sta
  683.    return @mouse_sta
  684. end
  685. #--------------------------------------------------------------------------
  686. # ● 完整鼠标系统
  687. #--------------------------------------------------------------------------
  688. def update
  689.    mouse_x, mouse_y = Mouse.get_mouse_pos
  690.    @mtp_x = mouse_x
  691.    @mtp_y = mouse_y
  692.    unless $game_system.map_interpreter.running? and @mouse_sta == 2 #鼠标状态不为跟随状态
  693.      #得到鼠标图标方向
  694.      $mouse_icon_id = $game_map.check_event_custom(mouse_x,mouse_y)  if not [11, 12, 13, 14, 16, 17, 18, 19].include?($mouse_icon_id)
  695.    else
  696.      #令鼠标图标为正常
  697.      $mouse_icon_id = 0 if @mouse_sta != 2
  698.    end
  699.  
  700.    #单击鼠标时进行判断寻路或跟随
  701.    if Mouse.trigger?(Mouse::LEFT) #当点击鼠标时
  702.      unless $game_system.map_interpreter.running? or
  703.             @move_route_forcing or $game_temp.message_window_showing #各种无效情况的排除
  704.        #初始化
  705.        @mouse_sta = 1
  706.        p_direction = 5
  707.        #检查鼠标处能否开启事件
  708.        event_start,p_direction = $game_map.check_event_custom_start(mouse_x, mouse_y)
  709.        #若在移动中再次点击鼠标左键(即双击左键),则改鼠标状态为跟随状态
  710.        @mouse_sta = 2 if @paths_id != nil and @paths_id != @paths.size
  711.        if @mouse_sta != 2
  712.          #鼠标状态不为跟随状态则取数据并初始化路径
  713.          trg_x = (mouse_x + $game_map.display_x / 4) / 32
  714.          trg_y = (mouse_y + $game_map.display_y / 4) / 32
  715.          @paths = []
  716.          @paths_id = 0
  717.          if event_start == 0 #若不能开启事件
  718.            if trg_x != $game_player.x or trg_y != $game_player.y #若目标不为自身则开始寻路
  719.              find_path = Find_Path.new
  720.              @paths = find_path.find_player_short_path(trg_x, trg_y, @mtp_x, @mtp_y)
  721.            end
  722.          else #若能开启事件则改变角色朝向
  723.            @direction = p_direction
  724.          end
  725.        end
  726.      end
  727.    end
  728.  
  729.    #开始移动
  730.    if @mouse_sta != nil and @mouse_sta == 1 #若鼠标状态为寻路状态
  731.      unless moving? or $game_system.map_interpreter.running? or
  732.             @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  733.        if @paths_id != nil and @paths != nil and @paths_id <= @paths.size #若没有完成路径
  734.          case @paths[@paths_id] #判断路径
  735.          when 6
  736.            @last_move_x = true
  737.            move_right
  738.            @paths_id += 1
  739.            @direction = 6 # 右
  740.          when 4
  741.            @last_move_x = true
  742.            move_left
  743.            @paths_id += 1
  744.            @direction = 4 # 左
  745.          when 2
  746.            @last_move_x = false
  747.            move_down
  748.            @direction = 2 # 下
  749.            @paths_id += 1
  750.          when 8
  751.            @last_move_x = false
  752.            move_up
  753.            @direction = 8 #上
  754.            @paths_id += 1
  755.          #斜四方向
  756.          when 1
  757.            @last_move_x = false
  758.            move_lower_left
  759.            @direction = 3 # 左下
  760.            @paths_id += 1
  761.          when 3
  762.            @last_move_x = false
  763.            move_lower_right
  764.            @direction = 1 # 右下
  765.            @paths_id += 1
  766.          when 7
  767.            @last_move_x = false
  768.            move_upper_left
  769.            @direction = 9 #左上
  770.            @paths_id += 1
  771.          when 9
  772.            @last_move_x = false
  773.            move_upper_right
  774.            @direction = 7 #右上
  775.            @paths_id += 1
  776.          end
  777.        end
  778.      end
  779.    elsif @paths != nil and @mouse_sta == 2 #当鼠标状态为跟随,且在移动中
  780.      if Mouse.press?(Mouse::LEFT) #持续按住鼠标
  781.        unless moving? or $game_system.map_interpreter.running? or
  782.               @move_route_forcing or $game_temp.message_window_showing #排除无效情况
  783.          #跟随方向判断并跟随
  784.          rate =  $game_map.show_rate(self)
  785.          width = (RPG::Cache.character(self.character_name,self.character_hue).width / $c3_每一步的帧数) * rate
  786.          height = (RPG::Cache.character(self.character_name,self.character_hue).height / 8) * rate
  787.          self_ox = (self.screen_x - width / 2 + self.screen_x + width / 2) / 2
  788.          self_oy = (self.screen_y - height + self.screen_y) / 2
  789.          #self_ox = self.screen_x
  790.          #self_oy = self.screen_y
  791.          if (@mtp_x - self_ox)*(@mtp_x - self_ox) + (@mtp_y - self_oy)*(@mtp_y - self_oy) >= 961
  792.            if @mtp_x > self_ox
  793.              if self_oy - @mtp_y < 0.4 * (@mtp_x - self_ox) and
  794.                 @mtp_y - self_oy < 0.4 * (@mtp_x - self_ox)
  795.                move_right
  796.                $mouse_icon_id = 16
  797.                @direction = 6 ## 右
  798.              end
  799.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  800.                 @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  801.                move_lower_right
  802.                $mouse_icon_id = 13
  803.                @direction = 3 ## 左下
  804.              end
  805.              if @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x ) and
  806.                 @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  807.                move_upper_right
  808.                $mouse_icon_id = 19
  809.                @direction = 7 ## 右上
  810.              end
  811.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  812.                move_down
  813.                $mouse_icon_id = 12
  814.                @direction = 2 ## 下
  815.              end
  816.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  817.                move_up
  818.                $mouse_icon_id = 18
  819.                @direction = 8 ## 上
  820.              end
  821.            end
  822.            if @mtp_x < self_ox
  823.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  824.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  825.                move_left
  826.                $mouse_icon_id = 14
  827.                @direction = 4 ## 左
  828.              end
  829.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  830.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  831.                move_lower_left
  832.                $mouse_icon_id = 11
  833.                @direction = 1 ## 左下
  834.              end
  835.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  836.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  837.                move_upper_left
  838.                $mouse_icon_id = 17
  839.                @direction = 9 ## 左上
  840.              end
  841.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  842.                move_down
  843.                $mouse_icon_id = 12
  844.                @direction = 2 ## 下
  845.              end
  846.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  847.                move_up
  848.                $mouse_icon_id = 18
  849.                @direction = 8 ## 上
  850.              end
  851.            end
  852.          end
  853.            #...................................................................
  854.            if @mtp_x > self_ox
  855.              if @mtp_y - self_oy > - 0.4 * ( @mtp_x - self_ox ) and
  856.                 @mtp_y - self_oy < 0.4 * ( @mtp_x - self_ox )
  857.                $mouse_icon_id = 16
  858.                @direction = 6 # 右
  859.              end
  860.              if @mtp_y - self_oy > 0.4 * ( @mtp_x - self_ox ) and
  861.                @mtp_y - self_oy < 2.4 * ( @mtp_x - self_ox )
  862.                $mouse_icon_id = 13
  863.                @direction = 1 # 右下
  864.              end
  865.              if @mtp_y - self_oy < - 0.4 * ( @mtp_x - self_ox ) and
  866.                @mtp_y - self_oy > - 2.4 * ( @mtp_x - self_ox )
  867.                $mouse_icon_id = 19
  868.                @direction = 7 # 右上
  869.              end
  870.              if @mtp_y - self_oy > 2.4 * ( @mtp_x - self_ox )
  871.                $mouse_icon_id = 12
  872.                @direction = 2 # 下
  873.              end
  874.              if @mtp_y - self_oy < - 2.4 * ( @mtp_x - self_ox )
  875.                $mouse_icon_id = 18
  876.                @direction = 8 # 上
  877.              end
  878.            end
  879.            if @mtp_x < self_ox
  880.              if @mtp_y - self_oy > - 0.4 * ( self_ox - @mtp_x ) and
  881.                 @mtp_y - self_oy < 0.4 * ( self_ox - @mtp_x )
  882.                $mouse_icon_id = 14
  883.                @direction = 4 # 左
  884.              end
  885.              if @mtp_y - self_oy > 0.4 * ( self_ox - @mtp_x ) and
  886.                 @mtp_y - self_oy < 2.4 * ( self_ox - @mtp_x )
  887.                $mouse_icon_id = 11
  888.                @direction = 3 # 左下
  889.              end
  890.              if @mtp_y - self_oy < - 0.4 * ( self_ox - @mtp_x ) and
  891.                 @mtp_y - self_oy > - 2.4 * ( self_ox - @mtp_x )
  892.                $mouse_icon_id = 17
  893.                @direction = 9 # 左上
  894.              end
  895.              if @mtp_y - self_oy > 2.4 * ( self_ox - @mtp_x )
  896.                $mouse_icon_id = 12
  897.                @direction = 2 # 下
  898.              end
  899.              if @mtp_y - self_oy < - 2.4 * ( self_ox - @mtp_x )
  900.                $mouse_icon_id = 18
  901.                @direction = 8 # 上
  902.              end
  903.            end
  904.            #...................................................................
  905.        end
  906.      else #没状态的情况
  907.        $mouse_icon_id = 0
  908.        @mouse_sta = 0
  909.        @paths_id = @paths.size #终止寻路移动
  910.      end
  911.    end
  912.    self_update
  913. end
  914. end
  915. Mouse.init
  916. END { Mouse.exit }

Lv4.逐梦者

梦石
0
星屑
6483
在线时间
119 小时
注册时间
2020-1-8
帖子
234
2
发表于 2022-11-6 16:09:05 | 只看该作者
RGU我的电脑运行RMXP直接闪退……,就没发试
对ruby1.8还比较熟悉,后续版本没用过……
好像有个Fiddle的模块取代了Win32API,应该也能调用这些DLL的函数,自己上网查一下吧
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2821
在线时间
585 小时
注册时间
2022-7-13
帖子
89
3
发表于 2022-11-8 07:04:16 | 只看该作者
我多次尝试,无解,只能等作者优化
使用sion鼠标系统可以正常获取到鼠标坐标,且不出错
但是由于获取不到句柄无法转化为屏幕坐标,依然无解
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-2 19:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表