Add cheat documentation, enable input repeat for L and R, show cheat category name

This commit is contained in:
Gericom
2026-03-08 13:03:26 +01:00
parent 43b1bf7afa
commit 6c34d9324d
22 changed files with 189 additions and 67 deletions

View File

@@ -24,7 +24,7 @@ CheatsViewModel::CheatsViewModel(const FileInfo& romFileInfo, IRomBrowserControl
});
}
void CheatsViewModel::ItemActivated()
void CheatsViewModel::ActivateSelectedItem()
{
auto cheatCategory = GetCurrentCheatCategory();
u32 numberOfCategories = 0;
@@ -58,21 +58,25 @@ void CheatsViewModel::ItemActivated()
}
}
void CheatsViewModel::Back()
bool CheatsViewModel::NavigateUp()
{
if (_categoryStackLevel == 0)
{
Close();
return false;
}
else
{
_selectedItem = _categoryStack[_categoryStackLevel].index;
_categoryStack[_categoryStackLevel--] = { nullptr, 0 };
return true;
}
}
void CheatsViewModel::Close()
{
_categoryStack.fill({ nullptr, 0 });
if (_changed)
{
// Save which cheats are enabled/disabled

View File

@@ -10,26 +10,57 @@
class CheatsViewModel
{
public:
/// @brief Enum representing the state of the cheats panel.
enum class State
{
/// @brief Cheats are being loaded.
Loading,
/// @brief No cheats were found.
NoCheats,
/// @brief Cheats are being displayed.
DisplayCheats
};
CheatsViewModel(const FileInfo& romFileInfo, IRomBrowserController* romBrowserController);
void ItemActivated();
void Back();
/// @brief Activates the selected cheat or category.
void ActivateSelectedItem();
/// @brief Navigates up in the cheat hierachy, or closes the cheats panel when at the root.
/// @return \c true when navigation happened in the cheats tree, or \c false when the cheats panel was closed.
bool NavigateUp();
/// @brief Closes the cheats panel.
void Close();
/// @brief Disables all cheats.
void DisableAllCheats();
/// @brief Gets the current state of the cheats panel.
/// @return The current state of the cheats panel.
State GetState() const { return _state; }
/// @brief Gets the current cheat category.
/// @return The current cheat category.
const ICheatCategory* GetCurrentCheatCategory() const { return _categoryStack[_categoryStackLevel].cheatCategory; }
/// @brief Gets the index of the selected item.
/// @return The index of the selected item.
constexpr int GetSelectedItem() const { return _selectedItem; }
/// @brief Sets the index of the selected item.
/// @param selectedItem The index of the selected item to set.
void SetSelectedItem(int selectedItem) { _selectedItem = selectedItem; }
/// @brief Returns whether the category name should be displayed.
/// @return \c true when the category name should be displayed, or \c false otherwise.
bool ShouldShowCategoryName() const
{
return _categoryStackLevel > 0;
}
private:
struct CategoryStackEntry
{