feat: remember parent folder index in menu when ascending folders
This commit is contained in:
parent
afe9672156
commit
1456cefc1c
@ -29,7 +29,6 @@ void FileSelectionActivity::taskTrampoline(void* param) {
|
|||||||
|
|
||||||
void FileSelectionActivity::loadFiles() {
|
void FileSelectionActivity::loadFiles() {
|
||||||
files.clear();
|
files.clear();
|
||||||
selectorIndex = 0;
|
|
||||||
|
|
||||||
auto root = SdMan.open(basepath.c_str());
|
auto root = SdMan.open(basepath.c_str());
|
||||||
if (!root || !root.isDirectory()) {
|
if (!root || !root.isDirectory()) {
|
||||||
@ -135,6 +134,11 @@ void FileSelectionActivity::loop() {
|
|||||||
basepath.replace(basepath.find_last_of('/'), std::string::npos, "");
|
basepath.replace(basepath.find_last_of('/'), std::string::npos, "");
|
||||||
if (basepath.empty()) basepath = "/";
|
if (basepath.empty()) basepath = "/";
|
||||||
loadFiles();
|
loadFiles();
|
||||||
|
|
||||||
|
auto pos = oldPath.find_last_of('/');
|
||||||
|
std::string dirName = oldPath.substr(pos + 1) + "/";
|
||||||
|
selectorIndex = findEntry(dirName);
|
||||||
|
|
||||||
updateRequired = true;
|
updateRequired = true;
|
||||||
} else {
|
} else {
|
||||||
onGoHome();
|
onGoHome();
|
||||||
@ -194,3 +198,10 @@ void FileSelectionActivity::render() const {
|
|||||||
|
|
||||||
renderer.displayBuffer();
|
renderer.displayBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FileSelectionActivity::findEntry(const std::string& name) const {
|
||||||
|
for (size_t i = 0; i < files.size(); i++)
|
||||||
|
if (files[i] == name)
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class FileSelectionActivity final : public Activity {
|
|||||||
[[noreturn]] void displayTaskLoop();
|
[[noreturn]] void displayTaskLoop();
|
||||||
void render() const;
|
void render() const;
|
||||||
void loadFiles();
|
void loadFiles();
|
||||||
|
int findEntry(const std::string& name) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
explicit FileSelectionActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user