mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-01-27 16:24:54 +00:00
SaveState: Show undos in save data manager.
This commit is contained in:
parent
2ee8dd7752
commit
862b553c66
@ -324,30 +324,46 @@ namespace SaveState
|
||||
// Slot utilities
|
||||
|
||||
std::string AppendSlotTitle(const std::string &filename, const std::string &title) {
|
||||
if (!endsWith(filename, std::string(".") + STATE_EXTENSION)) {
|
||||
return title + " (" + filename + ")";
|
||||
char slotChar = 0;
|
||||
auto detectSlot = [&](const std::string &ext) {
|
||||
if (!endsWith(filename, std::string(".") + ext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Usually these are slots, let's check the slot # after the last '_'.
|
||||
size_t slotNumPos = filename.find_last_of('_');
|
||||
if (slotNumPos == filename.npos) {
|
||||
return title + " (" + filename + ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t extLength = strlen(STATE_EXTENSION) + 1;
|
||||
const size_t extLength = ext.length() + 1;
|
||||
// If we take out the extension, '_', etc. we should be left with only a single digit.
|
||||
if (slotNumPos + 1 + extLength != filename.length() - 1) {
|
||||
return title + " (" + filename + ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string slot = filename.substr(slotNumPos + 1, 1);
|
||||
if (slot[0] < '0' || slot[0] > '8') {
|
||||
return title + " (" + filename + ")";
|
||||
slotChar = filename[slotNumPos + 1];
|
||||
if (slotChar < '0' || slotChar > '8') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Change from zero indexed to human friendly.
|
||||
slot[0]++;
|
||||
return title + " (" + slot + ")";
|
||||
slotChar++;
|
||||
return true;
|
||||
};
|
||||
|
||||
if (detectSlot(STATE_EXTENSION)) {
|
||||
return StringFromFormat("%s (%c)", title.c_str(), slotChar);
|
||||
}
|
||||
if (detectSlot(UNDO_STATE_EXTENSION)) {
|
||||
I18NCategory *sy = GetI18NCategory("System");
|
||||
// Allow the number to be positioned where it makes sense.
|
||||
std::string undo = sy->T("undo %c");
|
||||
return title + " (" + StringFromFormat(undo.c_str(), slotChar) + ")";
|
||||
}
|
||||
|
||||
// Couldn't detect, use the filename.
|
||||
return title + " (" + filename + ")";
|
||||
}
|
||||
|
||||
std::string GetTitle(const std::string &filename) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user