From 3c37036f7ae7096941dda375b6dadde7a49581d2 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 24 Apr 2021 17:59:55 +0200 Subject: [PATCH] save-overlays: add entry size info --- rpcs3/Emu/Cell/Modules/cellSaveData.cpp | 20 ++++++++++++++++++- rpcs3/Emu/Cell/Modules/cellSaveData.h | 3 +++ .../Emu/RSX/Overlays/overlay_save_dialog.cpp | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp index b9148a8f3b..9712123987 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.cpp @@ -16,6 +16,7 @@ #include "Loader/PSF.h" #include "Utilities/StrUtil.h" #include "Utilities/span.h" +#include "Utilities/date_time.h" #include #include @@ -53,6 +54,23 @@ SaveDialogBase::~SaveDialogBase() { } +std::string SaveDataEntry::date() const +{ + return date_time::fmt_time("%c", mtime); +} + +std::string SaveDataEntry::data_size() const +{ + std::string metric = "KB"; + u64 sz = utils::aligned_div(size, 1000); + if (sz > 1000) + { + metric = "MB"; + sz = utils::aligned_div(sz, 1000); + } + return fmt::format("%lu %s", sz, metric); +} + // cellSaveData aliases (only for cellSaveData.cpp) using PSetList = vm::ptr; using PSetBuf = vm::ptr; @@ -315,7 +333,7 @@ static error_code display_callback_result_error_message(ppu_thread& ppu, const C static std::string get_confirmation_message(u32 operation, const SaveDataEntry& entry) { - const std::string info = entry.title + "\n" + entry.subtitle + "\n" + entry.details; + const std::string info = fmt::format("%s\n%s\n%s\n%s\n\n%s", entry.title, entry.subtitle, entry.date(), entry.data_size(), entry.details); if (operation == SAVEDATA_OP_LIST_DELETE || operation == SAVEDATA_OP_FIXED_DELETE) { diff --git a/rpcs3/Emu/Cell/Modules/cellSaveData.h b/rpcs3/Emu/Cell/Modules/cellSaveData.h index baa46bdea3..c88a4a3f9a 100644 --- a/rpcs3/Emu/Cell/Modules/cellSaveData.h +++ b/rpcs3/Emu/Cell/Modules/cellSaveData.h @@ -352,6 +352,9 @@ struct SaveDataEntry s64 ctime{0}; std::vector iconBuf; bool isNew{false}; + + std::string date() const; + std::string data_size() const; }; class SaveDialogBase diff --git a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp index 6faf181320..754a563ead 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_save_dialog.cpp @@ -178,9 +178,9 @@ namespace rsx for (auto& entry : save_entries) { - const std::string modification_time = date_time::fmt_time("%c", entry.mtime); + const std::string date_and_size = fmt::format("%s %s", entry.date(), entry.data_size()); std::unique_ptr e; - e = std::make_unique(entry.subtitle, modification_time, entry.details, image_resource_id::raw_image, entry.iconBuf); + e = std::make_unique(entry.subtitle, date_and_size, entry.details, image_resource_id::raw_image, entry.iconBuf); entries.emplace_back(std::move(e)); }