Report abuse


			
#  rbGooey. -- Game GUI library to be used with rubygame
#  Copyright (C) 2006  Han 'kiba' Dao
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#This class is for mouse queue event designed for the purpose of click and and point.

#Use this classs only if you do not need to change the class to suit your own need. Otherwise, code your own queue event.
class MQueue
  attr_accessor :activate , :mouse
  def initialize event , main , text
    @q = Rubygame::Queue.instance
    @main = main
    @mouse = mouse
    @event = event
    @name
    @text = text
    @activate = false
    setup
  end
  def setup
    @mouse = Mouse_input.new
  end
  def queue text , name
    @text = text
    @name = name
    while 1
      @main.screen.flip
      @q.get.each do |event|
        mevent(event)
        case event
          when Rubygame::KeyDownEvent
            case event.key
              when Rubygame::K_ESCAPE
                exit
            end
        end
      end
      if Integer === @activate
        @activate = false
        break
      end
    end
  end
  def mevent event
    case event
      when Rubygame::MouseMotionEvent
        @mouse.pos(event)
      when Rubygame::MouseDownEvent
        @activate = @mouse.check(@text.textsprite.rect)
        if Integer === @activate
          event
        end
    end
    @mouse.update
  end
  def event 
    @event.self_send_"#{@name}"
  end
end