mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-01-02 06:40:20 +01:00
cellPhotoExport: Use roughly same path as cellScreenShot
This commit is contained in:
parent
d85b9d0cd1
commit
953f9f7e01
|
|
@ -1,5 +1,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "Emu/VFS.h"
|
||||
#include "cellSysutil.h"
|
||||
|
|
@ -107,30 +108,16 @@ bool check_photo_path(const std::string& file_path)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string get_available_photo_path(const std::string& filename)
|
||||
std::string get_available_photo_path(std::string_view filename)
|
||||
{
|
||||
const std::string photo_dir = "/dev_hdd0/photo/";
|
||||
std::string dst_path = vfs::get(photo_dir + filename);
|
||||
|
||||
// Do not overwrite existing files. Add a suffix instead.
|
||||
for (u32 i = 0; fs::exists(dst_path); i++)
|
||||
std::string_view extension = ".png";
|
||||
if (const auto extension_start = filename.find_last_of('.');
|
||||
extension_start != umax)
|
||||
{
|
||||
const std::string suffix = fmt::format("_%d", i);
|
||||
std::string new_filename = filename;
|
||||
|
||||
if (const usz pos = new_filename.find_last_of('.'); pos != std::string::npos)
|
||||
{
|
||||
new_filename.insert(pos, suffix);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_filename.append(suffix);
|
||||
}
|
||||
|
||||
dst_path = vfs::get(photo_dir + new_filename);
|
||||
extension = filename.substr(extension_start);
|
||||
}
|
||||
|
||||
return dst_path;
|
||||
return Emu.GetCallbacks().get_photo_path(fmt::format("%s%s", Emu.GetTitle(), extension));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,22 +46,6 @@ std::string screenshot_info::get_game_comment() const
|
|||
return game_comment;
|
||||
}
|
||||
|
||||
std::string screenshot_info::get_screenshot_path(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const
|
||||
{
|
||||
u32 counter = 0;
|
||||
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%s", ++counter, extension);
|
||||
}
|
||||
|
||||
return path + suffix;
|
||||
}
|
||||
|
||||
|
||||
error_code cellScreenShotSetParameter(vm::cptr<CellScreenShotSetParam> param)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ 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(s32 year, s32 month, s32 day, s32 hour, s32 minute, s32 second) const;
|
||||
};
|
||||
|
||||
struct screenshot_manager : public screenshot_info
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ struct EmuCallbacks
|
|||
std::function<std::string(localized_string_id, const char*)> get_localized_string;
|
||||
std::function<std::u32string(localized_string_id, const char*)> get_localized_u32string;
|
||||
std::function<std::string(const cfg::_base*, u32)> get_localized_setting;
|
||||
std::function<std::string(std::string_view)> get_photo_path;
|
||||
std::function<void(const std::string&, std::optional<f32>)> play_sound;
|
||||
std::function<bool(const std::string&, std::string&, s32&, s32&, s32&)> get_image_info; // (filename, sub_type, width, height, CellSearchOrientation)
|
||||
std::function<bool(const std::string&, s32, s32, s32&, s32&, u8*, bool)> get_scaled_image; // (filename, target_width, target_height, width, height, dst, force_fit)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "Emu/Io/Null/NullMouseHandler.h"
|
||||
#include "Emu/Io/KeyboardHandler.h"
|
||||
#include "Emu/Io/MouseHandler.h"
|
||||
#include "Emu/VFS.h"
|
||||
#include "Input/basic_keyboard_handler.h"
|
||||
#include "Input/basic_mouse_handler.h"
|
||||
#include "Input/raw_mouse_handler.h"
|
||||
|
|
@ -36,6 +37,7 @@
|
|||
#include "Emu/Audio/FAudio/faudio_enumerator.h"
|
||||
#endif
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo> // This shouldn't be outside rpcs3qt...
|
||||
#include <QImageReader> // This shouldn't be outside rpcs3qt...
|
||||
#include <QStandardPaths> // This shouldn't be outside rpcs3qt...
|
||||
|
|
@ -377,5 +379,33 @@ EmuCallbacks main_application::CreateCallbacks()
|
|||
|
||||
callbacks.enable_gamemode = [](bool enabled){ enable_gamemode(enabled); };
|
||||
|
||||
callbacks.get_photo_path = [](std::string_view title)
|
||||
{
|
||||
const QDateTime date_time = QDateTime::currentDateTime();
|
||||
const QDate date = date_time.date();
|
||||
const QTime time = date_time.time();
|
||||
|
||||
std::string_view extension = ".png";
|
||||
if (const auto extension_start = title.find_last_of('.');
|
||||
extension_start != umax)
|
||||
{
|
||||
extension = title.substr(extension_start);
|
||||
title = title.substr(0, extension_start);
|
||||
}
|
||||
|
||||
std::string suffix = std::string(extension);
|
||||
const std::string path = vfs::get(fmt::format("/dev_hdd0/photo/%04d/%02d/%02d/%s %02d-%02d-%04d %02d-%02d-%02d",
|
||||
date.year(), date.month(), date.day(), vfs::escape(title, true),
|
||||
date.day(), date.month(), date.year(), time.hour(), time.minute(), time.second()));
|
||||
|
||||
u32 counter = 0;
|
||||
while (!Emu.IsStopped() && fs::is_file(path + suffix))
|
||||
{
|
||||
suffix = fmt::format(" %d%s", ++counter, extension);
|
||||
}
|
||||
|
||||
return path + suffix;
|
||||
};
|
||||
|
||||
return callbacks;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1040,9 +1040,7 @@ void gs_frame::take_screenshot(std::vector<u8>&& data, u32 sshot_width, u32 ssho
|
|||
}
|
||||
}
|
||||
|
||||
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_filename = Emu.GetCallbacks().get_photo_path(manager.get_photo_title() + ".png");
|
||||
const std::string cell_sshot_dir = fs::get_parent_dir(cell_sshot_filename);
|
||||
|
||||
screenshot_log.notice("Saving cell screenshot to %s", cell_sshot_filename);
|
||||
|
|
|
|||
Loading…
Reference in a new issue