mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 09:06:54 +02:00
Add various extra customization options for custom themes. Fixes #40
This commit is contained in:
15
arm9/source/themes/custom/CustomBannerListTextElementInfo.h
Normal file
15
arm9/source/themes/custom/CustomBannerListTextElementInfo.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "core/math/Point.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
class CustomBannerListTextElementInfo
|
||||
{
|
||||
public:
|
||||
CustomBannerListTextElementInfo(const Rgb8& textColor)
|
||||
: _textColor(textColor) { }
|
||||
|
||||
const Rgb8& GetTextColor() const { return _textColor; }
|
||||
|
||||
private:
|
||||
Rgb8 _textColor;
|
||||
};
|
||||
15
arm9/source/themes/custom/CustomBottomIconInfo.h
Normal file
15
arm9/source/themes/custom/CustomBottomIconInfo.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "core/math/Point.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
class CustomBottomIconInfo
|
||||
{
|
||||
public:
|
||||
CustomBottomIconInfo(const Rgb8& blendColor)
|
||||
: _blendColor(blendColor) { }
|
||||
|
||||
const Rgb8& GetBlendColor() const { return _blendColor; }
|
||||
|
||||
private:
|
||||
Rgb8 _blendColor;
|
||||
};
|
||||
21
arm9/source/themes/custom/CustomTextElementInfo.h
Normal file
21
arm9/source/themes/custom/CustomTextElementInfo.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "core/math/Point.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
class CustomTopTextElementInfo
|
||||
{
|
||||
public:
|
||||
CustomTopTextElementInfo(const Point& position, u32 width, const Rgb8& textColor, const Rgb8& blendColor)
|
||||
: _position(position), _width(width), _textColor(textColor), _blendColor(blendColor) { }
|
||||
|
||||
const Point& GetPosition() const { return _position; }
|
||||
const u32 GetWidth() const { return _width; }
|
||||
const Rgb8& GetTextColor() const { return _textColor; }
|
||||
const Rgb8& GetBlendColor() const { return _blendColor; }
|
||||
|
||||
private:
|
||||
Point _position;
|
||||
u32 _width;
|
||||
Rgb8 _textColor;
|
||||
Rgb8 _blendColor;
|
||||
};
|
||||
@@ -11,13 +11,164 @@
|
||||
#include "romBrowser/views/IconButton3DView.h"
|
||||
#include "CustomTheme.h"
|
||||
|
||||
#define JSON_RESERVED_SIZE 2048
|
||||
#define JSON_RESERVED_SIZE 4096
|
||||
|
||||
#define KEY_COLOR_R "r"
|
||||
#define KEY_COLOR_G "g"
|
||||
#define KEY_COLOR_B "b"
|
||||
|
||||
#define KEY_POINT_X "x"
|
||||
#define KEY_POINT_Y "y"
|
||||
|
||||
#define KEY_TOP_ICON "topIcon"
|
||||
#define KEY_TOP_BANNER_TEXT_LINE_0 "topBannerTextLine0"
|
||||
#define KEY_TOP_BANNER_TEXT_LINE_1 "topBannerTextLine1"
|
||||
#define KEY_TOP_BANNER_TEXT_LINE_2 "topBannerTextLine2"
|
||||
#define KEY_TOP_FILE_NAME_TEXT "topFileNameText"
|
||||
#define KEY_GRID_ICON "gridIcon"
|
||||
#define KEY_BANNER_LIST_ICON "bannerListIcon"
|
||||
#define KEY_BANNER_LIST_TEXT_LINE_0 "bannerListTextLine0"
|
||||
#define KEY_BANNER_LIST_TEXT_LINE_1 "bannerListTextLine1"
|
||||
#define KEY_BANNER_LIST_TEXT_LINE_2 "bannerListTextLine2"
|
||||
|
||||
#define KEY_ELEMENT_POSITION "position"
|
||||
#define KEY_ELEMENT_WIDTH "width"
|
||||
#define KEY_ELEMENT_TEXT_COLOR "textColor"
|
||||
#define KEY_ELEMENT_BLEND_COLOR "blendColor"
|
||||
|
||||
static const CustomThemeInfo sDefaultCustomThemeInfo
|
||||
{
|
||||
.topIconInfo = CustomTopIconInfo(Point(24, 132), Rgb8(200, 200, 200)),
|
||||
.topBannerTextLine0Info = CustomTopTextElementInfo(Point(70, 126), 176, Rgb8(30, 30, 30), Rgb8(200, 200, 200)),
|
||||
.topBannerTextLine1Info = CustomTopTextElementInfo(Point(70, 141), 176, Rgb8(30, 30, 30), Rgb8(200, 200, 200)),
|
||||
.topBannerTextLine2Info = CustomTopTextElementInfo(Point(70, 155), 176, Rgb8(30, 30, 30), Rgb8(200, 200, 200)),
|
||||
.topFileNameTextInfo = CustomTopTextElementInfo(Point(18, 170), 220, Rgb8(30, 30, 30), Rgb8(200, 200, 200)),
|
||||
|
||||
.gridIconInfo = CustomBottomIconInfo(Rgb8(200, 200, 200)),
|
||||
|
||||
.bannerListIconInfo = CustomBottomIconInfo(Rgb8(200, 200, 200)),
|
||||
.bannerListTextLine0Info = CustomBannerListTextElementInfo(Rgb8(30, 30, 30)),
|
||||
.bannerListTextLine1Info = CustomBannerListTextElementInfo(Rgb8(30, 30, 30)),
|
||||
.bannerListTextLine2Info = CustomBannerListTextElementInfo(Rgb8(30, 30, 30))
|
||||
};
|
||||
|
||||
static CustomTopBackgroundType parseTopBackgroundType(const char* topBackgroundTypeString)
|
||||
{
|
||||
return CustomTopBackgroundType::Bitmap;
|
||||
}
|
||||
|
||||
static Rgb8 parseColor(const JsonObjectConst& json, const Rgb8& defaultColor)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultColor;
|
||||
}
|
||||
|
||||
return Rgb8(
|
||||
json[KEY_COLOR_R] | 0,
|
||||
json[KEY_COLOR_G] | 0,
|
||||
json[KEY_COLOR_B] | 0
|
||||
);
|
||||
}
|
||||
|
||||
static Point parsePoint(const JsonObjectConst& json, const Point& defaultPoint)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultPoint;
|
||||
}
|
||||
|
||||
return Point(
|
||||
json[KEY_POINT_X] | 0,
|
||||
json[KEY_POINT_Y] | 0
|
||||
);
|
||||
}
|
||||
|
||||
static CustomBannerListTextElementInfo parseCustomBannerListTextElementInfo(
|
||||
const JsonObjectConst& json, const CustomBannerListTextElementInfo& defaultInfo)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultInfo;
|
||||
}
|
||||
|
||||
return CustomBannerListTextElementInfo(
|
||||
parseColor(json[KEY_ELEMENT_TEXT_COLOR], defaultInfo.GetTextColor())
|
||||
);
|
||||
}
|
||||
|
||||
static CustomBottomIconInfo parseCustomBottomIconInfo(const JsonObjectConst& json, const CustomBottomIconInfo& defaultInfo)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultInfo;
|
||||
}
|
||||
|
||||
return CustomBottomIconInfo(
|
||||
parseColor(json[KEY_ELEMENT_BLEND_COLOR], defaultInfo.GetBlendColor())
|
||||
);
|
||||
}
|
||||
|
||||
static CustomTopIconInfo parseCustomTopIconInfo(const JsonObjectConst& json, const CustomTopIconInfo& defaultInfo)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultInfo;
|
||||
}
|
||||
|
||||
return CustomTopIconInfo(
|
||||
parsePoint(json[KEY_ELEMENT_POSITION], defaultInfo.GetPosition()),
|
||||
parseColor(json[KEY_ELEMENT_BLEND_COLOR], defaultInfo.GetBlendColor())
|
||||
);
|
||||
}
|
||||
|
||||
static CustomTopTextElementInfo parseCustomTextElementInfo(
|
||||
const JsonObjectConst& json, const CustomTopTextElementInfo& defaultInfo)
|
||||
{
|
||||
if (json.isNull())
|
||||
{
|
||||
return defaultInfo;
|
||||
}
|
||||
|
||||
return CustomTopTextElementInfo(
|
||||
parsePoint(json[KEY_ELEMENT_POSITION], defaultInfo.GetPosition()),
|
||||
json[KEY_ELEMENT_WIDTH] | defaultInfo.GetWidth(),
|
||||
parseColor(json[KEY_ELEMENT_TEXT_COLOR], defaultInfo.GetTextColor()),
|
||||
parseColor(json[KEY_ELEMENT_BLEND_COLOR], defaultInfo.GetBlendColor())
|
||||
);
|
||||
}
|
||||
|
||||
static CustomThemeInfo parseCustomThemeInfo(const JsonDocument& json)
|
||||
{
|
||||
return CustomThemeInfo
|
||||
{
|
||||
.topIconInfo = parseCustomTopIconInfo(json[KEY_TOP_ICON], sDefaultCustomThemeInfo.topIconInfo),
|
||||
.topBannerTextLine0Info = parseCustomTextElementInfo(
|
||||
json[KEY_TOP_BANNER_TEXT_LINE_0], sDefaultCustomThemeInfo.topBannerTextLine0Info),
|
||||
.topBannerTextLine1Info = parseCustomTextElementInfo(
|
||||
json[KEY_TOP_BANNER_TEXT_LINE_1], sDefaultCustomThemeInfo.topBannerTextLine1Info),
|
||||
.topBannerTextLine2Info = parseCustomTextElementInfo(
|
||||
json[KEY_TOP_BANNER_TEXT_LINE_2], sDefaultCustomThemeInfo.topBannerTextLine2Info),
|
||||
.topFileNameTextInfo = parseCustomTextElementInfo(
|
||||
json[KEY_TOP_FILE_NAME_TEXT], sDefaultCustomThemeInfo.topFileNameTextInfo),
|
||||
|
||||
.gridIconInfo = parseCustomBottomIconInfo(json[KEY_GRID_ICON], sDefaultCustomThemeInfo.gridIconInfo),
|
||||
|
||||
.bannerListIconInfo = parseCustomBottomIconInfo(json[KEY_BANNER_LIST_ICON], sDefaultCustomThemeInfo.bannerListIconInfo),
|
||||
.bannerListTextLine0Info = parseCustomBannerListTextElementInfo(
|
||||
json[KEY_BANNER_LIST_TEXT_LINE_0], sDefaultCustomThemeInfo.bannerListTextLine0Info),
|
||||
.bannerListTextLine1Info = parseCustomBannerListTextElementInfo(
|
||||
json[KEY_BANNER_LIST_TEXT_LINE_1], sDefaultCustomThemeInfo.bannerListTextLine1Info),
|
||||
.bannerListTextLine2Info = parseCustomBannerListTextElementInfo(
|
||||
json[KEY_BANNER_LIST_TEXT_LINE_2], sDefaultCustomThemeInfo.bannerListTextLine2Info)
|
||||
};
|
||||
}
|
||||
|
||||
CustomTheme::CustomTheme(const TCHAR* folderName, const Rgb<8, 8, 8>& primaryColor, bool darkMode)
|
||||
: Theme(folderName, primaryColor, darkMode)
|
||||
, _customThemeInfo(sDefaultCustomThemeInfo)
|
||||
, _romBrowserViewFactory(&_customThemeInfo, &_materialColorScheme, &_fontRepository) { }
|
||||
|
||||
void CustomTheme::LoadRomBrowserResources(const VramContext& mainVramContext, const VramContext& subVramContext)
|
||||
{
|
||||
const auto file = std::make_unique<File>();
|
||||
@@ -39,6 +190,7 @@ void CustomTheme::LoadRomBrowserResources(const VramContext& mainVramContext, co
|
||||
return;
|
||||
|
||||
_topBackgroundType = parseTopBackgroundType(json["topBackgroundType"].as<const char*>());
|
||||
_customThemeInfo = parseCustomThemeInfo(json);
|
||||
|
||||
mem_setVramDMapping(MEM_VRAM_D_LCDC);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
|
||||
@@ -7,19 +7,13 @@
|
||||
#include "romBrowser/Theme/custom/CustomRomBrowserViewFactory.h"
|
||||
#include "CustomTopBackgroundType.h"
|
||||
#include "../DefaultFontRepository.h"
|
||||
#include "CustomThemeInfo.h"
|
||||
#include "../Theme.h"
|
||||
|
||||
class CustomTheme : public Theme
|
||||
{
|
||||
String<TCHAR, 64> _folderName;
|
||||
CustomRomBrowserViewFactory _romBrowserViewFactory;
|
||||
CustomTopBackgroundType _topBackgroundType;
|
||||
DefaultFontRepository _fontRepository;
|
||||
|
||||
public:
|
||||
CustomTheme(const TCHAR* folderName, const Rgb<8, 8, 8>& primaryColor, bool darkMode)
|
||||
: Theme(folderName, primaryColor, darkMode)
|
||||
, _romBrowserViewFactory(&_materialColorScheme, &_fontRepository) { }
|
||||
CustomTheme(const TCHAR* folderName, const Rgb<8, 8, 8>& primaryColor, bool darkMode);
|
||||
|
||||
const IFontRepository* GetFontRepository() const override
|
||||
{
|
||||
@@ -47,4 +41,11 @@ public:
|
||||
}
|
||||
|
||||
void LoadRomBrowserResources(const VramContext& mainVramContext, const VramContext& subVramContext) override;
|
||||
|
||||
private:
|
||||
String<TCHAR, 64> _folderName;
|
||||
CustomThemeInfo _customThemeInfo;
|
||||
CustomRomBrowserViewFactory _romBrowserViewFactory;
|
||||
CustomTopBackgroundType _topBackgroundType;
|
||||
DefaultFontRepository _fontRepository;
|
||||
};
|
||||
|
||||
21
arm9/source/themes/custom/CustomThemeInfo.h
Normal file
21
arm9/source/themes/custom/CustomThemeInfo.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "CustomBannerListTextElementInfo.h"
|
||||
#include "CustomBottomIconInfo.h"
|
||||
#include "CustomTopIconInfo.h"
|
||||
#include "CustomTextElementInfo.h"
|
||||
|
||||
struct CustomThemeInfo
|
||||
{
|
||||
CustomTopIconInfo topIconInfo;
|
||||
CustomTopTextElementInfo topBannerTextLine0Info;
|
||||
CustomTopTextElementInfo topBannerTextLine1Info;
|
||||
CustomTopTextElementInfo topBannerTextLine2Info;
|
||||
CustomTopTextElementInfo topFileNameTextInfo;
|
||||
|
||||
CustomBottomIconInfo gridIconInfo;
|
||||
|
||||
CustomBottomIconInfo bannerListIconInfo;
|
||||
CustomBannerListTextElementInfo bannerListTextLine0Info;
|
||||
CustomBannerListTextElementInfo bannerListTextLine1Info;
|
||||
CustomBannerListTextElementInfo bannerListTextLine2Info;
|
||||
};
|
||||
17
arm9/source/themes/custom/CustomTopIconInfo.h
Normal file
17
arm9/source/themes/custom/CustomTopIconInfo.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "core/math/Point.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
class CustomTopIconInfo
|
||||
{
|
||||
public:
|
||||
CustomTopIconInfo(const Point& position, const Rgb8& blendColor)
|
||||
: _position(position), _blendColor(blendColor) { }
|
||||
|
||||
const Point& GetPosition() const { return _position; }
|
||||
const Rgb8& GetBlendColor() const { return _blendColor; }
|
||||
|
||||
private:
|
||||
Point _position;
|
||||
Rgb8 _blendColor;
|
||||
};
|
||||
Reference in New Issue
Block a user