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:
40
arm9/source/romBrowser/Theme/IRomBrowserViewFactory.h
Normal file
40
arm9/source/romBrowser/Theme/IRomBrowserViewFactory.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include "../views/IconGridItemView.h"
|
||||
#include "../views/BannerListItemView.h"
|
||||
#include "../views/AppBarView.h"
|
||||
#include "../views/BannerView.h"
|
||||
#include "gui/views/RecyclerViewBase.h"
|
||||
|
||||
class VramContext;
|
||||
class VBlankTextureLoader;
|
||||
class RomBrowserViewModel;
|
||||
class IThemeFileIconFactory;
|
||||
class FileRecyclerAdapter;
|
||||
|
||||
class IRomBrowserViewFactory
|
||||
{
|
||||
public:
|
||||
virtual ~IRomBrowserViewFactory() = 0;
|
||||
|
||||
virtual IconGridItemView* CreateIconGridItemView() const = 0;
|
||||
virtual IconGridItemView::VramToken UploadIconGridItemViewGraphics(
|
||||
const VramContext& vramContext) const { return IconGridItemView::VramToken(0); }
|
||||
|
||||
virtual BannerListItemView* CreateBannerListItemView(VBlankTextureLoader* vblankTextureLoader) const = 0;
|
||||
virtual BannerListItemView::VramToken UploadBannerListItemViewGraphics(
|
||||
const VramContext& vramContext) const { return BannerListItemView::VramToken(0); }
|
||||
|
||||
virtual std::unique_ptr<AppBarView> CreateAppBarView(int x, int y, AppBarView::Orientation orientation,
|
||||
int startButtonCount, int endButtonCount) const = 0;
|
||||
|
||||
virtual std::unique_ptr<BannerView> CreateFileInfoView() const = 0;
|
||||
|
||||
virtual std::unique_ptr<RecyclerViewBase> CreateCoverFlowRecyclerView() const = 0;
|
||||
|
||||
virtual FileRecyclerAdapter* CreateCoverFlowRecyclerAdapter(
|
||||
RomBrowserViewModel* viewModel, const IThemeFileIconFactory* themeFileIconFactory,
|
||||
VBlankTextureLoader* vblankTextureLoader) const = 0;
|
||||
};
|
||||
|
||||
inline IRomBrowserViewFactory::~IRomBrowserViewFactory() { }
|
||||
14
arm9/source/romBrowser/Theme/IThemeFileIconFactory.h
Normal file
14
arm9/source/romBrowser/Theme/IThemeFileIconFactory.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
class FileIcon;
|
||||
|
||||
class IThemeFileIconFactory
|
||||
{
|
||||
public:
|
||||
virtual ~IThemeFileIconFactory() = 0;
|
||||
virtual std::unique_ptr<FileIcon> CreateFolderIcon(const TCHAR* name) const = 0;
|
||||
virtual std::unique_ptr<FileIcon> CreateGenericFileIcon(const TCHAR* name) const = 0;
|
||||
virtual std::unique_ptr<FileIcon> CreateNdsFileIcon(const TCHAR* name) const = 0;
|
||||
};
|
||||
|
||||
inline IThemeFileIconFactory::~IThemeFileIconFactory() { }
|
||||
227
arm9/source/romBrowser/Theme/Material/CarouselRecyclerView.cpp
Normal file
227
arm9/source/romBrowser/Theme/Material/CarouselRecyclerView.cpp
Normal file
@@ -0,0 +1,227 @@
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <libtwl/mem/memVram.h>
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "gui/materialDesign.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
#include "romBrowser/FileType/FileCover.h"
|
||||
#include "core/math/SinTable.h"
|
||||
#include "carouselMask.h"
|
||||
#include "CarouselRecyclerView.h"
|
||||
|
||||
#define COVER_SPACING 4
|
||||
#define Y_OFFSET 56
|
||||
#define CORNER_RADIUS 18
|
||||
#define SELECTED_COVER_WIDTH COVER_WIDTH
|
||||
#define SELECTED_COVER_X 46
|
||||
#define NEXT_COVER_WIDTH 54
|
||||
#define NEXT_COVER_X (SELECTED_COVER_X + SELECTED_COVER_WIDTH + COVER_SPACING)
|
||||
#define SMALL_COVER_WIDTH 36
|
||||
#define HORIZONTAL_PADDING 6
|
||||
|
||||
u32 CarouselRecyclerView::sMaskTextureVramOffset;
|
||||
|
||||
void CarouselRecyclerView::UploadGraphics(const VramContext& vramContext)
|
||||
{
|
||||
const auto textureVramManager = vramContext.GetTexVramManager();
|
||||
if (textureVramManager)
|
||||
{
|
||||
sMaskTextureVramOffset = textureVramManager->Alloc(carouselMaskBitmapLen);
|
||||
dma_ntrCopy32(3, carouselMaskBitmap, textureVramManager->GetVramAddress(sMaskTextureVramOffset), carouselMaskBitmapLen);
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselRecyclerView::Update()
|
||||
{
|
||||
if (_itemCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int rangeStartIndex = GetSelectedItem() - 4;
|
||||
int rangeEndIndex = GetSelectedItem() + 1 + 4;
|
||||
rangeStartIndex = std::clamp(rangeStartIndex, 0, (int)_itemCount - 1);
|
||||
rangeEndIndex = std::clamp(rangeEndIndex, 0, (int)_itemCount);
|
||||
|
||||
if (_curRangeStart != rangeStartIndex || _curRangeLength != rangeEndIndex - rangeStartIndex)
|
||||
{
|
||||
LOG_DEBUG("range: %d - %d\n", rangeStartIndex, rangeEndIndex - 1);
|
||||
if (_curRangeLength != 0)
|
||||
{
|
||||
if (_curRangeStart < rangeStartIndex)
|
||||
ReleaseRange(_curRangeStart, rangeStartIndex);
|
||||
|
||||
if (rangeEndIndex < _curRangeStart + _curRangeLength)
|
||||
ReleaseRange(rangeEndIndex, _curRangeStart + _curRangeLength);
|
||||
}
|
||||
|
||||
BindRange(rangeStartIndex, rangeEndIndex);
|
||||
|
||||
_curRangeStart = rangeStartIndex;
|
||||
_curRangeLength = rangeEndIndex - rangeStartIndex;
|
||||
}
|
||||
|
||||
for (u32 i = _viewPoolFreeCount; i < _viewPool.size(); i++)
|
||||
{
|
||||
_viewPoolEx[i].xPositionAnimator.Update();
|
||||
_viewPoolEx[i].widthAnimator.Update();
|
||||
_viewPool[i].view->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void CarouselRecyclerView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
for (u32 i = _viewPoolFreeCount; i < _viewPool.size(); i++)
|
||||
{
|
||||
fix32<12> x = (_viewPoolEx[i].xPositionAnimator.GetValue() + 0.5).Int();
|
||||
fix32<12> width = (_viewPoolEx[i].widthAnimator.GetValue() + 0.5).Int();
|
||||
fix32<12> left = x;
|
||||
if (left < HORIZONTAL_PADDING)
|
||||
{
|
||||
left = HORIZONTAL_PADDING;
|
||||
}
|
||||
fix32<12> right = x + width;
|
||||
if (right > (256 - HORIZONTAL_PADDING))
|
||||
{
|
||||
right = 256 - HORIZONTAL_PADDING;
|
||||
}
|
||||
if (left != right)
|
||||
{
|
||||
graphicsContext.SetPolygonId(i);
|
||||
Gx::MtxIdentity();
|
||||
Gx::MtxTranslate(0, 0, fix32<12>(-5 - std::abs(GetSelectedItem() - _viewPool[i].itemIdx)) / 64);
|
||||
RenderCoverMask(graphicsContext, left, right);
|
||||
|
||||
// Render cover
|
||||
_viewPool[i].view->SetPosition((x - ((COVER_WIDTH - width) / 2) + 0.5).Int(), Y_OFFSET);
|
||||
_viewPool[i].view->Draw(graphicsContext);
|
||||
|
||||
RenderRoundedCorners(graphicsContext, x, width);
|
||||
}
|
||||
}
|
||||
|
||||
Gx::MtxIdentity();
|
||||
}
|
||||
|
||||
void CarouselRecyclerView::RenderCoverMask(GraphicsContext& graphicsContext, fix32<12> left, fix32<12> right) const
|
||||
{
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_LESS, false, 31, 0);
|
||||
Gx::TexImageParam((128 * 1024) >> 3, false, false, false, false, GX_TEXSIZE_8,
|
||||
GX_TEXSIZE_8, GX_TEXFMT_PLTT16, false, GX_TEXGEN_NONE);
|
||||
graphicsContext.GetRgb6Palette()->ApplyColor(Rgb<6, 6, 6>(_materialColorScheme->surfaceBright));
|
||||
Gx::TexCoord(0, 0);
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
{
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((left / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((left / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((right / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((right / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
}
|
||||
Gx::End();
|
||||
}
|
||||
|
||||
void CarouselRecyclerView::RenderRoundedCorners(GraphicsContext& graphicsContext, fix32<12> x, fix32<12> width) const
|
||||
{
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_EQUAL, false, 31, 0);
|
||||
Gx::TexImageParam(sMaskTextureVramOffset >> 3, true, true, true, true, GX_TEXSIZE_32,
|
||||
GX_TEXSIZE_32, GX_TEXFMT_A5I3, false, GX_TEXGEN_NONE);
|
||||
|
||||
graphicsContext.GetRgb6Palette()->ApplyColor(Rgb<6, 6, 6>(_materialColorScheme->inverseOnSurface));
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
// top-left
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((x / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
Gx::TexCoord(0, CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((x / 64).GetRawValue(), (Y_OFFSET + CORNER_RADIUS) << 3);
|
||||
Gx::TexCoord(CORNER_RADIUS, CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + CORNER_RADIUS) << 3);
|
||||
Gx::TexCoord(CORNER_RADIUS, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + CORNER_RADIUS) / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
|
||||
// top-right
|
||||
Gx::TexCoord(-CORNER_RADIUS, 0);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK(((x + width - CORNER_RADIUS) / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
Gx::TexCoord(-CORNER_RADIUS, CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width - CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + CORNER_RADIUS) << 3);
|
||||
Gx::TexCoord(0, CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width) / 64).GetRawValue(), (Y_OFFSET + CORNER_RADIUS) << 3);
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width) / 64).GetRawValue(), Y_OFFSET << 3);
|
||||
|
||||
// bottom-left
|
||||
Gx::TexCoord(0, -CORNER_RADIUS);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK((x / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT - CORNER_RADIUS) << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((x / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(CORNER_RADIUS, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(CORNER_RADIUS, -CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT - CORNER_RADIUS) << 3);
|
||||
|
||||
// bottom-right
|
||||
Gx::TexCoord(-CORNER_RADIUS, -CORNER_RADIUS);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK(((x + width - CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT - CORNER_RADIUS) << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
Gx::TexCoord(-CORNER_RADIUS, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width - CORNER_RADIUS) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(0, -CORNER_RADIUS);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(((x + width) / 64).GetRawValue(), (Y_OFFSET + COVER_HEIGHT - CORNER_RADIUS) << 3);
|
||||
Gx::End();
|
||||
}
|
||||
|
||||
void CarouselRecyclerView::UpdateItemPosition(int viewPoolIndex, bool initial)
|
||||
{
|
||||
ViewPoolEntry* item = &_viewPool[viewPoolIndex];
|
||||
ViewPoolEntryEx* itemEx = &_viewPoolEx[viewPoolIndex];
|
||||
int selectedIndex = GetSelectedItem();
|
||||
if (selectedIndex == -1)
|
||||
{
|
||||
selectedIndex = 0;
|
||||
}
|
||||
int itemIndex = item->itemIdx;
|
||||
fix32<12> x;
|
||||
fix32<12> width;
|
||||
if (itemIndex < selectedIndex)
|
||||
{
|
||||
x = SELECTED_COVER_X + (SMALL_COVER_WIDTH + COVER_SPACING) * (itemIndex - selectedIndex);
|
||||
width = SMALL_COVER_WIDTH;
|
||||
}
|
||||
else if (itemIndex == selectedIndex + 1)
|
||||
{
|
||||
x = NEXT_COVER_X;
|
||||
width = NEXT_COVER_WIDTH;
|
||||
}
|
||||
else if (itemIndex > selectedIndex + 1)
|
||||
{
|
||||
x = NEXT_COVER_X + NEXT_COVER_WIDTH + COVER_SPACING
|
||||
+ (SMALL_COVER_WIDTH + COVER_SPACING) * (itemIndex - selectedIndex - 2);
|
||||
width = SMALL_COVER_WIDTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = SELECTED_COVER_X;
|
||||
width = SELECTED_COVER_WIDTH;
|
||||
}
|
||||
|
||||
if (initial)
|
||||
{
|
||||
itemEx->xPositionAnimator = Animator(x);
|
||||
itemEx->widthAnimator = Animator(width);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemEx->xPositionAnimator.Goto(x, md::sys::motion::duration::medium4, &md::sys::motion::easing::standard);
|
||||
itemEx->widthAnimator.Goto(width, md::sys::motion::duration::medium4, &md::sys::motion::easing::standard);
|
||||
}
|
||||
}
|
||||
41
arm9/source/romBrowser/Theme/Material/CarouselRecyclerView.h
Normal file
41
arm9/source/romBrowser/Theme/Material/CarouselRecyclerView.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include "romBrowser/views/CoverFlowRecyclerViewBase.h"
|
||||
#include "animation/Animator.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
|
||||
class CarouselRecyclerView : public CoverFlowRecyclerViewBase
|
||||
{
|
||||
public:
|
||||
explicit CarouselRecyclerView(const MaterialColorScheme* materialColorScheme)
|
||||
: _materialColorScheme(materialColorScheme) { }
|
||||
|
||||
static void UploadGraphics(const VramContext& vramContext);
|
||||
|
||||
void Update() override;
|
||||
void Draw(GraphicsContext &graphicsContext) override;
|
||||
|
||||
private:
|
||||
struct ViewPoolEntryEx
|
||||
{
|
||||
Animator<fix32<12>> xPositionAnimator;
|
||||
Animator<fix32<12>> widthAnimator;
|
||||
};
|
||||
|
||||
std::array<ViewPoolEntryEx, 10> _viewPoolEx;
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
|
||||
static u32 sMaskTextureVramOffset;
|
||||
|
||||
void RenderCoverMask(GraphicsContext& graphicsContext, fix32<12> left, fix32<12> right) const;
|
||||
void RenderRoundedCorners(GraphicsContext& graphicsContext, fix32<12> x, fix32<12> width) const;
|
||||
|
||||
void UpdateItemPosition(int viewPoolIndex, bool initial) override;
|
||||
|
||||
void SwapViewPoolEntry(int indexA, int indexB) override
|
||||
{
|
||||
CoverFlowRecyclerViewBase::SwapViewPoolEntry(indexA, indexB);
|
||||
std::swap(_viewPoolEx[indexA], _viewPoolEx[indexB]);
|
||||
}
|
||||
};
|
||||
32
arm9/source/romBrowser/Theme/Material/MaterialAppBarView.cpp
Normal file
32
arm9/source/romBrowser/Theme/Material/MaterialAppBarView.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "common.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "romBrowser/views/IconButton2DView.h"
|
||||
#include "MaterialAppBarView.h"
|
||||
|
||||
MaterialAppBarView::MaterialAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme)
|
||||
: AppBarView(x, y, orientation, startButtonCount, endButtonCount, materialColorScheme)
|
||||
{
|
||||
for (int i = 0; i < _startButtonCount + _endButtonCount; i++)
|
||||
{
|
||||
_buttons[i] = new IconButton2DView(
|
||||
IconButtonView::Type::Standard,
|
||||
IconButtonView::State::NoToggle,
|
||||
md::sys::color::inverseOnSurface,
|
||||
materialColorScheme);
|
||||
AddChildTail(_buttons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialAppBarView::InitVram(const VramContext& vramContext)
|
||||
{
|
||||
const auto objVramManager = vramContext.GetObjVramManager();
|
||||
if (objVramManager)
|
||||
{
|
||||
auto iconButtonVramToken = IconButton2DView::UploadGraphics(*objVramManager);
|
||||
for (int i = 0; i < _startButtonCount + _endButtonCount; i++)
|
||||
{
|
||||
static_cast<IconButton2DView*>(_buttons[i])->SetGraphics(iconButtonVramToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
arm9/source/romBrowser/Theme/Material/MaterialAppBarView.h
Normal file
11
arm9/source/romBrowser/Theme/Material/MaterialAppBarView.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "../../views/AppBarView.h"
|
||||
|
||||
class MaterialAppBarView : public AppBarView
|
||||
{
|
||||
public:
|
||||
MaterialAppBarView(int x, int y, Orientation orientation,
|
||||
int startButtonCount, int endButtonCount, const MaterialColorScheme* materialColorScheme);
|
||||
|
||||
void InitVram(const VramContext& vramContext) override;
|
||||
};
|
||||
@@ -0,0 +1,147 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/gfx/gfx.h>
|
||||
#include "gui/PaletteManager.h"
|
||||
#include "gui/OamManager.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/Label2DView.h"
|
||||
#include "MaterialBannerListItemView.h"
|
||||
|
||||
MaterialBannerListItemView::MaterialBannerListItemView(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: BannerListItemView(
|
||||
std::make_unique<Label2DView>(160, 16, 50, fontRepository->GetFont(FontType::Medium10)),
|
||||
std::make_unique<Label2DView>(160, 16, 50, fontRepository->GetFont(FontType::Regular10)),
|
||||
std::make_unique<Label2DView>(160, 16, 50, fontRepository->GetFont(FontType::Regular10)))
|
||||
, _materialColorScheme(materialColorScheme) { }
|
||||
|
||||
void MaterialBannerListItemView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (!graphicsContext.IsVisible(Rectangle(_position.x - 2, _position.y - 2, 207, 48)))
|
||||
return;
|
||||
|
||||
auto backColor = _materialColorScheme->inverseOnSurface;
|
||||
auto frontColor = _isFocused
|
||||
? _materialColorScheme->mainIconBg
|
||||
: _materialColorScheme->surfaceBright;
|
||||
u16 bgPltt[16];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
auto blendFactors = ColorConverter::FromXBGR555(bannerListItemBg0Pal[i]);
|
||||
auto palColor = Rgb<8, 8, 8>(
|
||||
(backColor.r * blendFactors.r + frontColor.r * blendFactors.g + 16) / 31,
|
||||
(backColor.g * blendFactors.r + frontColor.g * blendFactors.g + 16) / 31,
|
||||
(backColor.b * blendFactors.r + frontColor.b * blendFactors.g + 16) / 31);
|
||||
palColor = palColor.Clamped();
|
||||
bgPltt[i] = ColorConverter::ToGBGR565(palColor);
|
||||
}
|
||||
u32 bgPaletteRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
DirectPalette(bgPltt), _position.y - 2, _position.y - 2 + 48);
|
||||
|
||||
gfx_oam_entry_t* oam = graphicsContext.GetOamManager().AllocOams(4);
|
||||
OamBuilder::OamWithSize<64, 64>(
|
||||
_position.x - 2,
|
||||
_position.y - 2, _bgVramOffset >> 7)
|
||||
.WithPalette16(bgPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oam[0]);
|
||||
OamBuilder::OamWithSize<64, 64>(
|
||||
_position.x - 2 + 64,
|
||||
_position.y - 2, (_bgVramOffset + bannerListItemBg0TilesLen) >> 7)
|
||||
.WithPalette16(bgPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oam[1]);
|
||||
OamBuilder::OamWithSize<64, 64>(
|
||||
_position.x - 2 + 64 + 64,
|
||||
_position.y - 2, (_bgVramOffset + bannerListItemBg0TilesLen) >> 7)
|
||||
.WithPalette16(bgPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oam[2]);
|
||||
OamBuilder::OamWithSize<32, 64>(
|
||||
_position.x - 2 + 64 + 64 + 64,
|
||||
_position.y - 2, (_bgVramOffset + bannerListItemBg0TilesLen + bannerListItemBg1TilesLen) >> 7)
|
||||
.WithPalette16(bgPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oam[3]);
|
||||
|
||||
if (_isFocused)
|
||||
{
|
||||
_firstLine->SetBackgroundColor(frontColor);
|
||||
_firstLine->SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
_secondLine->SetBackgroundColor(frontColor);
|
||||
_secondLine->SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
_thirdLine->SetBackgroundColor(frontColor);
|
||||
_thirdLine->SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_firstLine->SetForegroundColor(_materialColorScheme->onSurface);
|
||||
_firstLine->SetBackgroundColor(_materialColorScheme->surfaceBright);
|
||||
_secondLine->SetForegroundColor(_materialColorScheme->onSurfaceVariant);
|
||||
_secondLine->SetBackgroundColor(_materialColorScheme->surfaceBright);
|
||||
_thirdLine->SetForegroundColor(_materialColorScheme->onSurfaceVariant);
|
||||
_thirdLine->SetBackgroundColor(_materialColorScheme->surfaceBright);
|
||||
}
|
||||
|
||||
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, frontColor);
|
||||
}
|
||||
}
|
||||
|
||||
BannerListItemView::VramToken MaterialBannerListItemView::UploadGraphics(const VramContext& vramContext)
|
||||
{
|
||||
const auto objVramManager = vramContext.GetObjVramManager();
|
||||
u32 vramOffset = 0;
|
||||
if (objVramManager)
|
||||
{
|
||||
vramOffset = objVramManager->Alloc(
|
||||
bannerListItemBg0TilesLen + bannerListItemBg1TilesLen + bannerListItemBg2TilesLen);
|
||||
dma_ntrCopy32(3, bannerListItemBg0Tiles,
|
||||
objVramManager->GetVramAddress(vramOffset),
|
||||
bannerListItemBg0TilesLen);
|
||||
dma_ntrCopy32(3, bannerListItemBg1Tiles,
|
||||
objVramManager->GetVramAddress(vramOffset + bannerListItemBg0TilesLen),
|
||||
bannerListItemBg1TilesLen);
|
||||
dma_ntrCopy32(3, bannerListItemBg2Tiles,
|
||||
objVramManager->GetVramAddress(vramOffset + bannerListItemBg0TilesLen + bannerListItemBg1TilesLen),
|
||||
bannerListItemBg2TilesLen);
|
||||
}
|
||||
return BannerListItemView::VramToken(vramOffset);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "gui/views/LabelView.h"
|
||||
#include "../../views/BannerListItemView.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class MaterialBannerListItemView : public BannerListItemView
|
||||
{
|
||||
public:
|
||||
MaterialBannerListItemView(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository);
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position, 203, 44);
|
||||
}
|
||||
|
||||
void SetGraphics(const VramToken& vramToken) override
|
||||
{
|
||||
_bgVramOffset = vramToken.GetVramOffset();
|
||||
}
|
||||
|
||||
static VramToken UploadGraphics(const VramContext& vramContext);
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
u32 _bgVramOffset;
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "common.h"
|
||||
#include "romBrowser/FileInfoManager.h"
|
||||
#include "core/task/TaskQueue.h"
|
||||
#include "MaterialCoverView.h"
|
||||
#include "romBrowser/Theme/IRomBrowserViewFactory.h"
|
||||
#include "romBrowser/FileType/UnknownFileCover.h"
|
||||
#include "romBrowser/ICoverRepository.h"
|
||||
#include "MaterialCoverFlowFileRecyclerAdapter.h"
|
||||
|
||||
void MaterialCoverFlowFileRecyclerAdapter::GetViewSize(int& width, int& height) const
|
||||
{
|
||||
width = COVER_WIDTH;
|
||||
height = COVER_HEIGHT;
|
||||
}
|
||||
|
||||
View* MaterialCoverFlowFileRecyclerAdapter::CreateView() const
|
||||
{
|
||||
return new MaterialCoverView(_vblankTextureLoader);
|
||||
}
|
||||
|
||||
void MaterialCoverFlowFileRecyclerAdapter::DestroyView(View* view) const
|
||||
{
|
||||
auto coverView = static_cast<MaterialCoverView*>(view);
|
||||
delete coverView;
|
||||
}
|
||||
|
||||
TaskResult<void> MaterialCoverFlowFileRecyclerAdapter::BindView(View* view, int index,
|
||||
const InternalFileInfo* internalFileInfo, const vu8& cancelRequested) const
|
||||
{
|
||||
auto coverView = static_cast<MaterialCoverView*>(view);
|
||||
auto cover = _fileInfoManager->GetFileCover(index);
|
||||
if (cancelRequested)
|
||||
{
|
||||
_fileInfoManager->ReleaseFileInfo(index);
|
||||
return TaskResult<void>::Canceled();
|
||||
}
|
||||
coverView->SetCover(std::move(cover));
|
||||
coverView->UploadCoverGraphics();
|
||||
if (cancelRequested)
|
||||
{
|
||||
coverView->ClearCover();
|
||||
_fileInfoManager->ReleaseFileInfo(index);
|
||||
return TaskResult<void>::Canceled();
|
||||
}
|
||||
return TaskResult<void>::Completed();
|
||||
}
|
||||
|
||||
void MaterialCoverFlowFileRecyclerAdapter::ReleaseView(View* view, int index) const
|
||||
{
|
||||
LOG_DEBUG("Releasing %d\n", index);
|
||||
auto coverView = static_cast<MaterialCoverView*>(view);
|
||||
coverView->ClearCover();
|
||||
_fileInfoManager->ReleaseFileInfo(index);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "romBrowser/FileRecyclerAdapter.h"
|
||||
|
||||
class IRomBrowserViewFactory;
|
||||
class VBlankTextureLoader;
|
||||
class ICoverRepository;
|
||||
|
||||
class MaterialCoverFlowFileRecyclerAdapter : public FileRecyclerAdapter
|
||||
{
|
||||
public:
|
||||
MaterialCoverFlowFileRecyclerAdapter(FileInfoManager* fileInfoManager,
|
||||
TaskQueueBase* taskQueue, const IThemeFileIconFactory* themeFileIconFactory,
|
||||
const IRomBrowserViewFactory* romBrowserViewFactory,
|
||||
VBlankTextureLoader* vblankTextureLoader,
|
||||
const ICoverRepository* coverRepository)
|
||||
: FileRecyclerAdapter(fileInfoManager, taskQueue, themeFileIconFactory)
|
||||
, _romBrowserViewFactory(romBrowserViewFactory)
|
||||
, _vblankTextureLoader(vblankTextureLoader)
|
||||
, _coverRepository(coverRepository) { }
|
||||
|
||||
void GetViewSize(int& width, int& height) const override;
|
||||
View* CreateView() const override;
|
||||
void DestroyView(View* view) const override;
|
||||
void ReleaseView(View* view, int index) const override;
|
||||
|
||||
private:
|
||||
const IRomBrowserViewFactory* _romBrowserViewFactory;
|
||||
VBlankTextureLoader* _vblankTextureLoader;
|
||||
const ICoverRepository* _coverRepository;
|
||||
|
||||
TaskResult<void> BindView(View* view, int index,
|
||||
const InternalFileInfo* internalFileInfo, const vu8& cancelRequested) const override;
|
||||
};
|
||||
56
arm9/source/romBrowser/Theme/Material/MaterialCoverView.cpp
Normal file
56
arm9/source/romBrowser/Theme/Material/MaterialCoverView.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "common.h"
|
||||
#include "core/math/SinTable.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/materialDesign.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "MaterialCoverView.h"
|
||||
|
||||
void MaterialCoverView::InitVram(const VramContext& vramContext)
|
||||
{
|
||||
const auto texVramManager = vramContext.GetTexVramManager();
|
||||
const auto texPlttVramManager = vramContext.GetTexPlttVramManager();
|
||||
if (texVramManager && texPlttVramManager)
|
||||
{
|
||||
_texVramOffset = texVramManager->Alloc(128 * 96);
|
||||
_plttVramOffset = texPlttVramManager->Alloc(256 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialCoverView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (_cover.IsValid() && _textureLoadRequest.GetState() == VBlankTextureLoadRequestState::LoadComplete)
|
||||
{
|
||||
Gx::TexImageParam(_texVramOffset >> 3, false, true, false, true, GX_TEXSIZE_128,
|
||||
GX_TEXSIZE_128, GX_TEXFMT_PLTT256, false, GX_TEXGEN_NONE);
|
||||
Gx::TexPlttBase(_plttVramOffset >> 4);
|
||||
|
||||
u32 polygonId = graphicsContext.GetPolygonId();
|
||||
Gx::PolygonAttr(GX_LIGHTMASK_NONE, GX_POLYGON_MODE_MODULATE, GX_DISPLAY_MODE_FRONT,
|
||||
false, false, false, GX_DEPTH_FUNC_EQUAL, false, 31, polygonId);
|
||||
|
||||
Gx::Color(31, 31, 31);
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
Gx::TexCoord(0, -COVER_HEIGHT);
|
||||
REG_GX_VTX_16 = GX_VTX_PACK(_position.x << 6, _position.y << 3);
|
||||
REG_GX_VTX_16 = 0;
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK(_position.x << 6, (_position.y + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(COVER_WIDTH, 0);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((_position.x + COVER_WIDTH) << 6, (_position.y + COVER_HEIGHT) << 3);
|
||||
Gx::TexCoord(COVER_WIDTH, -COVER_HEIGHT);
|
||||
REG_GX_VTX_XY = GX_VTX_PACK((_position.x + COVER_WIDTH) << 6, _position.y << 3);
|
||||
Gx::End();
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialCoverView::UploadCoverGraphics()
|
||||
{
|
||||
if (_cover.IsValid())
|
||||
{
|
||||
_cover->SetTexVramOffset(_texVramOffset, _plttVramOffset);
|
||||
_vblankTextureLoader->CancelLoad(_textureLoadRequest);
|
||||
_textureLoadRequest = _cover->CreateTextureLoadRequest();
|
||||
_vblankTextureLoader->RequestLoad(_textureLoadRequest);
|
||||
}
|
||||
}
|
||||
54
arm9/source/romBrowser/Theme/Material/MaterialCoverView.h
Normal file
54
arm9/source/romBrowser/Theme/Material/MaterialCoverView.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include "core/SharedPtr.h"
|
||||
#include "gui/views/View.h"
|
||||
#include "romBrowser/FileType/FileCover.h"
|
||||
#include "gui/VBlankTextureLoader.h"
|
||||
|
||||
class MaterialCoverView : public View
|
||||
{
|
||||
public:
|
||||
explicit MaterialCoverView(VBlankTextureLoader* vblankTextureLoader)
|
||||
: _vblankTextureLoader(vblankTextureLoader) { }
|
||||
|
||||
~MaterialCoverView() override
|
||||
{
|
||||
_vblankTextureLoader->CancelLoad(_textureLoadRequest);
|
||||
}
|
||||
|
||||
void InitVram(const VramContext& vramContext) override;
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position.x - (COVER_WIDTH / 2), _position.y - (COVER_HEIGHT / 2), COVER_WIDTH, COVER_HEIGHT);
|
||||
}
|
||||
|
||||
void SetCover(SharedPtr<FileCover> cover)
|
||||
{
|
||||
if (_cover.IsValid())
|
||||
{
|
||||
_vblankTextureLoader->CancelLoad(_textureLoadRequest);
|
||||
}
|
||||
_cover = std::move(cover);
|
||||
}
|
||||
|
||||
void ClearCover()
|
||||
{
|
||||
if (_cover.IsValid())
|
||||
{
|
||||
_vblankTextureLoader->CancelLoad(_textureLoadRequest);
|
||||
}
|
||||
_cover.Reset();
|
||||
}
|
||||
|
||||
void UploadCoverGraphics();
|
||||
|
||||
private:
|
||||
VBlankTextureLoader* _vblankTextureLoader;
|
||||
SharedPtr<FileCover> _cover;
|
||||
VBlankTextureLoadRequest _textureLoadRequest;
|
||||
u32 _texVramOffset = 0;
|
||||
u32 _plttVramOffset = 0;
|
||||
};
|
||||
66
arm9/source/romBrowser/Theme/Material/MaterialFileIcon.cpp
Normal file
66
arm9/source/romBrowser/Theme/Material/MaterialFileIcon.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include "common.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "gui/PaletteManager.h"
|
||||
#include "gui/font/nitroFont2.h"
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "largeFolderIcon.h"
|
||||
#include "gui/palette/GradientPalette.h"
|
||||
#include "themes/IFontRepository.h"
|
||||
#include "MaterialFileIcon.h"
|
||||
|
||||
MaterialFileIcon::MaterialFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: _materialColorScheme(materialColorScheme), _fontRepository(fontRepository)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
TCHAR c = name[i];
|
||||
if (c == 0)
|
||||
break;
|
||||
_displayName[i] = c;
|
||||
}
|
||||
_displayName[i] = 0;
|
||||
}
|
||||
|
||||
void MaterialFileIcon::UploadGraphics(vu16* vram) const
|
||||
{
|
||||
dma_ntrCopy32(3, GetIconTiles(), vram, 32 * 32 / 2);
|
||||
|
||||
auto font = _fontRepository->GetFont(FontType::Medium11);
|
||||
u8 tileBuffer[32 * 16 / 2];
|
||||
memset(tileBuffer, 0, sizeof(tileBuffer));
|
||||
u32 textWidth, textHeight;
|
||||
nft2_measureString(font, _displayName, textWidth, textHeight);
|
||||
nft2_string_render_params_t renderParams;
|
||||
renderParams.x = ((int)32 - (int)textWidth) / 2;
|
||||
renderParams.y = 0;
|
||||
renderParams.width = 32;
|
||||
renderParams.height = 16;
|
||||
renderParams.a5i3 = false;
|
||||
nft2_renderString(font, _displayName, tileBuffer, 32, &renderParams);
|
||||
memcpy((u8*)vram + largeFolderIconTilesLen, tileBuffer, sizeof(tileBuffer));
|
||||
}
|
||||
|
||||
void MaterialFileIcon::Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor)
|
||||
{
|
||||
auto iconColor = GetIconColor();
|
||||
auto nameColor = GetTextColor();
|
||||
|
||||
auto oams = graphicsContext.GetOamManager().AllocOams(2);
|
||||
|
||||
u32 iconPaletteRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
GradientPalette(backgroundColor, iconColor), _position.y, _position.y + 32);
|
||||
OamBuilder::OamWithSize<32, 32>(_position.x, _position.y, _vramOffset >> 7)
|
||||
.WithPalette16(iconPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oams[1]);
|
||||
|
||||
u32 namePaletteRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
GradientPalette(iconColor, nameColor), _position.y, _position.y + 32);
|
||||
OamBuilder::OamWithSize<32, 16>(_position.x, _position.y + GetTextYOffset(), (_vramOffset + largeFolderIconTilesLen) >> 7)
|
||||
.WithPalette16(namePaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oams[0]);
|
||||
}
|
||||
28
arm9/source/romBrowser/Theme/Material/MaterialFileIcon.h
Normal file
28
arm9/source/romBrowser/Theme/Material/MaterialFileIcon.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "../../FileType/FileIcon.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class MaterialFileIcon : public FileIcon
|
||||
{
|
||||
public:
|
||||
MaterialFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository);
|
||||
|
||||
void UploadGraphics(vu16* vram) const override;
|
||||
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
||||
|
||||
protected:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
const IFontRepository* _fontRepository;
|
||||
|
||||
virtual const void* GetIconTiles() const = 0;
|
||||
virtual Rgb<8, 8, 8> GetIconColor() const = 0;
|
||||
virtual Rgb<8, 8, 8> GetTextColor() const = 0;
|
||||
virtual int GetTextYOffset() const = 0;
|
||||
|
||||
private:
|
||||
char16_t _displayName[4];
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
#include "common.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "gui/IVramManager.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "core/math/ColorConverter.h"
|
||||
#include "iconCell.h"
|
||||
#include "gui/palette/GradientPalette.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
#include "themes/IFontRepository.h"
|
||||
#include "MaterialFileInfoCardView.h"
|
||||
|
||||
MaterialFileInfoCardView::MaterialFileInfoCardView(const MaterialColorScheme* materialColorScheme,
|
||||
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))
|
||||
, _materialColorScheme(materialColorScheme)
|
||||
{
|
||||
AddChildTail(&_firstLine);
|
||||
AddChildTail(&_secondLine);
|
||||
AddChildTail(&_thirdLine);
|
||||
_filenameLabelView.SetEllipsis(true);
|
||||
AddChildTail(&_filenameLabelView);
|
||||
}
|
||||
|
||||
void MaterialFileInfoCardView::InitVram(const VramContext& vramContext)
|
||||
{
|
||||
BannerView::InitVram(vramContext);
|
||||
|
||||
const auto objVramManager = vramContext.GetObjVramManager();
|
||||
if (objVramManager)
|
||||
{
|
||||
_iconCellVramOffset = objVramManager->Alloc(iconCellTilesLen);
|
||||
dma_ntrCopy32(3, iconCellTiles, objVramManager->GetVramAddress(_iconCellVramOffset), iconCellTilesLen);
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialFileInfoCardView::Update()
|
||||
{
|
||||
BannerView::Update();
|
||||
_firstLine.SetPosition(_position.x + 70, _position.y + 130 - 8);
|
||||
_secondLine.SetPosition(_position.x + 70, _position.y + 145 - 8);
|
||||
_thirdLine.SetPosition(_position.x + 70, _position.y + 159 - 8);
|
||||
_filenameLabelView.SetPosition(_position.x + 18, _position.y + 168);
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetPosition(_position.x + 24, _position.y + 136 - 8);
|
||||
_icon->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialFileInfoCardView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
_firstLine.SetBackgroundColor(_materialColorScheme->secondaryContainer);
|
||||
_firstLine.SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
_secondLine.SetBackgroundColor(_materialColorScheme->secondaryContainer);
|
||||
_secondLine.SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
_thirdLine.SetBackgroundColor(_materialColorScheme->secondaryContainer);
|
||||
_thirdLine.SetForegroundColor(_materialColorScheme->onSecondaryContainer);
|
||||
_filenameLabelView.SetBackgroundColor(_materialColorScheme->secondaryContainer);
|
||||
_filenameLabelView.SetForegroundColor(_materialColorScheme->onSurfaceVariant);
|
||||
|
||||
BannerView::Draw(graphicsContext);
|
||||
|
||||
const auto& bgColor = _materialColorScheme->secondaryContainer;
|
||||
const auto& fgColor = _materialColorScheme->mainIconBg;
|
||||
u32 iconCellPlttRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
GradientPalette(bgColor, fgColor));
|
||||
|
||||
gfx_oam_entry_t* oam = graphicsContext.GetOamManager().AllocOams(1);
|
||||
OamBuilder::OamWithSize<64, 64>(_position.x + 18, _position.y + 130 - 8, _iconCellVramOffset >> 7)
|
||||
.WithPalette16(iconCellPlttRow)
|
||||
.WithPriority(3)
|
||||
.Build(oam[0]);
|
||||
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetObjVramOffset(_iconVramOffset);
|
||||
_icon->Draw(graphicsContext, fgColor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
#include "core/task/TaskQueue.h"
|
||||
#include "gui/views/Label2DView.h"
|
||||
#include "../../views/BannerView.h"
|
||||
|
||||
class FileIcon;
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class MaterialFileInfoCardView : public BannerView
|
||||
{
|
||||
public:
|
||||
MaterialFileInfoCardView(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository);
|
||||
|
||||
void InitVram(const VramContext& vramContext) override;
|
||||
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;
|
||||
u32 _iconCellVramOffset;
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
};
|
||||
30
arm9/source/romBrowser/Theme/Material/MaterialFolderIcon.h
Normal file
30
arm9/source/romBrowser/Theme/Material/MaterialFolderIcon.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "MaterialFileIcon.h"
|
||||
#include "largeFolderIcon.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
|
||||
class MaterialFolderIcon : public MaterialFileIcon
|
||||
{
|
||||
public:
|
||||
MaterialFolderIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: MaterialFileIcon(name, materialColorScheme, fontRepository) { }
|
||||
|
||||
protected:
|
||||
const void* GetIconTiles() const override
|
||||
{
|
||||
return largeFolderIconTiles;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetIconColor() const override
|
||||
{
|
||||
return _materialColorScheme->tertiaryContainer;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetTextColor() const override
|
||||
{
|
||||
return _materialColorScheme->onTertiaryContainer;
|
||||
}
|
||||
|
||||
int GetTextYOffset() const override { return 10; }
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "MaterialFileIcon.h"
|
||||
#include "largeFileIcon.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
|
||||
class MaterialGenericFileIcon : public MaterialFileIcon
|
||||
{
|
||||
public:
|
||||
MaterialGenericFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: MaterialFileIcon(name, materialColorScheme, fontRepository) { }
|
||||
|
||||
protected:
|
||||
const void* GetIconTiles() const override
|
||||
{
|
||||
return largeFileIconTiles;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetIconColor() const override
|
||||
{
|
||||
return _materialColorScheme->tertiary;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetTextColor() const override
|
||||
{
|
||||
return _materialColorScheme->onTertiary;
|
||||
}
|
||||
|
||||
int GetTextYOffset() const override { return 8; }
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/gfx/gfx.h>
|
||||
#include "gui/PaletteManager.h"
|
||||
#include "gui/OamManager.h"
|
||||
#include "gui/OamBuilder.h"
|
||||
#include "gui/IVramManager.h"
|
||||
#include "gui/VramContext.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "iconCell2.h"
|
||||
#include "iconCell3.h"
|
||||
#include "core/math/ColorConverter.h"
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
#include "gui/palette/DirectPalette.h"
|
||||
#include "MaterialIconGridItemView.h"
|
||||
|
||||
void MaterialIconGridItemView::Draw(GraphicsContext& graphicsContext)
|
||||
{
|
||||
if (!graphicsContext.IsVisible(Rectangle(_position.x - 2, _position.y - 2, 48, 48)))
|
||||
return;
|
||||
|
||||
auto backColor = _materialColorScheme->inverseOnSurface;
|
||||
auto frontColor = _isFocused
|
||||
? _materialColorScheme->mainIconBg
|
||||
: _materialColorScheme->surfaceBright;
|
||||
u16 selectedIconCellPltt[16];
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
auto blendFactors = ColorConverter::FromXBGR555(iconCell3Pal[i]);
|
||||
auto palColor = Rgb<8, 8, 8>(
|
||||
(backColor.r * blendFactors.r + frontColor.r * blendFactors.g + 16) / 31,
|
||||
(backColor.g * blendFactors.r + frontColor.g * blendFactors.g + 16) / 31,
|
||||
(backColor.b * blendFactors.r + frontColor.b * blendFactors.g + 16) / 31);
|
||||
palColor = palColor.Clamped();
|
||||
selectedIconCellPltt[i] = ColorConverter::ToGBGR565(palColor);
|
||||
}
|
||||
u32 cellPaletteRow = graphicsContext.GetPaletteManager().AllocRow(
|
||||
DirectPalette(selectedIconCellPltt), _position.y - 2, _position.y - 2 + 48);
|
||||
|
||||
gfx_oam_entry_t* oam = graphicsContext.GetOamManager().AllocOams(1);
|
||||
OamBuilder::OamWithSize<64, 64>(
|
||||
_position.x - 2,
|
||||
_position.y - 2, _bgVramOffset >> 7)
|
||||
.WithPalette16(cellPaletteRow)
|
||||
.WithPriority(graphicsContext.GetPriority())
|
||||
.Build(oam[0]);
|
||||
|
||||
if (_icon)
|
||||
{
|
||||
_icon->SetObjVramOffset(_iconVramOffset);
|
||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||
_icon->Draw(graphicsContext, frontColor);
|
||||
}
|
||||
}
|
||||
|
||||
MaterialIconGridItemView::VramToken MaterialIconGridItemView::UploadGraphics(const VramContext& vramContext)
|
||||
{
|
||||
const auto objVramManager = vramContext.GetObjVramManager();
|
||||
u32 vramOffset = 0;
|
||||
if (objVramManager)
|
||||
{
|
||||
vramOffset = objVramManager->Alloc(iconCell3TilesLen);
|
||||
dma_ntrCopy32(3, iconCell3Tiles, objVramManager->GetVramAddress(vramOffset), iconCell3TilesLen);
|
||||
}
|
||||
|
||||
return MaterialIconGridItemView::VramToken(vramOffset);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "../../views/IconGridItemView.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
|
||||
class MaterialIconGridItemView : public IconGridItemView
|
||||
{
|
||||
public:
|
||||
explicit MaterialIconGridItemView(const MaterialColorScheme* materialColorScheme)
|
||||
: _materialColorScheme(materialColorScheme) { }
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
|
||||
Rectangle GetBounds() const override
|
||||
{
|
||||
return Rectangle(_position, 44, 44);
|
||||
}
|
||||
|
||||
void SetGraphics(const VramToken& vramToken) override
|
||||
{
|
||||
_bgVramOffset = vramToken.GetVramOffset();
|
||||
}
|
||||
|
||||
static VramToken UploadGraphics(const VramContext& vramContext);
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
u32 _bgVramOffset;
|
||||
};
|
||||
30
arm9/source/romBrowser/Theme/Material/MaterialNdsFileIcon.h
Normal file
30
arm9/source/romBrowser/Theme/Material/MaterialNdsFileIcon.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include "MaterialFileIcon.h"
|
||||
#include "largeDSCardIcon.h"
|
||||
#include "themes/material/MaterialColorScheme.h"
|
||||
|
||||
class MaterialNdsFileIcon : public MaterialFileIcon
|
||||
{
|
||||
public:
|
||||
MaterialNdsFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: MaterialFileIcon(name, materialColorScheme, fontRepository) { }
|
||||
|
||||
protected:
|
||||
const void* GetIconTiles() const override
|
||||
{
|
||||
return largeDSCardIconTiles;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetIconColor() const override
|
||||
{
|
||||
return _materialColorScheme->tertiary;
|
||||
}
|
||||
|
||||
Rgb<8, 8, 8> GetTextColor() const override
|
||||
{
|
||||
return _materialColorScheme->onTertiary;
|
||||
}
|
||||
|
||||
int GetTextYOffset() const override { return 3; }
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
#include "MaterialIconGridItemView.h"
|
||||
#include "MaterialBannerListItemView.h"
|
||||
#include "MaterialFileInfoCardView.h"
|
||||
#include "../IRomBrowserViewFactory.h"
|
||||
#include "romBrowser/viewModels/RomBrowserViewModel.h"
|
||||
#include "CarouselRecyclerView.h"
|
||||
#include "MaterialCoverFlowFileRecyclerAdapter.h"
|
||||
#include "MaterialAppBarView.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class MaterialRomBrowserViewFactory : public IRomBrowserViewFactory
|
||||
{
|
||||
public:
|
||||
MaterialRomBrowserViewFactory(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: _materialColorScheme(materialColorScheme), _fontRepository(fontRepository) { }
|
||||
|
||||
IconGridItemView* CreateIconGridItemView() const override
|
||||
{
|
||||
return new MaterialIconGridItemView(_materialColorScheme);
|
||||
}
|
||||
|
||||
IconGridItemView::VramToken UploadIconGridItemViewGraphics(
|
||||
const VramContext& vramContext) const override
|
||||
{
|
||||
return MaterialIconGridItemView::UploadGraphics(vramContext);
|
||||
}
|
||||
|
||||
BannerListItemView* CreateBannerListItemView(VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return new MaterialBannerListItemView(_materialColorScheme, _fontRepository);
|
||||
}
|
||||
|
||||
BannerListItemView::VramToken UploadBannerListItemViewGraphics(
|
||||
const VramContext& vramContext) const override
|
||||
{
|
||||
return MaterialBannerListItemView::UploadGraphics(vramContext);
|
||||
}
|
||||
|
||||
std::unique_ptr<AppBarView> CreateAppBarView(int x, int y, AppBarView::Orientation orientation,
|
||||
int startButtonCount, int endButtonCount) const override
|
||||
{
|
||||
return std::make_unique<MaterialAppBarView>(x, y, orientation, startButtonCount, endButtonCount, _materialColorScheme);
|
||||
}
|
||||
|
||||
std::unique_ptr<BannerView> CreateFileInfoView() const override
|
||||
{
|
||||
return std::make_unique<MaterialFileInfoCardView>(_materialColorScheme, _fontRepository);
|
||||
}
|
||||
|
||||
std::unique_ptr<RecyclerViewBase> CreateCoverFlowRecyclerView() const override
|
||||
{
|
||||
return std::make_unique<CarouselRecyclerView>(_materialColorScheme);
|
||||
}
|
||||
|
||||
FileRecyclerAdapter* CreateCoverFlowRecyclerAdapter(
|
||||
RomBrowserViewModel* viewModel, const IThemeFileIconFactory* themeFileIconFactory,
|
||||
VBlankTextureLoader* vblankTextureLoader) const override
|
||||
{
|
||||
return new MaterialCoverFlowFileRecyclerAdapter(
|
||||
&viewModel->GetFileInfoManager(), viewModel->GetIoTaskQueue(),
|
||||
themeFileIconFactory, this, vblankTextureLoader, &viewModel->GetCoverRepository());
|
||||
}
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
const IFontRepository* _fontRepository;
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "../IThemeFileIconFactory.h"
|
||||
#include "MaterialFolderIcon.h"
|
||||
#include "MaterialGenericFileIcon.h"
|
||||
#include "MaterialNdsFileIcon.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
class IFontRepository;
|
||||
|
||||
class MaterialThemeFileIconFactory : public IThemeFileIconFactory
|
||||
{
|
||||
public:
|
||||
explicit MaterialThemeFileIconFactory(const MaterialColorScheme* materialColorScheme,
|
||||
const IFontRepository* fontRepository)
|
||||
: _materialColorScheme(materialColorScheme), _fontRepository(fontRepository) { }
|
||||
|
||||
std::unique_ptr<FileIcon> CreateFolderIcon(const TCHAR* name) const override
|
||||
{
|
||||
return std::make_unique<MaterialFolderIcon>(name, _materialColorScheme, _fontRepository);
|
||||
}
|
||||
|
||||
std::unique_ptr<FileIcon> CreateGenericFileIcon(const TCHAR* name) const override
|
||||
{
|
||||
return std::make_unique<MaterialGenericFileIcon>(name, _materialColorScheme, _fontRepository);
|
||||
}
|
||||
|
||||
std::unique_ptr<FileIcon> CreateNdsFileIcon(const TCHAR* name) const override
|
||||
{
|
||||
return std::make_unique<MaterialNdsFileIcon>(name, _materialColorScheme, _fontRepository);
|
||||
}
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
const IFontRepository* _fontRepository;
|
||||
};
|
||||
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