Fix some bugs in the cheats panel

This commit is contained in:
Gericom
2026-03-14 10:55:10 +01:00
parent 6c34d9324d
commit a4ecea6802
2 changed files with 17 additions and 2 deletions

View File

@@ -26,12 +26,24 @@ CheatsViewModel::CheatsViewModel(const FileInfo& romFileInfo, IRomBrowserControl
void CheatsViewModel::ActivateSelectedItem()
{
if (_state != State::DisplayCheats)
{
// No cheats or not yet loaded
return;
}
auto cheatCategory = GetCurrentCheatCategory();
u32 numberOfCategories = 0;
auto categories = cheatCategory->GetCategories(numberOfCategories);
u32 numberOfCheats = 0;
auto cheats = cheatCategory->GetCheats(numberOfCheats);
if (numberOfCategories + numberOfCheats == 0)
{
// There is nothing to activate
return;
}
if (_selectedItem < (int)numberOfCategories)
{
// Category activated
@@ -93,7 +105,10 @@ void CheatsViewModel::Close()
void CheatsViewModel::DisableAllCheats()
{
DisableAllCheats(_cheats.get());
if (_state == State::DisplayCheats)
{
DisableAllCheats(_cheats.get());
}
}
void CheatsViewModel::DisableAllCheats(const ICheatCategory* cheatCategory)