RigsofRods
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "CVar.h"
30 #include "GUI_MessageBox.h"
31 
32 // GUI panels
33 #include "GUI_CollisionsDebug.h"
34 #include "GUI_ConsoleWindow.h"
35 #include "GUI_FlexbodyDebug.h"
36 #include "GUI_FrictionSettings.h"
37 #include "GUI_RepositorySelector.h"
38 #include "GUI_GameMainMenu.h"
39 #include "GUI_GameAbout.h"
40 #include "GUI_GameChatBox.h"
41 #include "GUI_GameSettings.h"
42 #include "GUI_LoadingWindow.h"
43 #include "GUI_MessageBox.h"
46 #include "GUI_MainSelector.h"
47 #include "GUI_NodeBeamUtils.h"
48 #include "GUI_DirectionArrow.h"
49 #include "GUI_VehicleInfoTPanel.h"
50 #include "GUI_SimPerfStats.h"
51 #include "GUI_SurveyMap.h"
52 #include "GUI_TextureToolWindow.h"
53 #include "GUI_GameControls.h"
54 #include "GUI_TopMenubar.h"
55 
56 // Deps
57 #include <Bites/OgreWindowEventUtilities.h>
58 #include <MyGUI.h>
59 #include <MyGUI_OgrePlatform.h>
60 #include <MyGUI_UString.h>
61 #include <OgreOverlay.h>
62 
63 #include <string>
64 
65 namespace RoR {
66 
68 {
69  const char* uip_cvar;
70  std::string uip_values[(int)UiPreset::Count];
71 };
72 
73 extern UiPresetEntry UiPresets[];
74 
76 {
77 public:
78 
79  struct GuiTheme
80  {
81  ImVec4 in_progress_text_color = ImVec4(1.f, 0.832031f, 0.f, 1.f);
82  ImVec4 no_entries_text_color = ImVec4(0.7f, 0.7f, 0.7f, 1.f);
83  ImVec4 error_text_color = ImVec4(1.f, 0.175439f, 0.175439f, 1.f);
84  ImVec4 selected_entry_text_color = ImVec4(.9f, 0.7f, 0.05f, 1.f);
85  ImVec4 value_red_text_color = ImVec4(.9f, .1f, .1f, 1.f);
86  ImVec4 value_blue_text_color = ImVec4(0.34f, 0.67f, 0.84f, 1.f);
87  ImVec4 highlight_text_color = ImVec4(0.78f, 0.39f, 0.f, 1.f);
88  ImVec4 success_text_color = ImVec4(0.f, 0.8f, 0.f, 1.f);
89  ImVec4 warning_text_color = ImVec4(0.9f, 0.8f, 0.1f, 1.f);
90  ImVec4 help_text_color = ImVec4(0.5f, 0.7f, 1.f, 1.f);
91 
92  ImVec4 semitransparent_window_bg = ImVec4(0.1f, 0.1f, 0.1f, 0.8f);
93  ImVec4 semitrans_text_bg_color = ImVec4(0.1f, 0.1f, 0.1f, 0.6f);
94  ImVec4 color_mark_max_darkness = ImVec4(0.2, 0.2, 0.2, 0.0);
95 
96  ImVec2 screen_edge_padding = ImVec2(10.f, 10.f);
97  ImVec2 semitrans_text_bg_padding = ImVec2(4.f, 2.f);
98 
99  ImFont* default_font = nullptr;
100  };
101 
102  // 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
104  {
105  VISIBLE,
106  HIDDEN,
107  SUPRESSED,
108  };
109 
110  GUIManager();
111  ~GUIManager();
112 
113 
136  Ogre::Overlay* MenuWallpaper = nullptr;
137 
138  // GUI manipulation
139  void ShowMessageBox(const char* title, const char* text, bool allow_close = true, const char* btn1_text = "OK", const char* btn2_text = nullptr);
140  void ShowMessageBox(GUI::MessageBoxConfig const& conf);
141  void RequestGuiCaptureKeyboard(bool val);
143  void ApplyGuiCaptureKeyboard();
144  bool AreStaticMenusAllowed();
145  void ApplyUiPreset();
146 
147  void NewImGuiFrame(float dt);
148  void DrawMainMenuGui();
149  void DrawSimulationGui(float dt);
150  void DrawSimGuiBuffered(GfxActor* player_gfx_actor);
151  void DrawCommonGui();
152 
153  void SetGuiHidden(bool visible);
154  bool IsGuiHidden() const { return App::ui_hide_gui->getBool(); }
155 
156  void SetSceneManagerForGuiRendering(Ogre::SceneManager* scene_manager);
157 
158  void ShutdownMyGUI();
161  void SupressCursor(bool do_supress);
162 
163  void SetUpMenuWallpaper();
164 
165  inline OgreImGui& GetImGui() { return m_imgui; }
166  inline GuiTheme& GetTheme() { return m_theme; }
167 
168  void WakeUpGUI();
169 
170  void UpdateInputEvents(float dt);
171 
172 private:
173  void SetupImGui();
174 
175  void eventRequestTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
176 
177  MyGUI::Gui* m_mygui = nullptr;
178  MyGUI::OgrePlatform* m_mygui_platform = nullptr;
181  bool m_gui_kb_capture_queued = false;
184  bool m_is_cursor_supressed = false;
185 };
186 
187 } // namespace RoR
RoR::GUIManager::VehicleInfoTPanel
GUI::VehicleInfoTPanel VehicleInfoTPanel
Definition: GUIManager.h:118
RoR::GUI::GameAbout
Definition: GUI_GameAbout.h:31
RoR::GUIManager::SurveyMap
GUI::SurveyMap SurveyMap
Definition: GUIManager.h:133
GUI_MultiplayerClientList.h
RoR::GUIManager::GuiTheme::selected_entry_text_color
ImVec4 selected_entry_text_color
Definition: GUIManager.h:84
RoR::GUIManager::GuiTheme::default_font
ImFont * default_font
Definition: GUIManager.h:99
RoR::UiPresetEntry::uip_values
std::string uip_values[(int) UiPreset::Count]
Definition: GUIManager.h:70
RoR::GUIManager::GUIManager
GUIManager()
Definition: GUIManager.cpp:64
RoR::GUI::VehicleInfoTPanel
Definition: GUI_VehicleInfoTPanel.h:34
RoR::GUIManager::m_mygui_platform
MyGUI::OgrePlatform * m_mygui_platform
Definition: GUIManager.h:178
RoR::GUIManager::m_imgui
OgreImGui m_imgui
Definition: GUIManager.h:179
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:85
RoR::GUIManager::m_theme
GuiTheme m_theme
Definition: GUIManager.h:180
RoR::GUIManager::FrictionSettings
GUI::FrictionSettings FrictionSettings
Definition: GUIManager.h:125
RoR::GUI::GameControls
Definition: GUI_GameControls.h:28
RoR::GUIManager::GuiTheme
Definition: GUIManager.h:79
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:81
RoR::GUIManager::GuiTheme::value_blue_text_color
ImVec4 value_blue_text_color
Definition: GUIManager.h:86
GUI_GameMainMenu.h
RoR::GUIManager::ApplyGuiCaptureKeyboard
void ApplyGuiCaptureKeyboard()
Call after rendered frame to apply queued value.
Definition: GUIManager.cpp:122
GUI_FrictionSettings.h
RoR::GUIManager::MouseCursorVisibility
MouseCursorVisibility
Definition: GUIManager.h:103
RoR::GUIManager::eventRequestTag
void eventRequestTag(const MyGUI::UString &_tag, MyGUI::UString &_result)
Definition: GUIManager.cpp:232
RoR::GUIManager::SimPerfStats
GUI::SimPerfStats SimPerfStats
Definition: GUIManager.h:119
GUI_TopMenubar.h
RoR::GUIManager::TextureToolWindow
GUI::TextureToolWindow TextureToolWindow
Definition: GUIManager.h:126
RoR::CVar::getBool
bool getBool() const
Definition: CVar.h:98
RoR::GUI::DirectionArrow
Definition: GUI_DirectionArrow.h:36
RoR::GUIManager::SetupImGui
void SetupImGui()
Definition: GUIManager.cpp:338
RoR::UiPresetEntry::uip_cvar
const char * uip_cvar
Definition: GUIManager.h:69
RoR::GUIManager::IsGuiHidden
bool IsGuiHidden() const
Definition: GUIManager.h:154
RoR::GUI::FrictionSettings
Definition: GUI_FrictionSettings.h:36
RoR::GUIManager::GameControls
GUI::GameControls GameControls
Definition: GUIManager.h:127
RoR::GUIManager::MpClientList
GUI::MpClientList MpClientList
Definition: GUIManager.h:124
GUI_ConsoleWindow.h
GUI_DirectionArrow.h
Race direction arrow and text info (using OGRE Overlay)
RoR::GUIManager::ChatBox
GUI::GameChatBox ChatBox
Definition: GUIManager.h:123
RoR::GUIManager::GuiTheme::semitrans_text_bg_color
ImVec4 semitrans_text_bg_color
Definition: GUIManager.h:93
RoR::GUIManager::GameSettings
GUI::GameSettings GameSettings
Definition: GUIManager.h:117
RoR::GUI::GameMainMenu
Definition: GUI_GameMainMenu.h:33
RoR::GUIManager::DrawMainMenuGui
void DrawMainMenuGui()
Definition: GUIManager.cpp:414
RoR::UiPresetEntry
Definition: GUIManager.h:67
RoR::GUIManager::GuiTheme::semitransparent_window_bg
ImVec4 semitransparent_window_bg
Definition: GUIManager.h:92
OgreImGui
DearIMGUI integration.
Definition: OgreImGui.h:54
OgreImGui.h
RoR::GUIManager::DirectionArrow
GUI::DirectionArrow DirectionArrow
Definition: GUIManager.h:134
GUI_MultiplayerSelector.h
RoR::GUIManager::~GUIManager
~GUIManager()
Definition: GUIManager.cpp:101
RoR::GUIManager::LoadingWindow
GUI::LoadingWindow LoadingWindow
Definition: GUIManager.h:130
RoR::GUIManager::RepositorySelector
GUI::RepositorySelector RepositorySelector
Definition: GUIManager.h:128
RoR::GUIManager::SupressCursor
void SupressCursor(bool do_supress)
Definition: GUIManager.cpp:478
GUI_SurveyMap.h
RoR::GUIManager::NewImGuiFrame
void NewImGuiFrame(float dt)
Definition: GUIManager.cpp:318
RoR::GUIManager::GetTheme
GuiTheme & GetTheme()
Definition: GUIManager.h:166
RoR::GUIManager::UpdateMouseCursorVisibility
void UpdateMouseCursorVisibility()
Definition: GUIManager.cpp:310
RoR::GUIManager::GetImGui
OgreImGui & GetImGui()
Definition: GUIManager.h:165
RoR::GUI::LoadingWindow
Definition: GUI_LoadingWindow.h:31
RoR::GUIManager::MultiplayerSelector
GUI::MultiplayerSelector MultiplayerSelector
Definition: GUIManager.h:121
RoR::GUI::FlexbodyDebug
Flexbody and prop diagnostic.
Definition: GUI_FlexbodyDebug.h:32
RoR::GUIManager::MenuWallpaper
Ogre::Overlay * MenuWallpaper
Definition: GUIManager.h:136
RoR::GUIManager::SetMouseCursorVisibility
void SetMouseCursorVisibility(MouseCursorVisibility visi)
Definition: GUIManager.cpp:290
RoR::GUIManager::UpdateInputEvents
void UpdateInputEvents(float dt)
Definition: GUIManager.cpp:483
GUI_LoadingWindow.h
GUI_MainSelector.h
RoR::GUIManager::CollisionsDebug
GUI::CollisionsDebug CollisionsDebug
Definition: GUIManager.h:114
GUI_GameChatBox.h
RoR::GUIManager::DrawSimGuiBuffered
void DrawSimGuiBuffered(GfxActor *player_gfx_actor)
Reads data from simbuffer.
Definition: GUIManager.cpp:187
RoR::GUIManager::m_gui_kb_capture_queued
bool m_gui_kb_capture_queued
Resets and accumulates every frame.
Definition: GUIManager.h:181
RoR::GUIManager::GuiTheme::warning_text_color
ImVec4 warning_text_color
Definition: GUIManager.h:89
RoR::GUIManager::AreStaticMenusAllowed
bool AreStaticMenusAllowed()
i.e. top menubar / vehicle UI buttons
Definition: GUIManager.cpp:127
GUI_GameAbout.h
RoR::GUI::TopMenubar
Definition: GUI_TopMenubar.h:46
RoR::GUIManager::IsGuiCaptureKeyboardRequested
bool IsGuiCaptureKeyboardRequested() const
Definition: GUIManager.h:142
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:94
RoR::UiPreset::Count
@ Count
RoR::GUIManager::MouseCursorVisibility::SUPRESSED
@ SUPRESSED
Hidden manually, will not re-appear until explicitly set VISIBLE.
GUI_SimPerfStats.h
RoR::GUIManager::RequestGuiCaptureKeyboard
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
Definition: GUIManager.cpp:464
RoR::GUIManager::ApplyUiPreset
void ApplyUiPreset()
reads cvar 'ui_preset'
Definition: GUIManager.cpp:141
RoR::GUIManager::GuiTheme::no_entries_text_color
ImVec4 no_entries_text_color
Definition: GUIManager.h:82
RoR::GUIManager::GuiTheme::success_text_color
ImVec4 success_text_color
Definition: GUIManager.h:88
RoR::GUIManager::NodeBeamUtils
GUI::NodeBeamUtils NodeBeamUtils
Definition: GUIManager.h:129
RoR::GUIManager::ConsoleWindow
GUI::ConsoleWindow ConsoleWindow
Definition: GUIManager.h:132
RoR::GUI::MessageBoxDialog
Definition: GUI_MessageBox.h:65
RoR::GUI::NodeBeamUtils
Definition: GUI_NodeBeamUtils.h:28
RoR::GUIManager::DrawSimulationGui
void DrawSimulationGui(float dt)
Touches live data; must be called in sync with sim. thread.
Definition: GUIManager.cpp:154
RoR::GUIManager::ShutdownMyGUI
void ShutdownMyGUI()
Definition: GUIManager.cpp:105
RoR::GUIManager::TopMenubar
GUI::TopMenubar TopMenubar
Definition: GUIManager.h:131
RoR::GUIManager::SetSceneManagerForGuiRendering
void SetSceneManagerForGuiRendering(Ogre::SceneManager *scene_manager)
Definition: GUIManager.cpp:274
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:454
RoR::GUI::MpClientList
Definition: GUI_MultiplayerClientList.h:38
GUI_GameSettings.h
RoR::GUIManager::GuiTheme::screen_edge_padding
ImVec2 screen_edge_padding
Definition: GUIManager.h:96
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:135
RoR::GUIManager::GuiTheme::help_text_color
ImVec4 help_text_color
Definition: GUIManager.h:90
RoR::GUIManager::m_last_mousemove_time
Ogre::Timer m_last_mousemove_time
Definition: GUIManager.h:183
RoR::GUI::MessageBoxConfig
Definition: GUI_MessageBox.h:50
RoR::GUIManager::GuiTheme::highlight_text_color
ImVec4 highlight_text_color
Definition: GUIManager.h:87
RoR::GUI::RepositorySelector
Definition: GUI_RepositorySelector.h:86
RoR::GUIManager::WakeUpGUI
void WakeUpGUI()
Definition: GUIManager.cpp:469
RoR::GUIManager::DrawCommonGui
void DrawCommonGui()
Definition: GUIManager.cpp:391
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:116
GUI_FlexbodyDebug.h
RoR::GUIManager::MessageBoxDialog
GUI::MessageBoxDialog MessageBoxDialog
Definition: GUIManager.h:120
RoR::GfxActor
Definition: GfxActor.h:52
RoR::GUI::MultiplayerSelector
Definition: GUI_MultiplayerSelector.h:54
RoR::GUIManager::MainSelector
GUI::MainSelector MainSelector
Definition: GUIManager.h:122
RoR::GUIManager::SetUpMenuWallpaper
void SetUpMenuWallpaper()
Definition: GUIManager.cpp:237
RoR::GUIManager
Definition: GUIManager.h:75
RoR::GUIManager::m_mygui
MyGUI::Gui * m_mygui
Definition: GUIManager.h:177
RoR::GUIManager::GuiTheme::error_text_color
ImVec4 error_text_color
Definition: GUIManager.h:83
RoR::GUIManager::GuiTheme::semitrans_text_bg_padding
ImVec2 semitrans_text_bg_padding
Definition: GUIManager.h:97
RoR::GUIManager::m_gui_kb_capture_requested
bool m_gui_kb_capture_requested
Effective value, persistent.
Definition: GUIManager.h:182
GUI_GameControls.h
RoR::GUI::TextureToolWindow
Definition: GUI_TextureToolWindow.h:28
RoR::GUI::ConsoleWindow
Definition: GUI_ConsoleWindow.h:40
RoR::GUIManager::MouseCursorVisibility::HIDDEN
@ HIDDEN
Hidden as inactive, will re-appear the moment user moves mouse.
CVar.h
RoR::GUIManager::m_is_cursor_supressed
bool m_is_cursor_supressed
True if cursor was manually hidden.
Definition: GUIManager.h:184
RoR
Definition: AppContext.h:36
RoR::UiPresets
UiPresetEntry UiPresets[]
Global list of UI Presets, selectable via Settings menu in TopMenubar.
Definition: GUIManager.cpp:53
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::SetGuiHidden
void SetGuiHidden(bool visible)
Definition: GUIManager.cpp:279
RoR::GUI::GameSettings
Definition: GUI_GameSettings.h:28
RoR::GUIManager::GameMainMenu
GUI::GameMainMenu GameMainMenu
Definition: GUIManager.h:115
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::App::ui_hide_gui
CVar * ui_hide_gui
bool; The 'hide GUI' hotkey state
Definition: Application.cpp:265