mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-01-13 20:20:25 +01:00
ISO: Add ISO games through Emulator::AddGamesFromDir
- When dragging and dropping ISO files, they will be treated the same as game directories currently are and added to the game list rather than immediately being opened.
This commit is contained in:
parent
4cd75971f0
commit
407cbf9690
|
|
@ -4099,13 +4099,18 @@ u32 Emulator::AddGamesFromDir(const std::string& path)
|
|||
{
|
||||
auto dir_entry = std::move(*path_it);
|
||||
|
||||
if (!dir_entry.is_directory || dir_entry.name == "." || dir_entry.name == "..")
|
||||
if (dir_entry.name == "." || dir_entry.name == "..")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string dir_path = path + '/' + dir_entry.name;
|
||||
|
||||
if (!dir_entry.is_directory && !is_file_iso(dir_path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (const game_boot_result error = AddGame(dir_path); error == game_boot_result::no_errors)
|
||||
{
|
||||
games_added++;
|
||||
|
|
@ -4203,10 +4208,17 @@ game_boot_result Emulator::AddGameToYml(const std::string& path)
|
|||
return error;
|
||||
}
|
||||
|
||||
std::unique_ptr<iso_archive> archive;
|
||||
if (is_file_iso(path))
|
||||
{
|
||||
archive = std::make_unique<iso_archive>(path);
|
||||
}
|
||||
|
||||
// Load PARAM.SFO
|
||||
const std::string elf_dir = fs::get_parent_dir(path);
|
||||
std::string sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(fs::get_parent_dir(elf_dir));
|
||||
const psf::registry _psf = psf::load_object(sfo_dir + "/PARAM.SFO");
|
||||
std::string sfo_dir = !archive ? rpcs3::utils::get_sfo_dir_from_game_path(fs::get_parent_dir(elf_dir)) : "PS3_GAME";
|
||||
const std::string sfo_path = sfo_dir + "/PARAM.SFO";
|
||||
const psf::registry _psf = !archive ? psf::load_object(sfo_path) : archive->open_psf(sfo_path);
|
||||
|
||||
const std::string title_id = std::string(psf::get_string(_psf, "TITLE_ID"));
|
||||
const std::string cat = std::string(psf::get_string(_psf, "CATEGORY"));
|
||||
|
|
@ -4229,6 +4241,23 @@ game_boot_result Emulator::AddGameToYml(const std::string& path)
|
|||
return game_boot_result::invalid_file_or_folder;
|
||||
}
|
||||
|
||||
// Add ISO game
|
||||
if (archive)
|
||||
{
|
||||
if (cat == "DG")
|
||||
{
|
||||
std::string iso_path = path;
|
||||
switch (m_games_config.add_external_hdd_game(title_id, iso_path))
|
||||
{
|
||||
case games_config::result::failure: return game_boot_result::generic_error;
|
||||
case games_config::result::success: return game_boot_result::no_errors;
|
||||
case games_config::result::exists: return game_boot_result::already_added;
|
||||
}
|
||||
|
||||
return game_boot_result::generic_error;
|
||||
}
|
||||
}
|
||||
|
||||
// Set bdvd_dir
|
||||
std::string bdvd_dir;
|
||||
std::string game_dir;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
#include "Loader/PUP.h"
|
||||
#include "Loader/TAR.h"
|
||||
#include "Loader/PSF.h"
|
||||
#include "Loader/ISO.h"
|
||||
#include "Loader/mself.hpp"
|
||||
|
||||
#include "Utilities/Thread.h"
|
||||
|
|
@ -3959,7 +3960,7 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
|
|||
const QString suffix_lo = info.suffix().toLower();
|
||||
|
||||
// check for directories first, only valid if all other paths led to directories until now.
|
||||
if (info.isDir())
|
||||
if (info.isDir() || is_file_iso(path.toStdString()))
|
||||
{
|
||||
if (type != drop_type::drop_dir && type != drop_type::drop_error)
|
||||
{
|
||||
|
|
@ -4020,7 +4021,7 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
|
|||
type = drop_type::drop_rrc;
|
||||
}
|
||||
// The emulator allows to execute ANY filetype, just not from drag-and-drop because it is confusing to users
|
||||
else if (path.toLower().endsWith(".savestat.gz") || path.toLower().endsWith(".savestat.zst") || suffix_lo == "savestat" || suffix_lo == "sprx" || suffix_lo == "self" || suffix_lo == "bin" || suffix_lo == "prx" || suffix_lo == "elf" || suffix_lo == "o" || suffix_lo == "iso")
|
||||
else if (path.toLower().endsWith(".savestat.gz") || path.toLower().endsWith(".savestat.zst") || suffix_lo == "savestat" || suffix_lo == "sprx" || suffix_lo == "self" || suffix_lo == "bin" || suffix_lo == "prx" || suffix_lo == "elf" || suffix_lo == "o")
|
||||
{
|
||||
type = drop_type::drop_game;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue