From 91fa0ea68f556e7e527ea6e47de6c89747ee76a1 Mon Sep 17 00:00:00 2001 From: Mauro Vietri Date: Wed, 31 May 2023 22:53:45 -0300 Subject: [PATCH] not a big fan but it works. need to populate aliases.txt --- aliases.txt | 18 ++++++++++++++++ src/common/defines.h | 1 + src/minui/minui.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 aliases.txt diff --git a/aliases.txt b/aliases.txt new file mode 100644 index 0000000..e22fcfa --- /dev/null +++ b/aliases.txt @@ -0,0 +1,18 @@ +2020bb:2020 Super Baseball +alpham2:Alpha Mission II +mslug:Metal Slug - Super Vehicle-001 +neogeo:Neo-Geo MV-6F +mslug2:Metal Slug 2 - Super Vehicle-001/II +mslug2t:Metal Slug 2 Turbo +mslug3h:Metal Slug 3 +mslug3:Metal Slug 3 +mslug3a:Metal Slug 3 +mslug4h:Metal Slug 4 +mslug4:Metal Slug 4 +mslug5b:Metal Slug 5 +mslug5:Metal Slug 5 +mslug5h:Metal Slug 5 +mslug6:Metal Slug 6 +awbios:Atomiswave Bios +mslug3b6:Metal Slug 6 +mslugx:Metal Slug X - Super Vehicle-001 \ No newline at end of file diff --git a/src/common/defines.h b/src/common/defines.h index c8c405c..3bfbdd4 100644 --- a/src/common/defines.h +++ b/src/common/defines.h @@ -62,6 +62,7 @@ #define BATTERY_PATH SDCARD_PATH "/battery.txt" #define SCREENSHOTS_PATH SDCARD_PATH "/Screenshots" #define ADB_FLAG_PATH SDCARD_PATH "/enableADB" +#define ALIASES_PATH SDCARD_PATH "/aliases.txt" #define LAST_PATH "/tmp/last.txt" // transient #define CHANGE_DISC_PATH "/tmp/change_disc.txt" diff --git a/src/minui/minui.c b/src/minui/minui.c index 79cdd4c..6fba182 100644 --- a/src/minui/minui.c +++ b/src/minui/minui.c @@ -114,6 +114,7 @@ typedef struct Entry { char* path; char* name; char* unique; + char* alias; // for neogeo and others where you cannot change the rom filename int type; int alpha; // index in parent Directory's alphas Array, which points to the index of an Entry in its entries Array :sweat_smile: } Entry; @@ -125,6 +126,7 @@ static Entry* Entry_new(char* path, int type) { self->path = strdup(path); self->name = strdup(display_name); self->unique = NULL; + self->alias = NULL; self->type = type; self->alpha = 0; return self; @@ -133,6 +135,7 @@ static void Entry_free(Entry* self) { free(self->path); free(self->name); if (self->unique) free(self->unique); + if (self->alias) free(self->alias); free(self); } @@ -1299,6 +1302,36 @@ int main (int argc, char *argv[]) { POW_setCPUSpeed(CPU_SPEED_MENU); GFX_setVsync(VSYNC_STRICT); + FILE *aliases = fopen(ALIASES_PATH, "r"); + int aIndex = 0; + char* original[50]; + char* alias[50]; + char line[75]; + + if (aliases) { + while(fgets(line, sizeof line, aliases)!=NULL) { + original[aIndex] = malloc(sizeof(line)); + alias[aIndex] = malloc(sizeof(line)); + + int set_alias = 0; + char* split = strtok(line, ":"); + + while(split) { + if (!set_alias) { + strcpy(original[aIndex], split); + set_alias = 1; + } else { + strcpy(alias[aIndex], split); + } + split = strtok(NULL, ":"); + } + + aIndex++; + } + + fclose(aliases); + } + PAD_reset(); int dirty = 1; int show_version = 0; @@ -1536,6 +1569,7 @@ int main (int argc, char *argv[]) { Entry* entry = top->entries->items[i]; char* entry_name = entry->name; char* entry_unique = entry->unique; + char* entry_alias = entry->alias; int available_width = screen->w - SCALE1(PADDING * 2); if (i==top->start) available_width -= ow + CLOCK_SIZE; @@ -1543,7 +1577,24 @@ int main (int argc, char *argv[]) { if (isFavorite(entry->path)) { text_color = COLOR_GOLD; } + + if (aIndex > 0) { + for(int a = 0; a < aIndex; ++a) + { + if(!strcmp(original[a], entry_name)) + { + entry_alias = strdup(alias[a]); + } + } + } + if (entry_alias!=NULL) { + // has alias, we display these over the others + entry_unique = NULL; + entry_name = strdup(entry_alias); + LOG_info("new entry name: %s\n", entry_name); + } + trimSortingMeta(&entry_name); char display_name[256];