SaveData:Displays all saves like a PSP for LISTALLDELETE mode.
This commit is contained in:
parent
c84f9542d7
commit
81ad9a930a
3 changed files with 52 additions and 13 deletions
|
@ -180,7 +180,6 @@ int PSPSaveDialog::Init(int paramAddr)
|
||||||
display = DS_SAVE_LIST_CHOICE;
|
display = DS_SAVE_LIST_CHOICE;
|
||||||
break;
|
break;
|
||||||
case SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE:
|
case SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE:
|
||||||
// TODO:Should displays all saves like a PSP?
|
|
||||||
DEBUG_LOG(SCEUTILITY, "Delete. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
|
DEBUG_LOG(SCEUTILITY, "Delete. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str());
|
||||||
if(param.GetFilenameCount() == 0)
|
if(param.GetFilenameCount() == 0)
|
||||||
display = DS_DELETE_NODATA;
|
display = DS_DELETE_NODATA;
|
||||||
|
@ -969,6 +968,8 @@ int PSPSaveDialog::Update(int animSpeed)
|
||||||
if (param.GetFilenameCount() == 0)
|
if (param.GetFilenameCount() == 0)
|
||||||
display = DS_DELETE_NODATA;
|
display = DS_DELETE_NODATA;
|
||||||
else if (param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE || param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE) {
|
else if (param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE || param.GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE) {
|
||||||
|
if (currentSelectedSave > param.GetFilenameCount() - 1)
|
||||||
|
currentSelectedSave = param.GetFilenameCount() - 1;
|
||||||
display = DS_DELETE_LIST_CHOICE;
|
display = DS_DELETE_LIST_CHOICE;
|
||||||
} else {
|
} else {
|
||||||
param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS;
|
param.GetPspParam()->common.result = SCE_UTILITY_DIALOG_RESULT_SUCCESS;
|
||||||
|
@ -1039,7 +1040,7 @@ void PSPSaveDialog::ExecuteIOAction() {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DS_DELETE_DELETING:
|
case DS_DELETE_DELETING:
|
||||||
if (param.Delete(param.GetPspParam(),currentSelectedSave)) {
|
if (param.Delete(param.GetPspParam(), currentSelectedSave)) {
|
||||||
result = 0;
|
result = 0;
|
||||||
display = DS_DELETE_DONE;
|
display = DS_DELETE_DONE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -322,12 +322,12 @@ bool SavedataParam::Delete(SceUtilitySavedataParam* param, int saveId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity check, preventing full delete of savedata/ in MGS PW demo (!)
|
// Sanity check, preventing full delete of savedata/ in MGS PW demo (!)
|
||||||
if (!strlen(param->gameName)) {
|
if (!strlen(param->gameName) && param->mode != SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE) {
|
||||||
ERROR_LOG(SCEUTILITY, "Bad param with gameName empty - cannot delete save directory");
|
ERROR_LOG(SCEUTILITY, "Bad param with gameName empty - cannot delete save directory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dirPath = GetSaveFilePath(param,saveId);
|
std::string dirPath = GetSaveFilePath(param, GetSaveDir(saveId));
|
||||||
if (dirPath.size() == 0) {
|
if (dirPath.size() == 0) {
|
||||||
ERROR_LOG(SCEUTILITY, "GetSaveFilePath returned empty - cannot delete save directory");
|
ERROR_LOG(SCEUTILITY, "GetSaveFilePath returned empty - cannot delete save directory");
|
||||||
return false;
|
return false;
|
||||||
|
@ -1411,6 +1411,34 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTALLDELETE) {
|
||||||
|
Clear();
|
||||||
|
int realCount = 0;
|
||||||
|
auto allSaves = pspFileSystem.GetDirListing(savePath);
|
||||||
|
saveDataListCount = (int)allSaves.size();
|
||||||
|
saveDataList = new SaveFileInfo[saveDataListCount];
|
||||||
|
for (auto save : allSaves) {
|
||||||
|
if (save.name == "." || save.name == "..")
|
||||||
|
continue;
|
||||||
|
std::string fileDataDir = savePath + save.name;
|
||||||
|
PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataDir);
|
||||||
|
auto allFiles = pspFileSystem.GetDirListing(fileDataDir);
|
||||||
|
bool firstFile = true;
|
||||||
|
for (auto file : allFiles) {
|
||||||
|
if (firstFile) {
|
||||||
|
// Use a file in save directory to determine the directory info.
|
||||||
|
info = file;
|
||||||
|
firstFile = false;
|
||||||
|
} else
|
||||||
|
info.size += file.size;
|
||||||
|
}
|
||||||
|
SetFileInfo(realCount, info, "", save.name);
|
||||||
|
realCount++;
|
||||||
|
}
|
||||||
|
saveNameListDataCount = realCount;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool listEmptyFile = true;
|
bool listEmptyFile = true;
|
||||||
if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
|
if (param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD ||
|
||||||
param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE)
|
param->mode == SCE_UTILITY_SAVEDATA_TYPE_LISTDELETE)
|
||||||
|
@ -1548,13 +1576,16 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::string saveName)
|
void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::string saveName, std::string savrDir)
|
||||||
{
|
{
|
||||||
saveInfo.size = info.size;
|
saveInfo.size = info.size;
|
||||||
saveInfo.saveName = saveName;
|
saveInfo.saveName = saveName;
|
||||||
saveInfo.idx = 0;
|
saveInfo.idx = 0;
|
||||||
saveInfo.modif_time = info.mtime;
|
saveInfo.modif_time = info.mtime;
|
||||||
|
|
||||||
|
std::string saveDir = savrDir == "" ? GetGameName(pspParam) + saveName : savrDir;
|
||||||
|
saveInfo.saveDir = saveDir;
|
||||||
|
|
||||||
// Start with a blank slate.
|
// Start with a blank slate.
|
||||||
if (saveInfo.texture != NULL) {
|
if (saveInfo.texture != NULL) {
|
||||||
if (!noSaveIcon || saveInfo.texture != noSaveIcon->texture) {
|
if (!noSaveIcon || saveInfo.texture != noSaveIcon->texture) {
|
||||||
|
@ -1568,13 +1599,13 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::
|
||||||
|
|
||||||
// Search save image icon0
|
// Search save image icon0
|
||||||
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
// TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound
|
||||||
std::string fileDataPath2 = savePath + GetGameName(pspParam) + saveName + "/" + ICON0_FILENAME;
|
std::string fileDataPath2 = savePath + saveDir + "/" + ICON0_FILENAME;
|
||||||
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||||
if (info2.exists)
|
if (info2.exists)
|
||||||
saveInfo.texture = new PPGeImage(fileDataPath2);
|
saveInfo.texture = new PPGeImage(fileDataPath2);
|
||||||
|
|
||||||
// Load info in PARAM.SFO
|
// Load info in PARAM.SFO
|
||||||
fileDataPath2 = savePath + GetGameName(pspParam) + saveName + "/" + SFO_FILENAME;
|
fileDataPath2 = savePath + saveDir + "/" + SFO_FILENAME;
|
||||||
info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
info2 = pspFileSystem.GetFileInfo(fileDataPath2);
|
||||||
if (info2.exists) {
|
if (info2.exists) {
|
||||||
std::vector<u8> sfoData;
|
std::vector<u8> sfoData;
|
||||||
|
@ -1590,9 +1621,9 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName)
|
void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName, std::string saveDir)
|
||||||
{
|
{
|
||||||
SetFileInfo(saveDataList[idx], info, saveName);
|
SetFileInfo(saveDataList[idx], info, saveName, saveDir);
|
||||||
saveDataList[idx].idx = idx;
|
saveDataList[idx].idx = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1641,11 +1672,16 @@ const SaveFileInfo& SavedataParam::GetFileInfo(int idx)
|
||||||
{
|
{
|
||||||
return saveDataList[idx];
|
return saveDataList[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SavedataParam::GetFilename(int idx) const
|
std::string SavedataParam::GetFilename(int idx) const
|
||||||
{
|
{
|
||||||
return saveDataList[idx].saveName;
|
return saveDataList[idx].saveName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SavedataParam::GetSaveDir(int idx) const {
|
||||||
|
return saveDataList[idx].saveDir;
|
||||||
|
}
|
||||||
|
|
||||||
int SavedataParam::GetSelectedSave()
|
int SavedataParam::GetSelectedSave()
|
||||||
{
|
{
|
||||||
// The slot # of the same save on LOAD/SAVE lists can dismatch so this isn't right anyhow
|
// The slot # of the same save on LOAD/SAVE lists can dismatch so this isn't right anyhow
|
||||||
|
|
|
@ -65,11 +65,11 @@ static const char *const utilitySavedataTypeNames[] = {
|
||||||
"SAVE",
|
"SAVE",
|
||||||
"LISTLOAD",
|
"LISTLOAD",
|
||||||
"LISTSAVE",
|
"LISTSAVE",
|
||||||
"DELETE",
|
|
||||||
"LISTDELETE",
|
"LISTDELETE",
|
||||||
|
"LISTALLDELETE",
|
||||||
"SIZES",
|
"SIZES",
|
||||||
"AUTODELETE",
|
"AUTODELETE",
|
||||||
"SINGLEDELETE",
|
"DELETE",
|
||||||
"LIST",
|
"LIST",
|
||||||
"FILES",
|
"FILES",
|
||||||
"MAKEDATASECURE",
|
"MAKEDATASECURE",
|
||||||
|
@ -273,6 +273,7 @@ struct SaveFileInfo
|
||||||
{
|
{
|
||||||
s64 size;
|
s64 size;
|
||||||
std::string saveName;
|
std::string saveName;
|
||||||
|
std::string saveDir;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
char title[128];
|
char title[128];
|
||||||
|
@ -341,6 +342,7 @@ public:
|
||||||
int GetFilenameCount();
|
int GetFilenameCount();
|
||||||
const SaveFileInfo& GetFileInfo(int idx);
|
const SaveFileInfo& GetFileInfo(int idx);
|
||||||
std::string GetFilename(int idx) const;
|
std::string GetFilename(int idx) const;
|
||||||
|
std::string GetSaveDir(int idx) const;
|
||||||
|
|
||||||
int GetSelectedSave();
|
int GetSelectedSave();
|
||||||
void SetSelectedSave(int idx);
|
void SetSelectedSave(int idx);
|
||||||
|
@ -361,8 +363,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Clear();
|
void Clear();
|
||||||
void SetFileInfo(int idx, PSPFileInfo &info, std::string saveName);
|
void SetFileInfo(int idx, PSPFileInfo &info, std::string saveName, std::string saveDir = "");
|
||||||
void SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::string saveName);
|
void SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::string saveName, std::string saveDir = "");
|
||||||
void ClearFileInfo(SaveFileInfo &saveInfo, const std::string &saveName);
|
void ClearFileInfo(SaveFileInfo &saveInfo, const std::string &saveName);
|
||||||
|
|
||||||
int LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string& dirPath, bool secureMode);
|
int LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string& dirPath, bool secureMode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue