mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-07 03:55:33 +00:00
FullscreenUI: Fix consecutive choice dialogs
This commit is contained in:
parent
2d31bf5685
commit
4e2872f248
@ -18,9 +18,9 @@
|
|||||||
#include "common/threading.h"
|
#include "common/threading.h"
|
||||||
#include "common/timer.h"
|
#include "common/timer.h"
|
||||||
|
|
||||||
|
#include "core/fullscreen_ui.h" // For updating run idle state.
|
||||||
#include "core/host.h"
|
#include "core/host.h"
|
||||||
#include "core/system.h" // For async workers, should be in general host.
|
#include "core/system.h" // For async workers, should be in general host.
|
||||||
#include "core/fullscreen_ui.h" // For updating run idle state.
|
|
||||||
|
|
||||||
#include "fmt/core.h"
|
#include "fmt/core.h"
|
||||||
|
|
||||||
@ -2397,23 +2397,17 @@ void ImGuiFullscreen::PopupDialog::SetTitleAndOpen(std::string title)
|
|||||||
{
|
{
|
||||||
DebugAssert(!title.empty());
|
DebugAssert(!title.empty());
|
||||||
m_title = std::move(title);
|
m_title = std::move(title);
|
||||||
|
m_animation_time_remaining = OPEN_TIME;
|
||||||
|
|
||||||
if (m_state == State::Inactive)
|
if (m_state == State::Inactive)
|
||||||
{
|
{
|
||||||
// inactive -> active
|
// inactive -> active
|
||||||
m_state = State::OpeningTrigger;
|
m_state = State::OpeningTrigger;
|
||||||
m_animation_time_remaining = OPEN_TIME;
|
|
||||||
QueueResetFocus(FocusResetType::PopupOpened);
|
|
||||||
}
|
}
|
||||||
else if (m_state == State::Closing)
|
else
|
||||||
{
|
{
|
||||||
// cancel close
|
// we need to close under the old name, and reopen under the new
|
||||||
m_state = State::Opening;
|
m_state = State::Reopening;
|
||||||
}
|
|
||||||
else if (m_state == State::ClosingTrigger)
|
|
||||||
{
|
|
||||||
// prevent from closing
|
|
||||||
m_state = State::Open;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2441,6 +2435,20 @@ bool ImGuiFullscreen::PopupDialog::BeginRender(float scaled_window_padding /* =
|
|||||||
{
|
{
|
||||||
DebugAssert(IsOpen());
|
DebugAssert(IsOpen());
|
||||||
|
|
||||||
|
// reopening is messy...
|
||||||
|
if (m_state == State::Reopening) [[unlikely]]
|
||||||
|
{
|
||||||
|
// close it under the old name
|
||||||
|
if (ImGui::IsPopupOpen(ImGui::GetCurrentWindowRead()->GetID(m_title.c_str(), m_title.c_str() + m_title.length()),
|
||||||
|
ImGuiPopupFlags_None))
|
||||||
|
{
|
||||||
|
ImGui::ClosePopupToLevel(GImGui->OpenPopupStack.Size, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// and open under the new name
|
||||||
|
m_state = State::OpeningTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
// check for animation completion
|
// check for animation completion
|
||||||
ImVec2 pos_offset = ImVec2(0.0f, 0.0f);
|
ImVec2 pos_offset = ImVec2(0.0f, 0.0f);
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
@ -2467,6 +2475,7 @@ bool ImGuiFullscreen::PopupDialog::BeginRender(float scaled_window_padding /* =
|
|||||||
// need to have the openpopup at the correct level
|
// need to have the openpopup at the correct level
|
||||||
m_state = State::Opening;
|
m_state = State::Opening;
|
||||||
ImGui::OpenPopup(m_title.c_str());
|
ImGui::OpenPopup(m_title.c_str());
|
||||||
|
QueueResetFocus(FocusResetType::PopupOpened);
|
||||||
}
|
}
|
||||||
|
|
||||||
// inhibit menu animation while opening, otherwise it jitters
|
// inhibit menu animation while opening, otherwise it jitters
|
||||||
|
@ -442,6 +442,7 @@ protected:
|
|||||||
OpeningTrigger,
|
OpeningTrigger,
|
||||||
Opening,
|
Opening,
|
||||||
Closing,
|
Closing,
|
||||||
|
Reopening,
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr float OPEN_TIME = 0.2f;
|
static constexpr float OPEN_TIME = 0.2f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user