mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #14470 from unknownbrackets/http
Fix remote disc browsing, support subfolders
This commit is contained in:
commit
4ec3ce5ecc
5 changed files with 37 additions and 23 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "ppsspp_config.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
@ -117,6 +118,16 @@ std::string Path::GetFileExtension() const {
|
|||
|
||||
std::string Path::GetDirectory() const {
|
||||
size_t pos = path_.rfind('/');
|
||||
if (type_ == PathType::HTTP) {
|
||||
// Things are a bit different for HTTP, because we probably ended with /.
|
||||
if (pos + 1 == path_.size()) {
|
||||
pos = path_.rfind('/', pos - 1);
|
||||
if (pos != path_.npos && pos > 8) {
|
||||
return path_.substr(0, pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pos != std::string::npos) {
|
||||
if (pos == 0) {
|
||||
return "/"; // We're at the root.
|
||||
|
@ -176,6 +187,13 @@ bool Path::CanNavigateUp() const {
|
|||
if (path_ == "/" || path_ == "") {
|
||||
return false;
|
||||
}
|
||||
if (type_ == PathType::HTTP) {
|
||||
size_t rootSlash = path_.find_first_of('/', strlen("https://"));
|
||||
if (rootSlash == path_.npos || path_.size() < rootSlash + 1) {
|
||||
// This means, "http://server" or "http://server/". Can't go up.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ void PathBrowser::HandlePath() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (path_.Type() == PathType::HTTP) {
|
||||
if (path_.Type() != PathType::HTTP) {
|
||||
if (pendingActive_)
|
||||
ResetPending();
|
||||
ready_ = true;
|
||||
|
|
|
@ -541,14 +541,18 @@ UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) {
|
|||
}
|
||||
|
||||
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
|
||||
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
|
||||
SetPath(g_Config.memStickDirectory);
|
||||
#else
|
||||
SetPath(Path(getenv("HOME")));
|
||||
#endif
|
||||
SetPath(HomePath());
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
Path GameBrowser::HomePath() {
|
||||
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
|
||||
return g_Config.memStickDirectory;
|
||||
#else
|
||||
return Path(getenv("HOME"));
|
||||
#endif
|
||||
}
|
||||
|
||||
UI::EventReturn GameBrowser::PinToggleClick(UI::EventParams &e) {
|
||||
auto &pinnedPaths = g_Config.vPinnedPaths;
|
||||
const std::string path = File::ResolvePath(path_.GetPath().ToString());
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
protected:
|
||||
virtual bool DisplayTopBar();
|
||||
virtual bool HasSpecialFiles(std::vector<Path> &filenames);
|
||||
virtual Path HomePath();
|
||||
|
||||
void Refresh();
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ static bool LoadGameList(const Path &url, std::vector<Path> &games) {
|
|||
return false;
|
||||
}
|
||||
for (auto &file : files) {
|
||||
if (RemoteISOFileSupported(file.name)) {
|
||||
if (file.isDirectory || RemoteISOFileSupported(file.name)) {
|
||||
games.push_back(file.fullName);
|
||||
}
|
||||
}
|
||||
|
@ -498,28 +498,19 @@ void RemoteISOConnectScreen::ExecuteLoad() {
|
|||
|
||||
class RemoteGameBrowser : public GameBrowser {
|
||||
public:
|
||||
RemoteGameBrowser(const Path &url, const std::vector<Path> &games, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager* screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr)
|
||||
RemoteGameBrowser(const Path &url, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr)
|
||||
: GameBrowser(url, browseFlags, gridStyle_, screenManager, lastText, lastLink, layoutParams) {
|
||||
games_ = games;
|
||||
Refresh();
|
||||
initialPath_ = url;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool DisplayTopBar() override {
|
||||
return false;
|
||||
Path HomePath() override {
|
||||
return initialPath_;
|
||||
}
|
||||
|
||||
bool HasSpecialFiles(std::vector<Path> &filenames) override;
|
||||
|
||||
std::string url_;
|
||||
std::vector<Path> games_;
|
||||
Path initialPath_;
|
||||
};
|
||||
|
||||
bool RemoteGameBrowser::HasSpecialFiles(std::vector<Path> &filenames) {
|
||||
filenames = games_;
|
||||
return true;
|
||||
}
|
||||
|
||||
RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games)
|
||||
: url_(url), games_(games) {
|
||||
}
|
||||
|
@ -541,8 +532,8 @@ void RemoteISOBrowseScreen::CreateViews() {
|
|||
|
||||
ScrollView *scrollRecentGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
scrollRecentGames->SetTag("RemoteGamesTab");
|
||||
RemoteGameBrowser *tabRemoteGames = new RemoteGameBrowser(
|
||||
Path(url_), games_, BrowseFlags::PIN, &g_Config.bGridView1, screenManager(), "", "",
|
||||
GameBrowser *tabRemoteGames = new RemoteGameBrowser(
|
||||
Path(url_), BrowseFlags::PIN | BrowseFlags::NAVIGATE, &g_Config.bGridView1, screenManager(), "", "",
|
||||
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
scrollRecentGames->Add(tabRemoteGames);
|
||||
gameBrowsers_.push_back(tabRemoteGames);
|
||||
|
|
Loading…
Add table
Reference in a new issue