Skip to content

Commit

Permalink
Add setting for transparent UI background
Browse files Browse the repository at this point in the history
Fixes #16593
  • Loading branch information
hrydgard committed Dec 16, 2022
1 parent 8ed87d4 commit 8474c8e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ struct Config {
float fGameGridScale;
bool bShowOnScreenMessages;
int iBackgroundAnimation; // enum BackgroundAnimation
bool bTransparentBackground;

std::string sThemeName;

Expand Down
3 changes: 2 additions & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,14 +882,15 @@ 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());

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());
Expand Down
13 changes: 9 additions & 4 deletions UI/MiscScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion UI/MiscScreens.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class UIScreenWithGameBackground : public UIScreenWithBackground {
protected:
Path gamePath_;

bool darkenGameBackground_ = false;
bool forceTransparent_ = false;
bool darkenGameBackground_ = true;
};

class UIDialogScreenWithBackground : public UIDialogScreen {
Expand All @@ -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;
};

Expand Down

0 comments on commit 8474c8e

Please sign in to comment.