2009-10-04 19:59:05 -04:00
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2015-03-29 20:31:42 -04:00
|
|
|
// Copyright (C) 2009-2015 Marianne Gagnon
|
2009-10-04 19:59:05 -04:00
|
|
|
//
|
|
|
|
// 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 "states_screens/help_screen_1.hpp"
|
|
|
|
|
2013-02-16 11:43:13 -05:00
|
|
|
#include "challenges/unlock_manager.hpp"
|
2014-02-09 16:57:16 -05:00
|
|
|
#include "config/player_manager.hpp"
|
2014-02-25 20:52:16 -05:00
|
|
|
#include "config/user_config.hpp"
|
2009-10-04 19:59:05 -04:00
|
|
|
#include "guiengine/widget.hpp"
|
2013-05-29 18:04:35 -04:00
|
|
|
#include "guiengine/widgets/list_widget.hpp"
|
2010-04-26 10:41:23 -04:00
|
|
|
#include "guiengine/widgets/ribbon_widget.hpp"
|
2013-02-16 11:43:13 -05:00
|
|
|
#include "input/device_manager.hpp"
|
|
|
|
#include "input/input_manager.hpp"
|
2014-10-25 08:09:00 -04:00
|
|
|
#include "input/keyboard_device.hpp"
|
2013-02-16 11:43:13 -05:00
|
|
|
#include "karts/kart_properties_manager.hpp"
|
|
|
|
#include "race/race_manager.hpp"
|
2010-08-14 21:15:19 -04:00
|
|
|
#include "states_screens/help_screen_2.hpp"
|
|
|
|
#include "states_screens/help_screen_3.hpp"
|
2010-09-19 15:22:43 -04:00
|
|
|
#include "states_screens/help_screen_4.hpp"
|
2016-10-28 03:47:36 -04:00
|
|
|
#include "states_screens/help_screen_5.hpp"
|
2009-10-04 19:59:05 -04:00
|
|
|
#include "states_screens/state_manager.hpp"
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2009-10-04 19:59:05 -04:00
|
|
|
using namespace GUIEngine;
|
|
|
|
|
2012-07-26 17:24:15 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2009-10-04 19:59:05 -04:00
|
|
|
HelpScreen1::HelpScreen1() : Screen("help1.stkgui")
|
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
} // HelpScreen1
|
2009-10-04 19:59:05 -04:00
|
|
|
|
2012-07-26 17:24:15 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2010-05-01 15:16:38 -04:00
|
|
|
void HelpScreen1::loadedFromFile()
|
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
} // loadedFromFile
|
2010-05-01 15:16:38 -04:00
|
|
|
|
2012-07-26 17:24:15 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2010-05-01 15:16:38 -04:00
|
|
|
|
2009-10-28 19:04:38 -04:00
|
|
|
void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const int playerID)
|
2009-10-04 19:59:05 -04:00
|
|
|
{
|
2013-02-16 11:43:13 -05:00
|
|
|
if (name == "startTutorial")
|
|
|
|
{
|
2016-01-10 15:58:30 -05:00
|
|
|
race_manager->setNumPlayers(1);
|
2013-02-16 11:43:13 -05:00
|
|
|
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
|
|
|
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
|
|
|
|
race_manager->setNumKarts( 1 );
|
|
|
|
race_manager->setTrack( "tutorial" );
|
|
|
|
race_manager->setDifficulty(RaceManager::DIFFICULTY_EASY);
|
2013-12-01 23:27:55 -05:00
|
|
|
race_manager->setReverseTrack(false);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-02-16 11:43:13 -05:00
|
|
|
// Use keyboard 0 by default (FIXME: let player choose?)
|
2014-10-25 08:09:00 -04:00
|
|
|
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0);
|
2013-02-16 11:43:13 -05:00
|
|
|
|
|
|
|
// Create player and associate player with keyboard
|
2014-04-07 18:06:52 -04:00
|
|
|
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(),
|
2014-05-30 20:26:02 -04:00
|
|
|
device);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-02-16 11:43:13 -05:00
|
|
|
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL)
|
|
|
|
{
|
2014-07-19 14:43:19 -04:00
|
|
|
Log::warn("HelpScreen1", "Cannot find kart '%s', will revert to default",
|
|
|
|
UserConfigParams::m_default_kart.c_str());
|
2013-02-16 11:43:13 -05:00
|
|
|
UserConfigParams::m_default_kart.revertToDefaults();
|
|
|
|
}
|
2016-01-11 21:00:45 -05:00
|
|
|
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-02-16 11:43:13 -05:00
|
|
|
// ASSIGN should make sure that only input from assigned devices
|
|
|
|
// is read.
|
2014-10-25 08:09:00 -04:00
|
|
|
input_manager->getDeviceManager()->setAssignMode(ASSIGN);
|
|
|
|
input_manager->getDeviceManager()
|
2013-02-16 11:43:13 -05:00
|
|
|
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-02-16 11:43:13 -05:00
|
|
|
StateManager::get()->enterGameState();
|
2013-07-05 08:01:29 -04:00
|
|
|
race_manager->setupPlayerKartInfo();
|
2013-02-16 11:43:13 -05:00
|
|
|
race_manager->startNew(false);
|
|
|
|
}
|
|
|
|
else if (name == "category")
|
2009-10-04 19:59:05 -04:00
|
|
|
{
|
2014-07-15 21:11:46 -04:00
|
|
|
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
|
|
|
|
|
|
|
Screen *screen = NULL;
|
|
|
|
//if (selection == "page1")
|
|
|
|
// screen = HelpScreen1::getInstance();
|
|
|
|
if (selection == "page2")
|
|
|
|
screen = HelpScreen2::getInstance();
|
|
|
|
else if (selection == "page3")
|
|
|
|
screen = HelpScreen3::getInstance();
|
|
|
|
else if (selection == "page4")
|
|
|
|
screen = HelpScreen4::getInstance();
|
2016-10-28 03:47:36 -04:00
|
|
|
else if (selection == "page5")
|
|
|
|
screen = HelpScreen5::getInstance();
|
2014-07-15 21:11:46 -04:00
|
|
|
if(screen)
|
|
|
|
StateManager::get()->replaceTopMostScreen(screen);
|
2009-10-04 19:59:05 -04:00
|
|
|
}
|
|
|
|
else if (name == "back")
|
|
|
|
{
|
|
|
|
StateManager::get()->escapePressed();
|
|
|
|
}
|
2010-08-14 21:15:19 -04:00
|
|
|
} // eventCallback
|
2009-10-04 19:59:05 -04:00
|
|
|
|
2012-07-26 17:24:15 -04:00
|
|
|
// -----------------------------------------------------------------------------
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2009-10-04 19:59:05 -04:00
|
|
|
void HelpScreen1::init()
|
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
Screen::init();
|
2009-10-04 19:59:05 -04:00
|
|
|
RibbonWidget* w = this->getWidget<RibbonWidget>("category");
|
2013-12-01 23:27:55 -05:00
|
|
|
ButtonWidget* tutorial = getWidget<ButtonWidget>("startTutorial");
|
|
|
|
|
2016-10-28 03:47:36 -04:00
|
|
|
tutorial->setActive(StateManager::get()->getGameState() !=
|
2015-07-03 02:19:28 -04:00
|
|
|
GUIEngine::INGAME_MENU);
|
2013-05-27 19:23:40 -04:00
|
|
|
|
2010-04-08 17:02:40 -04:00
|
|
|
if (w != NULL) w->select( "page1", PLAYER_ID_GAME_MASTER );
|
2010-08-14 21:15:19 -04:00
|
|
|
} //init
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2012-07-26 17:24:15 -04:00
|
|
|
// -----------------------------------------------------------------------------
|