Added an option to disable the blurring of the background when opening menus.

This commit is contained in:
Leon Styhre 2021-03-18 19:46:45 +01:00
parent 06f88093c6
commit a46222030c
3 changed files with 43 additions and 20 deletions

View file

@ -331,6 +331,19 @@ void GuiMenu::openUISettings()
s->setNeedsSaving();
}
});
// Blur background when the menu is open.
auto menu_blur_background = std::make_shared<SwitchComponent>(mWindow);
menu_blur_background->setState(Settings::getInstance()->getBool("MenuBlurBackground"));
s->addWithLabel("BLUR BACKGROUND WHEN MENU IS OPEN", menu_blur_background);
s->addSaveFunc([menu_blur_background, s] {
if (menu_blur_background->getState() !=
Settings::getInstance()->getBool("MenuBlurBackground")) {
Settings::getInstance()->setBool("MenuBlurBackground",
menu_blur_background->getState());
s->setNeedsSaving();
}
});
#endif
// Display pillarboxes (and letterboxes) for videos in the gamelists.

View file

@ -116,6 +116,7 @@ void Settings::setDefaults()
mStringMap["UIMode"] = { "full", "full" };
mStringMap["DefaultSortOrder"] = { "filename, ascending", "filename, ascending" };
mStringMap["MenuOpeningEffect"] = { "scale-up", "scale-up" };
mBoolMap["MenuBlurBackground"] = { true, true };
mBoolMap["GamelistVideoPillarbox"] = { true, true };
mBoolMap["GamelistVideoScanlines"] = { true, true };
mBoolMap["FoldersOnTop"] = { true, true };

View file

@ -333,29 +333,38 @@ void Window::render()
// Defocus the background using multiple passes of gaussian blur, with the number
// of iterations relative to the screen resolution.
Renderer::shaderParameters backgroundParameters;
float heightModifier = Renderer::getScreenHeightModifier();
if (heightModifier < 1)
backgroundParameters.blurPasses = 2; // Below 1080
else if (heightModifier >= 4)
backgroundParameters.blurPasses = 12; // 8K
else if (heightModifier >= 2.9)
backgroundParameters.blurPasses = 10; // 6K
else if (heightModifier >= 2.6)
backgroundParameters.blurPasses = 8; // 5K
else if (heightModifier >= 2)
backgroundParameters.blurPasses = 5; // 4K
else if (heightModifier >= 1.3)
backgroundParameters.blurPasses = 3; // 1440
else if (heightModifier >= 1)
backgroundParameters.blurPasses = 2; // 1080
if (Settings::getInstance()->getBool("MenuBlurBackground")) {
float heightModifier = Renderer::getScreenHeightModifier();
// Also dim the background slightly.
backgroundParameters.fragmentDimValue = 0.60f;
if (heightModifier < 1)
backgroundParameters.blurPasses = 2; // Below 1080
else if (heightModifier >= 4)
backgroundParameters.blurPasses = 12; // 8K
else if (heightModifier >= 2.9)
backgroundParameters.blurPasses = 10; // 6K
else if (heightModifier >= 2.6)
backgroundParameters.blurPasses = 8; // 5K
else if (heightModifier >= 2)
backgroundParameters.blurPasses = 5; // 4K
else if (heightModifier >= 1.3)
backgroundParameters.blurPasses = 3; // 1440
else if (heightModifier >= 1)
backgroundParameters.blurPasses = 2; // 1080
Renderer::shaderPostprocessing(Renderer::SHADER_BLUR_HORIZONTAL |
Renderer::SHADER_BLUR_VERTICAL | Renderer::SHADER_DIM,
backgroundParameters, processedTexture);
// Also dim the background slightly.
backgroundParameters.fragmentDimValue = 0.60f;
Renderer::shaderPostprocessing(Renderer::SHADER_BLUR_HORIZONTAL |
Renderer::SHADER_BLUR_VERTICAL | Renderer::SHADER_DIM,
backgroundParameters, processedTexture);
}
else {
// Dim the background slightly.
backgroundParameters.fragmentDimValue = 0.60f;
Renderer::shaderPostprocessing(
Renderer::SHADER_DIM, backgroundParameters, processedTexture);
}
mPostprocessedBackground->initFromPixels(processedTexture,
Renderer::getScreenWidth(), Renderer::getScreenHeight());