Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
41bf731
Theme folder support implemented
ro8inmorgan May 11, 2025
400fc08
settings app now also writes values to theme.txt
ro8inmorgan May 11, 2025
ee4799e
now /Theme can also contain a font.ttf
ro8inmorgan May 11, 2025
bf7b796
fallback for old .media
ro8inmorgan May 11, 2025
28a0d9e
added bg.png to /Theme too
ro8inmorgan May 11, 2025
cd69569
colors seperated from minuisettings.txt and only read and write to th…
ro8inmorgan May 11, 2025
72f068a
assets.png added to /Theme too
ro8inmorgan May 11, 2025
8e2097d
Merge branch 'main' into themingupdate
ro8inmorgan May 11, 2025
481ecd5
restored to def
ro8inmorgan May 14, 2025
0dda64c
Merge branch 'main' of https://github.com/LoveRetro/NextUI
ro8inmorgan May 14, 2025
36d27fb
Theme folder support implemented
ro8inmorgan May 11, 2025
1298837
settings app now also writes values to theme.txt
ro8inmorgan May 11, 2025
91b0145
now /Theme can also contain a font.ttf
ro8inmorgan May 11, 2025
1ff235e
fallback for old .media
ro8inmorgan May 11, 2025
2586de6
added bg.png to /Theme too
ro8inmorgan May 11, 2025
581624c
colors seperated from minuisettings.txt and only read and write to th…
ro8inmorgan May 11, 2025
d59f550
assets.png added to /Theme too
ro8inmorgan May 11, 2025
9332ee6
Merge branch 'themingupdate' of https://github.com/LoveRetro/NextUI i…
ro8inmorgan May 15, 2025
ffbb20f
Merge branch 'main' of https://github.com/LoveRetro/NextUI
ro8inmorgan May 15, 2025
3dbceb0
Theme folder support implemented
ro8inmorgan May 11, 2025
b9595db
settings app now also writes values to theme.txt
ro8inmorgan May 11, 2025
e6e01a2
now /Theme can also contain a font.ttf
ro8inmorgan May 11, 2025
6f5ef6e
fallback for old .media
ro8inmorgan May 11, 2025
415a14f
added bg.png to /Theme too
ro8inmorgan May 11, 2025
cb10a12
colors seperated from minuisettings.txt and only read and write to th…
ro8inmorgan May 11, 2025
a5d7d83
assets.png added to /Theme too
ro8inmorgan May 11, 2025
253fb3f
Theme folder support implemented
ro8inmorgan May 11, 2025
18aaed1
settings app now also writes values to theme.txt
ro8inmorgan May 11, 2025
15cd808
fallback for old .media
ro8inmorgan May 11, 2025
9c8da27
colors seperated from minuisettings.txt and only read and write to th…
ro8inmorgan May 11, 2025
f38d162
Merge branch 'themingupdate' of https://github.com/LoveRetro/NextUI i…
ro8inmorgan May 15, 2025
38ab9df
rebase conflict removed
ro8inmorgan May 15, 2025
5914d34
temporarly logging for paths
ro8inmorgan Jun 15, 2025
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
Empty file added skeleton/BASE/Theme/.keep
Empty file.
5 changes: 4 additions & 1 deletion workspace/all/common/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ SDL_Surface* GFX_init(int mode)
asset_rects[ASSET_GAMEPAD] = (SDL_Rect){SCALE4(92,51,18,10)};

char asset_path[MAX_PATH];
sprintf(asset_path, RES_PATH "/assets@%ix.png", FIXED_SCALE);
// first see if there is an assets file in the Theme folder otherwise just load up default
sprintf(asset_path, THEME_PATH "/assets@%ix.png", FIXED_SCALE);
if (!exists(asset_path))
sprintf(asset_path, RES_PATH "/assets@%ix.png", FIXED_SCALE);
if (!exists(asset_path))
LOG_info("missing assets, you're about to segfault dummy!\n");
gfx.assets = IMG_Load(asset_path);
Expand Down
135 changes: 90 additions & 45 deletions workspace/all/common/config.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "config.h"
#include "defines.h"
#include "utils.h"

#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
NextUISettings settings = {0};

// deprecated
Expand Down Expand Up @@ -87,38 +89,7 @@ void CFG_init(FontLoad_callback_t cb, ColorSet_callback_t ccb)
fontLoaded = true;
continue;
}
if (sscanf(line, "color1=%x", &temp_color) == 1)
{
char hexColor[7];
snprintf(hexColor, sizeof(hexColor), "%06x", temp_color);
CFG_setColor(1, HexToUint32_unmapped(hexColor));
continue;
}
if (sscanf(line, "color2=%x", &temp_color) == 1)
{
CFG_setColor(2, temp_color);
continue;
}
if (sscanf(line, "color3=%x", &temp_color) == 1)
{
CFG_setColor(3, temp_color);
continue;
}
if (sscanf(line, "color4=%x", &temp_color) == 1)
{
CFG_setColor(4, temp_color);
continue;
}
if (sscanf(line, "color5=%x", &temp_color) == 1)
{
CFG_setColor(5, temp_color);
continue;
}
if (sscanf(line, "color6=%x", &temp_color) == 1)
{
CFG_setColor(6, temp_color);
continue;
}

