Windows: Add option to browse for bg image.

And also to clear the image.
This commit is contained in:
Unknown W. Brackets 2017-04-02 10:50:09 -07:00
parent 55908588eb
commit e59ebf8ad9
10 changed files with 91 additions and 9 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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.

View File

@ -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
#endif

View File

@ -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<int, std::string> 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;

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -153,6 +153,7 @@ enum SystemProperty {
SYSPROP_GPUDRIVER_VERSION,
SYSPROP_HAS_FILE_BROWSER,
SYSPROP_HAS_IMAGE_BROWSER,
SYSPROP_HAS_BACK_BUTTON,
// Available as Int: