mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 05:45:38 +00:00
Achievements: Reset focus when opening windows
This commit is contained in:
parent
66e7e16e8e
commit
b6e2869dce
|
@ -2467,6 +2467,10 @@ void Achievements::DrawAchievementsWindow()
|
|||
|
||||
ImGui::SetNextWindowBgAlpha(alpha);
|
||||
|
||||
// See note in FullscreenUI::DrawSettingsWindow().
|
||||
if (ImGuiFullscreen::IsFocusResetFromWindowChange())
|
||||
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||
|
||||
if (ImGuiFullscreen::BeginFullscreenWindow(
|
||||
ImVec2(0.0f, heading_height),
|
||||
ImVec2(display_size.x, display_size.y - heading_height - LayoutScale(ImGuiFullscreen::LAYOUT_FOOTER_HEIGHT)),
|
||||
|
@ -2481,6 +2485,7 @@ void Achievements::DrawAchievementsWindow()
|
|||
};
|
||||
|
||||
ImGuiFullscreen::BeginMenuButtons();
|
||||
ImGuiFullscreen::ResetFocusHere();
|
||||
|
||||
for (u32 bucket_type : {RC_CLIENT_ACHIEVEMENT_BUCKET_ACTIVE_CHALLENGE,
|
||||
RC_CLIENT_ACHIEVEMENT_BUCKET_RECENTLY_UNLOCKED, RC_CLIENT_ACHIEVEMENT_BUCKET_UNLOCKED,
|
||||
|
@ -2853,6 +2858,7 @@ void Achievements::DrawLeaderboardsWindow()
|
|||
ImGui::IsKeyPressed(ImGuiKey_NavGamepadTweakFast, false))
|
||||
{
|
||||
s_is_showing_all_leaderboard_entries = !s_is_showing_all_leaderboard_entries;
|
||||
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||
}
|
||||
|
||||
for (const bool show_all : {false, true})
|
||||
|
@ -2928,6 +2934,10 @@ void Achievements::DrawLeaderboardsWindow()
|
|||
ImGuiFullscreen::EndFullscreenWindow();
|
||||
FullscreenUI::SetStandardSelectionFooterText(true);
|
||||
|
||||
// See note in FullscreenUI::DrawSettingsWindow().
|
||||
if (ImGuiFullscreen::IsFocusResetFromWindowChange())
|
||||
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||
|
||||
if (!is_leaderboard_open)
|
||||
{
|
||||
if (ImGuiFullscreen::BeginFullscreenWindow(
|
||||
|
@ -2936,6 +2946,7 @@ void Achievements::DrawLeaderboardsWindow()
|
|||
"leaderboards", background, 0.0f, ImVec2(ImGuiFullscreen::LAYOUT_MENU_WINDOW_X_PADDING, 0.0f), 0))
|
||||
{
|
||||
ImGuiFullscreen::BeginMenuButtons();
|
||||
ImGuiFullscreen::ResetFocusHere();
|
||||
|
||||
for (u32 bucket_index = 0; bucket_index < s_leaderboard_list->num_buckets; bucket_index++)
|
||||
{
|
||||
|
@ -2961,6 +2972,8 @@ void Achievements::DrawLeaderboardsWindow()
|
|||
{
|
||||
if (s_leaderboard_nearby_entries)
|
||||
{
|
||||
ImGuiFullscreen::ResetFocusHere();
|
||||
|
||||
for (u32 i = 0; i < s_leaderboard_nearby_entries->num_entries; i++)
|
||||
{
|
||||
DrawLeaderboardEntry(s_leaderboard_nearby_entries->entries[i],
|
||||
|
@ -2983,6 +2996,9 @@ void Achievements::DrawLeaderboardsWindow()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (ImGuiFullscreen::IsFocusResetFromWindowChange() && !s_leaderboard_entry_lists.empty())
|
||||
ImGuiFullscreen::ResetFocusHere();
|
||||
|
||||
for (const rc_client_leaderboard_entry_list_t* list : s_leaderboard_entry_lists)
|
||||
{
|
||||
for (u32 i = 0; i < list->num_entries; i++)
|
||||
|
@ -3154,6 +3170,7 @@ void Achievements::OpenLeaderboard(const rc_client_leaderboard_t* lboard)
|
|||
s_is_showing_all_leaderboard_entries = false;
|
||||
s_leaderboard_fetch_handle = rc_client_begin_fetch_leaderboard_entries_around_user(
|
||||
s_client, lboard->id, LEADERBOARD_NEARBY_ENTRIES_TO_FETCH, LeaderboardFetchNearbyCallback, nullptr);
|
||||
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||
}
|
||||
|
||||
bool Achievements::OpenLeaderboardById(u32 leaderboard_id)
|
||||
|
@ -3259,6 +3276,7 @@ void Achievements::CloseLeaderboard()
|
|||
}
|
||||
|
||||
s_open_leaderboard = nullptr;
|
||||
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RAINTEGRATION
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR PolyForm-Strict-1.0.0)
|
||||
|
||||
#include "fullscreen_ui.h"
|
||||
#include "achievements.h"
|
||||
|
@ -124,9 +124,9 @@ using ImGuiFullscreen::ForceKeyNavEnabled;
|
|||
using ImGuiFullscreen::GetCachedTexture;
|
||||
using ImGuiFullscreen::GetCachedTextureAsync;
|
||||
using ImGuiFullscreen::GetPlaceholderTexture;
|
||||
using ImGuiFullscreen::GetQueuedFocusResetType;
|
||||
using ImGuiFullscreen::HorizontalMenuItem;
|
||||
using ImGuiFullscreen::IsFocusResetQueued;
|
||||
using ImGuiFullscreen::IsFocusResetFromWindowChange;
|
||||
using ImGuiFullscreen::IsGamepadInputSource;
|
||||
using ImGuiFullscreen::LayoutScale;
|
||||
using ImGuiFullscreen::LoadTexture;
|
||||
|
@ -2917,12 +2917,8 @@ void FullscreenUI::DrawSettingsWindow()
|
|||
|
||||
// we have to do this here, because otherwise it uses target, and jumps a frame later.
|
||||
// don't do it for popups opening/closing, otherwise we lose our position
|
||||
if (FocusResetType focus_reset = GetQueuedFocusResetType(); focus_reset != FocusResetType::None &&
|
||||
focus_reset != FocusResetType::PopupOpened &&
|
||||
focus_reset != FocusResetType::PopupClosed)
|
||||
{
|
||||
if (IsFocusResetFromWindowChange())
|
||||
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||
}
|
||||
|
||||
if (BeginFullscreenWindow(
|
||||
ImVec2(0.0f, heading_size.y),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR PolyForm-Strict-1.0.0)
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -604,6 +604,12 @@ bool ImGuiFullscreen::IsFocusResetQueued()
|
|||
return (s_focus_reset_queued != FocusResetType::None);
|
||||
}
|
||||
|
||||
bool ImGuiFullscreen::IsFocusResetFromWindowChange()
|
||||
{
|
||||
return (s_focus_reset_queued != FocusResetType::None && s_focus_reset_queued != FocusResetType::PopupOpened &&
|
||||
s_focus_reset_queued != FocusResetType::PopupClosed);
|
||||
}
|
||||
|
||||
ImGuiFullscreen::FocusResetType ImGuiFullscreen::GetQueuedFocusResetType()
|
||||
{
|
||||
return s_focus_reset_queued;
|
||||
|
@ -1940,7 +1946,8 @@ bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /*
|
|||
hovered ? ImGui::GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, 1.0f) :
|
||||
ImGui::GetColorU32(is_active ? background : ImVec4(background.x, background.y, background.z, 0.5f));
|
||||
|
||||
DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f);
|
||||
if (hovered)
|
||||
DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f);
|
||||
|
||||
if (is_active)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR PolyForm-Strict-1.0.0)
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -153,6 +153,7 @@ enum class FocusResetType : u8
|
|||
void QueueResetFocus(FocusResetType type);
|
||||
bool ResetFocusHere();
|
||||
bool IsFocusResetQueued();
|
||||
bool IsFocusResetFromWindowChange();
|
||||
FocusResetType GetQueuedFocusResetType();
|
||||
void ForceKeyNavEnabled();
|
||||
|
||||
|
|
Loading…
Reference in a new issue