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

Project1

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

[已经过期] 那个啥,如何在鼠标脚本中加入快捷菜单

[复制链接]

Lv1.梦旅人

梦石
0
星屑
70
在线时间
80 小时
注册时间
2014-4-12
帖子
167
跳转到指定楼层
1
发表于 2014-5-3 15:12:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 影风枪圣 于 2014-5-3 15:14 编辑

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

嘿嘿,说是请教,其实就是来送脚本

Lv1.梦旅人

梦石
0
星屑
50
在线时间
444 小时
注册时间
2011-1-3
帖子
151

开拓者

2
发表于 2014-5-6 15:31:57 | 只看该作者
直接上范例百度盘
没有附带System.dll文件,请自行复制进去。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-14 08:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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