diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 023651996203..c9dc74484393 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -459,59 +459,71 @@ void PSPSaveDialog::DisplaySaveDataInfo1() } } -void PSPSaveDialog::DisplaySaveDataInfo2() -{ +void PSPSaveDialog::DisplaySaveDataInfo2(bool showNewData) { std::lock_guard guard(paramLock); - if (param.GetFileInfo(currentSelectedSave).size == 0) { + + tm modif_time; + const char *save_title; + u32 data_size; + + if (showNewData || param.GetFileInfo(currentSelectedSave).size == 0) { + time_t t; + time(&t); + localtime_r(&t, &modif_time); + save_title = param.GetPspParam()->sfoParam.savedataTitle; + // TODO: Account for icon, etc., etc. + data_size = param.GetPspParam()->dataSize; } else { - char txt[1024]; - char date[256]; - char am_pm[] = "AM"; - char hour_time[10] ; - int hour = param.GetFileInfo(currentSelectedSave).modif_time.tm_hour; - int min = param.GetFileInfo(currentSelectedSave).modif_time.tm_min; - switch (g_Config.iTimeFormat) { - case 1: - if (hour > 12) { - strcpy(am_pm, "PM"); - hour -= 12; - } - snprintf(hour_time,10,"%02d:%02d %s", hour, min, am_pm); - break; - case 2: - snprintf(hour_time,10,"%02d:%02d", hour, min); - break; - default: - if (hour > 12) { - strcpy(am_pm, "PM"); - hour -= 12; - } - snprintf(hour_time,10,"%02d:%02d %s", hour, min, am_pm); - } + modif_time = param.GetFileInfo(currentSelectedSave).modif_time; + save_title = param.GetFileInfo(currentSelectedSave).saveTitle; + data_size = param.GetFileInfo(currentSelectedSave).size; + } - const char *saveTitle = param.GetFileInfo(currentSelectedSave).saveTitle; - int day = param.GetFileInfo(currentSelectedSave).modif_time.tm_mday; - int month = param.GetFileInfo(currentSelectedSave).modif_time.tm_mon + 1; - int year = param.GetFileInfo(currentSelectedSave).modif_time.tm_year + 1900; - s64 sizeK = param.GetFileInfo(currentSelectedSave).size / 1024; - switch (g_Config.iDateFormat) { - case 1: - snprintf(date, 256, "%d/%02d/%02d", year, month, day); - break; - case 2: - snprintf(date, 256, "%02d/%02d/%d", month, day, year); - break; - case 3: - snprintf(date, 256, "%02d/%02d/%d", day, month, year); - break; - default: - snprintf(date, 256, "%d/%02d/%02d", year, month, day); + char date[256]; + char am_pm[] = "AM"; + char hour_time[10] ; + int hour = modif_time.tm_hour; + int min = modif_time.tm_min; + switch (g_Config.iTimeFormat) { + case 1: + if (hour > 12) { + strcpy(am_pm, "PM"); + hour -= 12; + } + snprintf(hour_time, 10, "%02d:%02d %s", hour, min, am_pm); + break; + case 2: + snprintf(hour_time, 10, "%02d:%02d", hour, min); + break; + default: + if (hour > 12) { + strcpy(am_pm, "PM"); + hour -= 12; } - snprintf(txt, 1024, "%s\n%s %s\n%lld KB", saveTitle, date, hour_time, sizeK); - std::string saveinfoTxt = txt; - PPGeDrawText(saveinfoTxt.c_str(), 9, 202, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0x80000000)); - PPGeDrawText(saveinfoTxt.c_str(), 8, 200, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); + snprintf(hour_time, 10, "%02d:%02d %s", hour, min, am_pm); } + + int day = modif_time.tm_mday; + int month = modif_time.tm_mon + 1; + int year = modif_time.tm_year + 1900; + s64 sizeK = data_size / 1024; + switch (g_Config.iDateFormat) { + case 1: + snprintf(date, 256, "%d/%02d/%02d", year, month, day); + break; + case 2: + snprintf(date, 256, "%02d/%02d/%d", month, day, year); + break; + case 3: + snprintf(date, 256, "%02d/%02d/%d", day, month, year); + break; + default: + snprintf(date, 256, "%d/%02d/%02d", year, month, day); + } + + std::string saveinfoTxt = StringFromFormat("%.128s\n%s %s\n%lld KB", save_title, date, hour_time, sizeK); + PPGeDrawText(saveinfoTxt.c_str(), 9, 202, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0x80000000)); + PPGeDrawText(saveinfoTxt.c_str(), 8, 200, PPGE_ALIGN_LEFT, 0.5f, CalcFadedColor(0xFFFFFFFF)); } void PSPSaveDialog::DisplayMessage(std::string text, bool hasYesNo) @@ -637,7 +649,7 @@ int PSPSaveDialog::Update(int animSpeed) StartDraw(); DisplaySaveIcon(); - DisplaySaveDataInfo2(); + DisplaySaveDataInfo2(true); DisplayMessage(di->T("Confirm Save", "Do you want to save this data?"), true); @@ -687,7 +699,7 @@ int PSPSaveDialog::Update(int animSpeed) StartDraw(); DisplaySaveIcon(); - DisplaySaveDataInfo2(); + DisplaySaveDataInfo2(true); DisplayMessage(di->T("Saving","Saving\nPlease Wait...")); @@ -700,7 +712,7 @@ int PSPSaveDialog::Update(int animSpeed) StartDraw(); DisplaySaveIcon(); - DisplaySaveDataInfo2(); + DisplaySaveDataInfo2(true); DisplayMessage(di->T("SavingFailed", "Unable to save data.")); @@ -727,7 +739,7 @@ int PSPSaveDialog::Update(int animSpeed) StartDraw(); DisplaySaveIcon(); - DisplaySaveDataInfo2(); + DisplaySaveDataInfo2(true); DisplayMessage(di->T("Save completed")); diff --git a/Core/Dialog/PSPSaveDialog.h b/Core/Dialog/PSPSaveDialog.h index 128616f52005..c0d42e495531 100644 --- a/Core/Dialog/PSPSaveDialog.h +++ b/Core/Dialog/PSPSaveDialog.h @@ -92,7 +92,7 @@ class PSPSaveDialog: public PSPDialog { void DisplaySaveList(bool canMove = true); void DisplaySaveIcon(); void DisplaySaveDataInfo1(); - void DisplaySaveDataInfo2(); + void DisplaySaveDataInfo2(bool showNewData = false); void DisplayMessage(std::string text, bool hasYesNo = false); const std::string GetSelectedSaveDirName() const; diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index ac506478bc88..ff5a6d964a8e 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1456,8 +1456,7 @@ void SavedataParam::SetFileInfo(int idx, PSPFileInfo &info, std::string saveName saveDataList[idx].idx = idx; } -void SavedataParam::ClearFileInfo(SaveFileInfo &saveInfo, std::string saveName) -{ +void SavedataParam::ClearFileInfo(SaveFileInfo &saveInfo, const std::string &saveName) { saveInfo.size = 0; saveInfo.saveName = saveName; saveInfo.idx = 0; @@ -1468,16 +1467,17 @@ void SavedataParam::ClearFileInfo(SaveFileInfo &saveInfo, std::string saveName) saveInfo.texture = NULL; } - if (GetPspParam()->newData.IsValid() && GetPspParam()->newData->buf.IsValid()) - { + if (GetPspParam()->newData.IsValid() && GetPspParam()->newData->buf.IsValid()) { // We have a png to show - if (!noSaveIcon) - { + if (!noSaveIcon) { noSaveIcon = new SaveFileInfo(); PspUtilitySavedataFileData *newData = GetPspParam()->newData; noSaveIcon->texture = new PPGeImage(newData->buf.ptr, (SceSize)newData->size); } saveInfo.texture = noSaveIcon->texture; + } else if ((u32)GetPspParam()->mode == SCE_UTILITY_SAVEDATA_TYPE_SAVE && GetPspParam()->icon0FileData.buf.IsValid()) { + const PspUtilitySavedataFileData &icon0FileData = GetPspParam()->icon0FileData; + saveInfo.texture = new PPGeImage(icon0FileData.buf.ptr, (SceSize)icon0FileData.size); } } diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index cccfbfc1086c..0ea0e4ae61bc 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -352,7 +352,7 @@ class SavedataParam void Clear(); void SetFileInfo(int idx, PSPFileInfo &info, std::string saveName); void SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std::string saveName); - void ClearFileInfo(SaveFileInfo &saveInfo, std::string saveName); + void ClearFileInfo(SaveFileInfo &saveInfo, const std::string &saveName); bool LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string& dirPath, bool secureMode); void LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8 *saveData, int &saveSize, int prevCryptMode, bool &saveDone);