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

@@ -309,7 +309,7 @@ View* RecyclerView::MoveFocusVertical(View* currentFocus, FocusMoveDirection dir
bool RecyclerView::HandleInput(const InputProvider& inputProvider, FocusManager& focusManager)
{
if (inputProvider.Triggered(InputKey::L | InputKey::R))
if (_itemCount != 0 && inputProvider.Triggered(InputKey::L | InputKey::R))
{
int direction = inputProvider.Triggered(InputKey::L) ? 1 : -1;
int selected = _selectedItem->itemIdx;

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()
{
if (_state == State::DisplayCheats)
{
DisableAllCheats(_cheats.get());
}
}
void CheatsViewModel::DisableAllCheats(const ICheatCategory* cheatCategory)