Skip to content

Commit

Permalink
R4/GBC themes: Fix file list not scrolling down to selected file
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Oct 30, 2023
1 parent 2748bdd commit 2da06fa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions romsel_r4theme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,25 +1014,30 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
int screenOffset = 0;
int fileOffset = 0;
std::vector<DirEntry> dirContents;

getDirectoryContents (dirContents, extensionList);
showDirectoryContents (dirContents, screenOffset);

whiteScreen = false;
fadeType = true; // Fade in from white

const int entriesStartRow = (ms().theme==6 ? ENTRIES_START_ROW_GBNP : ENTRIES_START_ROW);
const int entriesPerScreen = (ms().theme==6 ? ENTRIES_PER_SCREEN_GBNP : ENTRIES_PER_SCREEN);

fileOffset = ms().cursorPosition[ms().secondaryDevice];
if (ms().pagenum[ms().secondaryDevice] > 0) {
fileOffset += ms().pagenum[ms().secondaryDevice]*40;
}

// Scroll screen if needed
if (fileOffset > screenOffset + entriesPerScreen - 1) {
screenOffset = fileOffset - entriesPerScreen + 1;
}

showDirectoryContents (dirContents, screenOffset);

whiteScreen = false;
fadeType = true; // Fade in from white

while (true) {
if (fileOffset < 0) fileOffset = dirContents.size() - 1; // Wrap around to bottom of list
if (fileOffset > ((int)dirContents.size() - 1)) fileOffset = 0; // Wrap around to top of list

int entriesStartRow = (ms().theme==6 ? ENTRIES_START_ROW_GBNP : ENTRIES_START_ROW);
int entriesPerScreen = (ms().theme==6 ? ENTRIES_PER_SCREEN_GBNP : ENTRIES_PER_SCREEN);

// Clear old cursors
for (int i = entriesStartRow; i < entriesPerScreen + entriesStartRow; i++) {
iprintf ("\x1b[%d;%dH ", i, (ms().theme==6 ? 7 : 0));
Expand Down

0 comments on commit 2da06fa

Please sign in to comment.