if (sscanf(line, "radius=%i", &temp_value) == 1)
{
CFG_setThumbnailRadius(temp_value);
Expand Down Expand Up @@ -212,6 +183,60 @@ void CFG_init(FontLoad_callback_t cb, ColorSet_callback_t ccb)
}
fclose(file);
}
// Check for theme.txt settings file and overwrite configs if found
sprintf(settingsPath, "%s/theme.txt", THEME_PATH);
file = fopen(settingsPath, "r");
if (file == NULL)
{
printf("[CFG] Unable to open settings file, loading defaults\n");
}
else
{
char line[256];
while (fgets(line, sizeof(line), file))
{
int temp_value;
uint32_t temp_color;
if (sscanf(line, "color1=%x", &temp_color) == 1)
{
char hexColor[7];
snprintf(hexColor, sizeof(hexColor), "%06x", temp_color);
CFG_setColor(1, HexToUint32_unmapped(hexColor));
continue;
}
if (sscanf(line, "color2=%x", &temp_color) == 1)
{
CFG_setColor(2, temp_color);
continue;
}
if (sscanf(line, "color3=%x", &temp_color) == 1)
{
CFG_setColor(3, temp_color);
continue;
}
if (sscanf(line, "color4=%x", &temp_color) == 1)
{
CFG_setColor(4, temp_color);
continue;
}
if (sscanf(line, "color5=%x", &temp_color) == 1)
{
CFG_setColor(5, temp_color);
continue;
}
if (sscanf(line, "color6=%x", &temp_color) == 1)
{
CFG_setColor(6, temp_color);
continue;
}
if (sscanf(line, "radius=%i", &temp_value) == 1)
{
CFG_setThumbnailRadius(temp_value);
continue;
}
}
fclose(file);
}

// load gfx related stuff until we drop the indirection
CFG_setColor(1, CFG_getColor(1));
Expand All @@ -234,13 +259,21 @@ void CFG_setFontId(int id)
{
settings.font = clamp(id, 0, 2);

const char *themeFontPath = THEME_PATH "/font.ttf";
char *fontPath;
if (settings.font == 1)
fontPath = RES_PATH "/font1.ttf";
else
fontPath = RES_PATH "/font2.ttf";

if(settings.onFontChange)
// Check if THEME_PATH/font.ttf exists
if (access(themeFontPath, F_OK) == 0) {
fontPath = (char *)themeFontPath;
} else {
// Fallback to default fonts
if (settings.font == 1)
fontPath = RES_PATH "/font1.ttf";
else
fontPath = RES_PATH "/font2.ttf";
}

if (settings.onFontChange)
settings.onFontChange(fontPath);
}

Expand Down Expand Up @@ -618,14 +651,7 @@ void CFG_sync(void)
}

fprintf(file, "font=%i\n", settings.font);
fprintf(file, "color1=0x%06X\n", settings.color1_255);
fprintf(file, "color2=0x%06X\n", settings.color2_255);
fprintf(file, "color3=0x%06X\n", settings.color3_255);
fprintf(file, "color4=0x%06X\n", settings.color4_255);
fprintf(file, "color5=0x%06X\n", settings.color5_255);
fprintf(file, "color6=0x%06X\n", settings.color6_255);
fprintf(file, "bgcolor=0x%06X\n", settings.backgroundColor_255);
fprintf(file, "radius=%i\n", settings.thumbRadius);
fprintf(file, "showclock=%i\n", settings.showClock);
fprintf(file, "clock24h=%i\n", settings.clock24h);
fprintf(file, "batteryperc=%i\n", settings.showBatteryPercent);
Expand All @@ -645,6 +671,25 @@ void CFG_sync(void)
fprintf(file, "wifi=%i\n", settings.wifi);

fclose(file);
sprintf(settingsPath, "%s/theme.txt", THEME_PATH);

if (!exists(THEME_PATH)) {
mkdir(THEME_PATH, 0755);
}
file = fopen(settingsPath, "w");
if (file == NULL)
{
printf("[CFG] Unable to open settings file, cant write\n");
return;
}
fprintf(file, "color1=0x%06X\n", settings.color1_255);
fprintf(file, "color2=0x%06X\n", settings.color2_255);
fprintf(file, "color3=0x%06X\n", settings.color3_255);
fprintf(file, "color4=0x%06X\n", settings.color4_255);
fprintf(file, "color5=0x%06X\n", settings.color5_255);
fprintf(file, "color6=0x%06X\n", settings.color6_255);
fprintf(file, "radius=%i\n", settings.thumbRadius);
fclose(file);
}

void CFG_print(void)
Expand Down
1 change: 1 addition & 0 deletions workspace/all/common/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#define FAUX_RECENT_PATH SDCARD_PATH "/Recently Played"
#define COLLECTIONS_PATH SDCARD_PATH "/Collections"
#define THEME_PATH SDCARD_PATH "/Theme"

