Rigs of Rods 2026.01
Soft-body Physics Simulation
Loading...
Searching...
No Matches
GUI_GameSettings.cpp
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2016-2020 Petr Ohlidal
4
5 For more information, see http://www.rigsofrods.org/
6
7 Rigs of Rods is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3, as
9 published by the Free Software Foundation.
10
11 Rigs of Rods is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include "GUI_GameSettings.h"
21
22#include "AppContext.h"
23#include "CacheSystem.h"
24#include "GameContext.h"
25#include "GUIManager.h"
26#include "GUIUtils.h"
27#include "Language.h"
28#include "SoundManager.h"
29
30#ifdef USE_OPENAL
31# include <alc.h>
32#endif
33
34using namespace RoR;
35using namespace GUI;
36
38{
39 const int flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
40 ImGui::SetNextWindowSize(ImVec2(ImGui::GetFontSize() * 41.875f, ImGui::GetFontSize() * 25.f), ImGuiCond_FirstUseEver);
41 if (m_bump_height != 0)
42 {
43 ImGui::SetNextWindowSize(m_window_size + ImVec2(0, m_bump_height));
44 m_bump_height = 0.f;
45 }
46 ImGui::SetNextWindowPosCenter(ImGuiCond_Appearing);
47 bool keep_open = true;
48 ImGui::Begin(_LC("GameSettings", "Game settings"), &keep_open, flags);
49
50 ImGui::BeginTabBar("GameSettingsTabs");
51
52 const float child_height = ImGui::GetWindowHeight()
53 - ((2.f * ImGui::GetStyle().WindowPadding.y) + (3.f * ImGui::GetItemsLineHeightWithSpacing())
54 + ImGui::GetStyle().ItemSpacing.y);
55
56 if (ImGui::BeginTabItem(_LC("GameSettings", "Render System")))
57 {
58 ImGui::BeginChild("Settings-Render-scroll", ImVec2(0.f, child_height), false);
60 ImGui::EndChild();
61 ImGui::EndTabItem();
62 }
63 if (ImGui::BeginTabItem(_LC("GameSettings", "General")))
64 {
65 ImGui::BeginChild("Settings-General-scroll", ImVec2(0.f, child_height), false);
66 this->DrawGeneralSettings();
67 ImGui::EndChild();
68 ImGui::EndTabItem();
69 }
70 if (ImGui::BeginTabItem(_LC("GameSettings", "Gameplay")))
71 {
72 ImGui::BeginChild("Settings-Gameplay-scroll", ImVec2(0.f, child_height), false);
74 ImGui::EndChild();
75 ImGui::EndTabItem();
76 }
77 if (ImGui::BeginTabItem(_LC("GameSettings", "UI")))
78 {
79 ImGui::BeginChild("Settings-UI-scroll", ImVec2(0.f, child_height), false);
80 this->DrawUiSettings();
81 ImGui::EndChild();
82 ImGui::EndTabItem();
83 }
84 if (ImGui::BeginTabItem(_LC("GameSettings", "Graphics")))
85 {
86 ImGui::BeginChild("Settings-Graphics-scroll", ImVec2(0.f, child_height), false);
88 ImGui::EndChild();
89 ImGui::EndTabItem();
90 }
91 if (ImGui::BeginTabItem(_LC("GameSettings", "Audio")))
92 {
93 ImGui::BeginChild("Settings-Audio-scroll", ImVec2(0.f, child_height), false);
94 this->DrawAudioSettings();
95 ImGui::EndChild();
96 ImGui::EndTabItem();
97 }
98 if (ImGui::BeginTabItem(_LC("GameSettings", "Controls")))
99 {
100 ImGui::BeginChild("Settings-Controls-scroll", ImVec2(0.f, child_height), false);
101 this->DrawControlSettings();
102 ImGui::EndChild();
103 ImGui::EndTabItem();
104 }
105 if (ImGui::BeginTabItem(_LC("GameSettings", "Diagnostic")))
106 {
107 ImGui::BeginChild("Settings-Diag-scroll", ImVec2(0.f, child_height), false);
108 this->DrawDiagSettings();
109 ImGui::EndChild();
110 ImGui::EndTabItem();
111 }
112
113 ImGui::EndTabBar();
114
115 ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 4.f);
116 m_window_size = ImGui::GetWindowSize();
117
118 ImGui::End();
119 if (!keep_open)
120 {
121 this->SetVisible(false);
122 }
123}
124
126{
127 ImGui::TextDisabled("%s", _LC("GameSettings", "Render system (changes require a restart)"));
128
130 {
131 std::string text = _LC("GameSettings", "You must restart the game to make changes effective.");
132 ImVec2 box_size = ImGui::CalcTextSize(text.c_str()) + ImGui::GetStyle().FramePadding * 2;
133 ImVec2 box_pos = ImGui::GetCursorPos() + ImVec2(ImGui::GetWindowContentRegionWidth() * 0.5f - box_size.x * 0.5f, 0.f);
134 ImGui::SetCursorPos(box_pos);
135 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.8f, 0.7f, 0.1f, 1.f));
136 ImGui::BeginChildFrame(ImGuiID(123), box_size);
137 ImGui::TextColored(ImVec4(0.1f, 0.1f, 0.1f, 1.f), text.c_str());
138 ImGui::EndChildFrame();
139 ImGui::PopStyleColor(); // FrameBg
140 }
141
142 const auto ogre_root = App::GetAppContext()->GetOgreRoot();
143 const auto render_systems = ogre_root->getAvailableRenderers();
144 std::string render_system_names;
145 for (auto rs : render_systems)
146 {
147 render_system_names += rs->getName() + '\0';
148 }
149 const auto ro = ogre_root->getRenderSystemByName(App::app_rendersys_override->getStr());
150 const auto rs = ro ? ro : ogre_root->getRenderSystem();
151 const auto it = std::find(render_systems.begin(), render_systems.end(), rs);
152 int render_id = it != render_systems.end() ? std::distance(render_systems.begin(), it) : 0;
153 /* Combobox for selecting the Render System*/
154 if (ImGui::Combo(_LC ("GameSettings", "Render System"), &render_id, render_system_names.c_str()))
155 {
156 App::app_rendersys_override->setStr(render_systems[render_id]->getName());
157 }
158
159 const auto config_options = ogre_root->getRenderSystem()->getConfigOptions();
160 std::set<std::string> filter = {"Allow NVPerfHUD", "Colour Depth", "Fixed Pipeline Enabled",
161 "Floating-point mode", "Resource Creation Policy", "VSync Interval", "sRGB Gamma Conversion"};
162 for (auto opt : config_options)
163 {
164 auto co = opt.second;
165 if (co.immutable)
166 continue;
167 if (co.possibleValues.empty())
168 continue;
169 if (filter.find(co.name) != filter.end())
170 continue;
171 std::sort(co.possibleValues.rbegin(), co.possibleValues.rend());
172 std::string option_values;
173 for (auto value : co.possibleValues)
174 {
175 option_values += value + '\0';
176 }
177 const auto it = std::find(co.possibleValues.begin(), co.possibleValues.end(), opt.second.currentValue);
178 int option_id = it != co.possibleValues.end() ? std::distance(co.possibleValues.begin(), it) : 0;
179 if (ImGui::Combo(co.name.c_str(), &option_id, option_values.c_str()))
180 {
181 // Check the new value is different from the current one
182 if (co.currentValue != co.possibleValues[option_id])
183 {
184 // Set the new value to the render system
185 rs->setConfigOption(co.name, co.possibleValues[option_id]);
186 if (rs->validateConfigOptions().empty())
187 {
188 ogre_root->saveConfig();
189
190 // Show the "Must restart game..." box, make the window bigger to accomodate it
192 {
194 m_bump_height = ImGui::GetTextLineHeightWithSpacing() + ImGui::GetStyle().FramePadding.y * 2;
195 }
196 }
197 }
198 }
199 }
200}
201
203{
204 ImGui::TextDisabled("%s", _LC("GameSettings", "Application settings"));
205
206#ifndef NOLANG
207 std::vector<std::pair<std::string, std::string>> languages = App::GetLanguageEngine()->getLanguages();
208 std::string lang_values;
209 for (auto value : languages)
210 {
211 lang_values += value.first + '\0';
212 }
213 const auto it = std::find_if(languages.begin(), languages.end(),
214 [](const std::pair<std::string, std::string>& l) { return l.second == App::app_language->getStr(); });
215 int lang_selection = it != languages.end() ? std::distance(languages.begin(), it) : 0;
216 if (ImGui::Combo(_LC("GameSettings", "Language"), &lang_selection, lang_values.c_str()))
217 {
218 App::app_language->setStr(languages[lang_selection].second);
220 }
221#endif
222
223 // Country selection
224 static Ogre::FileInfoListPtr fl = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo("FlagsRG", "*");
225 if (!fl->empty())
226 {
227 static std::vector<std::string> countries;
228 if (countries.empty())
229 {
230 for (auto& file : *fl)
231 {
232 std::string country = Ogre::StringUtil::replaceAll(file.filename, ".png", "");
233 if (country.size() == 2) // RoR protocol limitation
234 {
235 countries.push_back(country);
236 }
237 }
238 std::sort(countries.begin(), countries.end());
239 }
240 std::string country_values;
241 for (auto value : countries)
242 {
243 country_values += value + '\0';
244 }
245 const auto it = std::find(countries.begin(), countries.end(), App::app_country->getStr());
246 int country_selection = it != countries.end() ? std::distance(countries.begin(), it) : 0;
247 if (ImGui::Combo(_LC("GameSettings", "Country"), &country_selection, country_values.c_str()))
248 {
249 App::app_country->setStr(countries[country_selection].c_str());
250 }
251 }
252
253 int sshot_select = (App::app_screenshot_format->getStr() == "jpg") ? 1 : 0; // Hardcoded; TODO: list available formats.
254
255 /* Screenshot format: Can be png or jpg*/
256 if (ImGui::Combo(_LC("GameSettings", "Screenshot format"), &sshot_select, "png\0jpg\0\0"))
257 {
258 std::string str = (sshot_select == 1) ? "jpg" : "png";
260 }
261
262 DrawGTextEdit(App::app_extra_mod_path, _LC("GameSettings", "Extra mod path"), m_buf_app_extra_mod_dir);
263
264 DrawGCheckbox(App::app_skip_main_menu, _LC("GameSettings", "Skip main menu"));
265 DrawGCheckbox(App::app_async_physics, _LC("GameSettings", "Async physics"));
266 DrawGCheckbox(App::app_disable_online_api, _LC("GameSettings", "Disable online api"));
267
268 if (ImGui::Button(_LC("GameSettings", "Update cache")))
269 {
273 }
274}
275
277{
278 ImGui::TextDisabled("%s", _LC("GameSettings", "Simulation settings"));
279
280 DrawGCombo(App::sim_gearbox_mode, _LC("GameSettings", "Gearbox mode"),
282
283 //DrawGCheckbox(App::gfx_flexbody_cache, "Enable flexbody cache");
284
285 DrawGCheckbox(App::sim_spawn_running, _LC("GameSettings", "Engines spawn running"));
286
287 DrawGCheckbox(App::sim_replay_enabled, _LC("GameSettings", "Replay mode"));
288 if (App::sim_replay_enabled->getBool())
289 {
290 DrawGIntBox(App::sim_replay_length, _LC("GameSettings", "Replay length"));
291 DrawGIntBox(App::sim_replay_stepping, _LC("GameSettings", "Replay stepping"));
292 }
293
294 DrawGCheckbox(App::sim_realistic_commands, _LC("GameSettings", "Realistic forward commands"));
295
296 DrawGCheckbox(App::sim_races_enabled, _LC("GameSettings", "Enable races"));
297
298 DrawGCheckbox(App::sim_no_self_collisions, _LC("GameSettings", "No intra truck collisions"));
299 DrawGCheckbox(App::sim_no_collisions, _LC("GameSettings", "No inter truck collisions"));
300
301 DrawGCheckbox(App::io_discord_rpc, _LC("GameSettings", "Discord Rich Presence"));
302
303 DrawGCheckbox(App::sim_quickload_dialog, _LC("GameSettings", "Show confirm. UI dialog for quickload"));
304
305 DrawGCheckbox(App::sim_tuning_enabled, _LC("GameSettings", "Enable vehicle tuning"));
306}
307
309{
310#ifdef USE_OPENAL
311 ImGui::TextDisabled("%s", _LC("GameSettings", "Audio settings"));
312
313 static const ALCchar *devices = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
314 const ALCchar *device = devices, *next = devices + 1;
315 std::vector<std::string> audio_devices;
316
317 while (device && *device != '\0' && next && *next != '\0')
318 {
319 audio_devices.push_back(device);
320 size_t len = strlen(device);
321 device += (len + 1);
322 next += (len + 2);
323 }
324
325 const auto it = std::find(audio_devices.begin(), audio_devices.end(), App::audio_device_name->getStr());
326 int device_id = it != audio_devices.end() ? std::distance(audio_devices.begin(), it) : 0;
327 if (ImGui::Combo(_LC("GameSettings", "Audio device"), &device_id, devices))
328 {
329 App::audio_device_name->setStr(audio_devices[device_id]);
330 }
331
332 DrawGCheckbox(App::audio_enable_creak, _LC("GameSettings", "Creak sound"));
333 DrawGCheckbox(App::audio_enable_efx, _LC("GameSettings", "Enable advanced sound effects via OpenAL EFX"));
334
335 if (App::audio_enable_efx->getBool())
336 {
337 DrawGCombo(App::audio_efx_reverb_engine, _LC("GameSettings", "OpenAL Reverb engine"), m_combo_items_efx_reverb_engine.c_str());
338 DrawGCheckbox(App::audio_enable_obstruction, _LC("GameSettings", "Sound obstruction"));
339 if (App::audio_enable_obstruction->getBool())
340 {
341 DrawGCheckbox(App::audio_force_obstruction_inside_vehicles, _LC("GameSettings", "Force obstruction inside vehicles"));
342 }
343 DrawGCheckbox(App::audio_enable_occlusion, _LC("GameSettings", "Sound occlusion"));
344 DrawGCheckbox(App::audio_enable_directed_sounds, _LC("GameSettings", "Directed sounds (exhausts etc.)"));
345 if (App::audio_efx_reverb_engine->getEnum<EfxReverbEngine>() == EfxReverbEngine::EAXREVERB)
346 {
347 DrawGCheckbox(App::audio_enable_reflection_panning, _LC("GameSettings", "Early reflections panning (experimental)"));
348 }
349
350 DrawGCheckbox(App::audio_engine_controls_environmental_audio, _LC("GameSettings", "Engine exerts automatic control over environmental audio"));
351
353 {
354 DrawGTextEdit(App::audio_default_efx_preset, _LC("GameSettings", "Default EFX Reverb Preset"), m_buf_audio_default_efx_preset);
356 }
357 }
358
359 DrawGCheckbox(App::audio_menu_music, _LC("GameSettings", "Main menu music"));
360 DrawGFloatSlider(App::audio_master_volume, _LC("GameSettings", "Master volume"), 0, 1);
361 DrawGFloatSlider(App::audio_doppler_factor, _LC("GameSettings", "Doppler factor"), 0, 10);
362#endif // USE_OPENAL
363}
364
366{
367 ImGui::TextDisabled("%s", _LC("GameSettings", "UI settings"));
368
369 this->DrawUiPresetCombo();
370
371 this->DrawUiDefaultDashboard(m_ui_known_dash_truck, App::ui_default_truck_dash, CID_DashboardsTruck, _LC("GameSettings", "Default truck dashboard"));
372 this->DrawUiDefaultDashboard(m_ui_known_dash_boat, App::ui_default_boat_dash, CID_DashboardsBoat, _LC("GameSettings", "Default boat dashboard"));
373
374 this->DrawUiScaleSlider();
375
376 DrawGCheckbox(App::gfx_speedo_imperial, _LC("GameSettings", "Imperial units"));
377
378 DrawGCheckbox(App::ui_dashboard_cinecam, _LC("GameSettings", "Hide dashboard in cinecam view"));
379
380 DrawGCheckbox(App::ui_show_live_repair_controls, _LC("GameSettings", "Show controls in live repair box"));
381
382 DrawGCheckbox(App::ui_show_vehicle_buttons, _LC("GameSettings", "Show vehicle buttons menu"));
383
384 DrawGCheckbox(App::ui_always_show_fullsize, _LC("GameSettings", "Always show full size help image"));
385
386 DrawGCheckbox(App::gfx_surveymap_icons, _LC("GameSettings", "Overview map icons"));
387 if (App::gfx_surveymap_icons->getBool())
388 {
389 DrawGCheckbox(App::gfx_declutter_map, _LC("GameSettings", "Declutter overview map"));
390 }
391
392}
393
395{
396 ImGui::TextDisabled("%s", _LC("GameSettings", "Video settings"));
397
398 DrawGCombo(App::gfx_flares_mode, _LC("GameSettings", "Light sources"),
400
401 DrawGCombo(App::gfx_shadow_type, _LC("GameSettings", "Shadow type (requires restart)"),
403
404 if (App::gfx_shadow_type->getEnum<GfxShadowType>() != GfxShadowType::NONE)
405 {
406 DrawGCheckbox(App::gfx_reduce_shadows, _LC("GameSettings", "Shadow optimizations"));
407 if (App::gfx_shadow_type->getEnum<GfxShadowType>() == GfxShadowType::PSSM)
408 {
409 DrawGIntSlider(App::gfx_shadow_quality, _LC("GameSettings", "Shadow quality"), 0, 3);
410 }
411 }
412
413 DrawGCombo(App::gfx_sky_mode, _LC("GameSettings", "Sky gfx"),
414 m_combo_items_sky_mode.c_str());
415
416 if (App::gfx_sky_mode->getEnum<GfxSkyMode>() != GfxSkyMode::SKYX)
417 {
418 DrawGIntSlider(App::gfx_sight_range, _LC("GameSettings", "Sight range (meters)"), 100, 5000);
419 }
420
421 DrawGCombo(App::gfx_texture_filter , _LC("GameSettings", "Texture filtering"),
423
424 if (App::gfx_texture_filter->getEnum<GfxTexFilter>() == GfxTexFilter::ANISOTROPIC)
425 {
426 int anisotropy = Ogre::Math::Clamp(App::gfx_anisotropy->getInt(), 1, 16);
427 int selection = std::log2(anisotropy);
428 if (ImGui::Combo(_LC("GameSettings", "Anisotropy"), &selection, "1\0""2\0""4\0""8\0""16\0\0"))
429 {
430 App::gfx_anisotropy->setVal(std::pow(2, selection));
431 }
432 }
433
434 DrawGCombo(App::gfx_vegetation_mode, _LC("GameSettings", "Vegetation density"),
436
437 DrawGCombo(App::gfx_water_mode, _LC("GameSettings", "Water gfx"),
439
440 DrawGIntSlider(App::gfx_fps_limit, _LC("GameSettings", "FPS limit"), 0, 240);
441
442 DrawGIntCheck(App::gfx_particles_mode, _LC("GameSettings", "Enable particle gfx"));
443 DrawGIntCheck(App::gfx_skidmarks_mode, _LC("GameSettings", "Enable skidmarks"));
444
445 DrawGCheckbox(App::gfx_auto_lod, _LC("GameSettings", "Enable automatic mesh LOD generator (Increases loading times)"));
446
447 DrawGCheckbox(App::gfx_envmap_enabled, _LC("GameSettings", "Realtime reflections"));
448 if (App::gfx_envmap_enabled->getBool())
449 {
450 ImGui::PushItemWidth(ImGui::GetFontSize() * 7.8125f); // Width includes [+/-] buttons
451 DrawGIntSlider(App::gfx_envmap_rate, _LC("GameSettings", "Realtime refl. update rate"), 0, 2);
452 ImGui::PopItemWidth();
453 }
454
455 DrawGCheckbox(App::gfx_enable_videocams, _LC("GameSettings", "Render video cameras"));
456 DrawGCheckbox(App::gfx_water_waves, _LC("GameSettings", "Waves on water"));
457 DrawGCheckbox(App::gfx_alt_actor_materials, _LC("GameSettings", "Use alternate vehicle materials"));
458
459 DrawGCombo(App::gfx_extcam_mode, "Exterior camera mode",
461
462 DrawGIntSlider(App::gfx_camera_height, _LC("GameSettings", "Static camera height (meters)"), 1, 50);
463 DrawGIntSlider(App::gfx_fov_external_default, _LC("GameSettings", "Exterior field of view"), 10, 120);
464 DrawGIntSlider(App::gfx_fov_internal_default, _LC("GameSettings", "Interior field of view"), 10, 120);
465}
466
468{
469 ImGui::TextDisabled("%s", _LC("GameSettings", "Diagnostic options"));
470 ImGui::TextColored(ImVec4(0.89f,0.15f,0.21f,1.0f), "%s", _LC("GameSettings", "These settings are for advanced users only, you should only change these if you know what you're doing"));
471
472 DrawGTextEdit(App::diag_preset_terrain, _LC("GameSettings", "Preselected terrain"), m_buf_diag_preset_terrain);
473 DrawGTextEdit(App::diag_preset_vehicle, _LC("GameSettings", "Preselected vehicle"), m_buf_diag_preset_vehicle);
474 DrawGTextEdit(App::diag_preset_veh_config, _LC("GameSettings", "Presel. veh. config"), m_buf_diag_preset_veh_config);
475 DrawGCheckbox(App::diag_preset_veh_enter, _LC("GameSettings", "Enter preselected vehicle"));
476 DrawGCheckbox(App::diag_auto_spawner_report, _LC("GameSettings", "Auto actor spawner report"));
477 DrawGCheckbox(App::diag_rig_log_node_import, _LC("GameSettings", "Log node import (spawn)"));
478 DrawGCheckbox(App::diag_rig_log_node_stats, _LC("GameSettings", "Log node stats (spawn)"));
479 DrawGCheckbox(App::diag_camera, _LC("GameSettings", "Debug camera (rails)"));
480 DrawGCheckbox(App::diag_truck_mass, _LC("GameSettings", "Debug actor mass"));
481 DrawGCheckbox(App::diag_envmap, _LC("GameSettings", "Debug realtime reflections"));
482 DrawGCheckbox(App::diag_videocameras, _LC("GameSettings", "Debug videocameras"));
483 DrawGCheckbox(App::diag_warning_texture, _LC("GameSettings", "Debug textures"));
484 DrawGCheckbox(App::diag_hide_broken_beams, _LC("GameSettings", "Hide broken beams"));
485 DrawGCheckbox(App::diag_hide_wheel_info, _LC("GameSettings", "Hide wheel info"));
486 DrawGCheckbox(App::diag_hide_wheels, _LC("GameSettings", "Hide wheels"));
487 DrawGCheckbox(App::diag_hide_nodes, _LC("GameSettings", "Hide nodes"));
488 DrawGCheckbox(App::diag_log_console_echo, _LC("GameSettings", "Echo log to console"));
489 DrawGCheckbox(App::diag_log_beam_break, _LC("GameSettings", "Log beam breaking"));
490 DrawGCheckbox(App::diag_log_beam_deform, _LC("GameSettings", "Log beam deforming"));
491 DrawGCheckbox(App::diag_log_beam_trigger, _LC("GameSettings", "Log beam triggers"));
492 DrawGCheckbox(App::diag_allow_window_resize, _LC("GameSettings", "Allow game window resizing"));
493 DrawGCheckbox(App::diag_use_mygui_logfile, _LC("GameSettings", "Enable MyGUI.log (needs restart)"));
494 if (ImGui::Button(_LC("GameSettings", "Rebuild cache")))
495 {
499 }
500}
501
503{
504 ImGui::TextDisabled("%s", _LC("GameSettings", "Controller options"));
505
507 DrawGCombo(App::io_input_grab_mode, _LC("GameSettings", "Input grab mode"), m_combo_items_input_grab.c_str());
508 if (io_input_grab_mode_old != App::io_input_grab_mode->getEnum<IoInputGrabMode>())
509 {
511 // This may take a second - display a 'please wait' box
514 _LC("GameSettings", "Restarting input subsystem, please wait..."), /*render_frame:*/false);
515 }
516
517 DrawGFloatSlider(App::io_analog_smoothing, _LC("GameSettings", "Analog Input Smoothing"), 0.5f, 2.0f);
518 DrawGFloatSlider(App::io_analog_sensitivity, _LC("GameSettings", "Analog Input Sensitivity"), 0.5f, 2.0f);
519 DrawGFloatSlider(App::io_blink_lock_range, _LC("GameSettings", "Blinker Lock Range"), 0.1f, 1.0f);
520
521 DrawGCheckbox(App::io_arcade_controls, _LC("GameSettings", "Use arcade controls"));
522 DrawGCheckbox(App::io_invert_orbitcam, _LC("GameSettings", "Invert orbit camera"));
523
524 DrawGCheckbox(App::io_ffb_enabled, _LC("GameSettings", "Enable ForceFeedback"));
525 if (App::io_ffb_enabled->getBool())
526 {
527 ImGui::PushItemWidth(ImGui::GetFontSize() * 7.8125f);
528 DrawGFloatBox(App::io_ffb_camera_gain, _LC("GameSettings", "FFB camera gain"));
529 DrawGFloatBox(App::io_ffb_center_gain, _LC("GameSettings", "FFB center gain"));
530 DrawGFloatBox(App::io_ffb_master_gain, _LC("GameSettings", "FFB master gain"));
531 DrawGFloatBox(App::io_ffb_stress_gain, _LC("GameSettings", "FFB stress gain"));
532 ImGui::PopItemWidth();
533 }
534
535 DrawGIntCheck(App::io_outgauge_mode, _LC("GameSettings", "Enable OutGauge protocol"));
536 if (App::io_outgauge_mode->getBool())
537 {
538 DrawGTextEdit(App::io_outgauge_ip, _LC("GameSettings", "OutGauge IP"), m_buf_io_outgauge_ip);
539 ImGui::PushItemWidth(ImGui::GetFontSize() * 7.8125f);
540 DrawGIntBox(App::io_outgauge_port, _LC("GameSettings", "OutGauge port"));
541 DrawGIntBox(App::io_outgauge_id, _LC("GameSettings", "OutGauge ID"));
542 DrawGFloatBox(App::io_outgauge_delay, _LC("GameSettings", "OutGauge delay"));
543 ImGui::PopItemWidth();
544 }
545}
546
548{
549 m_is_visible = v;
550 if (!v && App::app_state->getEnum<AppState>() == RoR::AppState::MAIN_MENU)
551 {
553 }
554
555 // Initialize temp values
557
558 // Pre-format combobox strings.
560 {
567 }
568
570 {
577 }
578
580 {
584 }
585
586 if (m_combo_items_sky_mode == "")
587 {
592 }
593
594 if (m_combo_items_tex_filter == "")
595 {
601 }
602
603 if (m_combo_items_vegetation == "")
604 {
610 }
611
612 if (m_combo_items_water_mode == "")
613 {
621 }
622
624 {
629 }
630
631 if (m_combo_items_input_grab == "")
632 {
637 }
638
640 {
645 }
646
648 {
654 }
655}
656
658{
659 ImGui::PushID("uiPreset");
660
661 ImGui::SetNextItemWidth(UI_SELECTOR_WIDTH * ImGui::GetFontSize());
662 if (DrawGCombo(App::ui_preset, _LC("TopMenubar", "UI Preset"), m_cached_uipreset_combo_string.c_str()))
663 {
665 }
666
667 if (ImGui::IsItemHovered())
668 {
669 ImGui::BeginTooltip();
670 const float COLLUMNWIDTH_NAME = ImGui::GetFontSize() * 10.9375f;
671 const float COLLUMNWIDTH_VALUE = ImGui::GetFontSize() * 3.75f;
672 // Hack to make space for the table (doesn't autoresize)
673 ImGui::Dummy(ImVec2(COLLUMNWIDTH_NAME + COLLUMNWIDTH_VALUE*((int)UiPreset::Count), 1.f));
674
675 // UiPresets table
676 ImGui::Columns((int)UiPreset::Count + 1);
677 ImGui::SetColumnWidth(0, COLLUMNWIDTH_NAME);
678 for (int i = 0; i < (int)UiPreset::Count; i++)
679 {
680 ImGui::SetColumnWidth(i+1, COLLUMNWIDTH_VALUE);
681 }
682
683 // table header
684 ImGui::TextDisabled("%s", "Setting");
685 ImGui::NextColumn();
686 for (int i = 0; i < (int)UiPreset::Count; i++)
687 {
688 ImGui::TextDisabled("%s", ToLocalizedString((UiPreset)i).c_str());
689 ImGui::NextColumn();
690 }
691
692 // table body
693 ImGui::Separator();
694
695 int presetId = 0;
696 while (UiPresets[presetId].uip_cvar != nullptr)
697 {
698 ImGui::Text("%s", UiPresets[presetId].uip_cvar);
699 ImGui::NextColumn();
700 for (int i = 0; i < (int)UiPreset::Count; i++)
701 {
702 ImGui::Text("%s", UiPresets[presetId].uip_values[i].c_str());
703 ImGui::NextColumn();
704 }
705
706 presetId++;
707 }
708
709 // end table
710 ImGui::Columns(1);
711 ImGui::EndTooltip();
712 }
713
714 ImGui::PopID(); //"uiPreset"
715}
716
717void GameSettings::DrawUiDefaultDashboard(CacheEntryPtr& entry, CVar* cvar, CacheCategoryId category_id, const std::string& label)
718{
719 if (!entry || entry->fname != cvar->getStr())
720 {
721 entry = App::GetCacheSystem()->FindEntryByFilename(LT_DashBoard, /* partial: */false, cvar->getStr());
722 }
723
724 ImGui::AlignTextToFramePadding();
725 std::string caption = fmt::format("{}##truck_dash", entry ? entry->dname : cvar->getStr());
726 if (ImGui::Button(caption.c_str(), ImVec2(UI_SELECTOR_WIDTH * ImGui::GetFontSize(), 0.f)))
727 {
728 default_dash_being_selected = category_id;
731 }
732 ImGui::SameLine();
733 ImGui::Text("%s", label.c_str());
734}
735
737{
738 ImGui::SetNextItemWidth(UI_SELECTOR_WIDTH * ImGui::GetFontSize());
739 ImGui::SliderFloat(_LC("GameSettings", "UI scale factor"),
741 // Reinit UI on slider release
742 if (!ImGui::IsItemActive() && m_ui_scale_slider_temp != App::ui_scale_factor->getFloat())
743 {
746 }
747}
System integration layer; inspired by OgreBites::ApplicationContext.
A database of user-installed content alias 'mods' (vehicles, terrains...)
Game state manager and message-queue provider.
#define _LC(ctx, str)
Definition Language.h:38
Ogre::Root * GetOgreRoot()
Definition AppContext.h:68
Quake-style console variable, defined in RoR.cfg or crated via Console UI and scripts.
Definition CVar.h:53
T getEnum() const
Definition CVar.h:99
float getFloat() const
Definition CVar.h:96
std::string const & getStr() const
Definition CVar.h:95
void setStr(std::string const &str)
Definition CVar.h:83
void setVal(T val)
Definition CVar.h:72
Ogre::String fname
filename
Definition CacheSystem.h:67
Ogre::String dname
name parsed from the file
Definition CacheSystem.h:70
CacheEntryPtr FindEntryByFilename(RoR::LoaderType type, bool partial, const std::string &_filename_maybe_bundlequalified)
Returns NULL if none found; "Bundle-qualified" format also specifies the ZIP/directory in modcache,...
std::string m_combo_items_tex_filter
std::string m_combo_items_shadow_type
CacheCategoryId default_dash_being_selected
Str< 1000 > m_buf_app_extra_mod_dir
std::string m_combo_items_extcam_mode
Str< 1000 > m_buf_diag_preset_terrain
const float UI_SELECTOR_WIDTH
Relative to font size.
Str< 1000 > m_buf_diag_preset_vehicle
std::string m_combo_items_sky_mode
Str< 1000 > m_buf_audio_default_efx_preset
CacheEntryPtr m_ui_known_dash_truck
std::string m_combo_items_water_mode
Str< 1000 > m_buf_audio_force_listener_efx_preset
std::string m_cached_uipreset_combo_string
void DrawUiDefaultDashboard(CacheEntryPtr &entry, CVar *cvar, CacheCategoryId category_id, const std::string &label)
std::string m_combo_items_input_grab
std::string m_combo_items_gearbox_mode
std::string m_combo_items_light_sources
CacheEntryPtr m_ui_known_dash_boat
Str< 1000 > m_buf_diag_preset_veh_config
std::string m_combo_items_efx_reverb_engine
std::string m_combo_items_vegetation
void SetProgress(int _percent, const std::string &_text="", bool render_frame=true)
GUI::GameSettings GameSettings
Definition GUIManager.h:120
void ApplyUiPreset()
reads cvar 'ui_preset'
GUI::LoadingWindow LoadingWindow
Definition GUIManager.h:133
GUI::GameMainMenu GameMainMenu
Definition GUIManager.h:118
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
std::vector< std::pair< std::string, std::string > > getLanguages()
Definition Language.h:50
@ MSG_GUI_OPEN_MENU_REQUESTED
@ MSG_APP_MODCACHE_PURGE_REQUESTED
Definition Application.h:93
@ MSG_APP_REINIT_UI_REQUESTED
Reloads fonts and re-applies style, i.e. after changing 'ui_scale_factor'.
Definition Application.h:98
@ MSG_APP_MODCACHE_UPDATE_REQUESTED
Definition Application.h:92
@ MSG_GUI_OPEN_SELECTOR_REQUESTED
Payload = LoaderType* (owner), Description = GUID | empty.
@ MSG_APP_REINIT_INPUT_REQUESTED
Definition Application.h:97
std::string ToLocalizedString(SimGearboxMode e)
@ MANUAL_STICK
Fully manual: stick shift.
@ MANUAL_RANGES
Fully manual: stick shift with ranges.
@ SEMI_AUTO
Manual shift with auto clutch.
@ MANUAL
Fully manual: sequential shift.
@ AUTO
Automatic shift.
CVar * diag_warning_texture
CVar * gfx_sky_mode
CVar * io_ffb_enabled
AppContext * GetAppContext()
CVar * audio_force_listener_efx_preset
CVar * ui_show_live_repair_controls
bool
CVar * audio_efx_reverb_engine
CVar * audio_menu_music
CVar * app_screenshot_format
CVar * audio_enable_directed_sounds
CVar * io_outgauge_delay
CVar * gfx_water_mode
CVar * ui_show_vehicle_buttons
CVar * audio_enable_obstruction
CVar * io_outgauge_mode
CVar * diag_auto_spawner_report
CVar * gfx_extcam_mode
CVar * sim_spawn_running
CVar * io_blink_lock_range
CVar * diag_log_beam_trigger
CVar * audio_doppler_factor
CVar * diag_rig_log_node_import
CVar * ui_dashboard_cinecam
CVar * diag_allow_window_resize
CVar * gfx_envmap_rate
CVar * app_language
CVar * app_skip_main_menu
CVar * io_invert_orbitcam
CVar * diag_rig_log_node_stats
CVar * ui_preset
enum RoR::UiPreset
CVar * gfx_fov_internal_default
CVar * sim_replay_length
CVar * sim_races_enabled
CVar * app_rendersys_override
CVar * io_outgauge_port
CVar * audio_default_efx_preset
CVar * audio_enable_reflection_panning
CVar * audio_enable_creak
CVar * diag_preset_vehicle
CVar * ui_scale_factor
float; Resizes imgui-based UI (fonts + style sizes); apply by pushing MSG_APP_REINIT_UI_REQUESTED.
CVar * gfx_sight_range
CVar * app_country
CVar * audio_force_obstruction_inside_vehicles
CVar * gfx_anisotropy
CVar * gfx_particles_mode
CVar * diag_hide_wheels
CVar * diag_truck_mass
CVar * io_ffb_stress_gain
CVar * diag_hide_nodes
CVar * audio_master_volume
GUIManager * GetGuiManager()
GameContext * GetGameContext()
CVar * gfx_camera_height
CVar * sim_tuning_enabled
CVar * io_ffb_center_gain
CVar * gfx_auto_lod
CVar * io_analog_sensitivity
CVar * app_state
CVar * gfx_water_waves
CVar * diag_log_beam_deform
CVar * sim_no_collisions
CVar * audio_device_name
CVar * sim_realistic_commands
CVar * sim_replay_stepping
CVar * sim_no_self_collisions
CVar * gfx_fps_limit
CVar * gfx_vegetation_mode
CVar * diag_envmap
CVar * diag_hide_wheel_info
CVar * gfx_declutter_map
CVar * diag_camera
CVar * audio_enable_efx
CVar * app_disable_online_api
CVar * io_outgauge_id
CVar * gfx_flares_mode
CVar * ui_default_boat_dash
string; name of the '.dashboard' file in modcache.
CVar * ui_default_truck_dash
string; name of the '.dashboard' file in modcache.
CVar * sim_gearbox_mode
CVar * io_ffb_master_gain
CVar * diag_hide_broken_beams
CVar * gfx_alt_actor_materials
CacheSystem * GetCacheSystem()
CVar * diag_preset_veh_enter
CVar * gfx_speedo_imperial
CVar * ui_always_show_fullsize
CVar * diag_use_mygui_logfile
CVar * sim_quickload_dialog
CVar * gfx_envmap_enabled
CVar * diag_preset_terrain
CVar * gfx_reduce_shadows
CVar * diag_videocameras
CVar * audio_enable_occlusion
CVar * audio_engine_controls_environmental_audio
CVar * gfx_surveymap_icons
CVar * io_ffb_camera_gain
CVar * io_outgauge_ip
CVar * diag_preset_veh_config
CVar * io_discord_rpc
CVar * gfx_texture_filter
CVar * gfx_fov_external_default
CVar * diag_log_beam_break
CVar * io_input_grab_mode
CVar * gfx_enable_videocams
CVar * sim_replay_enabled
CVar * io_arcade_controls
CVar * io_analog_smoothing
CVar * gfx_shadow_quality
LanguageEngine * GetLanguageEngine()
CVar * diag_log_console_echo
CVar * app_extra_mod_path
CVar * gfx_shadow_type
CVar * gfx_skidmarks_mode
CVar * app_async_physics
@ CURR_VEHICLE_HEAD_ONLY
Only current vehicle, main lights.
@ ALL_VEHICLES_HEAD_ONLY
All vehicles, main lights.
@ NONE
None (fastest)
@ NO_LIGHTSOURCES
No light sources.
@ ALL_VEHICLES_ALL_LIGHTS
All vehicles, all lights.
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
@ LT_DashBoard
void DrawGFloatBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:336
void DrawGTextEdit(CVar *cvar, const char *label, Str< 1000 > &buf)
Definition GUIUtils.cpp:345
static const float UI_SCALE_FACTOR_MAX
void DrawGIntSlider(CVar *cvar, const char *label, int v_min, int v_max)
Definition GUIUtils.cpp:316
UiPreset
See UiPresets[] list in GUIManager.cpp (declared extern in GUIManager.h)
@ FULL_FAST
Reflection + refraction (speed optimized)
@ FULL_HQ
Reflection + refraction (quality optimized)
@ BASIC
Basic (fastest)
@ REFLECT
Reflection.
IoInputGrabMode
void DrawGIntBox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:307
void ImTerminateComboboxString(std::string &target)
Definition GUIUtils.cpp:434
void ImAddItemToComboboxString(std::string &target, std::string const &item)
Definition GUIUtils.cpp:412
static const float UI_SCALE_FACTOR_MIN
@ CAELUM
Caelum (best looking, slower)
@ SANDSTORM
Sandstorm (fastest)
@ SKYX
SkyX (best looking, slower)
void DrawGFloatSlider(CVar *cvar, const char *label, float v_min, float v_max)
Definition GUIUtils.cpp:326
UiPresetEntry UiPresets[]
Global list of UI Presets, selectable via Settings menu in TopMenubar.
bool DrawGCheckbox(CVar *cvar, const char *label)
Definition GUIUtils.cpp:287
CacheCategoryId
@ CID_DashboardsTruck
@ CID_DashboardsBoat
void DrawGIntCheck(CVar *cvar, const char *label)
Definition GUIUtils.cpp:298
bool DrawGCombo(CVar *cvar, const char *label, const char *values)
Definition GUIUtils.cpp:361
Unified game event system - all requests and state changes are reported using a message.
Definition GameContext.h:52