Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions skeleton/BASE/Palettes/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
NextUI Color Palettes
----------------------------------------

Drop custom color palette files (.txt) in this folder. They will show up under
Settings > Appearance > Color Palette, alongside the built-in palettes, and can be
shared with others by simply copying the file.

Each palette is a plain text file. Example (my_palette.txt):

version=1
name=Example
color1=0xffffffff
color2=0x9b2257ff
color3=0x1e2329ff
color4=0xffffffff
color5=0x000000ff
color6=0x000000ff
color7=0xffffffff

Fields
------
version Palette file format version. Use 1. Files with a version newer than the
running NextUI build supports are ignored.
name The label shown in the menu. If omitted, the file name is used (with
underscores turned into spaces).
color1 Main color - main UI elements.
color2 Primary accent - highlights important things.
color3 Secondary accent.
color4 List text.
color5 List text (selected).
color6 Hint / info text (button hints).
color7 Background - used when no background image is set.

Colors are packed hex. Both 0xRRGGBB and 0xRRGGBBAA are accepted; when the alpha
byte is omitted the color is treated as fully opaque. Any color you leave out
falls back to the NextUI default for that slot.

Built-in palettes live with the system files and cannot be edited. Copy one here
and rename it to use it as a starting point for your own.
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Brick Blush.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Brick Blush
color1=0xB5442EFF
color2=0xF6DFD9FF
color3=0xFBEAE6FF
color4=0x33201DFF
color5=0xFBEAE6FF
color6=0x8A6259FF
color7=0xFBECE8FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Catppuccin Frappe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Catppuccin Frappe
color1=0xA6D189FF
color2=0x292C3CFF
color3=0x232634FF
color4=0xC6D0F5FF
color5=0x232634FF
color6=0xA5ADCEFF
color7=0x303446FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Catppuccin Latte.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Catppuccin Latte
color1=0x8839EFFF
color2=0xE6E9EFFF
color3=0xEFF1F5FF
color4=0x4C4F69FF
color5=0xEFF1F5FF
color6=0x6C6F85FF
color7=0xEFF1F5FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Catppuccin Macchiato.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Catppuccin Macchiato
color1=0xF5A97FFF
color2=0x1E2030FF
color3=0x24273AFF
color4=0xCAD3F5FF
color5=0x24273AFF
color6=0xA5ADCBFF
color7=0x24273AFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Catppuccin Mocha.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Catppuccin Mocha
color1=0xCBA6F7FF
color2=0x181825FF
color3=0x1E1E2EFF
color4=0xCDD6F4FF
color5=0x1E1E2EFF
color6=0xA6ADC8FF
color7=0x1E1E2EFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Charcoal Coral.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Charcoal Coral
color1=0xFF6B5BFF
color2=0x161416FF
color3=0x2A0D06FF
color4=0xF2F0ECFF
color5=0x2A0D06FF
color6=0x948F8CFF
color7=0x1D1B1EFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Deep Violet.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Deep Violet
color1=0x6C4BC9FF
color2=0xE7DCF7FF
color3=0xF4EFFDFF
color4=0x241B3DFF
color5=0xF4EFFDFF
color6=0x6E6389FF
color7=0xF1EAFAFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Default.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Default
color1=0xffffffff
color2=0x9b2257ff
color3=0x1e2329ff
color4=0xffffffff
color5=0x000000ff
color6=0xffffffff
color7=0x000000ff
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Forest Lime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Forest Lime
color1=0xB7DD5BFF
color2=0x0A1712FF
color3=0x1B2708FF
color4=0xE7EFE7FF
color5=0x1B2708FF
color6=0x7F998AFF
color7=0x0F1F18FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Ink - Gold.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Ink & Gold
color1=0xF2A93BFF
color2=0x0C0E17FF
color3=0x241A05FF
color4=0xE7E6F2FF
color5=0x241A05FF
color6=0x8A87A3FF
color7=0x12141FFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Maroon Rose.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Maroon Rose
color1=0xE9A6A0FF
color2=0x1C0B0EFF
color3=0x2E100CFF
color4=0xF3E6E4FF
color5=0x2E100CFF
color6=0x9C7B78FF
color7=0x271014FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/MinUI.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=MinUI
color1=0xffffffff
color2=0x262626ff
color3=0x999999ff
color4=0xffffffff
color5=0x000000ff
color6=0xffffffff
color7=0x000000ff
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Mossy Sage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Mossy Sage
color1=0x4B6B3FFF
color2=0xE4EBD9FF
color3=0xEBF3E4FF
color4=0x1F2A1BFF
color5=0xEBF3E4FF
color6=0x647459FF
color7=0xEEF2E6FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Mustard Butter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Mustard Butter
color1=0xB08117FF
color2=0xF5E9C4FF
color3=0xFDF3DAFF
color4=0x2E2610FF
color5=0xFDF3DAFF
color6=0x8A7A45FF
color7=0xFBF3DCFF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Plum Magenta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Plum Magenta
color1=0xD6559EFF
color2=0x170F1DFF
color3=0x2E0A1FFF
color4=0xEEE6F2FF
color5=0x2E0A1FFF
color6=0x93849EFF
color7=0x1F1526FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Slate Cyan.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Slate Cyan
color1=0x45CFC3FF
color2=0x111A28FF
color3=0x0A2320FF
color4=0xE6EDF3FF
color5=0x0A2320FF
color6=0x7E8FA3FF
color7=0x182233FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Teal Powder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Teal Powder
color1=0x1E6E76FF
color2=0xDCEBEFFF
color3=0xE7F5F5FF
color4=0x17232EFF
color5=0xE7F5F5FF
color6=0x5B7480FF
color7=0xE9F2F5FF
9 changes: 9 additions & 0 deletions skeleton/SYSTEM/res/palettes/Terracotta Cream.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version=1
name=Terracotta Cream
color1=0xC1602EFF
color2=0xF1E8D9FF
color3=0xFCEEE4FF
color4=0x2B2118FF
color5=0xFCEEE4FF
color6=0x7A6E5CFF
color7=0xF7F1E7FF
6 changes: 3 additions & 3 deletions workspace/all/common/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -3327,7 +3327,7 @@ FALLBACK_IMPLEMENTATION void PLAT_pollInput(void)
{
uint8_t code = event.key.keysym.scancode;
pressed = event.type == SDL_KEYDOWN;
LOG_info("key event: %i (%i)\n", code,pressed);
// LOG_info("key event: %i (%i)\n", code,pressed);
if (code == CODE_UP)
{
btn = BTN_DPAD_UP;
Expand Down Expand Up @@ -3453,7 +3453,7 @@ FALLBACK_IMPLEMENTATION void PLAT_pollInput(void)
{
uint8_t joy = event.jbutton.button;
pressed = event.type == SDL_JOYBUTTONDOWN;
LOG_info("joy event: %i (%i)\n", joy,pressed);
// LOG_info("joy event: %i (%i)\n", joy,pressed);
if (joy == JOY_UP)
{
btn = BTN_DPAD_UP;
Expand Down Expand Up @@ -3579,7 +3579,7 @@ FALLBACK_IMPLEMENTATION void PLAT_pollInput(void)
{
int hats[4] = {-1, -1, -1, -1}; // -1=no change,0=up,1=down,2=left,3=right btn_ids
int hat = event.jhat.value;
LOG_info("hat event: %i\n", hat);
// LOG_info("hat event: %i\n", hat);
// TODO: safe to assume hats will always be the primary dpad?
// TODO: this is literally a bitmask, make it one (oh, except there's 3 states...)
switch (hat)
Expand Down
88 changes: 88 additions & 0 deletions workspace/all/common/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ void CFG_defaults(NextUISettings *cfg)
.gameArtWidth = CFG_DEFAULT_GAMEARTWIDTH,
.showFolderNamesAtRoot = CFG_DEFAULT_SHOWFOLDERNAMESATROOT,
.inputPromptStyle = CFG_DEFAULT_INPUT_PROMPT_STYLE,
.paletteName = CFG_DEFAULT_PALETTE_NAME,
.customColors = {CFG_DEFAULT_COLOR1, CFG_DEFAULT_COLOR2, CFG_DEFAULT_COLOR3,
CFG_DEFAULT_COLOR4, CFG_DEFAULT_COLOR5, CFG_DEFAULT_COLOR6,
CFG_DEFAULT_COLOR7},

.showClock = CFG_DEFAULT_SHOWCLOCK,
.clock24h = CFG_DEFAULT_CLOCK24H,
Expand Down Expand Up @@ -124,6 +128,14 @@ static inline uint32_t parseHexColor(const char *hexColor) {
return value;
}

uint32_t CFG_parseHexColor(const char *hexColor)
{
return parseHexColor(hexColor);
}

// Defined below, alongside the rest of the palette-name accessors.
static void setPaletteNameRaw(const char *name);

void CFG_init(FontLoad_callback_t cb, ColorSet_callback_t ccb)
{
CFG_defaults(&settings);
Expand Down Expand Up @@ -159,6 +171,17 @@ void CFG_init(FontLoad_callback_t cb, ColorSet_callback_t ccb)
fontLoaded = true;
continue;
}
if (strncmp(line, "palette=", 8) == 0)
{
char *value = line + 8;
value[strcspn(value, "\r\n")] = 0;
// Restore the persisted name as-is; the colors it names are loaded
// independently a few lines below in this same pass, so the pair is
// already consistent. Deliberately bypasses CFG_applyPalette, which
// would overwrite those colors with a (possibly stale) palette's.
setPaletteNameRaw(value);
continue;
}
if(strncmp(line, "color1=", 7) == 0)
{
char *value = line + 7;
Expand Down Expand Up @@ -577,6 +600,65 @@ void CFG_setColor(int color_id, uint32_t color)
settings.onColorSet();
}

// Predefined color palette selection (see palette.c for enumeration/loading)
//
// A non-empty palette name and the 7 colors it points at must never diverge, so
// setting a non-empty name is only possible atomically with the colors it names
// (CFG_applyPalette). setPaletteNameRaw is a private escape hatch used solely to
// restore already-consistent state read back from minuisettings.txt, where the
// colors are loaded independently in the same pass.

static void setPaletteNameRaw(const char *name)
{
if (!name)
name = "";
strncpy(settings.paletteName, name, sizeof(settings.paletteName) - 1);
settings.paletteName[sizeof(settings.paletteName) - 1] = '\0';
}

const char* CFG_getPaletteName(void)
{
return settings.paletteName;
}

void CFG_applyPalette(const char *name, const uint32_t colors[7])
{
// Snapshot the current colors before they're overwritten, but only when
// actually leaving Custom - switching directly between two named palettes must
// not clobber the one saved "last custom" backup with an intermediate palette's
// colors.
if (settings.paletteName[0] == '\0')
{
settings.customColors[0] = settings.color1_255;
settings.customColors[1] = settings.color2_255;
settings.customColors[2] = settings.color3_255;
settings.customColors[3] = settings.color4_255;
settings.customColors[4] = settings.color5_255;
settings.customColors[5] = settings.color6_255;
settings.customColors[6] = settings.color7_255;
}

for (int i = 0; i < 7; i++)
CFG_setColor(i + 1, colors[i]);
setPaletteNameRaw(name);
}

void CFG_clearPalette(void)
{
setPaletteNameRaw("");
}

void CFG_selectCustomPalette(void)
{
// Only restore when actually transitioning away from a palette: if we're
// already Custom, the current colors are whatever the user has been editing
// and must not be clobbered by the (now stale) backup.
if (settings.paletteName[0] != '\0')
for (int i = 0; i < 7; i++)
CFG_setColor(i + 1, settings.customColors[i]);
setPaletteNameRaw("");
}

bool CFG_getShowFolderNamesAtRoot(void)
{
return settings.showFolderNamesAtRoot;
Expand Down Expand Up @@ -1185,6 +1267,10 @@ void CFG_get(const char *key, char *value)
else
sprintf(value, "1");
}
else if (strcmp(key, "palette") == 0)
{
sprintf(value, "\"%s\"", CFG_getPaletteName());
}
else if (strcmp(key, "color1") == 0)
{
sprintf(value, "\"0x%08X\"", CFG_getColor(COLOR_MAIN));
Expand Down Expand Up @@ -1444,6 +1530,7 @@ void CFG_sync(void)
fprintf(file, "font=0\n");
else
fprintf(file, "font=%s\n", settings.fontFile);
fprintf(file, "palette=%s\n", settings.paletteName);
fprintf(file, "color1=0x%08X\n", settings.color1_255);
fprintf(file, "color2=0x%08X\n", settings.color2_255);
fprintf(file, "color3=0x%08X\n", settings.color3_255);
Expand Down Expand Up @@ -1513,6 +1600,7 @@ void CFG_print(void)
printf("\t\"font\": 0,\n");
else
printf("\t\"font\": 1,\n");
printf("\t\"palette\": \"%s\",\n", settings.paletteName);
printf("\t\"color1\": \"0x%08X\",\n", settings.color1_255);
printf("\t\"color2\": \"0x%08X\",\n", settings.color2_255);
printf("\t\"color3\": \"0x%08X\",\n", settings.color3_255);
Expand Down
Loading
Loading