RMParadise

It seems you either have yet to login or are not a member of RMP. If you are not yet a member, please feel free to sign up so that you can unlock every feature our forums have to offer. If you have yet to login, please do so soon.

Join the forum, it's quick and easy

RMParadise

It seems you either have yet to login or are not a member of RMP. If you are not yet a member, please feel free to sign up so that you can unlock every feature our forums have to offer. If you have yet to login, please do so soon.

RMParadise

Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Paradise for RPGMakers.

Welcome everyone to RMP, your very own RPGMaker Paradise.
If you are reading this, that means that you are one of the select few who have been invited to experience our site as a Beta User.
Being a Beta User only requires that you report any bugs and/or problems upon finding them.
You get the chance to have free roam over the boards before they are public and are further up in line for promotions (which will be happening very soon, so stay on your best behavior).
Check out the thread for the RMP Beta Contest. Lets get some new content rolling.
Chat
Back to Top

2 posters

    Basic Mouse System + Addons

    Vlue
    Vlue
    I'm a new member :)
    I'm a new member :)


    Registered on Registered on : 2012-05-28
    Posts Posts : 30
    Rep. Points Rep. Points : 13

    Basic Mouse System + Addons Empty Basic Mouse System + Addons

    Post by Vlue Thu May 31, 2012 2:44 pm

    Basic Mouse System + Addons v1.0
    By V.M.


    Introduction
    Adds mouse functionality! Alone it does nothing but I'll be adding more addons over time.
    Current addons:
    Mouse Movement
    Mouse Battle
    Mouse Title/File
    Mouse Menu
    Mouse Shop
    Mouse Name
    Mouse Map
    Mouse Cursor

    How to Use
    Plug and play!
    It's all been moderately tested to moderately work moderately.

    Script
    All the scripts in one big pastebin for those lazy folk out there (me included :D) - RMVXACE MOUSE
    Main Script:
    Code:
    #Basic Mouse System
    #----------#
    #Features: Provides a series of functions to find the current x, y position of
    #          the mouse and whether it is being clicked or not (left or right click)
    #
    #Usage:  Script calls:
    #          Mouse.pos?  - returns the x, y position as an array
    #          Mouse.lclick?(repeat) - returns if left click is achieved
    #                                  repeat = true for repeated checks
    #          Mouse.rclick?(repeat) - same as above for right click
    #          Mouse.within?(rect) - passes a Rect through to check if cursor
    #                                is within it, returns true if so
    #
    #No Customization
    #
    #----------#
    #-- Script by: V.M of D.T
    #--- Free to use in any non-commercial project with credit given

    CPOS = Win32API.new 'user32', 'GetCursorPos', ['p'], 'v'
    WINX = Win32API.new 'user32', 'FindWindowEx', ['l','l','p','p'], 'i'
    ASKS = Win32API.new 'user32', 'GetAsyncKeyState', ['p'], 'i'
    SMET = Win32API.new 'user32', 'GetSystemMetrics', ['i'], 'i'
    WREC = Win32API.new 'user32', 'GetWindowRect', ['l','p'], 'v'

    module Mouse
      def self.setup
        @delay = 0
        bwap = true if SMET.call(23) != 0
        bwap ? @lmb = 0x02 : @lmb = 0x01
        bwap ? @rmb = 0x01 : @rmb = 0x02
      end
      def self.update
        self.setup if @lmb.nil?
        @delay -= 1
        @window_loc = WINX.call(0,0,"RGSS PLAYER",0)
        if ASKS.call(@lmb) == 0 then @l_clicked = false end
        if ASKS.call(@rmb) == 0 then @r_clicked = false end
        rect = '0000000000000000'
        cursor_pos = '00000000'
        WREC.call(@window_loc, rect)
        side, top = rect.unpack("ll")
        CPOS.call(cursor_pos)
        @m_x, @m_y = cursor_pos.unpack("ll")
        w_x = side + SMET.call(5) + SMET.call(45)
        w_y = top + SMET.call(6) + SMET.call(46) + SMET.call(4)
        @m_x -= w_x; @m_y -= w_y
      end
      def self.pos?
        self.update
        return [@m_x, @m_y]
      end
      def self.lclick?(repeat = false)
        self.update
        return false if @l_clicked
        if ASKS.call(@lmb) != 0 then
          @l_clicked = true if !repeat
          return true end
      end
      def self.rclick?(repeat = false)
        self.update
        return false if @r_clicked
        if ASKS.call(@rmb) != 0 then
          @r_clicked = true if !repeat
          return true end
      end
      def self.slowpeat
        self.update
        return false if @delay > 0
        @delay = 120
        return true
      end
      def self.within?(rect)
        self.update
        return false if @m_x < rect.x or @m_y < rect.y
        bound_x = rect.x + rect.width; bound_y = rect.y + rect.height
        return true if @m_x < bound_x and @m_y < bound_y
        return false
      end
    end

    Addons:
    Spoiler:

    FAQ
    Q. Can I throw money at you?
    A. Yes, yes you may.

    Credit and Thanks
    - By V.M. of D.T
    - Free to use in any non-commercial game with credit given
    - Thanks to the well documented MSDN for the Win32API calls x.x

    Author's Notes
    Huff.. de luff...
    I like this one

    History
    Cursor v1.0 - Addon added
    Title/File v 1.1 - Added mouse click to gameover screen
    Menu Screen v1.1 - Edited to work with Mouse Map Addon
    Map v1.0 - Addon added
    Name v1.0 - Addon added
    Shop v1.0 - Addon added
    Menu Screen v1.0 - Addon added
    Title/File v1.0 - Addon added
    Movement v1.1 - Fixed bug allowing movement at odd times
    Hyde
    Hyde
    Administrator
    Administrator


    Registered on Registered on : 2012-05-18
    Posts Posts : 101
    Rep. Points Rep. Points : 6

    Basic Mouse System + Addons Empty Re: Basic Mouse System + Addons

    Post by Hyde Thu May 31, 2012 7:12 pm

    Ooooohh... Very nice. I personally love the fact that a mouse can be used with Ace. It just feels awkward to me having a computer game without any use of the mouse, and you fixed that for us. I will have to use this sometime.

      Current date/time is Wed May 15, 2024 12:48 am