moving class declarations of objects used by the KartSelectionScreen to kart_selection.hpp
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13373 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,12 +18,18 @@
|
||||
|
||||
#include <string>
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/dynamic_ribbon_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/model_view_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include <IGUIImage.h>
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
class Widget;
|
||||
class BubbleWidget;
|
||||
enum EventPropagation;
|
||||
}
|
||||
class InputDevice;
|
||||
class PlayerKartWidget;
|
||||
@@ -142,3 +148,205 @@ public:
|
||||
virtual bool onEscapePressed() OVERRIDE;
|
||||
|
||||
}; // KartSelectionScreen
|
||||
|
||||
//!----------------------------------------------------------------------------
|
||||
//! FocusDispatcher :
|
||||
/** Currently, navigation for multiple players at the same time is implemented
|
||||
in a somewhat clunky way. An invisible "dispatcher" widget is added above
|
||||
kart icons. When a player moves up, he focuses the dispatcher, which in
|
||||
turn moves the selection to the appropriate spinner. "tabbing roots" are
|
||||
used to make navigation back down possible. (FIXME: maybe find a cleaner
|
||||
way?) */
|
||||
class FocusDispatcher : public GUIEngine::Widget
|
||||
{
|
||||
KartSelectionScreen* m_parent;
|
||||
int m_reserved_id;
|
||||
|
||||
bool m_is_initialised;
|
||||
|
||||
public:
|
||||
|
||||
LEAK_CHECK()
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
FocusDispatcher(KartSelectionScreen* parent);
|
||||
// ------------------------------------------------------------------------
|
||||
void setRootID(const int reservedID);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void add();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
virtual GUIEngine::EventPropagation focused(const int playerID);
|
||||
}; // FocusDispatcher
|
||||
|
||||
//!----------------------------------------------------------------------------
|
||||
//! PlayerNameSpinner :
|
||||
/** A small extension to the spinner widget to add features like player ID
|
||||
* management or badging */
|
||||
class PlayerNameSpinner : public GUIEngine::SpinnerWidget
|
||||
{
|
||||
int m_playerID;
|
||||
bool m_incorrect;
|
||||
irr::gui::IGUIImage* m_red_mark_widget;
|
||||
KartSelectionScreen* m_parent;
|
||||
|
||||
//virtual EventPropagation focused(const int m_playerID) ;
|
||||
|
||||
public:
|
||||
PlayerNameSpinner(KartSelectionScreen* parent, const int playerID);
|
||||
// ------------------------------------------------------------------------
|
||||
void setID(const int m_playerID);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Add a red mark on the spinner to mean "invalid choice" */
|
||||
void markAsIncorrect();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Remove any red mark set with 'markAsIncorrect' */
|
||||
void markAsCorrect();
|
||||
};
|
||||
|
||||
/** A widget representing the kart selection for a player (i.e. the player's
|
||||
* number, name, the kart view, the kart's name) */
|
||||
class PlayerKartWidget : public GUIEngine::Widget,
|
||||
public GUIEngine::SpinnerWidget::ISpinnerConfirmListener
|
||||
{
|
||||
/** Whether this player confirmed their selection */
|
||||
bool m_ready;
|
||||
|
||||
/** widget coordinates */
|
||||
int player_id_x, player_id_y, player_id_w, player_id_h;
|
||||
int player_name_x, player_name_y, player_name_w, player_name_h;
|
||||
int model_x, model_y, model_w, model_h;
|
||||
int kart_name_x, kart_name_y, kart_name_w, kart_name_h;
|
||||
|
||||
/** A reserved ID for this widget if any, -1 otherwise. (If no ID is
|
||||
* reserved, widget will not be in the regular tabbing order */
|
||||
int m_irrlicht_widget_ID;
|
||||
|
||||
/** For animation purposes (see method 'move') */
|
||||
int target_x, target_y, target_w, target_h;
|
||||
float x_speed, y_speed, w_speed, h_speed;
|
||||
|
||||
/** Object representing this player */
|
||||
StateManager::ActivePlayer* m_associatedPlayer;
|
||||
int m_playerID;
|
||||
|
||||
/** Internal name of the spinner; useful to interpret spinner events,
|
||||
* which contain the name of the activated object */
|
||||
std::string spinnerID;
|
||||
|
||||
#ifdef DEBUG
|
||||
long m_magic_number;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
LEAK_CHECK()
|
||||
|
||||
/** Sub-widgets created by this widget */
|
||||
//LabelWidget* m_player_ID_label;
|
||||
PlayerNameSpinner* m_player_ident_spinner;
|
||||
GUIEngine::ModelViewWidget* m_model_view;
|
||||
GUIEngine::LabelWidget* m_kart_name;
|
||||
|
||||
KartSelectionScreen* m_parent_screen;
|
||||
|
||||
irr::gui::IGUIStaticText* m_ready_text;
|
||||
|
||||
//LabelWidget *getPlayerIDLabel() {return m_player_ID_label;}
|
||||
core::stringw deviceName;
|
||||
std::string m_kartInternalName;
|
||||
|
||||
bool m_not_updated_yet;
|
||||
|
||||
PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associatedPlayer,
|
||||
core::recti area, const int playerID,
|
||||
std::string kartGroup,
|
||||
const int irrlichtWidgetID=-1);
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
~PlayerKartWidget();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when players are renumbered (changes the player ID) */
|
||||
void setPlayerID(const int newPlayerID);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the ID of this player */
|
||||
int getPlayerID() const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Add the widgets to the current screen */
|
||||
virtual void add();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Get the associated ActivePlayer object*/
|
||||
StateManager::ActivePlayer* getAssociatedPlayer();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Starts a 'move/resize' animation, by simply passing destination coords.
|
||||
* The animation will then occur on each call to 'onUpdate'. */
|
||||
void move(const int x, const int y, const int w, const int h);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Call when player confirmed his identity and kart */
|
||||
void markAsReady();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** \return Whether this player confirmed his kart and indent selection */
|
||||
bool isReady();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Updates the animation (moving/shrinking/etc.) */
|
||||
void onUpdate(float delta);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Event callback */
|
||||
virtual GUIEngine::EventPropagation transmitEvent(
|
||||
GUIEngine::Widget* w,
|
||||
const std::string& originator,
|
||||
const int m_playerID);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Sets the size of the widget as a whole, and placed children widgets
|
||||
* inside itself */
|
||||
void setSize(const int x, const int y, const int w, const int h);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** Sets which kart was selected for this player */
|
||||
void setKartInternalName(const std::string& whichKart);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
const std::string& getKartInternalName() const;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** \brief Event callback from ISpinnerConfirmListener */
|
||||
virtual GUIEngine::EventPropagation onSpinnerConfirmed();
|
||||
}; // PlayerKartWidget
|
||||
|
||||
//!----------------------------------------------------------------------------
|
||||
//! KartHoverListener :
|
||||
|
||||
class KartHoverListener : public GUIEngine::DynamicRibbonHoverListener
|
||||
{
|
||||
KartSelectionScreen* m_parent;
|
||||
public:
|
||||
unsigned int m_magic_number;
|
||||
|
||||
KartHoverListener(KartSelectionScreen* parent);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
virtual ~KartHoverListener();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
void onSelectionChanged(GUIEngine::DynamicRibbonWidget* theWidget,
|
||||
const std::string& selectionID,
|
||||
const irr::core::stringw& selectionText,
|
||||
const int playerID);
|
||||
}; // KartHoverListener
|
||||
|
||||
@@ -13,11 +13,6 @@ NetworkKartSelectionScreen::~NetworkKartSelectionScreen()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void NetworkKartSelectionScreen::init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback handling events from the kart selection menu
|
||||
*/
|
||||
|
||||
@@ -12,8 +12,6 @@ protected:
|
||||
virtual ~NetworkKartSelectionScreen();
|
||||
|
||||
public:
|
||||
static bool isRunning() { return singleton!=NULL; }
|
||||
virtual void init() OVERRIDE;
|
||||
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID) OVERRIDE;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user