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

Project1

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

[已经解决] VA鼠标系统和名字输入处理冲突怎么办

[复制链接]

Lv1.梦旅人

梦石
0
星屑
82
在线时间
77 小时
注册时间
2011-10-23
帖子
37
跳转到指定楼层
1
 楼主| 发表于 2013-2-15 12:39:19 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
鼠标系统是从6R上的VA超级脚本整合里面要的  结果在开章设置名字输入处理 就出现....

未命名.jpg (7.49 KB, 下载次数: 25)

未命名.jpg

Lv3.寻梦者

梦石
0
星屑
3841
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2013-2-15 12:52:15 | 只看该作者
翻译:系统安插错误
            安插的层次太深
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
82
在线时间
77 小时
注册时间
2011-10-23
帖子
37
3
 楼主| 发表于 2013-2-15 14:04:22 | 只看该作者
紫英晓狼1130 发表于 2013-2-15 12:52
翻译:系统安插错误
            安插的层次太深

0.0那怎么办把
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
82
在线时间
77 小时
注册时间
2011-10-23
帖子
37
4
 楼主| 发表于 2013-2-15 15:10:22 | 只看该作者
顶一下求帮助啊
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
21957
在线时间
8567 小时
注册时间
2011-12-31
帖子
3362
5
发表于 2013-2-15 16:56:27 | 只看该作者
本帖最后由 tseyik 于 2013-2-16 14:03 编辑

