FullscreenUI: Fix CPU/GPU thread race on achievements toggle
This commit is contained in:
parent
26db661a05
commit
6b754e6759
|
@ -2185,12 +2185,7 @@ void Achievements::ConfirmHardcoreModeDisableAsync(const char* trigger, std::fun
|
||||||
|
|
||||||
void Achievements::ClearUIState()
|
void Achievements::ClearUIState()
|
||||||
{
|
{
|
||||||
#ifndef __ANDROID__
|
|
||||||
if (FullscreenUI::IsAchievementsWindowOpen() || FullscreenUI::IsLeaderboardsWindowOpen())
|
|
||||||
FullscreenUI::ReturnToPreviousWindow();
|
|
||||||
|
|
||||||
CloseLeaderboard();
|
CloseLeaderboard();
|
||||||
#endif
|
|
||||||
|
|
||||||
s_state.achievement_badge_paths = {};
|
s_state.achievement_badge_paths = {};
|
||||||
|
|
||||||
|
@ -2470,11 +2465,15 @@ void Achievements::DrawAchievementsWindow()
|
||||||
using ImGuiFullscreen::LayoutScale;
|
using ImGuiFullscreen::LayoutScale;
|
||||||
using ImGuiFullscreen::UIStyle;
|
using ImGuiFullscreen::UIStyle;
|
||||||
|
|
||||||
if (!s_state.achievement_list)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto lock = Achievements::GetLock();
|
auto lock = Achievements::GetLock();
|
||||||
|
|
||||||
|
// achievements can get turned off via the main UI
|
||||||
|
if (!s_state.achievement_list)
|
||||||
|
{
|
||||||
|
FullscreenUI::ReturnToPreviousWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr float alpha = 0.8f;
|
static constexpr float alpha = 0.8f;
|
||||||
static constexpr float heading_alpha = 0.95f;
|
static constexpr float heading_alpha = 0.95f;
|
||||||
static constexpr float heading_height_unscaled = 110.0f;
|
static constexpr float heading_height_unscaled = 110.0f;
|
||||||
|
@ -2846,7 +2845,12 @@ void Achievements::DrawLeaderboardsWindow()
|
||||||
static constexpr float heading_height_unscaled = 110.0f;
|
static constexpr float heading_height_unscaled = 110.0f;
|
||||||
static constexpr float tab_height_unscaled = 50.0f;
|
static constexpr float tab_height_unscaled = 50.0f;
|
||||||
|
|
||||||
auto lock = Achievements::GetLock();
|
const auto lock = Achievements::GetLock();
|
||||||
|
if (!s_state.leaderboard_list)
|
||||||
|
{
|
||||||
|
FullscreenUI::ReturnToPreviousWindow();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const bool is_leaderboard_open = (s_state.open_leaderboard != nullptr);
|
const bool is_leaderboard_open = (s_state.open_leaderboard != nullptr);
|
||||||
bool close_leaderboard_on_exit = false;
|
bool close_leaderboard_on_exit = false;
|
||||||
|
@ -3437,7 +3441,6 @@ void Achievements::CloseLeaderboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
s_state.open_leaderboard = nullptr;
|
s_state.open_leaderboard = nullptr;
|
||||||
ImGuiFullscreen::QueueResetFocus(ImGuiFullscreen::FocusResetType::Other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
|
@ -634,25 +634,7 @@ bool FullscreenUI::AreAnyDialogsOpen()
|
||||||
|
|
||||||
void FullscreenUI::CheckForConfigChanges(const Settings& old_settings)
|
void FullscreenUI::CheckForConfigChanges(const Settings& old_settings)
|
||||||
{
|
{
|
||||||
// NOTE: Called on CPU thread.
|
// NOTE: Called on GPU thread.
|
||||||
if (!IsInitialized())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If achievements got disabled, we might have the menu open...
|
|
||||||
// That means we're going to be reading achievement state.
|
|
||||||
if (old_settings.achievements_enabled && !g_settings.achievements_enabled)
|
|
||||||
{
|
|
||||||
if (!IsInitialized())
|
|
||||||
return;
|
|
||||||
|
|
||||||
GPUThread::RunOnThread([]() {
|
|
||||||
if (s_state.current_main_window == MainWindowType::Achievements ||
|
|
||||||
s_state.current_main_window == MainWindowType::Leaderboards)
|
|
||||||
{
|
|
||||||
ReturnToPreviousWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FullscreenUI::UpdateRunIdleState()
|
void FullscreenUI::UpdateRunIdleState()
|
||||||
|
@ -7635,11 +7617,6 @@ void FullscreenUI::OpenAchievementsWindow()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FullscreenUI::IsAchievementsWindowOpen()
|
|
||||||
{
|
|
||||||
return (s_state.current_main_window == MainWindowType::Achievements);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FullscreenUI::OpenLeaderboardsWindow()
|
void FullscreenUI::OpenLeaderboardsWindow()
|
||||||
{
|
{
|
||||||
if (!System::IsValid())
|
if (!System::IsValid())
|
||||||
|
@ -7674,11 +7651,6 @@ void FullscreenUI::OpenLeaderboardsWindow()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FullscreenUI::IsLeaderboardsWindowOpen()
|
|
||||||
{
|
|
||||||
return (s_state.current_main_window == MainWindowType::Leaderboards);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __ANDROID__
|
#endif // __ANDROID__
|
||||||
|
|
||||||
LoadingScreenProgressCallback::LoadingScreenProgressCallback()
|
LoadingScreenProgressCallback::LoadingScreenProgressCallback()
|
||||||
|
|
|
@ -29,9 +29,7 @@ void OnRunningGameChanged();
|
||||||
void OpenPauseMenu();
|
void OpenPauseMenu();
|
||||||
void OpenCheatsMenu();
|
void OpenCheatsMenu();
|
||||||
void OpenAchievementsWindow();
|
void OpenAchievementsWindow();
|
||||||
bool IsAchievementsWindowOpen();
|
|
||||||
void OpenLeaderboardsWindow();
|
void OpenLeaderboardsWindow();
|
||||||
bool IsLeaderboardsWindowOpen();
|
|
||||||
void ReturnToMainWindow();
|
void ReturnToMainWindow();
|
||||||
void ReturnToPreviousWindow();
|
void ReturnToPreviousWindow();
|
||||||
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
|
void SetStandardSelectionFooterText(bool back_instead_of_cancel);
|
||||||
|
|
Loading…
Reference in New Issue