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_VehicleInfoTPanel.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 
55 // Deps
56 #include <Bites/OgreWindowEventUtilities.h>
57 #include <MyGUI.h>
58 #include <MyGUI_OgrePlatform.h>
59 #include <MyGUI_UString.h>
60 #include <OgreOverlay.h>
61 
62 namespace RoR {
63 
65 {
66 public:
67 
68  struct GuiTheme
69  {
70  ImVec4 in_progress_text_color = ImVec4(1.f, 0.832031f, 0.f, 1.f);
71  ImVec4 no_entries_text_color = ImVec4(0.7f, 0.7f, 0.7f, 1.f);
72  ImVec4 error_text_color = ImVec4(1.f, 0.175439f, 0.175439f, 1.f);
73  ImVec4 selected_entry_text_color = ImVec4(.9f, 0.7f, 0.05f, 1.f);
74  ImVec4 value_red_text_color = ImVec4(.9f, .1f, .1f, 1.f);
75  ImVec4 value_blue_text_color = ImVec4(0.34f, 0.67f, 0.84f, 1.f);
76  ImVec4 highlight_text_color = ImVec4(0.78f, 0.39f, 0.f, 1.f);
77  ImVec4 success_text_color = ImVec4(0.f, 0.8f, 0.f, 1.f);
78  ImVec4 warning_text_color = ImVec4(0.9f, 0.8f, 0.1f, 1.f);
79  ImVec4 help_text_color = ImVec4(0.5f, 0.7f, 1.f, 1.f);
80 
81  ImVec4 semitransparent_window_bg = ImVec4(0.1f, 0.1f, 0.1f, 0.8f);
82  ImVec4 semitrans_text_bg_color = ImVec4(0.1f, 0.1f, 0.1f, 0.6f);
83  ImVec4 color_mark_max_darkness = ImVec4(0.2, 0.2, 0.2, 0.0);
84 
85  ImVec2 screen_edge_padding = ImVec2(10.f, 10.f);
86  ImVec2 semitrans_text_bg_padding = ImVec2(4.f, 2.f);
87 
88  ImFont* default_font = nullptr;
89  };
90 
91  // 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
93  {
94  VISIBLE,
95  HIDDEN,
96  SUPRESSED,
97  };
98 
99  GUIManager();
100  ~GUIManager();
101 
102 
125  Ogre::Overlay* MenuWallpaper = nullptr;
126 
127  // GUI manipulation
128  void ShowMessageBox(const char* title, const char* text, bool allow_close = true, const char* btn1_text = "OK", const char* btn2_text = nullptr);
129  void ShowMessageBox(GUI::MessageBoxConfig const& conf);
130  void RequestGuiCaptureKeyboard(bool val);
132  void ApplyGuiCaptureKeyboard();
133  bool AreStaticMenusAllowed();
134 
135  void NewImGuiFrame(float dt);
136  void DrawMainMenuGui();
137  void DrawSimulationGui(float dt);
138  void DrawSimGuiBuffered(GfxActor* player_gfx_actor);
139  void DrawCommonGui();
140 
141  void SetGuiHidden(bool visible);
142  bool IsGuiHidden() const { return m_hide_gui; }
143 
144  void SetSceneManagerForGuiRendering(Ogre::SceneManager* scene_manager);
145 
146  void ShutdownMyGUI();
149  void SupressCursor(bool do_supress);
150 
151  void SetUpMenuWallpaper();
152 
153  inline OgreImGui& GetImGui() { return m_imgui; }
154  inline GuiTheme& GetTheme() { return m_theme; }
155 
156  void WakeUpGUI();
157 
158  void UpdateInputEvents(float dt);
159 
160 private:
161  void SetupImGui();
162 
163  void eventRequestTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
164 
165  MyGUI::Gui* m_mygui = nullptr;
166  MyGUI::OgrePlatform* m_mygui_platform = nullptr;
167  bool m_hide_gui = false;
170  bool m_gui_kb_capture_queued = false;
173  bool m_is_cursor_supressed = false;
174 };
175 
176 } // namespace RoR
RoR::GUIManager::VehicleInfoTPanel
GUI::VehicleInfoTPanel VehicleInfoTPanel
Definition: GUIManager.h:107
RoR::GUI::GameAbout
Definition: GUI_GameAbout.h:31
RoR::GUIManager::SurveyMap
GUI::SurveyMap SurveyMap
Definition: GUIManager.h:122
GUI_MultiplayerClientList.h
RoR::GUIManager::GuiTheme::selected_entry_text_color
ImVec4 selected_entry_text_color
Definition: GUIManager.h:73
RoR::GUIManager::GuiTheme::default_font
ImFont * default_font
Definition: GUIManager.h:88
RoR::GUIManager::SetupImGui
void SetupImGui()
Definition: GUIManager.cpp:313
RoR::GUI::VehicleInfoTPanel
Definition: GUI_VehicleInfoTPanel.h:34
RoR::GUIManager::m_mygui_platform
MyGUI::OgrePlatform * m_mygui_platform
Definition: GUIManager.h:166
RoR::GUIManager::SupressCursor
void SupressCursor(bool do_supress)
Definition: GUIManager.cpp:453
RoR::GUIManager::m_imgui
OgreImGui m_imgui
Definition: GUIManager.h:168
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:74
RoR::GUIManager::WakeUpGUI
void WakeUpGUI()
Definition: GUIManager.cpp:444
RoR::GUIManager::m_theme
GuiTheme m_theme
Definition: GUIManager.h:169
RoR::GUIManager::FrictionSettings
GUI::FrictionSettings FrictionSettings
Definition: GUIManager.h:114
RoR::GUI::GameControls
Definition: GUI_GameControls.h:28
RoR::GUIManager::GuiTheme
Definition: GUIManager.h:68
RoR::GUIManager::ApplyGuiCaptureKeyboard
void ApplyGuiCaptureKeyboard()
Call after rendered frame to apply queued value.
Definition: GUIManager.cpp:110
GUI_VehicleInfoTPanel.h
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:70
RoR::GUIManager::GuiTheme::value_blue_text_color
ImVec4 value_blue_text_color
Definition: GUIManager.h:75
GUI_GameMainMenu.h
GUI_FrictionSettings.h
RoR::GUIManager::MouseCursorVisibility
MouseCursorVisibility
Definition: GUIManager.h:92
RoR::GUIManager::SimPerfStats
GUI::SimPerfStats SimPerfStats
Definition: GUIManager.h:108
GUI_TopMenubar.h
RoR::GUIManager::TextureToolWindow
GUI::TextureToolWindow TextureToolWindow
Definition: GUIManager.h:115
RoR::GUI::DirectionArrow
Definition: GUI_DirectionArrow.h:36
RoR::GUIManager::IsGuiHidden
bool IsGuiHidden() const
Definition: GUIManager.h:142
RoR::GUI::FrictionSettings
Definition: GUI_FrictionSettings.h:36
RoR::GUIManager::GameControls
GUI::GameControls GameControls
Definition: GUIManager.h:116
RoR::GUIManager::MpClientList
GUI::MpClientList MpClientList
Definition: GUIManager.h:113
GUI_ConsoleWindow.h
GUI_DirectionArrow.h
Race direction arrow and text info (using OGRE Overlay)
RoR::GUIManager::ChatBox
GUI::GameChatBox ChatBox
Definition: GUIManager.h:112
RoR::GUIManager::GuiTheme::semitrans_text_bg_color
ImVec4 semitrans_text_bg_color
Definition: GUIManager.h:82
RoR::GUIManager::GameSettings
GUI::GameSettings GameSettings
Definition: GUIManager.h:106
RoR::GUI::GameMainMenu
Definition: GUI_GameMainMenu.h:33
RoR::GUIManager::GuiTheme::semitransparent_window_bg
ImVec4 semitransparent_window_bg
Definition: GUIManager.h:81
OgreImGui
DearIMGUI integration.
Definition: OgreImGui.h:54
OgreImGui.h
RoR::GUIManager::DirectionArrow
GUI::DirectionArrow DirectionArrow
Definition: GUIManager.h:123
GUI_MultiplayerSelector.h
RoR::GUIManager::eventRequestTag
void eventRequestTag(const MyGUI::UString &_tag, MyGUI::UString &_result)
Definition: GUIManager.cpp:207
RoR::GUIManager::LoadingWindow
GUI::LoadingWindow LoadingWindow
Definition: GUIManager.h:119
RoR::GUIManager::RepositorySelector
GUI::RepositorySelector RepositorySelector
Definition: GUIManager.h:117
GUI_SurveyMap.h
RoR::GUIManager::NewImGuiFrame
void NewImGuiFrame(float dt)
Definition: GUIManager.cpp:293
RoR::GUIManager::m_hide_gui
bool m_hide_gui
Definition: GUIManager.h:167
RoR::GUIManager::GetTheme
GuiTheme & GetTheme()
Definition: GUIManager.h:154
RoR::GUIManager::GetImGui
OgreImGui & GetImGui()
Definition: GUIManager.h:153
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:110
RoR::GUI::FlexbodyDebug
Flexbody and prop diagnostic.
Definition: GUI_FlexbodyDebug.h:32
RoR::GUIManager::MenuWallpaper
Ogre::Overlay * MenuWallpaper
Definition: GUIManager.h:125
GUI_LoadingWindow.h
GUI_MainSelector.h
RoR::GUIManager::CollisionsDebug
GUI::CollisionsDebug CollisionsDebug
Definition: GUIManager.h:103
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:170
RoR::GUIManager::GuiTheme::warning_text_color
ImVec4 warning_text_color
Definition: GUIManager.h:78
RoR::GUIManager::SetGuiHidden
void SetGuiHidden(bool visible)
Definition: GUIManager.cpp:254
GUI_GameAbout.h
RoR::GUI::TopMenubar
Definition: GUI_TopMenubar.h:46
RoR::GUIManager::IsGuiCaptureKeyboardRequested
bool IsGuiCaptureKeyboardRequested() const
Definition: GUIManager.h:131
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:83
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
RoR::GUIManager::GuiTheme::no_entries_text_color
ImVec4 no_entries_text_color
Definition: GUIManager.h:71
RoR::GUIManager::GuiTheme::success_text_color
ImVec4 success_text_color
Definition: GUIManager.h:77
RoR::GUIManager::NodeBeamUtils
GUI::NodeBeamUtils NodeBeamUtils
Definition: GUIManager.h:118
RoR::GUIManager::ConsoleWindow
GUI::ConsoleWindow ConsoleWindow
Definition: GUIManager.h:121
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::TopMenubar
GUI::TopMenubar TopMenubar
Definition: GUIManager.h:120
RoR::GUIManager::SetUpMenuWallpaper
void SetUpMenuWallpaper()
Definition: GUIManager.cpp:212
RoR::GUIManager::SetMouseCursorVisibility
void SetMouseCursorVisibility(MouseCursorVisibility visi)
Definition: GUIManager.cpp:265
RoR::GUIManager::DrawCommonGui
void DrawCommonGui()
Definition: GUIManager.cpp:366
RoR::GUI::MpClientList
Definition: GUI_MultiplayerClientList.h:38
GUI_GameSettings.h
RoR::GUIManager::GuiTheme::screen_edge_padding
ImVec2 screen_edge_padding
Definition: GUIManager.h:85
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:124
RoR::GUIManager::GuiTheme::help_text_color
ImVec4 help_text_color
Definition: GUIManager.h:79
RoR::GUIManager::m_last_mousemove_time
Ogre::Timer m_last_mousemove_time
Definition: GUIManager.h:172
RoR::GUI::MessageBoxConfig
Definition: GUI_MessageBox.h:50
RoR::GUIManager::GuiTheme::highlight_text_color
ImVec4 highlight_text_color
Definition: GUIManager.h:76
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:429
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:105
GUI_FlexbodyDebug.h
RoR::GUIManager::MessageBoxDialog
GUI::MessageBoxDialog MessageBoxDialog
Definition: GUIManager.h:109
RoR::GUIManager::UpdateMouseCursorVisibility
void UpdateMouseCursorVisibility()
Definition: GUIManager.cpp:285
RoR::GfxActor
Definition: GfxActor.h:52
RoR::GUI::MultiplayerSelector
Definition: GUI_MultiplayerSelector.h:54
RoR::GUIManager::MainSelector
GUI::MainSelector MainSelector
Definition: GUIManager.h:111
RoR::GUIManager
Definition: GUIManager.h:64
RoR::GUIManager::m_mygui
MyGUI::Gui * m_mygui
Definition: GUIManager.h:165
RoR::GUIManager::GuiTheme::error_text_color
ImVec4 error_text_color
Definition: GUIManager.h:72
RoR::GUIManager::GuiTheme::semitrans_text_bg_padding
ImVec2 semitrans_text_bg_padding
Definition: GUIManager.h:86
RoR::GUIManager::m_gui_kb_capture_requested
bool m_gui_kb_capture_requested
Effective value, persistent.
Definition: GUIManager.h:171
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:389
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:458
RoR::GUIManager::m_is_cursor_supressed
bool m_is_cursor_supressed
True if cursor was manually hidden.
Definition: GUIManager.h:173
RoR::GUIManager::SetSceneManagerForGuiRendering
void SetSceneManagerForGuiRendering(Ogre::SceneManager *scene_manager)
Definition: GUIManager.cpp:249
RoR::GUIManager::RequestGuiCaptureKeyboard
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
Definition: GUIManager.cpp:439
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::GUI::GameSettings
Definition: GUI_GameSettings.h:28
RoR::GUIManager::GameMainMenu
GUI::GameMainMenu GameMainMenu
Definition: GUIManager.h:104
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