Skip to content

Commit

Permalink
Always display Back folder first + Hide all folders starting with _
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Aug 17, 2024
1 parent d9fec73 commit 4b78ab8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
13 changes: 12 additions & 1 deletion romsel_aktheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
if (pdir == nullptr) {
iprintf("Unable to open the directory.\n");
} else {
bool backFound = false;
int backPos = 0;
while (1) {
bgOperations(false);

Expand Down Expand Up @@ -218,8 +220,14 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<

bool emplaceBackDirContent = false;
if (ms().showDirectories) {
if (!backFound && (pent->d_type == DT_DIR) && (strcmp(pent->d_name, "..") == 0)) {
backFound = true;
backPos = file_count;
file_count++;
fileStartPos++;
}
emplaceBackDirContent =
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "_nds") != 0
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "..") != 0 && pent->d_name[0] != '_'
&& strcmp(pent->d_name, "saves") != 0 && strcmp(pent->d_name, "ramdisks") != 0)
|| nameEndsWith(pent->d_name, extensionList));
} else {
Expand Down Expand Up @@ -338,6 +346,9 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
logPrint("Custom");
}
logPrint("\n\n");
if (backFound) {
dirContents.insert(dirContents.begin(), {"..", true, backPos, false});
}
closedir(pdir);
}
}
Expand Down
20 changes: 17 additions & 3 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern int vblankRefreshCounter;
int file_count = 0;
int last_used_box = 0;
static int fileStartPos = 0; // The position of the first thing that is not a directory.
static bool backFound = false;

extern int spawnedtitleboxes;

Expand Down Expand Up @@ -290,6 +291,8 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
if (pdir == nullptr) {
printSmall(false, 4, 4, STR_UNABLE_TO_OPEN_DIRECTORY);
} else {
backFound = false;
int backPos = 0;
while (1) {
bgOperations(false);

Expand Down Expand Up @@ -321,8 +324,14 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<

bool emplaceBackDirContent = false;
if (ms().showDirectories) {
if (!backFound && (pent->d_type == DT_DIR) && (strcmp(pent->d_name, "..") == 0)) {
backFound = true;
backPos = file_count;
file_count++;
fileStartPos++;
}
emplaceBackDirContent =
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "_nds") != 0
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "..") != 0 && pent->d_name[0] != '_'
&& strcmp(pent->d_name, "saves") != 0 && strcmp(pent->d_name, "ramdisks") != 0)
|| nameEndsWith(pent->d_name, extensionList));
} else {
Expand Down Expand Up @@ -439,6 +448,9 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
logPrint("Custom");
}
logPrint("\n\n");
if (backFound) {
dirContents.insert(dirContents.begin(), {"..", true, backPos, false});
}
closedir(pdir);
}
}
Expand Down Expand Up @@ -3187,7 +3199,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
moveCursor(false, dirContents[scrn]);
} else if ((held & KEY_RIGHT) || ((held & KEY_TOUCH) && touch.py > 171 && touch.px > 236 && ms().theme == TWLSettings::EThemeDSi)) { // Right or button arrow (DSi theme)
moveCursor(true, dirContents[scrn]);
} else if ((pressed & KEY_UP) && (ms().theme != TWLSettings::EThemeSaturn && ms().theme != TWLSettings::EThemeHBL) && !dirInfoIniFound && (ms().sortMethod == 4) && CURPOS + PAGENUM * 40 < ((int)dirContents[scrn].size())) { // Move apps (DSi & 3DS themes)
} else if ((pressed & KEY_UP) && (PAGENUM > 0 || CURPOS > 0 || !backFound) && (ms().theme != TWLSettings::EThemeSaturn && ms().theme != TWLSettings::EThemeHBL) && !dirInfoIniFound && (ms().sortMethod == 4) && (CURPOS + PAGENUM * 40 < ((int)dirContents[scrn].size()))) { // Move apps (DSi & 3DS themes)
bannerTextShown = false; // Redraw the title when done
showSTARTborder = false;
currentBg = 2;
Expand Down Expand Up @@ -3233,7 +3245,9 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
}*/

if (held & KEY_LEFT) {
moveCursor(false, dirContents[scrn]);
if (PAGENUM > 0 || CURPOS > 1 || !backFound) {
moveCursor(false, dirContents[scrn]);
}
} else if (held & KEY_RIGHT) {
if (CURPOS + (PAGENUM * 40) < (int)dirContents[scrn].size() - 1) {
moveCursor(true, dirContents[scrn], dirContents[scrn].size() - 1 - PAGENUM * 40);
Expand Down
13 changes: 12 additions & 1 deletion romsel_r4theme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
int file_count = 0;
fileStartPos = 0;

bool backFound = false;
int backPos = 0;
while (1) {
bgOperations(false);

Expand Down Expand Up @@ -209,8 +211,14 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<

bool emplaceBackDirContent = false;
if (ms().showDirectories) {
if (!backFound && (pent->d_type == DT_DIR) && (strcmp(pent->d_name, "..") == 0)) {
backFound = true;
backPos = file_count;
file_count++;
fileStartPos++;
}
emplaceBackDirContent =
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "_nds") != 0
((pent->d_type == DT_DIR && strcmp(pent->d_name, ".") != 0 && strcmp(pent->d_name, "..") != 0 && pent->d_name[0] != '_'
&& strcmp(pent->d_name, "saves") != 0 && strcmp(pent->d_name, "ramdisks") != 0)
|| nameEndsWith(pent->d_name, extensionList));
} else {
Expand Down Expand Up @@ -326,6 +334,9 @@ void getDirectoryContents(std::vector<DirEntry> &dirContents, const std::vector<
logPrint("Custom");
}
logPrint("\n\n");
if (backFound) {
dirContents.insert(dirContents.begin(), {"..", true, backPos, false});
}
closedir(pdir);
}
}
Expand Down

0 comments on commit 4b78ab8

Please sign in to comment.