From 1ff77108547784b2e6657b3568c7fb1da39dbe4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 10 May 2024 10:39:58 +0200 Subject: [PATCH] Folder/file browser tweaks --- Common/File/PathBrowser.cpp | 12 +++++++----- Common/File/PathBrowser.h | 4 ++++ UI/MainScreen.cpp | 8 +++++++- ios/main.mm | 4 ++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Common/File/PathBrowser.cpp b/Common/File/PathBrowser.cpp index 16e83a39bc..df30a6bd61 100644 --- a/Common/File/PathBrowser.cpp +++ b/Common/File/PathBrowser.cpp @@ -168,24 +168,26 @@ void PathBrowser::HandlePath() { break; } lastPath = pendingPath_; - bool success = false; if (lastPath.Type() == PathType::HTTP) { guard.unlock(); results.clear(); - success = LoadRemoteFileList(lastPath, userAgent_, &pendingCancel_, results); + success_ = LoadRemoteFileList(lastPath, userAgent_, &pendingCancel_, results); guard.lock(); } else if (lastPath.empty()) { results.clear(); - success = true; + success_ = true; } else { guard.unlock(); results.clear(); - success = File::GetFilesInDir(lastPath, &results, nullptr); + success_ = File::GetFilesInDir(lastPath, &results, nullptr); + if (!success_) { + WARN_LOG(IO, "PathBrowser: Failed to list directory: %s", lastPath.c_str()); + } guard.lock(); } if (pendingPath_ == lastPath) { - if (success && !pendingCancel_) { + if (success_ && !pendingCancel_) { pendingFiles_ = results; } pendingPath_.clear(); diff --git a/Common/File/PathBrowser.h b/Common/File/PathBrowser.h index 9e6435b59f..38733c6cae 100644 --- a/Common/File/PathBrowser.h +++ b/Common/File/PathBrowser.h @@ -47,6 +47,9 @@ public: bool empty() const { return path_.empty(); } + bool Success() const { + return success_; + } private: void HandlePath(); @@ -67,5 +70,6 @@ private: bool pendingCancel_ = false; bool pendingStop_ = false; bool ready_ = false; + bool success_ = true; }; diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 8f210ac760..6346ea5f88 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -773,7 +773,11 @@ void GameBrowser::Refresh() { if (System_GetPropertyBool(SYSPROP_HAS_ADDITIONAL_STORAGE)) { topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick); } -#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC) +#if PPSSPP_PLATFORM(IOS_APP_STORE) + // Don't show a browse button, not meaningful to browse outside the documents folder it seems, + // as we can't list things like document folders of another app, as far as I can tell. + // However, we do show a Load.. button for picking individual files, that seems to work. +#elif PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC) // on Darwin, we don't show the 'Browse' text alongside the image // we show just the image, because we don't need to emphasize the button on Darwin topBar->Add(new Choice(ImageID("I_FOLDER_OPEN"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::BrowseClick); @@ -849,6 +853,8 @@ void GameBrowser::Refresh() { listingPending_ = !path_.IsListingReady(); + // TODO: If listing failed, show a special error message. + std::vector filenames; if (HasSpecialFiles(filenames)) { for (size_t i = 0; i < filenames.size(); i++) { diff --git a/ios/main.mm b/ios/main.mm index ea35024b66..4c0391c1d5 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -339,6 +339,10 @@ float System_GetPropertyFloat(SystemProperty prop) { bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { + case SYSPROP_HAS_FILE_BROWSER: + return true; + case SYSPROP_HAS_FOLDER_BROWSER: + return true; case SYSPROP_HAS_OPEN_DIRECTORY: return false; case SYSPROP_HAS_BACK_BUTTON: