Add option to disable all cheats by pressing X in the cheat panel

This commit is contained in:
Gericom
2026-03-07 14:51:58 +01:00
parent 4d9318b0b9
commit 12ebd482d4
3 changed files with 35 additions and 1 deletions

View File

@@ -86,3 +86,29 @@ void CheatsViewModel::Close()
_romBrowserController->HideGameInfo();
}
void CheatsViewModel::DisableAllCheats()
{
DisableAllCheats(_cheats.get());
}
void CheatsViewModel::DisableAllCheats(const ICheatCategory* cheatCategory)
{
u32 numberOfCategories = 0;
auto categories = cheatCategory->GetCategories(numberOfCategories);
for (u32 i = 0; i < numberOfCategories; i++)
{
DisableAllCheats(&categories[i]);
}
u32 numberOfCheats = 0;
auto cheats = cheatCategory->GetCheats(numberOfCheats);
for (u32 i = 0; i < numberOfCheats; i++)
{
if (cheats[i].GetIsCheatActive())
{
cheats[i].SetIsCheatActive(false);
_changed = true;
}
}
}

View File

@@ -22,6 +22,7 @@ public:
void ItemActivated();
void Back();
void Close();
void DisableAllCheats();
State GetState() const { return _state; }
const ICheatCategory* GetCurrentCheatCategory() const { return _categoryStack[_categoryStackLevel].cheatCategory; }
@@ -45,4 +46,6 @@ private:
bool _changed = false;
u32 _categoryStackLevel = 0;
std::array<CategoryStackEntry, 8> _categoryStack;
void DisableAllCheats(const ICheatCategory* cheatCategory);
};

View File

@@ -25,7 +25,7 @@
#define LIST_X 16
#define LIST_Y 36
#define LIST_WIDTH 224
#define LIST_HEIGHT /*124*/108
#define LIST_HEIGHT 108
CheatsBottomSheetView::CheatsBottomSheetView(std::unique_ptr<CheatsViewModel> viewModel,
const MaterialColorScheme* materialColorScheme, const IFontRepository* fontRepository,
@@ -214,6 +214,11 @@ bool CheatsBottomSheetView::HandleInput(const InputProvider& inputProvider, Focu
_viewModel->Close();
return true;
}
else if (inputProvider.Triggered(InputKey::X))
{
_viewModel->DisableAllCheats();
return true;
}
return false;
}