RigsofRods
Soft-body Physics Simulation
GUI_TopMenubar.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 2016-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 
25 
26 #pragma once
27 
28 #include "AddonPartFileFormat.h"
29 #include "CacheSystem.h"
30 #include "RoRnet.h"
31 
32 #include <imgui.h>
33 #include <imgui_internal.h>
34 #include <vector>
35 #include <rapidjson/document.h>
36 
37 struct ai_events
38 {
39  Ogre::Vector3 position;
40  int speed = -1;
41 };
42 
43 namespace RoR {
44 namespace GUI {
45 
47 {
48 public:
49  const float MENU_Y_OFFSET = 40.f;
50  const float PANEL_HOVERBOX_HEIGHT = 50.f;
51  const ImVec4 GRAY_HINT_TEXT = ImVec4(0.62f, 0.62f, 0.61f, 1.f);
52  const ImVec4 WHITE_TEXT = ImVec4(0.9f, 0.9f, 0.9f, 1.f);
53  const ImVec4 GREEN_TEXT = ImVec4(0.0f, 0.9f, 0.0f, 1.f);
54  const ImVec4 ORANGE_TEXT = ImVec4(0.9f, 0.6f, 0.0f, 1.f);
55  const ImVec4 RED_TEXT = ImVec4(1.00f, 0.00f, 0.00f, 1.f);
56  const ImVec2 MENU_HOVERBOX_PADDING = ImVec2(25.f, 10.f);
57  const int TUNING_SUBJECTID_USE_NAME = -2;
58 
61 
62  TopMenubar();
63  ~TopMenubar();
64 
65  void Draw(float dt);
66  bool ShouldDisplay(ImVec2 window_pos);
67 
69 
70  // Vehicle AI
71  std::vector<ai_events> ai_waypoints;
72  int ai_num = 1;
73  int ai_speed = 50;
74  int ai_times = 1;
75  int ai_altitude = 1000;
76  int ai_distance = 20;
78  Ogre::String ai_fname = "95bbUID-agoras.truck";
79  Ogre::String ai_dname = "Bus RVI Agora S";
80  Ogre::String ai_sectionconfig = "";
81  std::string ai_skin = "";
82  bool ai_select = false;
83  bool ai_rec = false;
84  int ai_mode = 0;
85  bool ai_menu = false;
86 
87  // Secondary selections for Drag Race and Crash driving modes
88  bool ai_select2 = false;
89  Ogre::String ai_fname2 = "95bbUID-agoras.truck";
90  Ogre::String ai_dname2 = "Bus RVI Agora S";
91  Ogre::String ai_sectionconfig2 = "";
92  std::string ai_skin2 = "";
93 
94  int ai_num_prev = 1;
95  int ai_speed_prev = 50;
97  int ai_times_prev = 1;
98  int ai_mode_prev = 0;
99 
100  // AI waypoint presets
102  void LoadBundledAiPresets(TerrainPtr terrain);
103  void RefreshAiPresets();
104  rapidjson::Document ai_presets_all;
105  rapidjson::Document ai_presets_extern;
108  rapidjson::Document ai_presets_bundled;
109 
110  // Tuning menu
112  std::vector<CacheEntryPtr> tuning_addonparts;
117  bool tuning_savebox_visible = false;
119  const ImVec4 TUNING_HOLDTOCONFIRM_COLOR = ImVec4(0.25f, 0.15f, 0.2f, 0.5f);
120  const float TUNING_HOLDTOCONFIRM_TIMELIMIT = 1.5f;
123  void RefreshTuningMenu();
124 
125 private:
126  bool IsMenuEnabled(TopMenu which);
127 
129  void DrawMpUserToActorList(RoRnet::UserInfo &user); // Multiplayer
130  void DrawSpecialStateBox(float top_offset);
131 
132  // Tuning menu helpers
133  void DrawTuningBoxedSubjectIdInline(int subject_id);
134  void DrawTuningProtectedChkRightAligned(const int subject_id, bool is_protected, ModifyProjectRequestType request_type_set, ModifyProjectRequestType request_type_reset, const std::string& subject = "");
135  void DrawTuningForceRemoveControls(const int subject_id, const std::string& name, const bool is_unwanted, const bool is_force_removed, ModifyProjectRequestType request_type_set, ModifyProjectRequestType request_type_reset);
136 
140 
144 
145  bool m_confirm_remove_all = false;
146 
147  float m_daytime = 0.f;
149  bool m_quickload = false;
150  std::string m_quicksave_name;
151  std::vector<std::string> m_savegame_names;
152 };
153 
154 } // namespace GUI
155 } // namespace RoR
RoR::GUI::TopMenubar::m_quickload
bool m_quickload
Definition: GUI_TopMenubar.h:149
RoR::GUI::TopMenubar::m_confirm_remove_all
bool m_confirm_remove_all
Definition: GUI_TopMenubar.h:145
RoR::GUI::TopMenubar::ShouldDisplay
bool ShouldDisplay(ImVec2 window_pos)
Definition: GUI_TopMenubar.cpp:1939
RoR::GUI::TopMenubar::GRAY_HINT_TEXT
const ImVec4 GRAY_HINT_TEXT
Definition: GUI_TopMenubar.h:51
RoR::GUI::TopMenubar::MENU_HOVERBOX_PADDING
const ImVec2 MENU_HOVERBOX_PADDING
Definition: GUI_TopMenubar.h:56
RoR::GUI::TopMenubar::StateBox::STATEBOX_NONE
@ STATEBOX_NONE
RoR::GUI::TopMenubar::ai_presets_extern
rapidjson::Document ai_presets_extern
Externally provided presets (GitHub repo or local 'savegames/waypoints.json' file).
Definition: GUI_TopMenubar.h:105
RoR::GUI::TopMenubar::ai_fname2
Ogre::String ai_fname2
Definition: GUI_TopMenubar.h:89
RoR::GUI::TopMenubar::DrawTuningBoxedSubjectIdInline
void DrawTuningBoxedSubjectIdInline(int subject_id)
Definition: GUI_TopMenubar.cpp:2564
RoR::GUI::TopMenubar::FetchExternAiPresetsOnBackground
void FetchExternAiPresetsOnBackground()
Initiate threaded (down)load of 'extern' waypoints from GitHub repo.
Definition: GUI_TopMenubar.cpp:2403
RoR::GUI::TopMenubar::tuning_savebox_buf
Str< 200 > tuning_savebox_buf
Buffer for tuneup name to be saved.
Definition: GUI_TopMenubar.h:116
RoR::GUI::TopMenubar::ai_fname
Ogre::String ai_fname
Definition: GUI_TopMenubar.h:78
ai_events::position
Ogre::Vector3 position
Definition: GUI_TopMenubar.h:39
RoR::GUI::TopMenubar::GREEN_TEXT
const ImVec4 GREEN_TEXT
Definition: GUI_TopMenubar.h:53
RoR::GUI::TopMenubar::ai_num
int ai_num
Definition: GUI_TopMenubar.h:72
RoR::GUI::TopMenubar::TopMenubar
TopMenubar()
Definition: GUI_TopMenubar.cpp:139
RoR::GUI::TopMenubar::TopMenu::TOPMENU_TUNING
@ TOPMENU_TUNING
RoR::GUI::TopMenubar::ai_presets_all
rapidjson::Document ai_presets_all
The full list of presets, used for display. Needs to be refreshed when terrain is loaded.
Definition: GUI_TopMenubar.h:104
RoR::GUI::TopMenubar::DrawSpecialStateBox
void DrawSpecialStateBox(float top_offset)
Definition: GUI_TopMenubar.cpp:2126
RoR::ModifyProjectRequestType
ModifyProjectRequestType
Definition: CacheSystem.h:232
RoRnet::UserInfo
Definition: RoRnet.h:170
RoR::GUI::TopMenubar::ai_position_scheme
int ai_position_scheme
Definition: GUI_TopMenubar.h:77
RoR::GUI::TopMenubar::ai_position_scheme_prev
int ai_position_scheme_prev
Definition: GUI_TopMenubar.h:96
RoR::GUI::TopMenubar::m_quicksave_name
std::string m_quicksave_name
Definition: GUI_TopMenubar.h:150
RoR::GUI::TopMenubar::ai_skin2
std::string ai_skin2
Definition: GUI_TopMenubar.h:92
RoR::GUI::TopMenubar::MENU_Y_OFFSET
const float MENU_Y_OFFSET
Definition: GUI_TopMenubar.h:49
RoR::GUI::TopMenubar::ai_altitude
int ai_altitude
Definition: GUI_TopMenubar.h:75
RoR::CacheQuery
Definition: CacheSystem.h:182
RoR::GUI::TopMenubar::PANEL_HOVERBOX_HEIGHT
const float PANEL_HOVERBOX_HEIGHT
Definition: GUI_TopMenubar.h:50
RoR::GUI::TopMenubar::TopMenu
TopMenu
Definition: GUI_TopMenubar.h:59
RoR::GUI::TopMenubar::TopMenu::TOPMENU_SAVEGAMES
@ TOPMENU_SAVEGAMES
RoR::GUI::TopMenubar::ai_waypoints
std::vector< ai_events > ai_waypoints
Definition: GUI_TopMenubar.h:68
RoR::GUI::TopMenubar::IsVisible
bool IsVisible()
Definition: GUI_TopMenubar.h:68
RoR::GUI::TopMenubar::TopMenu::TOPMENU_NONE
@ TOPMENU_NONE
RoR::GUI::TopMenubar::LoadBundledAiPresets
void LoadBundledAiPresets(TerrainPtr terrain)
Loads JSON files from [AI Presets] section in .terrn2 file format.
Definition: GUI_TopMenubar.cpp:2364
RoR::AddonPartConflictVec
std::vector< AddonPartConflict > AddonPartConflictVec
Definition: AddonPartFileFormat.h:53
RefCountingObjectPtr< Terrain >
RoR::GUI::TopMenubar::m_waves_height
float m_waves_height
Definition: GUI_TopMenubar.h:148
RoR::GUI::TopMenubar::tuning_conflicts
AddonPartConflictVec tuning_conflicts
Conflicts between eligible addonparts tweaking the same element.
Definition: GUI_TopMenubar.h:114
RoR::GUI::TopMenubar::DrawTuningProtectedChkRightAligned
void DrawTuningProtectedChkRightAligned(const int subject_id, bool is_protected, ModifyProjectRequestType request_type_set, ModifyProjectRequestType request_type_reset, const std::string &subject="")
Definition: GUI_TopMenubar.cpp:2528
RoR::GUI::TopMenubar::ai_menu
bool ai_menu
Definition: GUI_TopMenubar.h:85
RoR::GUI::TopMenubar::tuning_savebox_visible
bool tuning_savebox_visible
User pressed 'save active' to open savebox.
Definition: GUI_TopMenubar.h:117
RoR::GUI::TopMenubar::ai_num_prev
int ai_num_prev
Definition: GUI_TopMenubar.h:94
RoR::GUI::TopMenubar::StateBox::STATEBOX_QUICK_REPAIR
@ STATEBOX_QUICK_REPAIR
RoR::GUI::TopMenubar::ai_rec
bool ai_rec
Definition: GUI_TopMenubar.h:83
RoR::GUI::TopMenubar::ai_speed
int ai_speed
Definition: GUI_TopMenubar.h:73
RoR::GUI::TopMenubar::TopMenu::TOPMENU_SIM
@ TOPMENU_SIM
RoR::GUI::TopMenubar::tuning_rwidget_cursorx_min
float tuning_rwidget_cursorx_min
Avoid drawing right-side widgets ('Delete' button or 'Protected' chk) over saved tuneup names.
Definition: GUI_TopMenubar.h:121
RoR::GUI::TopMenubar::WHITE_TEXT
const ImVec4 WHITE_TEXT
Definition: GUI_TopMenubar.h:52
RoR::GUI::TopMenubar::ai_presets_bundled
rapidjson::Document ai_presets_bundled
Presets bundled with the terrain, see [AI Presets] section in .terrn2 file format.
Definition: GUI_TopMenubar.h:108
RoR::GUI::TopMenubar::m_open_menu
TopMenu m_open_menu
Definition: GUI_TopMenubar.h:139
RoR::GUI::TopMenubar::ai_dname2
Ogre::String ai_dname2
Definition: GUI_TopMenubar.h:90
RoR::GUI::TopMenubar::TopMenu::TOPMENU_TOOLS
@ TOPMENU_TOOLS
RoR::GUI::TopMenubar::RED_TEXT
const ImVec4 RED_TEXT
Definition: GUI_TopMenubar.h:55
RoR::Str< 200 >
CacheSystem.h
A database of user-installed content alias 'mods' (vehicles, terrains...)
RoR::GUI::TopMenubar::DrawTuningForceRemoveControls
void DrawTuningForceRemoveControls(const int subject_id, const std::string &name, const bool is_unwanted, const bool is_force_removed, ModifyProjectRequestType request_type_set, ModifyProjectRequestType request_type_reset)
Definition: GUI_TopMenubar.cpp:2579
RoR::GUI::TopMenubar::m_daytime
float m_daytime
Definition: GUI_TopMenubar.h:147
RoR::GUI::TopMenubar::ai_times
int ai_times
Definition: GUI_TopMenubar.h:74
RoR::GUI::TopMenubar::Draw
void Draw(float dt)
Definition: GUI_TopMenubar.cpp:153
RoR::GUI::TopMenubar::ai_times_prev
int ai_times_prev
Definition: GUI_TopMenubar.h:97
RoR::GUI::TopMenubar::ai_presets_extern_fetching
bool ai_presets_extern_fetching
True if the (down)load of 'extern' waypoints is in progress.
Definition: GUI_TopMenubar.h:106
RoR::GUI::TopMenubar::ai_mode_prev
int ai_mode_prev
Definition: GUI_TopMenubar.h:98
RoR::GUI::TopMenubar
Definition: GUI_TopMenubar.h:46
RoR::GUI::TopMenubar::ai_skin
std::string ai_skin
Definition: GUI_TopMenubar.h:81
RoR::GUI::TopMenubar::tuning_addonparts
std::vector< CacheEntryPtr > tuning_addonparts
Addonparts eligible for current actor, both matched by GUID and force-installed by user via [browse a...
Definition: GUI_TopMenubar.h:112
RoR::GUI::TopMenubar::TUNING_HOLDTOCONFIRM_COLOR
const ImVec4 TUNING_HOLDTOCONFIRM_COLOR
Definition: GUI_TopMenubar.h:119
RoR::GUI::TopMenubar::StateBox::STATEBOX_RACE
@ STATEBOX_RACE
RoR::GUI::TopMenubar::RefreshTuningMenu
void RefreshTuningMenu()
Definition: GUI_TopMenubar.cpp:2433
RoR::GUI::TopMenubar::StateBox::STATEBOX_REPLAY
@ STATEBOX_REPLAY
RoR::GUI::TopMenubar::RefreshAiPresets
void RefreshAiPresets()
Refresh the list of presets, used for display. Needs to be called when terrain is loaded.
Definition: GUI_TopMenubar.cpp:2412
RoR::GUI::TopMenubar::ai_sectionconfig2
Ogre::String ai_sectionconfig2
Definition: GUI_TopMenubar.h:91
RoR::GUI::TopMenubar::m_state_box_hoverbox_min
ImVec2 m_state_box_hoverbox_min
Definition: GUI_TopMenubar.h:141
RoR::GUI::TopMenubar::ai_speed_prev
int ai_speed_prev
Definition: GUI_TopMenubar.h:95
RoR::GUI::TopMenubar::m_savegame_names
std::vector< std::string > m_savegame_names
Definition: GUI_TopMenubar.h:151
RoR::GUI::TopMenubar::StateBox
StateBox
Definition: GUI_TopMenubar.h:60
RoR::GUI::TopMenubar::m_state_box_hoverbox_max
ImVec2 m_state_box_hoverbox_max
Definition: GUI_TopMenubar.h:142
RoR::GUI::TopMenubar::TopMenu::TOPMENU_AI
@ TOPMENU_AI
RoR::GUI::TopMenubar::ai_mode
int ai_mode
Definition: GUI_TopMenubar.h:84
ai_events
Definition: GUI_TopMenubar.h:37
RoR::GUI::TopMenubar::TopMenu::TOPMENU_SETTINGS
@ TOPMENU_SETTINGS
RoR::GUI::TopMenubar::IsMenuEnabled
bool IsMenuEnabled(TopMenu which)
Definition: GUI_TopMenubar.cpp:2637
RoR::GUI::TopMenubar::ai_presets_extern_error
std::string ai_presets_extern_error
Error message from the (down)load of 'extern' waypoints.
Definition: GUI_TopMenubar.h:107
RoR::GUI::TopMenubar::tuning_hovered_addonpart
CacheEntryPtr tuning_hovered_addonpart
Definition: GUI_TopMenubar.h:122
RoR::GUI::TopMenubar::TopMenu::TOPMENU_ACTORS
@ TOPMENU_ACTORS
RoR::GUI::TopMenubar::ORANGE_TEXT
const ImVec4 ORANGE_TEXT
Definition: GUI_TopMenubar.h:54
RoR::GUI::TopMenubar::DrawActorListSinglePlayer
void DrawActorListSinglePlayer()
Definition: GUI_TopMenubar.cpp:2058
RoR::GUI::TopMenubar::tuning_saves
CacheQuery tuning_saves
Tuneups saved by user, with category ID RoR::CID_AddonpartUser
Definition: GUI_TopMenubar.h:115
AddonPartFileFormat.h
RoR::GUI::TopMenubar::tuning_addonparts_conflict_w_used
std::vector< bool > tuning_addonparts_conflict_w_used
1:1 with tuning_addonparts; True means the eligible (not used) addonpart conflicts with an used addon...
Definition: GUI_TopMenubar.h:113
ai_events::speed
int speed
Definition: GUI_TopMenubar.h:40
RoR::GUI::TopMenubar::ai_dname
Ogre::String ai_dname
Definition: GUI_TopMenubar.h:79
RoR::GUI::TopMenubar::ai_sectionconfig
Ogre::String ai_sectionconfig
Definition: GUI_TopMenubar.h:80
RoR::GUI::TopMenubar::ai_select2
bool ai_select2
Definition: GUI_TopMenubar.h:88
RoR::GUI::TopMenubar::StateBox::STATEBOX_LIVE_REPAIR
@ STATEBOX_LIVE_REPAIR
RoR::GUI::TopMenubar::~TopMenubar
~TopMenubar()
Definition: GUI_TopMenubar.cpp:148
RoR
Definition: AppContext.h:36
RoR::GUI::TopMenubar::ai_select
bool ai_select
Definition: GUI_TopMenubar.h:82
RoR::GUI::TopMenubar::m_open_menu_hoverbox_max
ImVec2 m_open_menu_hoverbox_max
Definition: GUI_TopMenubar.h:138
RoR::GUI::TopMenubar::m_open_menu_hoverbox_min
ImVec2 m_open_menu_hoverbox_min
Definition: GUI_TopMenubar.h:137
RoR::GUI::TopMenubar::tuning_savebox_overwrite
bool tuning_savebox_overwrite
Status of "Overwrite?" checkbox.
Definition: GUI_TopMenubar.h:118
RoR::GUI::TopMenubar::TUNING_HOLDTOCONFIRM_TIMELIMIT
const float TUNING_HOLDTOCONFIRM_TIMELIMIT
Delete button must be held for several sec to confirm.
Definition: GUI_TopMenubar.h:120
RoR::GUI::TopMenubar::ai_distance
int ai_distance
Definition: GUI_TopMenubar.h:76
RoR::GUI::TopMenubar::tuning_actor
ActorPtr tuning_actor
Detecting actor change to update cached values.
Definition: GUI_TopMenubar.h:111
RoR::GUI::TopMenubar::DrawMpUserToActorList
void DrawMpUserToActorList(RoRnet::UserInfo &user)
Definition: GUI_TopMenubar.cpp:1988
RoR::GUI::TopMenubar::m_state_box
StateBox m_state_box
Definition: GUI_TopMenubar.h:143
RoR::GUI::TopMenubar::TUNING_SUBJECTID_USE_NAME
const int TUNING_SUBJECTID_USE_NAME
Definition: GUI_TopMenubar.h:57