From 407cbf9690f55d54ef73b3496891fa8e339b2ea6 Mon Sep 17 00:00:00 2001 From: Functionable <40835042+Functionable@users.noreply.github.com> Date: Wed, 7 Jan 2026 18:47:12 +0000 Subject: [PATCH] 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. --- rpcs3/Emu/System.cpp | 35 ++++++++++++++++++++++++++++++++--- rpcs3/rpcs3qt/main_window.cpp | 5 +++-- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f0addb4be1..2608de03e3 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -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 archive; + if (is_file_iso(path)) + { + archive = std::make_unique(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; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 0456da3502..b32e2ded34 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -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; }