From 8474c8e8b1102aa92a3ed957b7e842c61953cc2b 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/GameSettingsScreen.cpp | 3 ++- UI/MiscScreens.cpp | 13 +++++++++---- UI/MiscScreens.h | 5 ++++- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index ad93c3aef23a..820ab1d9290d 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 64d17da3a1d5..60a148d4e34a 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -276,6 +276,7 @@ struct Config { float fGameGridScale; bool bShowOnScreenMessages; int iBackgroundAnimation; // enum BackgroundAnimation + bool bTransparentBackground; std::string sThemeName; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 32c71aedf90e..8bb2e4cf13e0 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 d1dbb2dd1bad..fef1fae1b990 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 f91cfa6bfeef..c55a24a72558 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -52,7 +52,8 @@ class UIScreenWithGameBackground : public UIScreenWithBackground { protected: Path gamePath_; - bool darkenGameBackground_ = false; + bool forceTransparent_ = false; + bool darkenGameBackground_ = true; }; class UIDialogScreenWithBackground : public UIDialogScreen { @@ -73,6 +74,8 @@ class UIDialogScreenWithGameBackground : public UIDialogScreenWithBackground { void sendMessage(const char *message, const char *value) override; protected: Path gamePath_; + + bool forceTransparent_ = false; bool darkenGameBackground_ = true; };