CogEngine: Fix crash with new cheat window when no asset defined

minor: rework cheat filters
This commit is contained in:
Arnaud Jamin
2025-01-16 19:28:20 -05:00
parent cde200829f
commit 4491614a0d
@@ -59,6 +59,9 @@ void FCogEngineWindow_Cheats::Initialize()
})); }));
if (Asset == nullptr)
{ return; }
for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories) for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories)
{ {
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects) for (const FCogEngineCheat& Cheat : CheatCategory.PersistentEffects)
@@ -219,22 +222,7 @@ void FCogEngineWindow_Cheats::RenderContent()
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 7); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 7);
FString CategoryPreview; if (ImGui::BeginMenu("Filters"))
if (Config->SelectedCategories.Num() == 0)
{
CategoryPreview = "None";
}
else if (Config->SelectedCategories.Num() == 1)
{
CategoryPreview = *Config->SelectedCategories.CreateIterator();
}
else
{
CategoryPreview = "Multiple";
}
const auto CategoryPreviewStr = StringCast<ANSICHAR>(*CategoryPreview);
if (ImGui::BeginCombo("##Categories", CategoryPreviewStr.Get()))
{ {
for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories) for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories)
{ {
@@ -252,7 +240,7 @@ void FCogEngineWindow_Cheats::RenderContent()
} }
} }
} }
ImGui::EndCombo(); ImGui::EndMenu();
} }
FCogWindowWidgets::SearchBar(Filter); FCogWindowWidgets::SearchBar(Filter);