Add setting for transparent UI background

Fixes #16593
This commit is contained in:
Henrik Rydgård 2022-12-16 09:09:21 +01:00
parent 8ed87d48e3
commit 3053f763f6
6 changed files with 18 additions and 6 deletions

View file

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

View file

@ -276,6 +276,7 @@ public:
float fGameGridScale;
bool bShowOnScreenMessages;
int iBackgroundAnimation; // enum BackgroundAnimation
bool bTransparentBackground;
std::string sThemeName;

View file

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

View file

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

View file

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

View file

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