mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Initial commit
This commit is contained in:
60
arm9/source/romBrowser/Theme/custom/CustomAppBarView.cpp
Normal file
60
arm9/source/romBrowser/Theme/custom/CustomAppBarView.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "common.h"
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "romBrowser/views/IconButton3DView.h"
|
||||
#include "CustomAppBarView.h"
|
||||
|
||||
#define BLOCK_VTX_PACK(x, y, z) (((x)&0x3FF) | ((((y) >> 3) & 0x3FF) << 10) | ((z) << 20))
|
||||
|
||||
CustomAppBarView::CustomAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme,
|
||||
u32 scrimTexVramOffset, u32 scrimPlttVramOffset)
|
||||
: AppBarView(x, y, orientation, startButtonCount, endButtonCount, materialColorScheme)
|
||||
, _scrimTexVramOffset(scrimTexVramOffset), _scrimPlttVramOffset(scrimPlttVramOffset)
|
||||
{
|
||||
for (int i = 0; i < _startButtonCount + _endButtonCount; i++)
|
||||
{
|
||||
_buttons[i] = new IconButton3DView(
|
||||
IconButtonView::Type::Tonal,
|
||||
IconButtonView::State::NoToggle,
|
||||
md::sys::color::inverseOnSurface,
|
||||
materialColorScheme);
|
||||
AddChildTail(_buttons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void CustomAppBarView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
Gx::MtxIdentity();
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_LESS, false, 31, 63);
|
||||
Gx::Color(0);
|
||||
Gx::TexImageParam(_scrimTexVramOffset >> 3, true, false, false, false, GX_TEXSIZE_8,
|
||||
GX_TEXSIZE_64, GX_TEXFMT_A5I3, false, GX_TEXGEN_NONE);
|
||||
Gx::TexPlttBase(_scrimPlttVramOffset >> 4);
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
if (GetOrientation() == Orientation::Horizontal)
|
||||
{
|
||||
Gx::TexCoord(0, 0);
|
||||
Gx::Vtx16(0, 0, -1.0 / 64);
|
||||
Gx::TexCoord(0, 42);
|
||||
Gx::Vtx16(0, 42.0 / 512.0, -1.0 / 64);
|
||||
Gx::TexCoord(256, 42);
|
||||
Gx::Vtx16(256.0 / 64, 42.0 / 512.0, -1.0 / 64);
|
||||
Gx::TexCoord(256, 0);
|
||||
Gx::Vtx16(256.0 / 64, 0, -1.0 / 64);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gx::TexCoord(0, 0);
|
||||
Gx::Vtx16(0, 192.0 / 512, -1.0 / 64);
|
||||
Gx::TexCoord(0, 42);
|
||||
Gx::Vtx16(42.0 / 64, 192.0 / 512, -1.0 / 64);
|
||||
Gx::TexCoord(192, 42);
|
||||
Gx::Vtx16(42.0 / 64, 0, -1.0 / 64);
|
||||
Gx::TexCoord(192, 0);
|
||||
Gx::Vtx16(0, 0, -1.0 / 64);
|
||||
Gx::End();
|
||||
}
|
||||
AppBarView::Draw(graphicsContext);
|
||||
}
|
||||
16
arm9/source/romBrowser/Theme/custom/CustomAppBarView.h
Normal file
16
arm9/source/romBrowser/Theme/custom/CustomAppBarView.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "../../views/AppBarView.h"
|
||||
|
||||
class CustomAppBarView : public AppBarView
|
||||
{
|
||||
public:
|
||||
CustomAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme,
|
||||
u32 scrimTexVramOffset, u32 scrimPlttVramOffset);
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
private:
|
||||
u32 _scrimTexVramOffset = 0;
|
||||
u32 _scrimPlttVramOffset = 0;
|
||||
};
|
||||
124
arm9/source/romBrowser/Theme/custom/CustomBannerListItemView.cpp
Normal file
124
arm9/source/romBrowser/Theme/custom/CustomBannerListItemView.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/gfx/gfx.h>
|
||||
#include "core/math/Rgb.h"
|
||||
#include "gui/PaletteManager.h"
|
||||
#include "gui/OamManager.h"
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "gui/IVramManager.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "core/math/ColorConverter.h"
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
#include "themes/IFontRepository.h"
|
||||
#include "bannerListItemBg0.h"
|
||||
#include "bannerListItemBg1.h"
|
||||
#include "bannerListItemBg2.h"
|
||||
#include "gui/palette/GradientPalette.h"
|
||||
#include "gui/palette/DirectPalette.h"
|
||||
#include "gui/views/Label3DView.h"
|
||||
#include "CustomBannerListItemView.h"
|
||||
|
||||
#define X_OFFSET (-3)
|
||||
#define Y_OFFSET (-2)
|
||||
#define Z_OFFSET 300
|
||||
#define WIDTH 209
|
||||
#define HEIGHT 49
|
||||
|
||||
#define LINE_WIDTH 160
|
||||
#define LINE_HEIGHT 16
|
||||
#define MAX_LINE_STRING_LENGTH 50
|
||||
|
||||
CustomBannerListItemView::CustomBannerListItemView(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository, u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset, VBlankTextureLoader* vblankTextureLoader)
|
||||
: BannerListItemView(
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Medium10), vblankTextureLoader),
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Regular10), vblankTextureLoader),
|
||||
std::make_unique<Label3DView>(LINE_WIDTH, LINE_HEIGHT, MAX_LINE_STRING_LENGTH,
|
||||
fontRepository->GetFont(FontType::Regular10), vblankTextureLoader))
|
||||
, _materialColorScheme(materialColorScheme)
|
||||
, _texVramOffset(texVramOffset)
|
||||
, _plttVramOffset(plttVramOffset)
|
||||
, _selectedTexVramOffset(selectedTexVramOffset)
|
||||
, _selectedPlttVramOffset(selectedPlttVramOffset) { }
|
||||
|
||||
void CustomBannerListItemView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (!graphicsContext.IsVisible(Rectangle(_position.x + X_OFFSET, _position.y + Y_OFFSET, WIDTH, HEIGHT)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto backgroundColor = Rgb<8, 8, 8>(200, 200, 200);
|
||||
|
||||
Gx::MtxIdentity();
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_LESS, false, 31, 0);
|
||||
Gx::Color(0x7FFF);
|
||||
|
||||
u32 tex = _isFocused ? _selectedTexVramOffset : _texVramOffset;
|
||||
u32 pltt = _isFocused ? _selectedPlttVramOffset : _plttVramOffset;
|
||||
Gx::TexImageParam(tex >> 3, false, false, false, false, GX_TEXSIZE_256,
|
||||
GX_TEXSIZE_64, GX_TEXFMT_A3I5, false, GX_TEXGEN_NONE);
|
||||
Gx::TexPlttBase(pltt >> 4);
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET) << 6, (_position.y + Y_OFFSET) << 3);
|
||||
REG_GX_VTX_16 = (Z_OFFSET) << 6;
|
||||
Gx::TexCoord(0, HEIGHT);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET) << 6, (_position.y + Y_OFFSET + HEIGHT) << 3);
|
||||
REG_GX_VTX_16 = (Z_OFFSET) << 6;
|
||||
Gx::TexCoord(WIDTH, HEIGHT);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET + WIDTH) << 6, (_position.y + Y_OFFSET + HEIGHT) << 3);
|
||||
REG_GX_VTX_16 = (Z_OFFSET) << 6;
|
||||
Gx::TexCoord(WIDTH, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET + WIDTH) << 6, (_position.y + Y_OFFSET) << 3);
|
||||
REG_GX_VTX_16 = (Z_OFFSET) << 6;
|
||||
Gx::End();
|
||||
|
||||
graphicsContext.SetPolygonId(1);
|
||||
|
||||
_firstLine->SetForegroundColor(Rgb<8, 8, 8>(30, 30, 30));
|
||||
_secondLine->SetForegroundColor(Rgb<8, 8, 8>(30, 30, 30));
|
||||
_thirdLine->SetForegroundColor(Rgb<8, 8, 8>(30, 30, 30));
|
||||
|
||||
if (_lines == 1)
|
||||
{
|
||||
_firstLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 14);
|
||||
}
|
||||
else if (_lines == 2)
|
||||
{
|
||||
_firstLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 8);
|
||||
_secondLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
_firstLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 2);
|
||||
_secondLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 14);
|
||||
_thirdLine->SetPosition(_position.x + 6 + 32 + 6, _position.y + 26);
|
||||
}
|
||||
|
||||
if (_lines >= 1)
|
||||
{
|
||||
_firstLine->Draw(graphicsContext);
|
||||
}
|
||||
if (_lines >= 2)
|
||||
{
|
||||
_secondLine->Draw(graphicsContext);
|
||||
}
|
||||
if (_lines >= 3)
|
||||
{
|
||||
_thirdLine->Draw(graphicsContext);
|
||||
}
|
||||
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetObjVramOffset(_iconVramOffset);
|
||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||
_icon->Draw(graphicsContext, backgroundColor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "gui/views/LabelView.h"
|
||||
#include "../../views/BannerListItemView.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class CustomBannerListItemView : public BannerListItemView
|
||||
{
|
||||
public:
|
||||
CustomBannerListItemView(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository, u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset, VBlankTextureLoader* vblankTextureLoader);
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position, 203, 44);
|
||||
}
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
u32 _texVramOffset = 0;
|
||||
u32 _plttVramOffset = 0;
|
||||
u32 _selectedTexVramOffset = 0;
|
||||
u32 _selectedPlttVramOffset = 0;
|
||||
};
|
||||
53
arm9/source/romBrowser/Theme/custom/CustomFileInfoView.cpp
Normal file
53
arm9/source/romBrowser/Theme/custom/CustomFileInfoView.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "common.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "gui/IVramManager.h"
|
||||
#include "themes/IFontRepository.h"
|
||||
#include "CustomFileInfoView.h"
|
||||
|
||||
CustomFileInfoView::CustomFileInfoView(const IFontRepository* fontRepository)
|
||||
: _firstLine(176, 16, 50, fontRepository->GetFont(FontType::Medium11))
|
||||
, _secondLine(176, 16, 50, fontRepository->GetFont(FontType::Regular10))
|
||||
, _thirdLine(176, 16, 50, fontRepository->GetFont(FontType::Regular10))
|
||||
, _filenameLabelView(220, 16, 200, fontRepository->GetFont(FontType::Medium7_5))
|
||||
, _backgroundColor(200, 200, 200), _textColor(30, 30, 30)
|
||||
{
|
||||
AddChildTail(&_firstLine);
|
||||
AddChildTail(&_secondLine);
|
||||
AddChildTail(&_thirdLine);
|
||||
_filenameLabelView.SetEllipsis(true);
|
||||
AddChildTail(&_filenameLabelView);
|
||||
}
|
||||
|
||||
void CustomFileInfoView::Update()
|
||||
{
|
||||
BannerView::Update();
|
||||
_firstLine.SetPosition(_position.x + 70, _position.y + 130 - 4);
|
||||
_secondLine.SetPosition(_position.x + 70, _position.y + 145 - 4);
|
||||
_thirdLine.SetPosition(_position.x + 70, _position.y + 159 - 4);
|
||||
_filenameLabelView.SetPosition(_position.x + 18, _position.y + 170);
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetPosition(_position.x + 24, _position.y + 136 - 4);
|
||||
_icon->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void CustomFileInfoView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
_firstLine.SetBackgroundColor(_backgroundColor);
|
||||
_firstLine.SetForegroundColor(_textColor);
|
||||
_secondLine.SetBackgroundColor(_backgroundColor);
|
||||
_secondLine.SetForegroundColor(_textColor);
|
||||
_thirdLine.SetBackgroundColor(_backgroundColor);
|
||||
_thirdLine.SetForegroundColor(_textColor);
|
||||
_filenameLabelView.SetBackgroundColor(_backgroundColor);
|
||||
_filenameLabelView.SetForegroundColor(_textColor);
|
||||
|
||||
BannerView::Draw(graphicsContext);
|
||||
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetObjVramOffset(_iconVramOffset);
|
||||
_icon->Draw(graphicsContext, _backgroundColor);
|
||||
}
|
||||
}
|
||||
72
arm9/source/romBrowser/Theme/custom/CustomFileInfoView.h
Normal file
72
arm9/source/romBrowser/Theme/custom/CustomFileInfoView.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
#include "core/task/TaskQueue.h"
|
||||
#include "gui/views/Label2DView.h"
|
||||
#include "../../views/BannerView.h"
|
||||
|
||||
class FileIcon;
|
||||
class IFontRepository;
|
||||
|
||||
class CustomFileInfoView : public BannerView
|
||||
{
|
||||
public:
|
||||
explicit CustomFileInfoView(const IFontRepository* fontRepository);
|
||||
|
||||
void Update() override;
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
void SetFirstLineAsync(TaskQueueBase* taskQueue, const char* firstLine, bool ellipsis) override
|
||||
{
|
||||
_firstLine.SetEllipsis(ellipsis);
|
||||
if (taskQueue)
|
||||
_firstLine.SetTextAsync(taskQueue, firstLine);
|
||||
else
|
||||
_firstLine.SetText(firstLine);
|
||||
}
|
||||
|
||||
void SetFirstLineAsync(TaskQueueBase* taskQueue, const char16_t* firstLine, u32 length, bool ellipsis) override
|
||||
{
|
||||
_firstLine.SetEllipsis(ellipsis);
|
||||
if (taskQueue)
|
||||
_firstLine.SetTextAsync(taskQueue, firstLine, length);
|
||||
else
|
||||
_firstLine.SetText(firstLine, length);
|
||||
}
|
||||
|
||||
void SetSecondLineAsync(TaskQueueBase* taskQueue, const char16_t* secondLine, u32 length) override
|
||||
{
|
||||
if (taskQueue)
|
||||
_secondLine.SetTextAsync(taskQueue, secondLine, length);
|
||||
else
|
||||
_secondLine.SetText(secondLine, length);
|
||||
}
|
||||
|
||||
void SetThirdLineAsync(TaskQueueBase* taskQueue, const char16_t* thirdLine, u32 length) override
|
||||
{
|
||||
if (taskQueue)
|
||||
_thirdLine.SetTextAsync(taskQueue, thirdLine, length);
|
||||
else
|
||||
_thirdLine.SetText(thirdLine, length);
|
||||
}
|
||||
|
||||
void SetFileNameAsync(TaskQueueBase* taskQueue, const TCHAR* fileName, bool useAsTitle) override
|
||||
{
|
||||
BannerView::SetFileNameAsync(taskQueue, fileName, useAsTitle);
|
||||
if (taskQueue)
|
||||
_filenameLabelView.SetTextAsync(taskQueue, fileName);
|
||||
else
|
||||
_filenameLabelView.SetText(fileName);
|
||||
}
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position, 236, 60);
|
||||
}
|
||||
|
||||
private:
|
||||
Label2DView _firstLine;
|
||||
Label2DView _secondLine;
|
||||
Label2DView _thirdLine;
|
||||
Label2DView _filenameLabelView;
|
||||
Rgb<8, 8, 8> _backgroundColor;
|
||||
Rgb<8, 8, 8> _textColor;
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "common.h"
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/PaletteManager.h"
|
||||
#include "gui/OamManager.h"
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "gui/IVramManager.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "CustomIconGridItemView.h"
|
||||
|
||||
#define X_OFFSET (-2)
|
||||
#define Y_OFFSET (-2)
|
||||
#define Z_OFFSET (-5)
|
||||
#define WIDTH 48
|
||||
#define HEIGHT 48
|
||||
|
||||
void CustomIconGridItemView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (!graphicsContext.IsVisible(Rectangle(_position.x + X_OFFSET, _position.y + Y_OFFSET, WIDTH, HEIGHT)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Gx::MtxIdentity();
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_LESS, false, 31, 0);
|
||||
Gx::Color(0x7FFF);
|
||||
|
||||
u32 tex = _isFocused ? _selectedTexVramOffset : _texVramOffset;
|
||||
u32 pltt = _isFocused ? _selectedPlttVramOffset : _plttVramOffset;
|
||||
Gx::TexImageParam(tex >> 3, false, false, false, false, GX_TEXSIZE_64,
|
||||
GX_TEXSIZE_64, GX_TEXFMT_A3I5, false, GX_TEXGEN_NONE);
|
||||
Gx::TexPlttBase(pltt >> 4);
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET) << 6, (_position.y + Y_OFFSET) << 3);
|
||||
REG_GX_VTX_16 = Z_OFFSET << 6;
|
||||
Gx::TexCoord(0, HEIGHT);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET) << 6, (_position.y + Y_OFFSET + HEIGHT) << 3);
|
||||
REG_GX_VTX_16 = Z_OFFSET << 6;
|
||||
Gx::TexCoord(WIDTH, HEIGHT);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET + WIDTH) << 6, (_position.y + Y_OFFSET + HEIGHT) << 3);
|
||||
REG_GX_VTX_16 = Z_OFFSET << 6;
|
||||
Gx::TexCoord(WIDTH, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((_position.x + X_OFFSET + WIDTH) << 6, (_position.y + Y_OFFSET) << 3);
|
||||
REG_GX_VTX_16 = Z_OFFSET << 6;
|
||||
Gx::End();
|
||||
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetObjVramOffset(_iconVramOffset);
|
||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||
_icon->Draw(graphicsContext, Rgb<8, 8, 8>(200, 200, 200));
|
||||
}
|
||||
}
|
||||
24
arm9/source/romBrowser/Theme/custom/CustomIconGridItemView.h
Normal file
24
arm9/source/romBrowser/Theme/custom/CustomIconGridItemView.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "../../views/IconGridItemView.h"
|
||||
|
||||
class CustomIconGridItemView : public IconGridItemView
|
||||
{
|
||||
public:
|
||||
CustomIconGridItemView(u32 texVramOffset, u32 plttVramOffset,
|
||||
u32 selectedTexVramOffset, u32 selectedPlttVramOffset)
|
||||
: _texVramOffset(texVramOffset), _plttVramOffset(plttVramOffset)
|
||||
, _selectedTexVramOffset(selectedTexVramOffset), _selectedPlttVramOffset(selectedPlttVramOffset) { }
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position.x + 2, _position.y + 2, 40, 40);
|
||||
}
|
||||
|
||||
private:
|
||||
u32 _texVramOffset = 0;
|
||||
u32 _plttVramOffset = 0;
|
||||
u32 _selectedTexVramOffset = 0;
|
||||
u32 _selectedPlttVramOffset = 0;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <libtwl/mem/memVram.h>
|
||||
#include "themes/ITheme.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "CustomRomBrowserViewFactory.h"
|
||||
|
||||
void CustomRomBrowserViewFactory::LoadResources(const ITheme& theme, const VramContext& mainVramContext)
|
||||
{
|
||||
auto tmpBuf = std::unique_ptr<u8[]>(new(cache_align) u8[13 * 1024]);
|
||||
const auto file = std::make_unique<File>();
|
||||
if (theme.OpenThemeFile(*file, "gridcell.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 4096, bytesRead);
|
||||
_gridCellTexVramOffset = mainVramContext.GetTexVramManager()->Alloc(4096);
|
||||
mem_setVramDMapping(MEM_VRAM_D_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexVramManager()->GetVramAddress(_gridCellTexVramOffset), tmpBuf.get(), 4096);
|
||||
mem_setVramDMapping(MEM_VRAM_D_TEX_SLOT_0);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "gridcellPltt.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 64, bytesRead);
|
||||
_gridCellPlttVramOffset = mainVramContext.GetTexPlttVramManager()->Alloc(64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexPlttVramManager()->GetVramAddress(_gridCellPlttVramOffset), tmpBuf.get(), 64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "gridcellSelected.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 4096, bytesRead);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_LCDC);
|
||||
memcpy((void*)0x681E200, tmpBuf.get(), 4096);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_TEX_SLOT_1);
|
||||
file->Close();
|
||||
_gridCellSelectedTexVramOffset = 0x3E200;
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "gridcellSelectedPltt.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 64, bytesRead);
|
||||
_gridCellSelectedPlttVramOffset = mainVramContext.GetTexPlttVramManager()->Alloc(64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexPlttVramManager()->GetVramAddress(_gridCellSelectedPlttVramOffset), tmpBuf.get(), 64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "scrim.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 336, bytesRead);
|
||||
_scrimTexVramOffset = mainVramContext.GetTexVramManager()->Alloc(336);
|
||||
mem_setVramDMapping(MEM_VRAM_D_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexVramManager()->GetVramAddress(_scrimTexVramOffset), tmpBuf.get(), 336);
|
||||
mem_setVramDMapping(MEM_VRAM_D_TEX_SLOT_0);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "scrimPltt.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 16, bytesRead);
|
||||
_scrimPlttVramOffset = mainVramContext.GetTexPlttVramManager()->Alloc(16);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexPlttVramManager()->GetVramAddress(_scrimPlttVramOffset), tmpBuf.get(), 16);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "bannerListCell.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 0x3100, bytesRead);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_LCDC);
|
||||
memcpy((void*)0x6818000, tmpBuf.get(), 12544);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_TEX_SLOT_1);
|
||||
file->Close();
|
||||
_bannerListCellTexVramOffset = 0x38000;
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "bannerListCellPltt.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 64, bytesRead);
|
||||
_bannerListCellPlttVramOffset = mainVramContext.GetTexPlttVramManager()->Alloc(64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexPlttVramManager()->GetVramAddress(_bannerListCellPlttVramOffset), tmpBuf.get(), 64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
file->Close();
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "bannerListCellSelected.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 0x3100, bytesRead);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_LCDC);
|
||||
memcpy((void*)0x681B100, tmpBuf.get(), 0x3100);
|
||||
mem_setVramAMapping(MEM_VRAM_AB_TEX_SLOT_1);
|
||||
file->Close();
|
||||
_bannerListCellSelectedTexVramOffset = 0x3B100;
|
||||
}
|
||||
if (theme.OpenThemeFile(*file, "bannerListCellSelectedPltt.bin"))
|
||||
{
|
||||
u32 bytesRead = 0;
|
||||
file->Read(tmpBuf.get(), 64, bytesRead);
|
||||
_bannerListCellSelectedPlttVramOffset = mainVramContext.GetTexPlttVramManager()->Alloc(64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
memcpy((void*)mainVramContext.GetTexPlttVramManager()->GetVramAddress(_bannerListCellSelectedPlttVramOffset), tmpBuf.get(), 64);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
file->Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
#include "CustomIconGridItemView.h"
|
||||
#include "CustomAppBarView.h"
|
||||
#include "CustomFileInfoView.h"
|
||||
#include "../IRomBrowserViewFactory.h"
|
||||
#include "CustomBannerListItemView.h"
|
||||
#include "romBrowser/views/CoverFlowRecyclerView.h"
|
||||
#include "romBrowser/viewModels/RomBrowserViewModel.h"
|
||||
#include "romBrowser/DisplayMode/CoverFlowFileRecyclerAdapter.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class ITheme;
|
||||
class VramContext;
|
||||
class IFontRepository;
|
||||
|
||||
class CustomRomBrowserViewFactory : public IRomBrowserViewFactory
|
||||
{
|
||||
public:
|
||||
CustomRomBrowserViewFactory(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: _materialColorScheme(materialColorScheme), _fontRepository(fontRepository) { }
|
||||
|
||||
IconGridItemView* CreateIconGridItemView() const override
|
||||
{
|
||||
return new CustomIconGridItemView(_gridCellTexVramOffset, _gridCellPlttVramOffset,
|
||||
_gridCellSelectedTexVramOffset, _gridCellSelectedPlttVramOffset);
|
||||
}
|
||||
|
||||
BannerListItemView* CreateBannerListItemView(VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return new CustomBannerListItemView(_materialColorScheme, _fontRepository,
|
||||
_bannerListCellTexVramOffset, _bannerListCellPlttVramOffset,
|
||||
_bannerListCellSelectedTexVramOffset, _bannerListCellSelectedPlttVramOffset, vblankTextureLoader);
|
||||
}
|
||||
|
||||
BannerListItemView::VramToken UploadBannerListItemViewGraphics(const VramContext& vramContext) const override
|
||||
{
|
||||
return BannerListItemView::VramToken(0);
|
||||
}
|
||||
|
||||
std::unique_ptr<AppBarView> CreateAppBarView(int x, int y, AppBarView::Orientation orientation,
|
||||
int startButtonCount, int endButtonCount) const override
|
||||
{
|
||||
return std::make_unique<CustomAppBarView>(x, y, orientation, startButtonCount, endButtonCount, _materialColorScheme,
|
||||
_scrimTexVramOffset, _scrimPlttVramOffset);
|
||||
}
|
||||
|
||||
std::unique_ptr<BannerView> CreateFileInfoView() const override
|
||||
{
|
||||
return std::make_unique<CustomFileInfoView>(_fontRepository);
|
||||
}
|
||||
|
||||
std::unique_ptr<RecyclerViewBase> CreateCoverFlowRecyclerView() const override
|
||||
{
|
||||
return std::make_unique<CoverFlowRecyclerView>();
|
||||
}
|
||||
|
||||
FileRecyclerAdapter* CreateCoverFlowRecyclerAdapter(
|
||||
RomBrowserViewModel* viewModel, const IThemeFileIconFactory* themeFileIconFactory,
|
||||
VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return new CoverFlowFileRecyclerAdapter(
|
||||
&viewModel->GetFileInfoManager(), viewModel->GetIoTaskQueue(),
|
||||
themeFileIconFactory, this, vblankTextureLoader, &viewModel->GetCoverRepository());
|
||||
}
|
||||
|
||||
void LoadResources(const ITheme& theme, const VramContext& mainVramContext);
|
||||
|
||||
private:
|
||||
u32 _gridCellTexVramOffset;
|
||||
u32 _gridCellPlttVramOffset;
|
||||
u32 _gridCellSelectedTexVramOffset;
|
||||
u32 _gridCellSelectedPlttVramOffset;
|
||||
u32 _bannerListCellTexVramOffset;
|
||||
u32 _bannerListCellPlttVramOffset;
|
||||
u32 _bannerListCellSelectedTexVramOffset;
|
||||
u32 _bannerListCellSelectedPlttVramOffset;
|
||||
u32 _scrimTexVramOffset;
|
||||
u32 _scrimPlttVramOffset;
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
const IFontRepository* _fontRepository;
|
||||
};
|
||||
Reference in New Issue
Block a user