Emergency 20 Dokumentation  4.2.0
MessageBox.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
15 
16 #include <qsf/job/JobProxy.h>
17 
18 #include <boost/function.hpp>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace Rocket
25 {
26  namespace Core
27  {
28  class ElementText;
29  }
30 }
31 
32 
33 //[-------------------------------------------------------]
34 //[ Namespace ]
35 //[-------------------------------------------------------]
36 namespace em5
37 {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Classes ]
42  //[-------------------------------------------------------]
48  {
49 
50 
51  //[-------------------------------------------------------]
52  //[ Public methods ]
53  //[-------------------------------------------------------]
54  public:
59  explicit MessageBox(qsf::GuiContext& guiContext);
60 
65  void setup(const std::string& title, const std::string& text, const std::string& buttonTrueText, const std::string& buttonFalseText, const boost::function<void(bool)>& callback);
66  void setup(const std::string& title, const std::string& text, const std::string& buttonTrueText, const std::string& buttonFalseText, float autoFalseTime, const boost::function<void(bool)>& callback);
67  void setup(const std::string& title, const std::string& text, const std::string& buttonText, const boost::function<void(bool)>& callback);
68  void setup(const std::string& title, const std::string& text, const std::string& buttonText);
69 
70  void abort();
71 
72 
73  //[-------------------------------------------------------]
74  //[ Public virtual qsf::GuiDocument methods ]
75  //[-------------------------------------------------------]
76  public:
81  virtual void processEvent(const std::string& eventKey, Rocket::Core::Event& event) override;
82  virtual void onPostShow() override;
83 
84 
85  //[-------------------------------------------------------]
86  //[ Protected virtual em5::GuiHotReloadSupport methods ]
87  //[-------------------------------------------------------]
88  protected:
89  virtual void onReloadGui() override;
90 
91 
92  //[-------------------------------------------------------]
93  //[ Private methods ]
94  //[-------------------------------------------------------]
95  private:
96  void setupUI();
97  void setupTitleAndText(const std::string& title, const std::string& text);
98  void setupOneButton(const std::string& buttonText);
99  void setupTwoButtons(const std::string& buttonTrueText, const std::string& buttonFalseText);
100  void showTime(bool show);
101 
102  void updateTime(const qsf::JobArguments& jobArguments);
103 
104 
105  //[-------------------------------------------------------]
106  //[ Private data ]
107  //[-------------------------------------------------------]
108  private:
109  boost::function<void(bool)> mCallbackFunction;
110  float mShowUpTime;
111  float mAutoFalseTime;
112  qsf::JobProxy mJobProxy;
113 
114  Rocket::Core::Element* mMessageBoxElement;
115 
116  Rocket::Core::Element* mButtonsContainerElement;
117  Rocket::Core::Element* mTrueButtonElement;
118  Rocket::Core::ElementText* mTrueButtonTextElement;
119  Rocket::Core::Element* mFalseButtonElement;
120  Rocket::Core::ElementText* mFalseButtonTextElement;
121 
122  Rocket::Core::Element* mTimeElement;
123  Rocket::Core::ElementText* mTimeTextElement;
124  Rocket::Core::ElementText* mCaptionTextElement;
125  Rocket::Core::Element* mTextElement;
126  Rocket::Core::ElementText* mTextTextElement;
127 
128 
129  };
130 
131 
132 //[-------------------------------------------------------]
133 //[ Namespace ]
134 //[-------------------------------------------------------]
135 } // em5
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
#define EM5_API_EXPORT
Definition: Export.h:28
A base class which adds GUI hot reloading support to an GUI document.
Definition: GuiHotReloadSupport.h:34
Definition: OverlayComponent.h:29
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
Message box GUI element class.
Definition: MessageBox.h:47
void MessageBox(const std::string &title, const std::string &msg, const std::string &defaultButton)
Show an alter popup (like MessageBox on Windows)
Ingame Graphical User Interface (GUI) context class.
Definition: GuiContext.h:62