save-overlays: add entry size info

This commit is contained in:
Megamouse 2021-04-24 17:59:55 +02:00
parent 14b6d6291b
commit 3c37036f7a
3 changed files with 24 additions and 3 deletions

View File

@ -16,6 +16,7 @@
#include "Loader/PSF.h"
#include "Utilities/StrUtil.h"
#include "Utilities/span.h"
#include "Utilities/date_time.h"
#include <mutex>
#include <algorithm>
@ -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<CellSaveDataSetList>;
using PSetBuf = vm::ptr<CellSaveDataSetBuf>;
@ -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)
{

View File

@ -352,6 +352,9 @@ struct SaveDataEntry
s64 ctime{0};
std::vector<uchar> iconBuf;
bool isNew{false};
std::string date() const;
std::string data_size() const;
};
class SaveDialogBase

View File

@ -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<overlay_element> e;
e = std::make_unique<save_dialog_entry>(entry.subtitle, modification_time, entry.details, image_resource_id::raw_image, entry.iconBuf);
e = std::make_unique<save_dialog_entry>(entry.subtitle, date_and_size, entry.details, image_resource_id::raw_image, entry.iconBuf);
entries.emplace_back(std::move(e));
}