Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 "GUI_MessageBox.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 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 ImVec4 tip_panel_bg_color = ImVec4(0.3f, 0.6f, 0.45f, 1.f);
100
101 ImFont* default_font = nullptr;
102 };
103
104 // 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
106 {
107 VISIBLE,
108 HIDDEN,
109 SUPRESSED,
110 };
111
112 GUIManager();
113 ~GUIManager();
114
115
138 Ogre::Overlay* MenuWallpaper = nullptr;
139
140 // GUI manipulation
141 void ShowMessageBox(const char* title, const char* text, bool allow_close = true, const char* btn1_text = "OK", const char* btn2_text = nullptr);
142 void ShowMessageBox(GUI::MessageBoxConfig const& conf);
143 void RequestGuiCaptureKeyboard(bool val);
146 bool AreStaticMenusAllowed();
147 void ApplyUiPreset();
148
149 void NewImGuiFrame(float dt);
150 void DrawMainMenuGui();
151 void DrawSimulationGui(float dt);
152 void DrawSimGuiBuffered(GfxActor* player_gfx_actor);
153 void DrawCommonGui();
154
155 void SetGuiHidden(bool visible);
156 bool IsGuiHidden() const { return App::ui_hide_gui->getBool(); }
157
158 void SetSceneManagerForGuiRendering(Ogre::SceneManager* scene_manager);
159
160 void ShutdownMyGUI();
163 void SupressCursor(bool do_supress);
164
165 void SetUpMenuWallpaper();
166
167 inline OgreImGui& GetImGui() { return m_imgui; }
168 inline GuiTheme& GetTheme() { return m_theme; }
169
170 void WakeUpGUI();
171
172 void UpdateInputEvents(float dt);
173
174private:
175 void SetupImGui();
176
177 void eventRequestTag(const MyGUI::UString& _tag, MyGUI::UString& _result);
178
179 MyGUI::Gui* m_mygui = nullptr;
180 MyGUI::OgrePlatform* m_mygui_platform = nullptr;
187};
188
189} // 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:180
GUI::RepositorySelector RepositorySelector
Definition GUIManager.h:130
bool IsGuiCaptureKeyboardRequested() const
Definition GUIManager.h:144
GUI::TextureToolWindow TextureToolWindow
Definition GUIManager.h:128
bool IsGuiHidden() const
Definition GUIManager.h:156
GUI::SimPerfStats SimPerfStats
Definition GUIManager.h:121
@ 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:183
void SetGuiHidden(bool visible)
void UpdateInputEvents(float dt)
Ogre::Timer m_last_mousemove_time
Definition GUIManager.h:185
GUI::MultiplayerSelector MultiplayerSelector
Definition GUIManager.h:123
GUI::GameAbout GameAbout
Definition GUIManager.h:118
void SetSceneManagerForGuiRendering(Ogre::SceneManager *scene_manager)
GUI::MainSelector MainSelector
Definition GUIManager.h:124
GUI::GameSettings GameSettings
Definition GUIManager.h:119
GUI::VehicleInfoTPanel VehicleInfoTPanel
Definition GUIManager.h:120
GUI::GameChatBox ChatBox
Definition GUIManager.h:125
void SetUpMenuWallpaper()
GUI::TopMenubar TopMenubar
Definition GUIManager.h:133
void ApplyGuiCaptureKeyboard()
Call after rendered frame to apply queued value.
OgreImGui & GetImGui()
Definition GUIManager.h:167
OgreImGui m_imgui
Definition GUIManager.h:181
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:186
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:138
GUI::FrictionSettings FrictionSettings
Definition GUIManager.h:127
void DrawSimulationGui(float dt)
Touches live data; must be called in sync with sim. thread.
GUI::CollisionsDebug CollisionsDebug
Definition GUIManager.h:116
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
GUI::LoadingWindow LoadingWindow
Definition GUIManager.h:132
GUI::GameControls GameControls
Definition GUIManager.h:129
GUI::MpClientList MpClientList
Definition GUIManager.h:126
bool AreStaticMenusAllowed()
i.e. top menubar / vehicle UI buttons
GUI::SurveyMap SurveyMap
Definition GUIManager.h:135
GUI::GameMainMenu GameMainMenu
Definition GUIManager.h:117
GuiTheme & GetTheme()
Definition GUIManager.h:168
bool m_gui_kb_capture_requested
Effective value, persistent.
Definition GUIManager.h:184
GUI::DirectionArrow DirectionArrow
Definition GUIManager.h:136
void eventRequestTag(const MyGUI::UString &_tag, MyGUI::UString &_result)
void SetMouseCursorVisibility(MouseCursorVisibility visi)
GuiTheme m_theme
Definition GUIManager.h:182
GUI::NodeBeamUtils NodeBeamUtils
Definition GUIManager.h:131
GUI::ConsoleWindow ConsoleWindow
Definition GUIManager.h:134
GUI::MessageBoxDialog MessageBoxDialog
Definition GUIManager.h:122
MyGUI::Gui * m_mygui
Definition GUIManager.h:179
GUI::FlexbodyDebug FlexbodyDebug
Definition GUIManager.h:137
void SupressCursor(bool do_supress)
CVar * ui_hide_gui
bool; The 'hide GUI' hotkey state
UiPresetEntry UiPresets[]
Global list of UI Presets, selectable via Settings menu in TopMenubar.
ImVec4 color_mark_max_darkness
If all RGB components are darker than this, text is auto-lightened.
Definition GUIManager.h:94
Definition GUIManager.h:68
const char * uip_cvar
Definition GUIManager.h:69
std::string uip_values[(int) UiPreset::Count]
Definition GUIManager.h:70