mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
FullscreenUI: Untangle Escape button behaviour
Now it doesn't race against Open Pause Menu
This commit is contained in:
parent
4d89b52d3b
commit
3040ce7bbd
|
@ -628,6 +628,8 @@ void FullscreenUI::Render()
|
|||
GetEditingSettingsInterface()->Save();
|
||||
Host::RunOnCPUThread([]() { System::ApplySettings(false); });
|
||||
}
|
||||
|
||||
ImGuiFullscreen::ResetCloseMenuIfNeeded();
|
||||
}
|
||||
|
||||
void FullscreenUI::ReturnToMainWindow()
|
||||
|
@ -2066,7 +2068,7 @@ void FullscreenUI::DrawSettingsWindow()
|
|||
{
|
||||
ResetFocusHere();
|
||||
|
||||
if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed))
|
||||
if (WantsToCloseMenu())
|
||||
{
|
||||
if (ImGui::IsWindowFocused())
|
||||
ReturnToMainWindow();
|
||||
|
|
|
@ -474,18 +474,26 @@ bool ImGuiFullscreen::WantsToCloseMenu()
|
|||
// Wait for the Close button to be released, THEN pressed
|
||||
if (s_close_button_state == 0)
|
||||
{
|
||||
if (!IsCancelButtonPressed())
|
||||
if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed))
|
||||
s_close_button_state = 1;
|
||||
}
|
||||
else if (s_close_button_state == 1)
|
||||
{
|
||||
if (IsCancelButtonPressed())
|
||||
if (ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Released))
|
||||
{
|
||||
s_close_button_state = 0;
|
||||
return true;
|
||||
s_close_button_state = 2;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return s_close_button_state > 1;
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::ResetCloseMenuIfNeeded()
|
||||
{
|
||||
// If s_close_button_state reached the "Released" state, reset it after the tick
|
||||
if (s_close_button_state > 1)
|
||||
{
|
||||
s_close_button_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiFullscreen::PushPrimaryColor()
|
||||
|
@ -516,11 +524,6 @@ void ImGuiFullscreen::PopSecondaryColor()
|
|||
ImGui::PopStyleColor(5);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::IsCancelButtonPressed()
|
||||
{
|
||||
return ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiNavReadMode_Pressed);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::BeginFullscreenColumns(const char* title)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(g_layout_padding_left, 0.0f));
|
||||
|
@ -1639,7 +1642,7 @@ void ImGuiFullscreen::DrawFileSelector()
|
|||
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor);
|
||||
|
||||
bool is_open = !IsCancelButtonPressed();
|
||||
bool is_open = !WantsToCloseMenu();
|
||||
bool directory_selected = false;
|
||||
if (ImGui::BeginPopupModal(s_file_selector_title.c_str(), &is_open,
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
|
||||
|
@ -1759,7 +1762,7 @@ void ImGuiFullscreen::DrawChoiceDialog()
|
|||
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor);
|
||||
ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor);
|
||||
|
||||
bool is_open = !IsCancelButtonPressed();
|
||||
bool is_open = !WantsToCloseMenu();
|
||||
s32 choice = -1;
|
||||
|
||||
if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open,
|
||||
|
|
|
@ -128,14 +128,13 @@ void EndLayout();
|
|||
void QueueResetFocus();
|
||||
bool ResetFocusHere();
|
||||
bool WantsToCloseMenu();
|
||||
void ResetCloseMenuIfNeeded();
|
||||
|
||||
void PushPrimaryColor();
|
||||
void PopPrimaryColor();
|
||||
void PushSecondaryColor();
|
||||
void PopSecondaryColor();
|
||||
|
||||
bool IsCancelButtonPressed();
|
||||
|
||||
void DrawWindowTitle(const char* title);
|
||||
|
||||
bool BeginFullscreenColumns(const char* title = nullptr);
|
||||
|
|
Loading…
Reference in a new issue