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

Project1

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

和ABS兼容的鼠标脚本与鼠标响应的兼容问题

[复制链接]

Lv3.寻梦者 (版主)

梦石
0
星屑
3105
在线时间
741 小时
注册时间
2015-2-28
帖子
816

开拓者

跳转到指定楼层
1
发表于 2015-3-5 20:47:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 唯道集虚 于 2016-11-20 01:11 编辑

ABS同作者发布了一套鼠标脚本可以在屏幕上显示一些按钮,类似鼠标响应脚本,但把鼠标放上去之后按钮会“晃动”,而不是显示另一个图片,我想让它显示图片却与鼠标响应系统不兼容,求解决方法。

RUBY 代码复制
  1. =begin
  2. ==========================================================================
  3. 鼠标系统按钮2.5
  4. ===========================================================================
  5. 这是一个基于鼠标脚本,让之创造尽可能多的按钮,你要在地图屏幕或地图地,也是游戏中
  6. 为您提供完整的RMVXACE鼠标交互播放
  7. 安装、复制并粘贴上面主这个脚本做鼠标触发
  8. - 左击:动作按钮
  9. - 右键点击:取消按钮,关闭窗口# - 鼠标滚轮中键: DASH
  10. ————————————————————————————————————————
  11. *主要功能
  12. - 允许您创建按钮,并配置它们做一些事情
  13. - 事件可以是按钮也对应地按钮!对于一些难题等等
  14. - 允许您显示事件名称
  15. - 全鼠标交互
  16. - WASD移动可选
  17. - 寻路功能,玩家可以用鼠标
  18. #===========================================================================#
  19. #  #*****************#                                                      #
  20. #  #*** By Falcao ***#         Mouse System Buttons 2.5                     #
  21. #  #*****************#         This is a button based mouse script, allow   #
  22. #                              create as many buttons you want to the map   #
  23. #                              screen or map ground, also provide you full  #
  24. #       RMVXACE                mouse interaction within the game play       #
  25. #                                                                           #
  26. #                                                                           #
  27. # Falcao RGSS site:  [url]http://falcaorgss.wordpress.com[/url]                        #
  28. # Falcao Forum site: [url]http://makerpalace.com[/url]                                 #
  29. #                                                                           #
  30. #===========================================================================#
  31. =end
  32. #----------------------------------------------------------------------------
  33. # * Version 2.5 change log (Date: June 9 2013)
  34. #
  35. # Fixed non-refreshing item description bug
  36. # Fixed Save file selection issue
  37. # Added ability to start events even if the player is no facing the event
  38. # Removed option to display arrow selector on save file
  39. # Added compatibility for multiples game resolutions
  40. # Item selection with mouse is now more occurate
  41. # Fixed issue with pearl skillbar (when clicking any tool perform path finding)
  42. # Cleaned up some code
  43. #
  44. #----------------------------------------------------------------------------
  45. # * Version 2.0 change log (Date: January 13 2013)
  46. #
  47. # - Added path finding, now the game player is able to move using the mouse
  48. # - Now you are able to change the mouse cursor icon in game
  49. # - Two new notetags added to change the mouse cursor by event comment tags
  50. # - Fixed crash when pointing a notetagged event with a valid condition
  51. #----------------------------------------------------------------------------
  52. # * Version 1.6 change log (Date: November 21 2012)
  53. #
  54. # - Added compatibility for any game screen resolution
  55. # - System optimized to consume less cpu than before
  56. # - Added extra compatibility for Pearl ABS Liquid
  57. # - Removed the font fix
  58. # - Added the imported bolean
  59. #----------------------------------------------------------------------------
  60. # * Version 1.5 change log
  61. #
  62. # - Fixed cursor sound over loading on selectable windows
  63. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  64. # - FIxed minor bug when transfering (event name now erase completely)
  65. # - Added option to turn on / off arrow selector on save file
  66. # - Important! changes on mouse comment tags!
  67. #   ~ CLICK START change to MOUSE START
  68. #   ~ ANIMATION   change to MOUSE ANIMATION
  69. #   ~ NAME        change to MOUSE NAME
  70. #
  71. #---------------------------------------------------------------------------
  72. # * installation
  73. #
  74. # Copy and paste this script above main done!
  75. #
  76. # * Mouse triggers
  77. #   - Left click:     Action button
  78. #   - Right click:    Cancel button, close windows
  79. #   - Mouse wheel middle button:   DASH
  80. #
  81. #---------------------------------------------------------------------------
  82. # * Main features
  83. #
  84. # - Allow you create buttons and configure them to do something
  85. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  86. # - Allow you display event name
  87. # - Full mouse interaction
  88. # - WASD movement optional
  89. # - Path finding feature, player is able to move using the mouse
  90. # - Mouse cursor changing in-game enabled
  91. #---------------------------------------------------------------------------
  92. # * Event buttons commands
  93. #
  94. # Write this lines on event comments tags
  95. #
  96. # MOUSE START       - Event start when you click the event
  97. # MOUSE ANIMATION x - Show animation when mouse is over event,
  98. #                     ex: MOUSE ANIMATION 1
  99. # MOUSE NAME x      - Display event name when mouse is over event,
  100. #                     ex: MOUSE NAME Falcao
  101. # MOUSE ICON x      - change the mouse cursor icon when it is over the event
  102. #                     change x for the icon index to display
  103. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  104. #                     case it display a picture graphic name, change x for the
  105. #                     picture name
  106. #------------------------------------------------------------------------------
  107. # * Script calls
  108. #
  109. # Call this line to turn off/on the mouse cursor within the game true/false
  110. # Mouse.show_cursor(false)
  111. #
  112. # If you want to change the mouse cursor manually use the following script calls
  113. # Mouse.set_cursor(:iconset, x)     - change x for any icon index
  114. #
  115. # if you want to show a picture instead iconset use the next script call
  116. # Mouse.set_cursor(:picture, name)  - change name for picture name
  117. #-----------------------------------------------------------------------------
  118.  
  119. module Map_Buttons
  120.  
  121. # You can easily insert as many buttons you want to the map screen
  122. # define here below your buttons parameters
  123.  
  124.   Insert = {
  125. #-----------------------------------------------------------------------------
  126. #  A => [B, C, D, E, F]
  127. #  
  128. #  A = Button number
  129. #
  130. #  B = Name
  131. #  C = X position in screen tile
  132. #  D = Y position in screen tile
  133. #  E = Icon, if you want a picture write picture 'name' otherwise icon index
  134. #  F = What this button gonna do?, you have two options, call scene or call
  135. #  common event, if you want scene put scene name, if you want common event
  136. #  put common event ID
  137.  
  138.   # This button call the menu screen
  139.   1=> ["Menu", 16, 11, 117, Scene_Menu],  
  140.  
  141.   # This button call a common event ID 1
  142.   2=>  ["Bestiary",  16, 12, 121, 1],
  143.  
  144.  
  145.  
  146.   }
  147.  
  148. # * General configutration
  149.  
  150. # Mouse cursor icon, if you want a picture write pic 'name' otherwise icon index
  151.   CursorIcon = 386
  152.  
  153. # Switch ID to turn off/on the icons on the screen
  154.   Switch = 500
  155.  
  156. # Allow movement with  W A S D keys true/false
  157.   WASD_Movement = true
  158.  
  159. # When you click on event, do you want the player to ignore the self movement?
  160.   IgnoreEventPath = true
  161.  
  162. # Switch id to enable or disable the path finding feature
  163.   PathFinderSwitch = 500
  164. #
  165. #----------------------------------------------------------------------------
  166. #
  167. # * License
  168. #
  169. # You can use this script in non comercial games, in you need it for comercial
  170. # games let me know. [email][email protected][/email]
  171. #-----------------------------------------------------------------------------
  172.  
  173.   def self.check_value(value)
  174.     return 'numeric' if value.is_a? Fixnum
  175.     return 'string'
  176.   end
  177. end
  178.  
  179. ($imported ||= {})[:Mouse_System_Buttons] = 2.0
  180.  
  181. # This class create all screen and event buttons on game screen
  182. class Interactive_Buttoms
  183.   attr_reader :cursoring
  184.   def initialize
  185.     create_screen_buttoms
  186.     @ani_delay = 0
  187.     @pearl_abs = $imported["Falcao Pearl ABS Liquid"]
  188.   end
  189.  
  190.   def create_screen_buttoms
  191.     @buttons_sprites = []
  192.     for i in Map_Buttons::Insert.values
  193.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  194.     end
  195.   end
  196.  
  197.   def create_button_text
  198.     if @button_text.nil?
  199.       @button_text = Sprite.new
  200.       @button_text.bitmap = Bitmap.new(100, 32)
  201.       @button_text.z = 50
  202.       @button_text.bitmap.font.size = 16
  203.     end
  204.   end
  205.  
  206.   def dispose_screen_buttons
  207.     for button in @buttons_sprites
  208.       button.dispose
  209.     end
  210.     @buttons_sprites = []
  211.   end
  212.  
  213.   def dispose_button_text
  214.     if not @button_text.nil?
  215.       @button_text.dispose
  216.       @button_text.bitmap.dispose
  217.       @button_text = nil
  218.     end
  219.   end
  220.  
  221.   def dispose
  222.     dispose_screen_buttons
  223.     dispose_button_text
  224.   end
  225.  
  226.   def update
  227.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  228.       dispose_screen_buttons
  229.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  230.       create_screen_buttoms
  231.     end
  232.     update_buttons
  233.     update_event_selection
  234.   end
  235.  
  236.   # path update
  237.   def update_path
  238.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  239.     return if $game_message.busy?
  240.     return unless $game_player.normal_walk?
  241.     @mxx, [url=home.php?mod=space&uid=397486]@myy[/url] = Mouse.map_grid[0], Mouse.map_grid[1]
  242.     if Map_Buttons::IgnoreEventPath
  243.       $game_map.events.values.each do |event|
  244.         return if event.x == @mxx and event.y == @myy
  245.       end
  246.     end
  247.     $game_player.find_path(@mxx, @myy) unless on_toolbar?
  248.   end
  249.  
  250.  
  251.   def on_toolbar?
  252.     return false unless @pearl_abs
  253.     9.times.each {|x| return true if @mxx == PearlSkillBar::Tile_X + x and
  254.     [url=home.php?mod=space&uid=397486]@myy[/url] == PearlSkillBar::Tile_Y}
  255.     return false
  256.   end
  257.  
  258.  
  259.   def update_buttons                               #更新_按钮
  260.     for button in @buttons_sprites
  261.       button.update
  262.       if button.zooming
  263.         @screen_b = true
  264.         create_button_text
  265.         if button.x > 272 #################################
  266.           x, y = button.px * 32 - 98, button.py * 32#98
  267.           draw_button_text(x, y, button.name, 2)
  268.         elsif button.x < 272
  269.           x, y = button.px * 32 + 31, button.py * 32#31
  270.           draw_button_text(x, y, button.name, 0)
  271.         end
  272.       end
  273.     end
  274.  
  275.     if @screen_b != nil
  276.       unless mouse_over_button?
  277.         dispose_button_text
  278.         @screen_b = nil
  279.       end
  280.     end
  281.   end
  282.  
  283.   def reset_cursor
  284.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  285.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  286.     else
  287.       Mouse.set_cursor(:picture, @cursoring[1], true)
  288.     end
  289.     @cursoring = nil
  290.   end
  291.  
  292.   def apply_iconchanging(sym, operand, event)
  293.     cursor = $game_system.cursorr
  294.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  295.     @cursoring = [event, cursor]
  296.     Mouse.set_cursor(sym, operand, true)
  297.   end
  298.  
  299.   def update_event_selection
  300.     return if @screen_b #disable event buttom if mouse over screen buttom
  301.     update_path if Mouse.trigger?(0)
  302.     for event in $game_map.events.values
  303.       next if event.page.nil?
  304.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  305.         if event.mouse_start
  306.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  307.             event.start
  308.           end
  309.         end
  310.  
  311.         if event.square_size?($game_player, 2)
  312.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  313.             event.start
  314.           end
  315.         end
  316.  
  317.         anime = event.mouse_animation
  318.         if anime != 0
  319.           @ani_delay += 1
  320.           event.animation_id = anime if @ani_delay == 1
  321.           @ani_delay = 0 if @ani_delay > 16
  322.         end
  323.         name = event.mouse_name
  324.         if name != ""
  325.           [url=home.php?mod=space&uid=94943]@Eve[/url] = [event.x, event.y, event, name]
  326.           create_button_text
  327.         end
  328.         icon = event.mouse_iconset
  329.         picture = event.mouse_picture
  330.         if !icon.nil? and icon != 0 and @cursoring.nil?
  331.           apply_iconchanging(:iconset, icon, event)
  332.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  333.           apply_iconchanging(:picture, picture, event)
  334.         end
  335.       end
  336.     end
  337.  
  338.     if @cursoring != nil
  339.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  340.     end
  341.  
  342.     if [url=home.php?mod=space&uid=94943]@Eve[/url] != nil
  343.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  344.       if event_oy > 32
  345.         draw_button_text(@eve[2].screen_x - 49,
  346.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  347.       else
  348.         draw_button_text(@eve[2].screen_x - 49,
  349.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  350.       end
  351.       if not mouse_over_event?(@eve[0], @eve[1])
  352.         dispose_button_text
  353.         @eve = nil
  354.       end
  355.     end
  356.   end
  357.  
  358.   def draw_button_text(x, y, text, a=0)
  359.     return if @button_text.nil?
  360.     @button_text.x = x
  361.     @button_text.y = y
  362.     return if @old_name == text
  363.     @button_text.bitmap.clear
  364.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  365.     @old_name = text
  366.   end
  367.  
  368.   def mouse_over_button?
  369.     for button in @buttons_sprites
  370.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  371.         return true
  372.       end
  373.     end
  374.     @old_name = nil
  375.     return false
  376.   end
  377.  
  378.   def mouse_over_event?(event_x, event_y)
  379.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  380.       return true
  381.     end
  382.     @old_name = nil
  383.     return false
  384.   end
  385. end
  386.  
  387. # Set buttons sprites
  388. class Spriteset_Map
  389.   alias falcao_insert_buttuns_view create_viewports
  390.   def create_viewports
  391.     @interact_buttoms = Interactive_Buttoms.new
  392.     falcao_insert_buttuns_view
  393.   end
  394.  
  395.   alias falcao_insert_buttuns_dis dispose
  396.   def dispose
  397.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  398.     @interact_buttoms.dispose
  399.     falcao_insert_buttuns_dis
  400.   end
  401.  
  402.   alias falcao_insert_buttuns_up update
  403.   def update
  404.     if $game_player.clear_mousepointers
  405.       @interact_buttoms.dispose
  406.       $game_player.clear_mousepointers = nil
  407.     end
  408.     @interact_buttoms.update
  409.     falcao_insert_buttuns_up
  410.   end
  411. end
  412.  
  413. # comments definition
  414. # 事件注释定义
  415. class Game_Event < Game_Character
  416.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  417.   attr_reader   :mouse_picture, :page
  418.   alias falcaomouse_setup setup_page_settings
  419.   def setup_page_settings
  420.     falcaomouse_setup
  421.     @mouse_start     = check_comment("MOUSE START")
  422.     @mouse_animation = check_value("MOUSE ANIMATION")
  423.     @mouse_name      = check_name("MOUSE NAME")
  424.     @mouse_iconset   = check_value("MOUSE ICON")
  425.     @mouse_picture   = check_name("MOUSE PIC")
  426.   end
  427.  
  428.   def check_comment(comment)
  429.     return false if @list.nil? or @list.size <= 0
  430.     for item in @list
  431.       if item.code == 108 or item.code == 408
  432.         if item.parameters[0].include?(comment)
  433.           return true
  434.         end
  435.       end
  436.     end
  437.     return false
  438.   end
  439.  
  440.   def check_value(comment)
  441.     return 0 if @list.nil? or @list.size <= 0
  442.     for item in @list
  443.       if item.code == 108 or item.code == 408
  444.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  445.           return $1.to_i
  446.         end
  447.       end
  448.     end
  449.     return 0
  450.   end
  451.  
  452.   def check_name(comment)
  453.     return "" if @list.nil? or @list.size <= 0
  454.     for item in @list
  455.       next unless item.code == 108 or item.code == 408
  456.       if item.parameters[0] =~ /#{comment} (.*)/
  457.         return $1.to_s
  458.       end
  459.     end
  460.     return ""
  461.   end
  462.  
  463.   def square_size?(target, size)
  464.     distance = (@x - target.x).abs + (@y - target.y).abs
  465.     enable   = (distance <= size-1)
  466.     return true if enable
  467.     return false
  468.   end
  469.  
  470. end
  471.  
  472. # Create screen buttons sprites
  473. class Sprite_Buttons < Sprite
  474.   attr_reader   :px
  475.   attr_reader   :py
  476.   attr_reader   :name
  477.   attr_reader   :zooming
  478.   def initialize(name, px, py, icon_index, action=nil)
  479.     super()
  480.     self.z = 50
  481.     @icon_index = icon_index
  482.     @px = px
  483.     @py = py
  484.     @action = action
  485.     @object_zooming = 0
  486.     @zooming = false
  487.     @name = name
  488.     set_bitmap
  489.     update
  490.   end
  491.  
  492.   def update
  493.     super
  494.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  495.       self.bitmap.height)
  496.       @zooming = true
  497.       @object_zooming += 1
  498.       case @object_zooming
  499.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  500.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  501.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  502.         @object_zooming = 0
  503.       end
  504.       if Mouse.trigger?(0) and @action != nil
  505.         unless $game_map.interpreter.running?
  506.           Sound.play_ok
  507.           if @action == Scene_Menu and not $game_system.menu_disabled
  508.             SceneManager.call(@action)
  509.             Window_MenuCommand::init_command_position
  510.             return
  511.           end
  512.          if Map_Buttons::check_value(@action) == 'numeric'
  513.            $game_temp.reserve_common_event(@action)
  514.          else
  515.            SceneManager.call(@action)
  516.          end
  517.         end
  518.       end
  519.     elsif @object_zooming > 0
  520.       self.zoom_x = 1.0
  521.       self.zoom_y = 1.0
  522.       @object_zooming = 0
  523.     else
  524.       @zooming = false
  525.     end
  526.   end
  527.  
  528.   def set_bitmap
  529.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  530.       self.bitmap = Bitmap.new(24, 24)
  531.       bitmap = Cache.system("Iconset")
  532.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  533.       self.bitmap.blt(0, 0, bitmap, rect)
  534.     else
  535.       self.bitmap = Cache.picture(@icon_index)
  536.     end
  537.     self.x = @px * 32 + 4
  538.     self.y = @py * 32 + 4
  539.   end
  540. end
  541.  
  542. # Game_character new variable
  543. class Game_CharacterBase
  544.   attr_accessor :ch_oy
  545. end
  546.  
  547. # Sprite character
  548. class Sprite_Character < Sprite_Base
  549.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  550.   def set_character_bitmap
  551.     falcaoadd_oxy_set_character_bitmap
  552.     @character.ch_oy = self.oy
  553.   end
  554. end
  555.  
  556. class Game_System
  557.   attr_accessor :current_cursor
  558.   def cursorr
  559.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  560.     return @current_cursor
  561.   end
  562. end
  563.  
  564. # Mouse module
  565. # 鼠标模块
  566. module Mouse
  567.  
  568.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  569.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  570.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  571.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  572.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  573.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  574.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  575.   %w(p p p p l p), 'l')
  576.  
  577.   ShowCursor.call(0)
  578.  
  579.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  580.   @old_pos      =   0
  581.  
  582.   # Mouse Sprite
  583.  
  584.   def self.set_cursor(sym, operand, write=false)
  585.     case sym
  586.     when :iconset
  587.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  588.       bitmap = Cache.system("Iconset")
  589.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  590.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  591.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  592.     end
  593.     $game_system.current_cursor = operand if write
  594.   end
  595.  
  596.   $mouse_cursor = Sprite.new
  597.   icon = Map_Buttons::CursorIcon
  598.   if Map_Buttons::check_value(icon) == 'numeric'
  599.     set_cursor(:iconset, icon)
  600.   else
  601.     set_cursor(:picture, icon)
  602.   end
  603.   $mouse_cursor.z = 10001
  604.   $mouse_cursor.x = $mouse_cursor.y = 1000
  605.   $mouse_cursor.ox = 4
  606.  
  607.   def self.show_cursor(value)
  608.     unless value
  609.       @pos[0] = @pos[1] = 600
  610.     end
  611.     $mouse_cursor.visible = value
  612.   end
  613.  
  614.   def self.map_grid
  615.     return nil if @pos == nil
  616.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  617.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  618.     return [x, y]
  619.   end
  620.  
  621.   def self.standing?
  622.     return false if @old_px != @pos[0]
  623.     return false if @old_py != @pos[1]
  624.     return true
  625.   end
  626.  
  627.   def self.input_keys
  628.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  629.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  630.     return keys
  631.   end
  632.  
  633.   def self.object_area?(x, y, width, height)
  634.     return false if @pos.nil?
  635.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  636.   end
  637.  
  638.   def self.position
  639.     return @pos == nil ? [0, 0] : @pos
  640.   end
  641.  
  642.   def self.global_pos
  643.     pos = [0, 0].pack('ll')
  644.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  645.   end
  646.  
  647.   def self.screen_to_client(x=0, y=0)
  648.     pos = [x, y].pack('ll')
  649.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  650.   end  
  651.  
  652.   def self.pos
  653.     global_pos = [0, 0].pack('ll')   
  654.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  655.     local_pos = [gx, gy].pack('ll')
  656.     x, y = ScreenToClient.call(self.hwnd,
  657.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  658.     begin
  659.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  660.         @old_px, @old_py = x, y
  661.         return x, y
  662.       else
  663.         return -20, -20
  664.       end
  665.     rescue
  666.       return 0, 0
  667.     end
  668.   end  
  669.  
  670.   def self.update
  671.     old_pos = @pos
  672.     @pos = self.pos
  673.     self.input_keys
  674.     if !$mouse_cursor.visible && old_pos != @pos
  675.       $mouse_cursor.visible = true
  676.     end
  677.     if old_pos != [-20, -20] && @pos == [-20, -20]
  678.       ShowCursor.call(1)
  679.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  680.        ShowCursor.call(0)
  681.     end
  682.     for i in @triggers
  683.       n = GetKeyState.call(i[1])
  684.       if [0, 1].include?(n)
  685.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  686.       else
  687.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  688.       end
  689.     end
  690.   end
  691.  
  692.   # trigger definition
  693.   def self.trigger?(id = 0)
  694.     pos = self.pos
  695.     if pos != [-20,-20]
  696.     case id
  697.       when 0  
  698.         return @triggers[id][0] == 1
  699.       when 1  
  700.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  701.           return @triggers[id][0] == 1
  702.         end
  703.       when 2
  704.         return @triggers[id][0] == 1
  705.       end   
  706.     end
  707.   end
  708.  
  709.   # repeat definition
  710.   def self.repeat?(id = 0)
  711.     if @triggers[id][0] <= 0
  712.       return false
  713.     else
  714.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  715.     end
  716.   end
  717.  
  718.   #press definition
  719.   def self.press?(id = 0)
  720.     if @triggers[id][0] <= 0
  721.       return false
  722.     else
  723.       return true
  724.     end
  725.   end
  726.  
  727.   def self.screen_to_client(x=0, y=0)
  728.     pos = [x, y].pack('ll')
  729.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  730.   end
  731.  
  732.   def self.hwnd
  733.     if @hwnd.nil?
  734.       game_name = "\0" * 256
  735.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  736.       game_name.delete!("\0")
  737.       @hwnd = Findwindow.call('RGSS Player', game_name)
  738.     end
  739.     return @hwnd
  740.   end
  741.  
  742.   def self.client_size
  743.     rect = [0, 0, 0, 0].pack('l4')
  744.     GetClientRect.call(self.hwnd, rect)
  745.     right, bottom = rect.unpack('l4')[2..3]
  746.     return right, bottom
  747.   end
  748. end
  749.  
  750. # Input module aliased
  751. class << Input
  752.   unless self.method_defined?(:falcao21_mouse_update)
  753.     alias_method :falcao21_mouse_update,   :update
  754.     alias_method :falcao21_mouse_trigger?, :trigger?
  755.     alias_method :falcao21_mouse_repeat?,  :repeat?
  756.     alias_method :fal_mouse_input_press?,  :press?
  757.   end
  758.  
  759.   def update
  760.     if $mouse_cursor.visible
  761.       Mouse.update
  762.       $game_arrows.update
  763.       mx, my = *Mouse.position
  764.       $mouse_cursor.x = mx unless mx.nil?
  765.       $mouse_cursor.y = my unless my.nil?   
  766.     end
  767.     falcao21_mouse_update
  768.   end
  769.  
  770.   # trigger
  771.   def trigger?(constant)
  772.     return true if falcao21_mouse_trigger?(constant)
  773.     unless Mouse.pos.nil?
  774.       if Mouse.input_keys.has_value?(constant)
  775.         mouse_trigger = Mouse.input_keys.index(constant)
  776.         return true if Mouse.trigger?(mouse_trigger)
  777.       end
  778.     end
  779.     return false
  780.   end
  781.  
  782.   # press
  783.   def press?(constant)
  784.     return true if fal_mouse_input_press?(constant)
  785.     unless Mouse.pos.nil?
  786.       if Mouse.input_keys.has_value?(constant)
  787.         mouse_trigger = Mouse.input_keys.index(constant)
  788.         return true if Mouse.press?(mouse_trigger)      
  789.       end
  790.     end
  791.     return false
  792.   end
  793.  
  794.   # repeat
  795.   def repeat?(constant)
  796.     return true if falcao21_mouse_repeat?(constant)
  797.     unless Mouse.pos.nil?
  798.       if Mouse.input_keys.has_value?(constant)
  799.         mouse_trigger = Mouse.input_keys.index(constant)     
  800.         return true if Mouse.repeat?(mouse_trigger)
  801.       end
  802.     end
  803.     return false
  804.   end
  805. end
  806.  
  807. # Here your best friend, you can call this script within the game, scene etc.
  808. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  809. class Game_Arrow_Selector
  810.   attr_accessor :mode_on
  811.   attr_accessor :in_type
  812.   def initialize
  813.     @mode_on = false
  814.   end
  815.  
  816.   def create_arrows(x, y)
  817.     return unless @arrows_sprites.nil?
  818.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  819.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  820.     @arrows_sprites = []
  821.     for i in buttons.values
  822.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  823.     end
  824.   end
  825.  
  826.   def dispose
  827.     return if @arrows_sprites.nil?
  828.     for arrow in @arrows_sprites
  829.       arrow.dispose
  830.     end
  831.     @arrows_sprites = nil
  832.     @mode_on = false
  833.   end
  834.  
  835.   def update
  836.     return if @arrows_sprites.nil?
  837.     for arrow in @arrows_sprites
  838.       arrow.update
  839.     end
  840.   end
  841. end
  842.  
  843. class Garrows_Sprites < Sprite
  844.   def initialize(name, x, y)
  845.     super()
  846.     self.z = 1000
  847.     @px, @py = x, y
  848.     @name = name
  849.     @object_zooming = 0
  850.     @zooming = false
  851.     set_bitmap
  852.     update
  853.   end
  854.  
  855.   def update
  856.     super
  857.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  858.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  859.       $game_arrows.mode_on = true
  860.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  861.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  862.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  863.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  864.       $game_arrows.in_type = Input::C     if @name == 'OK'
  865.       $game_arrows.in_type = Input::B     if @name == 'Cancel'
  866.       @object_zooming += 1
  867.       @zooming = true
  868.       case @object_zooming
  869.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  870.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  871.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  872.         @object_zooming = 0
  873.       end
  874.     elsif @object_zooming > 0
  875.       self.zoom_x = 1.0
  876.       self.zoom_y = 1.0
  877.       @object_zooming = 0
  878.     elsif @zooming
  879.       @zooming = false
  880.       $game_arrows.mode_on = false
  881.     end
  882.   end
  883.  
  884.   def set_bitmap
  885.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  886.     case @name
  887.     when 'UP'
  888.       self.x = @px + 25 ; self.y = @py - 2
  889.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  890.     when 'DOWN'
  891.       self.x = @px + 1 ; self.y = @py + 26
  892.       @fix = [0, -4, 0,  0]
  893.     when 'LEFT'
  894.       self.x = @px      ; self.y = @py + 1
  895.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  896.     when 'RIGHT'
  897.       self.x = @px + 26  ; self.y = @py + 26
  898.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  899.     when 'OK'
  900.       self.x = @px + 1  ; self.y = @py + 6
  901.       @fix = [0, -4, 0,  0]
  902.       self.bitmap.font.size = 20
  903.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  904.       return
  905.     when 'Cancel'
  906.       self.x = @px - 11  ; self.y = @py + 42
  907.       @fix = [0, -4, 0,  0]
  908.       self.bitmap = Bitmap.new(50, 15)
  909.       self.bitmap.font.size = 20
  910.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  911.       return
  912.     end
  913.     draw_crappy_triangle(0, 0)
  914.   end
  915.  
  916.   # This method create a crappy triangle pointing down
  917.   def draw_crappy_triangle(px, py)
  918.     color = Color.new(192, 224, 255, 255)
  919.     x, y, w, =  0, 4, 24
  920.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  921.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  922.     for i in 1..10
  923.       x += 1; y += 1; w -= 2
  924.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  925.     end
  926.   end
  927. end
  928.  
  929. $game_arrows = Game_Arrow_Selector.new
  930.  
  931. # Arrow selector is displayed when Input number is on
  932. # 当输入数量时,将显示箭头选择器
  933. class Game_Interpreter
  934.   alias falcao_setup_num_input setup_num_input
  935.   def setup_num_input(params)
  936.     falcao_setup_num_input(params)
  937.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  938.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  939.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  940.   end
  941. end
  942.  
  943. # Arrow selector is disposed when press ok
  944. class Window_NumberInput < Window_Base
  945.   alias falcao_process_ok process_ok
  946.   def process_ok
  947.     falcao_process_ok
  948.     $game_arrows.dispose
  949.   end
  950. end
  951.  
  952. # WASD Movements
  953. module Input
  954.   class << self
  955.     if !method_defined?('vxe_dir4')
  956.       alias vxace_dir4 dir4
  957.     end
  958.     def dir4
  959.       if Map_Buttons::WASD_Movement
  960.         return 2 if (Input.press?(Input::Y))
  961.         return 4 if (Input.press?(Input::X))
  962.         return 6 if (Input.press?(Input::Z))
  963.         return 8 if (Input.press?(Input::R))
  964.       end
  965.       return vxace_dir4
  966.     end
  967.   end
  968. end
  969.  
  970. # If event start with mouse
  971. class Game_Player < Game_Character
  972.   alias falcao_start_map_event start_map_event
  973.   def start_map_event(x, y, triggers, normal)
  974.     $game_map.events_xy(x, y).each do |event_click|
  975.       return if event_click.check_comment("MOUSE START")
  976.     end  
  977.     falcao_start_map_event(x, y, triggers, normal)
  978.   end
  979. end
  980.  
  981. # clear pointers when tranfering
  982. class Game_Player < Game_Character
  983.   attr_accessor :clear_mousepointers
  984.   alias falcaomouse_perform_transfer perform_transfer
  985.   def perform_transfer
  986.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  987.     falcaomouse_perform_transfer
  988.   end
  989. end
  990.  
  991. # Path find
  992. class Game_Character < Game_CharacterBase
  993.   attr_accessor :map, :runpath
  994.   alias pathfind1_ini initialize
  995.   def initialize
  996.     pathfind1_ini
  997.     @map = nil
  998.     @runpath = false
  999.   end
  1000.  
  1001.   alias pathfind1_up update
  1002.   def update
  1003.     run_path if @runpath == true
  1004.     pathfind1_up
  1005.   end
  1006.  
  1007.   def run_path
  1008.     return if moving?
  1009.     step = @map[@x,@y]
  1010.     if step == 1
  1011.       @map = nil
  1012.       @runpath = false
  1013.       return
  1014.     end
  1015.     dir = rand(2)
  1016.     case dir
  1017.     when 0
  1018.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  1019.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  1020.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  1021.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  1022.     when 1
  1023.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  1024.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  1025.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  1026.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  1027.     end
  1028.   end
  1029.  
  1030.   def find_path(x,y)
  1031.     sx, sy = @x, @y
  1032.     result = setup_map(sx,sy,x,y)
  1033.     @runpath = result[0]
  1034.     @map = result[1]
  1035.     @map[sx,sy] = result[2] if result[2] != nil
  1036.   end
  1037.  
  1038.   def clear_path
  1039.     @map = nil
  1040.     @runpath = false
  1041.   end
  1042.  
  1043.   def setup_map(sx,sy,ex,ey)
  1044.     map = Table.new($game_map.width, $game_map.height)
  1045.     map[ex,ey] = 1
  1046.     old_positions = []
  1047.     new_positions = []
  1048.     old_positions.push([ex, ey])
  1049.     depth = 2
  1050.     depth.upto(100){|step|
  1051.       loop do
  1052.         break if old_positions[0] == nil
  1053.         x,y = old_positions.shift
  1054.         return [true, map, step] if x == sx and y+1 == sy
  1055.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  1056.           map[x,y + 1] = step
  1057.           new_positions.push([x,y + 1])
  1058.         end
  1059.         return [true, map, step] if x-1 == sx and y == sy
  1060.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  1061.           map[x - 1,y] = step
  1062.           new_positions.push([x - 1,y])
  1063.         end
  1064.         return [true, map, step] if x+1 == sx and y == sy
  1065.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  1066.           map[x + 1,y] = step
  1067.           new_positions.push([x + 1,y])
  1068.         end
  1069.         return [true, map, step] if x == sx and y-1 == sy
  1070.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  1071.           map[x,y - 1] = step
  1072.           new_positions.push([x,y - 1])
  1073.         end
  1074.       end
  1075.       old_positions = new_positions
  1076.       new_positions = []
  1077.     }
  1078.     return [false, nil, nil]
  1079.   end
  1080. end
  1081.  
  1082. class Game_Player
  1083.   alias pathfind_player_update update
  1084.   def update
  1085.     clear_path if Input.dir4 != 0
  1086.     pathfind_player_update
  1087.   end
  1088.  
  1089.   alias findpath_perform_transfer perform_transfer
  1090.   def perform_transfer
  1091.     clear_path if $game_map.map_id !=  @new_map_id
  1092.     findpath_perform_transfer
  1093.   end
  1094. end
  1095.  
  1096. # Window selectable (Thanks wora for some lines here)
  1097. class Window_Selectable < Window_Base
  1098.   alias mouse_selection_ini initialize
  1099.   def initialize(*args)
  1100.     mouse_selection_ini(*args)
  1101.     @scroll_wait = 0
  1102.     @cursor_wait = 0
  1103.     @sdelay = 0
  1104.   end
  1105.  
  1106.   alias mouse_selection_update update
  1107.   def update
  1108.     update_mouse_selection if self.active and self.visible
  1109.     @sdelay -= 1 if @sdelay > 0
  1110.     mouse_selection_update
  1111.   end
  1112.  
  1113.   def update_mouse_selection
  1114.     @cursor_wait -= 1 if @cursor_wait > 0
  1115.     plus_x = self.x + 16 - self.ox
  1116.     plus_y = self.y + 8 - self.oy
  1117.     unless self.viewport.nil?
  1118.       plus_x += self.viewport.rect.x - self.viewport.ox
  1119.       plus_y += self.viewport.rect.y - self.viewport.oy
  1120.     end
  1121.     (0..self.item_max - 1).each do |i|
  1122.       irect = item_rect(i)
  1123.       move_cursor(i) if Mouse.object_area?(
  1124.       irect.x + plus_x, irect.y + plus_y, irect.width, irect.height)
  1125.       update_cursor
  1126.     end
  1127.   end
  1128.  
  1129.   def move_cursor(index)
  1130.     return if @index == index
  1131.     @scroll_wait -= 1 if @scroll_wait > 0
  1132.     row1 = @index / self.col_max
  1133.     row2 = index / self.col_max
  1134.     bottom = self.top_row + (self.page_row_max - 1)
  1135.     if index != @index and @sdelay == 0
  1136.       Sound.play_cursor
  1137.       @sdelay = 5
  1138.     end
  1139.     if row1 == self.top_row and row2 < self.top_row
  1140.       return if @scroll_wait > 0
  1141.       @index = [@index - self.col_max, 0].max
  1142.       @scroll_wait = 30
  1143.     elsif row1 == bottom and row2 > bottom
  1144.       return if @scroll_wait > 0
  1145.       @index = [@index + self.col_max, self.item_max - 1].min
  1146.       @scroll_wait = 30
  1147.     else
  1148.       @index = index
  1149.     end
  1150.     select(@index)
  1151.     return if @cursor_wait > 0
  1152.     @cursor_wait += 2
  1153.   end
  1154. end
  1155.  
  1156.  
  1157. class Window_NameInput
  1158.   def item_max
  1159.     return 90
  1160.   end
  1161. end
  1162.  
  1163. class Scene_File < Scene_MenuBase
  1164.  
  1165.   alias mouse_top_index top_index=
  1166.   def top_index=(index)
  1167.     @scroll_timer = 0 if @scroll_timer.nil? ; @scroll_timer -= 1
  1168.     return if @scroll_timer > 0
  1169.     mouse_top_index(index) ; @scroll_timer = 35
  1170.   end
  1171.  
  1172.   alias mouse_sb_update update
  1173.   def update
  1174.     (0..self.item_max - 1).each do |i|
  1175.       ix = @savefile_windows[i].x
  1176.       iy = @savefile_windows[i].y + 40 - @savefile_viewport.oy
  1177.       iw = @savefile_windows[i].width
  1178.       ih = @savefile_windows[i].height
  1179.       if Mouse.object_area?(ix, iy, iw, ih)
  1180.         @savefile_windows[@index].selected = false
  1181.         @savefile_windows[i].selected = true
  1182.         @index = i
  1183.       end
  1184.       ensure_cursor_visible
  1185.     end
  1186.     mouse_sb_update
  1187.   end
  1188. end
器识为先,文艺其从。

Lv5.捕梦者

梦石
0
星屑
22968
在线时间
8639 小时
注册时间
2011-12-31
帖子
3367
2
发表于 2015-3-5 21:46:12 | 只看该作者
本帖最后由 tseyik 于 2015-3-5 21:47 编辑

#  E = Icon, if you want a picture write picture 'name' otherwise icon index
#  E =圖標,如果你想要的顕示圖片則寫圖片的'名字',否則圖標指數
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (版主)

梦石
0
星屑
3105
在线时间
741 小时
注册时间
2015-2-28
帖子
816

开拓者

3
 楼主| 发表于 2015-3-6 15:55:49 | 只看该作者
tseyik 发表于 2015-3-5 21:46
#  E = Icon, if you want a picture write picture 'name' otherwise icon index
#  E =圖標,如果你想要 ...

这我知道,但关键是“但把鼠标放上去之后图片按钮会“晃动”,而不是显示另一个图片”
器识为先,文艺其从。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-21 18:57

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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