換其他鼠標系統

  1. #===========================================================================#
  2. #  #*****************#                                                      #
  3. #  #*** By Falcao ***#         滑鼠系統按鈕 2.0                     #
  4. #  #*****************#         這是一個基於按鈕滑鼠腳本   #
  5. #                              允許創建地圖螢幕或地圖按鈕  #
  6. #                              在遊戲玩法內提供充分的全滑鼠互動  #
  7. #       RMVXACE                      #
  8. #                                                                           #
  9. #                                                                           #
  10. # Falcao RGSS site:  http://falcaorgss.wordpress.com                        #
  11. # Falcao Forum site: http://makerpalace.com                                 #
  12. #                                                                           #
  13. #===========================================================================#

  14. # * Version 2.0 change log (Date: January 13 2013)

  15. # - Added path finding, now the game player is able to move using the mouse
  16. # - Added compatibility with Victor Animated Battle version 1.x and above
  17. # - Now you are able to change the mouse cursor icon in game
  18. # - Two new notetags added to change the mouse cursor by event comment tags
  19. # - Fixed crash when pointing a notetagged event with a valid condition
  20. #----------------------------------------------------------------------------
  21. # * Version 1.6 change log (Date: November 21 2012)
  22. #
  23. # - Added compatibility for any game screen resolution
  24. # - System optimized to consume less cpu than before
  25. # - Added extra compatibility for Pearl ABS Liquid
  26. # - Removed the font fix
  27. # - Added the imported bolean
  28. #----------------------------------------------------------------------------
  29. # * Version 1.5 change log
  30. #
  31. # - Fixed cursor sound over loading on selectable windows
  32. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  33. # - FIxed minor bug when transfering (event name now erase completely)
  34. # - Added option to turn on / off arrow selector on save file
  35. # - Important! changes on mouse comment tags!
  36. #   ~ CLICK START change to MOUSE START
  37. #   ~ ANIMATION   change to MOUSE ANIMATION
  38. #   ~ NAME        change to MOUSE NAME
  39. #
  40. #---------------------------------------------------------------------------
  41. # * 安裝
  42. #
  43. # 複製和粘貼此腳本於main前面 !
  44. #
  45. # * 滑鼠按鍵
  46. #   -按下滑鼠左鍵:     動作按鈕
  47. #   -按下滑鼠右鍵:    取消按鈕,關閉視窗
  48. #   - 按下滑鼠滾輪/中間按鈕:   DASH
  49. #按下滑鼠左鍵
  50. #---------------------------------------------------------------------------
  51. # * 主要功能
  52. #
  53. # - 允許創建按鈕,並為它們指定工作
  54. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  55. # -顯示事件的名稱
  56. # - 全滑鼠互動
  57. # - 可選WASD 移動
  58. # - 滑鼠自動尋路功能
  59. # - 可在遊戲中啟用改變鼠標光標
  60. #---------------------------------------------------------------------------
  61. # * 事件按鈕命令
  62. #
  63. # Write this lines on event comments tags
  64. #
  65. # MOUSE START       - 單擊事件時開始事件
  66. # MOUSE ANIMATION x - 鼠標在事件上時顯示動畫效果
  67. #                     例: MOUSE ANIMATION 1
  68. # MOUSE NAME x      - 鼠標在事件上時顯示事件名稱,
  69. #                     例: MOUSE NAME Falcao
  70. # MOUSE ICON x      - 鼠標在事件上時改變鼠標光標的圖標
  71. #                     x : 圖標索引
  72. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  73. #                     case it display a picture graphic name, change x for the
  74. #                     picture name
  75. #------------------------------------------------------------------------------
  76. # * Script calls
  77. #
  78. # 調用此行來打開/關閉鼠標光標 true/false
  79. # Mouse.show_cursor(false)
  80. #
  81. # 如果您要手動更改滑鼠游標使用下面的腳本調用
  82. # Mouse.set_cursor(:iconset, x)     - X是圖標的索引
  83. #
  84. #  如果您想要顯示圖片 iconset 使用下面的腳本調用
  85. # Mouse.set_cursor(:picture, name)  -  name 更改成圖片名稱
  86. #-----------------------------------------------------------------------------

  87. module Map_Buttons

  88. # 很容易在地圖畫面上増加許多按鈕
  89. # 下方是按鈕定義的參數
  90.   
  91.   Insert = {
  92. #-----------------------------------------------------------------------------
  93. #  A => [B, C, D, E, F]
  94. #  
  95. #  A = 按鈕號碼
  96. #
  97. #  B = 命名
  98. #  C = X 在屏幕位置(以字符為單位)
  99. #  D = Y 在屏幕位置(以字符為單位)
  100. #  E = 圖標,寫入圖片圖片'名'或圖標索引
  101. #  F = 這按鈕做什麼?有兩個選項, 呼叫場景或呼叫公共事件,
  102. # 如果你想要場景則寫入場景名稱,
  103. # 公共事件 則寫入公共事件ID
  104.   
  105.   # 按鈕調用菜單畫面(場景用法例子)
  106.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  107.   
  108.   # 按鈕調用事件 ID 1(事件用法例子)
  109.   2=>  ["Bestiary",  16, 12, 121, 1],
  110.   
  111.   

  112.   }

  113. # * General configutration

  114. # 鼠標光標的圖標,圖標索引如果想要圖片寫入圖片的名字
  115.   CursorIcon = 386

  116. # 切換ID:在屏幕上顕示圖標 打開/關閉
  117.   Switch = 100
  118.   
  119. # 允許使用W A S D鍵移動 true/false
  120.   WASD_Movement = true
  121.   
  122. # 顯示箭頭選擇保存文件? true / false
  123.   DisplaySelector = false
  124.   
  125. # 當你點擊事件,讓玩家忽略該自我的的移動嗎?
  126.   IgnoreEventPath = true
  127.   
  128. # 尋路開關ID:啟用或禁用尋路功能
  129.   PathFinderSwitch = 500
  130. #
  131. #----------------------------------------------------------------------------
  132. #
  133. # * License
  134. #
  135. # 可以在非商業遊戲中使用此腳本,
  136. # 商業遊戲則要通知我(作者). [email protected]
  137. #-----------------------------------------------------------------------------

  138.   def self.check_value(value)
  139.     return 'numeric' if value.is_a? Fixnum
  140.     return 'string'
  141.   end
  142. end

  143. ($imported ||= {})[:Mouse_System_Buttons] = 2.0

  144. # 這個類創建的所有屏幕遊戲畫面上的按鈕和事
  145. class Interactive_Buttoms
  146.   attr_reader :cursoring
  147.   def initialize
  148.     create_screen_buttoms
  149.     @ani_delay = 0
  150.   end
  151.   
  152.   def create_screen_buttoms
  153.     if $imported["Falcao Pearl ABS Liquid"]
  154.       if PearlKernel::clean_back?
  155.         @buttons_sprites = []
  156.         return
  157.       end
  158.     end
  159.     @buttons_sprites = []
  160.     for i in Map_Buttons::Insert.values
  161.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  162.     end
  163.   end
  164.   
  165.   def create_button_text
  166.     if @button_text.nil?
  167.       @button_text = Sprite.new
  168.       @button_text.bitmap = Bitmap.new(100, 32)
  169.       @button_text.z = 50
  170.       @button_text.bitmap.font.size = 16
  171.     end
  172.   end
  173.   
  174.   def dispose_screen_buttons
  175.     for button in @buttons_sprites
  176.       button.dispose
  177.     end
  178.     @buttons_sprites = []
  179.   end
  180.   
  181.   def dispose_button_text
  182.     if not @button_text.nil?
  183.       @button_text.dispose
  184.       @button_text.bitmap.dispose
  185.       @button_text = nil
  186.     end
  187.   end
  188.   
  189.   def dispose
  190.     dispose_screen_buttons
  191.     dispose_button_text
  192.   end
  193.   
  194.   def update
  195.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  196.       dispose_screen_buttons
  197.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  198.       create_screen_buttoms
  199.     end
  200.     update_buttons
  201.     update_event_selection
  202.   end
  203.   
  204.   # 路徑更新
  205.   def update_path
  206.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  207.     return if $game_message.busy?
  208.     return unless $game_player.normal_walk?
  209.     mx, my = Mouse.map_grid[0], Mouse.map_grid[1]
  210.     if Map_Buttons::IgnoreEventPath
  211.       $game_map.events.values.each do |event|
  212.         return if event.x == mx and event.y == my
  213.       end
  214.     end
  215.     $game_player.find_path(mx, my)
  216.   end
  217.   
  218.   def update_buttons
  219.     for button in @buttons_sprites
  220.       button.update
  221.       if button.zooming
  222.         @screen_b = true
  223.         create_button_text
  224.         if button.x > 272
  225.           x, y = button.px * 32 - 98, button.py * 32
  226.           draw_button_text(x, y, button.name, 2)
  227.         elsif button.x < 272
  228.           x, y = button.px * 32 + 31, button.py * 32
  229.           draw_button_text(x, y, button.name, 0)
  230.         end
  231.       end
  232.     end
  233.    
  234.     if @screen_b != nil
  235.       unless mouse_over_button?
  236.         dispose_button_text
  237.         @screen_b = nil
  238.       end
  239.     end
  240.   end
  241.   
  242.   def reset_cursor
  243.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  244.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  245.     else
  246.       Mouse.set_cursor(:picture, @cursoring[1], true)
  247.     end
  248.     @cursoring = nil
  249.   end
  250.   
  251.   def apply_iconchanging(sym, operand, event)
  252.     cursor = $game_system.cursorr
  253.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  254.     @cursoring = [event, cursor]
  255.     Mouse.set_cursor(sym, operand, true)
  256.   end
  257.   
  258.   def update_event_selection
  259.     return if @screen_b #disable event buttom if mouse over screen buttom
  260.     update_path if Mouse.trigger?(0)
  261.     for event in $game_map.events.values
  262.       next if event.page.nil?
  263.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  264.         if event.mouse_start
  265.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  266.             event.start
  267.           end
  268.         end
  269.         anime = event.mouse_animation
  270.         if anime != 0
  271.           @ani_delay += 1
  272.           event.animation_id = anime if @ani_delay == 1
  273.           @ani_delay = 0 if @ani_delay > 16
  274.         end
  275.         name = event.mouse_name
  276.         if name != ""
  277.           [url=home.php?mod=space&uid=94943]@Eve[/url] = [event.x, event.y, event, name]
  278.           create_button_text
  279.         end
  280.         icon = event.mouse_iconset
  281.         picture = event.mouse_picture
  282.         if !icon.nil? and icon != 0 and @cursoring.nil?
  283.           apply_iconchanging(:iconset, icon, event)
  284.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  285.           apply_iconchanging(:picture, picture, event)
  286.         end
  287.       end
  288.     end
  289.    
  290.     if @cursoring != nil
  291.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  292.     end
  293.    
  294.     if @eve != nil
  295.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  296.       if event_oy > 32
  297.         draw_button_text(@eve[2].screen_x - 49,
  298.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  299.       else
  300.         draw_button_text(@eve[2].screen_x - 49,
  301.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  302.       end
  303.       if not mouse_over_event?(@eve[0], @eve[1])
  304.         dispose_button_text
  305.         @eve = nil
  306.       end
  307.     end
  308.   end
  309.   
  310.   def draw_button_text(x, y, text, a=0)
  311.     return if @button_text.nil?
  312.     @button_text.x = x
  313.     @button_text.y = y
  314.     return if @old_name == text
  315.     @button_text.bitmap.clear
  316.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  317.     @old_name = text
  318.   end
  319.   
  320.   def mouse_over_button?
  321.     for button in @buttons_sprites
  322.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  323.         return true
  324.       end
  325.     end
  326.     @old_name = nil
  327.     return false
  328.   end
  329.   
  330.   def mouse_over_event?(event_x, event_y)
  331.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  332.       return true
  333.     end
  334.     @old_name = nil
  335.     return false
  336.   end
  337. end

  338. # 設置按鍵 sprites
  339. class Spriteset_Map
  340.   alias falcao_insert_buttuns_view create_viewports
  341.   def create_viewports
  342.     @interact_buttoms = Interactive_Buttoms.new
  343.     falcao_insert_buttuns_view
  344.   end
  345.   
  346.   alias falcao_insert_buttuns_dis dispose
  347.   def dispose
  348.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  349.     @interact_buttoms.dispose
  350.     falcao_insert_buttuns_dis
  351.   end
  352.   
  353.   alias falcao_insert_buttuns_up update
  354.   def update
  355.     if $game_player.clear_mousepointers
  356.       @interact_buttoms.dispose
  357.       $game_player.clear_mousepointers = nil
  358.     end
  359.     @interact_buttoms.update
  360.     falcao_insert_buttuns_up
  361.   end
  362. end

  363. # 註釋定義
  364. class Game_Event < Game_Character
  365.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  366.   attr_reader   :mouse_picture, :page
  367.   alias falcaomouse_setup setup_page_settings
  368.   def setup_page_settings
  369.     falcaomouse_setup
  370.     @mouse_start     = check_comment("MOUSE START")
  371.     @mouse_animation = check_value("MOUSE ANIMATION")
  372.     @mouse_name      = check_name("MOUSE NAME")
  373.     @mouse_iconset   = check_value("MOUSE ICON")
  374.     @mouse_picture   = check_name("MOUSE PIC")
  375.   end

  376.   def check_comment(comment)
  377.     return false if @list.nil? or @list.size <= 0
  378.     for item in @list
  379.       if item.code == 108 or item.code == 408
  380.         if item.parameters[0].include?(comment)
  381.           return true
  382.         end
  383.       end
  384.     end
  385.     return false
  386.   end
  387.   
  388.   def check_value(comment)
  389.     return 0 if @list.nil? or @list.size <= 0
  390.     for item in @list
  391.       if item.code == 108 or item.code == 408
  392.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  393.           return $1.to_i
  394.         end
  395.       end
  396.     end
  397.     return 0
  398.   end
  399.   
  400.   def check_name(comment)
  401.     return "" if @list.nil? or @list.size <= 0
  402.     for item in @list
  403.       next unless item.code == 108 or item.code == 408
  404.       if item.parameters[0] =~ /#{comment} (.*)/
  405.         return $1.to_s
  406.       end
  407.     end
  408.     return ""
  409.   end
  410. end

  411. # 創建屏幕上的按鈕 sprites
  412. class Sprite_Buttons < Sprite
  413.   attr_reader   :px
  414.   attr_reader   :py
  415.   attr_reader   :name
  416.   attr_reader   :zooming
  417.   def initialize(name, px, py, icon_index, action=nil)
  418.     super()
  419.     self.z = 50
  420.     @icon_index = icon_index
  421.     @px = px
  422.     @py = py
  423.     @action = action
  424.     @object_zooming = 0
  425.     @zooming = false
  426.     @name = name
  427.     set_bitmap
  428.     update
  429.   end
  430.   
  431.   def update
  432.     super
  433.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  434.       self.bitmap.height)
  435.       @zooming = true
  436.       @object_zooming += 1
  437.       case @object_zooming
  438.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  439.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  440.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  441.         @object_zooming = 0
  442.       end
  443.       if Mouse.trigger?(0) and @action != nil
  444.         unless $game_map.interpreter.running?
  445.           Sound.play_ok
  446.           if @action == Scene_Menu and not $game_system.menu_disabled
  447.             SceneManager.call(@action)
  448.             Window_MenuCommand::init_command_position
  449.             return
  450.           end
  451.          if Map_Buttons::check_value(@action) == 'numeric'
  452.            $game_temp.reserve_common_event(@action)
  453.          else
  454.            SceneManager.call(@action)
  455.          end
  456.         end
  457.       end
  458.     elsif @object_zooming > 0
  459.       self.zoom_x = 1.0
  460.       self.zoom_y = 1.0
  461.       @object_zooming = 0
  462.     else
  463.       @zooming = false
  464.     end
  465.   end
  466.   
  467.   def set_bitmap
  468.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  469.       self.bitmap = Bitmap.new(24, 24)
  470.       bitmap = Cache.system("Iconset")
  471.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  472.       self.bitmap.blt(0, 0, bitmap, rect)
  473.     else
  474.       self.bitmap = Cache.picture(@icon_index)
  475.     end
  476.     self.x = @px * 32 + 4
  477.     self.y = @py * 32 + 4
  478.   end
  479. end

  480. # Game_character 新的變量
  481. class Game_CharacterBase
  482.   attr_accessor :ch_oy
  483. end

  484. # Sprite character
  485. class Sprite_Character < Sprite_Base
  486.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  487.   def set_character_bitmap
  488.     falcaoadd_oxy_set_character_bitmap
  489.     @character.ch_oy = self.oy
  490.   end
  491. end

  492. class Game_System
  493.   attr_accessor :current_cursor
  494.   def cursorr
  495.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  496.     return @current_cursor
  497.   end
  498. end

  499. # 鼠標模組
  500. module Mouse
  501.   
  502.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  503.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  504.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  505.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  506.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  507.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  508.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  509.   %w(p p p p l p), 'l')
  510.                               
  511.   ShowCursor.call(0)
  512.   
  513.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  514.   @old_pos      =   0

  515.   # 鼠標 Sprite
  516.   
  517.   def self.set_cursor(sym, operand, write=false)
  518.     case sym
  519.     when :iconset
  520.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  521.       bitmap = Cache.system("Iconset")
  522.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  523.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  524.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  525.     end
  526.     $game_system.current_cursor = operand if write
  527.   end
  528.   
  529.   $mouse_cursor = Sprite.new
  530.   icon = Map_Buttons::CursorIcon
  531.   if Map_Buttons::check_value(icon) == 'numeric'
  532.     set_cursor(:iconset, icon)
  533.   else
  534.     set_cursor(:picture, icon)
  535.   end
  536.   $mouse_cursor.z = 10001
  537.   $mouse_cursor.x = $mouse_cursor.y = 1000
  538.   $mouse_cursor.ox = 4
  539.   
  540.   def self.show_cursor(value)
  541.     unless value
  542.       @pos[0] = @pos[1] = 600
  543.     end
  544.     $mouse_cursor.visible = value
  545.   end
  546.   
  547.   def self.map_grid
  548.     return nil if @pos == nil
  549.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  550.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  551.     return [x, y]
  552.   end
  553.   
  554.   def self.standing?
  555.     return false if @old_px != @pos[0]
  556.     return false if @old_py != @pos[1]
  557.     return true
  558.   end
  559.   
  560.   def self.input_keys
  561.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  562.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  563.     return keys
  564.   end
  565.   
  566.   def self.object_area?(x, y, width, height)
  567.     return false if @pos.nil?
  568.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  569.   end
  570.   
  571.   def self.position
  572.     return @pos == nil ? [0, 0] : @pos
  573.   end
  574.   
  575.   def self.global_pos
  576.     pos = [0, 0].pack('ll')
  577.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  578.   end

  579.   def self.screen_to_client(x=0, y=0)
  580.     pos = [x, y].pack('ll')
  581.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  582.   end  

  583.   def self.pos
  584.     global_pos = [0, 0].pack('ll')   
  585.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  586.     local_pos = [gx, gy].pack('ll')
  587.     x, y = ScreenToClient.call(self.hwnd,
  588.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  589.     begin
  590.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  591.         @old_px, @old_py = x, y
  592.         return x, y
  593.       else
  594.         return -20, -20
  595.       end
  596.     rescue
  597.       return 0, 0
  598.     end
  599.   end  
  600.    
  601.   def self.update
  602.     old_pos = @pos
  603.     @pos = self.pos
  604.     self.input_keys
  605.     if !$mouse_cursor.visible && old_pos != @pos
  606.       $mouse_cursor.visible = true
  607.     end
  608.     if old_pos != [-20, -20] && @pos == [-20, -20]
  609.       ShowCursor.call(1)
  610.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  611.        ShowCursor.call(0)
  612.     end
  613.     for i in @triggers
  614.       n = GetKeyState.call(i[1])
  615.       if [0, 1].include?(n)
  616.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  617.       else
  618.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  619.       end
  620.     end
  621.   end
  622.   
  623.   # trigger 定義
  624.   def self.trigger?(id = 0)
  625.     pos = self.pos
  626.     if pos != [-20,-20]
  627.     case id
  628.       when 0  
  629.         return @triggers[id][0] == 1
  630.       when 1  
  631.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  632.           return @triggers[id][0] == 1
  633.         end
  634.       when 2
  635.         return @triggers[id][0] == 1
  636.       end   
  637.     end
  638.   end
  639.   
  640.   # repeat 定義
  641.   def self.repeat?(id = 0)
  642.     if @triggers[id][0] <= 0
  643.       return false
  644.     else
  645.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  646.     end
  647.   end
  648.   
  649.   #按下定義
  650.   def self.press?(id = 0)
  651.     if @triggers[id][0] <= 0
  652.       return false
  653.     else
  654.       return true
  655.     end
  656.   end
  657.   
  658.   def self.screen_to_client(x=0, y=0)
  659.     pos = [x, y].pack('ll')
  660.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  661.   end

  662.   def self.hwnd
  663.     if @hwnd.nil?
  664.       game_name = "\0" * 256
  665.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  666.       game_name.delete!("\0")
  667.       @hwnd = Findwindow.call('RGSS Player', game_name)
  668.     end
  669.     return @hwnd
  670.   end
  671.   
  672.   def self.client_size
  673.     rect = [0, 0, 0, 0].pack('l4')
  674.     GetClientRect.call(self.hwnd, rect)
  675.     right, bottom = rect.unpack('l4')[2..3]
  676.     return right, bottom
  677.   end
  678. end

  679. # 輸入模塊混疊
  680. class << Input
  681.   unless self.method_defined?(:falcao21_mouse_update)
  682.     alias_method :falcao21_mouse_update,   :update
  683.     alias_method :falcao21_mouse_trigger?, :trigger?
  684.     alias_method :falcao21_mouse_repeat?,  :repeat?
  685.     alias_method :fal_mouse_input_press?,  :press?
  686.   end
  687.   
  688.   def update
  689.     if $mouse_cursor.visible
  690.       Mouse.update
  691.       $game_arrows.update
  692.       mx, my = *Mouse.position
  693.       $mouse_cursor.x = mx unless mx.nil?
  694.       $mouse_cursor.y = my unless my.nil?   
  695.     end
  696.     falcao21_mouse_update
  697.   end
  698.   
  699.   # trigger
  700.   def trigger?(constant)
  701.     return true if falcao21_mouse_trigger?(constant)
  702.     unless Mouse.pos.nil?
  703.       if Mouse.input_keys.has_value?(constant)
  704.         mouse_trigger = Mouse.input_keys.index(constant)
  705.         return true if Mouse.trigger?(mouse_trigger)
  706.       end
  707.     end
  708.     return false
  709.   end

  710.   # 按下
  711.   def press?(constant)
  712.     return true if fal_mouse_input_press?(constant)
  713.     unless Mouse.pos.nil?
  714.       if Mouse.input_keys.has_value?(constant)
  715.         mouse_trigger = Mouse.input_keys.index(constant)
  716.         return true if Mouse.press?(mouse_trigger)      
  717.       end
  718.     end
  719.     return false
  720.   end
  721.   
  722.   # repeat
  723.   def repeat?(constant)
  724.     return true if falcao21_mouse_repeat?(constant)
  725.     unless Mouse.pos.nil?
  726.       if Mouse.input_keys.has_value?(constant)
  727.         mouse_trigger = Mouse.input_keys.index(constant)     
  728.         return true if Mouse.repeat?(mouse_trigger)
  729.       end
  730.     end
  731.     return false
  732.   end
  733. end

  734. # Here your best friend, 你可以在遊戲中,場景等調用這個腳本.
  735. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  736. class Game_Arrow_Selector
  737.   attr_accessor :mode_on
  738.   attr_accessor :in_type
  739.   def initialize
  740.     @mode_on = false
  741.   end

  742.   def create_arrows(x, y)
  743.     return unless @arrows_sprites.nil?
  744.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  745.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  746.     @arrows_sprites = []
  747.     for i in buttons.values
  748.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  749.     end
  750.   end
  751.   
  752.   def dispose
  753.     return if @arrows_sprites.nil?
  754.     for arrow in @arrows_sprites
  755.       arrow.dispose
  756.     end
  757.     @arrows_sprites = nil
  758.     @mode_on = false
  759.   end
  760.   
  761.   def update
  762.     return if @arrows_sprites.nil?
  763.     for arrow in @arrows_sprites
  764.       arrow.update
  765.     end
  766.   end
  767. end

  768. class Garrows_Sprites < Sprite
  769.   def initialize(name, x, y)
  770.     super()
  771.     self.z = 1000
  772.     @px, @py = x, y
  773.     @name = name
  774.     @object_zooming = 0
  775.     @zooming = false
  776.     set_bitmap
  777.     update
  778.   end
  779.   
  780.   def update
  781.     super
  782.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  783.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  784.       $game_arrows.mode_on = true
  785.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  786.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  787.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  788.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  789.       $game_arrows.in_type = Input::C     if @name == 'OK'
  790.       $game_arrows.in_type = Input::B     if @name == 'Cancel'
  791.       @object_zooming += 1
  792.       @zooming = true
  793.       case @object_zooming
  794.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  795.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  796.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  797.         @object_zooming = 0
  798.       end
  799.     elsif @object_zooming > 0
  800.       self.zoom_x = 1.0
  801.       self.zoom_y = 1.0
  802.       @object_zooming = 0
  803.     elsif @zooming
  804.       @zooming = false
  805.       $game_arrows.mode_on = false
  806.     end
  807.   end
  808.   
  809.   def set_bitmap
  810.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  811.     case @name
  812.     when 'UP'
  813.       self.x = @px + 25 ; self.y = @py - 2
  814.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  815.     when 'DOWN'
  816.       self.x = @px + 1 ; self.y = @py + 26
  817.       @fix = [0, -4, 0,  0]
  818.     when 'LEFT'
  819.       self.x = @px      ; self.y = @py + 1
  820.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  821.     when 'RIGHT'
  822.       self.x = @px + 26  ; self.y = @py + 26
  823.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  824.     when 'OK'
  825.       self.x = @px + 1  ; self.y = @py + 6
  826.       @fix = [0, -4, 0,  0]
  827.       self.bitmap.font.size = 20
  828.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  829.       return
  830.     when 'Cancel'
  831.       self.x = @px - 11  ; self.y = @py + 42
  832.       @fix = [0, -4, 0,  0]
  833.       self.bitmap = Bitmap.new(50, 15)
  834.       self.bitmap.font.size = 20
  835.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  836.       return
  837.     end
  838.     draw_crappy_triangle(0, 0)
  839.   end
  840.   
  841.   # This method create a crappy triangle pointing down
  842.   def draw_crappy_triangle(px, py)
  843.     color = Color.new(192, 224, 255, 255)
  844.     x, y, w, =  0, 4, 24
  845.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  846.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  847.     for i in 1..10
  848.       x += 1; y += 1; w -= 2
  849.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  850.     end
  851.   end
  852. end

  853. $game_arrows = Game_Arrow_Selector.new

  854. # 當輸入的數字
  855. class Game_Interpreter
  856.   alias falcao_setup_num_input setup_num_input
  857.   def setup_num_input(params)
  858.     falcao_setup_num_input(params)
  859.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  860.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  861.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  862.   end
  863. end

  864. # 按OK
  865. class Window_NumberInput < Window_Base
  866.   alias falcao_process_ok process_ok
  867.   def process_ok
  868.     falcao_process_ok
  869.     $game_arrows.dispose
  870.   end
  871. end

  872. # 保存和加載場景
  873. class Scene_File < Scene_MenuBase
  874.   alias falcao47_start start
  875.   alias falcao47_terminate terminate
  876.   
  877.   def start
  878.     falcao47_start
  879.     $game_arrows.create_arrows(210, 166) if Map_Buttons::DisplaySelector
  880.   end
  881.   
  882.   def terminate
  883.     falcao47_terminate
  884.     $game_arrows.dispose if Map_Buttons::DisplaySelector
  885.   end
  886. end

  887. # WASD 移動
  888. module Input
  889.   class << self
  890.     if !method_defined?('vxe_dir4')
  891.       alias vxace_dir4 dir4
  892.     end
  893.     def dir4
  894.       if Map_Buttons::WASD_Movement
  895.         return 2 if (Input.press?(Input::Y))
  896.         return 4 if (Input.press?(Input::X))
  897.         return 6 if (Input.press?(Input::Z))
  898.         return 8 if (Input.press?(Input::R))
  899.       end
  900.       return vxace_dir4
  901.     end
  902.   end
  903. end

  904. # 用鼠標開始事件
  905. class Game_Player < Game_Character
  906.   alias falcao_start_map_event start_map_event
  907.   def start_map_event(x, y, triggers, normal)
  908.     $game_map.events_xy(x, y).each do |event_click|
  909.       return if event_click.check_comment("MOUSE START")
  910.     end  
  911.     falcao_start_map_event(x, y, triggers, normal)
  912.   end
  913. end

  914. # clear pointers when tranfering
  915. class Game_Player < Game_Character
  916.   attr_accessor :clear_mousepointers
  917.   alias falcaomouse_perform_transfer perform_transfer
  918.   def perform_transfer
  919.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  920.     falcaomouse_perform_transfer
  921.   end
  922. end

  923. # Path find
  924. class Game_Character < Game_CharacterBase
  925.   attr_accessor :map, :runpath
  926.   alias pathfind1_ini initialize
  927.   def initialize
  928.     pathfind1_ini
  929.     @map = nil
  930.     @runpath = false
  931.   end
  932.   
  933.   alias pathfind1_up update
  934.   def update
  935.     run_path if @runpath == true
  936.     pathfind1_up
  937.   end
  938.   
  939.   def run_path
  940.     return if moving?
  941.     step = @map[@x,@y]
  942.     if step == 1
  943.       @map = nil
  944.       @runpath = false
  945.       return
  946.     end
  947.     dir = rand(2)
  948.     case dir
  949.     when 0
  950.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  951.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  952.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  953.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  954.     when 1
  955.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  956.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  957.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  958.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  959.     end
  960.   end

  961.   def find_path(x,y)
  962.     sx, sy = @x, @y
  963.     result = setup_map(sx,sy,x,y)
  964.     @runpath = result[0]
  965.     @map = result[1]
  966.     @map[sx,sy] = result[2] if result[2] != nil
  967.   end

  968.   def clear_path
  969.     @map = nil
  970.     @runpath = false
  971.   end
  972.   
  973.   def setup_map(sx,sy,ex,ey)
  974.     map = Table.new($game_map.width, $game_map.height)
  975.     map[ex,ey] = 1
  976.     old_positions = []
  977.     new_positions = []
  978.     old_positions.push([ex, ey])
  979.     depth = 2
  980.     depth.upto(100){|step|
  981.       loop do
  982.         break if old_positions[0] == nil
  983.         x,y = old_positions.shift
  984.         return [true, map, step] if x == sx and y+1 == sy
  985.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  986.           map[x,y + 1] = step
  987.           new_positions.push([x,y + 1])
  988.         end
  989.         return [true, map, step] if x-1 == sx and y == sy
  990.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  991.           map[x - 1,y] = step
  992.           new_positions.push([x - 1,y])
  993.         end
  994.         return [true, map, step] if x+1 == sx and y == sy
  995.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  996.           map[x + 1,y] = step
  997.           new_positions.push([x + 1,y])
  998.         end
  999.         return [true, map, step] if x == sx and y-1 == sy
  1000.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  1001.           map[x,y - 1] = step
  1002.           new_positions.push([x,y - 1])
  1003.         end
  1004.       end
  1005.       old_positions = new_positions
  1006.       new_positions = []
  1007.     }
  1008.     return [false, nil, nil]
  1009.   end
  1010. end
  1011.   
  1012. class Game_Player
  1013.   alias pathfind_player_update update
  1014.   def update
  1015.     clear_path if Input.dir4 != 0
  1016.     pathfind_player_update
  1017.   end
  1018.   
  1019.   alias findpath_perform_transfer perform_transfer
  1020.   def perform_transfer
  1021.     clear_path if $game_map.map_id !=  @new_map_id
  1022.     findpath_perform_transfer
  1023.   end
  1024. end

  1025. # Window selectable (Thanks wora for some lines here)
  1026. class Window_Selectable < Window_Base
  1027.   alias mouse_selection_ini initialize
  1028.   def initialize(*args)
  1029.     mouse_selection_ini(*args)
  1030.     @scroll_wait = 0
  1031.     @cursor_wait = 0
  1032.     @sdelay = 0
  1033.   end

  1034.   alias mouse_selection_update update
  1035.   def update
  1036.     update_mouse_selection if self.active and self.visible
  1037.     @sdelay -= 1 if @sdelay > 0
  1038.     mouse_selection_update
  1039.   end
  1040.   
  1041.   def update_mouse_selection
  1042.     @cursor_wait -= 1 if @cursor_wait > 0
  1043.     (0..self.item_max - 1).each do |i|
  1044.       irect = item_rect(i)
  1045.       irx = self.x + 16 + irect.x - self.ox
  1046.       iry = self.y + 16 + irect.y - self.oy
  1047.       move_cursor(i) if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1048.       update_cursor
  1049.     end
  1050.   end

  1051.   def move_cursor(index)
  1052.     return if @index == index
  1053.     @scroll_wait -= 1 if @scroll_wait > 0
  1054.     row1 = @index / self.col_max
  1055.     row2 = index / self.col_max
  1056.     bottom = self.top_row + (self.page_row_max - 1)
  1057.     if index != @index and @sdelay == 0
  1058.       Sound.play_cursor
  1059.       @sdelay = 5
  1060.     end
  1061.     if row1 == self.top_row and row2 < self.top_row
  1062.       return if @scroll_wait > 0
  1063.       @index = [@index - self.col_max, 0].max
  1064.       @scroll_wait = 30
  1065.     elsif row1 == bottom and row2 > bottom
  1066.       return if @scroll_wait > 0
  1067.       @index = [@index + self.col_max, self.item_max - 1].min
  1068.       @scroll_wait = 30
  1069.     else
  1070.       @index = index
  1071.     end
  1072.     return if @cursor_wait > 0
  1073.     @cursor_wait += 2
  1074.   end
  1075. end

  1076. # Name imput selectable
  1077. class Window_NameInput
  1078.   alias mouse_name_select update unless $@
  1079.   def update(*args, &block)
  1080.     mouse_name_select(*args, &block)
  1081.     if self.active and self.visible
  1082.       (0..self.table[@page].size - 1).each do |i|
  1083.       irect = item_rect(i)
  1084.       irx = self.x + 16 + irect.x - self.ox
  1085.       iry = self.y + 16 + irect.y - self.oy
  1086.       @index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1087.       end
  1088.     end
  1089.   end
  1090. end

  1091. # Window party command
  1092. class Window_PartyCommand < Window_Command
  1093.   def update_mouse_selection
  1094.     (0..self.item_max - 1).each do |i|
  1095.     irect = item_rect(i)
  1096.     irx = self.viewport.ox + 16 + irect.x - self.ox
  1097.     iry = 288 + 16 + irect.y - self.oy
  1098.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1099.     end
  1100.   end
  1101. end

  1102. # Window actor command
  1103. class Window_ActorCommand < Window_Command
  1104.   def update_mouse_selection
  1105.     (0..self.item_max - 1).each do |i|
  1106.     irect = item_rect(i)
  1107.     add = 288
  1108.     add = 156 if !$imported[:ve_animated_battle].nil? &&  
  1109.     $imported[:ve_animated_battle] > 1
  1110.     irx = self.viewport.ox + add + 16 + irect.x
  1111.     iry = 288 + 16 + irect.y
  1112.     self.index = i if Mouse.object_area?(irx, iry, irect.width, irect.height)
  1113.     end
  1114.   end
  1115. end
复制代码

点评

但是有没有动态鼠标系统?  发表于 2014-2-10 17:12
更新翻譯(未完)  发表于 2013-2-16 14:02
谢谢了啊  发表于 2013-2-16 13:36
這鼠標系統名字输入没問題  发表于 2013-2-15 17:01

评分

参与人数 1梦石 +1 收起 理由
Mic_洛洛 + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-3 19:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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