Add R+A - Directory options

This commit is contained in:
RocketRobz 2020-02-03 18:42:14 -07:00
parent ca9653f6fa
commit 893396deed
2 changed files with 35 additions and 17 deletions

View File

@ -204,6 +204,7 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
} }
} }
iprintf ("\x1b[%d;0H", cursorScreenPos + OPTIONS_ENTRIES_START_ROW); iprintf ("\x1b[%d;0H", cursorScreenPos + OPTIONS_ENTRIES_START_ROW);
if (!entry->isDirectory) {
if (entry->isApp) { if (entry->isApp) {
maxCursors++; maxCursors++;
assignedOp[maxCursors] = 0; assignedOp[maxCursors] = 0;
@ -216,6 +217,7 @@ int fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
assignedOp[maxCursors] = 3; assignedOp[maxCursors] = 3;
printf(" Mount NitroFS\n"); printf(" Mount NitroFS\n");
} }
}
maxCursors++; maxCursors++;
assignedOp[maxCursors] = 4; assignedOp[maxCursors] = 4;
printf(entry->isDirectory ? " Show directory info\n" : " Show file info\n"); printf(entry->isDirectory ? " Show directory info\n" : " Show file info\n");
@ -392,7 +394,7 @@ void recRemove(DirEntry* entry, std::vector<DirEntry> dirContents) {
void fileBrowse_drawBottomScreen(DirEntry* entry, int fileOffset) { void fileBrowse_drawBottomScreen(DirEntry* entry, int fileOffset) {
printf ("\x1B[47m"); // Print foreground white color printf ("\x1B[47m"); // Print foreground white color
printf ("\x1b[23;0H"); printf ("\x1b[22;0H");
printf (titleName); printf (titleName);
printf ("\n"); printf ("\n");
printf ("X - DELETE/[+R] RENAME file"); printf ("X - DELETE/[+R] RENAME file");
@ -402,6 +404,8 @@ void fileBrowse_drawBottomScreen(DirEntry* entry, int fileOffset) {
if (!clipboardOn) { if (!clipboardOn) {
printf ("\n"); printf ("\n");
} }
printf ("R+A - Directory options");
printf ("\n");
printf (SCREENSHOTTEXT); printf (SCREENSHOTTEXT);
printf ("\n"); printf ("\n");
printf (clipboardOn ? "SELECT - Clear Clipboard" : "SELECT - Restore Clipboard"); printf (clipboardOn ? "SELECT - Clear Clipboard" : "SELECT - Restore Clipboard");
@ -514,7 +518,8 @@ string browseForFile (void) {
getcwd(path, PATH_MAX); getcwd(path, PATH_MAX);
if (pressed & KEY_A) { if ((!(held & KEY_R) && (pressed & KEY_A))
|| (!dirContents.at(fileOffset).isDirectory && (held & KEY_R) && (pressed & KEY_A))) {
DirEntry* entry = &dirContents.at(fileOffset); DirEntry* entry = &dirContents.at(fileOffset);
if (((strcmp (entry->name.c_str(), "..") == 0) && (strcmp (path, (secondaryDrive ? "fat:/" : "sd:/")) == 0)) if (((strcmp (entry->name.c_str(), "..") == 0) && (strcmp (path, (secondaryDrive ? "fat:/" : "sd:/")) == 0))
|| ((strcmp (entry->name.c_str(), "..") == 0) && (strcmp (path, "nitro:/") == 0))) || ((strcmp (entry->name.c_str(), "..") == 0) && (strcmp (path, "nitro:/") == 0)))
@ -528,9 +533,7 @@ string browseForFile (void) {
getDirectoryContents (dirContents); getDirectoryContents (dirContents);
screenOffset = 0; screenOffset = 0;
fileOffset = 0; fileOffset = 0;
} else if (bothSDandFlashcard() || entry->isApp } else {
|| strcmp (path, (secondaryDrive ? "fat:/gm9i/out/" : "sd:/gm9i/out/")) != 0)
{
int getOp = fileBrowse_A(entry, path); int getOp = fileBrowse_A(entry, path);
if (getOp == 0) { if (getOp == 0) {
// Return the chosen file // Return the chosen file
@ -547,6 +550,21 @@ string browseForFile (void) {
} }
} }
// Directory options
if (dirContents.at(fileOffset).isDirectory && (held & KEY_R) && (pressed & KEY_A)) {
DirEntry* entry = &dirContents.at(fileOffset);
int getOp = fileBrowse_A(entry, path);
if (getOp == 1 || getOp == 2) {
getDirectoryContents (dirContents); // Refresh directory listing
if (getOp == 3 && nitroMounted) {
screenOffset = 0;
fileOffset = 0;
}
} else if (getOp == 4) {
for (int i = 0; i < 15; i++) swiWaitForVBlank();
}
}
if (pressed & KEY_B) { if (pressed & KEY_B) {
if ((strcmp (path, "sd:/") == 0) || (strcmp (path, "fat:/") == 0) || (strcmp (path, "nitro:/") == 0)) { if ((strcmp (path, "sd:/") == 0) || (strcmp (path, "fat:/") == 0) || (strcmp (path, "nitro:/") == 0)) {
screenMode = 0; screenMode = 0;