RigsofRods
Soft-body Physics Simulation
GUI_MainSelector.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 "Application.h" // Str
29 #include "SimData.h" // ActorSpawnRequest
30 #include "CacheSystem.h" // CacheSearchMethod
31 #include "ForwardDeclarations.h"
32 
33 #include <map>
34 
35 namespace RoR {
36 namespace GUI {
37 
39 {
40 public:
41  const float LEFT_PANE_WIDTH = 250.f;
42  const float PREVIEW_SIZE_RATIO = 0.7f;
43 
44  MainSelector();
45  ~MainSelector();
46 
47  void Show(LoaderType type, std::string const& filter_guid = "", CacheEntryPtr advertised_entry = nullptr);
48  bool IsVisible() { return m_loader_type != LT_None; };
49  bool IsHovered() { return IsVisible() && m_is_hovered; }
50  bool m_kb_focused = true;
51  void Draw();
52  void Close();
53 
54 private:
56  {
57  DisplayCategory(int id, std::string const& name, size_t usage);
58 
61  };
62 
63  struct DisplayEntry
64  {
66 
68  Str<50> sde_filetime_str; // pre-formatted
69  Str<50> sde_addtime_str; // pre-formatted
70  Str<50> sde_driveable_str; // pre-formatted
71  };
72 
73  typedef std::vector<DisplayCategory> DisplayCategoryVec;
74  typedef std::vector<DisplayEntry> DisplayEntryVec;
75 
76  void UpdateDisplayLists();
77  void UpdateSearchParams();
78  void Apply();
79  void Cancel();
80  void DrawAttrInt(const char* desc, int val) const;
81  void DrawAttrFloat(const char* desc, float val) const;
82  void DrawAttrSpecial(bool val, const char* label) const;
83  void DrawAttrStr(const char* desc, std::string const& str) const;
84 
85  static bool ScComboItemGetter(void* data, int idx, const char** out_text);
86  static bool CatComboItemGetter(void* data, int idx, const char** out_text);
87 
92  std::string m_search_string;
93  std::string m_filter_guid;
95  bool m_show_details = false;
96  bool m_searchbox_was_active = false;
98  bool m_is_hovered = false;
99 
101  int m_selected_cid = 0;
104 
105  std::map<LoaderType, int> m_last_selected_category;
106  std::map<LoaderType, int> m_last_selected_cid;
107  std::map<LoaderType, int> m_last_selected_entry;
108 };
109 
110 } // namespace GUI
111 } // namespace RoR
RoR::GUI::MainSelector::MainSelector
MainSelector()
Definition: GUI_MainSelector.cpp:55
RoR::GUI::MainSelector::Cancel
void Cancel()
Definition: GUI_MainSelector.cpp:602
ForwardDeclarations.h
Global forward declarations.
RoR::GUI::MainSelector::DisplayCategory::sdc_category_id
int sdc_category_id
Definition: GUI_MainSelector.h:59
RoR::GUI::MainSelector::PREVIEW_SIZE_RATIO
const float PREVIEW_SIZE_RATIO
Definition: GUI_MainSelector.h:42
RoR::GUI::MainSelector::DrawAttrSpecial
void DrawAttrSpecial(bool val, const char *label) const
Definition: GUI_MainSelector.cpp:574
RoR::GUI::MainSelector::UpdateDisplayLists
void UpdateDisplayLists()
Definition: GUI_MainSelector.cpp:453
RoR::GUI::MainSelector::~MainSelector
~MainSelector()
Definition: GUI_MainSelector.cpp:60
RoR::GUI::MainSelector::DisplayEntry::sde_filetime_str
Str< 50 > sde_filetime_str
Definition: GUI_MainSelector.h:68
RoR::GUI::MainSelector::IsHovered
bool IsHovered()
Definition: GUI_MainSelector.h:49
RoR::CacheSearchMethod
CacheSearchMethod
Definition: CacheSystem.h:172
RoR::GUI::MainSelector::m_selected_sectionconfig
int m_selected_sectionconfig
Definition: GUI_MainSelector.h:103
RoR::GUI::MainSelector::DisplayCategory::DisplayCategory
DisplayCategory(int id, std::string const &name, size_t usage)
Definition: GUI_MainSelector.cpp:670
RoR::GUI::MainSelector::m_selected_entry
int m_selected_entry
Definition: GUI_MainSelector.h:102
RoR::GUI::MainSelector::DrawAttrInt
void DrawAttrInt(const char *desc, int val) const
Definition: GUI_MainSelector.cpp:554
RoR::GUI::MainSelector::m_selected_cid
int m_selected_cid
Category ID.
Definition: GUI_MainSelector.h:101
RoR::GUI::MainSelector::m_display_categories
DisplayCategoryVec m_display_categories
Definition: GUI_MainSelector.h:89
RoR::GUI::MainSelector::Show
void Show(LoaderType type, std::string const &filter_guid="", CacheEntryPtr advertised_entry=nullptr)
Definition: GUI_MainSelector.cpp:65
RoR::GUI::MainSelector::m_selected_category
int m_selected_category
Combobox position (uses display list)
Definition: GUI_MainSelector.h:100
RoR::GUI::MainSelector::LEFT_PANE_WIDTH
const float LEFT_PANE_WIDTH
Definition: GUI_MainSelector.h:41
RoR::GUI::MainSelector::DrawAttrFloat
void DrawAttrFloat(const char *desc, float val) const
Definition: GUI_MainSelector.cpp:564
RefCountingObjectPtr< CacheEntry >
RoR::CacheSearchMethod::NONE
@ NONE
Ignore the search string and find all.
RoR::GUI::MainSelector::DisplayEntry
Definition: GUI_MainSelector.h:63
RoR::GUI::MainSelector::DisplayCategoryVec
std::vector< DisplayCategory > DisplayCategoryVec
Definition: GUI_MainSelector.h:73
RoR::GUI::MainSelector::m_is_hovered
bool m_is_hovered
Definition: GUI_MainSelector.h:98
RoR::GUI::MainSelector::CatComboItemGetter
static bool CatComboItemGetter(void *data, int idx, const char **out_text)
Definition: GUI_MainSelector.cpp:646
RoR::Str< 200 >
SimData.h
Core data structures for simulation; Everything affected by by either physics, network or user intera...
CacheSystem.h
A database of user-installed content alias 'mods' (vehicles, terrains...)
RoR::GUI::MainSelector::m_advertised_entry
CacheEntryPtr m_advertised_entry
Always shown on top, even if not existing in modcache (i.e. dummy default skin)
Definition: GUI_MainSelector.h:97
RoR::GUI::MainSelector::IsVisible
bool IsVisible()
Definition: GUI_MainSelector.h:48
RoR::GUI::MainSelector::UpdateSearchParams
void UpdateSearchParams()
Definition: GUI_MainSelector.cpp:500
RoR::GUI::MainSelector::m_show_details
bool m_show_details
Definition: GUI_MainSelector.h:95
RoR::LoaderType
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
Definition: Application.h:289
RoR::GUI::MainSelector::m_last_selected_entry
std::map< LoaderType, int > m_last_selected_entry
Stores the last manually selected entry index for each loader type.
Definition: GUI_MainSelector.h:107
Application.h
Central state/object manager and communications hub.
RoR::GUI::MainSelector::m_search_method
CacheSearchMethod m_search_method
Definition: GUI_MainSelector.h:91
RoR::GUI::MainSelector::Apply
void Apply()
Definition: GUI_MainSelector.cpp:620
RoR::GUI::MainSelector
Definition: GUI_MainSelector.h:38
RoR::GUI::MainSelector::DisplayEntry::DisplayEntry
DisplayEntry(CacheEntryPtr entry)
Definition: GUI_MainSelector.cpp:654
RoR::GUI::MainSelector::DisplayEntry::sde_driveable_str
Str< 50 > sde_driveable_str
Definition: GUI_MainSelector.h:70
RoR::GUI::MainSelector::DisplayEntryVec
std::vector< DisplayEntry > DisplayEntryVec
Definition: GUI_MainSelector.h:74
RoR::LT_None
@ LT_None
Definition: Application.h:291
RoR::GUI::MainSelector::m_filter_guid
std::string m_filter_guid
Used for skins.
Definition: GUI_MainSelector.h:93
RoR::GUI::MainSelector::DisplayCategory
Definition: GUI_MainSelector.h:55
RoR::GUI::MainSelector::m_last_selected_cid
std::map< LoaderType, int > m_last_selected_cid
Last selected category-ID for each loader type.
Definition: GUI_MainSelector.h:106
RoR::GUI::MainSelector::Close
void Close()
Definition: GUI_MainSelector.cpp:592
RoR::GUI::MainSelector::ScComboItemGetter
static bool ScComboItemGetter(void *data, int idx, const char **out_text)
Definition: GUI_MainSelector.cpp:546
RoR::GUI::MainSelector::m_kb_focused
bool m_kb_focused
Definition: GUI_MainSelector.h:50
RoR::GUI::MainSelector::DisplayEntry::sde_entry
CacheEntryPtr sde_entry
Definition: GUI_MainSelector.h:67
RoR::GUI::MainSelector::m_display_entries
DisplayEntryVec m_display_entries
Definition: GUI_MainSelector.h:90
RoR::GUI::MainSelector::Draw
void Draw()
Definition: GUI_MainSelector.cpp:87
RoR::GUI::MainSelector::m_loader_type
LoaderType m_loader_type
Definition: GUI_MainSelector.h:88
RoR::GUI::MainSelector::m_searchbox_was_active
bool m_searchbox_was_active
Definition: GUI_MainSelector.h:96
RoR::GUI::MainSelector::m_last_selected_category
std::map< LoaderType, int > m_last_selected_category
Last category-combobox position for each loader type.
Definition: GUI_MainSelector.h:105
RoR::GUI::MainSelector::DisplayCategory::sdc_title
Str< 200 > sdc_title
Definition: GUI_MainSelector.h:60
RoR::GUI::MainSelector::m_search_input
Str< 500 > m_search_input
Definition: GUI_MainSelector.h:94
RoR::GUI::MainSelector::m_search_string
std::string m_search_string
Definition: GUI_MainSelector.h:92
RoR
Definition: AppContext.h:36
RoR::GUI::MainSelector::DrawAttrStr
void DrawAttrStr(const char *desc, std::string const &str) const
Definition: GUI_MainSelector.cpp:582
RoR::GUI::MainSelector::DisplayEntry::sde_addtime_str
Str< 50 > sde_addtime_str
Definition: GUI_MainSelector.h:69