mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55: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);
|
ImGui::SetNextWindowBgAlpha(alpha);
|
||||||
|
|
||||||
|
// See note in FullscreenUI::DrawSettingsWindow().
|
||||||
|
if (ImGuiFullscreen::IsFocusResetFromWindowChange())
|
||||||
|
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||||
|
|
||||||
if (ImGuiFullscreen::BeginFullscreenWindow(
|
if (ImGuiFullscreen::BeginFullscreenWindow(
|
||||||
ImVec2(0.0f, heading_height),
|
ImVec2(0.0f, heading_height),
|
||||||
ImVec2(display_size.x, display_size.y - heading_height - LayoutScale(ImGuiFullscreen::LAYOUT_FOOTER_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::BeginMenuButtons();
|
||||||
|
ImGuiFullscreen::ResetFocusHere();
|
||||||
|
|
||||||
for (u32 bucket_type : {RC_CLIENT_ACHIEVEMENT_BUCKET_ACTIVE_CHALLENGE,
|
for (u32 bucket_type : {RC_CLIENT_ACHIEVEMENT_BUCKET_ACTIVE_CHALLENGE,
|
||||||
RC_CLIENT_ACHIEVEMENT_BUCKET_RECENTLY_UNLOCKED, RC_CLIENT_ACHIEVEMENT_BUCKET_UNLOCKED,
|
RC_CLIENT_ACHIEVEMENT_BUCKET_RECENTLY_UNLOCKED, RC_CLIENT_ACHIEVEMENT_BUCKET_UNLOCKED,
|
||||||
|
@ -2853,6 +2858,7 @@ void Achievements::DrawLeaderboardsWindow()
|
||||||
ImGui::IsKeyPressed(ImGuiKey_NavGamepadTweakFast, false))
|
ImGui::IsKeyPressed(ImGuiKey_NavGamepadTweakFast, false))
|
||||||
{
|
{
|
||||||
s_is_showing_all_leaderboard_entries = !s_is_showing_all_leaderboard_entries;
|
s_is_showing_all_leaderboard_entries = !s_is_showing_all_leaderboard_entries;
|
||||||
|
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const bool show_all : {false, true})
|
for (const bool show_all : {false, true})
|
||||||
|
@ -2928,6 +2934,10 @@ void Achievements::DrawLeaderboardsWindow()
|
||||||
ImGuiFullscreen::EndFullscreenWindow();
|
ImGuiFullscreen::EndFullscreenWindow();
|
||||||
FullscreenUI::SetStandardSelectionFooterText(true);
|
FullscreenUI::SetStandardSelectionFooterText(true);
|
||||||
|
|
||||||
|
// See note in FullscreenUI::DrawSettingsWindow().
|
||||||
|
if (ImGuiFullscreen::IsFocusResetFromWindowChange())
|
||||||
|
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||||
|
|
||||||
if (!is_leaderboard_open)
|
if (!is_leaderboard_open)
|
||||||
{
|
{
|
||||||
if (ImGuiFullscreen::BeginFullscreenWindow(
|
if (ImGuiFullscreen::BeginFullscreenWindow(
|
||||||
|
@ -2936,6 +2946,7 @@ void Achievements::DrawLeaderboardsWindow()
|
||||||
"leaderboards", background, 0.0f, ImVec2(ImGuiFullscreen::LAYOUT_MENU_WINDOW_X_PADDING, 0.0f), 0))
|
"leaderboards", background, 0.0f, ImVec2(ImGuiFullscreen::LAYOUT_MENU_WINDOW_X_PADDING, 0.0f), 0))
|
||||||
{
|
{
|
||||||
ImGuiFullscreen::BeginMenuButtons();
|
ImGuiFullscreen::BeginMenuButtons();
|
||||||
|
ImGuiFullscreen::ResetFocusHere();
|
||||||
|
|
||||||
for (u32 bucket_index = 0; bucket_index < s_leaderboard_list->num_buckets; bucket_index++)
|
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)
|
if (s_leaderboard_nearby_entries)
|
||||||
{
|
{
|
||||||
|
ImGuiFullscreen::ResetFocusHere();
|
||||||
|
|
||||||
for (u32 i = 0; i < s_leaderboard_nearby_entries->num_entries; i++)
|
for (u32 i = 0; i < s_leaderboard_nearby_entries->num_entries; i++)
|
||||||
{
|
{
|
||||||
DrawLeaderboardEntry(s_leaderboard_nearby_entries->entries[i],
|
DrawLeaderboardEntry(s_leaderboard_nearby_entries->entries[i],
|
||||||
|
@ -2983,6 +2996,9 @@ void Achievements::DrawLeaderboardsWindow()
|
||||||
}
|
}
|
||||||
else
|
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 (const rc_client_leaderboard_entry_list_t* list : s_leaderboard_entry_lists)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < list->num_entries; i++)
|
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_is_showing_all_leaderboard_entries = false;
|
||||||
s_leaderboard_fetch_handle = rc_client_begin_fetch_leaderboard_entries_around_user(
|
s_leaderboard_fetch_handle = rc_client_begin_fetch_leaderboard_entries_around_user(
|
||||||
s_client, lboard->id, LEADERBOARD_NEARBY_ENTRIES_TO_FETCH, LeaderboardFetchNearbyCallback, nullptr);
|
s_client, lboard->id, LEADERBOARD_NEARBY_ENTRIES_TO_FETCH, LeaderboardFetchNearbyCallback, nullptr);
|
||||||
|
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Achievements::OpenLeaderboardById(u32 leaderboard_id)
|
bool Achievements::OpenLeaderboardById(u32 leaderboard_id)
|
||||||
|
@ -3259,6 +3276,7 @@ void Achievements::CloseLeaderboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
s_open_leaderboard = nullptr;
|
s_open_leaderboard = nullptr;
|
||||||
|
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_RAINTEGRATION
|
#ifdef ENABLE_RAINTEGRATION
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
// 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 "fullscreen_ui.h"
|
||||||
#include "achievements.h"
|
#include "achievements.h"
|
||||||
|
@ -124,9 +124,9 @@ using ImGuiFullscreen::ForceKeyNavEnabled;
|
||||||
using ImGuiFullscreen::GetCachedTexture;
|
using ImGuiFullscreen::GetCachedTexture;
|
||||||
using ImGuiFullscreen::GetCachedTextureAsync;
|
using ImGuiFullscreen::GetCachedTextureAsync;
|
||||||
using ImGuiFullscreen::GetPlaceholderTexture;
|
using ImGuiFullscreen::GetPlaceholderTexture;
|
||||||
using ImGuiFullscreen::GetQueuedFocusResetType;
|
|
||||||
using ImGuiFullscreen::HorizontalMenuItem;
|
using ImGuiFullscreen::HorizontalMenuItem;
|
||||||
using ImGuiFullscreen::IsFocusResetQueued;
|
using ImGuiFullscreen::IsFocusResetQueued;
|
||||||
|
using ImGuiFullscreen::IsFocusResetFromWindowChange;
|
||||||
using ImGuiFullscreen::IsGamepadInputSource;
|
using ImGuiFullscreen::IsGamepadInputSource;
|
||||||
using ImGuiFullscreen::LayoutScale;
|
using ImGuiFullscreen::LayoutScale;
|
||||||
using ImGuiFullscreen::LoadTexture;
|
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.
|
// 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
|
// don't do it for popups opening/closing, otherwise we lose our position
|
||||||
if (FocusResetType focus_reset = GetQueuedFocusResetType(); focus_reset != FocusResetType::None &&
|
if (IsFocusResetFromWindowChange())
|
||||||
focus_reset != FocusResetType::PopupOpened &&
|
|
||||||
focus_reset != FocusResetType::PopupClosed)
|
|
||||||
{
|
|
||||||
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
ImGui::SetNextWindowScroll(ImVec2(0.0f, 0.0f));
|
||||||
}
|
|
||||||
|
|
||||||
if (BeginFullscreenWindow(
|
if (BeginFullscreenWindow(
|
||||||
ImVec2(0.0f, heading_size.y),
|
ImVec2(0.0f, heading_size.y),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
// 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
|
#pragma once
|
||||||
|
|
||||||
|
|
|
@ -604,6 +604,12 @@ bool ImGuiFullscreen::IsFocusResetQueued()
|
||||||
return (s_focus_reset_queued != FocusResetType::None);
|
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()
|
ImGuiFullscreen::FocusResetType ImGuiFullscreen::GetQueuedFocusResetType()
|
||||||
{
|
{
|
||||||
return s_focus_reset_queued;
|
return s_focus_reset_queued;
|
||||||
|
@ -1940,6 +1946,7 @@ bool ImGuiFullscreen::NavTab(const char* title, bool is_active, bool enabled /*
|
||||||
hovered ? ImGui::GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, 1.0f) :
|
hovered ? ImGui::GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered, 1.0f) :
|
||||||
ImGui::GetColorU32(is_active ? background : ImVec4(background.x, background.y, background.z, 0.5f));
|
ImGui::GetColorU32(is_active ? background : ImVec4(background.x, background.y, background.z, 0.5f));
|
||||||
|
|
||||||
|
if (hovered)
|
||||||
DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f);
|
DrawMenuButtonFrame(bb.Min, bb.Max, col, true, 0.0f);
|
||||||
|
|
||||||
if (is_active)
|
if (is_active)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
// 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
|
#pragma once
|
||||||
|
|
||||||
|
@ -153,6 +153,7 @@ enum class FocusResetType : u8
|
||||||
void QueueResetFocus(FocusResetType type);
|
void QueueResetFocus(FocusResetType type);
|
||||||
bool ResetFocusHere();
|
bool ResetFocusHere();
|
||||||
bool IsFocusResetQueued();
|
bool IsFocusResetQueued();
|
||||||
|
bool IsFocusResetFromWindowChange();
|
||||||
FocusResetType GetQueuedFocusResetType();
|
FocusResetType GetQueuedFocusResetType();
|
||||||
void ForceKeyNavEnabled();
|
void ForceKeyNavEnabled();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue