From b80df6c36001ce8165a22813eef266d123cd099a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 22 Nov 2022 14:16:24 +0100 Subject: [PATCH] Add transparent background to the existing Display Layout Editor. --- UI/DisplayLayoutScreen.cpp | 5 ++++- UI/DisplayLayoutScreen.h | 5 ++--- UI/EmuScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 10 ++++------ UI/GameSettingsScreen.h | 1 - UI/MiscScreens.cpp | 4 ++-- UI/MiscScreens.h | 1 + UI/PauseScreen.cpp | 9 +++++++++ 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index e2ea500884..881eb9b262 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -90,9 +90,12 @@ std::string DragDropDisplay::DescribeText() const { return u->T("Screen representation"); } -DisplayLayoutScreen::DisplayLayoutScreen() { +DisplayLayoutScreen::DisplayLayoutScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename) { // Ignore insets - just couldn't get the logic to work. ignoreInsets_ = true; + + // Show background at full brightness + darkenGameBackground_ = false; } bool DisplayLayoutScreen::touch(const TouchInput &touch) { diff --git a/UI/DisplayLayoutScreen.h b/UI/DisplayLayoutScreen.h index 06730742d4..6fc613f574 100644 --- a/UI/DisplayLayoutScreen.h +++ b/UI/DisplayLayoutScreen.h @@ -23,9 +23,9 @@ class DragDropDisplay; -class DisplayLayoutScreen : public UIDialogScreenWithBackground { +class DisplayLayoutScreen : public UIDialogScreenWithGameBackground { public: - DisplayLayoutScreen(); + DisplayLayoutScreen(const Path &filename); virtual void CreateViews() override; virtual bool touch(const TouchInput &touch) override; virtual void dialogFinished(const Screen *dialog, DialogResult result) override; @@ -49,5 +49,4 @@ private: float startScale_ = 1.0f; int offsetTouchX_ = 0; int offsetTouchY_ = 0; - }; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 2571e2fd23..a0b898663c 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -489,7 +489,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) { screenManager()->push(new ControlMappingScreen()); } else if (!strcmp(message, "display layout editor") && screenManager()->topScreen() == this) { UpdateUIState(UISTATE_PAUSEMENU); - screenManager()->push(new DisplayLayoutScreen()); + screenManager()->push(new DisplayLayoutScreen(gamePath_)); } else if (!strcmp(message, "settings") && screenManager()->topScreen() == this) { UpdateUIState(UISTATE_PAUSEMENU); screenManager()->push(new GameSettingsScreen(gamePath_)); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index d3d2e60202..f22627e100 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -463,7 +463,10 @@ void GameSettingsScreen::CreateViews() { #endif // Display Layout Editor: To avoid overlapping touch controls on large tablets, meet geeky demands for integer zoom/unstretched image etc. displayEditor_ = graphicsSettings->Add(new Choice(gr->T("Display layout editor"))); - displayEditor_->OnClick.Handle(this, &GameSettingsScreen::OnDisplayLayoutEditor); + displayEditor_->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { + screenManager()->push(new DisplayLayoutScreen(gamePath_)); + return UI::EVENT_DONE; + }); #if PPSSPP_PLATFORM(ANDROID) // Hide insets option if no insets, or OS too old. @@ -1332,11 +1335,6 @@ UI::EventReturn GameSettingsScreen::OnFullscreenMultiChange(UI::EventParams &e) return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnDisplayLayoutEditor(UI::EventParams &e) { - screenManager()->push(new DisplayLayoutScreen()); - return UI::EVENT_DONE; -}; - UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) { if (g_Config.iAndroidHwScale == 1) { RecreateActivity(); diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 2fd7d6e59d..5dbe9a682f 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -105,7 +105,6 @@ private: UI::EventReturn OnChangeBackground(UI::EventParams &e); UI::EventReturn OnFullscreenChange(UI::EventParams &e); UI::EventReturn OnFullscreenMultiChange(UI::EventParams &e); - UI::EventReturn OnDisplayLayoutEditor(UI::EventParams &e); UI::EventReturn OnResolutionChange(UI::EventParams &e); UI::EventReturn OnHwScaleChange(UI::EventParams &e); UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index f26562157e..487effe1b4 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -419,7 +419,7 @@ void HandleCommonMessages(const char *message, const char *value, ScreenManager manager->push(new ControlMappingScreen()); } else if (!strcmp(message, "display layout editor") && isActiveScreen && std::string(activeScreen->tag()) != "DisplayLayout") { UpdateUIState(UISTATE_MENU); - manager->push(new DisplayLayoutScreen()); + manager->push(new DisplayLayoutScreen(Path())); } else if (!strcmp(message, "settings") && isActiveScreen && std::string(activeScreen->tag()) != "GameSettings") { UpdateUIState(UISTATE_MENU); manager->push(new GameSettingsScreen(Path())); @@ -474,7 +474,7 @@ void UIDialogScreenWithGameBackground::DrawBackground(UIContext &dc) { using namespace Draw; float x, y, z; screenManager()->getFocusPosition(x, y, z); - DrawGameBackground(dc, gamePath_, x, y, z, true); + DrawGameBackground(dc, gamePath_, x, y, z, darkenGameBackground_); } void UIDialogScreenWithGameBackground::sendMessage(const char *message, const char *value) { diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 216def14f7..2790f85c37 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -73,6 +73,7 @@ public: void sendMessage(const char *message, const char *value) override; protected: Path gamePath_; + bool darkenGameBackground_ = true; }; class PromptScreen : public UIDialogScreenWithBackground { diff --git a/UI/PauseScreen.cpp b/UI/PauseScreen.cpp index 929e0d1d7d..c45d6b7920 100644 --- a/UI/PauseScreen.cpp +++ b/UI/PauseScreen.cpp @@ -49,6 +49,7 @@ #include "UI/MainScreen.h" #include "UI/OnScreenDisplay.h" #include "UI/GameInfoCache.h" +#include "UI/DisplayLayoutScreen.h" static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) { if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) { @@ -260,6 +261,7 @@ void GamePauseScreen::CreateViews() { static const int NUM_SAVESLOTS = 5; using namespace UI; + Margins scrollMargins(0, 20, 0, 0); Margins actionMenuMargins(0, 20, 15, 0); auto gr = GetI18NCategory("Graphics"); @@ -314,6 +316,8 @@ void GamePauseScreen::CreateViews() { root_->SetDefaultFocusView(continueChoice); continueChoice->OnClick.Handle(this, &UIScreen::OnBack); + rightColumnItems->Add(new Spacer(25.0)); + std::string gameId = g_paramSFO.GetDiscID(); if (g_Config.hasGameConfig(gameId)) { rightColumnItems->Add(new Choice(pa->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); @@ -322,6 +326,11 @@ void GamePauseScreen::CreateViews() { rightColumnItems->Add(new Choice(pa->T("Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); rightColumnItems->Add(new Choice(pa->T("Create Game Config")))->OnClick.Handle(this, &GamePauseScreen::OnCreateConfig); } + UI::Choice *displayEditor_ = rightColumnItems->Add(new Choice(gr->T("Display layout editor"))); + displayEditor_->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { + screenManager()->push(new DisplayLayoutScreen(gamePath_)); + return UI::EVENT_DONE; + }); if (g_Config.bEnableCheats) { rightColumnItems->Add(new Choice(pa->T("Cheats")))->OnClick.Handle(this, &GamePauseScreen::OnCwCheat); }