mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-31 05:43:14 +00:00
Merge pull request #11592 from unknownbrackets/savestate
SaveState: Retry failed state screenshots
This commit is contained in:
commit
8e56c62c28
@ -240,6 +240,7 @@ namespace SaveState
|
||||
static bool needsProcess = false;
|
||||
static std::vector<Operation> pending;
|
||||
static std::mutex mutex;
|
||||
static int screenshotFailures = 0;
|
||||
static bool hasLoadedState = false;
|
||||
static const int STALE_STATE_USES = 2;
|
||||
// 4 hours of total gameplay since the virtual PSP started the game.
|
||||
@ -249,6 +250,7 @@ namespace SaveState
|
||||
|
||||
// TODO: Should this be configurable?
|
||||
static const int REWIND_NUM_STATES = 20;
|
||||
static const int SCREENSHOT_FAILURE_RETRIES = 15;
|
||||
static StateRingbuffer rewindStates(REWIND_NUM_STATES);
|
||||
// TODO: Any reason for this to be configurable?
|
||||
const static float rewindMaxWallFrequency = 1.0f;
|
||||
@ -852,6 +854,12 @@ namespace SaveState
|
||||
callbackResult = tempResult ? Status::SUCCESS : Status::FAILURE;
|
||||
if (!tempResult) {
|
||||
ERROR_LOG(SAVESTATE, "Failed to take a screenshot for the savestate! %s", op.filename.c_str());
|
||||
if (screenshotFailures++ < SCREENSHOT_FAILURE_RETRIES) {
|
||||
// Requeue for next frame.
|
||||
SaveScreenshot(op.filename, op.callback, op.cbUserData);
|
||||
}
|
||||
} else {
|
||||
screenshotFailures = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -323,6 +323,8 @@ void SavedataBrowser::SetSortOption(SavedataSortOption opt) {
|
||||
gl->SetCompare(&ByFilename, &SortDone);
|
||||
} else if (sortOption_ == SavedataSortOption::SIZE) {
|
||||
gl->SetCompare(&BySize, &SortDone);
|
||||
} else if (sortOption_ == SavedataSortOption::DATE) {
|
||||
gl->SetCompare(&ByDate, &SortDone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,6 +347,29 @@ bool SavedataBrowser::BySize(const UI::View *v1, const UI::View *v2) {
|
||||
return g1info->gameSize > g2info->gameSize;
|
||||
}
|
||||
|
||||
bool SavedataBrowser::ByDate(const UI::View *v1, const UI::View *v2) {
|
||||
const SavedataButton *b1 = static_cast<const SavedataButton *>(v1);
|
||||
const SavedataButton *b2 = static_cast<const SavedataButton *>(v2);
|
||||
|
||||
auto getDateSeconds = [&](const SavedataButton *b) {
|
||||
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(nullptr, b->GamePath(), 0);
|
||||
tm datetm;
|
||||
bool success;
|
||||
if (ginfo && ginfo->fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY) {
|
||||
success = File::GetModifTime(b->GamePath() + "/PARAM.SFO", datetm);
|
||||
} else {
|
||||
success = File::GetModifTime(b->GamePath(), datetm);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
return mktime(&datetm);
|
||||
}
|
||||
return (time_t)0;
|
||||
};
|
||||
|
||||
return getDateSeconds(b1) > getDateSeconds(b2);
|
||||
}
|
||||
|
||||
bool SavedataBrowser::SortDone() {
|
||||
PrioritizedWorkQueue *wq = g_gameInfoCache->WorkQueue();
|
||||
return wq->Done();
|
||||
@ -454,6 +479,7 @@ void SavedataScreen::CreateViews() {
|
||||
ChoiceStrip *sortStrip = new ChoiceStrip(ORIENT_HORIZONTAL, new AnchorLayoutParams(NONE, 0, 0, NONE));
|
||||
sortStrip->AddChoice(sa->T("Filename"));
|
||||
sortStrip->AddChoice(sa->T("Size"));
|
||||
sortStrip->AddChoice(sa->T("Date"));
|
||||
sortStrip->SetSelection((int)sortOption_);
|
||||
sortStrip->OnChoice.Handle<SavedataScreen>(this, &SavedataScreen::OnSortClick);
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
enum class SavedataSortOption {
|
||||
FILENAME,
|
||||
SIZE,
|
||||
DATE,
|
||||
};
|
||||
|
||||
class SavedataBrowser : public UI::LinearLayout {
|
||||
@ -42,6 +43,7 @@ public:
|
||||
private:
|
||||
static bool ByFilename(const UI::View *, const UI::View *);
|
||||
static bool BySize(const UI::View *, const UI::View *);
|
||||
static bool ByDate(const UI::View *, const UI::View *);
|
||||
static bool SortDone();
|
||||
|
||||
void Refresh();
|
||||
|
Loading…
x
Reference in New Issue
Block a user