From a4ecea6802c1ce6021c108e708e772129d449f4e Mon Sep 17 00:00:00 2001 From: Gericom Date: Sat, 14 Mar 2026 10:55:10 +0100 Subject: [PATCH] Fix some bugs in the cheats panel --- arm9/source/gui/views/RecyclerView.cpp | 2 +- .../romBrowser/viewModels/CheatsViewModel.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arm9/source/gui/views/RecyclerView.cpp b/arm9/source/gui/views/RecyclerView.cpp index f849134..8db6d4e 100644 --- a/arm9/source/gui/views/RecyclerView.cpp +++ b/arm9/source/gui/views/RecyclerView.cpp @@ -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; diff --git a/arm9/source/romBrowser/viewModels/CheatsViewModel.cpp b/arm9/source/romBrowser/viewModels/CheatsViewModel.cpp index 7112953..e9cdde9 100644 --- a/arm9/source/romBrowser/viewModels/CheatsViewModel.cpp +++ b/arm9/source/romBrowser/viewModels/CheatsViewModel.cpp @@ -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)