2009-07-04 13:24:09 -04:00
|
|
|
// $Id: font.cpp 3625 2009-06-21 01:10:43Z auria $
|
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2006
|
|
|
|
//
|
|
|
|
// 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 <string>
|
2009-10-04 19:59:05 -04:00
|
|
|
#include "guiengine/screen.hpp"
|
2010-02-18 16:28:32 -05:00
|
|
|
#include "states_screens/state_manager.hpp"
|
2009-07-04 13:24:09 -04:00
|
|
|
|
|
|
|
namespace GUIEngine
|
|
|
|
{
|
|
|
|
class Widget;
|
|
|
|
}
|
2009-07-04 16:00:18 -04:00
|
|
|
class InputDevice;
|
2009-10-29 20:51:58 -04:00
|
|
|
class PlayerKartWidget;
|
|
|
|
class KartHoverListener;
|
2009-07-04 13:24:09 -04:00
|
|
|
|
2010-04-23 16:48:56 -04:00
|
|
|
/**
|
|
|
|
* \brief screen where players can choose their kart
|
|
|
|
* \ingroup states_screens
|
|
|
|
*/
|
2009-10-04 19:59:05 -04:00
|
|
|
class KartSelectionScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<KartSelectionScreen>
|
2009-07-04 13:24:09 -04:00
|
|
|
{
|
2009-10-29 20:51:58 -04:00
|
|
|
friend class KartHoverListener;
|
|
|
|
friend class PlayerNameSpinner;
|
2009-10-30 20:32:18 -04:00
|
|
|
friend class FocusDispatcher;
|
2009-10-29 20:51:58 -04:00
|
|
|
|
2010-03-02 19:48:31 -05:00
|
|
|
/** Contains the custom widget shown for every player. (ref only since we're adding them to a
|
|
|
|
* Screen, and the Screen will take ownership of these widgets)
|
|
|
|
*/
|
2009-10-29 20:51:58 -04:00
|
|
|
ptr_vector<PlayerKartWidget, REF> m_kart_widgets;
|
|
|
|
|
2009-10-04 19:59:05 -04:00
|
|
|
friend class GUIEngine::ScreenSingleton<KartSelectionScreen>;
|
|
|
|
KartSelectionScreen();
|
|
|
|
|
2010-03-02 19:48:31 -05:00
|
|
|
/** Stores whether any player confirmed their choice; then, some things are "frozen", for instance
|
|
|
|
* the selected kart group tab
|
|
|
|
*/
|
|
|
|
bool m_player_confirmed;
|
|
|
|
|
2009-10-28 19:04:38 -04:00
|
|
|
/** Called when all players selected their kart */
|
|
|
|
void allPlayersDone();
|
|
|
|
|
|
|
|
/** Called when number/order of karts changed, so that all will keep an up-to-date ID */
|
|
|
|
void renumberKarts();
|
|
|
|
|
2009-10-29 14:30:29 -04:00
|
|
|
/** Checks identities chosen by players, making sure no duplicates are used.
|
2010-03-02 19:48:31 -05:00
|
|
|
* \return Whether all choices are ok
|
|
|
|
*/
|
2009-10-29 14:30:29 -04:00
|
|
|
bool validateIdentChoices();
|
|
|
|
|
2010-01-04 13:59:07 -05:00
|
|
|
/** Checks karts chosen by players, making sure no duplicates are used.
|
2010-03-02 19:48:31 -05:00
|
|
|
* \return Whether all choices are ok
|
|
|
|
*/
|
2010-01-04 13:59:07 -05:00
|
|
|
bool validateKartChoices();
|
|
|
|
|
2010-03-03 14:40:49 -05:00
|
|
|
/** Fill the ribbon with the karts from the currently selected group */
|
|
|
|
void setKartsFromCurrentGroup();
|
|
|
|
|
2009-10-04 19:59:05 -04:00
|
|
|
public:
|
2009-10-28 19:04:38 -04:00
|
|
|
|
|
|
|
/** Called when a player hits 'fire' on his device to join the game */
|
2009-08-26 16:05:51 -04:00
|
|
|
bool playerJoin(InputDevice* device, bool firstPlayer);
|
2009-10-28 19:04:38 -04:00
|
|
|
|
|
|
|
/** Called when a player hits 'rescue' on his device to leave the game */
|
2010-02-18 16:28:32 -05:00
|
|
|
bool playerQuit(StateManager::ActivePlayer* player);
|
2009-10-04 19:59:05 -04:00
|
|
|
|
2009-10-28 19:04:38 -04:00
|
|
|
/** Standard 'Screen' callback before screen is entered */
|
2009-10-04 19:59:05 -04:00
|
|
|
void init();
|
2009-10-28 19:04:38 -04:00
|
|
|
|
|
|
|
/** Standard 'Screen' callback before screen is left */
|
2009-10-04 19:59:05 -04:00
|
|
|
void tearDown();
|
2009-10-28 19:04:38 -04:00
|
|
|
|
|
|
|
/** Standard 'Screen' callback when an event occurs*/
|
|
|
|
void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
|
|
|
|
|
|
|
|
/** Standard 'Screen' callback every frame */
|
2009-10-04 19:59:05 -04:00
|
|
|
void onUpdate(float dt, irr::video::IVideoDriver*);
|
2009-12-30 15:59:56 -05:00
|
|
|
|
|
|
|
/** overload */
|
|
|
|
virtual void forgetWhatWasLoaded();
|
2009-10-04 19:59:05 -04:00
|
|
|
};
|