RigsofRods
Soft-body Physics Simulation
GUIManager.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 
24 
25 #pragma once
26 
27 #include "OgreImGui.h"
28 #include "Application.h"
29 #include "GUI_MessageBox.h"
30 
31 // GUI panels
32 #include "GUI_CollisionsDebug.h"
33 #include "GUI_ConsoleWindow.h"
34 #include "GUI_FlexbodyDebug.h"
35 #include "GUI_FrictionSettings.h"
36 #include "GUI_RepositorySelector.h"
37 #include "GUI_GameMainMenu.h"
38 #include "GUI_GameAbout.h"
39 #include "GUI_GameChatBox.h"
40 #include "GUI_GameSettings.h"
41 #include "GUI_LoadingWindow.h"
42 #include "GUI_MessageBox.h"
45 #include "GUI_MainSelector.h"
46 #include "GUI_NodeBeamUtils.h"
47 #include "GUI_DirectionArrow.h"
48 #include "GUI_SimActorStats.h"
49 #include "GUI_SimPerfStats.h"
50 #include "GUI_SurveyMap.h"
51 #include "GUI_TextureToolWindow.h"
52 #include "GUI_GameControls.h"
53 #include "GUI_TopMenubar.h"
54 #include "GUI_VehicleDescription.h"
55 #include "GUI_VehicleButtons.h"
56 
57 // Deps
58 #include <Bites/OgreWindowEventUtilities.h>
59 #include <MyGUI.h>
60 #include <MyGUI_OgrePlatform.h>
61 #include <MyGUI_UString.h>
62 #include <OgreOverlay.h>
63 
64 namespace RoR {
65 
67 {
68 public:
69 
70  struct GuiTheme
71  {
72  ImVec4 in_progress_text_color = ImVec4(1.f, 0.832031f, 0.f, 1.f);
73  ImVec4 no_entries_text_color = ImVec4(0.7f, 0.7f, 0.7f, 1.f);
74  ImVec4 error_text_color = ImVec4(1.f, 0.175439f, 0.175439f, 1.f);
75  ImVec4 selected_entry_text_color = ImVec4(.9f, 0.7f, 0.05f, 1.f);
76  ImVec4 value_red_text_color = ImVec4(.9f, .1f, .1f, 1.f);
77  ImVec4 value_blue_text_color = ImVec4(0.34f, 0.67f, 0.84f, 1.f);
78  ImVec4 highlight_text_color = ImVec4(0.78f, 0.39f, 0.f, 1.f);
79  ImVec4 success_text_color = ImVec4(0.f, 0.8f, 0.f, 1.f);
80  ImVec4 warning_text_color = ImVec4(0.9f, 0.8f, 0.1f, 1.f);
81  ImVec4 help_text_color = ImVec4(0.5f, 0.7f, 1.f, 1.f);
82 
83  ImVec4 semitransparent_window_bg = ImVec4(0.1f, 0.1f, 0.1f, 0.8f);
84  ImVec4 semitrans_text_bg_color = ImVec4(0.1f, 0.1f, 0.1f, 0.6f);
85  ImVec4 color_mark_max_darkness = ImVec4(0.2, 0.2, 0.2, 0.0);
86 
87  ImVec2 screen_edge_padding = ImVec2(10.f, 10.f);
88  ImVec2 semitrans_text_bg_padding = ImVec2(4.f, 2.f);
89 
90  ImFont* default_font = nullptr;
91  };
92 
93  // NOTE: RoR's mouse cursor management is a mess - cursor is hidden/revealed ad-hoc in the code (originally by calling `MyGUI::PointerManager::setVisible()`); this enum+API cleans it up a bit ~ only_a_ptr, 09/2017
95  {
96  VISIBLE,
97  HIDDEN,
98  SUPRESSED,
99  };
100 
101  GUIManager();
102  ~GUIManager();
103 
104 
129  Ogre::Overlay* MenuWallpaper = nullptr;
130 
131  // GUI manipulation
132  void ShowMessageBox(const char* title, const char* text, bool allow_close = true, const char* btn1_text = "OK", const char* btn2_text = nullptr);
133  void ShowMessageBox(GUI::MessageBoxConfig const& conf);
134  void RequestGuiCaptureKeyboard(bool val);
136  void ApplyGuiCaptureKeyboard();
137  bool AreStaticMenusAllowed();
138 
139  void NewImGuiFrame(float dt);
140  void DrawMainMenuGui();
141  void DrawSimulationGui(float dt);
142  void DrawSimGuiBuffered(GfxActor* player_gfx_actor);
143  void DrawCommonGui();
144 
145  void SetGuiHidden(bool visible);
146  bool IsGuiHidden() const { return m_hide_gui; }
147 
148  void SetSceneManagerForGuiRendering(Ogre::SceneManager* scene_manager);
149 
150  void ShutdownMyGUI();
153  void SupressCursor(bool do_supress);
154 
155  void SetUpMenuWallpaper();
156 
157  inline OgreImGui& GetImGui() { return m_imgui; }
158  inline GuiTheme& GetTheme() { return m_theme; }
159 
160  void WakeUpGUI();
161 
162  void UpdateInputEvents(float dt);
163 
164 private:
165  void SetupImGui();
166 
167  void eventRequestTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
168 
169  MyGUI::Gui* m_mygui = nullptr;
170  MyGUI::OgrePlatform* m_mygui_platform = nullptr;
171  bool m_hide_gui = false;
174  bool m_gui_kb_capture_queued = false;
177  bool m_is_cursor_supressed = false;
178 };
179 
180 } // namespace RoR
RoR::GUI::SimActorStats
Definition: GUI_SimActorStats.h:33
RoR::GUI::VehicleDescription
Definition: GUI_VehicleDescription.h:33
RoR::GUI::GameAbout
Definition: GUI_GameAbout.h:31
RoR::GUIManager::SurveyMap
GUI::SurveyMap SurveyMap
Definition: GUIManager.h:125
GUI_MultiplayerClientList.h
RoR::GUIManager::GuiTheme::selected_entry_text_color
ImVec4 selected_entry_text_color
Definition: GUIManager.h:75
RoR::GUIManager::GuiTheme::default_font
ImFont * default_font
Definition: GUIManager.h:90
RoR::GUIManager::SetupImGui
void SetupImGui()
Definition: GUIManager.cpp:324
RoR::GUIManager::m_mygui_platform
MyGUI::OgrePlatform * m_mygui_platform
Definition: GUIManager.h:170
RoR::GUIManager::SupressCursor
void SupressCursor(bool do_supress)
Definition: GUIManager.cpp:464
RoR::GUIManager::m_imgui
OgreImGui m_imgui
Definition: GUIManager.h:172
RoR::GUI::GameChatBox
Overlay showing chat/console messages on screen, with optional entry field.
Definition: GUI_GameChatBox.h:40
RoR::GUIManager::GuiTheme::value_red_text_color
ImVec4 value_red_text_color
Definition: GUIManager.h:76
RoR::GUIManager::WakeUpGUI
void WakeUpGUI()
Definition: GUIManager.cpp:455
RoR::GUIManager::m_theme
GuiTheme m_theme
Definition: GUIManager.h:173
RoR::GUIManager::FrictionSettings
GUI::FrictionSettings FrictionSettings
Definition: GUIManager.h:117
RoR::GUI::GameControls
Definition: GUI_GameControls.h:28
RoR::GUIManager::GuiTheme
Definition: GUIManager.h:70
RoR::GUIManager::ApplyGuiCaptureKeyboard
void ApplyGuiCaptureKeyboard()
Call after rendered frame to apply queued value.
Definition: GUIManager.cpp:110
GUI_MessageBox.h
Generic UI dialog (not modal). Invocable from scripting. Any number of buttons. Configurable to fire ...
RoR::GUIManager::GuiTheme::in_progress_text_color
ImVec4 in_progress_text_color
Definition: GUIManager.h:72
RoR::GUIManager::GuiTheme::value_blue_text_color
ImVec4 value_blue_text_color
Definition: GUIManager.h:77
GUI_GameMainMenu.h
GUI_FrictionSettings.h
RoR::GUIManager::MouseCursorVisibility
MouseCursorVisibility
Definition: GUIManager.h:94
RoR::GUIManager::SimPerfStats
GUI::SimPerfStats SimPerfStats
Definition: GUIManager.h:110
GUI_TopMenubar.h
RoR::GUIManager::TextureToolWindow
GUI::TextureToolWindow TextureToolWindow
Definition: GUIManager.h:118
RoR::GUI::DirectionArrow
Definition: GUI_DirectionArrow.h:36
RoR::GUIManager::IsGuiHidden
bool IsGuiHidden() const
Definition: GUIManager.h:146
RoR::GUI::FrictionSettings
Definition: GUI_FrictionSettings.h:36
RoR::GUIManager::GameControls
GUI::GameControls GameControls
Definition: GUIManager.h:119
RoR::GUIManager::MpClientList
GUI::MpClientList MpClientList
Definition: GUIManager.h:116
GUI_ConsoleWindow.h
GUI_DirectionArrow.h
Race direction arrow and text info (using OGRE Overlay)
RoR::GUIManager::ChatBox
GUI::GameChatBox ChatBox
Definition: GUIManager.h:114
RoR::GUIManager::GuiTheme::semitrans_text_bg_color
ImVec4 semitrans_text_bg_color
Definition: GUIManager.h:84
RoR::GUIManager::GameSettings
GUI::GameSettings GameSettings
Definition: GUIManager.h:108
RoR::GUI::GameMainMenu
Definition: GUI_GameMainMenu.h:33
RoR::GUIManager::GuiTheme::semitransparent_window_bg
ImVec4 semitransparent_window_bg
Definition: GUIManager.h:83
GUI_SimActorStats.h
OgreImGui
DearIMGUI integration.
Definition: OgreImGui.h:54
RoR::GUI::VehicleButtons
Definition: GUI_VehicleButtons.h:35
OgreImGui.h
RoR::GUIManager::DirectionArrow
GUI::DirectionArrow DirectionArrow
Definition: GUIManager.h:126
GUI_MultiplayerSelector.h
RoR::GUIManager::eventRequestTag
void eventRequestTag(const MyGUI::UString &_tag, MyGUI::UString &_result)
Definition: GUIManager.cpp:218
RoR::GUIManager::LoadingWindow
GUI::LoadingWindow LoadingWindow
Definition: GUIManager.h:122
RoR::GUIManager::RepositorySelector
GUI::RepositorySelector RepositorySelector
Definition: GUIManager.h:120
GUI_SurveyMap.h
RoR::GUIManager::NewImGuiFrame
void NewImGuiFrame(float dt)
Definition: GUIManager.cpp:304
RoR::GUIManager::m_hide_gui
bool m_hide_gui
Definition: GUIManager.h:171
RoR::GUIManager::GetTheme
GuiTheme & GetTheme()
Definition: GUIManager.h:158
RoR::GUIManager::GetImGui
OgreImGui & GetImGui()
Definition: GUIManager.h:157
RoR::GUI::LoadingWindow
Definition: GUI_LoadingWindow.h:31
RoR::GUIManager::AreStaticMenusAllowed
bool AreStaticMenusAllowed()
i.e. top menubar / vehicle UI buttons
Definition: GUIManager.cpp:115
RoR::GUIManager::MultiplayerSelector
GUI::MultiplayerSelector MultiplayerSelector
Definition: GUIManager.h:112
RoR::GUI::FlexbodyDebug
Flexbody and prop diagnostic.
Definition: GUI_FlexbodyDebug.h:32
RoR::GUIManager::MenuWallpaper
Ogre::Overlay * MenuWallpaper
Definition: GUIManager.h:129
GUI_VehicleDescription.h
GUI_LoadingWindow.h
GUI_MainSelector.h
RoR::GUIManager::CollisionsDebug
GUI::CollisionsDebug CollisionsDebug
Definition: GUIManager.h:105
GUI_GameChatBox.h
RoR::GUIManager::DrawSimulationGui
void DrawSimulationGui(float dt)
Touches live data; must be called in sync with sim. thread.
Definition: GUIManager.cpp:129
RoR::GUIManager::m_gui_kb_capture_queued
bool m_gui_kb_capture_queued
Resets and accumulates every frame.
Definition: GUIManager.h:174
RoR::GUIManager::GuiTheme::warning_text_color
ImVec4 warning_text_color
Definition: GUIManager.h:80
RoR::GUIManager::SetGuiHidden
void SetGuiHidden(bool visible)
Definition: GUIManager.cpp:265
GUI_GameAbout.h
RoR::GUI::TopMenubar
Definition: GUI_TopMenubar.h:46
RoR::GUIManager::IsGuiCaptureKeyboardRequested
bool IsGuiCaptureKeyboardRequested() const
Definition: GUIManager.h:135
Application.h
Central state/object manager and communications hub.
RoR::GUIManager::GuiTheme::color_mark_max_darkness
ImVec4 color_mark_max_darkness
If all RGB components are darker than this, text is auto-lightened.
Definition: GUIManager.h:85
RoR::GUIManager::MouseCursorVisibility::SUPRESSED
@ SUPRESSED
Hidden manually, will not re-appear until explicitly set VISIBLE.
GUI_SimPerfStats.h
RoR::GUIManager::ShutdownMyGUI
void ShutdownMyGUI()
Definition: GUIManager.cpp:93
GUI_VehicleButtons.h
RoR::GUIManager::GuiTheme::no_entries_text_color
ImVec4 no_entries_text_color
Definition: GUIManager.h:73
RoR::GUIManager::GuiTheme::success_text_color
ImVec4 success_text_color
Definition: GUIManager.h:79
RoR::GUIManager::NodeBeamUtils
GUI::NodeBeamUtils NodeBeamUtils
Definition: GUIManager.h:121
RoR::GUIManager::ConsoleWindow
GUI::ConsoleWindow ConsoleWindow
Definition: GUIManager.h:124
RoR::GUI::MessageBoxDialog
Definition: GUI_MessageBox.h:65
RoR::GUI::NodeBeamUtils
Definition: GUI_NodeBeamUtils.h:28
RoR::GUIManager::DrawSimGuiBuffered
void DrawSimGuiBuffered(GfxActor *player_gfx_actor)
Reads data from simbuffer.
Definition: GUIManager.cpp:162
RoR::GUIManager::SimActorStats
GUI::SimActorStats SimActorStats
Definition: GUIManager.h:109
RoR::GUIManager::TopMenubar
GUI::TopMenubar TopMenubar
Definition: GUIManager.h:123
RoR::GUIManager::SetUpMenuWallpaper
void SetUpMenuWallpaper()
Definition: GUIManager.cpp:223
RoR::GUIManager::SetMouseCursorVisibility
void SetMouseCursorVisibility(MouseCursorVisibility visi)
Definition: GUIManager.cpp:276
RoR::GUIManager::DrawCommonGui
void DrawCommonGui()
Definition: GUIManager.cpp:377
RoR::GUI::MpClientList
Definition: GUI_MultiplayerClientList.h:38
GUI_GameSettings.h
RoR::GUIManager::GuiTheme::screen_edge_padding
ImVec2 screen_edge_padding
Definition: GUIManager.h:87
GUI_RepositorySelector.h
GUI_NodeBeamUtils.h
RoR::GUI::MainSelector
Definition: GUI_MainSelector.h:38
GUI_TextureToolWindow.h
RoR::GUIManager::FlexbodyDebug
GUI::FlexbodyDebug FlexbodyDebug
Definition: GUIManager.h:128
RoR::GUIManager::GuiTheme::help_text_color
ImVec4 help_text_color
Definition: GUIManager.h:81
RoR::GUIManager::m_last_mousemove_time
Ogre::Timer m_last_mousemove_time
Definition: GUIManager.h:176
RoR::GUI::MessageBoxConfig
Definition: GUI_MessageBox.h:50
RoR::GUIManager::GuiTheme::highlight_text_color
ImVec4 highlight_text_color
Definition: GUIManager.h:78
RoR::GUI::RepositorySelector
Definition: GUI_RepositorySelector.h:86
RoR::GUIManager::ShowMessageBox
void ShowMessageBox(const char *title, const char *text, bool allow_close=true, const char *btn1_text="OK", const char *btn2_text=nullptr)
Definition: GUIManager.cpp:440
RoR::GUI::CollisionsDebug
Diagnostic view for static terrain collisions and script event-boxes.
Definition: GUI_CollisionsDebug.h:38
RoR::GUIManager::GameAbout
GUI::GameAbout GameAbout
Definition: GUIManager.h:107
GUI_FlexbodyDebug.h
RoR::GUIManager::MessageBoxDialog
GUI::MessageBoxDialog MessageBoxDialog
Definition: GUIManager.h:111
RoR::GUIManager::UpdateMouseCursorVisibility
void UpdateMouseCursorVisibility()
Definition: GUIManager.cpp:296
RoR::GfxActor
Definition: GfxActor.h:52
RoR::GUI::MultiplayerSelector
Definition: GUI_MultiplayerSelector.h:54
RoR::GUIManager::MainSelector
GUI::MainSelector MainSelector
Definition: GUIManager.h:113
RoR::GUIManager
Definition: GUIManager.h:66
RoR::GUIManager::VehicleDescription
GUI::VehicleDescription VehicleDescription
Definition: GUIManager.h:115
RoR::GUIManager::m_mygui
MyGUI::Gui * m_mygui
Definition: GUIManager.h:169
RoR::GUIManager::GuiTheme::error_text_color
ImVec4 error_text_color
Definition: GUIManager.h:74
RoR::GUIManager::GuiTheme::semitrans_text_bg_padding
ImVec2 semitrans_text_bg_padding
Definition: GUIManager.h:88
RoR::GUIManager::m_gui_kb_capture_requested
bool m_gui_kb_capture_requested
Effective value, persistent.
Definition: GUIManager.h:175
RoR::GUIManager::GUIManager
GUIManager()
Definition: GUIManager.cpp:52
GUI_GameControls.h
RoR::GUI::TextureToolWindow
Definition: GUI_TextureToolWindow.h:28
RoR::GUI::ConsoleWindow
Definition: GUI_ConsoleWindow.h:40
RoR::GUIManager::DrawMainMenuGui
void DrawMainMenuGui()
Definition: GUIManager.cpp:400
RoR::GUIManager::MouseCursorVisibility::HIDDEN
@ HIDDEN
Hidden as inactive, will re-appear the moment user moves mouse.
RoR::GUIManager::UpdateInputEvents
void UpdateInputEvents(float dt)
Definition: GUIManager.cpp:469
RoR::GUIManager::m_is_cursor_supressed
bool m_is_cursor_supressed
True if cursor was manually hidden.
Definition: GUIManager.h:177
RoR::GUIManager::SetSceneManagerForGuiRendering
void SetSceneManagerForGuiRendering(Ogre::SceneManager *scene_manager)
Definition: GUIManager.cpp:260
RoR::GUIManager::RequestGuiCaptureKeyboard
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
Definition: GUIManager.cpp:450
RoR
Definition: AppContext.h:36
RoR::GUI::SurveyMap
In-game map widget Has 3 display modes (see SurveyMapMode), cycled using input SURVEY_MAP_TOGGLE_VIEW
Definition: GUI_SurveyMap.h:48
RoR::GUIManager::VehicleButtons
GUI::VehicleButtons VehicleButtons
Definition: GUIManager.h:127
RoR::GUI::GameSettings
Definition: GUI_GameSettings.h:28
RoR::GUIManager::GameMainMenu
GUI::GameMainMenu GameMainMenu
Definition: GUIManager.h:106
RoR::GUI::SimPerfStats
Definition: GUI_SimPerfStats.h:29
GUI_CollisionsDebug.h
RoR::GUIManager::MouseCursorVisibility::VISIBLE
@ VISIBLE
Visible, will be auto-hidden if not moving for a while.
RoR::GUIManager::~GUIManager
~GUIManager()
Definition: GUIManager.cpp:89