Fix vehicle categories not showing

This commit is contained in:
Grinch_ 2022-06-30 06:18:12 +06:00
parent 3e48745587
commit 495a0d1207
3 changed files with 18 additions and 20 deletions

View File

@ -184,9 +184,10 @@ Overlay = "Overlay"
Position = "Position" Position = "Position"
Remove = "Remove" Remove = "Remove"
Favourites = "Add to favourites" Favourites = "Add to favourites"
FavouritesText = "Added to favourites" FavouritesNone = "You don't have any favourites!"
FavouritesRemove = "Remove from favourites" FavouritesRemove = "Remove from favourites"
FavouritesRemoveText = "Removed from favourites" FavouritesRemoveText = "Removed from favourites"
FavouritesText = "Added to favourites"
Close = "Close" Close = "Close"
QuickSSKey = "Quick screenshot" QuickSSKey = "Quick screenshot"
QuickTPKey = "Toogle quick teleport" QuickTPKey = "Toogle quick teleport"
@ -556,7 +557,7 @@ Siren = "Siren"
SkidMarks = "Always skid marks" SkidMarks = "Always skid marks"
Small = "Small" Small = "Small"
SpawnInAir = "Spawn aircraft in air" SpawnInAir = "Spawn aircraft in air"
SpawnInside = "Spawn inside as driver" SpawnInside = "Spawn as driver"
StayOnBike = "Don't fall off bike" StayOnBike = "Don't fall off bike"
SteeringLock = "Steering lock" SteeringLock = "Steering lock"
SuspensionBias = "Suspension bias" SuspensionBias = "Suspension bias"

View File

@ -56,7 +56,7 @@ void ResourceStore::LoadTextureResource(std::string&& name)
if (!std::filesystem::exists(fullPath)) if (!std::filesystem::exists(fullPath))
{ {
//Log::PrintWarn("Failed to load {}", fullPath); Log::Print<eLogLevel::Warn>("Failed to load {}", fullPath);
return; return;
} }
@ -66,7 +66,7 @@ void ResourceStore::LoadTextureResource(std::string&& name)
{ {
RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next; RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next;
RwTexDictionary *pEndDic; RwTexDictionary *pEndDic;
bool addCategories = m_Categories.empty(); bool addCategories = (m_Categories.size() < 2); // "All"
do do
{ {
pEndDic = (RwTexDictionary*)pRLL->link.next; pEndDic = (RwTexDictionary*)pRLL->link.next;
@ -114,7 +114,7 @@ void ResourceStore::LoadTextureResource(std::string&& name)
} }
// Genereate categories // Genereate categories
if (m_Type == TYPE_IMAGE_TEXT && if (m_Type != TYPE_TEXT_IMAGE &&
!std::count(m_Categories.begin(), m_Categories.end(), m_ImagesList.back().get()->m_CategoryName)) !std::count(m_Categories.begin(), m_Categories.end(), m_ImagesList.back().get()->m_CategoryName))
{ {
m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName); m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName);

View File

@ -91,21 +91,8 @@ void Widget::DataList(ResourceStore& data, ArgCallback3 clickFunc, ArgCallback3
// Category box // Category box
ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - ImGui::GetStyle().ItemSpacing.x)/2); ImGui::PushItemWidth((ImGui::GetWindowContentRegionWidth() - ImGui::GetStyle().ItemSpacing.x)/2);
Ui::ListBoxStr("##Categories", data.m_Categories, data.m_Selected); Ui::ListBoxStr("##Categories", data.m_Categories, data.m_Selected);
ImGui::SameLine(); ImGui::SameLine();
FilterWithHint("##Filter", data.m_Filter, TEXT("Window.Search"));
// Search box
data.m_Filter.Draw("##Filter");
if (strlen(data.m_Filter.InputBuf) == 0)
{
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImVec2 min = ImGui::GetItemRectMin();
min.x += ImGui::GetStyle().FramePadding.x;
min.y += ImGui::GetStyle().FramePadding.y;
drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), "Search");
}
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::Spacing(); ImGui::Spacing();
@ -163,8 +150,13 @@ void Widget::DataList(ResourceStore& data, ArgCallback3 clickFunc, ArgCallback3
} }
if (ImGui::BeginTabItem(TEXT("Window.FavouritesTab"))) if (ImGui::BeginTabItem(TEXT("Window.FavouritesTab")))
{ {
ImGui::Spacing();
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth());
FilterWithHint("##Filter", data.m_Filter, TEXT("Window.Search"));
ImGui::PopItemWidth();
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild(1); ImGui::BeginChild(1);
size_t count = 0;
for (auto [k, v] : *data.m_pData->GetTable("Favourites")) for (auto [k, v] : *data.m_pData->GetTable("Favourites"))
{ {
std::string key = std::string(k.str()); std::string key = std::string(k.str());
@ -179,9 +171,14 @@ void Widget::DataList(ResourceStore& data, ArgCallback3 clickFunc, ArgCallback3
if (ImGui::IsItemClicked(1)) if (ImGui::IsItemClicked(1))
{ {
contextMenu = {std::string("Favourites"), key, val}; contextMenu = {std::string("Favourites"), key, val, removeFunc};
} }
} }
++count;
}
if (count == 0)
{
Widget::TextCentered(TEXT("Menu.FavouritesNone"));
} }
if (contextMenu.func != nullptr) if (contextMenu.func != nullptr)
{ {