@@ -81,7 +81,7 @@ static void DoStartFile();
8181static void DoStartBIOS ();
8282static void DoStartDisc ();
8383static void DoToggleFastForward ();
84- static void ConfirmIfSavingMemoryCards (std::string action, std::function<void (bool )> callback);
84+ static void ConfirmWithSafetyCheck (std::string action, bool check_achievements , std::function<void (bool )> callback);
8585static void RequestShutdown (bool save_state);
8686static void RequestRestart ();
8787static void BeginChangeDiscOnCoreThread (bool needs_pause);
@@ -713,29 +713,45 @@ void FullscreenUI::DoStartDisc()
713713 });
714714}
715715
716- void FullscreenUI::ConfirmIfSavingMemoryCards (std::string action, std::function<void (bool )> callback)
716+ void FullscreenUI::ConfirmWithSafetyCheck (std::string action, bool check_achievements,
717+ std::function<void (bool )> callback)
717718{
718- Host::RunOnCoreThread ([action = std::move (action), callback = std::move (callback)]() mutable {
719+ Host::RunOnCoreThread ([action = std::move (action), callback = std::move (callback), check_achievements]() mutable {
720+ const u32 pending_unlock_count = check_achievements ? Achievements::GetPendingUnlockCount () : 0 ;
719721 const bool was_saving = System::IsSavingMemoryCards ();
720- GPUThread::RunOnThread ([action = std::move (action), callback = std::move (callback), was_saving]() mutable {
721- if (!was_saving)
722+ GPUThread::RunOnThread ([action = std::move (action), callback = std::move (callback), pending_unlock_count,
723+ was_saving]() mutable {
724+ if (!was_saving && pending_unlock_count == 0 )
722725 {
723726 callback (true );
724727 return ;
725728 }
726729
727- OpenConfirmMessageDialog (
728- ICON_EMOJI_WARNING, FSUI_ICONVSTR (ICON_PF_MEMORY_CARD, " Memory Card Busy" ),
729- fmt::format (
730- FSUI_FSTR (" WARNING: Your game is still saving to the memory card. Continuing to {0} may IRREVERSIBLY "
731- " DESTROY YOUR MEMORY CARD. We recommend resuming your game and waiting 5 seconds for it to "
732- " finish saving.\n\n Do you want to {0} anyway?" ),
733- action),
734- std::move (callback),
735- fmt::format (
736- fmt::runtime (FSUI_ICONVSTR (ICON_FA_TRIANGLE_EXCLAMATION, " Yes, {} now and risk memory card corruption." )),
737- action),
738- FSUI_ICONSTR (ICON_FA_PLAY, " No, resume the game." ));
730+ if (was_saving)
731+ {
732+ OpenConfirmMessageDialog (
733+ ICON_EMOJI_WARNING, FSUI_ICONVSTR (ICON_PF_MEMORY_CARD, " Memory Card Busy" ),
734+ fmt::format (
735+ FSUI_FSTR (" WARNING: Your game is still saving to the memory card. Continuing to {0} may IRREVERSIBLY "
736+ " DESTROY YOUR MEMORY CARD. We recommend resuming your game and waiting 5 seconds for it to "
737+ " finish saving.\n\n Do you want to {0} anyway?" ),
738+ action),
739+ std::move (callback),
740+ fmt::format (
741+ fmt::runtime (FSUI_ICONVSTR (ICON_FA_TRIANGLE_EXCLAMATION, " Yes, {} now and risk memory card corruption." )),
742+ action),
743+ FSUI_ICONSTR (ICON_FA_PLAY, " No, resume the game." ));
744+ }
745+ else
746+ {
747+ OpenConfirmMessageDialog (
748+ ICON_EMOJI_WARNING, FSUI_ICONVSTR (ICON_FA_TROPHY, " Achievement Unlocks Unconfirmed" ),
749+ fmt::format (FSUI_FSTR (" {0} achievement unlocks have not been confirmed by the server. Continuing to {1} will "
750+ " result in loss of these unlocks. Once network connectivity has been re-established, "
751+ " these unlocks will be confirmed automatically.\n\n Do you want to {1} anyway?" ),
752+ pending_unlock_count, action),
753+ std::move (callback));
754+ }
739755 });
740756 });
741757}
@@ -744,7 +760,7 @@ void FullscreenUI::RequestShutdown(bool save_state)
744760{
745761 SwitchToMainWindow (MainWindowType::None);
746762
747- ConfirmIfSavingMemoryCards (FSUI_STR (" shut down" ), [save_state](bool result) {
763+ ConfirmWithSafetyCheck (FSUI_STR (" shut down" ), true , [save_state](bool result) {
748764 if (result)
749765 Host::RunOnCoreThread ([save_state]() { Host::RequestSystemShutdown (false , save_state, false ); });
750766 else
@@ -756,7 +772,7 @@ void FullscreenUI::RequestRestart()
756772{
757773 SwitchToMainWindow (MainWindowType::None);
758774
759- ConfirmIfSavingMemoryCards (FSUI_STR (" restart" ), [](bool result) {
775+ ConfirmWithSafetyCheck (FSUI_STR (" restart" ), false , [](bool result) {
760776 if (result)
761777 Host::RunOnCoreThread (System::ResetSystem);
762778
@@ -783,7 +799,7 @@ void FullscreenUI::StartChangeDiscFromFile()
783799 return ;
784800 }
785801
786- ConfirmIfSavingMemoryCards (FSUI_STR (" change disc" ), [path](bool result) {
802+ ConfirmWithSafetyCheck (FSUI_STR (" change disc" ), false , [path](bool result) {
787803 if (result)
788804 {
789805 if (!GameList::IsScannableFilename (path))
@@ -839,7 +855,7 @@ void FullscreenUI::BeginChangeDiscOnCoreThread(bool needs_pause)
839855 }
840856 else if (index > 0 )
841857 {
842- ConfirmIfSavingMemoryCards (FSUI_STR (" change disc" ), [index](bool result) {
858+ ConfirmWithSafetyCheck (FSUI_STR (" change disc" ), false , [index](bool result) {
843859 if (result)
844860 System::SwitchMediaSubImage (static_cast <u32 >(index - 1 ));
845861
@@ -890,7 +906,7 @@ void FullscreenUI::BeginChangeDiscOnCoreThread(bool needs_pause)
890906 }
891907 else if (index > 0 )
892908 {
893- ConfirmIfSavingMemoryCards (FSUI_STR (" change disc" ), [paths = std::move (paths), index](bool result) {
909+ ConfirmWithSafetyCheck (FSUI_STR (" change disc" ), false , [paths = std::move (paths), index](bool result) {
894910 if (result)
895911 Host::RunOnCoreThread ([path = std::move (paths[index - 1 ])]() { System::InsertMedia (path.c_str ()); });
896912
0 commit comments