SuperTuxKart
race_paused_dialog.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2009-2015 Marianne Gagnon
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 #ifndef HEADER_RACE_PAUSED_DIALOG_HPP
19 #define HEADER_RACE_PAUSED_DIALOG_HPP
20 
21 #include "guiengine/modaldialog.hpp"
22 #include "guiengine/widgets/text_box_widget.hpp"
23 #include "utils/cpp2011.hpp"
24 
25 namespace GUIEngine
26 {
27  class RibbonWidget;
28  class TextBoxWidget;
29 }
30 
37 {
38 private:
39  bool m_self_destroy;
40  bool m_from_overworld;
41 
42  GUIEngine::TextBoxWidget* m_text_box;
43 
44  virtual void onTextUpdated() OVERRIDE {}
45  virtual bool onEnterPressed(const irr::core::stringw& text) OVERRIDE;
46 
47 protected:
48  virtual void loadedFromFile() OVERRIDE;
49 
50 public:
54  RacePausedDialog(const float percentWidth, const float percentHeight);
55  virtual ~RacePausedDialog();
56  virtual void onEnterPressedInternal() OVERRIDE;
57  GUIEngine::EventPropagation processEvent(const std::string& eventSource)
58  OVERRIDE;
59  virtual void beforeAddingWidgets() OVERRIDE;
60  // ------------------------------------------------------------------------
61  virtual void onUpdate(float dt) OVERRIDE
62  {
63  // It's unsafe to delete from inside the event handler so we do it here
64  if (m_self_destroy)
65  {
66  ModalDialog::dismiss();
67  return;
68  }
69  }
70 };
71 
72 #endif
RacePausedDialog(const float percentWidth, const float percentHeight)
Creates a modal dialog with given percentage of screen width and height.
Definition: race_paused_dialog.cpp:55
GUIEngine::EventPropagation processEvent(const std::string &eventSource) OVERRIDE
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: race_paused_dialog.cpp:181
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:31
A text field widget.
Definition: text_box_widget.hpp:52
Dialog shown when the race is paused.
Definition: race_paused_dialog.hpp:35
virtual void loadedFromFile() OVERRIDE
Callback invoked when the dialog was loaded from the XML file (if the constructor that takes a XML fi...
Definition: race_paused_dialog.cpp:139
virtual void beforeAddingWidgets() OVERRIDE
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: race_paused_dialog.cpp:304
Definition: text_box_widget.hpp:41
virtual void onUpdate(float dt) OVERRIDE
Override to be notified of updates.
Definition: race_paused_dialog.hpp:61
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:55