@@ -33,36 +33,6 @@ class GlobalsWindow : public OverlayWindow
3333
3434 ImGui::Begin (" Globals" , nullptr , ImGuiWindowFlags_AlwaysAutoResize);
3535
36- ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 .51f , 0 .00f , 0 .14f , 0 .00f ));
37- if (ImGui::Button (" -" ))
38- {
39- if (Overlay::GlobalFontScale > 1 .0f )
40- {
41- Overlay::GlobalFontScale -= 0 .05f ;
42- settingsChanged = true ;
43- }
44-
45- ImGui::GetIO ().FontGlobalScale = Overlay::GlobalFontScale;
46- }
47-
48- ImGui::SameLine ();
49-
50- if (ImGui::Button (" +" ))
51- {
52- if (Overlay::GlobalFontScale < 4 .0f )
53- {
54- Overlay::GlobalFontScale += 0 .05f ;
55- settingsChanged = true ;
56- }
57-
58- ImGui::GetIO ().FontGlobalScale = Overlay::GlobalFontScale;
59- }
60-
61- ImGui::PopStyleColor ();
62- ImGui::SameLine ();
63- ImGui::Text (" Overlay Font Size" );
64-
65- ImGui::Separator ();
6636 ImGui::Text (" Info" );
6737 EVWORK_CAR* car = Game::pl_car ();
6838 ImGui::Text (" game_mode: %d" , *Game::game_mode);
@@ -139,22 +109,81 @@ class UISettingsWindow : public OverlayWindow
139109 {
140110 bool settingsChanged = false ;
141111
142- ImGui::Begin (" Notification Settings" , nullptr , ImGuiWindowFlags_AlwaysAutoResize);
143- ImGui::SetWindowPos (ImVec2 (startX, curY), ImGuiCond_FirstUseEver);
144-
145- settingsChanged |= ImGui::SliderInt (" Display Time" , &Overlay::NotifyDisplayTime, 0 , 60 );
146- settingsChanged |= ImGui::Checkbox (" Enable Online Lobby Notifications" , &Overlay::NotifyOnlineEnable);
147- settingsChanged |= ImGui::SliderInt (" Online Update Time" , &Overlay::NotifyOnlineUpdateTime, 10 , 60 );
148-
149- static const char * items[]{ " Never Hide" , " Online Race" , " Any Race" };
150- settingsChanged |= ImGui::Combo (" Hide During" , &Overlay::NotifyHideMode, items, IM_ARRAYSIZE (items));
151-
152- settingsChanged |= ImGui::Checkbox (" Hide Chat Background" , &Overlay::ChatHideBackground);
153-
154- ImGui::End ();
112+ if (ImGui::Begin (" UI Settings" , nullptr , ImGuiWindowFlags_AlwaysAutoResize))
113+ {
114+ ImGui::SetWindowPos (ImVec2 (startX, curY), ImGuiCond_FirstUseEver);
115+
116+ if (ImGui::TreeNodeEx (" Global" , ImGuiTreeNodeFlags_DefaultOpen))
117+ {
118+ static bool fontScaleChanged = false ;
119+ if (ImGui::SliderFloat (" Font Scale" , &Overlay::GlobalFontScale, 0 .5f , 2 .5f ))
120+ fontScaleChanged |= true ;
121+
122+ if (fontScaleChanged)
123+ if (ImGui::IsMouseReleased (ImGuiMouseButton_Left))
124+ {
125+ settingsChanged |= true ;
126+ fontScaleChanged = false ;
127+ }
128+
129+ ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 .51f , 0 .00f , 0 .14f , 0 .00f ));
130+ if (ImGui::Button (" -" ))
131+ {
132+ if (Overlay::GlobalFontScale > 1 .0f )
133+ {
134+ Overlay::GlobalFontScale -= 0 .05f ;
135+ settingsChanged = true ;
136+ }
137+ }
138+
139+ ImGui::SameLine ();
140+
141+ if (ImGui::Button (" +" ))
142+ {
143+ if (Overlay::GlobalFontScale < 5 .0f )
144+ {
145+ Overlay::GlobalFontScale += 0 .05f ;
146+ settingsChanged = true ;
147+ }
148+ }
149+
150+ ImGui::PopStyleColor ();
151+
152+ settingsChanged |= ImGui::SliderFloat (" Overlay Opacity" , &Overlay::GlobalOpacity, 0 .1f , 5 .0f );
153+
154+ ImGui::TreePop ();
155+ }
156+
157+ if (ImGui::TreeNodeEx (" Notifications" , ImGuiTreeNodeFlags_DefaultOpen))
158+ {
159+ settingsChanged |= ImGui::Checkbox (" Enable Notifications" , &Overlay::NotifyEnable);
160+ settingsChanged |= ImGui::SliderInt (" Display Time" , &Overlay::NotifyDisplayTime, 0 , 60 );
161+ settingsChanged |= ImGui::Checkbox (" Enable Online Lobby Notifications" , &Overlay::NotifyOnlineEnable);
162+ settingsChanged |= ImGui::SliderInt (" Online Update Time" , &Overlay::NotifyOnlineUpdateTime, 10 , 60 );
163+
164+ static const char * items[]{ " Never Hide" , " Online Race" , " Any Race" };
165+ settingsChanged |= ImGui::Combo (" Hide During" , &Overlay::NotifyHideMode, items, IM_ARRAYSIZE (items));
166+
167+ ImGui::TreePop ();
168+ }
169+
170+ if (ImGui::TreeNodeEx (" Chat" , ImGuiTreeNodeFlags_DefaultOpen))
171+ {
172+ settingsChanged |= ImGui::Checkbox (" Hide Chat Background" , &Overlay::ChatHideBackground);
173+
174+ ImGui::TreePop ();
175+ }
176+
177+ ImGui::End ();
178+ }
155179
156180 if (settingsChanged)
181+ {
182+ ImGui::GetStyle ().Colors [ImGuiCol_WindowBg].w = Overlay::GlobalOpacity;
183+ ImGui::GetIO ().FontGlobalScale = Overlay::GlobalFontScale;
184+
157185 Overlay::settings_write ();
186+ }
158187 }
159188 }
160189 static UISettingsWindow instance;
@@ -181,6 +210,33 @@ void Overlay::init()
181210 UpdateCheck_Init ();
182211}
183212
213+ void Overlay::init_imgui ()
214+ {
215+ // Setup Dear ImGui context
216+ IMGUI_CHECKVERSION ();
217+ ImGui::CreateContext ();
218+ ImGuiIO& io = ImGui::GetIO (); (void )io;
219+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
220+ io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
221+ io.FontGlobalScale = Overlay::GlobalFontScale;
222+
223+ // Setup Dear ImGui style
224+ ImGui::StyleColorsDark ();
225+ // ImGui::StyleColorsLight();
226+
227+ ImGui::GetStyle ().Colors [ImGuiCol_WindowBg].w = Overlay::GlobalOpacity;
228+ ImGui::GetIO ().FontGlobalScale = Overlay::GlobalFontScale;
229+ }
230+
231+ void ForceShowCursor (bool show) {
232+ int counter = 0 ;
233+
234+ // Adjust the counter until the cursor visibility matches the desired state
235+ do {
236+ counter = ShowCursor (show);
237+ } while ((show && counter < 0 ) || (!show && counter >= 0 ));
238+ }
239+
184240bool Overlay::render ()
185241{
186242 IsActive = false ;
@@ -196,9 +252,9 @@ bool Overlay::render()
196252 {
197253 overlay_visible = !overlay_visible;
198254 if (overlay_visible)
199- ShowCursor (true );
255+ ForceShowCursor (true );
200256 else
201- ShowCursor (false );
257+ ForceShowCursor (false );
202258 }
203259
204260 // Start the Dear ImGui frame
@@ -207,6 +263,53 @@ bool Overlay::render()
207263 // Notifications are rendered before any other window
208264 Notifications::instance.render ();
209265
266+ if (overlay_visible)
267+ {
268+ if (ImGui::BeginMainMenuBar ()) {
269+ if (ImGui::BeginMenu (" File" )) {
270+ if (ImGui::MenuItem (" Open" , " Ctrl+O" )) {
271+ // Handle Open action
272+ }
273+ if (ImGui::MenuItem (" Save" , " Ctrl+S" )) {
274+ // Handle Save action
275+ }
276+ if (ImGui::MenuItem (" Exit" )) {
277+ // Handle Exit action
278+ }
279+ ImGui::EndMenu ();
280+ }
281+
282+ if (ImGui::BeginMenu (" Edit" )) {
283+ if (ImGui::MenuItem (" Undo" , " Ctrl+Z" )) {
284+ // Handle Undo action
285+ }
286+ if (ImGui::MenuItem (" Redo" , " Ctrl+Y" , false , false )) {
287+ // Disabled menu item (not clickable)
288+ }
289+ ImGui::Separator (); // Adds a separator line
290+ if (ImGui::MenuItem (" Cut" , " Ctrl+X" )) {
291+ // Handle Cut action
292+ }
293+ if (ImGui::MenuItem (" Copy" , " Ctrl+C" )) {
294+ // Handle Copy action
295+ }
296+ if (ImGui::MenuItem (" Paste" , " Ctrl+V" )) {
297+ // Handle Paste action
298+ }
299+ ImGui::EndMenu ();
300+ }
301+
302+ if (ImGui::BeginMenu (" Help" )) {
303+ if (ImGui::MenuItem (" About" )) {
304+ // Handle About action
305+ }
306+ ImGui::EndMenu ();
307+ }
308+
309+ ImGui::EndMainMenuBar ();
310+ }
311+ }
312+
210313 for (const auto & wnd : s_windows)
211314 wnd->render (overlay_visible);
212315
@@ -234,7 +337,9 @@ bool Overlay::settings_read()
234337 }
235338
236339 GlobalFontScale = ini.Get (" Overlay" , " FontScale" , GlobalFontScale);
340+ GlobalOpacity = ini.Get (" Overlay" , " Opacity" , GlobalOpacity);
237341
342+ NotifyEnable = ini.Get (" Notifications" , " Enable" , NotifyEnable);
238343 NotifyDisplayTime = ini.Get (" Notifications" , " DisplayTime" , NotifyDisplayTime);
239344 NotifyOnlineEnable = ini.Get (" Notifications" , " OnlineEnable" , NotifyOnlineEnable);
240345 NotifyOnlineUpdateTime = ini.Get (" Notifications" , " OnlineUpdateTime" , NotifyOnlineUpdateTime);
@@ -255,7 +360,9 @@ bool Overlay::settings_write()
255360{
256361 inih::INIReader ini;
257362 ini.Set (" Overlay" , " FontScale" , GlobalFontScale);
363+ ini.Set (" Overlay" , " Opacity" , GlobalOpacity);
258364
365+ ini.Set (" Notifications" , " Enable" , NotifyEnable);
259366 ini.Set (" Notifications" , " DisplayTime" , NotifyDisplayTime);
260367 ini.Set (" Notifications" , " OnlineEnable" , NotifyOnlineEnable);
261368 ini.Set (" Notifications" , " OnlineUpdateTime" , NotifyOnlineUpdateTime);
0 commit comments