 |
RigsofRods
Soft-body Physics Simulation
|
Go to the documentation of this file.
39 #include <imgui_internal.h>
92 ImGuiWindowFlags win_flags = ImGuiWindowFlags_NoCollapse;
93 ImGui::SetNextWindowPosCenter(ImGuiCond_FirstUseEver);
94 ImGui::SetNextWindowSize(ImVec2((ImGui::GetIO().DisplaySize.x / 1.4), (ImGui::GetIO().DisplaySize.y / 1.2)), ImGuiCond_FirstUseEver);
95 bool keep_open =
true;
96 if (!ImGui::Begin(
_LC(
"MainSelector",
"Loader"), &keep_open, win_flags))
107 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
115 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)))
136 ImGui::PopItemWidth();
140 const ImVec2 searchbox_cursor = ImGui::GetCursorPos();
141 const float searchbox_width = ImGui::GetWindowWidth() -
142 (
LEFT_PANE_WIDTH + 2 * (ImGui::GetStyle().WindowPadding.x) + ImGui::GetStyle().ItemSpacing.x);
146 ImGui::SetKeyboardFocusHere();
150 if (!
m_searchbox_was_active && (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Tab)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Slash))))
152 ImGui::SetKeyboardFocusHere();
154 ImGui::PushItemWidth(searchbox_width);
162 ImGui::PopItemWidth();
164 const ImVec2 separator_cursor = ImGui::GetCursorPos()
165 + ImVec2(0, ImGui::GetStyle().WindowPadding.y - ImGui::GetStyle().ItemSpacing.y);
168 const char* searchbox_hint =
"(?)";
169 ImGui::SetCursorPos(searchbox_cursor + ImVec2(searchbox_width - (ImGui::CalcTextSize(searchbox_hint).
x + ImGui::GetStyle().FramePadding.x), ImGui::GetStyle().FramePadding.y));
170 ImGui::TextDisabled(searchbox_hint);
171 if (ImGui::IsItemHovered())
173 ImGui::BeginTooltip();
174 ImGui::TextDisabled(
"Fulltext search:");
175 ImGui::Text(
"~ partial name, filename, description, author name or e-mail");
176 ImGui::TextDisabled(
"Advanced search:");
177 ImGui::Text(
"guid: ~ partial GUID");
178 ImGui::Text(
"author: ~ partial author name or e-mail");
179 ImGui::Text(
"wheels: ~ wheel configuration (i.e. 4x4)");
180 ImGui::Text(
"file: ~ partial file name");
184 ImGui::SetCursorPos(separator_cursor);
190 bool scroll_to_selected =
false;
194 if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
198 scroll_to_selected =
true;
200 else if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
204 scroll_to_selected =
true;
208 ImDrawList* drawlist = ImGui::GetWindowDrawList();
209 drawlist->ChannelsSplit(2);
210 bool do_apply =
false;
211 for (
int i = 0; i < num_entries; ++i)
217 drawlist->ChannelsSetCurrent(1);
219 ImGui::GetStyle().Colors[ImGuiCol_Text],
224 drawlist->ChannelsSetCurrent(0);
226 if (ImGui::Selectable(
"##dummy", &is_selected, 0, mouse_area))
232 if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0))
239 if (is_selected && scroll_to_selected)
241 ImGui::SetScrollHere();
250 drawlist->ChannelsMerge();
257 ImGui::BeginChild(
"item view", ImVec2(0, -ImGui::GetItemsLineHeightWithSpacing()));
266 ImVec2 cursor_pos = ImGui::GetCursorPos();
269 Ogre::TexturePtr preview_tex =
270 Ogre::TextureManager::getSingleton().load(
276 ImVec2 size(preview_tex->getWidth(), preview_tex->getHeight());
279 size *= max_size.x / size.x;
280 if (size.y > max_size.y)
282 size *= max_size.y / size.y;
286 ImGui::SetCursorPos((cursor_pos + ImGui::GetWindowSize()) - size);
287 ImGui::Image(
reinterpret_cast<ImTextureID
>(preview_tex->getHandle()), size);
288 ImGui::SetCursorPos(cursor_pos);
305 ImGui::TextDisabled(
"%s",
_LC(
"MainSelector",
"Author(s): "));
312 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Wheels: "));
318 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Mass: "));
327 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Load Mass: "));
345 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Using Submeshs: "));
351 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Default skin: "));
359 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Engine RPM: "));
385 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Source: "));
392 ImGui::Text(
"%s",
_LC(
"MainSelector",
"Filename: "));
402 ImGui::BeginChild(
"buttons");
408 ImGui::PushItemWidth(ImGui::GetWindowWidth() / 2);
414 ImGui::SameLine(ImGui::GetWindowWidth()-280);
415 if (ImGui::Button(
_LC(
"MainSelector",
"OK"), ImVec2(120.f, 0.0f)) ||
416 ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Enter)))
421 ImGui::SameLine(ImGui::GetWindowWidth()-150);
422 if (ImGui::Button(
_LC(
"MainSelector",
"Cancel"), ImVec2(120.f, 0.0f)) || ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Escape)))
430 m_is_hovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
439 template <
typename T1,
typename T2>
442 bool operator ()(std::pair<int, Ogre::String>
const& a, std::pair<int, Ogre::String>
const& b)
const
452 return a.second < b.second;
494 std::vector<std::pair<int, Ogre::String>> sorted_cats(cats.begin(), cats.end());
498 for (
auto itor: sorted_cats)
512 if (input.find(
":") == std::string::npos)
519 Ogre::StringVector v = Ogre::StringUtil::split(input,
":");
525 else if (v[0] ==
"guid")
530 else if (v[0] ==
"author")
535 else if (v[0] ==
"wheels")
540 else if (v[0] ==
"file")
566 ImGui::Text(
"%s", title);
568 ImGui::TextColored(
App::GetGuiManager()->GetTheme().value_blue_text_color,
"%d", val);
576 ImGui::Text(
"%s", title);
578 ImGui::TextColored(
App::GetGuiManager()->GetTheme().value_blue_text_color,
"%f", val);
586 ImGui::TextColored(
App::GetGuiManager()->GetTheme().value_red_text_color,
"%s", label);
594 ImGui::Text(
"%s", desc);
596 ImGui::TextColored(
App::GetGuiManager()->GetTheme().value_blue_text_color,
"%s", str.c_str());
659 LOG(
fmt::format(
"[RoR|GameSettings] INTERNAL ERROR - Unrecognized dashboard type being selected ({})!",
669 std::string sectionconfig;
685 *out_text = dc_vec->at(idx).sdc_title.ToCStr();
706 : sdc_category_id(id)
708 sdc_title <<
"(" << usage <<
") " <<
_LC(
"ModCategory", name.c_str());
#define ROR_ASSERT(_EXPR)
Game state manager and message-queue provider.
std::string resource_bundle_type
Archive type recognized by OGRE resource system: 'FileSystem' or 'Zip'.
@ MSG_SIM_LOAD_TERRN_REQUESTED
std::map< int, Ogre::String > CategoryIdNameMap
Ogre::String dname
name parsed from the file
@ GUID
Partial match in: guid.
void ImTextWrappedColorMarked(std::string const &text)
Prints multiline text with '#rrggbb' color markers. Behaves like ImGui::Text* functions.
const float PREVIEW_SIZE_RATIO
void DrawAttrSpecial(bool val, const char *label) const
int cqy_filter_category_id
void UpdateDisplayLists()
Str< 50 > sde_filetime_str
GUIManager * GetGuiManager()
ImVec4 value_blue_text_color
int version
file's version
int m_selected_sectionconfig
CacheSearchMethod cqy_search_method
CacheCategoryId default_dash_being_selected
ImVec2 DrawColorMarkedText(ImDrawList *drawlist, ImVec2 text_cursor, ImVec4 default_color, float override_alpha, float wrap_width, std::string const &line)
Draw multiline text with '#rrggbb' color markers. Returns total text size.
Truck file format(technical spec)
DisplayCategory(int id, std::string const &name, size_t usage)
size_t GetCapacity() const
@ FILENAME
Partial match in file name.
void DrawAttrInt(const char *desc, int val) const
void OnLoaderGuiApply(RoR::LoaderType type, CacheEntryPtr entry, std::string sectionconfig)
GUI callback.
Ogre::Real Round(Ogre::Real value, unsigned short ndigits=0)
CVar * ui_default_boat_dash
string; name of the '.dashboard' file in modcache.
int m_selected_cid
Category ID.
@ MSG_APP_LOAD_SCRIPT_REQUESTED
Payload = RoR::LoadScriptRequest* (owner)
GUI::GameSettings GameSettings
DisplayCategoryVec m_display_categories
std::vector< Ogre::String > sectionconfigs
void Show(LoaderType type, std::string const &filter_guid="", CacheEntryPtr advertised_entry=nullptr)
int m_selected_category
Combobox position (uses display list)
const float LEFT_PANE_WIDTH
void DrawAttrFloat(const char *desc, float val) const
@ NONE
Ignore the search string and find all.
std::vector< DisplayCategory > DisplayCategoryVec
static bool CatComboItemGetter(void *data, int idx, const char **out_text)
std::map< int, size_t > cqy_res_category_usage
Total usage (ignores search params + category filter)
@ AUTHORS
Partial match in: author name/email.
CVar * ui_default_truck_dash
string; name of the '.dashboard' file in modcache.
std::vector< AuthorInfo > authors
authors
Ogre::String filecachename
preview image filename
A database of user-installed content alias 'mods' (vehicles, terrains...)
CacheEntryPtr m_advertised_entry
Always shown on top, even if not existing in modcache (i.e. dummy default skin)
const CategoryIdNameMap & GetCategories() const
std::time_t addtimestamp
timestamp when this file was added to the cache
void PushMessage(Message m)
Doesn't guarantee order! Use ChainMessage() if order matters.
const char * ToCStr() const
void UpdateSearchParams()
@ FULLTEXT
Partial match in: name, filename, description, author name/mail.
@ WHEELS
Wheel configuration, i.e. 4x4.
LoaderType
< Search mode for ModCache::Query() & Operation mode for GUI::MainSelector
std::map< LoaderType, int > m_last_selected_entry
Stores the last manually selected entry index for each loader type.
Central state/object manager and communications hub.
std::string cqy_search_string
GameContext * GetGameContext()
void RequestGuiCaptureKeyboard(bool val)
Pass true during frame to prevent input passing to application.
Ogre::String uniqueid
file's unique id
CacheSearchMethod m_search_method
std::string ActorTypeToName(ActorType driveable)
DisplayEntry(CacheEntryPtr entry)
Str< 50 > sde_driveable_str
CacheSystem * GetCacheSystem()
int usagecounter
how much it was used already
RoR::LoaderType cqy_filter_type
void OnLoaderGuiCancel()
GUI callback.
Unified game event system - all requests and state changes are reported using a message.
std::string m_filter_guid
Used for skins.
std::string resource_bundle_path
Path of ZIP or directory which contains the media. Shared between CacheEntries, loaded only once.
std::map< LoaderType, int > m_last_selected_cid
Last selected category-ID for each loader type.
static bool ScComboItemGetter(void *data, int idx, const char **out_text)
std::string cqy_filter_guid
Exact match (case-insensitive); leave empty to disable.
DisplayEntryVec m_display_entries
@ GADGET
Associated with a .gadget mod file, launched via UI or any method given below for CUSTOM scripts (use...
bool m_searchbox_was_active
std::map< LoaderType, int > m_last_selected_category
Last category-combobox position for each loader type.
std::time_t filetime
filetime
Str< 500 > m_search_input
std::string m_search_string
size_t Query(CacheQuery &query)
void setStr(std::string const &str)
void DrawAttrStr(const char *desc, std::string const &str) const
GUI::GameMainMenu GameMainMenu
std::vector< CacheQueryResult > cqy_results
Ogre::String guid
global unique id; Type "addonpart" leaves this empty and uses addonpart_guids; Always lowercase.
@ MSG_NET_DISCONNECT_REQUESTED
Str< 50 > sde_addtime_str
Ogre::String fname
filename