//  SuperTuxKart - a fun racing game with go-kart
//  Copyright (C) 2009-2015 Marianne Gagnon
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 3
//  of the License, or (at your option) any later version.
//
//  This program 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 General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


#include "state_manager.h"


#include "../config/stk_config.h"
#include "../graphics/irr_driver.h"
#include "../guiengine/engine.h"
#include "../guiengine/modaldialog.h"
#include "../guiengine/screen.h"
#include "../input/input_device.h"
#include "../input/input_manager.h"
#include "../main_loop.h"
#include "../utils/log.h"

using namespace GUIEngine;

static StateManager* state_manager_singleton = NULL;

StateManager* StateManager::get()
{
    if (state_manager_singleton == NULL)
        state_manager_singleton = new StateManager();
    return state_manager_singleton;
}   // get

void StateManager::deallocate()
{
    delete state_manager_singleton;
    state_manager_singleton = NULL;
}   // deallocate


// ============================================================================

#if 0
#pragma mark -
#pragma mark Player Management
#endif




// ----------------------------------------------------------------------------

#if 0
#pragma mark -
#pragma mark misc stuff
#endif

bool StateManager::throttleFPS()
{
    return m_game_mode != GUIEngine::GAME  &&
           GUIEngine::getCurrentScreen()->throttleFPS();
}   // throttleFPS

// ----------------------------------------------------------------------------

void StateManager::escapePressed()
{
    // in input sensing mode

    // when another modal dialog is visible
    if(ModalDialog::isADialogActive())
    {
        if(ModalDialog::getCurrent()->onEscapePressed())
            ModalDialog::getCurrent()->dismiss();
    }
    else
    {
        if (getCurrentScreen() != NULL &&
            getCurrentScreen()->onEscapePressed()) popMenu();
    }
}   // escapePressed

// ----------------------------------------------------------------------------

void StateManager::onGameStateChange(GameState new_state)
{
    irr_driver->showPointer();
    input_manager->setMode(InputManager::MENU);

    if (new_state == MENU)
        {
        GUIEngine::Screen* screen = GUIEngine::getCurrentScreen();
        }



}   // onGameStateChange

// ----------------------------------------------------------------------------

void StateManager::onTopMostScreenChanged()
{


}



// ----------------------------------------------------------------------------

void StateManager::onStackEmptied()
{
    GUIEngine::cleanUp();
    GUIEngine::deallocate();
    main_loop->abort();
}   // onStackEmptied

// ============================================================================

#if 0
#pragma mark -
#pragma mark ActivePlayer
#endif







