Advertisement
Black_Mage

VLUE Basic Mouse Script Compatibility Fix

Apr 11th, 2021 (edited)
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.16 KB | None | 0 0
  1. #==============================================================================
  2. module BLACK
  3.   # There's a hidden window on the game menu that corresponds with the mouse
  4.   # highlight system. The setting below can be used to customize said window.
  5.   #
  6.   #                     x, y, option height, option width
  7.   MOUSE_MENU_SETTING = [0, 0,            34,         236]
  8.  
  9.   # We list the scene where we don't want the mouse to be active inside this
  10.   # array. Note that the scene name is case sensitive.
  11.   MOUSE_BLACKLIST = [
  12.                       'Scene_System',
  13.                       'Scene_Save'
  14.                     ]
  15.  
  16.   # This determines how far the least distance of swiping should be before it
  17.   # triggers the swipe function.
  18.   MINIMUM_SWIPE = 100
  19.  
  20. end
  21. #==============================================================================
  22.  
  23. #------------------------------------------------------------------------------
  24. # * Beyond this is the sacred land of code. You need programming qualification
  25. #   to dwelve deeper, or it'll cause many unnecessary problems. Proceed on your
  26. #   own risk.
  27. #------------------------------------------------------------------------------
  28.  
  29. #==============================================================================
  30. # Fix a crash on File Scene
  31. #==============================================================================
  32. # Make the mouse_input method does nothing to avoid crash.
  33. class Scene_File < Scene_MenuBase; def mouse_input; end; end
  34. #==============================================================================
  35.  
  36.  
  37. #==============================================================================
  38. # Add sounds when switching between choices.
  39. #==============================================================================
  40. class Window_Selectable
  41.   alias b_up_mo update_mouse
  42.   def update_mouse
  43.     last_index = @index; b_up_mo; Sound.play_cursor if @index != last_index
  44.   end
  45. end
  46. #==============================================================================
  47.  
  48.  
  49. #==============================================================================
  50. # Fix the in-game menu mouse offset.
  51. #==============================================================================
  52. class Scene_Menu < Scene_MenuBase
  53.   alias b_ms_ccw create_command_window
  54.   def create_command_window
  55.     b_ms_ccw
  56.     @command_window.x = BLACK::MOUSE_MENU_SETTING[0]
  57.     @command_window.y = BLACK::MOUSE_MENU_SETTING[1]
  58.   end
  59. end
  60.  
  61. class Window_MenuCommand < Window_Command
  62.   def item_height; BLACK::MOUSE_MENU_SETTING[2]; end
  63.   def window_width; BLACK::MOUSE_MENU_SETTING[3]; end
  64.   def window_height
  65.     visible_line_number * item_height + standard_padding * 2
  66.   end
  67. end
  68. #==============================================================================
  69.  
  70.  
  71. #==============================================================================
  72. # Made the mouse always appears on the screen.
  73. # Disable the mouse on certain scenes.
  74. #==============================================================================
  75. module Mouse
  76.  
  77.   # Create an alias to always update cursor position.
  78.   class << self
  79.     alias b_update update
  80.     def update
  81.       self.update_cursor_pos
  82.       #p SceneManager.scene.class.name
  83.       return false if BLACK::MOUSE_BLACKLIST.include?(SceneManager.scene.class.name)
  84.       b_update
  85.     end
  86.   end
  87.  
  88.   # New method to update cursor position.
  89.   def self.update_cursor_pos
  90.     @window_loc = WINX.call(0,0,"RGSS PLAYER",0)
  91.     rect = '0000000000000000'
  92.     cursor_pos = '00000000'
  93.     WREC.call(@window_loc, rect)
  94.     side, top = rect.unpack("ll")
  95.     CPOS.call(cursor_pos)
  96.     @m_x, @m_y = cursor_pos.unpack("ll")
  97.     w_x = side + SMET.call(5) + SMET.call(45)
  98.     w_y = top + SMET.call(6) + SMET.call(46) + SMET.call(4)
  99.     @m_x -= w_x; @m_y -= w_y
  100.     if MOUSE_KEEP_WINDOW
  101.       @m_x = [[@m_x, 0].max,Graphics.width-5].min
  102.       @m_y = [[@m_y, 0].max,Graphics.height-5].min
  103.     end
  104.   end  
  105.  
  106.   # Overwrite pos? method.
  107.   def self.pos?; return [@m_x, @m_y]; end
  108.    
  109. end
  110.  
  111. # Make the scene always update the mouse.
  112. class Scene_Base
  113.   alias b_m_c mouse_cursor; def mouse_cursor; Mouse.update; b_m_c; end
  114. end
  115. #==============================================================================
  116.  
  117.  
  118. #==============================================================================
  119. # Make a swipe function on relationship menu.
  120. # Add right click function to relationship menu.
  121. #==============================================================================
  122. class Scene_CharacterStats < Scene_MenuBase
  123.   alias mouse_update update
  124.   def update; mouse_update; update_mouse; end
  125.   def update_mouse
  126.     @swipe_pos = Mouse.pos? if !Mouse.lclick?.nil? && @swipe_pos.nil?
  127.     if Mouse.lclick?.nil? && !@swipe_pos.nil?
  128.       dist = @swipe_pos[0] - Mouse.pos?[0]
  129.       @swipe_pos = nil
  130.       return if dist.abs <= BLACK::MINIMUM_SWIPE
  131.       # When dist is positive, it means the mouse swiped to the left.
  132.       if dist < 0
  133.         Sound.play_cursor
  134.         @index += 1
  135.         if @index == $game_system.character_list.size
  136.           @index = 0
  137.         end
  138.         @character = CharacterStats::CONFIG[$game_system.character_list[@index]]
  139.         dispose_dynamic_sprites
  140.         create_dynamic_sprites
  141.       else
  142.         Sound.play_cursor
  143.         @index -= 1
  144.         if @index == -1
  145.           @index = $game_system.character_list.size - 1
  146.         end
  147.         @character = CharacterStats::CONFIG[$game_system.character_list[@index]]
  148.         dispose_dynamic_sprites
  149.         create_dynamic_sprites
  150.       end
  151.     end
  152.     (Sound.play_cancel; return_scene) if Mouse.rclick?
  153.   end
  154. end
  155. #==============================================================================
  156.  
  157.  
  158. #==============================================================================
  159. # Add right click function to Scene_NewStatusMenu.
  160. #==============================================================================
  161. class Scene_NewStatusMenu < Scene_Base
  162.   alias mouse_update update
  163.   def update; mouse_update; update_mouse; end
  164.   def update_mouse; (Sound.play_cancel; return_scene) if Mouse.rclick?; end
  165. end
  166. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement