From 4388c7aad645dd53bfdc7bd9c0a41c3107d4fe33 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Tue, 30 Jan 2024 17:27:53 +0100 Subject: [PATCH] fixed #1011 --- src/gui/LauncherFileListWidget.cxx | 28 ++++++++++++++-------------- src/gui/LauncherFileListWidget.hxx | 3 +-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/gui/LauncherFileListWidget.cxx b/src/gui/LauncherFileListWidget.cxx index 6f281c8a1..1200c55fe 100644 --- a/src/gui/LauncherFileListWidget.cxx +++ b/src/gui/LauncherFileListWidget.cxx @@ -31,7 +31,6 @@ LauncherFileListWidget::LauncherFileListWidget(GuiObject* boss, // This widget is special, in that it catches signals and redirects them setTarget(this); myFavorites = make_unique(instance().settings()); - myRomDir = startRomDir(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118,29 +117,30 @@ void LauncherFileListWidget::addFolder(StringList& list, int& offset, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string LauncherFileListWidget::startRomDir() +FSNode LauncherFileListWidget::startRomNode() const { - const string romDir = instance().settings().getString("startromdir"); - const FSNode node(romDir); - return node.getPath(); + return FSNode(instance().settings().getString("startromdir")); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void LauncherFileListWidget::extendLists(StringList& list) { - // Only show virtual dirs in "romdir". Except if - // "romdir" is virtual or "romdir" is a ZIP - // Then show virtual dirs in parent dir of "romdir". - if(_node.getPath() == startRomDir() + FSNode romNode = startRomNode(); + + // Only show virtual dirs in "romNode". Except if + // "romNode" is virtual or "romNode" is a ZIP + // Then show virtual dirs in parent of "romNode". + if(_node == romNode && (myInVirtualDir || BSPF::endsWithIgnoreCase(_node.getPath(), ".zip"))) { - myRomDir = _node.getParent().getPath(); - instance().settings().setValue("startromdir", myRomDir); + romNode = _node.getParent(); + instance().settings().setValue("startromdir", romNode.getPath()); } - else - myRomDir = startRomDir(); + else if(!romNode.isDirectory() && romNode.getParent() == _node) + // If launcher started in virtual dir, add virtual folders to parent dir + romNode = _node; - if(instance().settings().getBool("favorites") && _node.getPath() == myRomDir) + if(instance().settings().getBool("favorites") && _node == romNode) { // Add virtual directories behind ".." int offset = _fileList.begin()->getName() == ".." ? 1 : 0; diff --git a/src/gui/LauncherFileListWidget.hxx b/src/gui/LauncherFileListWidget.hxx index 05612877c..ab23525e1 100644 --- a/src/gui/LauncherFileListWidget.hxx +++ b/src/gui/LauncherFileListWidget.hxx @@ -67,10 +67,9 @@ class LauncherFileListWidget : public FileListWidget unique_ptr myFavorites; bool myInVirtualDir{false}; string myVirtualDir; - string myRomDir; private: - string startRomDir(); + FSNode startRomNode() const; void getChildren(const FSNode::CancelCheck& isCancelled) override; void userFavor(string_view path); void addFolder(StringList& list, int& offset, string_view name, IconType icon);