RigsofRods
Soft-body Physics Simulation
GUI_MessageBox.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2020 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
26 
27 #pragma once
28 
29 #include "ForwardDeclarations.h"
30 #include "Application.h"
31 
32 #include <string>
33 #include <vector>
34 
35 namespace RoR {
36 namespace GUI {
37 
38  // ----------------------------
39  // Config
40 
42 {
43  std::string mbb_caption;
45  std::string mbb_mq_description;
46  void* mbb_mq_payload = nullptr;
47  int mbb_script_number = -1;
48 };
49 
51 {
52  std::string mbc_title;
53  std::string mbc_text;
55  bool* mbc_close_handle = nullptr;
56  bool mbc_allow_close = false;
57  float mbc_content_width = 300.f;
58 
59  std::vector<MessageBoxButton> mbc_buttons;
60 };
61 
62  // ----------------------------
63  // Execution
64 
66 {
67 public:
68  void Show(MessageBoxConfig const& cfg);
69  void Show(const char* title, const char* text, bool allow_close, const char* button1_text, const char* button2_text);
70  void Draw();
71  bool IsVisible() const { return m_is_visible; }
72 
73 private:
74  void DrawButton(MessageBoxButton const& button);
75 
77  bool* m_close_handle = nullptr;
78  bool m_is_visible = false;
79 };
80 
81 } // namespace GUI
82 } // namespace RoR
RoR::GUI::MessageBoxConfig::mbc_buttons
std::vector< MessageBoxButton > mbc_buttons
Definition: GUI_MessageBox.h:59
ForwardDeclarations.h
Global forward declarations.
RoR::GUI::MessageBoxDialog::DrawButton
void DrawButton(MessageBoxButton const &button)
Definition: GUI_MessageBox.cpp:133
RoR::GUI::MessageBoxDialog::m_close_handle
bool * m_close_handle
If nullptr, close button is hidden. Otherwise visible.
Definition: GUI_MessageBox.h:77
RoR::GUI::MessageBoxButton::mbb_mq_payload
void * mbb_mq_payload
Message argument to queue on click.
Definition: GUI_MessageBox.h:46
RoR::GUI::MessageBoxButton::mbb_caption
std::string mbb_caption
Definition: GUI_MessageBox.h:43
RoR::GUI::MessageBoxDialog::m_is_visible
bool m_is_visible
Definition: GUI_MessageBox.h:78
RoR::GUI::MessageBoxButton
Definition: GUI_MessageBox.h:41
RoR::GUI::MessageBoxConfig::mbc_title
std::string mbc_title
Definition: GUI_MessageBox.h:52
RoR::MsgType
MsgType
Global gameplay message loop, see struct Message in GameContext.h.
Definition: Application.h:74
Application.h
Central state/object manager and communications hub.
RoR::GUI::MessageBoxConfig::mbc_text
std::string mbc_text
Definition: GUI_MessageBox.h:53
RoR::GUI::MessageBoxDialog::Show
void Show(MessageBoxConfig const &cfg)
Definition: GUI_MessageBox.cpp:42
RoR::GUI::MessageBoxDialog
Definition: GUI_MessageBox.h:65
RoR::MSG_INVALID
@ MSG_INVALID
Definition: Application.h:83
RoR::GUI::MessageBoxDialog::IsVisible
bool IsVisible() const
Definition: GUI_MessageBox.h:71
RoR::CVar
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition: CVar.h:52
RoR::GUI::MessageBoxButton::mbb_mq_message
MsgType mbb_mq_message
Message to queue on click.
Definition: GUI_MessageBox.h:44
RoR::GUI::MessageBoxButton::mbb_script_number
int mbb_script_number
Valid values are >= 1. -1 means not defined.
Definition: GUI_MessageBox.h:47
RoR::GUI::MessageBoxConfig::mbc_close_handle
bool * mbc_close_handle
External close handle - not required for mbc_allow_close.
Definition: GUI_MessageBox.h:55
RoR::GUI::MessageBoxConfig::mbc_always_ask_conf
CVar * mbc_always_ask_conf
If set, displays classic checkbox "[x] Always ask".
Definition: GUI_MessageBox.h:54
RoR::GUI::MessageBoxDialog::Draw
void Draw()
Definition: GUI_MessageBox.cpp:97
RoR::GUI::MessageBoxDialog::m_cfg
MessageBoxConfig m_cfg
Definition: GUI_MessageBox.h:76
RoR::GUI::MessageBoxConfig
Definition: GUI_MessageBox.h:50
RoR::GUI::MessageBoxConfig::mbc_content_width
float mbc_content_width
Parameter to ImGui::SetContentWidth() - hard limit on content size.
Definition: GUI_MessageBox.h:57
RoR::GUI::MessageBoxConfig::mbc_allow_close
bool mbc_allow_close
Show close handle even if dbc_close_handle isn't set.
Definition: GUI_MessageBox.h:56
RoR
Definition: AppContext.h:36
RoR::GUI::MessageBoxButton::mbb_mq_description
std::string mbb_mq_description
Message argument to queue on click.
Definition: GUI_MessageBox.h:45