mGUI: Load parent directory if last used directory is missing (fixes #3379)

This commit is contained in:
Vicki Pfau 2024-12-22 04:50:46 -08:00
parent 39ab641953
commit 08430fc058
4 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,7 @@ Other fixes:
- GBA: Fix getting game info for multiboot ROMs
- GBA Core: Fix booting into BIOS when skip BIOS is enabled
- GBA Hardware: Fix loading states unconditionally overwriting GPIO memory
- mGUI: Load parent directory if last used directory is missing (fixes mgba.io/i/3379)
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
- Qt: Fix potential crash when configuring shortcuts
Misc:

View File

@ -10,9 +10,12 @@
CXX_GUARD_START
#include <mgba/core/log.h>
#include <mgba-util/gui.h>
#include <mgba-util/vector.h>
mLOG_DECLARE_CATEGORY(GUI_MENU);
#define GUI_V_V (struct GUIVariant) { .type = GUI_VARIANT_VOID }
#define GUI_V_U(U) (struct GUIVariant) { .type = GUI_VARIANT_UNSIGNED, .v.u = (U) }
#define GUI_V_I(I) (struct GUIVariant) { .type = GUI_VARIANT_INT, .v.i = (I) }

View File

@ -163,7 +163,16 @@ bool GUISelectFile(struct GUIParams* params, char* outPath, size_t outLen, bool
.subtitle = params->currentPath,
};
GUIMenuItemListInit(&menu.items, 0);
_refreshDirectory(params, params->currentPath, &menu.items, filterName, filterContents, preselect);
while (true) {
if (_refreshDirectory(params, params->currentPath, &menu.items, filterName, filterContents, preselect)) {
break;
}
if (strncmp(params->currentPath, params->basePath, PATH_MAX) == 0 || !params->currentPath[0]) {
mLOG(GUI_MENU, ERROR, "Failed to load base directory");
return false;
}
_upDirectory(params->currentPath);
}
menu.index = params->fileIndex;
while (true) {

View File

@ -17,6 +17,8 @@
DEFINE_VECTOR(GUIMenuItemList, struct GUIMenuItem);
DEFINE_VECTOR(GUIMenuSavedList, struct GUIMenuSavedState);
mLOG_DEFINE_CATEGORY(GUI_MENU, "GUI Menu", "gui.menu");
void _itemNext(struct GUIMenuItem* item, bool wrap) {
if (wrap || item->state < item->nStates - 1) {
unsigned oldState = item->state;