#define LAST_PATH "/tmp/last.txt" // transient
#define CHANGE_DISC_PATH "/tmp/change_disc.txt"
Expand Down
8 changes: 8 additions & 0 deletions workspace/all/common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,21 @@ void getEmuName(const char* in_name, char* out_name) { // NOTE: both char arrays
// printf("--------\n in_name: %s\n",in_name); fflush(stdout);

// extract just the Roms folder name if necessary

if (prefixMatch(ROMS_PATH, tmp)) {
tmp += strlen(ROMS_PATH) + 1;
char* tmp2 = strchr(tmp, '/');
if (tmp2) tmp2[0] = '\0';
// printf(" tmp1: %s\n", tmp);
strcpy(out_name, tmp);
tmp = out_name;
} else if (prefixMatch(SDCARD_PATH, tmp)) { // doing this to also grab non systems like Tools, Collections etc
tmp += strlen(SDCARD_PATH) + 1;
char* tmp2 = strchr(tmp, '/');
if (tmp2) tmp2[0] = '\0';
// printf(" tmp1: %s\n", tmp);
strcpy(out_name, tmp);
tmp = out_name;
}

// finally extract pak name from parenths if present
Expand Down
48 changes: 39 additions & 9 deletions workspace/all/nextui/nextui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1361,12 +1361,25 @@ static int remember_selection = 0;

SDL_Surface* loadFolderBackground(char* rompath, int type)
{
char emutag[255];
getEmuName(rompath,emutag);
LOG_info("romath ais: %s\n",emutag);
char imagePath[MAX_PATH];
if(type == ENTRY_DIR)
snprintf(imagePath, sizeof(imagePath), "%s/.media/bg.png", rompath);
snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag);
else if(type == ENTRY_ROM)
snprintf(imagePath, sizeof(imagePath), "%s/.media/bglist.png", rompath);

snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag);

LOG_info("background path: %s\n",imagePath);
// fallback for old .media system
if(!exists(imagePath)) {
if(type == ENTRY_DIR)
snprintf(imagePath, sizeof(imagePath), "%s/.media/bg.png", rompath);
else if(type == ENTRY_ROM)
snprintf(imagePath, sizeof(imagePath), "%s/.media/bglist.png", rompath);
}


//LOG_info("Loading folder bg from %s\n", imagePath);
if(exists(imagePath)) {
SDL_Surface *image = IMG_Load(imagePath);
Expand Down Expand Up @@ -1462,7 +1475,10 @@ int main (int argc, char *argv[]) {

char folderBgPath[1024];
folderbgbmp = NULL;
SDL_Surface* bgbmp = IMG_Load(SDCARD_PATH "/bg.png");
SDL_Surface* bgbmp = IMG_Load(THEME_PATH "/bg.png");
if(!bgbmp)
bgbmp = IMG_Load(SDCARD_PATH "/bg.png");

SDL_Surface* convertedbg = SDL_ConvertSurfaceFormat(bgbmp, SDL_PIXELFORMAT_RGBA8888, 0);
if (convertedbg) {
SDL_FreeSurface(bgbmp);
Expand Down Expand Up @@ -1980,11 +1996,14 @@ int main (int argc, char *argv[]) {

// draw background
static int lastType = -1;
if(((entry->type == ENTRY_DIR || entry->type == ENTRY_ROM) && CFG_getRomsUseFolderBackground())) {
static int lastTotal = 0;
if((CFG_getRomsUseFolderBackground())) {
LOG_info("entry path %s %s\n",entry->path,rompath);
LOG_info("Totals %i %i\n",lastTotal,total);
char *newBg = entry->type == ENTRY_DIR ? entry->path:rompath;
if((strcmp(newBg, folderBgPath) != 0 || lastType != entry->type) && sizeof(folderBgPath) != 1) {
if((strcmp(newBg, folderBgPath) != 0 || lastType != entry->type || lastTotal != total) && sizeof(folderBgPath) != 1) {
lastType = entry->type;
lastTotal = total;
strncpy(folderBgPath, newBg, sizeof(folderBgPath) - 1);
SDL_FreeSurface(folderbgbmp);
folderbgbmp = loadFolderBackground(folderBgPath,entry->type);
Expand All @@ -2003,9 +2022,20 @@ int main (int argc, char *argv[]) {
if (total > 0) {
char thumbpath[1024];

if(CFG_getShowGameArt())
snprintf(thumbpath, sizeof(thumbpath), "%s/.media/%s.png", rompath, res_copy);

if(CFG_getShowGameArt()) {
char emutag[255];
getEmuName(rompath,emutag);
char *newBg = entry->type == ENTRY_DIR ? entry->path:rompath;
snprintf(thumbpath, sizeof(thumbpath), entry->type == ENTRY_DIR ? "":"%s/.media/%s.png", rompath, res_copy);

if( entry->type == ENTRY_DIR)
snprintf(thumbpath, sizeof(thumbpath), "%s/%s/icon.png", THEME_PATH,emutag);
else
snprintf(thumbpath, sizeof(thumbpath),"%s/.media/%s.png", rompath, res_copy);

LOG_info("gamearth path: %s\n",thumbpath);

}
had_thumb = 0;
GFX_clearLayers(3);
if (exists(thumbpath)) {
Expand Down