diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index faa67c5c9c..6ba78a0b47 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -77,9 +77,6 @@ #if !PPSSPP_PLATFORM(UWP) #include "gfx/gl_common.h" #endif -#if !PPSSPP_PLATFORM(UWP) -#include "gfx/gl_common.h" -#endif #ifndef MOBILE_DEVICE AVIDump avi; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 2fec1774cb..87be377c97 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -667,6 +667,20 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new CheckBox(&g_Config.bCheckForNewVersion, sy->T("VersionCheck", "Check for new versions of PPSSPP"))); if (g_Config.iMaxRecent > 0) systemSettings->Add(new Choice(sy->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents); + + const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png"; + const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg"; + if (File::Exists(bgPng) || File::Exists(bgJpg)) { + backgroundChoice_ = systemSettings->Add(new Choice(sy->T("Clear UI background"))); + } else if (System_GetPropertyInt(SYSPROP_HAS_IMAGE_BROWSER)) { + backgroundChoice_ = systemSettings->Add(new Choice(sy->T("Set UI background..."))); + } else { + backgroundChoice_ = nullptr; + } + if (backgroundChoice_ != nullptr) { + backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); + } + systemSettings->Add(new Choice(sy->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings); systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, sy->T("Auto Load Newest Savestate"))); @@ -908,6 +922,29 @@ UI::EventReturn GameSettingsScreen::OnClearRecents(UI::EventParams &e) { return UI::EVENT_DONE; } +UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) { + const std::string bgPng = GetSysDirectory(DIRECTORY_SYSTEM) + "background.png"; + const std::string bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg"; + if (File::Exists(bgPng) || File::Exists(bgJpg)) { + if (File::Exists(bgPng)) { + File::Delete(bgPng); + } + if (File::Exists(bgJpg)) { + File::Delete(bgJpg); + } + + NativeMessageReceived("bgImage_updated", ""); + } else { + if (System_GetPropertyInt(SYSPROP_HAS_IMAGE_BROWSER)) { + System_SendMessage("bgImage_browse", ""); + } + } + + // Change to a browse or clear button. + RecreateViews(); + return UI::EVENT_DONE; +} + UI::EventReturn GameSettingsScreen::OnReloadCheats(UI::EventParams &e) { // Hmm, strange mechanism. g_Config.bReloadCheats = true; diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 6ed2a8542e..196dd04309 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -47,6 +47,7 @@ private: UI::Choice *layoutEditorChoice_; UI::Choice *postProcChoice_; UI::Choice *displayEditor_; + UI::Choice *backgroundChoice_ = nullptr; UI::PopupMultiChoice *resolutionChoice_; UI::CheckBox *frameSkipAuto_; SettingInfoMessage *settingInfo_; @@ -79,6 +80,7 @@ private: UI::EventReturn OnChangeproAdhocServerAddress(UI::EventParams &e); UI::EventReturn OnChangeMacAddress(UI::EventParams &e); UI::EventReturn OnClearRecents(UI::EventParams &e); + UI::EventReturn OnChangeBackground(UI::EventParams &e); UI::EventReturn OnFullscreenChange(UI::EventParams &e); UI::EventReturn OnDisplayLayoutEditor(UI::EventParams &e); UI::EventReturn OnResolutionChange(UI::EventParams &e); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index a8fbe806ea..eed5eeada3 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -977,11 +977,11 @@ UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) { g_Config.Save(); screenManager()->switchScreen(new EmuScreen(fileName.toStdString())); } -#elif PPSSPP_PLATFORM(UWP) - System_SendMessage("browse_file", ""); -#elif defined(USING_WIN_UI) - MainWindow::BrowseAndBoot(""); #endif + + if (System_GetPropertyInt(SYSPROP_HAS_FILE_BROWSER)) { + System_SendMessage("browse_file", ""); + } return UI::EVENT_DONE; } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 3990a249fd..1e7012ccfe 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -875,6 +875,10 @@ namespace MainWindow BrowseAndBootDone(); break; + case WM_USER_BROWSE_BG_DONE: + BrowseBackgroundDone(); + break; + case WM_MENUSELECT: // Unfortunately, accelerate keys (hotkeys) shares the same enabled/disabled states // with corresponding menu items. diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index 17d8a8651e..48eb344d38 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -16,6 +16,7 @@ namespace MainWindow enum { WM_USER_SAVESTATE_FINISH = WM_USER + 100, WM_USER_UPDATE_UI = WM_USER + 101, + WM_USER_BROWSE_BG_DONE = WM_USER + 102, WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103, WM_USER_BROWSE_BOOT_DONE = WM_USER + 104, WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105, @@ -74,4 +75,4 @@ namespace MainWindow void SetWindowSize(int zoom); } -#endif \ No newline at end of file +#endif diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 2b88acc7c1..dc408b7687 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -41,6 +41,7 @@ namespace MainWindow { static const int numCPUs = 1; // what? extern bool noFocusPause; static W32Util::AsyncBrowseDialog *browseDialog; + static W32Util::AsyncBrowseDialog *browseImageDialog; static bool browsePauseAfter; static std::map initialMenuKeys; @@ -399,6 +400,37 @@ namespace MainWindow { browseDialog = 0; } + void BrowseBackground() { + static std::wstring filter = L"All supported images (*.jpg *.png)|*.jpg;*.png|All files (*.*)|*.*||"; + for (size_t i = 0; i < filter.length(); i++) { + if (filter[i] == '|') + filter[i] = '\0'; + } + + W32Util::MakeTopMost(GetHWND(), false); + browseImageDialog = new W32Util::AsyncBrowseDialog(W32Util::AsyncBrowseDialog::OPEN, GetHWND(), WM_USER_BROWSE_BG_DONE, L"LoadFile", L"", filter, L"*.jpg;*.png;"); + } + + void BrowseBackgroundDone() { + std::string filename; + if (browseImageDialog->GetResult(filename)) { + std::wstring src = ConvertUTF8ToWString(filename); + std::wstring dest; + if (filename.size() >= 4 && filename.substr(filename.size() - 4) == ".jpg") { + dest = ConvertUTF8ToWString(GetSysDirectory(DIRECTORY_SYSTEM) + "background.jpg"); + } else { + dest = ConvertUTF8ToWString(GetSysDirectory(DIRECTORY_SYSTEM) + "background.png"); + } + + CopyFileW(src.c_str(), dest.c_str(), FALSE); + NativeMessageReceived("bgImage_updated", ""); + } + + W32Util::MakeTopMost(GetHWND(), g_Config.bTopMost); + + delete browseImageDialog; + browseImageDialog = nullptr; + } static void UmdSwitchAction() { std::string fn; diff --git a/Windows/MainWindowMenu.h b/Windows/MainWindowMenu.h index 03e04baf18..01115aee41 100644 --- a/Windows/MainWindowMenu.h +++ b/Windows/MainWindowMenu.h @@ -9,5 +9,7 @@ namespace MainWindow { void TranslateMenus(HWND hWnd, HMENU menu); void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false); void BrowseAndBootDone(); + void BrowseBackground(); + void BrowseBackgroundDone(); void setTexScalingMultiplier(int level); } diff --git a/Windows/main.cpp b/Windows/main.cpp index bf77d68fcb..c84275e0a4 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -213,7 +213,9 @@ int System_GetPropertyInt(SystemProperty prop) { case SYSPROP_DISPLAY_DPI: return ScreenDPI(); case SYSPROP_HAS_FILE_BROWSER: - return true; + return 1; + case SYSPROP_HAS_IMAGE_BROWSER: + return 1; case SYSPROP_HAS_BACK_BUTTON: return 1; default: @@ -235,6 +237,10 @@ void System_SendMessage(const char *command, const char *parameter) { GlobalFree(handle); CloseClipboard(); } + } else if (!strcmp(command, "browse_file")) { + MainWindow::BrowseAndBoot(""); + } else if (!strcmp(command, "bgImage_browse")) { + MainWindow::BrowseBackground(); } } diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 6de2e92ed2..1b1191a4a4 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -153,6 +153,7 @@ enum SystemProperty { SYSPROP_GPUDRIVER_VERSION, SYSPROP_HAS_FILE_BROWSER, + SYSPROP_HAS_IMAGE_BROWSER, SYSPROP_HAS_BACK_BUTTON, // Available as Int: