Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ICON = {'arrow' => 386, 'talk' => 0, 'look' => 3, 'fight' => 116,
- 'touch' => 491, 'exit' => 121}
- DEFAULT_ICON = 'talk'
- class Sprite_Mouse < Sprite
- #--------------------------------------------------------------------------
- # * Initialization
- #--------------------------------------------------------------------------
- def initialize
- super
- self.z = 10100
- self.ox = 4
- update
- @dummy = Bitmap.new(32, 32)
- self.bitmap = Bitmap.new(32, 32)
- @enabled = false
- @ignored = false
- end
- #--------------------------------------------------------------------------
- # * Enable Mouse
- #--------------------------------------------------------------------------
- def enabled=(value)
- @enabled = value
- self.visible = value
- end
- #--------------------------------------------------------------------------
- # * Mouse Enabled?
- #--------------------------------------------------------------------------
- def enabled?
- @enabled
- end
- #--------------------------------------------------------------------------
- # * Ignore Mouse
- #--------------------------------------------------------------------------
- def ignored=(value)
- @ignored = value
- end
- #--------------------------------------------------------------------------
- # * Mouse Ignored?
- #--------------------------------------------------------------------------
- def ignored?
- @ignored
- end
- end
- $mouse = Sprite_Mouse.new
- #==============================================================================
- # ** Mouse Module
- #------------------------------------------------------------------------------
- # by Near Fantastica and SephirothSpawn
- # adapted and converted to VX Ace by Shaz
- #==============================================================================
- module Mouse
- #--------------------------------------------------------------------------
- # * Mouse to Input Triggers
- # key => Input::KeyCONSTANT (key: 0 - left, 1 - middle, 2 - right)
- #--------------------------------------------------------------------------
- Mouse_to_Input_Triggers = {0 => Input::C, 1 => Input::B, 2 => Input::A}
- #--------------------------------------------------------------------------
- # * API Declarations
- #--------------------------------------------------------------------------
- GAKS = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
- GSM = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
- Cursor_Pos = Win32API.new('user32', 'GetCursorPos', 'p', 'i')
- Scr2cli = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')
- Client_rect = Win32API.new('user32', 'GetClientRect', %w(l p), 'i')
- Findwindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
- Readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')
- ShowCursor = Win32API.new('user32', 'ShowCursor', 'i', 'l')
- #--------------------------------------------------------------------------
- # * Module Variables
- #--------------------------------------------------------------------------
- @triggers = [[0, 1], [0, 2], [0, 4]]
- @old_pos = 0
- @pos_i = 0
- @sys_cursor_visible = false
- #--------------------------------------------------------------------------
- # * Screen to Client
- #--------------------------------------------------------------------------
- def self.screen_to_client(x=0, y=0)
- pos = [x, y].pack('ll')
- return Scr2cli.call(self.hwnd, pos) == 0 ? nil : pos.unpack('ll')
- end
- #--------------------------------------------------------------------------
- # * Mouse Position
- #--------------------------------------------------------------------------
- def self.pos
- gx, gy = global_pos
- x, y = screen_to_client(gx, gy)
- # Test boundaries
- begin
- if (x >= 0 && y >= 0 && x <= Graphics.width && y <= Graphics.height)
- return x, y
- else
- return -20, -20
- end
- rescue
- return 0, 0
- end
- end
- #--------------------------------------------------------------------------
- # * Trigger?
- # id : 0:Left, 1:Right, 2:Center
- #--------------------------------------------------------------------------
- def self.trigger?(id = 0)
- if pos != [-20, -20]
- return @triggers[id][0] == 1
- end
- return false
- end
- #--------------------------------------------------------------------------
- # * Repeat?
- # id : 0:Left, 1:Right, 2:Center
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- # * Hwnd NEEDED
- #--------------------------------------------------------------------------
- def self.hwnd
- if @hwnd.nil?
- title = "\0" * 256
- Readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')
- title.delete!("\0")
- @hwnd = Findwindow.call('RGSS Player', title)
- ShowCursor.call(0)
- end
- return @hwnd
- end
- #============================================================================
- # SUPER SIMPLE MOUSE SCRIPT
- # Input
- #============================================================================
- class << Input
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :method
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias :seph_mouse_input_update :update
- alias :seph_mouse_input_trigger? :trigger?
- alias :seph_mouse_input_repeat? :repeat?
- #============================================================================
- # SUPER SIMPLE MOUSE SCRIPT
- # Windows
- #============================================================================
- class Scene_File < Scene_MenuBase
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment