mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Fix a few bugs related to the cheat panel
This commit is contained in:
16
arm9/source/cheats/EmptyCheatRepository.h
Normal file
16
arm9/source/cheats/EmptyCheatRepository.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "ICheatRepository.h"
|
||||||
|
|
||||||
|
class EmptyCheatRepository : public ICheatRepository
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::unique_ptr<GameCheats> GetCheatsForGame(const FastFileRef& romFile) const override
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateEnabledCheatsForGame(const std::unique_ptr<GameCheats>& cheats) const override
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "SdFolderFactory.h"
|
#include "SdFolderFactory.h"
|
||||||
#include "services/settings/IAppSettingsService.h"
|
#include "services/settings/IAppSettingsService.h"
|
||||||
#include "cheats/UsrCheatRepositoryFactory.h"
|
#include "cheats/UsrCheatRepositoryFactory.h"
|
||||||
|
#include "cheats/EmptyCheatRepository.h"
|
||||||
#include "cheats/PicoLoaderCheatDataFactory.h"
|
#include "cheats/PicoLoaderCheatDataFactory.h"
|
||||||
#include "RomBrowserController.h"
|
#include "RomBrowserController.h"
|
||||||
|
|
||||||
@@ -145,6 +146,11 @@ void RomBrowserController::HandleNavigateTrigger()
|
|||||||
if (!_cheatRepository)
|
if (!_cheatRepository)
|
||||||
{
|
{
|
||||||
_cheatRepository = UsrCheatRepositoryFactory().FromUsrCheatDat("/_pico/usrcheat.dat");
|
_cheatRepository = UsrCheatRepositoryFactory().FromUsrCheatDat("/_pico/usrcheat.dat");
|
||||||
|
if (!_cheatRepository)
|
||||||
|
{
|
||||||
|
// When usrcheat.dat is not found or cannot be read use a dummy empty cheat repository
|
||||||
|
_cheatRepository = std::make_unique<EmptyCheatRepository>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 startTick = gTickCounter.GetValue();
|
u64 startTick = gTickCounter.GetValue();
|
||||||
|
|||||||
@@ -29,19 +29,16 @@ public:
|
|||||||
|
|
||||||
View* CreateView() const override
|
View* CreateView() const override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("CheatsAdapter::CreateView\n");
|
|
||||||
return new CheatListItemView(_vramOffsets, _materialColorScheme, _fontRepository);
|
return new CheatListItemView(_vramOffsets, _materialColorScheme, _fontRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyView(View* view) const override
|
void DestroyView(View* view) const override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("CheatsAdapter::DestroyView\n");
|
|
||||||
delete (CheatListItemView*)view;
|
delete (CheatListItemView*)view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BindView(View* view, int index) const override
|
void BindView(View* view, int index) const override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("CheatsAdapter::BindView\n");
|
|
||||||
auto listItemView = static_cast<CheatListItemView*>(view);
|
auto listItemView = static_cast<CheatListItemView*>(view);
|
||||||
u32 numberOfCategories = 0;
|
u32 numberOfCategories = 0;
|
||||||
auto categories = _cheatCategory->GetCategories(numberOfCategories);
|
auto categories = _cheatCategory->GetCategories(numberOfCategories);
|
||||||
@@ -60,7 +57,7 @@ public:
|
|||||||
|
|
||||||
void ReleaseView(View* view, int index) const override
|
void ReleaseView(View* view, int index) const override
|
||||||
{
|
{
|
||||||
LOG_DEBUG("CheatsAdapter::ReleaseView\n");
|
// Nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void CheatsBottomSheetView::Update()
|
|||||||
_cheatListRecycler->SetPosition(LIST_X, _position.y + LIST_Y);
|
_cheatListRecycler->SetPosition(LIST_X, _position.y + LIST_Y);
|
||||||
if (_viewModel->GetState() == CheatsViewModel::State::DisplayCheats)
|
if (_viewModel->GetState() == CheatsViewModel::State::DisplayCheats)
|
||||||
{
|
{
|
||||||
if (_cheatsAdapter == nullptr)
|
if (_cheatsAdapter == nullptr && _objVramManager != nullptr)
|
||||||
{
|
{
|
||||||
_cheatsAdapter = new CheatsAdapter(
|
_cheatsAdapter = new CheatsAdapter(
|
||||||
_viewModel->GetCurrentCheatCategory(), _materialColorScheme, _fontRepository, _vramOffsets);
|
_viewModel->GetCurrentCheatCategory(), _materialColorScheme, _fontRepository, _vramOffsets);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ private:
|
|||||||
CheatsAdapter* _cheatsAdapter = nullptr;
|
CheatsAdapter* _cheatsAdapter = nullptr;
|
||||||
const MaterialColorScheme* _materialColorScheme;
|
const MaterialColorScheme* _materialColorScheme;
|
||||||
const IFontRepository* _fontRepository;
|
const IFontRepository* _fontRepository;
|
||||||
IVramManager* _objVramManager;
|
IVramManager* _objVramManager = nullptr;
|
||||||
FocusManager* _focusManager;
|
FocusManager* _focusManager;
|
||||||
CheatListItemView::VramOffsets _vramOffsets;
|
CheatListItemView::VramOffsets _vramOffsets;
|
||||||
u32 _savedVramState = 0;
|
u32 _savedVramState = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user