FullscreenUI: Make achievements/settings/load state closable with controller
This commit is contained in:
parent
99ff0e64c5
commit
738bf9be9f
|
@ -62,6 +62,7 @@ using ImGuiFullscreen::EndFullscreenWindow;
|
|||
using ImGuiFullscreen::EndMenuButtons;
|
||||
using ImGuiFullscreen::EnumChoiceButton;
|
||||
using ImGuiFullscreen::FloatingButton;
|
||||
using ImGuiFullscreen::IsCancelButtonPressed;
|
||||
using ImGuiFullscreen::LayoutScale;
|
||||
using ImGuiFullscreen::MenuButton;
|
||||
using ImGuiFullscreen::MenuButtonFrame;
|
||||
|
@ -1087,7 +1088,7 @@ void DrawSettingsWindow()
|
|||
}
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetWindowHeight() - LayoutScale(50.0f));
|
||||
if (ActiveButton(ICON_FA_BACKWARD " Back", false))
|
||||
if (ActiveButton(ICON_FA_BACKWARD " Back", false) || IsCancelButtonPressed())
|
||||
ReturnToMainWindow();
|
||||
|
||||
EndMenuButtons();
|
||||
|
@ -2194,7 +2195,7 @@ void DrawQuickMenu(MainWindowType type)
|
|||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING,
|
||||
ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY);
|
||||
|
||||
if (ActiveButton(ICON_FA_PLAY " Resume Game", false))
|
||||
if (ActiveButton(ICON_FA_PLAY " Resume Game", false) || IsCancelButtonPressed())
|
||||
CloseQuickMenu();
|
||||
|
||||
if (ActiveButton(ICON_FA_FAST_FORWARD " Fast Forward", false))
|
||||
|
@ -2458,7 +2459,7 @@ void DrawSaveStateSelector(bool is_loading, bool fullscreen)
|
|||
ImGui::SetNextWindowSize(LayoutScale(1000.0f, 680.0f));
|
||||
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::OpenPopup(window_title);
|
||||
bool is_open = true;
|
||||
bool is_open = !IsCancelButtonPressed();
|
||||
if (!ImGui::BeginPopupModal(window_title, &is_open,
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove) ||
|
||||
!is_open)
|
||||
|
@ -3802,28 +3803,11 @@ void DrawAchievementWindow()
|
|||
const u32 current_points = Cheevos::GetCurrentPointsForGame();
|
||||
const u32 total_points = Cheevos::GetMaximumPointsForGame();
|
||||
|
||||
text.Format(ICON_FA_TIMES);
|
||||
text_size = g_large_font->CalcTextSizeA(g_large_font->FontSize, right, -1.0f, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength());
|
||||
const ImRect close_button_bb(ImVec2(right - padding - text_size.x, top), ImVec2(right, top + text_size.y));
|
||||
|
||||
bool close_held, close_hovered;
|
||||
bool close_clicked = ImGui::ButtonBehavior(close_button_bb, ImGui::GetCurrentWindow()->GetID("close_button"),
|
||||
&close_hovered, &close_held);
|
||||
if (close_clicked)
|
||||
if (FloatingButton(ICON_FA_WINDOW_CLOSE, 10.0f, 10.0f, -1.0f, -1.0f, 1.0f, 0.0f, true, g_large_font) ||
|
||||
IsCancelButtonPressed())
|
||||
{
|
||||
ReturnToMainWindow();
|
||||
}
|
||||
else if (close_hovered || close_held)
|
||||
{
|
||||
const ImU32 col = ImGui::GetColorU32(close_held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, alpha);
|
||||
ImGui::RenderFrame(close_button_bb.Min, close_button_bb.Max, col, true, 0.0f);
|
||||
}
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::RenderTextClipped(close_button_bb.Min, close_button_bb.Max, text.GetCharArray(),
|
||||
text.GetCharArray() + text.GetLength(), nullptr, ImVec2(0.0f, 0.0f), &close_button_bb);
|
||||
ImGui::PopFont();
|
||||
|
||||
const ImRect title_bb(ImVec2(left, top), ImVec2(right, top + g_large_font->FontSize));
|
||||
text.Assign(Cheevos::GetGameTitle());
|
||||
|
@ -3887,9 +3871,8 @@ void DrawAchievementWindow()
|
|||
|
||||
static bool unlocked_achievements_collapsed = false;
|
||||
|
||||
unlocked_achievements_collapsed ^=
|
||||
MenuHeadingButton("Unlocked Achievements",
|
||||
unlocked_achievements_collapsed ? ICON_FA_CHEVRON_DOWN : ICON_FA_CHEVRON_UP);
|
||||
unlocked_achievements_collapsed ^= MenuHeadingButton(
|
||||
"Unlocked Achievements", unlocked_achievements_collapsed ? ICON_FA_CHEVRON_DOWN : ICON_FA_CHEVRON_UP);
|
||||
if (!unlocked_achievements_collapsed)
|
||||
{
|
||||
Cheevos::EnumerateAchievements([](const Cheevos::Achievement& cheevo) -> bool {
|
||||
|
|
|
@ -234,6 +234,11 @@ void EndLayout()
|
|||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
bool IsCancelButtonPressed()
|
||||
{
|
||||
return ImGui::IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed);
|
||||
}
|
||||
|
||||
bool BeginFullscreenColumns(const char* title)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImVec2(g_layout_padding_left, s_menu_bar_size));
|
||||
|
@ -1135,7 +1140,7 @@ void DrawFileSelector()
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||
LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
|
||||
bool is_open = (ImGui::GetNavInputAmount(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed) < 1.0f);
|
||||
bool is_open = !IsCancelButtonPressed();
|
||||
bool directory_selected = false;
|
||||
if (ImGui::BeginPopupModal(s_file_selector_title.c_str(), &is_open,
|
||||
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
|
||||
|
@ -1251,7 +1256,7 @@ void DrawChoiceDialog()
|
|||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
|
||||
LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
|
||||
bool is_open = (ImGui::GetNavInputAmount(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed) < 1.0f);
|
||||
bool is_open = !IsCancelButtonPressed();
|
||||
s32 choice = -1;
|
||||
|
||||
if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open,
|
||||
|
|
|
@ -154,6 +154,8 @@ bool UpdateLayoutScale();
|
|||
void BeginLayout();
|
||||
void EndLayout();
|
||||
|
||||
bool IsCancelButtonPressed();
|
||||
|
||||
void DrawWindowTitle(const char* title);
|
||||
|
||||
bool BeginFullscreenColumns(const char* title = nullptr);
|
||||
|
|
Loading…
Reference in New Issue