diff --git a/Common/System/System.h b/Common/System/System.h index b08ad08ce1..88e7e1ac3d 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -47,6 +47,7 @@ enum class LaunchUrlType { BROWSER_URL, MARKET_URL, EMAIL_ADDRESS, + LOCAL_FILE, }; void System_Vibrate(int length_ms); diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 15f7cfd13f..a7b84b1aba 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -26,8 +26,7 @@ #include "Common/OSVersion.h" #include -#include -#include +#include // For drag/drop functionality #include #include @@ -37,7 +36,6 @@ #include "Common/TimeUtil.h" #include "Common/StringUtils.h" #include "Common/Data/Text/I18n.h" -#include "Common/Data/Text/Parsers.h" #include "Common/Input/InputState.h" #include "Common/Input/KeyCodes.h" #include "Common/Thread/ThreadUtil.h" @@ -51,12 +49,9 @@ #include "Core/Instance.h" #include "Core/KeyMap.h" #include "Core/MIPS/JitCommon/JitCommon.h" -#include "Core/MIPS/JitCommon/JitBlockCache.h" #include "Core/Reporting.h" -#include "Windows/InputBox.h" #include "Windows/InputDevice.h" #if PPSSPP_API(ANY_GL) -#include "Windows/GPU/WindowsGLContext.h" #include "Windows/GEDebugger/GEDebugger.h" #endif #include "Windows/W32Util/DarkMode.h" @@ -77,17 +72,13 @@ #include "Common/Log/LogManager.h" #include "Common/Log/ConsoleListener.h" #include "Windows/W32Util/DialogManager.h" -#include "Windows/W32Util/ShellUtil.h" #include "Windows/W32Util/Misc.h" #include "Windows/RawInput.h" #include "Windows/CaptureDevice.h" #include "Windows/TouchInputHandler.h" #include "Windows/MainWindowMenu.h" #include "GPU/GPUCommon.h" -#include "UI/OnScreenDisplay.h" -#include "UI/GameSettingsScreen.h" #include "UI/PauseScreen.h" -#include "Core/SaveState.h" #define MOUSEEVENTF_FROMTOUCH_NOPEN 0xFF515780 //http://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx #define MOUSEEVENTF_MASK_PLUS_PENTOUCH 0xFFFFFF80 diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 04773bc645..fd30325bea 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -4,9 +4,6 @@ #include #include -#include "CommonWindows.h" -#include - #include "resource.h" #include "Common/GPU/OpenGL/GLFeatures.h" @@ -15,31 +12,24 @@ #include "Common/Data/Encoding/Utf8.h" #include "Common/System/System.h" #include "Common/System/OSD.h" -#include "Common/System/NativeApp.h" #include "Common/System/Request.h" #include "Common/System/Display.h" #include "Common/File/FileUtil.h" #include "Common/Log.h" #include "Common/Log/LogManager.h" #include "Common/Log/ConsoleListener.h" -#include "Common/OSVersion.h" -#include "Common/GPU/Vulkan/VulkanLoader.h" #include "Common/StringUtils.h" #if PPSSPP_API(ANY_GL) #include "GPU/GLES/TextureCacheGLES.h" #include "GPU/GLES/FramebufferManagerGLES.h" #endif -#include "UI/OnScreenDisplay.h" #include "GPU/Common/PostShader.h" -#include "GPU/Common/FramebufferManagerCommon.h" -#include "GPU/Common/TextureDecoder.h" #include "GPU/Common/TextureScalerCommon.h" #include "Core/Config.h" #include "Core/ConfigValues.h" #include "Core/FileSystems/MetaFileSystem.h" #include "Core/KeyMap.h" -#include "UI/OnScreenDisplay.h" #include "Windows/MainWindowMenu.h" #include "Windows/MainWindow.h" #include "Windows/W32Util/DialogManager.h" @@ -469,7 +459,7 @@ namespace MainWindow { auto gr = GetI18NCategory(I18NCat::GRAPHICS); - int wmId = LOWORD(wParam); + const int wmId = LOWORD(wParam); // Parse the menu selections: switch (wmId) { case ID_FILE_LOAD: @@ -489,7 +479,7 @@ namespace MainWindow { break; case ID_FILE_MEMSTICK: - ShellExecute(NULL, L"open", g_Config.memStickDirectory.ToWString().c_str(), 0, 0, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::LOCAL_FILE, g_Config.memStickDirectory.ToString()); break; case ID_TOGGLE_BREAK: @@ -857,10 +847,10 @@ namespace MainWindow { } else if (info.type == FILETYPE_DIRECTORY) { MessageBox(hWnd, L"Cannot extract directories.", L"Sorry", 0); } else if (W32Util::BrowseForFileName(false, hWnd, L"Save file as...", 0, L"All files\0*.*\0\0", L"", fn)) { - u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ, ""); + const u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ, ""); // Note: len may be in blocks. size_t len = pspFileSystem.SeekFile(handle, 0, FILEMOVE_END); - bool isBlockMode = pspFileSystem.DevType(handle) & PSPDevType::BLOCK; + const bool isBlockMode = pspFileSystem.DevType(handle) & PSPDevType::BLOCK; FILE *fp = File::OpenCFile(Path(fn), "wb"); pspFileSystem.SeekFile(handle, 0, FILEMOVE_BEGIN); @@ -868,11 +858,11 @@ namespace MainWindow { size_t bufferSize = isBlockMode ? sizeof(buffer) / 2048 : sizeof(buffer); while (len > 0) { // This is all in blocks, not bytes, if isBlockMode. - size_t remain = std::min(len, bufferSize); - size_t readSize = pspFileSystem.ReadFile(handle, buffer, remain); + const size_t remain = std::min(len, bufferSize); + const size_t readSize = pspFileSystem.ReadFile(handle, buffer, remain); if (readSize == 0) break; - size_t bytes = isBlockMode ? readSize * 2048 : readSize; + const size_t bytes = isBlockMode ? readSize * 2048 : readSize; fwrite(buffer, 1, bytes, fp); len -= readSize; } @@ -938,23 +928,23 @@ namespace MainWindow { break; case ID_HELP_OPENWEBSITE: - ShellExecute(NULL, L"open", L"https://www.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/"); break; case ID_HELP_BUYGOLD: - ShellExecute(NULL, L"open", L"https://www.ppsspp.org/buygold", NULL, NULL, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://www.ppsspp.org/buygold"); break; case ID_HELP_OPENFORUM: - ShellExecute(NULL, L"open", L"https://forums.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://forums.ppsspp.org/"); break; case ID_HELP_GITHUB: - ShellExecute(NULL, L"open", L"https://github.com/hrydgard/ppsspp/", NULL, NULL, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://github.com/hrydgard/ppsspp/"); break; case ID_HELP_DISCORD: - ShellExecute(NULL, L"open", L"https://discord.gg/5NJB6dD", NULL, NULL, SW_SHOWNORMAL); + System_LaunchUrl(LaunchUrlType::BROWSER_URL, "https://discord.gg/5NJB6dD"); break; case ID_HELP_ABOUT: diff --git a/Windows/W32Util/ShellUtil.h b/Windows/W32Util/ShellUtil.h index 1874a2d0ea..697148d448 100644 --- a/Windows/W32Util/ShellUtil.h +++ b/Windows/W32Util/ShellUtil.h @@ -3,7 +3,6 @@ #include #include #include -#include class Path; diff --git a/Windows/main.cpp b/Windows/main.cpp index 04fe408a8d..cd836bee74 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -132,6 +132,7 @@ static double g_lastKeepAwake = 0.0; static constexpr double ACTIVITY_IDLE_TIMEOUT = 2.0 * 3600.0; void System_LaunchUrl(LaunchUrlType urlType, std::string_view url) { + // We don't even check urlType. std::string u(url); std::thread t = std::thread([u]() { ShellExecute(NULL, L"open", ConvertUTF8ToWString(u).c_str(), NULL, NULL, SW_SHOWNORMAL); @@ -141,7 +142,8 @@ void System_LaunchUrl(LaunchUrlType urlType, std::string_view url) { } void System_Vibrate(int length_ms) { - // Ignore on PC + // Ignore on PC. TODO: Actually, we could vibrate a controller if we wanted to, but we should only do that + // if it was used within the last few seconds. } static void AddDebugRestartArgs() {