SuperTuxKart
Loading...
Searching...
No Matches
splitscreen_player_dialog.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2018 SuperTuxKart-Team
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19#ifndef HEADER_SPLITSCREEN_PLAYER_DIALOG_HPP
20#define HEADER_SPLITSCREEN_PLAYER_DIALOG_HPP
21
22#include "guiengine/modaldialog.hpp"
23#include "utils/types.hpp"
24
25#include <irrString.h>
26#include <vector>
27
28class InputDevice;
29class PlayerProfile;
30
31namespace GUIEngine
32{
33 class CheckBoxWidget;
34 class IconButtonWidget;
35 class LabelWidget;
36 class RibbonWidget;
37 class SpinnerWidget;
38}
39
45{
46private:
47 InputDevice* m_device;
48
49 bool m_self_destroy;
50
51 std::vector<PlayerProfile*> m_available_players;
52
53 GUIEngine::LabelWidget* m_message;
54
55 GUIEngine::SpinnerWidget* m_profiles;
56
57 GUIEngine::CheckBoxWidget* m_handicap;
58
59 GUIEngine::RibbonWidget* m_options_widget;
60
62
64
66
68
69public:
71 : ModalDialog(0.8f,0.8f), m_device(device), m_self_destroy(false)
72 {
73 loadFromFile("online/splitscreen_player_dialog.stkgui");
74 }
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
78 virtual void beforeAddingWidgets();
79 // ------------------------------------------------------------------------
80 void onEnterPressedInternal() { m_self_destroy = true; }
81 // ------------------------------------------------------------------------
82 GUIEngine::EventPropagation processEvent(const std::string& source);
83 // ------------------------------------------------------------------------
84 virtual bool onEscapePressed()
85 {
86 m_self_destroy = true;
87 return false;
88 }
89 // ------------------------------------------------------------------------
90 virtual void onUpdate(float dt)
91 {
92 // It's unsafe to delete from inside the event handler so we do it here
93 if (m_self_destroy)
94 {
95 ModalDialog::dismiss();
96 return;
97 }
98 }
99};
100
101#endif
A checkbox widget.
Definition: check_box_widget.hpp:34
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
A simple label widget.
Definition: label_widget.hpp:36
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
void loadFromFile(const char *xmlFile)
Load a XML file to create the dialog from.
Definition: modaldialog.cpp:69
ModalDialog(const float percentWidth, const float percentHeight, ModalDialogLocation location=MODAL_DIALOG_LOCATION_CENTER)
Creates a modal dialog with given percentage of screen width and height.
Definition: modaldialog.cpp:54
A static text/icons/tabs bar widget.
Definition: ribbon_widget.hpp:60
A spinner or gauge widget (to select numbers / percentages).
Definition: spinner_widget.hpp:41
base class for input devices
Definition: input_device.hpp:48
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:54
Dialog that handle user in network lobby.
Definition: splitscreen_player_dialog.hpp:45
virtual void onUpdate(float dt)
Override to be notified of updates.
Definition: splitscreen_player_dialog.hpp:90
GUIEngine::EventPropagation processEvent(const std::string &source)
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: splitscreen_player_dialog.cpp:104
virtual void beforeAddingWidgets()
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: splitscreen_player_dialog.cpp:43
virtual bool onEscapePressed()
Override to change what happens on escape pressed.
Definition: splitscreen_player_dialog.hpp:84
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Declares the general types that are used by the network.