mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Further work on support for cheats
Cheats can now be enabled/disabled and games can be launched with cheats
This commit is contained in:
@@ -6,14 +6,16 @@
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "CheatListItemView.h"
|
||||
|
||||
#define ICON_X 20
|
||||
#define ICON_Y 3
|
||||
#define ICON_X 4
|
||||
#define ICON_Y 4
|
||||
|
||||
#define NAME_LABEL_X 40
|
||||
#define NAME_LABEL_Y 4
|
||||
#define NAME_LABEL_X 24
|
||||
#define NAME_LABEL_Y 5
|
||||
|
||||
CheatListItemView::CheatListItemView(const MaterialColorScheme* materialColorScheme, const IFontRepository* fontRepository)
|
||||
CheatListItemView::CheatListItemView(const VramOffsets& vramOffsets,
|
||||
const MaterialColorScheme* materialColorScheme, const IFontRepository* fontRepository)
|
||||
: _nameLabel(200, 16, 64, fontRepository->GetFont(FontType::Regular10))
|
||||
, _vramOffsets(vramOffsets)
|
||||
, _materialColorScheme(materialColorScheme)
|
||||
{
|
||||
_nameLabel.SetEllipsis(true);
|
||||
@@ -22,15 +24,57 @@ CheatListItemView::CheatListItemView(const MaterialColorScheme* materialColorSch
|
||||
|
||||
void CheatListItemView::Update()
|
||||
{
|
||||
_nameLabel.SetPosition(NAME_LABEL_X, _position.y + NAME_LABEL_Y);
|
||||
_nameLabel.SetPosition(_position.x + NAME_LABEL_X, _position.y + NAME_LABEL_Y);
|
||||
if (_cheat != nullptr)
|
||||
{
|
||||
_iconVramOffset = _cheat->GetIsCheatActive()
|
||||
? _vramOffsets.checkboxCheckedIconVramOffset
|
||||
: _vramOffsets.checkboxUncheckedIconVramOffset;
|
||||
}
|
||||
ViewContainer::Update();
|
||||
}
|
||||
|
||||
void CheatListItemView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (!graphicsContext.IsVisible(GetBounds()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto backColor = _materialColorScheme->GetColor(md::sys::color::surfaceContainerLow);
|
||||
if (IsFocused())
|
||||
{
|
||||
auto selectorFullColor = _materialColorScheme->GetColor(md::sys::color::onSurface);
|
||||
backColor = RgbMixer::Lerp(backColor, selectorFullColor, 10, 100);
|
||||
}
|
||||
|
||||
_nameLabel.SetBackgroundColor(backColor);
|
||||
_nameLabel.SetForegroundColor(_materialColorScheme->onSurface);
|
||||
|
||||
if (IsFocused())
|
||||
{
|
||||
u32 selectorPaletteRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
GradientPalette(backColor, backColor),
|
||||
_position.y, _position.y + 24);
|
||||
auto selectorOam = graphicsContext.GetOamManager().AllocOams(4);
|
||||
OamBuilder::OamWithSize<64, 32>(_position.x, _position.y, _vramOffsets.cheatSelectorVramOffset >> 7)
|
||||
.WithPalette16(selectorPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(selectorOam[0]);
|
||||
OamBuilder::OamWithSize<64, 32>(_position.x + 64, _position.y, _vramOffsets.cheatSelectorVramOffset >> 7)
|
||||
.WithPalette16(selectorPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(selectorOam[1]);
|
||||
OamBuilder::OamWithSize<64, 32>(_position.x + 2 * 64, _position.y, _vramOffsets.cheatSelectorVramOffset >> 7)
|
||||
.WithPalette16(selectorPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(selectorOam[2]);
|
||||
OamBuilder::OamWithSize<64, 32>(_position.x + 2 * 64 + 32, _position.y, _vramOffsets.cheatSelectorVramOffset >> 7)
|
||||
.WithPalette16(selectorPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(selectorOam[3]);
|
||||
}
|
||||
|
||||
ViewContainer::Draw(graphicsContext);
|
||||
|
||||
if (graphicsContext.IsVisible(Rectangle(_position.x + ICON_X, _position.y + ICON_Y, 16, 16)))
|
||||
|
||||
Reference in New Issue
Block a user