From 3c486c5dc57fadb3441179fa56515785bb265bfe Mon Sep 17 00:00:00 2001 From: aquanull Date: Sun, 19 May 2013 12:46:10 +0800 Subject: [PATCH 1/4] Swap positions of "Back" and "Enter" buttons in PSPSaveDialog. --- Core/Dialog/PSPSaveDialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index c870e4736f..40104f365f 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -370,10 +370,10 @@ void PSPSaveDialog::DisplayTitle(std::string name) void PSPSaveDialog::DisplayEnterBack() { I18NCategory *d = GetI18NCategory("Dialog"); - PPGeDrawImage(okButtonImg, 180, 257, 11, 11, 0, CalcFadedColor(0xFFFFFFFF)); - PPGeDrawImage(cancelButtonImg, 270, 257, 11, 11, 0, CalcFadedColor(0xFFFFFFFF)); - PPGeDrawText(d->T("Enter"), 195, 255, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(0xFFFFFFFF)); - PPGeDrawText(d->T("Back"), 285, 255, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawImage(cancelButtonImg, 180, 257, 11, 11, 0, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawImage(okButtonImg, 270, 257, 11, 11, 0, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawText(d->T("Back"), 195, 255, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(0xFFFFFFFF)); + PPGeDrawText(d->T("Enter"), 285, 255, PPGE_ALIGN_LEFT, 0.45f, CalcFadedColor(0xFFFFFFFF)); } void PSPSaveDialog::DisplayBack() From ae486f8e023c662455cc3a9cfb59ade838851c1a Mon Sep 17 00:00:00 2001 From: aquanull Date: Sun, 19 May 2013 21:03:45 +0800 Subject: [PATCH 2/4] Make the default choice in all save dialogs except for overwrite/delete confirmation be "Yes". --- Core/Dialog/PSPSaveDialog.cpp | 38 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 40104f365f..f3f708eb81 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -55,6 +55,7 @@ int PSPSaveDialog::Init(int paramAddr) INFO_LOG(HLE,"Mode: %i", param.GetPspParam()->mode); currentSelectedSave = 0; + yesnoChoice = 1; switch(param.GetPspParam()->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: @@ -80,7 +81,10 @@ int PSPSaveDialog::Init(int paramAddr) case SCE_UTILITY_SAVEDATA_TYPE_SAVE: DEBUG_LOG(HLE, "Saving. 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.GetFileInfo(0).size != 0) + { + yesnoChoice = 0; display = DS_SAVE_CONFIRM_OVERWRITE; + } else display = DS_SAVE_CONFIRM; currentSelectedSave = param.GetSelectedSave(); @@ -408,7 +412,7 @@ int PSPSaveDialog::Update() cancelButtonImg = I_CROSS; okButtonFlag = CTRL_CIRCLE; cancelButtonFlag = CTRL_CROSS; - if(param.GetPspParam()->buttonSwap == 1) { + if (param.GetPspParam()->buttonSwap == 1) { okButtonImg = I_CROSS; cancelButtonImg = I_CIRCLE; okButtonFlag = CTRL_CROSS; @@ -417,7 +421,7 @@ int PSPSaveDialog::Update() I18NCategory *d = GetI18NCategory("Dialog"); - switch(display) + switch (display) { case DS_SAVE_LIST_CHOICE: StartDraw(); @@ -433,7 +437,7 @@ int PSPSaveDialog::Update() StartFade(false); } else if (IsButtonPressed(okButtonFlag)) { // Save exist, ask user confirm - if(param.GetFileInfo(currentSelectedSave).size > 0) { + if (param.GetFileInfo(currentSelectedSave).size > 0) { yesnoChoice = 0; display = DS_SAVE_CONFIRM_OVERWRITE; } else { @@ -506,7 +510,6 @@ int PSPSaveDialog::Update() break; case DS_SAVE_SAVING: StartDraw(); - DisplaySaveIcon(); DisplaySaveDataInfo2(); @@ -517,7 +520,6 @@ int PSPSaveDialog::Update() break; case DS_SAVE_DONE: StartDraw(); - DisplaySaveIcon(); DisplaySaveDataInfo2(); @@ -579,7 +581,6 @@ int PSPSaveDialog::Update() break; case DS_LOAD_LOADING: StartDraw(); - DisplaySaveIcon(); DisplaySaveDataInfo2(); @@ -591,7 +592,6 @@ int PSPSaveDialog::Update() case DS_LOAD_DONE: StartDraw(); - DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayBack(); @@ -609,7 +609,6 @@ int PSPSaveDialog::Update() break; case DS_LOAD_NODATA: StartDraw(); - DisplayBack(); @@ -642,23 +641,21 @@ int PSPSaveDialog::Update() break; case DS_DELETE_CONFIRM: StartDraw(); - DisplaySaveIcon(); DisplaySaveDataInfo2(); DisplayConfirmationYesNo(d->T("DeleteConfirm", " This save data will be deleted.\nAre you sure you want to continue?")); - DisplayEnterBack(); if (IsButtonPressed(cancelButtonFlag)) display = DS_DELETE_LIST_CHOICE; else if (IsButtonPressed(okButtonFlag)) { - if(yesnoChoice == 0) + if (yesnoChoice == 0) display = DS_DELETE_LIST_CHOICE; else { display = DS_DELETE_DELETING; - if(param.Delete(param.GetPspParam(),currentSelectedSave)) { + if (param.Delete(param.GetPspParam(),currentSelectedSave)) { param.SetPspParam(param.GetPspParam()); // Optim : Just Update modified save display = DS_DELETE_DONE; } else @@ -670,7 +667,6 @@ int PSPSaveDialog::Update() break; case DS_DELETE_DELETING: StartDraw(); - DisplayInfo(d->T("Deleting","Deleting\nPlease Wait...")); @@ -679,13 +675,12 @@ int PSPSaveDialog::Update() case DS_DELETE_DONE: StartDraw(); - DisplayBack(); DisplayInfo(d->T("Delete completed")); if (IsButtonPressed(cancelButtonFlag)) { - if(param.GetFilenameCount() == 0) + if (param.GetFilenameCount() == 0) display = DS_DELETE_NODATA; else display = DS_DELETE_LIST_CHOICE; @@ -696,7 +691,6 @@ int PSPSaveDialog::Update() case DS_DELETE_NODATA: StartDraw(); - DisplayBack(); DisplayInfo(d->T("There is no data")); @@ -711,7 +705,7 @@ int PSPSaveDialog::Update() case DS_NONE: // For action which display nothing { - switch(param.GetPspParam()->mode) + switch (param.GetPspParam()->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: // Only load and exit case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: @@ -723,14 +717,14 @@ int PSPSaveDialog::Update() break; case SCE_UTILITY_SAVEDATA_TYPE_SAVE: // Only save and exit case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE: - if(param.Save(param.GetPspParam(), GetSelectedSaveDirName())) + if (param.Save(param.GetPspParam(), GetSelectedSaveDirName())) param.GetPspParam()->result = 0; else param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE; status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_SIZES: - if(param.GetSizes(param.GetPspParam())) + if (param.GetSizes(param.GetPspParam())) param.GetPspParam()->result = 0; else param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA; @@ -742,7 +736,7 @@ int PSPSaveDialog::Update() status = SCE_UTILITY_STATUS_FINISHED; break; case SCE_UTILITY_SAVEDATA_TYPE_FILES: - if(param.GetFilesList(param.GetPspParam())) + if (param.GetFilesList(param.GetPspParam())) param.GetPspParam()->result = 0; else param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; @@ -770,7 +764,7 @@ int PSPSaveDialog::Update() break; //case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE: case SCE_UTILITY_SAVEDATA_TYPE_SINGLEDELETE: - if(param.Delete(param.GetPspParam(), param.GetSelectedSave())) + if (param.Delete(param.GetPspParam(), param.GetSelectedSave())) param.GetPspParam()->result = 0; else param.GetPspParam()->result = SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA; @@ -813,7 +807,7 @@ int PSPSaveDialog::Update() lastButtons = buttons; - if(status == SCE_UTILITY_STATUS_FINISHED) + if (status == SCE_UTILITY_STATUS_FINISHED) Memory::Memcpy(requestAddr,&request,request.size); return 0; From dc25e6d2239b4a40dff0bcbd6580ba8c09e0236f Mon Sep 17 00:00:00 2001 From: aquanull Date: Sun, 19 May 2013 21:11:54 +0800 Subject: [PATCH 3/4] Always pick up the saveID by latest file time instead of the previously used one. This fixes SRWAP & SRWMXP. --- Core/Dialog/PSPSaveDialog.cpp | 12 ++++++------ Core/Dialog/SavedataParam.cpp | 34 ++++++++++++++++++++++++++-------- Core/Dialog/SavedataParam.h | 2 ++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index f3f708eb81..0d3d174ffb 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -54,9 +54,9 @@ int PSPSaveDialog::Init(int paramAddr) INFO_LOG(HLE,"sceUtilitySavedataInitStart(%08x)", paramAddr); INFO_LOG(HLE,"Mode: %i", param.GetPspParam()->mode); - currentSelectedSave = 0; yesnoChoice = 1; - switch(param.GetPspParam()->mode) + currentSelectedSave = param.GetLatestSave(); + switch (param.GetPspParam()->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: DEBUG_LOG(HLE, "Loading. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetSaveName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str()); @@ -64,12 +64,12 @@ int PSPSaveDialog::Init(int paramAddr) display = DS_LOAD_CONFIRM; else display = DS_LOAD_NODATA; - currentSelectedSave = param.GetSelectedSave(); break; case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: DEBUG_LOG(HLE, "Loading. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetSaveName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str()); display = DS_NONE; - currentSelectedSave = param.GetSelectedSave(); + // Is this necessary? + // currentSelectedSave = param.GetSelectedSave(); break; case SCE_UTILITY_SAVEDATA_TYPE_LISTLOAD: DEBUG_LOG(HLE, "Loading. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str()); @@ -87,12 +87,12 @@ int PSPSaveDialog::Init(int paramAddr) } else display = DS_SAVE_CONFIRM; - currentSelectedSave = param.GetSelectedSave(); break; case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE: DEBUG_LOG(HLE, "Saving. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str()); display = DS_NONE; - currentSelectedSave = param.GetSelectedSave(); + // Is this necessary? + // currentSelectedSave = param.GetSelectedSave(); break; case SCE_UTILITY_SAVEDATA_TYPE_LISTSAVE: DEBUG_LOG(HLE, "Saving. Title: %s Save: %s File: %s", param.GetGameName(param.GetPspParam()).c_str(), param.GetGameName(param.GetPspParam()).c_str(), param.GetFileName(param.GetPspParam()).c_str()); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 3609ccf497..1c648b8e3e 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -985,22 +985,23 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) listEmptyFile = false; } - char (*saveNameListData)[20]; + typedef char (*SaveNameListData_t)[20]; + SaveNameListData_t saveNameListData; bool hasMultipleFileName = false; if (param->saveNameList != 0) { Clear(); - saveNameListData = (char(*)[20])Memory::GetPointer(param->saveNameList); + saveNameListData = (SaveNameListData_t)Memory::GetPointer(param->saveNameList); // Get number of fileName in array saveDataListCount = 0; - while(saveNameListData[saveDataListCount][0] != 0) + while (saveNameListData[saveDataListCount][0] != 0) { saveDataListCount++; } - if(saveDataListCount > 0) + if (saveDataListCount > 0) { hasMultipleFileName = true; saveDataList = new SaveFileInfo[saveDataListCount]; @@ -1011,7 +1012,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) { DEBUG_LOG(HLE,"Name : %s",saveNameListData[i]); - std::string fileDataPath = savePath+GetGameName(param)+saveNameListData[i]+"/"+param->fileName; + std::string fileDataPath = savePath+GetGameName(param) + saveNameListData[i] + "/" + param->fileName; PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath); if (info.exists) { @@ -1033,7 +1034,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) saveNameListDataCount = realCount; } } - if(!hasMultipleFileName) // Load info on only save + if (!hasMultipleFileName) // Load info on only save { saveNameListData = 0; @@ -1044,7 +1045,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) // get and stock file info for each file DEBUG_LOG(HLE,"Name : %s",GetSaveName(param).c_str()); - std::string fileDataPath = savePath+GetGameName(param)+GetSaveName(param)+"/"+param->fileName; + std::string fileDataPath = savePath + GetGameName(param) + GetSaveName(param) + "/" + param->fileName; PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath); if (info.exists) { @@ -1187,7 +1188,8 @@ std::string SavedataParam::GetFilename(int idx) int SavedataParam::GetSelectedSave() { - return selectedSave; + // The slot # of the same save on LOAD/SAVE lists can dismatch so this isn't right anyhow + return selectedSave < saveNameListDataCount ? selectedSave : 0; } void SavedataParam::SetSelectedSave(int idx) @@ -1195,6 +1197,22 @@ void SavedataParam::SetSelectedSave(int idx) selectedSave = idx; } +int SavedataParam::GetLatestSave() +{ + int idx = 0; + time_t lastTime = 0; + for (int i = 0; i < saveDataListCount; ++i) + { + time_t thisTime = mktime(&saveDataList[i].modif_time); + if (lastTime < thisTime) + { + idx = i; + lastTime = thisTime; + } + } + return idx; +} + void SavedataParam::DoState(PointerWrap &p) { // pspParam is handled in PSPSaveDialog. diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index a993a0cd1f..e4ce11eaf8 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -223,6 +223,8 @@ public: int GetSelectedSave(); void SetSelectedSave(int idx); + int GetLatestSave(); + void DoState(PointerWrap &p); private: From c316bc9a3362fccf0a76345d5a93a038954db01a Mon Sep 17 00:00:00 2001 From: aquanull Date: Mon, 20 May 2013 19:03:58 +0800 Subject: [PATCH 4/4] Support more list focus settings. --- Core/Dialog/PSPSaveDialog.cpp | 36 +++++++++++++- Core/Dialog/SavedataParam.cpp | 90 +++++++++++++++++++++++++++++++++-- Core/Dialog/SavedataParam.h | 20 ++++++++ 3 files changed, 142 insertions(+), 4 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 0d3d174ffb..23d0452da5 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -55,7 +55,41 @@ int PSPSaveDialog::Init(int paramAddr) INFO_LOG(HLE,"Mode: %i", param.GetPspParam()->mode); yesnoChoice = 1; - currentSelectedSave = param.GetLatestSave(); + switch (param.GetPspParam()->focus) + { + case SCE_UTILITY_SAVEDATA_FOCUS_NAME: + currentSelectedSave = 0; + break; + case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTLIST: + currentSelectedSave = param.GetFirstListSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_LASTLIST: + currentSelectedSave = param.GetLastListSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_LATEST: + currentSelectedSave = param.GetLatestSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_OLDEST: + currentSelectedSave = param.GetOldestSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA: + currentSelectedSave = param.GetFirstDataSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_LASTDATA: + currentSelectedSave = param.GetLastDataSave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY: + currentSelectedSave = param.GetFirstEmptySave(); + break; + case SCE_UTILITY_SAVEDATA_FOCUS_LASTEMPTY: + currentSelectedSave = param.GetLastEmptySave(); + break; + default: + WARN_LOG(HLE, "Unknown save list focus option: %d", param.GetPspParam()->focus); + currentSelectedSave = 0; + break; + } + switch (param.GetPspParam()->mode) { case SCE_UTILITY_SAVEDATA_TYPE_LOAD: diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 1c648b8e3e..1780a4a7d1 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1197,17 +1197,101 @@ void SavedataParam::SetSelectedSave(int idx) selectedSave = idx; } +int SavedataParam::GetFirstListSave() +{ + return 0; +} + +int SavedataParam::GetLastListSave() +{ + return saveDataListCount - 1; +} + int SavedataParam::GetLatestSave() { int idx = 0; - time_t lastTime = 0; + time_t idxTime = 0; for (int i = 0; i < saveDataListCount; ++i) { time_t thisTime = mktime(&saveDataList[i].modif_time); - if (lastTime < thisTime) + if (idxTime < thisTime) { idx = i; - lastTime = thisTime; + idxTime = thisTime; + } + } + return idx; +} + +int SavedataParam::GetOldestSave() +{ + int idx = 0; + time_t idxTime = 0; + for (int i = 0; i < saveDataListCount; ++i) + { + time_t thisTime = mktime(&saveDataList[i].modif_time); + if (idxTime > thisTime) + { + idx = i; + idxTime = thisTime; + } + } + return idx; +} + +int SavedataParam::GetFirstDataSave() +{ + int idx = 0; + for (int i = 0; i < saveDataListCount; ++i) + { + if (saveDataList[i].size != 0) + { + idx = i;; + break; + } + } + return idx; +} + +int SavedataParam::GetLastDataSave() +{ + int idx = 0; + for (int i = saveDataListCount; i > 0; ) + { + --i; + if (saveDataList[i].size != 0) + { + idx = i; + break; + } + } + return idx; +} + +int SavedataParam::GetFirstEmptySave() +{ + int idx = 0; + for (int i = 0; i < saveDataListCount; ++i) + { + if (saveDataList[i].size == 0) + { + idx = i; + break; + } + } + return idx; +} + +int SavedataParam::GetLastEmptySave() +{ + int idx = 0; + for (int i = saveDataListCount; i > 0; ) + { + --i; + if (saveDataList[i].size == 0) + { + idx = i; + break; } } return idx; diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index e4ce11eaf8..37cea1a617 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -47,6 +47,19 @@ enum SceUtilitySavedataType SCE_UTILITY_SAVEDATA_TYPE_GETSIZE = 22, }; +enum SceUtilitySavedataFocus +{ + SCE_UTILITY_SAVEDATA_FOCUS_NAME = 0, // specified by saveName[] + SCE_UTILITY_SAVEDATA_FOCUS_FIRSTLIST = 1, // first listed (on screen or of all)? + SCE_UTILITY_SAVEDATA_FOCUS_LASTLIST = 2, // last listed (on screen or of all)? + SCE_UTILITY_SAVEDATA_FOCUS_LATEST = 3, // latest by modification date (first if none) + SCE_UTILITY_SAVEDATA_FOCUS_OLDEST = 4, // doldest by modification date (first if none) + SCE_UTILITY_SAVEDATA_FOCUS_FIRSTDATA = 5, // first non-empty (first if none) + SCE_UTILITY_SAVEDATA_FOCUS_LASTDATA = 6, // last non-empty (first if none) + SCE_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY = 7, // first empty (what if no empty?) + SCE_UTILITY_SAVEDATA_FOCUS_LASTEMPTY = 8, // last empty (what if no empty?) +}; + // title, savedataTitle, detail: parts of the unencrypted SFO // data, it contains what the VSH and standard load screen shows struct PspUtilitySavedataSFOParam @@ -223,7 +236,14 @@ public: int GetSelectedSave(); void SetSelectedSave(int idx); + int GetFirstListSave(); + int GetLastListSave(); int GetLatestSave(); + int GetOldestSave(); + int GetFirstDataSave(); + int GetLastDataSave(); + int GetFirstEmptySave(); + int GetLastEmptySave(); void DoState(PointerWrap &p);