From bb2ba8086b306ca735450824ba2bff446027af48 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 21 May 2019 23:22:56 +0200 Subject: [PATCH] Improved Show in Folder: - Not spawning cmd.exe anymore, rather using the same way Chromium does to spawn a shell window with a file focused - Hid a nonfunctional "Show In Folder" button for UWP builds --- Qt/QtMain.cpp | 4 ++++ SDL/SDLMain.cpp | 10 ++++++++++ UI/GameScreen.cpp | 7 ++----- UWP/PPSSPP_UWPMain.cpp | 4 ++++ Windows/main.cpp | 9 +++++++++ android/jni/app-android.cpp | 4 ++++ ext/native/base/NativeApp.h | 1 + ios/ViewController.mm | 4 ++++ 8 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index f8cafb0bc6..cdef67f0a8 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -149,6 +149,10 @@ void Vibrate(int length_ms) { length_ms = 25; } +void OpenDirectory(const char *path) { + // Unsupported +} + void LaunchBrowser(const char *url) { QDesktopServices::openUrl(QUrl(url)); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index b653c1ae57..08d4b7adb0 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -126,6 +126,16 @@ void System_SendMessage(const char *command, const char *parameter) { void System_AskForPermission(SystemPermission permission) {} PermissionStatus System_GetPermissionStatus(SystemPermission permission) { return PERMISSION_STATUS_GRANTED; } +void OpenDirectory(const char *path) { +#if defined(_WIN32) + PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str()); + if (pidl) { + SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); + ILFree(pidl); + } +#endif +} + void LaunchBrowser(const char *url) { #if defined(MOBILE_DEVICE) ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 250977b329..b48ef1c7d4 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -134,7 +134,7 @@ void GameScreen::CreateViews() { if (isRecentGame(gamePath_)) { rightColumnItems->Add(AddOtherChoice(new Choice(ga->T("Remove From Recent"))))->OnClick.Handle(this, &GameScreen::OnRemoveFromRecent); } -#ifdef _WIN32 +#if 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) { @@ -261,10 +261,7 @@ void GameScreen::render() { } UI::EventReturn GameScreen::OnShowInFolder(UI::EventParams &e) { -#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) - std::string str = std::string("explorer.exe /select,\"") + ReplaceAll(gamePath_, "/", "\\") + "\""; - _wsystem(ConvertUTF8ToWString(str).c_str()); -#endif + OpenDirectory(gamePath_.c_str()); return UI::EVENT_DONE; } diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 4819f79534..2ff75df9e1 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -432,6 +432,10 @@ void System_SendMessage(const char *command, const char *parameter) { } } +void OpenDirectory(const char *path) { + // Unsupported +} + void LaunchBrowser(const char *url) { auto uri = ref new Windows::Foundation::Uri(ToPlatformString(url)); diff --git a/Windows/main.cpp b/Windows/main.cpp index d59eb688a2..b7052c13b1 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include "base/NativeApp.h" @@ -97,6 +98,14 @@ static std::string gpuDriverVersion; HMENU g_hPopupMenus; int g_activeWindow = 0; +void OpenDirectory(const char *path) { + PIDLIST_ABSOLUTE pidl = ILCreateFromPath(ConvertUTF8ToWString(ReplaceAll(path, "/", "\\")).c_str()); + if (pidl) { + SHOpenFolderAndSelectItems(pidl, 0, NULL, 0); + ILFree(pidl); + } +} + void LaunchBrowser(const char *url) { ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL); } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index e638d7e2a8..c61acb745e 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -247,6 +247,10 @@ void Vibrate(int length_ms) { PushCommand("vibrate", temp); } +void OpenDirectory(const char *path) { + // Unsupported +} + void LaunchBrowser(const char *url) { PushCommand("launchBrowser", url); } diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 39638436ab..87978dea4d 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -114,6 +114,7 @@ enum { HAPTIC_LONG_PRESS_ACTIVATED = -3, }; void Vibrate(int length_ms); +void OpenDirectory(const char *path); void LaunchBrowser(const char *url); void LaunchMarket(const char *url); void LaunchEmail(const char *email_address); diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 720963df6d..5eba171e2b 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -693,6 +693,10 @@ static GraphicsContext *graphicsContext; @end +void OpenDirectory(const char *path) { + // Unsupported +} + void LaunchBrowser(char const* url) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithCString:url encoding:NSStringEncodingConversionAllowLossy]]];