Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
promote collections to root when roms are hidden
Browse files Browse the repository at this point in the history
just add a leading dot to your system rom folders, eg. change "Game Boy (GB)" to just ".(GB)"
  • Loading branch information
Shaun Inman committed Jul 17, 2022
1 parent 6a73478 commit 6f7c634
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
2 changes: 1 addition & 1 deletion skeleton/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ To streamline launching multi-file disc-based games with MiniUI place your bin/c
Harmful Park (English v1.0).bin
Harmful Park (English v1.0).cue

For multi-disc games, put all the the discs files in a single folder and create an m3u file (just a text file containing the relative path to each disc's cue file on a separate line) with the same name as the folder. Instead of showing the entire messy contents of the folder, MiniUI will launch the appropriate cue file, eg. For a Policenauts folder structured like this:
For multi-disc games, put all the files for all the discs in a single folder and create an m3u file (just a text file containing the relative path to each disc's cue file on a separate line) with the same name as the folder. Instead of showing the entire messy contents of the folder, MiniUI will launch the appropriate cue file, eg. For a Policenauts folder structured like this:

Policenauts (English v1.0)/
Policenauts (English v1.0).m3u
Expand Down
50 changes: 41 additions & 9 deletions src/miniui/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,14 @@ static int hasRoms(char* dir_name) {
return has;
}
static Array* getRoot(void) {
Array* entries = Array_new();
Array* root = Array_new();

if (hasRecents()) Array_push(root, Entry_new(Paths.fauxRecentDir, kEntryDir));

if (hasRecents()) Array_push(entries, Entry_new(Paths.fauxRecentDir, kEntryDir));
if (hasCollections()) Array_push(entries, Entry_new(Paths.collectionsDir, kEntryDir));
DIR *dh;

DIR *dh = opendir(Paths.romsDir);
Array* entries = Array_new();
dh = opendir(Paths.romsDir);
if (dh!=NULL) {
struct dirent *dp;
char* tmp;
Expand Down Expand Up @@ -616,17 +618,47 @@ static Array* getRoot(void) {
Array_push(entries, entry);
prev_entry = entry;
}
Array_free(emus); // just free the array part, root now owns emus entries
Array_free(emus); // just free the array part, entries now owns emus entries
closedir(dh);
}

if (hasCollections()) {
if (entries->count) Array_push(root, Entry_new(Paths.collectionsDir, kEntryDir));
else { // no visible systems, promote collections to root
dh = opendir(Paths.collectionsDir);
if (dh!=NULL) {
struct dirent *dp;
char* tmp;
char full_path[256];
sprintf(full_path, "%s/", Paths.collectionsDir);
tmp = full_path + strlen(full_path);
Array* collections = Array_new();
while((dp = readdir(dh)) != NULL) {
if (hide(dp->d_name)) continue;
strcpy(tmp, dp->d_name);
Array_push(collections, Entry_new(full_path, kEntryDir)); // yes, collections are fake directories
}
EntryArray_sort(collections);
for (int i=0; i<collections->count; i++) {
Array_push(entries, collections->items[i]);
}
Array_free(collections); // just free the array part, entries now owns emus entries
closedir(dh);
}
}
}

// add systems to root
for (int i=0; i<entries->count; i++) {
Array_push(root, entries->items[i]);
}
Array_free(entries); // root now owns entries' entries

char tools_path[256];
sprintf(tools_path, "%s/Tools", Paths.rootDir);
if (!is_simple && exists(tools_path)) Array_push(entries, Entry_new(tools_path, kEntryDir));
if (!is_simple && exists(tools_path)) Array_push(root, Entry_new(tools_path, kEntryDir));

fflush(stdout);

return entries;
return root;
}
static Array* getRecents(void) {
Array* entries = Array_new();
Expand Down

0 comments on commit 6f7c634

Please sign in to comment.