Project1

标题: 如何在不移动鼠标的情况下自动禁用鼠标? [打印本页]

作者: 果冻叮当猫    时间: 2008-9-21 01:52
标题: 如何在不移动鼠标的情况下自动禁用鼠标?
鼠标在没有使用的情况下老是自己碰到别的光标时候总是要跟键盘抢光标!应该如何解决这个问题呢?有没有什么办法让鼠标暂时禁用? [LINE]1,#dddddd[/LINE]版务信息:版主帮忙结贴~
作者: 黑鏻    时间: 2008-9-21 01:55
鼠标脚本选项页的滚动
http://rpg.blue/web/htm/news1021.htm

看下~~~
作者: dbshy    时间: 2008-9-21 03:29
屏蔽按键请改下面

module Input
  if @self_update == nil
    @self_update = method('update')
    @self_press = method('press?')
    @self_trigger = method('trigger?')
    @self_repeat = method('repeat?')
  end
  def self.update
    @self_update.call
    Mouse.update
  end
  def self.press?(key_code)
    if @self_press.call(key_code)
      return true
    end
    if key_code == C
      return Mouse.press?(Mouse::LEFT)
    elsif key_code == B
      return Mouse.press?(Mouse::RIGHT)
    else
      return @self_press.call(key_code)
    end
  end
  def self.trigger?(key_code)
    if @self_trigger.call(key_code)
      return true
    end
    if key_code == C
      return Mouse.trigger?(Mouse::LEFT)
    elsif key_code == B  
      return Mouse.trigger?(Mouse::RIGHT)
    else
      return @self_trigger.call(key_code)
    end
  end
  def self.repeat?(key_code)
    if @self_repeat.call(key_code)
      return true
    end
    if key_code == C
     return Mouse.repeat?(Mouse::LEFT)
    elsif key_code == B
      return Mouse.repeat?(Mouse::RIGHT)
    else
      return @self_repeat.call(key_code)
    end
  end
end


在着这加句判断
if key_code == C


刷新光标

class Window_Selectable
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    #self.cursor_rect.empty
    self_update
    if self.active and @item_max > 0
      index_var = @index
      tp_index = @index
      mouse_x, mouse_y = Mouse.get_mouse_pos
      mouse_not_in_rect = true
      for i in 0...@item_max
        @index = i
        update_cursor_rect
        top_x = self.cursor_rect.x + self.x + 16
        top_y = self.cursor_rect.y + self.y + 16
        bottom_x = top_x + self.cursor_rect.width
        bottom_y = top_y + self.cursor_rect.height
        if (mouse_x > top_x) and (mouse_y > top_y) and
           (mouse_x < bottom_x) and (mouse_y < bottom_y)
          mouse_not_in_rect = false
          if tp_index != @index
            tp_index = @index
            $game_system.se_play($data_system.cursor_se)
          end
          break
        end
      end
      if mouse_not_in_rect
        @index = index_var
        update_cursor_rect
        Mouse.click_lock
      else
        Mouse.click_unlock               
      end
    end
  end
end

把update_cursor_rect这句用个IF来判断一下

自动禁用的话,可以用变量记录上一次的mouse_pos
如果不动就不刷新

[LINE]1,#dddddd[/LINE]系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
作者: 果冻叮当猫    时间: 2008-9-21 04:19
以下引用dbshy于2008-9-20 19:29:05的发言:

屏蔽按键请改下面

module Input
if @self_update == nil
   @self_update = method('update')
   @self_press = method('press?')
   @self_trigger = method('trigger?')
   @self_repeat = method('repeat?')
end
def self.update
   @self_update.call
   Mouse.update
end
def self.press?(key_code)
   if @self_press.call(key_code)
     return true
   end
   if key_code == C
     return Mouse.press?(Mouse::LEFT)
   elsif key_code == B
     return Mouse.press?(Mouse::RIGHT)
   else
     return @self_press.call(key_code)
   end
end
def self.trigger?(key_code)
   if @self_trigger.call(key_code)
     return true
   end
   if key_code == C
     return Mouse.trigger?(Mouse::LEFT)
   elsif key_code == B  
     return Mouse.trigger?(Mouse::RIGHT)
   else
     return @self_trigger.call(key_code)
   end
end
def self.repeat?(key_code)
   if @self_repeat.call(key_code)
     return true
   end
   if key_code == C
    return Mouse.repeat?(Mouse::LEFT)
   elsif key_code == B
     return Mouse.repeat?(Mouse::RIGHT)
   else
     return @self_repeat.call(key_code)
   end
end
end


在着这加句判断
if key_code == C


刷新光标

class Window_Selectable
if @self_alias == nil
   alias self_update update
   @self_alias = true
end
def update
   #self.cursor_rect.empty
   self_update
   if self.active and @item_max > 0
     index_var = @index
     tp_index = @index
     mouse_x, mouse_y = Mouse.get_mouse_pos
     mouse_not_in_rect = true
     for i in 0...@item_max
       @index = i
       update_cursor_rect
       top_x = self.cursor_rect.x + self.x + 16
       top_y = self.cursor_rect.y + self.y + 16
       bottom_x = top_x + self.cursor_rect.width
       bottom_y = top_y + self.cursor_rect.height
       if (mouse_x > top_x) and (mouse_y > top_y) and
          (mouse_x < bottom_x) and (mouse_y < bottom_y)
         mouse_not_in_rect = false
         if tp_index != @index
           tp_index = @index
           $game_system.se_play($data_system.cursor_se)
         end
         break
       end
     end
     if mouse_not_in_rect
       @index = index_var
       update_cursor_rect
       Mouse.click_lock
     else
       Mouse.click_unlock               
     end
   end
end
end

把update_cursor_rect这句用个IF来判断一下

自动禁用的话,可以用变量记录上一次的mouse_pos
如果不动就不刷新




[本贴由作者于 2008-9-20 19:49:24 最后编辑]


老大!看不懂!郁闷中……需要售后服务!谢谢!{/hx}

作者: 果冻叮当猫    时间: 2008-9-23 05:50
老大!我研究不出来啊!bug满天飞!再找个高手帮我看看吧
作者: 果冻叮当猫    时间: 2008-9-23 08:39
ok!搞定了!不过还是有点问题!鼠标被禁用后光标还是不听话自动跑掉一次!{/jy}怎么会这样




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1