mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Avoid having a single frame where the icon was not displayed on the top screen after selecting a different rom
This commit is contained in:
@@ -13,9 +13,17 @@ class FileIcon
|
|||||||
public:
|
public:
|
||||||
virtual ~FileIcon() = 0;
|
virtual ~FileIcon() = 0;
|
||||||
|
|
||||||
/// @brief Uploads the graphics of this icon to the specified \p vram address.
|
/// @brief Sets the OBJ vram address and offset to use.
|
||||||
/// @param vram The vram address to load the graphics to.
|
/// @param objVramAddress The OBJ vram address to use.
|
||||||
virtual void UploadGraphics(vu16* vram) = 0;
|
/// @param objVramOffset The OBJ vram offset to use.
|
||||||
|
virtual void SetVramAddress(vu16* objVramAddress, u32 objVramOffset)
|
||||||
|
{
|
||||||
|
_vramAddress = objVramAddress;
|
||||||
|
_vramOffset = objVramOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Uploads the graphics of this icon to the vram address specified by SetVramAddress.
|
||||||
|
virtual void UploadGraphics() = 0;
|
||||||
|
|
||||||
/// @brief Updates this icon.
|
/// @brief Updates this icon.
|
||||||
virtual void Update() { }
|
virtual void Update() { }
|
||||||
@@ -25,10 +33,6 @@ public:
|
|||||||
/// @param backgroundColor The color on which the icon is drawn.
|
/// @param backgroundColor The color on which the icon is drawn.
|
||||||
virtual void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) = 0;
|
virtual void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) = 0;
|
||||||
|
|
||||||
/// @brief Sets the OBJ vram offset of this icon.
|
|
||||||
/// @param offset The OBJ vram offset.
|
|
||||||
void SetObjVramOffset(u32 offset) { _vramOffset = offset; }
|
|
||||||
|
|
||||||
/// @brief Sets the icon animation frame.
|
/// @brief Sets the icon animation frame.
|
||||||
/// @param frame The animation frame.
|
/// @param frame The animation frame.
|
||||||
void SetAnimFrame(u32 frame)
|
void SetAnimFrame(u32 frame)
|
||||||
@@ -50,6 +54,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
vu16* _vramAddress = nullptr;
|
||||||
u32 _vramOffset = 0;
|
u32 _vramOffset = 0;
|
||||||
u32 _frame = 0;
|
u32 _frame = 0;
|
||||||
Point _position;
|
Point _position;
|
||||||
|
|||||||
@@ -38,14 +38,18 @@ NdsFileIcon::NdsFileIcon(const nds_banner_t* banner)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NdsFileIcon::UploadGraphics(vu16* vram)
|
void NdsFileIcon::SetVramAddress(vu16* objVramAddress, u32 objVramOffset)
|
||||||
{
|
{
|
||||||
_vramAddress = vram;
|
FileIcon::SetVramAddress(objVramAddress, objVramOffset);
|
||||||
_currentVramSlot = 0;
|
_currentVramSlot = 0;
|
||||||
_currentGfxIdx = -1;
|
_currentGfxIdx = -1;
|
||||||
if (!_animated)
|
}
|
||||||
|
|
||||||
|
void NdsFileIcon::UploadGraphics()
|
||||||
{
|
{
|
||||||
dma_ntrCopy32(3, _banner->iconGfx, vram, sizeof(_banner->iconGfx));
|
if (_vramAddress != nullptr && !_animated)
|
||||||
|
{
|
||||||
|
dma_ntrCopy32(3, _banner->iconGfx, _vramAddress, sizeof(_banner->iconGfx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ class NdsFileIcon : public FileIcon
|
|||||||
public:
|
public:
|
||||||
explicit NdsFileIcon(const nds_banner_t* banner);
|
explicit NdsFileIcon(const nds_banner_t* banner);
|
||||||
|
|
||||||
void UploadGraphics(vu16* vram) override;
|
void SetVramAddress(vu16* objVramAddress, u32 objVramOffset) override;
|
||||||
|
void UploadGraphics() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
||||||
|
|
||||||
@@ -16,13 +17,11 @@ private:
|
|||||||
const nds_banner_t* _banner;
|
const nds_banner_t* _banner;
|
||||||
bool _animated;
|
bool _animated;
|
||||||
int _animTokenIdx;
|
int _animTokenIdx;
|
||||||
// int _durationCounter;
|
|
||||||
u32 _lastAnimToken;
|
u32 _lastAnimToken;
|
||||||
u32 _animLength;
|
u32 _animLength;
|
||||||
u16 _tokenStartTimes[65];
|
u16 _tokenStartTimes[65];
|
||||||
bool _loop;
|
bool _loop;
|
||||||
|
|
||||||
vu16* _vramAddress = nullptr;
|
|
||||||
int _currentVramSlot = 0;
|
int _currentVramSlot = 0;
|
||||||
int _currentGfxIdx = -1;
|
int _currentGfxIdx = -1;
|
||||||
};
|
};
|
||||||
@@ -7,9 +7,12 @@
|
|||||||
#include "gui/palette/DirectPalette.h"
|
#include "gui/palette/DirectPalette.h"
|
||||||
#include "StaticIcon.h"
|
#include "StaticIcon.h"
|
||||||
|
|
||||||
void StaticIcon::UploadGraphics(vu16* vram)
|
void StaticIcon::UploadGraphics()
|
||||||
{
|
{
|
||||||
dma_ntrCopy32(3, _tileData, vram, 512);
|
if (_vramAddress != nullptr)
|
||||||
|
{
|
||||||
|
dma_ntrCopy32(3, _tileData, _vramAddress, 512);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StaticIcon::Update()
|
void StaticIcon::Update()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public:
|
|||||||
StaticIcon(const u8* tileData, const u16* paletteData)
|
StaticIcon(const u8* tileData, const u16* paletteData)
|
||||||
: _tileData(tileData), _paletteData(paletteData) { }
|
: _tileData(tileData), _paletteData(paletteData) { }
|
||||||
|
|
||||||
void UploadGraphics(vu16* vram) override;
|
void UploadGraphics() override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ void MaterialBannerListItemView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||||
_icon->Draw(graphicsContext, frontColor);
|
_icon->Draw(graphicsContext, frontColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ MaterialFileIcon::MaterialFileIcon(const TCHAR* name, const MaterialColorScheme*
|
|||||||
_displayName[i] = 0;
|
_displayName[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialFileIcon::UploadGraphics(vu16* vram)
|
void MaterialFileIcon::UploadGraphics()
|
||||||
{
|
{
|
||||||
dma_ntrCopy32(3, GetIconTiles(), vram, 32 * 32 / 2);
|
if (_vramAddress != nullptr)
|
||||||
|
{
|
||||||
|
dma_ntrCopy32(3, GetIconTiles(), _vramAddress, 32 * 32 / 2);
|
||||||
|
|
||||||
auto font = _fontRepository->GetFont(FontType::Medium11);
|
auto font = _fontRepository->GetFont(FontType::Medium11);
|
||||||
u8 tileBuffer[32 * 16 / 2];
|
u8 tileBuffer[32 * 16 / 2];
|
||||||
@@ -40,7 +42,8 @@ void MaterialFileIcon::UploadGraphics(vu16* vram)
|
|||||||
renderParams.height = 16;
|
renderParams.height = 16;
|
||||||
renderParams.a5i3 = false;
|
renderParams.a5i3 = false;
|
||||||
nft2_renderString(font, _displayName, tileBuffer, 32, &renderParams);
|
nft2_renderString(font, _displayName, tileBuffer, 32, &renderParams);
|
||||||
memcpy((u8*)vram + largeFolderIconTilesLen, tileBuffer, sizeof(tileBuffer));
|
memcpy((u8*)_vramAddress + largeFolderIconTilesLen, tileBuffer, sizeof(tileBuffer));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaterialFileIcon::Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor)
|
void MaterialFileIcon::Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public:
|
|||||||
MaterialFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
MaterialFileIcon(const TCHAR* name, const MaterialColorScheme* materialColorScheme,
|
||||||
const IFontRepository* fontRepository);
|
const IFontRepository* fontRepository);
|
||||||
|
|
||||||
void UploadGraphics(vu16* vram) override;
|
void UploadGraphics() override;
|
||||||
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
void Draw(GraphicsContext& graphicsContext, const Rgb<8, 8, 8>& backgroundColor) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ void MaterialFileInfoCardView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->Draw(graphicsContext, fgColor);
|
_icon->Draw(graphicsContext, fgColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ void MaterialIconGridItemView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||||
_icon->Draw(graphicsContext, frontColor);
|
_icon->Draw(graphicsContext, frontColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ void CustomBannerListItemView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||||
_icon->Draw(graphicsContext, backgroundColor);
|
_icon->Draw(graphicsContext, backgroundColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ void CustomFileInfoView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->Draw(graphicsContext, _backgroundColor);
|
_icon->Draw(graphicsContext, _backgroundColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ void CustomIconGridItemView::Draw(GraphicsContext& graphicsContext)
|
|||||||
|
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->SetObjVramOffset(_iconVramOffset);
|
|
||||||
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
_icon->SetPosition(6 + _position.x, 6 + _position.y);
|
||||||
_icon->Draw(graphicsContext, Rgb<8, 8, 8>(200, 200, 200));
|
_icon->Draw(graphicsContext, Rgb<8, 8, 8>(200, 200, 200));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,17 @@ public:
|
|||||||
void SetIcon(std::unique_ptr<FileIcon> icon)
|
void SetIcon(std::unique_ptr<FileIcon> icon)
|
||||||
{
|
{
|
||||||
_icon = std::move(icon);
|
_icon = std::move(icon);
|
||||||
|
if (_icon)
|
||||||
|
{
|
||||||
|
_icon->SetVramAddress(_iconVram, _iconVramOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadIconGraphics() const
|
void UploadIconGraphics() const
|
||||||
{
|
{
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->UploadGraphics(_iconVram);
|
_icon->UploadGraphics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,17 @@ public:
|
|||||||
void SetIcon(std::unique_ptr<FileIcon> icon)
|
void SetIcon(std::unique_ptr<FileIcon> icon)
|
||||||
{
|
{
|
||||||
_icon = std::move(icon);
|
_icon = std::move(icon);
|
||||||
|
if (_icon)
|
||||||
|
{
|
||||||
|
_icon->SetVramAddress(_iconVram, _iconVramOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UploadIconGraphics() const
|
void UploadIconGraphics() const
|
||||||
{
|
{
|
||||||
if (_icon)
|
if (_icon)
|
||||||
{
|
{
|
||||||
_icon->UploadGraphics(_iconVram);
|
_icon->UploadGraphics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user