mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 20:15:32 +00:00
FullscreenUI: Fade alpha change when switching to postfx settings
This commit is contained in:
parent
ffef0c2e38
commit
884459d1cf
@ -280,6 +280,7 @@ static void DrawAdvancedSettingsPage();
|
|||||||
static void DrawPatchesOrCheatsSettingsPage(bool cheats);
|
static void DrawPatchesOrCheatsSettingsPage(bool cheats);
|
||||||
|
|
||||||
static bool ShouldShowAdvancedSettings();
|
static bool ShouldShowAdvancedSettings();
|
||||||
|
static float GetSettingsWindowBgAlpha();
|
||||||
static bool IsEditingGameSettings(SettingsInterface* bsi);
|
static bool IsEditingGameSettings(SettingsInterface* bsi);
|
||||||
static SettingsInterface* GetEditingSettingsInterface();
|
static SettingsInterface* GetEditingSettingsInterface();
|
||||||
static SettingsInterface* GetEditingSettingsInterface(bool game_settings);
|
static SettingsInterface* GetEditingSettingsInterface(bool game_settings);
|
||||||
@ -442,6 +443,7 @@ struct ALIGN_TO_CACHE_LINE UIState
|
|||||||
std::shared_ptr<GPUTexture> fallback_playlist_texture;
|
std::shared_ptr<GPUTexture> fallback_playlist_texture;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
float settings_last_bg_alpha = 1.0f;
|
||||||
SettingsPage settings_page = SettingsPage::Interface;
|
SettingsPage settings_page = SettingsPage::Interface;
|
||||||
std::unique_ptr<INISettingsInterface> game_settings_interface;
|
std::unique_ptr<INISettingsInterface> game_settings_interface;
|
||||||
const GameDatabase::Entry* game_settings_db_entry;
|
const GameDatabase::Entry* game_settings_db_entry;
|
||||||
@ -1597,6 +1599,11 @@ bool FullscreenUI::ShouldShowAdvancedSettings()
|
|||||||
return Host::GetBaseBoolSettingValue("Main", "ShowDebugMenu", false);
|
return Host::GetBaseBoolSettingValue("Main", "ShowDebugMenu", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float FullscreenUI::GetSettingsWindowBgAlpha()
|
||||||
|
{
|
||||||
|
return GPUThread::HasGPUBackend() ? (s_state.settings_page == SettingsPage::PostProcessing ? 0.50f : 0.90f) : 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
bool FullscreenUI::IsEditingGameSettings(SettingsInterface* bsi)
|
bool FullscreenUI::IsEditingGameSettings(SettingsInterface* bsi)
|
||||||
{
|
{
|
||||||
return (bsi == s_state.game_settings_interface.get());
|
return (bsi == s_state.game_settings_interface.get());
|
||||||
@ -2798,6 +2805,7 @@ void FullscreenUI::SwitchToSettings()
|
|||||||
|
|
||||||
s_state.current_main_window = MainWindowType::Settings;
|
s_state.current_main_window = MainWindowType::Settings;
|
||||||
s_state.settings_page = SettingsPage::Interface;
|
s_state.settings_page = SettingsPage::Interface;
|
||||||
|
s_state.settings_last_bg_alpha = GetSettingsWindowBgAlpha();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::SwitchToGameSettingsForSerial(std::string_view serial)
|
void FullscreenUI::SwitchToGameSettingsForSerial(std::string_view serial)
|
||||||
@ -2917,11 +2925,14 @@ void FullscreenUI::DrawSettingsWindow()
|
|||||||
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
ImVec2(io.DisplaySize.x, LayoutScale(LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY) +
|
||||||
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
(LayoutScale(LAYOUT_MENU_BUTTON_Y_PADDING) * 2.0f) + LayoutScale(2.0f));
|
||||||
|
|
||||||
const float bg_alpha =
|
const float target_bg_alpha = GetSettingsWindowBgAlpha();
|
||||||
GPUThread::HasGPUBackend() ? (s_state.settings_page == SettingsPage::PostProcessing ? 0.50f : 0.90f) : 1.0f;
|
s_state.settings_last_bg_alpha = (target_bg_alpha < s_state.settings_last_bg_alpha) ?
|
||||||
|
std::max(s_state.settings_last_bg_alpha - io.DeltaTime * 2.0f, target_bg_alpha) :
|
||||||
|
std::min(s_state.settings_last_bg_alpha + io.DeltaTime * 2.0f, target_bg_alpha);
|
||||||
|
|
||||||
if (BeginFullscreenWindow(ImVec2(0.0f, 0.0f), heading_size, "settings_category",
|
if (BeginFullscreenWindow(
|
||||||
ImVec4(UIStyle.PrimaryColor.x, UIStyle.PrimaryColor.y, UIStyle.PrimaryColor.z, bg_alpha)))
|
ImVec2(0.0f, 0.0f), heading_size, "settings_category",
|
||||||
|
ImVec4(UIStyle.PrimaryColor.x, UIStyle.PrimaryColor.y, UIStyle.PrimaryColor.z, s_state.settings_last_bg_alpha)))
|
||||||
{
|
{
|
||||||
static constexpr float ITEM_WIDTH = 25.0f;
|
static constexpr float ITEM_WIDTH = 25.0f;
|
||||||
|
|
||||||
@ -3020,8 +3031,9 @@ void FullscreenUI::DrawSettingsWindow()
|
|||||||
ImVec2(0.0f, heading_size.y),
|
ImVec2(0.0f, heading_size.y),
|
||||||
ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT)),
|
ImVec2(io.DisplaySize.x, io.DisplaySize.y - heading_size.y - LayoutScale(LAYOUT_FOOTER_HEIGHT)),
|
||||||
TinyString::from_format("settings_page_{}", static_cast<u32>(s_state.settings_page)).c_str(),
|
TinyString::from_format("settings_page_{}", static_cast<u32>(s_state.settings_page)).c_str(),
|
||||||
ImVec4(UIStyle.BackgroundColor.x, UIStyle.BackgroundColor.y, UIStyle.BackgroundColor.z, bg_alpha), 0.0f,
|
ImVec4(UIStyle.BackgroundColor.x, UIStyle.BackgroundColor.y, UIStyle.BackgroundColor.z,
|
||||||
ImVec2(ImGuiFullscreen::LAYOUT_MENU_WINDOW_X_PADDING, 0.0f)))
|
s_state.settings_last_bg_alpha),
|
||||||
|
0.0f, ImVec2(ImGuiFullscreen::LAYOUT_MENU_WINDOW_X_PADDING, 0.0f)))
|
||||||
{
|
{
|
||||||
ResetFocusHere();
|
ResetFocusHere();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user