From 450b59809bcac1febdf9a489cdc64e86dad284ba Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Oct 2021 15:56:05 -0700 Subject: [PATCH 1/4] Qt: Allow opening game folder. --- Qt/QtMain.cpp | 4 +++- UI/GameScreen.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index b642f74421..2205dad741 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -5,6 +5,7 @@ // Qt 4.7+ / 5.0+ implementation of the framework. // Currently supports: Android, Linux, Windows, Mac OSX +#include "ppsspp_config.h" #include #include #include @@ -41,6 +42,7 @@ #include "Common/Data/Text/I18n.h" #include "Common/Thread/ThreadUtil.h" #include "Common/Data/Encoding/Utf8.h" +#include "Common/StringUtils.h" #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/HW/Camera.h" @@ -280,7 +282,7 @@ void Vibrate(int length_ms) { } void OpenDirectory(const char *path) { - // Unsupported + QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromUtf8(path))); } void LaunchBrowser(const char *url) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 9cb05ca450..7a885187f5 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -168,7 +168,7 @@ void GameScreen::CreateViews() { if (isRecentGame(gamePath_)) { rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Remove From Recent"))))->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent); } -#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP) +#if (defined(USING_QT_UI) || PPSSPP_PLATFORM(WINDOWS)) && !PPSSPP_PLATFORM(UWP) rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Show In Folder"))))->OnClick.Handle(this, &GameScreen::OnShowInFolder); #endif if (g_Config.bEnableCheats) { From 08a55d19d5ddf9c35ee9036db545b27ad87a615b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Oct 2021 15:56:39 -0700 Subject: [PATCH 2/4] macOS: Allow opening game folder. --- SDL/SDLMain.cpp | 5 ++++- UI/GameScreen.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index f0f74f979a..e3db0bb005 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -190,12 +190,15 @@ void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } void OpenDirectory(const char *path) { -#if defined(_WIN32) +#if PPSSPP_PLATFORM(WINDOWS) PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str()); if (pidl) { SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); ILFree(pidl); } +#elif PPSSPP_PLATFORM(MAC) + std::string command = std::string("open ") + path; + system(command.c_str()); #endif } diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 7a885187f5..2749fa98b3 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -168,7 +168,7 @@ void GameScreen::CreateViews() { if (isRecentGame(gamePath_)) { rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Remove From Recent"))))->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent); } -#if (defined(USING_QT_UI) || PPSSPP_PLATFORM(WINDOWS)) && !PPSSPP_PLATFORM(UWP) +#if (defined(USING_QT_UI) || PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC)) && !PPSSPP_PLATFORM(UWP) rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Show In Folder"))))->OnClick.Handle(this, &GameScreen::OnShowInFolder); #endif if (g_Config.bEnableCheats) { From 8d29aa6590de66f83c5f0d5e191462a612325984 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Oct 2021 15:58:49 -0700 Subject: [PATCH 3/4] Windows: Switch to preferred file selection method. It seems like the previous may not support long paths. --- SDL/SDLMain.cpp | 9 ++++++--- Windows/main.cpp | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index e3db0bb005..b6bdd25ad1 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -191,10 +191,13 @@ PermissionStatus System_GetPermissionStatus(SystemPermission permission) { retur void OpenDirectory(const char *path) { #if PPSSPP_PLATFORM(WINDOWS) - PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str()); + SFGAOF flags; + PIDLIST_ABSOLUTE pidl = nullptr; + HRESULT hr = SHParseDisplayName(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str(), nullptr, &pidl, 0, &flags); if (pidl) { - SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); - ILFree(pidl); + if (SUCCEEDED(hr)) + SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); + CoTaskMemFree(pidl); } #elif PPSSPP_PLATFORM(MAC) std::string command = std::string("open ") + path; diff --git a/Windows/main.cpp b/Windows/main.cpp index 9395233e20..1981eb7ede 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -108,10 +108,14 @@ static std::thread inputBoxThread; static bool inputBoxRunning = false; void OpenDirectory(const char *path) { - PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str()); + SFGAOF flags; + PIDLIST_ABSOLUTE pidl = nullptr; + HRESULT hr = SHParseDisplayName(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str(), nullptr, &pidl, 0, &flags); + if (pidl) { - SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); - ILFree(pidl); + if (SUCCEEDED(hr)) + SHOpenFolderAndSelectItems(pidl, 0, nullptr, 0); + CoTaskMemFree(pidl); } } From e86b7a3a4430827a20f8fd7e02d2baa8ac4256f1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 9 Oct 2021 15:59:32 -0700 Subject: [PATCH 4/4] UI: Add button to show memstick folder. See #13919. --- UI/GameSettingsScreen.cpp | 9 +++++++++ UI/GameSettingsScreen.h | 1 + 2 files changed, 10 insertions(+) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c227c8f79d..ced2912481 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -920,6 +920,10 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new ItemHeader(sy->T("PSP Memory Stick"))); +#if (defined(USING_QT_UI) || PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(MAC)) && !PPSSPP_PLATFORM(UWP) + systemSettings->Add(new Choice(sy->T("Show Memory Stick folder")))->OnClick.Handle(this, &GameSettingsScreen::OnOpenMemStick); +#endif + #if PPSSPP_PLATFORM(ANDROID) memstickDisplay_ = g_Config.memStickDirectory.ToVisualString(); auto memstickPath = systemSettings->Add(new ChoiceWithValueDisplay(&memstickDisplay_, sy->T("Memory Stick folder", "Memory Stick folder"), (const char *)nullptr)); @@ -1155,6 +1159,11 @@ UI::EventReturn GameSettingsScreen::OnChangeMemStickDir(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn GameSettingsScreen::OnOpenMemStick(UI::EventParams &e) { + OpenDirectory(File::ResolvePath(g_Config.memStickDirectory.ToString().c_str()).c_str()); + return UI::EVENT_DONE; +} + #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UI::EventReturn GameSettingsScreen::OnSavePathMydoc(UI::EventParams &e) { diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index fb892d6ea9..1f257826d6 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -109,6 +109,7 @@ private: UI::EventReturn OnAudioDevice(UI::EventParams &e); UI::EventReturn OnJitAffectingSetting(UI::EventParams &e); UI::EventReturn OnChangeMemStickDir(UI::EventParams &e); + UI::EventReturn OnOpenMemStick(UI::EventParams &e); #if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) UI::EventReturn OnSavePathMydoc(UI::EventParams &e); UI::EventReturn OnSavePathOther(UI::EventParams &e);