SuperTuxKart
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 
28 class InputDevice;
29 class PlayerProfile;
30 
31 namespace GUIEngine
32 {
33  class CheckBoxWidget;
34  class IconButtonWidget;
35  class LabelWidget;
36  class RibbonWidget;
37  class SpinnerWidget;
38 }
39 
45 {
46 private:
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 
63  GUIEngine::IconButtonWidget* m_connect;
64 
66 
68 
69 public:
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 spinner or gauge widget (to select numbers / percentages).
Definition: spinner_widget.hpp:39
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
virtual void onUpdate(float dt)
Override to be notified of updates.
Definition: splitscreen_player_dialog.hpp:90
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:52
void loadFromFile(const char *xmlFile)
Load a XML file to create the dialog from.
Definition: modaldialog.cpp:65
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
Declares the general types that are used by the network.
A checkbox widget.
Definition: check_box_widget.hpp:33
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:43
virtual void beforeAddingWidgets()
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: splitscreen_player_dialog.cpp:43
base class for input devices
Definition: input_device.hpp:47
Class for managing player profiles (name, usage frequency, etc.).
Definition: player_profile.hpp:53
A static text/icons/tabs bar widget.
Definition: ribbon_widget.hpp:59
A simple label widget.
Definition: label_widget.hpp:35
Dialog that handle user in network lobby.
Definition: splitscreen_player_dialog.hpp:44
virtual bool onEscapePressed()
Override to change what happens on escape pressed.
Definition: splitscreen_player_dialog.hpp:84
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:55