From 3053f763f6b9f431017c25da436b537fe7fb5573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 16 Dec 2022 09:09:21 +0100 Subject: [PATCH] Add setting for transparent UI background Fixes #16593 --- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/DisplayLayoutScreen.cpp | 1 + UI/GameSettingsScreen.cpp | 3 ++- UI/MiscScreens.cpp | 13 +++++++++---- UI/MiscScreens.h | 5 ++++- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index ad93c3aef2..820ab1d929 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -600,6 +600,7 @@ static ConfigSetting generalSettings[] = { ConfigSetting("InternalScreenRotation", &g_Config.iInternalScreenRotation, ROTATION_LOCKED_HORIZONTAL, true, true), ConfigSetting("BackgroundAnimation", &g_Config.iBackgroundAnimation, 1, true, false), + ConfigSetting("TransparentBackground", &g_Config.bTransparentBackground, true, true, false), ConfigSetting("UITint", &g_Config.fUITint, 0.0, true, false), ConfigSetting("UISaturation", &g_Config.fUISaturation, &DefaultUISaturation, true, false), diff --git a/Core/Config.h b/Core/Config.h index 64d17da3a1..60a148d4e3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -276,6 +276,7 @@ public: float fGameGridScale; bool bShowOnScreenMessages; int iBackgroundAnimation; // enum BackgroundAnimation + bool bTransparentBackground; std::string sThemeName; diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index ab9dd58d86..54721f58de 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -120,6 +120,7 @@ private: DisplayLayoutScreen::DisplayLayoutScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename) { // Show background at full brightness darkenGameBackground_ = false; + forceTransparent_ = true; } void DisplayLayoutScreen::DrawBackground(UIContext &dc) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 32c71aedf9..8bb2e4cf13 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -882,6 +882,8 @@ void GameSettingsScreen::CreateViews() { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } + systemSettings->Add(new CheckBox(&g_Config.bTransparentBackground, sy->T("Transparent UI background"))); + PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Theme"), GetThemeInfoNames(), th->GetName(), screenManager())); theme->OnChoice.Add([=](EventParams &e) { UpdateTheme(screenManager()->getUIContext()); @@ -889,7 +891,6 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_CONTINUE; }); - if (!draw->GetBugs().Has(Draw::Bugs::RASPBERRY_SHADER_COMP_HANG)) { // We use shaders without tint capability on hardware with this driver bug. PopupSliderChoiceFloat *tint = new PopupSliderChoiceFloat(&g_Config.fUITint, 0.0, 1.0, sy->T("Color Tint"), 0.01f, screenManager()); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d1dbb2dd1b..fef1fae1b9 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -358,11 +358,11 @@ uint32_t GetBackgroundColorWithAlpha(const UIContext &dc) { return colorAlpha(colorBlend(dc.GetTheme().backgroundColor, 0, 0.5f), 0.65f); // 0.65 = 166 = A6 } -void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, float z, bool darkenBackground) { +void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, float z, bool transparent, bool darkenBackground) { using namespace Draw; using namespace UI; - if (PSP_IsInited() && !g_Config.bSkipBufferEffects) { + if (transparent && PSP_IsInited() && !g_Config.bSkipBufferEffects) { gpu->CheckDisplayResized(); gpu->CheckConfigChanged(); gpu->CopyDisplayToOutput(true); @@ -457,7 +457,7 @@ void UIScreenWithGameBackground::DrawBackground(UIContext &dc) { float x, y, z; screenManager()->getFocusPosition(x, y, z); if (!gamePath_.empty()) { - DrawGameBackground(dc, gamePath_, x, y, z, darkenGameBackground_); + DrawGameBackground(dc, gamePath_, x, y, z, (g_Config.bTransparentBackground || forceTransparent_), darkenGameBackground_); } else { ::DrawBackground(dc, 1.0f, x, y, z); dc.Flush(); @@ -477,7 +477,12 @@ void UIDialogScreenWithGameBackground::DrawBackground(UIContext &dc) { using namespace Draw; float x, y, z; screenManager()->getFocusPosition(x, y, z); - DrawGameBackground(dc, gamePath_, x, y, z, darkenGameBackground_); + if (!gamePath_.empty()) { + DrawGameBackground(dc, gamePath_, x, y, z, (g_Config.bTransparentBackground || forceTransparent_), darkenGameBackground_); + } else { + ::DrawBackground(dc, 1.0f, x, y, z); + dc.Flush(); + } } void UIDialogScreenWithGameBackground::sendMessage(const char *message, const char *value) { diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index f91cfa6bfe..c55a24a725 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -52,7 +52,8 @@ public: protected: Path gamePath_; - bool darkenGameBackground_ = false; + bool forceTransparent_ = false; + bool darkenGameBackground_ = true; }; class UIDialogScreenWithBackground : public UIDialogScreen { @@ -73,6 +74,8 @@ public: void sendMessage(const char *message, const char *value) override; protected: Path gamePath_; + + bool forceTransparent_ = false; bool darkenGameBackground_ = true; };