From 41bf731132beb1075447666204919be3e67b348d Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:13:15 +0200 Subject: [PATCH 01/28] Theme folder support implemented /Theme /Theme/theme.txt (color1 to color6) /Theme/Tools bg.png, bglist.png, icon.png Same for /Theme/SFC, /Theme/GBA etc --- skeleton/BASE/Theme/.keep | 0 workspace/all/common/config.c | 54 ++++++++++++++++++++++++++++++++++ workspace/all/common/defines.h | 1 + workspace/all/common/utils.c | 8 +++++ workspace/all/nextui/nextui.c | 29 +++++++++++++----- 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 skeleton/BASE/Theme/.keep diff --git a/skeleton/BASE/Theme/.keep b/skeleton/BASE/Theme/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index b56b9ae91..93e26c901 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -212,6 +212,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)); diff --git a/workspace/all/common/defines.h b/workspace/all/common/defines.h index 453e6dcea..846155fe1 100644 --- a/workspace/all/common/defines.h +++ b/workspace/all/common/defines.h @@ -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" diff --git a/workspace/all/common/utils.c b/workspace/all/common/utils.c index bea1fbd12..4d16a82f2 100644 --- a/workspace/all/common/utils.c +++ b/workspace/all/common/utils.c @@ -353,6 +353,7 @@ 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, '/'); @@ -360,6 +361,13 @@ void getEmuName(const char* in_name, char* out_name) { // NOTE: both char arrays // 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 diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index e97211659..1f0770c8f 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1361,11 +1361,14 @@ 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("Loading folder bg from %s\n", imagePath); if(exists(imagePath)) { @@ -1980,11 +1983,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); @@ -2003,9 +2009,18 @@ 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); + + } had_thumb = 0; GFX_clearLayers(3); if (exists(thumbpath)) { From 400fc0855f506ffd9854e6533b7025e2948c7fd4 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:33:31 +0200 Subject: [PATCH 02/28] settings app now also writes values to theme.txt --- workspace/all/common/config.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 93e26c901..342037b7b 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -699,6 +699,21 @@ void CFG_sync(void) fprintf(file, "wifi=%i\n", settings.wifi); fclose(file); + sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + 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) From ee4799e112e0a4f46a02770fb0f64617cdb83846 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:44:26 +0200 Subject: [PATCH 03/28] now /Theme can also contain a font.ttf --- workspace/all/common/config.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 342037b7b..19c39b9e0 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -1,6 +1,7 @@ #include "config.h" #include "defines.h" #include "utils.h" +#include NextUISettings settings = {0}; @@ -288,13 +289,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); } From bf7b796678ba819c52b944e0953c8a91143b7a58 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:09:04 +0200 Subject: [PATCH 04/28] fallback for old .media --- workspace/all/nextui/nextui.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 1f0770c8f..d426995e3 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1369,7 +1369,15 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag); else if(type == ENTRY_ROM) snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag); - + + // 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); From 28a0d9e4bad6511a724b8d0c54ef829d62d4fa2e Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:14:31 +0200 Subject: [PATCH 05/28] added bg.png to /Theme too --- workspace/all/nextui/nextui.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index d426995e3..31039a980 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1473,7 +1473,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); From cd69569b5b62cd3e5b4886daf75b7eec8fb37c4e Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:31:30 +0200 Subject: [PATCH 06/28] colors seperated from minuisettings.txt and only read and write to theme.txt, fallback to builtin default theme if there's no theme.txt, will create it upon saving settings when none is available --- workspace/all/common/config.c | 47 ++++++----------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 19c39b9e0..00d4a8e79 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -2,7 +2,8 @@ #include "defines.h" #include "utils.h" #include - +#include +#include NextUISettings settings = {0}; // deprecated @@ -88,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); @@ -681,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); @@ -709,6 +672,10 @@ void CFG_sync(void) fclose(file); sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + + if (!exists(THEME_PATH)) { + mkdir(THEME_PATH, 0755); + } file = fopen(settingsPath, "w"); if (file == NULL) { From 72f068a21499a7d85ef05f9e8c494d676ae0e8cf Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:59:04 +0200 Subject: [PATCH 07/28] assets.png added to /Theme too --- workspace/all/common/api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/common/api.c b/workspace/all/common/api.c index 0a4ac041f..87bc4a522 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -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); From 481ecd5e0c53adcb1e2e99cb8e152b0afe8fc843 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Wed, 14 May 2025 23:18:11 +0200 Subject: [PATCH 08/28] restored to def --- workspace/macos/platform/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/macos/platform/platform.c b/workspace/macos/platform/platform.c index 3259efeda..c1faab471 100644 --- a/workspace/macos/platform/platform.c +++ b/workspace/macos/platform/platform.c @@ -894,7 +894,7 @@ void PLAT_updateShader(int i, const char *filename, int *scale, int *filter, int shader->texelSizeLocation = glGetUniformLocation(shader->shader_p, "texelSize"); for (int i = 0; i < shader->num_pragmas; ++i) { shader->pragmas[i].uniformLocation = glGetUniformLocation(shader->shader_p, shader->pragmas[i].name); - shader->pragmas[i].value = shader->pragmas[i].min; + shader->pragmas[i].value = shader->pragmas[i].def; printf("Param: %s = %f (min: %f, max: %f, step: %f)\n", shader->pragmas[i].name, shader->pragmas[i].def, From 36d27fb2c21c7f2baa1856d8861123a964d6252b Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:13:15 +0200 Subject: [PATCH 09/28] Theme folder support implemented /Theme /Theme/theme.txt (color1 to color6) /Theme/Tools bg.png, bglist.png, icon.png Same for /Theme/SFC, /Theme/GBA etc --- skeleton/BASE/Theme/.keep | 0 workspace/all/common/config.c | 54 ++++++++++++++++++++++++++++++++++ workspace/all/common/defines.h | 1 + workspace/all/common/utils.c | 8 +++++ workspace/all/nextui/nextui.c | 29 +++++++++++++----- 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 skeleton/BASE/Theme/.keep diff --git a/skeleton/BASE/Theme/.keep b/skeleton/BASE/Theme/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index b56b9ae91..93e26c901 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -212,6 +212,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)); diff --git a/workspace/all/common/defines.h b/workspace/all/common/defines.h index 453e6dcea..846155fe1 100644 --- a/workspace/all/common/defines.h +++ b/workspace/all/common/defines.h @@ -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" diff --git a/workspace/all/common/utils.c b/workspace/all/common/utils.c index bea1fbd12..4d16a82f2 100644 --- a/workspace/all/common/utils.c +++ b/workspace/all/common/utils.c @@ -353,6 +353,7 @@ 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, '/'); @@ -360,6 +361,13 @@ void getEmuName(const char* in_name, char* out_name) { // NOTE: both char arrays // 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 diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index e97211659..1f0770c8f 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1361,11 +1361,14 @@ 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("Loading folder bg from %s\n", imagePath); if(exists(imagePath)) { @@ -1980,11 +1983,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); @@ -2003,9 +2009,18 @@ 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); + + } had_thumb = 0; GFX_clearLayers(3); if (exists(thumbpath)) { From 1298837c9c420c0fd41d00bdb3994cdd2ddcb552 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:33:31 +0200 Subject: [PATCH 10/28] settings app now also writes values to theme.txt --- workspace/all/common/config.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 93e26c901..342037b7b 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -699,6 +699,21 @@ void CFG_sync(void) fprintf(file, "wifi=%i\n", settings.wifi); fclose(file); + sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + 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) From 91b01455f7120cb93a41de71107d0917c24b6c33 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:44:26 +0200 Subject: [PATCH 11/28] now /Theme can also contain a font.ttf --- workspace/all/common/config.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 342037b7b..19c39b9e0 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -1,6 +1,7 @@ #include "config.h" #include "defines.h" #include "utils.h" +#include NextUISettings settings = {0}; @@ -288,13 +289,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); } From 1ff235e99e6476bf9a3c590389ed350d5169fba2 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:09:04 +0200 Subject: [PATCH 12/28] fallback for old .media --- workspace/all/nextui/nextui.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 1f0770c8f..d426995e3 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1369,7 +1369,15 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag); else if(type == ENTRY_ROM) snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag); - + + // 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); From 2586de65b2f7cf27f39b604b3790f6339a23b27e Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:14:31 +0200 Subject: [PATCH 13/28] added bg.png to /Theme too --- workspace/all/nextui/nextui.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index d426995e3..31039a980 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1473,7 +1473,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); From 581624cca57510e3fec822b36ef50cceba921e0b Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:31:30 +0200 Subject: [PATCH 14/28] colors seperated from minuisettings.txt and only read and write to theme.txt, fallback to builtin default theme if there's no theme.txt, will create it upon saving settings when none is available --- workspace/all/common/config.c | 47 ++++++----------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 19c39b9e0..00d4a8e79 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -2,7 +2,8 @@ #include "defines.h" #include "utils.h" #include - +#include +#include NextUISettings settings = {0}; // deprecated @@ -88,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); @@ -681,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); @@ -709,6 +672,10 @@ void CFG_sync(void) fclose(file); sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + + if (!exists(THEME_PATH)) { + mkdir(THEME_PATH, 0755); + } file = fopen(settingsPath, "w"); if (file == NULL) { From d59f5504ccfab339be0c21f5e142e49ce4b7cd97 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:59:04 +0200 Subject: [PATCH 15/28] assets.png added to /Theme too --- workspace/all/common/api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/common/api.c b/workspace/all/common/api.c index 0a4ac041f..87bc4a522 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -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); From 3dbceb035339a8d20b92dffb060921a439a63201 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:13:15 +0200 Subject: [PATCH 16/28] Theme folder support implemented /Theme /Theme/theme.txt (color1 to color6) /Theme/Tools bg.png, bglist.png, icon.png Same for /Theme/SFC, /Theme/GBA etc --- skeleton/BASE/Theme/.keep | 0 workspace/all/common/config.c | 54 ++++++++++++++++++++++++++++++++++ workspace/all/common/defines.h | 1 + workspace/all/common/utils.c | 8 +++++ workspace/all/nextui/nextui.c | 29 +++++++++++++----- 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 skeleton/BASE/Theme/.keep diff --git a/skeleton/BASE/Theme/.keep b/skeleton/BASE/Theme/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index b56b9ae91..93e26c901 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -212,6 +212,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)); diff --git a/workspace/all/common/defines.h b/workspace/all/common/defines.h index 453e6dcea..846155fe1 100644 --- a/workspace/all/common/defines.h +++ b/workspace/all/common/defines.h @@ -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" diff --git a/workspace/all/common/utils.c b/workspace/all/common/utils.c index bea1fbd12..4d16a82f2 100644 --- a/workspace/all/common/utils.c +++ b/workspace/all/common/utils.c @@ -353,6 +353,7 @@ 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, '/'); @@ -360,6 +361,13 @@ void getEmuName(const char* in_name, char* out_name) { // NOTE: both char arrays // 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 diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index e97211659..1f0770c8f 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1361,11 +1361,14 @@ 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("Loading folder bg from %s\n", imagePath); if(exists(imagePath)) { @@ -1980,11 +1983,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); @@ -2003,9 +2009,18 @@ 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); + + } had_thumb = 0; GFX_clearLayers(3); if (exists(thumbpath)) { From b9595db4e9363d35fd80ad568f42bc90454b030b Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:33:31 +0200 Subject: [PATCH 17/28] settings app now also writes values to theme.txt --- workspace/all/common/config.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 93e26c901..342037b7b 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -699,6 +699,21 @@ void CFG_sync(void) fprintf(file, "wifi=%i\n", settings.wifi); fclose(file); + sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + 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) From e6e01a2f9e53ed3d8df679c3ec5f4b9602ee5de9 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:44:26 +0200 Subject: [PATCH 18/28] now /Theme can also contain a font.ttf --- workspace/all/common/config.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 342037b7b..19c39b9e0 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -1,6 +1,7 @@ #include "config.h" #include "defines.h" #include "utils.h" +#include NextUISettings settings = {0}; @@ -288,13 +289,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); } From 6f5ef6ee6e37edabe71780e601684ed5f7a3561f Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:09:04 +0200 Subject: [PATCH 19/28] fallback for old .media --- workspace/all/nextui/nextui.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 1f0770c8f..d426995e3 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1369,7 +1369,15 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag); else if(type == ENTRY_ROM) snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag); - + + // 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); From 415a14f97e7362a2af503b9495fbabdb9aaa677c Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:14:31 +0200 Subject: [PATCH 20/28] added bg.png to /Theme too --- workspace/all/nextui/nextui.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index d426995e3..31039a980 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1473,7 +1473,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); From cb10a129ecc6e6627d5143d72445dc78bcf89b00 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:31:30 +0200 Subject: [PATCH 21/28] colors seperated from minuisettings.txt and only read and write to theme.txt, fallback to builtin default theme if there's no theme.txt, will create it upon saving settings when none is available --- workspace/all/common/config.c | 47 ++++++----------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 19c39b9e0..00d4a8e79 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -2,7 +2,8 @@ #include "defines.h" #include "utils.h" #include - +#include +#include NextUISettings settings = {0}; // deprecated @@ -88,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); @@ -681,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); @@ -709,6 +672,10 @@ void CFG_sync(void) fclose(file); sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + + if (!exists(THEME_PATH)) { + mkdir(THEME_PATH, 0755); + } file = fopen(settingsPath, "w"); if (file == NULL) { From a5d7d831798c7a2d1fbdc3fac8a8490da9210a6a Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:59:04 +0200 Subject: [PATCH 22/28] assets.png added to /Theme too --- workspace/all/common/api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/workspace/all/common/api.c b/workspace/all/common/api.c index 0a4ac041f..87bc4a522 100644 --- a/workspace/all/common/api.c +++ b/workspace/all/common/api.c @@ -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); From 253fb3f7f0fb114027176eee8c59fb74be37f384 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:13:15 +0200 Subject: [PATCH 23/28] Theme folder support implemented /Theme /Theme/theme.txt (color1 to color6) /Theme/Tools bg.png, bglist.png, icon.png Same for /Theme/SFC, /Theme/GBA etc --- workspace/all/nextui/nextui.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 31039a980..68b0a09fd 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1361,6 +1361,9 @@ 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 emutag[255]; getEmuName(rompath,emutag); LOG_info("romath ais: %s\n",emutag); @@ -1369,15 +1372,7 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag); else if(type == ENTRY_ROM) snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag); - - // 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); From 18aaed13f6d38da57778f8e58128001185af1e4a Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 20:33:31 +0200 Subject: [PATCH 24/28] settings app now also writes values to theme.txt --- workspace/all/common/config.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index 00d4a8e79..f41692f9f 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -672,10 +672,6 @@ void CFG_sync(void) fclose(file); sprintf(settingsPath, "%s/theme.txt", THEME_PATH); - - if (!exists(THEME_PATH)) { - mkdir(THEME_PATH, 0755); - } file = fopen(settingsPath, "w"); if (file == NULL) { From 15cd8084a0f9fb9e8df670a33e68a45216f96f61 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:09:04 +0200 Subject: [PATCH 25/28] fallback for old .media --- workspace/all/nextui/nextui.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 68b0a09fd..9fd1ca226 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1372,7 +1372,15 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) snprintf(imagePath, sizeof(imagePath), "%s/%s/bg.png", THEME_PATH,emutag); else if(type == ENTRY_ROM) snprintf(imagePath, sizeof(imagePath), "%s/%s/bglist.png", THEME_PATH,emutag); - + + // 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); From 9c8da273a004165dad911634f13602a44b5a12be Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 11 May 2025 21:31:30 +0200 Subject: [PATCH 26/28] colors seperated from minuisettings.txt and only read and write to theme.txt, fallback to builtin default theme if there's no theme.txt, will create it upon saving settings when none is available --- workspace/all/common/config.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workspace/all/common/config.c b/workspace/all/common/config.c index f41692f9f..00d4a8e79 100644 --- a/workspace/all/common/config.c +++ b/workspace/all/common/config.c @@ -672,6 +672,10 @@ void CFG_sync(void) fclose(file); sprintf(settingsPath, "%s/theme.txt", THEME_PATH); + + if (!exists(THEME_PATH)) { + mkdir(THEME_PATH, 0755); + } file = fopen(settingsPath, "w"); if (file == NULL) { From 38ab9dff2ecc6f124c2a9050559003bc6cd21f73 Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Thu, 15 May 2025 18:28:09 +0200 Subject: [PATCH 27/28] rebase conflict removed --- workspace/all/nextui/nextui.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index e1f84e93b..45a5f76ca 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1361,9 +1361,6 @@ 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 emutag[255]; getEmuName(rompath,emutag); LOG_info("romath ais: %s\n",emutag); From 5914d34d9dd2731ede0b20d356798f7ab0266caf Mon Sep 17 00:00:00 2001 From: ro8inmorgan Date: Sun, 15 Jun 2025 15:25:47 +0200 Subject: [PATCH 28/28] temporarly logging for paths --- workspace/all/nextui/nextui.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/workspace/all/nextui/nextui.c b/workspace/all/nextui/nextui.c index 45a5f76ca..3527cb8f2 100644 --- a/workspace/all/nextui/nextui.c +++ b/workspace/all/nextui/nextui.c @@ -1370,6 +1370,7 @@ SDL_Surface* loadFolderBackground(char* rompath, int type) else if(type == ENTRY_ROM) 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) @@ -2031,6 +2032,8 @@ int main (int argc, char *argv[]) { 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;