mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-18 11:55:38 +00:00
FullscreenUI: Close menus on Cancel button edge only
Now requires the button to be released, THEN pressed
This commit is contained in:
parent
3849ec449b
commit
435a848559
|
@ -62,7 +62,6 @@ using ImGuiFullscreen::EndFullscreenWindow;
|
||||||
using ImGuiFullscreen::EndMenuButtons;
|
using ImGuiFullscreen::EndMenuButtons;
|
||||||
using ImGuiFullscreen::EnumChoiceButton;
|
using ImGuiFullscreen::EnumChoiceButton;
|
||||||
using ImGuiFullscreen::FloatingButton;
|
using ImGuiFullscreen::FloatingButton;
|
||||||
using ImGuiFullscreen::IsCancelButtonPressed;
|
|
||||||
using ImGuiFullscreen::LayoutScale;
|
using ImGuiFullscreen::LayoutScale;
|
||||||
using ImGuiFullscreen::MenuButton;
|
using ImGuiFullscreen::MenuButton;
|
||||||
using ImGuiFullscreen::MenuButtonFrame;
|
using ImGuiFullscreen::MenuButtonFrame;
|
||||||
|
@ -110,6 +109,7 @@ static bool s_debug_menu_allowed = false;
|
||||||
static bool s_quick_menu_was_open = false;
|
static bool s_quick_menu_was_open = false;
|
||||||
static bool s_was_paused_on_quick_menu_open = false;
|
static bool s_was_paused_on_quick_menu_open = false;
|
||||||
static bool s_about_window_open = false;
|
static bool s_about_window_open = false;
|
||||||
|
static u32 s_close_button_state = 0;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Resources
|
// Resources
|
||||||
|
@ -357,6 +357,7 @@ void SaveAndApplySettings()
|
||||||
void ClearImGuiFocus()
|
void ClearImGuiFocus()
|
||||||
{
|
{
|
||||||
ImGui::SetWindowFocus(nullptr);
|
ImGui::SetWindowFocus(nullptr);
|
||||||
|
s_close_button_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReturnToMainWindow()
|
void ReturnToMainWindow()
|
||||||
|
@ -1179,6 +1180,25 @@ static bool ConfirmChallengeModeEnable()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool WantsToCloseMenu()
|
||||||
|
{
|
||||||
|
// Wait for the Close button to be released, THEN pressed
|
||||||
|
if (s_close_button_state == 0)
|
||||||
|
{
|
||||||
|
if (!ImGuiFullscreen::IsCancelButtonPressed())
|
||||||
|
s_close_button_state = 1;
|
||||||
|
}
|
||||||
|
else if (s_close_button_state == 1)
|
||||||
|
{
|
||||||
|
if (ImGuiFullscreen::IsCancelButtonPressed())
|
||||||
|
{
|
||||||
|
s_close_button_state = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void DrawSettingsWindow()
|
void DrawSettingsWindow()
|
||||||
{
|
{
|
||||||
BeginFullscreenColumns();
|
BeginFullscreenColumns();
|
||||||
|
@ -1201,7 +1221,7 @@ void DrawSettingsWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SetCursorPosY(ImGui::GetWindowHeight() - LayoutScale(50.0f));
|
ImGui::SetCursorPosY(ImGui::GetWindowHeight() - LayoutScale(50.0f));
|
||||||
if (ActiveButton(ICON_FA_BACKWARD " Back", false) || IsCancelButtonPressed())
|
if (ActiveButton(ICON_FA_BACKWARD " Back", false) || WantsToCloseMenu())
|
||||||
ReturnToMainWindow();
|
ReturnToMainWindow();
|
||||||
|
|
||||||
EndMenuButtons();
|
EndMenuButtons();
|
||||||
|
@ -2346,7 +2366,7 @@ void DrawQuickMenu(MainWindowType type)
|
||||||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING,
|
ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING,
|
||||||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||||
|
|
||||||
if (ActiveButton(ICON_FA_PLAY " Resume Game", false) || IsCancelButtonPressed())
|
if (ActiveButton(ICON_FA_PLAY " Resume Game", false) || WantsToCloseMenu())
|
||||||
CloseQuickMenu();
|
CloseQuickMenu();
|
||||||
|
|
||||||
if (ActiveButton(ICON_FA_FAST_FORWARD " Fast Forward", false))
|
if (ActiveButton(ICON_FA_FAST_FORWARD " Fast Forward", false))
|
||||||
|
@ -2610,7 +2630,7 @@ void DrawSaveStateSelector(bool is_loading, bool fullscreen)
|
||||||
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f));
|
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f));
|
||||||
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||||
ImGui::OpenPopup(window_title);
|
ImGui::OpenPopup(window_title);
|
||||||
bool is_open = !IsCancelButtonPressed();
|
bool is_open = !WantsToCloseMenu();
|
||||||
if (!ImGui::BeginPopupModal(window_title, &is_open,
|
if (!ImGui::BeginPopupModal(window_title, &is_open,
|
||||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove) ||
|
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove) ||
|
||||||
!is_open)
|
!is_open)
|
||||||
|
@ -3945,7 +3965,7 @@ void DrawAchievementWindow()
|
||||||
const u32 total_points = Cheevos::GetMaximumPointsForGame();
|
const u32 total_points = Cheevos::GetMaximumPointsForGame();
|
||||||
|
|
||||||
if (FloatingButton(ICON_FA_WINDOW_CLOSE, 10.0f, 10.0f, -1.0f, -1.0f, 1.0f, 0.0f, true, g_large_font) ||
|
if (FloatingButton(ICON_FA_WINDOW_CLOSE, 10.0f, 10.0f, -1.0f, -1.0f, 1.0f, 0.0f, true, g_large_font) ||
|
||||||
IsCancelButtonPressed())
|
WantsToCloseMenu())
|
||||||
{
|
{
|
||||||
ReturnToMainWindow();
|
ReturnToMainWindow();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue