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

Project1

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

[已经过期] 两个鼠标脚本的功能能整合在一起吗?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
120
在线时间
188 小时
注册时间
2014-1-18
帖子
254
跳转到指定楼层
1
发表于 2014-8-6 14:37:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
一个是Sion大神的多功能DLL鼠标脚本(就是这个):
https://rpg.blue/thread-347535-1-1.html
我主要就是希以下这个脚本中的鼠标界面按钮能整合进去,最好格式差不多,谢谢了(不好意思,又来伸手了)
  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. # * Version 2.5 change log (Date: June 9 2013)
  38. #
  39. # Fixed non-refreshing item description bug
  40. # Fixed Save file selection issue
  41. # Added ability to start events even if the player is no facing the event
  42. # Removed option to display arrow selector on save file
  43. # Added compatibility for multiples game resolutions
  44. # Item selection with mouse is now more occurate
  45. # Fixed issue with pearl skillbar (when clicking any tool perform path finding)
  46. # Cleaned up some code
  47. #
  48. #----------------------------------------------------------------------------
  49. # * Version 2.0 change log (Date: January 13 2013)
  50. #
  51. # - Added path finding, now the game player is able to move using the mouse
  52. # - Now you are able to change the mouse cursor icon in game
  53. # - Two new notetags added to change the mouse cursor by event comment tags
  54. # - Fixed crash when pointing a notetagged event with a valid condition
  55. #----------------------------------------------------------------------------
  56. # * Version 1.6 change log (Date: November 21 2012)
  57. #
  58. # - Added compatibility for any game screen resolution
  59. # - System optimized to consume less cpu than before
  60. # - Added extra compatibility for Pearl ABS Liquid
  61. # - Removed the font fix
  62. # - Added the imported bolean
  63. #----------------------------------------------------------------------------
  64. # * Version 1.5 change log
  65. #
  66. # - Fixed cursor sound over loading on selectable windows
  67. # - Fixed bug when selecting event graphic tileset that have mouse comment tag
  68. # - FIxed minor bug when transfering (event name now erase completely)
  69. # - Added option to turn on / off arrow selector on save file
  70. # - Important! changes on mouse comment tags!
  71. #   ~ CLICK START change to MOUSE START
  72. #   ~ ANIMATION   change to MOUSE ANIMATION
  73. #   ~ NAME        change to MOUSE NAME
  74. #
  75. #---------------------------------------------------------------------------
  76. # * installation
  77. #
  78. # Copy and paste this script above main done!
  79. #
  80. # * Mouse triggers
  81. #   - Left click:     Action button
  82. #   - Right click:    Cancel button, close windows
  83. #   - Mouse wheel middle button:   DASH
  84. #
  85. #---------------------------------------------------------------------------
  86. # * Main features
  87. #
  88. # - Allow you create buttons and configure them to do something
  89. # - Events can be buttons too, map ground buttons! for some puzzles etc.
  90. # - Allow you display event name
  91. # - Full mouse interaction
  92. # - WASD movement optional
  93. # - Path finding feature, player is able to move using the mouse
  94. # - Mouse cursor changing in-game enabled
  95. #---------------------------------------------------------------------------
  96. # * Event buttons commands
  97. #
  98. # Write this lines on event comments tags
  99. #
  100. # MOUSE START       - Event start when you click the event
  101. # MOUSE ANIMATION x - Show animation when mouse is over event,
  102. #                     ex: MOUSE ANIMATION 1
  103. # MOUSE NAME x      - Display event name when mouse is over event,
  104. #                     ex: MOUSE NAME Falcao
  105. # MOUSE ICON x      - change the mouse cursor icon when it is over the event
  106. #                     change x for the icon index to display
  107. # MOUSE PIC X       - Change the mouse cursor when is over an event but in this
  108. #                     case it display a picture graphic name, change x for the
  109. #                     picture name
  110. #------------------------------------------------------------------------------
  111. # * Script calls
  112. #
  113. # Call this line to turn off/on the mouse cursor within the game true/false
  114. # Mouse.show_cursor(false)
  115. #
  116. # If you want to change the mouse cursor manually use the following script calls
  117. # Mouse.set_cursor(:iconset, x)     - change x for any icon index
  118. #
  119. # if you want to show a picture instead iconset use the next script call
  120. # Mouse.set_cursor(:picture, name)  - change name for picture name
  121. #-----------------------------------------------------------------------------

  122. module Map_Buttons

  123. # You can easily insert as many buttons you want to the map screen
  124. # define here below your buttons parameters

  125.   Insert = {
  126. #-----------------------------------------------------------------------------
  127. #  A => [B, C, D, E, F]
  128. #  
  129. #  A = Button number 按键序号
  130. #
  131. #  B = Name  游戏中按键显示的名字
  132. #  C = X position in screen tile  屏幕上X坐标
  133. #  D = Y position in screen tile  屏幕上Y坐标
  134. #  E = Icon, if you want a picture write picture 'name' otherwise icon index
  135. #  F = What this button gonna do?, you have two options, call scene or call
  136. #  common event, if you want scene put scene name, if you want common event
  137. #  put common event ID

  138. #Y坐标12,显示在最靠近屏幕下方。添加新菜单的时候请将Y坐标-1。
  139. #F处可填场景呼叫和公共事件ID。

  140.   # This button call the menu screen

  141.   
  142.   
  143. # ID=> ["显示名称",    X,   Y, 图标Index,      呼出菜单],
  144.     1=>  ["菜单",     16,   8,  117,         Scene_Menu],
  145.     2=>  ["存档",     16,   7,  4,           Scene_Save],


  146.     #Scene_Point
  147. #~ #   10=>  ["成就",    0,   8,   254,         Scene_Medalinfo],
  148.   }

  149. # * General configutration

  150. # Mouse cursor icon, if you want a picture write pic 'name' otherwise icon index
  151.   CursorIcon = 386

  152. # Switch ID to turn off/on the icons on the screen
  153.   Switch = 100

  154. # Allow movement with  W A S D keys true/false
  155.   WASD_Movement = true

  156. # When you click on event, do you want the player to ignore the self movement?
  157.   IgnoreEventPath = true

  158. # Switch id to enable or disable the path finding feature
  159.   PathFinderSwitch = 500
  160. #
  161. #----------------------------------------------------------------------------
  162. #
  163. # * License
  164. #
  165. # You can use this script in non comercial games, in you need it for comercial
  166. # games let me know. [email][email protected][/email]
  167. #-----------------------------------------------------------------------------

  168.   def self.check_value(value)
  169.     return 'numeric' if value.is_a? Fixnum
  170.     return 'string'
  171.   end
  172. end

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

  174. # This class create all screen and event buttons on game screen
  175. class Interactive_Buttoms
  176.   attr_reader :cursoring
  177.   def initialize
  178.     create_screen_buttoms
  179.     @ani_delay = 0
  180.     @pearl_abs = $imported["Falcao Pearl ABS Liquid"]
  181.   end

  182.   def create_screen_buttoms
  183.     @buttons_sprites = []
  184.     for i in Map_Buttons::Insert.values
  185.       @buttons_sprites.push(Sprite_Buttons.new(i[0], i[1], i[2], i[3], i[4]))
  186.     end
  187.   end

  188.   def create_button_text
  189.     if @button_text.nil?
  190.       @button_text = Sprite.new
  191.       @button_text.bitmap = Bitmap.new(100, 32)
  192.       @button_text.z = 500
  193.       @button_text.bitmap.font.size = 16
  194.     end
  195.   end

  196.   def dispose_screen_buttons
  197.     for button in @buttons_sprites
  198.       button.dispose
  199.     end
  200.     @buttons_sprites = []
  201.   end

  202.   def dispose_button_text
  203.     if not @button_text.nil?
  204.       @button_text.dispose
  205.       @button_text.bitmap.dispose
  206.       @button_text = nil
  207.     end
  208.   end

  209.   def dispose
  210.     dispose_screen_buttons
  211.     dispose_button_text
  212.   end

  213.   def update
  214.     if $game_switches[Map_Buttons::Switch] and not @buttons_sprites.empty?
  215.       dispose_screen_buttons
  216.     elsif not $game_switches[Map_Buttons::Switch] and @buttons_sprites.empty?
  217.       create_screen_buttoms
  218.     end
  219.     update_buttons
  220.     update_event_selection
  221.   end

  222.   # path update
  223.   def update_path
  224.     return if $game_switches[Map_Buttons::PathFinderSwitch]
  225.     return if $game_message.busy?
  226.     return unless $game_player.normal_walk?
  227.     @mxx, [url=home.php?mod=space&uid=397486]@myy[/url] = Mouse.map_grid[0], Mouse.map_grid[1]
  228.     if Map_Buttons::IgnoreEventPath
  229.       $game_map.events.values.each do |event|
  230.         return if event.x == @mxx and event.y == @myy
  231.       end
  232.     end
  233.     $game_player.find_path(@mxx, @myy) unless on_toolbar?
  234.   end


  235.   def on_toolbar?
  236.     return false unless @pearl_abs
  237.     9.times.each {|x| return true if @mxx == PearlSkillBar::Tile_X + x and
  238.     @myy == PearlSkillBar::Tile_Y}
  239.     return false
  240.   end


  241.   def update_buttons
  242.     for button in @buttons_sprites
  243.       button.update
  244.       if button.zooming
  245.         @screen_b = true
  246.         create_button_text
  247.         if button.x > 272
  248.           x, y = button.px * 32 - 98, button.py * 32
  249.           draw_button_text(x, y, button.name, 2)
  250.         elsif button.x < 272
  251.           x, y = button.px * 32 + 31, button.py * 32
  252.           draw_button_text(x, y, button.name, 0)
  253.         end
  254.       end
  255.     end

  256.     if @screen_b != nil
  257.       unless mouse_over_button?
  258.         dispose_button_text
  259.         @screen_b = nil
  260.       end
  261.     end
  262.   end

  263.   def reset_cursor
  264.     if Map_Buttons::check_value(@cursoring[1]) == 'numeric'
  265.       Mouse.set_cursor(:iconset, @cursoring[1], true)
  266.     else
  267.       Mouse.set_cursor(:picture, @cursoring[1], true)
  268.     end
  269.     @cursoring = nil
  270.   end

  271.   def apply_iconchanging(sym, operand, event)
  272.     cursor = $game_system.cursorr
  273.     cursor = Map_Buttons::CursorIcon if cursor.nil?
  274.     @cursoring = [event, cursor]
  275.     Mouse.set_cursor(sym, operand, true)
  276.   end

  277.   def update_event_selection
  278.     return if @screen_b #disable event buttom if mouse over screen buttom
  279.     update_path if Mouse.trigger?(0)
  280.     for event in $game_map.events.values
  281.       next if event.page.nil?
  282.       if event.x == Mouse.map_grid[0] and event.y == Mouse.map_grid[1]
  283.         if event.mouse_start
  284.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  285.             event.start
  286.           end
  287.         end

  288.         if event.square_size?($game_player, 2)
  289.           if Mouse.trigger?(0) and !$game_map.interpreter.running?
  290.             event.start
  291.           end
  292.         end

  293.         anime = event.mouse_animation
  294.         if anime != 0
  295.           @ani_delay += 1
  296.           event.animation_id = anime if @ani_delay == 1
  297.           @ani_delay = 0 if @ani_delay > 16
  298.         end
  299.         name = event.mouse_name
  300.         if name != ""
  301.           [url=home.php?mod=space&uid=94943]@Eve[/url] = [event.x, event.y, event, name]
  302.           create_button_text
  303.         end
  304.         icon = event.mouse_iconset
  305.         picture = event.mouse_picture
  306.         if !icon.nil? and icon != 0 and @cursoring.nil?
  307.           apply_iconchanging(:iconset, icon, event)
  308.         elsif !picture.nil? and picture != "" and @cursoring.nil?
  309.           apply_iconchanging(:picture, picture, event)
  310.         end
  311.       end
  312.     end

  313.     if @cursoring != nil
  314.       reset_cursor if not mouse_over_event?(@cursoring[0].x, @cursoring[0].y)
  315.     end

  316.     if @Eve != nil
  317.       @eve[2].ch_oy.nil? ? event_oy = 32 : event_oy = @eve[2].ch_oy
  318.       if event_oy > 32
  319.         draw_button_text(@eve[2].screen_x - 49,
  320.         @eve[2].screen_y - event_oy / 2 - 50, @eve[3], 1)
  321.       else
  322.         draw_button_text(@eve[2].screen_x - 49,
  323.         @eve[2].screen_y - event_oy / 2 - 36, @eve[3], 1)
  324.       end
  325.       if not mouse_over_event?(@eve[0], @eve[1])
  326.         dispose_button_text
  327.         @eve = nil
  328.       end
  329.     end
  330.   end

  331.   def draw_button_text(x, y, text, a=0)
  332.     return if @button_text.nil?
  333.     @button_text.x = x
  334.     @button_text.y = y
  335.     return if @old_name == text
  336.     @button_text.bitmap.clear
  337.     @button_text.bitmap.draw_text(2, 0, @button_text.bitmap.width, 32, text, a)
  338.     @old_name = text
  339.   end

  340.   def mouse_over_button?
  341.     for button in @buttons_sprites
  342.       if Mouse.object_area?(button.x, button.y - 6, button.width, button.height)
  343.         return true
  344.       end
  345.     end
  346.     @old_name = nil
  347.     return false
  348.   end

  349.   def mouse_over_event?(event_x, event_y)
  350.     if Mouse.map_grid[0] == event_x and Mouse.map_grid[1] == event_y
  351.       return true
  352.     end
  353.     @old_name = nil
  354.     return false
  355.   end
  356. end

  357. # Set buttons sprites
  358. class Spriteset_Map
  359.   alias falcao_insert_buttuns_view create_viewports
  360.   def create_viewports
  361.     @interact_buttoms = Interactive_Buttoms.new
  362.     falcao_insert_buttuns_view
  363.   end

  364.   alias falcao_insert_buttuns_dis dispose
  365.   def dispose
  366.     @interact_buttoms.reset_cursor if @interact_buttoms.cursoring != nil
  367.     @interact_buttoms.dispose
  368.     falcao_insert_buttuns_dis
  369.   end

  370.   alias falcao_insert_buttuns_up update
  371.   def update
  372.     if $game_player.clear_mousepointers
  373.       @interact_buttoms.dispose
  374.       $game_player.clear_mousepointers = nil
  375.     end
  376.     @interact_buttoms.update
  377.     falcao_insert_buttuns_up
  378.   end
  379. end

  380. # comments definition
  381. class Game_Event < Game_Character
  382.   attr_reader   :mouse_start, :mouse_animation, :mouse_name, :mouse_iconset
  383.   attr_reader   :mouse_picture, :page
  384.   alias falcaomouse_setup setup_page_settings
  385.   def setup_page_settings
  386.     falcaomouse_setup
  387.     @mouse_start     = check_comment("MOUSE START")
  388.     @mouse_animation = check_value("MOUSE ANIMATION")
  389.     @mouse_name      = check_name("MOUSE NAME")
  390.     @mouse_iconset   = check_value("MOUSE ICON")#
  391.     @mouse_picture   = check_name("MOUSE PIC")#
  392.   end

  393.   def check_comment(comment)
  394.     return false if @list.nil? or @list.size <= 0
  395.     for item in @list
  396.       if item.code == 108 or item.code == 408
  397.         if item.parameters[0].include?(comment)
  398.           return true
  399.         end
  400.       end
  401.     end
  402.     return false
  403.   end

  404.   def check_value(comment)
  405.     return 0 if @list.nil? or @list.size <= 0
  406.     for item in @list
  407.       if item.code == 108 or item.code == 408
  408.         if item.parameters[0] =~ /#{comment}[ ]?(\d+)?/
  409.           return $1.to_i
  410.         end
  411.       end
  412.     end
  413.     return 0
  414.   end

  415.   def check_name(comment)
  416.     return "" if @list.nil? or @list.size <= 0
  417.     for item in @list
  418.       next unless item.code == 108 or item.code == 408
  419.       if item.parameters[0] =~ /#{comment} (.*)/
  420.         return $1.to_s
  421.       end
  422.     end
  423.     return ""
  424.   end

  425.   def square_size?(target, size)
  426.     distance = (@x - target.x).abs + (@y - target.y).abs
  427.     enable   = (distance <= size-1)
  428.     return true if enable
  429.     return false
  430.   end

  431. end

  432. # Create screen buttons sprites
  433. class Sprite_Buttons < Sprite
  434.   attr_reader   :px
  435.   attr_reader   :py
  436.   attr_reader   :name
  437.   attr_reader   :zooming
  438.   def initialize(name, px, py, icon_index, action=nil)
  439.     super()
  440.     self.z = 50
  441.     @icon_index = icon_index
  442.     @px = px
  443.     @py = py
  444.     @action = action
  445.     @object_zooming = 0
  446.     @zooming = false
  447.     @name = name
  448.     set_bitmap
  449.     update
  450.   end

  451.   def update
  452.     super
  453.     if Mouse.object_area?(self.x, self.y - 4, self.bitmap.width,
  454.       self.bitmap.height)
  455.       @zooming = true
  456.       @object_zooming += 1
  457.       case @object_zooming
  458.       when 1..10  ; self.zoom_x -= 0.02 ;  self.zoom_y -= 0.02
  459.       when 11..20 ; self.zoom_x += 0.02 ;  self.zoom_y += 0.02
  460.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  461.         @object_zooming = 0
  462.       end
  463.       if Mouse.trigger?(0) and @action != nil
  464.         unless $game_map.interpreter.running?
  465.           Sound.play_ok
  466.           if @action == Scene_Menu and not $game_system.menu_disabled
  467.             SceneManager.call(@action)
  468.             Window_MenuCommand::init_command_position
  469.             return
  470.           end
  471.          if Map_Buttons::check_value(@action) == 'numeric'
  472.            $game_temp.reserve_common_event(@action)
  473.          else
  474.            SceneManager.call(@action)
  475.          end
  476.         end
  477.       end
  478.     elsif @object_zooming > 0
  479.       self.zoom_x = 1.0
  480.       self.zoom_y = 1.0
  481.       @object_zooming = 0
  482.     else
  483.       @zooming = false
  484.     end
  485.   end

  486.   def set_bitmap
  487.     if Map_Buttons::check_value(@icon_index) == 'numeric'
  488.       self.bitmap = Bitmap.new(24, 24)
  489.       bitmap = Cache.system("Iconset")
  490.       rect = Rect.new(@icon_index % 16 * 24, @icon_index / 16 * 24, 24, 24)
  491.       self.bitmap.blt(0, 0, bitmap, rect)
  492.     else
  493.       self.bitmap = Cache.picture(@icon_index)
  494.     end
  495.     self.x = @px * 32 + 4
  496.     self.y = @py * 32 + 4
  497.   end
  498. end

  499. # Game_character new variable
  500. class Game_CharacterBase
  501.   attr_accessor :ch_oy
  502. end

  503. # Sprite character
  504. class Sprite_Character < Sprite_Base
  505.   alias falcaoadd_oxy_set_character_bitmap set_character_bitmap
  506.   def set_character_bitmap
  507.     falcaoadd_oxy_set_character_bitmap
  508.     @character.ch_oy = self.oy
  509.   end
  510. end

  511. class Game_System
  512.   attr_accessor :current_cursor
  513.   def cursorr
  514.     return Map_Buttons::CursorIcon if @current_cursor.nil?
  515.     return @current_cursor
  516.   end
  517. end

  518. # Mouse module
  519. module Mouse

  520.   GetKeyState    = Win32API.new('user32',    'GetAsyncKeyState', 'i',     'i')
  521.   GetCursorPos   = Win32API.new('user32',    'GetCursorPos',     'p',     'i')
  522.   GetClientRect  = Win32API.new('user32',    'GetClientRect',    %w(l p), 'i')
  523.   ShowCursor     = Win32API.new('user32',    'ShowCursor',       'i',     'l')
  524.   ScreenToClient = Win32API.new('user32',    'ScreenToClient',   %w(l p), 'i')
  525.   Findwindow     = Win32API.new('user32',    'FindWindowA',      %w(p p), 'l')
  526.   GetPrivatePro  = Win32API.new('kernel32',  'GetPrivateProfileStringA',
  527.   %w(p p p p l p), 'l')

  528.   ShowCursor.call(0)

  529.   @triggers     =   [[0, 1], [0, 2], [0, 4]]
  530.   @old_pos      =   0

  531.   # Mouse Sprite

  532.   def self.set_cursor(sym, operand, write=false)
  533.     case sym
  534.     when :iconset
  535.       $mouse_cursor.bitmap = Bitmap.new(24, 24)
  536.       bitmap = Cache.system("Iconset")
  537.       rect = Rect.new(operand % 16 * 24, operand / 16 * 24, 24, 24)
  538.       $mouse_cursor.bitmap.blt(0, 0, bitmap, rect)
  539.     when :picture then $mouse_cursor.bitmap = Cache.picture(operand)
  540.     end
  541.     $game_system.current_cursor = operand if write
  542.   end

  543.   $mouse_cursor = Sprite.new
  544.   icon = Map_Buttons::CursorIcon
  545.   if Map_Buttons::check_value(icon) == 'numeric'
  546.     set_cursor(:iconset, icon)
  547.   else
  548.     set_cursor(:picture, icon)
  549.   end
  550.   $mouse_cursor.z = 10001
  551.   $mouse_cursor.x = $mouse_cursor.y = 1000
  552.   $mouse_cursor.ox = 4

  553.   def self.show_cursor(value)
  554.     unless value
  555.       @pos[0] = @pos[1] = 600
  556.     end
  557.     $mouse_cursor.visible = value
  558.   end

  559.   def self.map_grid
  560.     return nil if @pos == nil
  561.     x = ($game_map.display_x).to_i + (@pos[0] / 32)
  562.     y = ($game_map.display_y).to_i + (@pos[1] / 32)
  563.     return [x, y]
  564.   end

  565.   def self.standing?
  566.     return false if @old_px != @pos[0]
  567.     return false if @old_py != @pos[1]
  568.     return true
  569.   end

  570.   def self.input_keys
  571.     $game_arrows.mode_on ? type = $game_arrows.in_type : type = Input::C
  572.     keys = {0 => type, 1 => Input::B, 2 => Input::A}
  573.     return keys
  574.   end

  575.   def self.object_area?(x, y, width, height)
  576.     return false if @pos.nil?
  577.     return @pos[0].between?(x, width + x) && @pos[1].between?(y, height + y)
  578.   end

  579.   def self.position
  580.     return @pos == nil ? [0, 0] : @pos
  581.   end

  582.   def self.global_pos
  583.     pos = [0, 0].pack('ll')
  584.     return GetCursorPos.call(pos) == 0 ? nil : pos.unpack('ll')
  585.   end

  586.   def self.screen_to_client(x=0, y=0)
  587.     pos = [x, y].pack('ll')
  588.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  589.   end  

  590.   def self.pos
  591.     global_pos = [0, 0].pack('ll')   
  592.     gx, gy = GetCursorPos.call(global_pos) == 0 ? nil : global_pos.unpack('ll')
  593.     local_pos = [gx, gy].pack('ll')
  594.     x, y = ScreenToClient.call(self.hwnd,
  595.     local_pos) == 0 ? nil : local_pos.unpack('ll')
  596.     begin
  597.       if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  598.         @old_px, @old_py = x, y
  599.         return x, y
  600.       else
  601.         return -20, -20
  602.       end
  603.     rescue
  604.       return 0, 0
  605.     end
  606.   end  

  607.   def self.update
  608.     old_pos = @pos
  609.     @pos = self.pos
  610.     self.input_keys
  611.     if !$mouse_cursor.visible && old_pos != @pos
  612.       $mouse_cursor.visible = true
  613.     end
  614.     if old_pos != [-20, -20] && @pos == [-20, -20]
  615.       ShowCursor.call(1)
  616.     elsif old_pos == [-20, -20] && @pos != [-20, -20]
  617.        ShowCursor.call(0)
  618.     end
  619.     for i in @triggers
  620.       n = GetKeyState.call(i[1])
  621.       if [0, 1].include?(n)
  622.         i[0] = (i[0] > 0 ? i[0] * -1 : 0)
  623.       else
  624.         i[0] = (i[0] > 0 ? i[0] + 1 : 1)
  625.       end
  626.     end
  627.   end

  628.   # trigger definition
  629.   def self.trigger?(id = 0)
  630.     pos = self.pos
  631.     if pos != [-20,-20]
  632.     case id
  633.       when 0  
  634.         return @triggers[id][0] == 1
  635.       when 1  
  636.         if @triggers[1][0] == 1 && !$game_system.menu_disabled
  637.           return @triggers[id][0] == 1
  638.         end
  639.       when 2
  640.         return @triggers[id][0] == 1
  641.       end   
  642.     end
  643.   end

  644.   # repeat definition
  645.   def self.repeat?(id = 0)
  646.     if @triggers[id][0] <= 0
  647.       return false
  648.     else
  649.       return @triggers[id][0] % 5 == 1 && @triggers[id][0] % 5 != 2
  650.     end
  651.   end

  652.   #press definition
  653.   def self.press?(id = 0)
  654.     if @triggers[id][0] <= 0
  655.       return false
  656.     else
  657.       return true
  658.     end
  659.   end

  660.   def self.screen_to_client(x=0, y=0)
  661.     pos = [x, y].pack('ll')
  662.     return ScreenToClient.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  663.   end

  664.   def self.hwnd
  665.     if @hwnd.nil?
  666.       game_name = "\0" * 256
  667.       GetPrivatePro.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
  668.       game_name.delete!("\0")
  669.       @hwnd = Findwindow.call('RGSS Player', game_name)
  670.     end
  671.     return @hwnd
  672.   end

  673.   def self.client_size
  674.     rect = [0, 0, 0, 0].pack('l4')
  675.     GetClientRect.call(self.hwnd, rect)
  676.     right, bottom = rect.unpack('l4')[2..3]
  677.     return right, bottom
  678.   end
  679. end

  680. # Input module aliased
  681. class << Input
  682.   unless self.method_defined?(:falcao21_mouse_update)
  683.     alias_method :falcao21_mouse_update,   :update
  684.     alias_method :falcao21_mouse_trigger?, :trigger?
  685.     alias_method :falcao21_mouse_repeat?,  :repeat?
  686.     alias_method :fal_mouse_input_press?,  :press?
  687.   end

  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.   # trigger
  699.   def trigger?(constant)
  700.     return true if falcao21_mouse_trigger?(constant)
  701.     unless Mouse.pos.nil?
  702.       if Mouse.input_keys.has_value?(constant)
  703.         mouse_trigger = Mouse.input_keys.index(constant)
  704.         return true if Mouse.trigger?(mouse_trigger)
  705.       end
  706.     end
  707.     return false
  708.   end

  709.   # press
  710.   def press?(constant)
  711.     return true if fal_mouse_input_press?(constant)
  712.     unless Mouse.pos.nil?
  713.       if Mouse.input_keys.has_value?(constant)
  714.         mouse_trigger = Mouse.input_keys.index(constant)
  715.         return true if Mouse.press?(mouse_trigger)      
  716.       end
  717.     end
  718.     return false
  719.   end

  720.   # repeat
  721.   def repeat?(constant)
  722.     return true if falcao21_mouse_repeat?(constant)
  723.     unless Mouse.pos.nil?
  724.       if Mouse.input_keys.has_value?(constant)
  725.         mouse_trigger = Mouse.input_keys.index(constant)     
  726.         return true if Mouse.repeat?(mouse_trigger)
  727.       end
  728.     end
  729.     return false
  730.   end
  731. end

  732. # Here your best friend, you can call this script within the game, scene etc.
  733. # $game_arrows.create_arrows(x, y), create it, $game_arrows.dispose, delete it
  734. class Game_Arrow_Selector
  735.   attr_accessor :mode_on
  736.   attr_accessor :in_type
  737.   def initialize
  738.     @mode_on = false
  739.   end

  740.   def create_arrows(x, y)
  741.     return unless @arrows_sprites.nil?
  742.     buttons = {1=> 'UP', 2=> 'RIGHT', 3=> 'DOWN',
  743.     4=> 'LEFT', 5=> 'OK', 6=> 'Cancel'}
  744.     @arrows_sprites = []
  745.     for i in buttons.values
  746.       @arrows_sprites.push(Garrows_Sprites.new(i, x, y))
  747.     end
  748.   end

  749.   def dispose
  750.     return if @arrows_sprites.nil?
  751.     for arrow in @arrows_sprites
  752.       arrow.dispose
  753.     end
  754.     @arrows_sprites = nil
  755.     @mode_on = false
  756.   end

  757.   def update
  758.     return if @arrows_sprites.nil?
  759.     for arrow in @arrows_sprites
  760.       arrow.update
  761.     end
  762.   end
  763. end

  764. class Garrows_Sprites < Sprite
  765.   def initialize(name, x, y)
  766.     super()
  767.     self.z = 1000
  768.     @px, @py = x, y
  769.     @name = name
  770.     @object_zooming = 0
  771.     @zooming = false
  772.     set_bitmap
  773.     update
  774.   end

  775.   def update
  776.     super
  777.     if Mouse.object_area?(self.x + @fix[0], self.y + @fix[1],
  778.       self.bitmap.width + @fix[2], self.bitmap.height + @fix[3])
  779.       $game_arrows.mode_on = true
  780.       $game_arrows.in_type = Input::UP    if @name == 'UP'
  781.       $game_arrows.in_type = Input::DOWN  if @name == 'DOWN'
  782.       $game_arrows.in_type = Input::LEFT  if @name == 'LEFT'
  783.       $game_arrows.in_type = Input::RIGHT if @name == 'RIGHT'
  784.       $game_arrows.in_type = Input::B     if @name == 'OK'
  785.       $game_arrows.in_type = Input::C     if @name == 'Cancel'
  786.       @object_zooming += 1
  787.       @zooming = true
  788.       case @object_zooming
  789.       when 1..10  ; self.zoom_x -= 0.01 ;  self.zoom_y -= 0.01
  790.       when 11..20 ; self.zoom_x += 0.01 ;  self.zoom_y += 0.01
  791.       when 21..30 ; self.zoom_x = 1.0   ;  self.zoom_y = 1.0
  792.         @object_zooming = 0
  793.       end
  794.     elsif @object_zooming > 0
  795.       self.zoom_x = 1.0
  796.       self.zoom_y = 1.0
  797.       @object_zooming = 0
  798.     elsif @zooming
  799.       @zooming = false
  800.       $game_arrows.mode_on = false
  801.     end
  802.   end

  803.   def set_bitmap
  804.     self.bitmap = Bitmap.new(24, 15) if @name != 'Cancel'
  805.     case @name
  806.     when 'UP'
  807.       self.x = @px + 25 ; self.y = @py - 2
  808.       self.angle = 182  ; @fix = [-23, -18, 0,  0]
  809.     when 'DOWN'
  810.       self.x = @px + 1 ; self.y = @py + 26
  811.       @fix = [0, -4, 0,  0]
  812.     when 'LEFT'
  813.       self.x = @px      ; self.y = @py + 1
  814.       self.angle = - 92 ; @fix = [-14, -4, - 9,  9]
  815.     when 'RIGHT'
  816.       self.x = @px + 26  ; self.y = @py + 26
  817.       self.angle = + 92  ; @fix = [0, - 26, - 9,  9]
  818.     when 'OK'
  819.       self.x = @px + 1  ; self.y = @py + 6
  820.       @fix = [0, -4, 0,  0]
  821.       self.bitmap.font.size = 20
  822.       self.bitmap.draw_text(4, -7, self.bitmap.width, 32, @name)
  823.       return
  824.     when 'Cancel'
  825.       self.x = @px - 11  ; self.y = @py + 42
  826.       @fix = [0, -4, 0,  0]
  827.       self.bitmap = Bitmap.new(50, 15)
  828.       self.bitmap.font.size = 20
  829.       self.bitmap.draw_text(2, -7, self.bitmap.width, 32, @name)
  830.       return
  831.     end
  832.     draw_crappy_triangle(0, 0)
  833.   end

  834.   # This method create a crappy triangle pointing down
  835.   def draw_crappy_triangle(px, py)
  836.     color = Color.new(192, 224, 255, 255)
  837.     x, y, w, =  0, 4, 24
  838.     self.bitmap.fill_rect(px + 1, py, 22, 1, color)
  839.     self.bitmap.fill_rect(px,     py + 1, 24, 4, color)
  840.     for i in 1..10
  841.       x += 1; y += 1; w -= 2
  842.       self.bitmap.fill_rect(px + x, py + y,       w, 1, color)
  843.     end
  844.   end
  845. end

  846. $game_arrows = Game_Arrow_Selector.new

  847. # Arrow selector is displayed when Input number is on
  848. class Game_Interpreter
  849.   alias falcao_setup_num_input setup_num_input
  850.   def setup_num_input(params)
  851.     falcao_setup_num_input(params)
  852.     $game_arrows.create_arrows(256, 194) if $game_message.position == 0
  853.     $game_arrows.create_arrows(256, 340) if $game_message.position == 1
  854.     $game_arrows.create_arrows(256, 180) if $game_message.position == 2
  855.   end
  856. end

  857. # Arrow selector is disposed when press ok
  858. class Window_NumberInput < Window_Base
  859.   alias falcao_process_ok process_ok
  860.   def process_ok
  861.     falcao_process_ok
  862.     $game_arrows.dispose
  863.   end
  864. end

  865. # WASD Movements
  866. module Input
  867.   class << self
  868.     if !method_defined?('vxe_dir4')
  869.       alias vxace_dir4 dir4
  870.     end
  871.     def dir4
  872.       if Map_Buttons::WASD_Movement
  873.         return 2 if (Input.press?(Input::Y))
  874.         return 4 if (Input.press?(Input::X))
  875.         return 6 if (Input.press?(Input::Z))
  876.         return 8 if (Input.press?(Input::R))
  877.       end
  878.       return vxace_dir4
  879.     end
  880.   end
  881. end

  882. # If event start with mouse
  883. class Game_Player < Game_Character
  884.   alias falcao_start_map_event start_map_event
  885.   def start_map_event(x, y, triggers, normal)
  886.     $game_map.events_xy(x, y).each do |event_click|
  887.       return if event_click.check_comment("MOUSE START")
  888.     end  
  889.     falcao_start_map_event(x, y, triggers, normal)
  890.   end
  891. end

  892. # clear pointers when tranfering
  893. class Game_Player < Game_Character
  894.   attr_accessor :clear_mousepointers
  895.   alias falcaomouse_perform_transfer perform_transfer
  896.   def perform_transfer
  897.     @clear_mousepointers = true if $game_map.map_id !=  @new_map_id
  898.     falcaomouse_perform_transfer
  899.   end
  900. end

  901. # Path find
  902. class Game_Character < Game_CharacterBase
  903.   attr_accessor :map, :runpath
  904.   alias pathfind1_ini initialize
  905.   def initialize
  906.     pathfind1_ini
  907.     @map = nil
  908.     @runpath = false
  909.   end

  910.   alias pathfind1_up update
  911.   def update
  912.     run_path if @runpath == true
  913.     pathfind1_up
  914.   end

  915.   def run_path
  916.     return if moving?
  917.     step = @map[@x,@y]
  918.     if step == 1
  919.       @map = nil
  920.       @runpath = false
  921.       return
  922.     end
  923.     dir = rand(2)
  924.     case dir
  925.     when 0
  926.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  927.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  928.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  929.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  930.     when 1
  931.       move_straight(8) if @map[@x,@y-1] == step - 1 && step != 0
  932.       move_straight(4) if @map[@x-1,@y] == step - 1 && step != 0
  933.       move_straight(2) if @map[@x,@y+1] == step - 1 && step != 0
  934.       move_straight(6) if @map[@x+1,@y] == step - 1 && step != 0
  935.     end
  936.   end

  937.   def find_path(x,y)
  938.     sx, sy = @x, @y
  939.     result = setup_map(sx,sy,x,y)
  940.     @runpath = result[0]
  941.     @map = result[1]
  942.     @map[sx,sy] = result[2] if result[2] != nil
  943.   end

  944.   def clear_path
  945.     @map = nil
  946.     @runpath = false
  947.   end

  948.   def setup_map(sx,sy,ex,ey)
  949.     map = Table.new($game_map.width, $game_map.height)
  950.     map[ex,ey] = 1
  951.     old_positions = []
  952.     new_positions = []
  953.     old_positions.push([ex, ey])
  954.     depth = 2
  955.     depth.upto(100){|step|
  956.       loop do
  957.         break if old_positions[0] == nil
  958.         x,y = old_positions.shift
  959.         return [true, map, step] if x == sx and y+1 == sy
  960.         if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
  961.           map[x,y + 1] = step
  962.           new_positions.push([x,y + 1])
  963.         end
  964.         return [true, map, step] if x-1 == sx and y == sy
  965.         if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
  966.           map[x - 1,y] = step
  967.           new_positions.push([x - 1,y])
  968.         end
  969.         return [true, map, step] if x+1 == sx and y == sy
  970.         if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
  971.           map[x + 1,y] = step
  972.           new_positions.push([x + 1,y])
  973.         end
  974.         return [true, map, step] if x == sx and y-1 == sy
  975.         if $game_player.passable?(x, y, 8) and map[x,y - 1] == 0
  976.           map[x,y - 1] = step
  977.           new_positions.push([x,y - 1])
  978.         end
  979.       end
  980.       old_positions = new_positions
  981.       new_positions = []
  982.     }
  983.     return [false, nil, nil]
  984.   end
  985. end

  986. class Game_Player
  987.   alias pathfind_player_update update
  988.   def update
  989.     clear_path if Input.dir4 != 0
  990.     pathfind_player_update
  991.   end

  992.   alias findpath_perform_transfer perform_transfer
  993.   def perform_transfer
  994.     clear_path if $game_map.map_id !=  @new_map_id
  995.     findpath_perform_transfer
  996.   end
  997. end

  998. # Window selectable (Thanks wora for some lines here)
  999. class Window_Selectable < Window_Base
  1000.   alias mouse_selection_ini initialize
  1001.   def initialize(*args)
  1002.     mouse_selection_ini(*args)
  1003.     @scroll_wait = 0
  1004.     @cursor_wait = 0
  1005.     @sdelay = 0
  1006.   end

  1007.   alias mouse_selection_update update
  1008.   def update
  1009.     update_mouse_selection if self.active and self.visible
  1010.     @sdelay -= 1 if @sdelay > 0
  1011.     mouse_selection_update
  1012.   end

  1013.   def update_mouse_selection
  1014.     @cursor_wait -= 1 if @cursor_wait > 0
  1015.     plus_x = self.x + 16 - self.ox
  1016.     plus_y = self.y + 8 - self.oy
  1017.     unless self.viewport.nil?
  1018.       plus_x += self.viewport.rect.x - self.viewport.ox
  1019.       plus_y += self.viewport.rect.y - self.viewport.oy
  1020.     end
  1021.     (0..self.item_max - 1).each do |i|
  1022.       irect = item_rect(i)
  1023.       move_cursor(i) if Mouse.object_area?(
  1024.       irect.x + plus_x, irect.y + plus_y, irect.width, irect.height)
  1025.       update_cursor
  1026.     end
  1027.   end

  1028.   def move_cursor(index)
  1029.     return if @index == index
  1030.     @scroll_wait -= 1 if @scroll_wait > 0
  1031.     row1 = @index / self.col_max
  1032.     row2 = index / self.col_max
  1033.     bottom = self.top_row + (self.page_row_max - 1)
  1034.     if index != @index and @sdelay == 0
  1035.       Sound.play_cursor
  1036.       @sdelay = 5
  1037.     end
  1038.     if row1 == self.top_row and row2 < self.top_row
  1039.       return if @scroll_wait > 0
  1040.       @index = [@index - self.col_max, 0].max
  1041.       @scroll_wait = 30
  1042.     elsif row1 == bottom and row2 > bottom
  1043.       return if @scroll_wait > 0
  1044.       @index = [@index + self.col_max, self.item_max - 1].min
  1045.       @scroll_wait = 30
  1046.     else
  1047.       @index = index
  1048.     end
  1049.     select(@index)
  1050.     return if @cursor_wait > 0
  1051.     @cursor_wait += 2
  1052.   end
  1053. end


  1054. class Window_NameInput
  1055.   def item_max
  1056.     return 90
  1057.   end
  1058. end

  1059. class Scene_File < Scene_MenuBase

  1060.   alias mouse_top_index top_index=
  1061.   def top_index=(index)
  1062.     @scroll_timer = 0 if @scroll_timer.nil? ; @scroll_timer -= 1
  1063.     return if @scroll_timer > 0
  1064.     mouse_top_index(index) ; @scroll_timer = 35
  1065.   end

  1066.   alias mouse_sb_update update
  1067.   def update
  1068.     (0..self.item_max - 1).each do |i|
  1069.       ix = @savefile_windows[i].x
  1070.       iy = @savefile_windows[i].y + 40 - @savefile_viewport.oy
  1071.       iw = @savefile_windows[i].width
  1072.       ih = @savefile_windows[i].height
  1073.       if Mouse.object_area?(ix, iy, iw, ih)
  1074.         @savefile_windows[@index].selected = false
  1075.         @savefile_windows[i].selected = true
  1076.         @index = i
  1077.       end
  1078.       ensure_cursor_visible
  1079.     end
  1080.     mouse_sb_update
  1081.   end
  1082. end
复制代码
没事的过来瞄一眼,有事的也过来瞄一眼...群组,XAS PS VA
http://rpg.blue/forum.php?mod=group&fid=537
XAS探索目录:http://rpg.blue/home.php?mo ... o=blog&id=12595
如果有人对你说,你如此帅气(美丽),你要分三个角度去想:
1.就像妈妈对你说:“你如此帅气(美丽)。”(安慰)
2.就像女(男)朋友对你说:“你如此帅气(美丽)”(欺瞒)
3.就像乞丐对你说:“你如此帅气(美丽)”(讨好)
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-26 16:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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