//  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.

#define DEBUG_MENU_ITEM 0

#include "main_menu_screen.h"





#include "../config/user_config.h"
#include "../graphics/irr_driver.h"
#include "../guiengine/scalable_font.h"
#include "../guiengine/widgets/label_widget.h"

#include "../input/device_manager.h"
#include "../input/input_manager.h"
#include "../input/keyboard_device.h"
#include "../io/file_manager.h"
#include "../main_loop.h"




#include "state_manager.h"
#include "map_selection_screen.h"


#include "../utils/string_utils.h"



#include <string>


using namespace GUIEngine;

DEFINE_SCREEN_SINGLETON( MainMenuScreen );

bool MainMenuScreen::m_enable_online = false;

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

MainMenuScreen::MainMenuScreen() : Screen("main.lsgui")
{
}   // MainMenuScreen

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

void MainMenuScreen::loadedFromFile()
{



}   // loadedFromFile

// ----------------------------------------------------------------------------
//
void MainMenuScreen::init()
{
    Screen::init();



    // reset in case we're coming back from a race
    input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
    input_manager->getDeviceManager()->setSinglePlayer( NULL );
    input_manager->setMasterPlayerOnly(false);

    // Avoid incorrect behaviour in certain race circumstances:
    // If a multi-player game is played with two keyboards, the 2nd
    // player selects his kart last, and only the keyboard is used
    // to select all other settings - then if the next time the kart
    // selection screen comes up, the default device will still be
    // the 2nd player. So if the first player presses 'select', it
    // will instead add a second player (so basically the key
    // binding for the second player become the default, so pressing
    // select will add a new player). See bug 3090931
    // To avoid this, we will clean the last used device, making
    // the key bindings for the first player the default again.
    input_manager->getDeviceManager()->clearLatestUsedDevice();



}   // init

// ----------------------------------------------------------------------------
void MainMenuScreen::onUpdate(float delta)

{


}   // onUpdate

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

void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
                                   const int playerID)
{

    if(name=="button_map")
    {

        MapSelectionScreen::getInstance()->push();
        return;
    }

}   // eventCallback

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

void MainMenuScreen::tearDown()
{
}   // tearDown

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

void MainMenuScreen::onDisabledItemClicked(const std::string& item)
{

}   // onDisabledItemClicked
