From 2dbf207f9b2257ad03b4349971c26c48aec4b564 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 21 Aug 2015 21:22:52 -0700 Subject: [PATCH] GUI: Merge file-select changes from Wii branch --- src/util/gui/file-select.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/gui/file-select.c b/src/util/gui/file-select.c index cc13a2b81..05a0fbb67 100644 --- a/src/util/gui/file-select.c +++ b/src/util/gui/file-select.c @@ -56,6 +56,7 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP strncpy(currentPath, basePath, sizeof(currentPath)); int oldInput = -1; size_t fileIndex = 0; + size_t start = 0; struct FileList currentFiles; FileListInit(¤tFiles, 0); @@ -72,6 +73,12 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP if (newInput & (1 << GUI_INPUT_DOWN) && fileIndex < FileListSize(¤tFiles) - 1) { ++fileIndex; } + if (fileIndex < start) { + start = fileIndex; + } + while ((fileIndex - start + 4) * GUIFontHeight(params->font) > params->height) { + ++start; + } if (newInput & (1 << GUI_INPUT_CANCEL)) { _cleanFiles(¤tFiles); FileListDeinit(¤tFiles); @@ -101,7 +108,7 @@ bool selectFile(const struct GUIParams* params, const char* basePath, char* outP 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(¤tFiles); ++i) { + for (i = start; i < FileListSize(¤tFiles); ++i) { int color = 0xE0A0A0A0; char bullet = ' '; if (i == fileIndex) {