#include ".\gamestate.h"


CGameState::CGameState() :
  m_ButtonUnderMouse( -1 ),
  m_ButtonReleased( false )
{
}

CGameState::~CGameState(void)
{
}



bool CGameState::HandleButton( int iX, int iY, int iButtons, int X, int Y, int W, int H, int Button )
{

  if ( ( iX >= X )
  &&   ( iX < X + W )
  &&   ( iY >= Y )
  &&   ( iY < Y + H ) )
  {
    if ( iButtons & 1 )
    {
      if ( m_ButtonReleased )
      {
        m_ButtonUnderMouse = Button;
      }
    }
    else
    {
      if ( m_ButtonUnderMouse == Button )
      {
        m_ButtonUnderMouse = -1;
        return true;
      }
      m_ButtonUnderMouse = -1;
    }
  }
  else
  {
    if ( m_ButtonUnderMouse == Button )
    {
      m_ButtonUnderMouse = -1;
    }
    return false;
  }
  return false;

}