EmuScreen: Show the loading spinner while a savestate saves or loads

The boot spinner, in the same corner without the background, while a
save, load or rewind is queued or in progress. Only after a quarter of a
second, so it doesn't flash up on every quick save; on desktop that's
rarely reached, but slow devices get some feedback.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-19 18:51:10 +02:00
1 parent 5bbeb6254b
commit 86e420b9ce
4 files changed
+30 -1

No files matched your search

+6
View File
@@ -454,6 +454,12 @@ int g_screenshotFailures;
return !rewindStates.Empty();
}
bool IsBusy() {
std::lock_guard<std::mutex> guard(mutex);
// A save leaves the queue once its snapshot is taken, but stays pending until it's written.
return !g_pendingOperations.empty() || !g_pendingSaves.empty();
}
// Slot utilities
std::string AppendSlotTitle(const std::string &filename, const std::string &title) {
+4
View File
@@ -112,6 +112,10 @@ namespace SaveState {
// Returns true if there are rewind snapshots available.
bool CanRewind();
// Returns true while a save, load or rewind is queued or still in progress (rewind snapshots
// don't count). Saves are done once the file is written.
bool IsBusy();
// Returns true if a savestate has been used during this session.
bool HasLoadedState();
+17 -1
View File
@@ -1329,6 +1329,11 @@ void EmuScreen::CreateViews() {
Spinner *loadingSpinner = root_->Add(new Spinner(symbols, ARRAY_SIZE(symbols), new AnchorLayoutParams(NONE, NONE, 70, 70, Centering::Both)));
loadingSpinner_ = loadingSpinner;
// The same spinner in the same place, without the background.
saveStateSpinner_ = root_->Add(new Spinner(symbols, ARRAY_SIZE(symbols), new AnchorLayoutParams(NONE, NONE, 70, 70, Centering::Both)));
saveStateSpinner_->SetColor(alphaMul(0xFFFFFFFF, 0.7f));
saveStateSpinner_->SetVisibility(V_GONE);
loadingBG->SetTag("LoadingBG");
loadingSpinner->SetTag("LoadingSpinner");
@@ -1417,6 +1422,17 @@ void EmuScreen::update() {
releaseMapperInput_ = false;
}
// Only once a savestate operation has taken a while, or it'd flash up on every quick save.
if (SaveState::IsBusy()) {
if (saveStateBusySince_ < 0.0) {
saveStateBusySince_ = time_now_d();
}
} else {
saveStateBusySince_ = -1.0;
}
const bool showSaveStateSpinner = saveStateBusySince_ >= 0.0 && time_now_d() - saveStateBusySince_ > 0.25 && loadingSpinner_->GetVisibility() != V_VISIBLE;
saveStateSpinner_->SetVisibility(showSaveStateSpinner ? V_VISIBLE : V_GONE);
resumeButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR && Memory::MemFault_MayBeResumable() ? V_VISIBLE : V_GONE);
resetButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR ? V_VISIBLE : V_GONE);
backButton_->SetVisibility(coreState == CoreState::CORE_RUNTIME_ERROR ? V_VISIBLE : V_GONE);
@@ -1853,7 +1869,7 @@ ScreenRenderFlags EmuScreen::RunEmulation(bool skipBufferEffects) {
bool EmuScreen::hasVisibleUI() {
// Regular but uncommon UI.
if (saveStatePreview_->GetVisibility() != UI::V_GONE || loadingSpinner_->GetVisibility() == UI::V_VISIBLE)
if (saveStatePreview_->GetVisibility() != UI::V_GONE || loadingSpinner_->GetVisibility() == UI::V_VISIBLE || saveStateSpinner_->GetVisibility() == UI::V_VISIBLE)
return true;
if (!g_OSD.IsEmpty() || g_Config.bShowTouchControls || g_Config.iShowStatusFlags != 0)
return true;
+3
View File
@@ -124,6 +124,9 @@ private:
UI::CallbackColorTween *loadingViewColor_ = nullptr;
UI::VisibilityTween *loadingViewVisible_ = nullptr;
UI::Spinner *loadingSpinner_ = nullptr;
// Shown while a savestate is being saved or loaded, if that takes long enough to notice.
UI::Spinner *saveStateSpinner_ = nullptr;
double saveStateBusySince_ = -1.0;
UI::Button *resumeButton_ = nullptr;
UI::Button *resetButton_ = nullptr;
UI::Button *backButton_ = nullptr;