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

Project1

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

[已经过期] VX鼠标系统 存不了挡

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
5 小时
注册时间
2012-12-15
帖子
6
跳转到指定楼层
1
 楼主| 发表于 2013-1-17 21:42:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

#=================以下两个用来调整战斗时的手感问题,可以自己试试。
$敌人选框扩大 = 20
$角色选框扩大 = 30


#==============================================================================
# API调用
#==============================================================================
$ShowCursor = Win32API.new("user32", "ShowCursor", 'i', 'l')
$GetCursorPos = Win32API.new("user32", "GetCursorPos", 'p', 'i')
$ScreenToClient = Win32API.new("user32", "ScreenToClient", 'ip', 'i')
$GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, 'l')
$Window_HWND = $GetActiveWindow.call
$GetKeyState = Win32API.new("user32", "GetKeyState", 'i', 'i')
#$FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
#$HookStart  = Win32API.new("mouse_hook.dll", "HookStart", 'i', nil)
#$HookEnd  = Win32API.new("mouse_hook.dll", "HookEnd", nil, nil)
#$GetMouseStatus  = Win32API.new("mouse_hook.dll", "GetMouseStatus", 'i', 'i')
#$Window_HWND = $FindWindow.call(nil, 'mousetry')

module Mouse  
  LEFT = 0x01
  RIGHT = 0x02

  def self.init(sprite = nil)
#   $HookStart.call($Window_HWND)
    $ShowCursor.call(0)
   
    @show_cursor = false
   
    @mouse_sprite = Sprite.new
    @mouse_sprite.z = 99999
    @mouse_sprite.bitmap = Bitmap.new('Graphics/Mouse/鼠标.png')
    #@mouse_sprite.bitmap.fill_rect(Rect.new(0, 0, 32, 32), Color.new(0, 0, 0))

    @left_press = false
    @right_press = false
    @left_trigger = false
    @right_trigger = false
    @left_repeat = false
    @right_repeat = false
    @click_lock = false
   
    update
  end
  def self.exit
    @mouse_sprite.bitmap.dispose
    @mouse_sprite.dispose
    @show_cursor = true
#    $HookEnd.call
    $ShowCursor.call(1)
  end
  def self.mouse_debug
    return @mouse_debug.bitmap
  end
  def self.update
    left_down = $GetKeyState.call(0x01)
    right_down = $GetKeyState.call(0x02)
   
    @click_lock = false
    mouse_x, mouse_y = self.get_mouse_pos
    if @mouse_sprite != nil
      @mouse_sprite.x = mouse_x
      @mouse_sprite.y = mouse_y
    end
    if left_down[7] == 1
      @left_repeat = (not @left_repeat)
      @left_trigger = (not @left_press)
      @left_press = true
    else
      @left_press = false
      @left_trigger = false
      @left_repeat = false
    end
    if right_down[7] == 1
      @right_repeat = (not @right_repeat)
      @right_trigger = (not @right_press)
      @right_press = true
    else
      @right_press = false
      @right_trigger = false
      @right_repeat = false
    end
  end
  def self.get_mouse_pos
    point_var = [0, 0].pack('ll')
    if $GetCursorPos.call(point_var) != 0
      if $ScreenToClient.call($Window_HWND, point_var) != 0
        x, y = point_var.unpack('ll')
        if (x < 0) or (x > 10000) then x = 0 end
        if (y < 0) or (y > 10000) then y = 0 end
        if x > 640 then x = 640 end
        if y > 480 then y = 480 end
        return x, y
      else
        return 0, 0
      end
    else
      return 0, 0
    end
  end
  def self.press?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
        return false
      else
        return @left_press
      end
    elsif mouse_code == RIGHT
      return @right_press
    else
      return false
    end
  end
  def self.trigger?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
        return false
      else
        return @left_trigger
      end
    elsif mouse_code == RIGHT
      return @right_trigger
    else
      return false
    end
  end
  def self.repeat?(mouse_code)
    if mouse_code == LEFT
      if @click_lock
        return false
      else
        return @left_repeat
      end
    elsif mouse_code == RIGHT
      return @right_repeat
    else
      return false
    end
  end
  def self.click_lock?
    return @click_lock
  end
  def self.click_lock
    @click_lock = true
  end
  def self.click_unlock
    @click_lock = false
  end
end
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

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
        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
        
          top_x += self.x_mod
          top_y += self.y_mod
          bottom_x += self.x_mod
          bottom_y += self.y_mod
        
        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
            $data_system.sounds[0].play
          end
          break
        end
      end
    if Input.trigger?(Input::F9)
    p top_x,top_y,Mouse.get_mouse_pos
    end
      if mouse_not_in_rect
        @index = index_var
        update_cursor
        Mouse.click_lock
      else
        Mouse.click_unlock               
      end
    end
  end
end




class Window_NameInput
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    #self.cursor_rect.empty
    self_update
    if self.active
      index_var = @index
      mouse_x, mouse_y = Mouse.get_mouse_pos
      mouse_not_in_rect = true
      for i in (0...HIRAGANA.size).to_a.push(180)
        @index = i
        update_cursor
        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
          break
        end
      end
      if mouse_not_in_rect
        @index = index_var
        update_cursor
        Mouse.click_lock
      else
        Mouse.click_unlock
      end
    end
  end
end
=begin

