mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-06-02 17:16:57 +02:00
Initial commit
This commit is contained in:
56
arm9/source/themes/material/MaterialColorScheme.h
Normal file
56
arm9/source/themes/material/MaterialColorScheme.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
#include "gui/materialDesign.h"
|
||||
#include "core/math/Rgb.h"
|
||||
|
||||
struct MaterialColorScheme
|
||||
{
|
||||
using Rgb888 = Rgb<8, 8, 8>;
|
||||
|
||||
Rgb888 primary;
|
||||
Rgb888 onPrimary;
|
||||
Rgb888 secondaryContainer;
|
||||
Rgb888 onSecondaryContainer;
|
||||
Rgb888 tertiary;
|
||||
Rgb888 onTertiary;
|
||||
Rgb888 tertiaryContainer;
|
||||
Rgb888 onTertiaryContainer;
|
||||
Rgb888 surfaceBright;
|
||||
Rgb888 inverseOnSurface;
|
||||
Rgb888 onSurface;
|
||||
Rgb888 onSurfaceVariant;
|
||||
Rgb888 mainIconBg;
|
||||
// Rgb888 surfaceContainerLow;
|
||||
Rgb888 surfaceContainerHighest;
|
||||
Rgb888 scrim;
|
||||
Rgb888 outline;
|
||||
|
||||
constexpr const Rgb888& GetColor(md::sys::color color) const
|
||||
{
|
||||
switch (color)
|
||||
{
|
||||
case md::sys::color::primary:
|
||||
return primary;
|
||||
case md::sys::color::onPrimary:
|
||||
return onPrimary;
|
||||
case md::sys::color::inverseOnSurface:
|
||||
return inverseOnSurface;
|
||||
case md::sys::color::onSurface:
|
||||
return onSurface;
|
||||
case md::sys::color::onSurfaceVariant:
|
||||
return onSurfaceVariant;
|
||||
case md::sys::color::outline:
|
||||
return outline;
|
||||
case md::sys::color::secondaryContainer:
|
||||
return secondaryContainer;
|
||||
case md::sys::color::onSecondaryContainer:
|
||||
return onSecondaryContainer;
|
||||
case md::sys::color::surfaceBright:
|
||||
return surfaceBright;
|
||||
case md::sys::color::surfaceContainerHighest:
|
||||
return surfaceContainerHighest;
|
||||
|
||||
default:
|
||||
return inverseOnSurface;
|
||||
}
|
||||
}
|
||||
};
|
||||
47
arm9/source/themes/material/MaterialColorSchemeFactory.cpp
Normal file
47
arm9/source/themes/material/MaterialColorSchemeFactory.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "common.h"
|
||||
#include <algorithm>
|
||||
#include "material/scheme/scheme.h"
|
||||
#include "MaterialColorSchemeFactory.h"
|
||||
|
||||
using Rgb888 = Rgb<8, 8, 8>;
|
||||
|
||||
static material_color_utilities::Argb Rgb888ToMaterialArgb(const Rgb888& color)
|
||||
{
|
||||
return material_color_utilities::ArgbFromRgb(color.r, color.g, color.b);
|
||||
}
|
||||
|
||||
static Rgb888 MaterialArgbToRgb888(material_color_utilities::Argb color)
|
||||
{
|
||||
return Rgb888(
|
||||
material_color_utilities::RedFromInt(color),
|
||||
material_color_utilities::GreenFromInt(color),
|
||||
material_color_utilities::BlueFromInt(color));
|
||||
}
|
||||
|
||||
void MaterialColorSchemeFactory::FromPrimaryColor(const Rgb<8, 8, 8>& primaryColor,
|
||||
bool darkTheme, MaterialColorScheme& materialColorScheme)
|
||||
{
|
||||
auto materialPrimaryColor = Rgb888ToMaterialArgb(primaryColor);
|
||||
auto corePalette = material_color_utilities::CorePalette::Of(materialPrimaryColor);
|
||||
auto scheme = darkTheme
|
||||
? material_color_utilities::MaterialDarkColorSchemeFromPalette(corePalette)
|
||||
: material_color_utilities::MaterialLightColorSchemeFromPalette(corePalette);
|
||||
|
||||
materialColorScheme.primary = MaterialArgbToRgb888(scheme.primary);
|
||||
materialColorScheme.onPrimary = MaterialArgbToRgb888(scheme.on_primary);
|
||||
materialColorScheme.secondaryContainer = MaterialArgbToRgb888(scheme.secondary_container);
|
||||
materialColorScheme.onSecondaryContainer = MaterialArgbToRgb888(scheme.on_secondary_container);
|
||||
materialColorScheme.tertiary = MaterialArgbToRgb888(scheme.tertiary);
|
||||
materialColorScheme.onTertiary = MaterialArgbToRgb888(scheme.on_tertiary);
|
||||
materialColorScheme.tertiaryContainer = MaterialArgbToRgb888(scheme.tertiary_container);
|
||||
materialColorScheme.onTertiaryContainer = MaterialArgbToRgb888(scheme.on_tertiary_container);
|
||||
materialColorScheme.inverseOnSurface = MaterialArgbToRgb888(darkTheme ? corePalette.neutral().get(10.0) : scheme.inverse_on_surface);
|
||||
materialColorScheme.onSurface = MaterialArgbToRgb888(scheme.on_surface);
|
||||
materialColorScheme.onSurfaceVariant = MaterialArgbToRgb888(scheme.on_surface_variant);
|
||||
materialColorScheme.surfaceBright = MaterialArgbToRgb888(corePalette.neutral().get(darkTheme ? 24.0 : 98.0));
|
||||
materialColorScheme.mainIconBg = MaterialArgbToRgb888(corePalette.secondary().get(darkTheme ? 42.0 : 78.0));
|
||||
// materialColorScheme.surfaceContainerLow = MaterialArgbToRgb888(corePalette.neutral().get(darkTheme ? 10.0 : 96.0));
|
||||
materialColorScheme.surfaceContainerHighest = MaterialArgbToRgb888(corePalette.neutral().get(darkTheme ? 22.0 : 90.0));
|
||||
materialColorScheme.scrim = MaterialArgbToRgb888(corePalette.neutral().get(darkTheme ? 70.0 : 30.0));
|
||||
materialColorScheme.outline = MaterialArgbToRgb888(scheme.outline);
|
||||
}
|
||||
10
arm9/source/themes/material/MaterialColorSchemeFactory.h
Normal file
10
arm9/source/themes/material/MaterialColorSchemeFactory.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "core/math/Rgb.h"
|
||||
#include "MaterialColorScheme.h"
|
||||
|
||||
class MaterialColorSchemeFactory
|
||||
{
|
||||
public:
|
||||
static void FromPrimaryColor(const Rgb<8, 8, 8>& primaryColor,
|
||||
bool darkTheme, MaterialColorScheme& materialColorScheme);
|
||||
};
|
||||
33
arm9/source/themes/material/MaterialMainBackground.cpp
Normal file
33
arm9/source/themes/material/MaterialMainBackground.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "common.h"
|
||||
#include <string.h>
|
||||
#include <libtwl/mem/memVram.h>
|
||||
#include "gui/Gx.h"
|
||||
#include "gui/GraphicsContext.h"
|
||||
#include "../ITheme.h"
|
||||
#include "MaterialMainBackground.h"
|
||||
|
||||
#define BLOCK_VTX_PACK(x, y, z) (((x)&0x3FF) | ((((y) >> 3) & 0x3FF) << 10) | ((z) << 20))
|
||||
|
||||
void MaterialMainBackground::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, 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->inverseOnSurface));
|
||||
Gx::Begin(GX_PRIMITIVE_QUAD);
|
||||
Gx::TexCoord(0, 0);
|
||||
REG_GX_VTX_10 = BLOCK_VTX_PACK(0, 0, 500);
|
||||
REG_GX_VTX_10 = BLOCK_VTX_PACK(0, 192, 500);
|
||||
REG_GX_VTX_10 = BLOCK_VTX_PACK(256, 192, 500);
|
||||
REG_GX_VTX_10 = BLOCK_VTX_PACK(256, 0, 500);
|
||||
Gx::End();
|
||||
}
|
||||
|
||||
void MaterialMainBackground::LoadResources(const ITheme& theme, const VramContext& vramContext)
|
||||
{
|
||||
mem_setVramAMapping(MEM_VRAM_AB_LCDC);
|
||||
*(vu32*)0x06800000 = 0;
|
||||
mem_setVramAMapping(MEM_VRAM_AB_TEX_SLOT_1);
|
||||
}
|
||||
17
arm9/source/themes/material/MaterialMainBackground.h
Normal file
17
arm9/source/themes/material/MaterialMainBackground.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "../background/IThemeBackground.h"
|
||||
|
||||
class MaterialColorScheme;
|
||||
|
||||
class MaterialMainBackground : public IThemeBackground
|
||||
{
|
||||
public:
|
||||
explicit MaterialMainBackground(const MaterialColorScheme* materialColorScheme)
|
||||
: _materialColorScheme(materialColorScheme) { }
|
||||
|
||||
void Draw(GraphicsContext& graphicsContext) override;
|
||||
void LoadResources(const ITheme& theme, const VramContext& vramContext) override;
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
};
|
||||
25
arm9/source/themes/material/MaterialSubBackground.cpp
Normal file
25
arm9/source/themes/material/MaterialSubBackground.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "common.h"
|
||||
#include <nds/arm9/background.h>
|
||||
#include <libtwl/dma/dmaNitro.h>
|
||||
#include <libtwl/mem/memVram.h>
|
||||
#include "core/math/RgbMixer.h"
|
||||
#include "mainBg.h"
|
||||
#include "MaterialSubBackground.h"
|
||||
|
||||
void MaterialSubBackground::LoadResources(const ITheme& theme, const VramContext& vramContext)
|
||||
{
|
||||
mem_setVramHMapping(MEM_VRAM_H_LCDC);
|
||||
RgbMixer::MakeGradientPalette((u16*)0x06898020,
|
||||
_materialColorScheme->inverseOnSurface, _materialColorScheme->secondaryContainer);
|
||||
mem_setVramHMapping(MEM_VRAM_H_SUB_BG_EXT_PLTT_SLOT_0123);
|
||||
dma_ntrCopy32(3, mainBgTiles, (vu8*)BG_GFX_SUB + 0x8000, mainBgTilesLen);
|
||||
dma_ntrCopy32(3, mainBgMap, (vu8*)BG_GFX_SUB + 0x8800, mainBgMapLen);
|
||||
}
|
||||
|
||||
void MaterialSubBackground::VBlank()
|
||||
{
|
||||
REG_DISPCNT_SUB |= (1 << 8);
|
||||
REG_BG0CNT_SUB = BG_32x32 | BG_PRIORITY_3 | BG_COLOR_256 | BG_MAP_BASE(17) | BG_TILE_BASE(2);
|
||||
REG_BG0HOFS_SUB = 0;
|
||||
REG_BG0VOFS_SUB = 0;
|
||||
}
|
||||
16
arm9/source/themes/material/MaterialSubBackground.h
Normal file
16
arm9/source/themes/material/MaterialSubBackground.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "../background/IThemeBackground.h"
|
||||
#include "MaterialColorScheme.h"
|
||||
|
||||
class MaterialSubBackground : public IThemeBackground
|
||||
{
|
||||
public:
|
||||
explicit MaterialSubBackground(const MaterialColorScheme* materialColorScheme)
|
||||
: _materialColorScheme(materialColorScheme) { }
|
||||
|
||||
void LoadResources(const ITheme& theme, const VramContext& vramContext) override;
|
||||
void VBlank() override;
|
||||
|
||||
private:
|
||||
const MaterialColorScheme* _materialColorScheme;
|
||||
};
|
||||
13
arm9/source/themes/material/MaterialTheme.cpp
Normal file
13
arm9/source/themes/material/MaterialTheme.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "common.h"
|
||||
#include <libtwl/mem/memVram.h>
|
||||
#include "romBrowser/Theme/Material/CarouselRecyclerView.h"
|
||||
#include "MaterialTheme.h"
|
||||
|
||||
void MaterialTheme::LoadRomBrowserResources(const VramContext& mainVramContext, const VramContext& subVramContext)
|
||||
{
|
||||
mem_setVramDMapping(MEM_VRAM_D_LCDC);
|
||||
mem_setVramEMapping(MEM_VRAM_E_LCDC);
|
||||
CarouselRecyclerView::UploadGraphics(mainVramContext);
|
||||
mem_setVramDMapping(MEM_VRAM_D_TEX_SLOT_0);
|
||||
mem_setVramEMapping(MEM_VRAM_E_TEX_PLTT_SLOT_0123);
|
||||
}
|
||||
49
arm9/source/themes/material/MaterialTheme.h
Normal file
49
arm9/source/themes/material/MaterialTheme.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
#include <libtwl/gfx/gfxPalette.h>
|
||||
#include "../Theme.h"
|
||||
#include "MaterialColorScheme.h"
|
||||
#include "core/math/Rgb.h"
|
||||
#include "romBrowser/Theme/Material/MaterialThemeFileIconFactory.h"
|
||||
#include "romBrowser/Theme/Material/MaterialRomBrowserViewFactory.h"
|
||||
#include "MaterialMainBackground.h"
|
||||
#include "MaterialSubBackground.h"
|
||||
#include "../DefaultFontRepository.h"
|
||||
|
||||
class MaterialTheme : public Theme
|
||||
{
|
||||
MaterialThemeFileIconFactory _themeFileIconFactory;
|
||||
MaterialRomBrowserViewFactory _romBrowserViewFactory;
|
||||
DefaultFontRepository _fontRepository;
|
||||
public:
|
||||
MaterialTheme(const TCHAR* folderName, const Rgb<8, 8, 8>& primaryColor, bool darkMode)
|
||||
: Theme(folderName, primaryColor, darkMode)
|
||||
, _themeFileIconFactory(&_materialColorScheme, &_fontRepository)
|
||||
, _romBrowserViewFactory(&_materialColorScheme, &_fontRepository) { }
|
||||
|
||||
const IFontRepository* GetFontRepository() const override
|
||||
{
|
||||
return &_fontRepository;
|
||||
}
|
||||
|
||||
const IThemeFileIconFactory* GetThemeFileIconFactory() const override
|
||||
{
|
||||
return &_themeFileIconFactory;
|
||||
}
|
||||
|
||||
const IRomBrowserViewFactory* GetRomBrowserViewFactory() const override
|
||||
{
|
||||
return &_romBrowserViewFactory;
|
||||
}
|
||||
|
||||
std::unique_ptr<IThemeBackground> CreateRomBrowserTopBackground() const override
|
||||
{
|
||||
return std::make_unique<MaterialSubBackground>(&_materialColorScheme);
|
||||
}
|
||||
|
||||
std::unique_ptr<IThemeBackground> CreateRomBrowserBottomBackground() const override
|
||||
{
|
||||
return std::make_unique<MaterialMainBackground>(&_materialColorScheme);
|
||||
}
|
||||
|
||||
void LoadRomBrowserResources(const VramContext& mainVramContext, const VramContext& subVramContext) override;
|
||||
};
|
||||
Reference in New Issue
Block a user