Qt: Add Recent savestates menu

This commit is contained in:
Megamouse 2025-01-23 00:30:53 +01:00
parent 448666c896
commit ba702509c8
8 changed files with 248 additions and 138 deletions

View file

@ -1117,47 +1117,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
}
else
{
fs::file save{m_path, fs::isfile + fs::read};
if (m_path.ends_with(".SAVESTAT") && save && save.size() >= 8 && save.read<u64>() == "RPCS3SAV"_u64)
{
m_ar = std::make_shared<utils::serial>();
m_ar->set_reading_state();
m_ar->m_file_handler = make_uncompressed_serialization_file_handler(std::move(save));
}
else if (save && m_path.ends_with(".zst"))
{
m_ar = std::make_shared<utils::serial>();
m_ar->set_reading_state();
m_ar->m_file_handler = make_compressed_zstd_serialization_file_handler(std::move(save));
if (m_ar->try_read<u64>().second != "RPCS3SAV"_u64)
{
m_ar.reset();
}
else
{
m_ar->pos = 0;
}
}
else if (save && m_path.ends_with(".gz"))
{
m_ar = std::make_shared<utils::serial>();
m_ar->set_reading_state();
m_ar->m_file_handler = make_compressed_serialization_file_handler(std::move(save));
if (m_ar->try_read<u64>().second != "RPCS3SAV"_u64)
{
m_ar.reset();
}
else
{
m_ar->pos = 0;
}
}
m_ar = make_savestate_reader(m_path);
m_boot_source_type = CELL_GAME_GAMETYPE_SYS;
}
@ -1189,18 +1149,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
if (m_ar)
{
struct file_header
{
ENABLE_BITWISE_SERIALIZATION;
nse_t<u64, 1> magic;
bool LE_format;
bool state_inspection_support;
nse_t<u64, 1> offset;
b8 flag_versions_is_following_data;
};
const auto header = m_ar->try_read<file_header>().second;
const auto header = m_ar->try_read<savestate_header>().second;
if (header.magic != "RPCS3SAV"_u64)
{
@ -1329,7 +1278,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
if (m_ar->m_max_data != m_ar->pos)
{
fmt::throw_exception("TAR desrialization failed: read bytes: 0x%x, expected: 0x%x, path='%s', ar: %s", m_ar->pos - (m_ar->m_max_data - size), size, path, *m_ar);
fmt::throw_exception("TAR deserialization failed: read bytes: 0x%x, expected: 0x%x, path='%s', ar: %s", m_ar->pos - (m_ar->m_max_data - size), size, path, *m_ar);
}
m_ar->m_max_data = umax;