class Window_InputNumber
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    #self.cursor_rect.empty
    self_update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if self.active and @digits_max > 0
      index_var = @index
      mouse_not_in_rect = true
      for i in 0...@digits_max
        @index = i
        #update_cursor
        top_x = self.cursor_rect.x + self.x + 16
        bottom_x = top_x + self.cursor_rect.width
        #
        if (mouse_x > top_x) and (mouse_x < bottom_x)
          mouse_not_in_rect = false
          break
        end
      end
      if mouse_not_in_rect
        @index = index_var
        #update_cursor
        Mouse.click_lock
      else
        Mouse.click_unlock
      end
    end
    if @last_mouse_y == nil
      @last_mouse_y = mouse_y
    end
    check_pos = (@last_mouse_y - mouse_y).abs
    if check_pos > 10
      #$game_system.se_play($data_system.cursor_se)
      place = 10 ** (@digits_max - 1 - @index)
      n = @Number / place % 10
      @number -= n * place
      n = (n + 1) % 10 if mouse_y < @last_mouse_y
      n = (n + 9) % 10 if mouse_y > @last_mouse_y
      @number += n * place
      refresh
      @last_mouse_y = mouse_y
    end
  end
end
=end
class Scene_File
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    Mouse.click_lock
    idx = 0
    for i in @savefile_windows      
      top_x = i.x + 16
      top_y = i.y + 16
      bottom_x = top_x + i.width
      bottom_y = top_y + i.height
      if (mouse_x > top_x) and (mouse_y > top_y) and
         (mouse_x < bottom_x) and (mouse_y < bottom_y)
        i.selected = true
        if @file_index != idx
          @file_index = idx
          $data_system.sounds[0].play
        end            
        Mouse.click_unlock
      else
        i.selected = false
      end
      idx += 1
    end
    self_update
  end
end

class Game_Player
  if @self_alias == nil
    alias self_update update
    @self_alias = true
  end
  def update
    mouse_x, mouse_y = Mouse.get_mouse_pos
    if @last_move_x == nil
      @last_move_x = false
    end
    if $game_switches[123]
     if Mouse.press?(Mouse::LEFT)
       for event in $game_map.events.values
         if event.screen_x/32 == mouse_x/32 and event.screen_y/32-1 == mouse_y/32
           event.start
         end
       end
     end
     self_update
     return
   end
    if Mouse.press?(Mouse::LEFT)
   #for event in $game_map.events.values
   #if event.screen_x/32 == mouse_x/32 and event.screen_y/32-1 == mouse_y/32
   #event.start
   #end
   #end
      last_moving = moving?
      last_direction = @direction
    #  return unless movable?
    #  return if $game_map.interpreter.running?
      unless moving? or $game_map.interpreter.running?
      last_x = @x
        if @last_move_x
          @last_move_x = false
        elsif mouse_x > screen_x + 16
          move_right
        elsif mouse_x < screen_x - 16
          move_left
        end
        last_y = @y
        if last_x != @x
          @last_move_x = true
        elsif mouse_y > screen_y
          move_down
        elsif mouse_y < screen_y - 32
          move_up
        end
=begin        
        if last_y != @y
          @last_move_x = false
        elsif not @last_move_x
          case last_direction
          when 2
            turn_down
          when 4
            turn_left
          when 6
            turn_right
          when 8
            turn_up
          end        
        end
=end         
      end
    end
    self_update
  end
end
Mouse.init
END { Mouse.exit }


class Window_Base < Window
  attr_accessor :x_mod
  attr_accessor :y_mod
  alias ka_initialize initialize
  def initialize(x, y, width, height)
    ka_initialize(x, y, width, height)
    self.x_mod = 0
    self.y_mod = 0
  end
end
class Window_PartyCommand < Window_Command
  alias ka1_initialize initialize
  def initialize
    ka1_initialize
    self.y_mod = 288
  end
end
class Window_ActorCommand < Window_Command
  alias ka2_initialize initialize
  def initialize
    ka2_initialize
    self.x_mod = -128
    self.y_mod = 288
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================

Lv1.梦旅人

梦石
0
星屑
50
在线时间
5 小时
注册时间
2012-12-15
帖子
6
2
 楼主| 发表于 2013-1-17 22:09:56 | 只看该作者
点开存档后就说 for i in @savefile_windows 这行有错误
回复 支持 反对

使用道具 举报

Lv4.逐梦者

送快递的水表员

梦石
10
星屑
4792
在线时间
3303 小时
注册时间
2012-6-27
帖子
7160

开拓者贵宾

3
发表于 2013-1-18 12:01:59 | 只看该作者
我测试的时候没有任何问题
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
5 小时
注册时间
2012-12-15
帖子
6
4
 楼主| 发表于 2013-1-18 12:47:26 | 只看该作者
不知道 我用不了
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
40 小时
注册时间
2013-1-28
帖子
9
5
发表于 2013-2-4 22:33:25 | 只看该作者
Password 发表于 2013-1-18 12:01
我测试的时候没有任何问题

我前两天用也发现了。原版是没问题的,但是用癫狂侠客的DKRM 修改了savefile 导致已经没有 i 了,下边这就不行了。
RUBY 代码复制
  1. for i in  @savefile_windows  
  2.      top_x = i.x + 16
  3.      top_y = i.y + 16
  4.      bottom_x = top_x + i.width
  5.       bottom_y = top_y + i.height


新手,不会改,弄了下不行{:2_254:}  我这水平也就能发现这么多了

评分

参与人数 1星屑 -20 收起 理由
咕噜 -20 挖坟

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1373
在线时间
206 小时
注册时间
2013-2-3
帖子
629
6
发表于 2013-2-5 20:53:52 | 只看该作者
鼠标系统不错,没有BUG
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-9 05:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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