Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
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 "RTTLayer.h"
31
32// GUI panels
33#include "GUI_CollisionsDebug.h"
34#include "GUI_ConsoleWindow.h"
35#include "GUI_FlexbodyDebug.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"
50#include "GUI_SimPerfStats.h"
51#include "GUI_SurveyMap.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
65namespace RoR {
66
68{
69 const char* uip_cvar;
70 std::string uip_values[(int)UiPreset::Count];
71};
72
74
76{
77public:
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 semitrans_scrollbar_bg = ImVec4(0.1f, 0.1f, 0.1f, 0.3f); // Drawn on top of a transparent panel; make it just a shade
95 ImVec4 color_mark_max_darkness = ImVec4(0.2, 0.2, 0.2, 0.0);
96
97 ImVec2 screen_edge_padding = ImVec2(0.f, 0.f);
98 ImVec2 semitrans_text_bg_padding = ImVec2(0.f, 0.f);
99
100 ImVec4 tip_panel_bg_color = ImVec4(0.3f, 0.6f, 0.45f, 1.f);
101
102 ImFont* default_font = nullptr;
103 };
104
105 // 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
107 {
108 VISIBLE,
109 HIDDEN,
110 SUPRESSED,
111 };
112
113 GUIManager();
114 ~GUIManager();
115
116
139 Ogre::Overlay* MenuWallpaper = nullptr;
140
141 // GUI manipulation
142 void ShowMessageBox(const char* title, const char* text, bool allow_close = true, const char* btn1_text = "OK", const char* btn2_text = nullptr);
143 void ShowMessageBox(GUI::MessageBoxConfig const& conf);
144 void RequestGuiCaptureKeyboard(bool val);
147 bool AreStaticMenusAllowed();
148 void ApplyUiPreset();
149 void ReinitUI();
150 float GetUiScaleFactor() const;
151
152 void NewImGuiFrame(float dt);
153 void DrawMainMenuGui();
154 void DrawSimulationGui(float dt);
155 void DrawSimGuiBuffered(GfxActor* player_gfx_actor);
156 void DrawCommonGui();
157
158 void SetGuiHidden(bool visible);
159 bool IsGuiHidden() const { return App::ui_hide_gui->getBool(); }
160
161 void SetSceneManagerForGuiRendering(Ogre::SceneManager* scene_manager);
162
163 void ShutdownMyGUI();
166 void SupressCursor(bool do_supress);
167
168 void SetUpMenuWallpaper();
169
170 inline OgreImGui& GetImGui() { return m_imgui; }
171 inline GuiTheme& GetTheme() { return m_theme; }
173
174 void WakeUpGUI();
175
176 void UpdateInputEvents(float dt);
177
178private:
179 void SetupImGui();
180 void ApplyImGuiStyle();
181
182 void eventRequestTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
183
184 MyGUI::Gui* m_mygui = nullptr;
185 MyGUI::OgrePlatform* m_mygui_platform = nullptr;
194};
195
196} // namespace RoR
Central state/object manager and communications hub.
Race direction arrow and text info (using OGRE Overlay)
DearIMGUI integration.
Definition OgreImGui.h:55
bool getBool() const
Definition CVar.h:98
Diagnostic view for static terrain collisions and script event-boxes.
Flexbody and prop diagnostic.
Overlay showing chat/console messages on screen, with optional entry field.
In-game map widget Has 3 display modes (see SurveyMapMode), cycled using input SURVEY_MAP_TOGGLE_VIEW
void NewImGuiFrame(float dt)
MyGUI::OgrePlatform * m_mygui_platform
Definition GUIManager.h:185
GUI::RepositorySelector RepositorySelector
Definition GUIManager.h:131
bool IsGuiCaptureKeyboardRequested() const
Definition GUIManager.h:145
GUI::TextureToolWindow TextureToolWindow
Definition GUIManager.h:129
bool IsGuiHidden() const
Definition GUIManager.h:159
GUI::SimPerfStats SimPerfStats
Definition GUIManager.h:122
@ HIDDEN
Hidden as inactive, will re-appear the moment user moves mouse.
@ VISIBLE
Visible, will be auto-hidden if not moving for a while.
@ SUPRESSED
Hidden manually, will not re-appear until explicitly set VISIBLE.
bool m_gui_kb_capture_queued
Resets and accumulates every frame.
Definition GUIManager.h:189
void SetGuiHidden(bool visible)
void UpdateInputEvents(float dt)
Ogre::Timer m_last_mousemove_time
Definition GUIManager.h:191
GUI::MultiplayerSelector MultiplayerSelector
Definition GUIManager.h:124
GUI::GameAbout GameAbout
Definition GUIManager.h:119
void SetSceneManagerForGuiRendering(Ogre::SceneManager *scene_manager)
GUI::MainSelector MainSelector
Definition GUIManager.h:125
GUI::GameSettings GameSettings
Definition GUIManager.h:120
GUI::VehicleInfoTPanel VehicleInfoTPanel
Definition GUIManager.h:121
GUI::GameChatBox ChatBox
Definition GUIManager.h:126
void SetUpMenuWallpaper()
GUI::TopMenubar TopMenubar
Definition GUIManager.h:134
RTTLayerManager m_rtt_layer_manager
Manages dashboard RTT layers (reusable).
Definition GUIManager.h:188
void ApplyGuiCaptureKeyboard()
Call after rendered frame to apply queued value.
OgreImGui & GetImGui()
Definition GUIManager.h:170
OgreImGui m_imgui
Definition GUIManager.h:186
void UpdateMouseCursorVisibility()
void DrawSimGuiBuffered(GfxActor *player_gfx_actor)
Reads data from simbuffer.
bool m_is_cursor_supressed
True if cursor was manually hidden.
Definition GUIManager.h:192
void ApplyUiPreset()
reads cvar 'ui_preset'
void ShowMessageBox(const char *title, const char *text, bool allow_close=true, const char *btn1_text="OK", const char *btn2_text=nullptr)
Ogre::Overlay * MenuWallpaper
Definition GUIManager.h:139
GUI::FrictionSettings FrictionSettings
Definition GUIManager.h:128
void DrawSimulationGui(float dt)
Touches live data; must be called in sync with sim. thread.
GUI::CollisionsDebug CollisionsDebug
Definition GUIManager.h:117
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
GUI::LoadingWindow LoadingWindow
Definition GUIManager.h:133
GUI::GameControls GameControls
Definition GUIManager.h:130
GUI::MpClientList MpClientList
Definition GUIManager.h:127
void ApplyImGuiStyle()
Resets style to defaults, applies RoR theme and scales by 'ui_scale_factor'.
RTTLayerManager & GetRttLayerManager()
Definition GUIManager.h:172
void ReinitUI()
Reloads fonts and re-applies style; reads cvar 'ui_scale_factor'. Must be called outside ImGui frame ...
bool AreStaticMenusAllowed()
i.e. top menubar / vehicle UI buttons
GUI::SurveyMap SurveyMap
Definition GUIManager.h:136
GUI::GameMainMenu GameMainMenu
Definition GUIManager.h:118
GuiTheme & GetTheme()
Definition GUIManager.h:171
bool m_gui_kb_capture_requested
Effective value, persistent.
Definition GUIManager.h:190
GUI::DirectionArrow DirectionArrow
Definition GUIManager.h:137
void eventRequestTag(const MyGUI::UString &_tag, MyGUI::UString &_result)
void SetMouseCursorVisibility(MouseCursorVisibility visi)
GuiTheme m_theme
Definition GUIManager.h:187
float GetUiScaleFactor() const
Reads cvar 'ui_scale_factor', clamped to sane range.
GUI::NodeBeamUtils NodeBeamUtils
Definition GUIManager.h:132
GUI::ConsoleWindow ConsoleWindow
Definition GUIManager.h:135
GUI::MessageBoxDialog MessageBoxDialog
Definition GUIManager.h:123
MyGUI::Gui * m_mygui
Definition GUIManager.h:184
GUI::FlexbodyDebug FlexbodyDebug
Definition GUIManager.h:138
float m_active_ui_scale_factor
Last applied value of cvar 'ui_scale_factor', clamped to sane range.
Definition GUIManager.h:193
void SupressCursor(bool do_supress)
Global object, see RoR::GUIManager::GetRttLayerManager()
Definition RTTLayer.h:40
CVar * ui_hide_gui
bool; The 'hide GUI' hotkey state
UiPresetEntry UiPresets[]
Global list of UI Presets, selectable via Settings menu in TopMenubar.
ImVec2 semitrans_text_bg_padding
Set by ApplyImGuiStyle() relative to font size.
Definition GUIManager.h:98
ImVec2 screen_edge_padding
Set by ApplyImGuiStyle() relative to font size.
Definition GUIManager.h:97
ImVec4 color_mark_max_darkness
If all RGB components are darker than this, text is auto-lightened.
Definition GUIManager.h:95
Definition GUIManager.h:68
const char * uip_cvar
Definition GUIManager.h:69
std::string uip_values[(int) UiPreset::Count]
Definition GUIManager.h:70