brandondevito

Fillscreen ++ fix for Falcoar's Mouse Events (RMVX Ace)

Aug 17th, 2014
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ICON = {'arrow' => 386, 'talk' => 0, 'look' => 3, 'fight' => 116,
  3. 'touch' => 491, 'exit' => 121}
  4. DEFAULT_ICON = 'talk'
  5.  
  6. class Sprite_Mouse < Sprite
  7. #--------------------------------------------------------------------------
  8. # * Initialization
  9. #--------------------------------------------------------------------------
  10. def initialize
  11. super
  12. self.z = 10100
  13. self.ox = 4
  14. update
  15. @dummy = Bitmap.new(32, 32)
  16. self.bitmap = Bitmap.new(32, 32)
  17. @enabled = false
  18. @ignored = false
  19. end
  20.  
  21. #--------------------------------------------------------------------------
  22. # * Enable Mouse
  23. #--------------------------------------------------------------------------
  24. def enabled=(value)
  25. @enabled = value
  26. self.visible = value
  27. end
  28. #--------------------------------------------------------------------------
  29. # * Mouse Enabled?
  30. #--------------------------------------------------------------------------
  31. def enabled?
  32. @enabled
  33. end
  34. #--------------------------------------------------------------------------
  35. # * Ignore Mouse
  36. #--------------------------------------------------------------------------
  37. def ignored=(value)
  38. @ignored = value
  39. end
  40. #--------------------------------------------------------------------------
  41. # * Mouse Ignored?
  42. #--------------------------------------------------------------------------
  43. def ignored?
  44. @ignored
  45. end
  46. end
  47.  
  48. $mouse = Sprite_Mouse.new
  49.  
  50.  
  51. #==============================================================================
  52. # ** Mouse Module
  53. #------------------------------------------------------------------------------
  54. # by Near Fantastica and SephirothSpawn
  55. # adapted and converted to VX Ace by Shaz
  56. #==============================================================================
  57. module Mouse
  58. #--------------------------------------------------------------------------
  59. # * Mouse to Input Triggers
  60. # key => Input::KeyCONSTANT (key: 0 - left, 1 - middle, 2 - right)
  61. #--------------------------------------------------------------------------
  62. Mouse_to_Input_Triggers = {0 => Input::C, 1 => Input::B, 2 => Input::A}
  63. #--------------------------------------------------------------------------
  64. # * API Declarations
  65. #--------------------------------------------------------------------------
  66. GAKS = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  67. GSM = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
  68. Cursor_Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
  69. Scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
  70. Client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
  71. Findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
  72. Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
  73. ShowCursor = Win32API.new('user32', 'ShowCursor', 'i', 'l')
  74. #--------------------------------------------------------------------------
  75. # * Module Variables
  76. #--------------------------------------------------------------------------
  77. @triggers = [[0, 1], [0, 2], [0, 4]]
  78. @old_pos = 0
  79. @pos_i = 0
  80. @sys_cursor_visible = false
  81.  
  82. #--------------------------------------------------------------------------
  83. # * Screen to Client
  84. #--------------------------------------------------------------------------
  85. def self.screen_to_client(x=0, y=0)
  86. pos = [x, y].pack('ll')
  87. return Scr2cli.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
  88. end
  89. #--------------------------------------------------------------------------
  90. # * Mouse Position
  91. #--------------------------------------------------------------------------
  92. def self.pos
  93. gx, gy = global_pos
  94. x, y = screen_to_client(gx, gy)
  95.  
  96. # Test boundaries
  97. begin
  98. if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
  99. return x, y
  100. else
  101. return -20, -20
  102. end
  103. rescue
  104. return 0, 0
  105. end
  106. end
  107.  
  108. #--------------------------------------------------------------------------
  109. # * Trigger?
  110. # id : 0:Left, 1:Right, 2:Center
  111. #--------------------------------------------------------------------------
  112. def self.trigger?(id = 0)
  113. if pos != [-20, -20]
  114. return @triggers[id][0] == 1
  115. end
  116. return false
  117. end
  118. #--------------------------------------------------------------------------
  119. # * Repeat?
  120. # id : 0:Left, 1:Right, 2:Center
  121. #--------------------------------------------------------------------------
  122.  
  123. #--------------------------------------------------------------------------
  124. # * Hwnd NEEDED
  125. #--------------------------------------------------------------------------
  126. def self.hwnd
  127. if @hwnd.nil?
  128. title = "\0" * 256
  129. Readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')
  130. title.delete!("\0")
  131. @hwnd = Findwindow.call('RGSS Player', title)
  132. ShowCursor.call(0)
  133. end
  134. return @hwnd
  135. end
  136.  
  137. #============================================================================
  138. # SUPER SIMPLE MOUSE SCRIPT
  139. # Input
  140. #============================================================================
  141.  
  142. class << Input
  143. #--------------------------------------------------------------------------
  144. # * Public Instance Variables
  145. #--------------------------------------------------------------------------
  146. attr_accessor :method
  147. #--------------------------------------------------------------------------
  148. # * Alias Listings
  149. #--------------------------------------------------------------------------
  150. alias :seph_mouse_input_update :update
  151. alias :seph_mouse_input_trigger? :trigger?
  152. alias :seph_mouse_input_repeat? :repeat?
  153.  
  154. #============================================================================
  155. # SUPER SIMPLE MOUSE SCRIPT
  156. # Windows
  157. #============================================================================
  158.  
  159. class Scene_File < Scene_MenuBase
  160. end
  161. end
  162. end
RAW Paste Data