all repos — mgba @ 2dbf207f9b2257ad03b4349971c26c48aec4b564

mGBA Game Boy Advance Emulator

GUI: Merge file-select changes from Wii branch
Jeffrey Pfau jeffrey@endrift.com
Fri, 21 Aug 2015 21:22:52 -0700
commit

2dbf207f9b2257ad03b4349971c26c48aec4b564

parent

5966f46355d18ba472404a7f7ed3cbeebf846635

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M src/util/gui/file-select.csrc/util/gui/file-select.c

@@ -56,6 +56,7 @@ char currentPath[256];

strncpy(currentPath, basePath, sizeof(currentPath)); int oldInput = -1; size_t fileIndex = 0; + size_t start = 0; struct FileList currentFiles; FileListInit(&currentFiles, 0);

@@ -71,6 +72,12 @@ --fileIndex;

} if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(&currentFiles) - 1) { ++fileIndex; + } + if (fileIndex < start) { + start = fileIndex; + } + while ((fileIndex - start + 4) * GUIFontHeight(params->font) > params->height) { + ++start; } if (newInput & (1 << GUI_INPUT_CANCEL)) { _cleanFiles(&currentFiles);

@@ -101,7 +108,7 @@ int y = GUIFontHeight(params->font);

GUIFontPrintf(params->font, 0, y, GUI_TEXT_LEFT, 0xFFFFFFFF, "Current directory: %s", currentPath); y += 2 * GUIFontHeight(params->font); size_t i; - for (i = 0; i < FileListSize(&currentFiles); ++i) { + for (i = start; i < FileListSize(&currentFiles); ++i) { int color = 0xE0A0A0A0; char bullet = ' '; if (i == fileIndex) {