RigsofRods
Soft-body Physics Simulation
GUI_GameMainMenu.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 
25 
26 #pragma once
27 
28 #include <imgui.h>
29 
30 namespace RoR {
31 namespace GUI {
32 
34 {
35 public:
36  // This class implements hand-made keyboard focus - button count must be known for wrapping
37  const float WINDOW_WIDTH = 200.f;
38  const ImVec4 WINDOW_BG_COLOR = ImVec4(0.1f, 0.1f, 0.1f, 0.8f);
39  const ImVec4 BUTTON_BG_COLOR = ImVec4(0.25f, 0.25f, 0.24f, 0.6f); // Drawn on top of a transparent panel; make it just a shade
40  const ImVec2 BUTTON_PADDING = ImVec2(4.f, 6.f);
41 
42  inline bool IsVisible() const { return m_is_visible; }
43  inline void SetVisible(bool v) { m_is_visible = v; m_kb_focus_index = -1; }
44  void Draw();
45  void CacheUpdatedNotice();
46 
47 private:
48 
49  void DrawMenuPanel();
50  void DrawVersionBox();
51  void DrawNoticeBox();
52  bool HighlightButton(const std::string &text, ImVec2 btn_size, int index) const;
53  void HandleInputEvents();
54  bool m_is_visible = false;
56  int m_kb_focus_index = -1; // -1 = no focus; 0+ = button index
57  int m_kb_enter_index = -1; // Focus positon when enter key was pressed.
58  const char* title;
59  bool cache_updated = false;
60 };
61 
62 } // namespace GUI
63 } // namespace RoR
RoR::GUI::GameMainMenu::DrawMenuPanel
void DrawMenuPanel()
Definition: GUI_GameMainMenu.cpp:61
RoR::GUI::GameMainMenu::m_num_buttons
int m_num_buttons
Definition: GUI_GameMainMenu.h:55
RoR::GUI::GameMainMenu::m_is_visible
bool m_is_visible
Definition: GUI_GameMainMenu.h:54
RoR::GUI::GameMainMenu
Definition: GUI_GameMainMenu.h:33
RoR::GUI::GameMainMenu::DrawNoticeBox
void DrawNoticeBox()
Definition: GUI_GameMainMenu.cpp:253
RoR::GUI::GameMainMenu::m_kb_focus_index
int m_kb_focus_index
Definition: GUI_GameMainMenu.h:56
RoR::GUI::GameMainMenu::BUTTON_PADDING
const ImVec2 BUTTON_PADDING
Definition: GUI_GameMainMenu.h:40
RoR::GUI::GameMainMenu::DrawVersionBox
void DrawVersionBox()
Definition: GUI_GameMainMenu.cpp:227
RoR::GUI::GameMainMenu::HandleInputEvents
void HandleInputEvents()
Definition: GUI_GameMainMenu.cpp:288
RoR::GUI::GameMainMenu::WINDOW_BG_COLOR
const ImVec4 WINDOW_BG_COLOR
Definition: GUI_GameMainMenu.h:38
RoR::GUI::GameMainMenu::HighlightButton
bool HighlightButton(const std::string &text, ImVec2 btn_size, int index) const
Definition: GUI_GameMainMenu.cpp:283
RoR::GUI::GameMainMenu::cache_updated
bool cache_updated
Definition: GUI_GameMainMenu.h:59
RoR::GUI::GameMainMenu::SetVisible
void SetVisible(bool v)
Definition: GUI_GameMainMenu.h:43
RoR::GUI::GameMainMenu::IsVisible
bool IsVisible() const
Definition: GUI_GameMainMenu.h:42
RoR::GUI::GameMainMenu::CacheUpdatedNotice
void CacheUpdatedNotice()
Definition: GUI_GameMainMenu.cpp:56
RoR::GUI::GameMainMenu::Draw
void Draw()
Definition: GUI_GameMainMenu.cpp:43
RoR::GUI::GameMainMenu::BUTTON_BG_COLOR
const ImVec4 BUTTON_BG_COLOR
Definition: GUI_GameMainMenu.h:39
RoR
Definition: AppContext.h:36
RoR::GUI::GameMainMenu::title
const char * title
Definition: GUI_GameMainMenu.h:58
RoR::GUI::GameMainMenu::m_kb_enter_index
int m_kb_enter_index
Definition: GUI_GameMainMenu.h:57
RoR::GUI::GameMainMenu::WINDOW_WIDTH
const float WINDOW_WIDTH
Definition: GUI_GameMainMenu.h:37