This commit is contained in:
Megamouse 2025-12-15 18:13:40 +00:00 committed by GitHub
commit 7a8f55bbf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 15 deletions

View File

@ -33,18 +33,12 @@ std::string screenshot_info::get_overlay_path() const
std::string screenshot_info::get_photo_title() const
{
std::string photo = photo_title;
if (photo.empty())
photo = Emu.GetTitle();
return photo;
return photo_title.empty() ? Emu.GetTitle() : photo_title;
}
std::string screenshot_info::get_game_title() const
{
std::string game = game_title;
if (game.empty())
game = Emu.GetTitle();
return game;
return game_title.empty() ? Emu.GetTitle() : game_title;
}
std::string screenshot_info::get_game_comment() const
@ -52,15 +46,17 @@ std::string screenshot_info::get_game_comment() const
return game_comment;
}
std::string screenshot_info::get_screenshot_path(const std::string& date_path) const
std::string screenshot_info::get_screenshot_path(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const
{
u32 counter = 0;
std::string path = vfs::get("/dev_hdd0/photo/" + date_path + "/" + get_photo_title());
std::string suffix = ".png";
const std::string path = vfs::get(fmt::format("/dev_hdd0/photo/%04d/%02d/%02d/%s %02d-%02d-%04d %02d-%02d-%02d",
year, month, day, vfs::escape(get_photo_title(), true), day, month, year, hour, minute, second));
constexpr std::string_view extension = ".png";
std::string suffix = std::string(extension);
while (!Emu.IsStopped() && fs::is_file(path + suffix))
{
suffix = fmt::format("_%d.png", ++counter);
suffix = fmt::format(" %d%s", ++counter, extension);
}
return path + suffix;

View File

@ -44,7 +44,7 @@ struct screenshot_info
std::string get_photo_title() const;
std::string get_game_title() const;
std::string get_game_comment() const;
std::string get_screenshot_path(const std::string& date_path) const;
std::string get_screenshot_path(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const;
};
struct screenshot_manager : public screenshot_info

View File

@ -1040,7 +1040,9 @@ void gs_frame::take_screenshot(std::vector<u8>&& data, u32 sshot_width, u32 ssho
}
}
const std::string cell_sshot_filename = manager.get_screenshot_path(date_time.toString("yyyy/MM/dd").toStdString());
const QDate date = date_time.date();
const QTime time = date_time.time();
const std::string cell_sshot_filename = manager.get_screenshot_path(date.year(), date.month(), date.day(), time.hour(), time.minute(), time.second());
const std::string cell_sshot_dir = fs::get_parent_dir(cell_sshot_filename);
screenshot_log.notice("Saving cell screenshot to %s", cell_sshot_filename);

View File

@ -641,7 +641,7 @@ namespace gui
usz byte_unit = 0;
usz divisor = 1;
#if defined(__APPLE__)
constexpr usz multiplier = 1000;
constexpr usz multiplier = 1000;
static const QString s_units[]{"B", "kB", "MB", "GB", "TB", "PB"};
#else
constexpr usz multiplier = 1024;