mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
72 lines
2.2 KiB
C++
72 lines
2.2 KiB
C++
#pragma once
|
|
#include "gui/views/RecyclerAdapter.h"
|
|
#include "cheats/CheatCategory.h"
|
|
#include "cheats/Cheat.h"
|
|
#include "CheatListItemView.h"
|
|
|
|
class CheatsAdapter : public RecyclerAdapter
|
|
{
|
|
public:
|
|
CheatsAdapter(const ICheatCategory* cheatCategory, const MaterialColorScheme* materialColorScheme,
|
|
const IFontRepository* fontRepository, const CheatListItemView::VramOffsets& vramOffsets)
|
|
: _cheatCategory(cheatCategory), _materialColorScheme(materialColorScheme)
|
|
, _fontRepository(fontRepository), _vramOffsets(vramOffsets) { }
|
|
|
|
u32 GetItemCount() const override
|
|
{
|
|
u32 numberOfCategories = 0;
|
|
_cheatCategory->GetCategories(numberOfCategories);
|
|
u32 numberOfCheats = 0;
|
|
_cheatCategory->GetCheats(numberOfCheats);
|
|
return numberOfCategories + numberOfCheats;
|
|
}
|
|
|
|
void GetViewSize(int& width, int& height) const override
|
|
{
|
|
width = 224;
|
|
height = 24;
|
|
}
|
|
|
|
View* CreateView() const override
|
|
{
|
|
LOG_DEBUG("CheatsAdapter::CreateView\n");
|
|
return new CheatListItemView(_vramOffsets, _materialColorScheme, _fontRepository);
|
|
}
|
|
|
|
void DestroyView(View* view) const override
|
|
{
|
|
LOG_DEBUG("CheatsAdapter::DestroyView\n");
|
|
delete (CheatListItemView*)view;
|
|
}
|
|
|
|
void BindView(View* view, int index) const override
|
|
{
|
|
LOG_DEBUG("CheatsAdapter::BindView\n");
|
|
auto listItemView = static_cast<CheatListItemView*>(view);
|
|
u32 numberOfCategories = 0;
|
|
auto categories = _cheatCategory->GetCategories(numberOfCategories);
|
|
if ((u32)index < numberOfCategories)
|
|
{
|
|
listItemView->SetCategory(&categories[index]);
|
|
}
|
|
else
|
|
{
|
|
index -= numberOfCategories;
|
|
u32 numberOfCheats = 0;
|
|
auto cheats = _cheatCategory->GetCheats(numberOfCheats);
|
|
listItemView->SetCheat(&cheats[index]);
|
|
}
|
|
}
|
|
|
|
void ReleaseView(View* view, int index) const override
|
|
{
|
|
LOG_DEBUG("CheatsAdapter::ReleaseView\n");
|
|
}
|
|
|
|
private:
|
|
const ICheatCategory* _cheatCategory;
|
|
const MaterialColorScheme* _materialColorScheme;
|
|
const IFontRepository* _fontRepository;
|
|
CheatListItemView::VramOffsets _vramOffsets;
|
|
};
|