mirror of https://github.com/PCSX2/pcsx2.git
Achievements: Fix async HC mode disable running on wrong thread
This commit is contained in:
parent
d53b2ae104
commit
c44500ba0f
|
@ -1855,30 +1855,32 @@ void Achievements::ConfirmHardcoreModeDisableAsync(const char* trigger, std::fun
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!FullscreenUI::Initialize())
|
||||
{
|
||||
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("Cannot {} while hardcode mode is active.", trigger)),
|
||||
Host::OSD_WARNING_DURATION);
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
MTGS::RunOnGSThread([trigger = TinyString(trigger), callback = std::move(callback)]() {
|
||||
if (!FullscreenUI::Initialize())
|
||||
{
|
||||
Host::AddOSDMessage(fmt::format(TRANSLATE_FS("Cannot {} while hardcode mode is active.", trigger)),
|
||||
Host::OSD_WARNING_DURATION);
|
||||
callback(false);
|
||||
return;
|
||||
}
|
||||
|
||||
auto real_callback = [callback = std::move(callback)](bool res) mutable {
|
||||
// don't run the callback in the middle of rendering the UI
|
||||
Host::RunOnCPUThread([callback = std::move(callback), res]() {
|
||||
if (res)
|
||||
DisableHardcoreMode();
|
||||
callback(res);
|
||||
});
|
||||
};
|
||||
auto real_callback = [callback = std::move(callback)](bool res) mutable {
|
||||
// don't run the callback in the middle of rendering the UI
|
||||
Host::RunOnCPUThread([callback = std::move(callback), res]() {
|
||||
if (res)
|
||||
DisableHardcoreMode();
|
||||
callback(res);
|
||||
});
|
||||
};
|
||||
|
||||
ImGuiFullscreen::OpenConfirmMessageDialog(
|
||||
TRANSLATE_STR("Achievements", "Confirm Hardcore Mode"),
|
||||
fmt::format(TRANSLATE_FS("Achievements", "{0} cannot be performed while hardcore mode is active. Do you "
|
||||
"want to disable hardcore mode? {0} will be cancelled if you select No."),
|
||||
trigger),
|
||||
std::move(real_callback), fmt::format(ICON_FA_CHECK " {}", TRANSLATE_SV("Achievements", "Yes")),
|
||||
fmt::format(ICON_FA_TIMES " {}", TRANSLATE_SV("Achievements", "No")));
|
||||
ImGuiFullscreen::OpenConfirmMessageDialog(
|
||||
TRANSLATE_STR("Achievements", "Confirm Hardcore Mode"),
|
||||
fmt::format(TRANSLATE_FS("Achievements", "{0} cannot be performed while hardcore mode is active. Do you "
|
||||
"want to disable hardcore mode? {0} will be cancelled if you select No."),
|
||||
trigger),
|
||||
std::move(real_callback), fmt::format(ICON_FA_CHECK " {}", TRANSLATE_SV("Achievements", "Yes")),
|
||||
fmt::format(ICON_FA_TIMES " {}", TRANSLATE_SV("Achievements", "No")));
|
||||
});
|
||||
}
|
||||
|
||||
void Achievements::ClearUIState()
|
||||
|
|
Loading…
Reference in New Issue