mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 15:01:28 +12:00
System: don't consider games as registered if they were already in games.yml
Also, show message if nothing was added
This commit is contained in:
parent
d33955c290
commit
5fe36872c5
6 changed files with 87 additions and 31 deletions
|
@ -137,6 +137,7 @@ void fmt_class_string<game_boot_result>::format(std::string& out, u64 arg)
|
||||||
case game_boot_result::savestate_corrupted: return "Savestate data is corrupted or it's not an RPCS3 savestate";
|
case game_boot_result::savestate_corrupted: return "Savestate data is corrupted or it's not an RPCS3 savestate";
|
||||||
case game_boot_result::savestate_version_unsupported: return "Savestate versioning data differs from your RPCS3 build.\nTry to use an older or newer RPCS3 build.\nEspecially if you know the build that created the savestate.";
|
case game_boot_result::savestate_version_unsupported: return "Savestate versioning data differs from your RPCS3 build.\nTry to use an older or newer RPCS3 build.\nEspecially if you know the build that created the savestate.";
|
||||||
case game_boot_result::still_running: return "Game is still running";
|
case game_boot_result::still_running: return "Game is still running";
|
||||||
|
case game_boot_result::already_added: return "Game was already added";
|
||||||
}
|
}
|
||||||
return unknown;
|
return unknown;
|
||||||
});
|
});
|
||||||
|
@ -1758,11 +1759,11 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store /dev_bdvd/ location
|
// Store /dev_bdvd/ location
|
||||||
if (m_games_config.add_game(m_title_id, bdvd_dir))
|
if (games_config::result res = m_games_config.add_game(m_title_id, bdvd_dir); res == games_config::result::success)
|
||||||
{
|
{
|
||||||
sys_log.notice("Registered BDVD game directory for title '%s': %s", m_title_id, bdvd_dir);
|
sys_log.notice("Registered BDVD game directory for title '%s': %s", m_title_id, bdvd_dir);
|
||||||
}
|
}
|
||||||
else
|
else if (res == games_config::result::failure)
|
||||||
{
|
{
|
||||||
sys_log.error("Failed to save BDVD location of title '%s' (error=%s)", m_title_id, fs::g_tls_error);
|
sys_log.error("Failed to save BDVD location of title '%s' (error=%s)", m_title_id, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
|
@ -1818,7 +1819,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
|
||||||
std::string game_dir = m_sfo_dir;
|
std::string game_dir = m_sfo_dir;
|
||||||
|
|
||||||
// Add HG games not in HDD0 to games.yml
|
// Add HG games not in HDD0 to games.yml
|
||||||
[[maybe_unused]] const bool res = m_games_config.add_external_hdd_game(m_title_id, game_dir);
|
[[maybe_unused]] const games_config::result res = m_games_config.add_external_hdd_game(m_title_id, game_dir);
|
||||||
|
|
||||||
const std::string dir = fmt::trim(game_dir.substr(fs::get_parent_dir_view(game_dir).size() + 1), fs::delim);
|
const std::string dir = fmt::trim(game_dir.substr(fs::get_parent_dir_view(game_dir).size() + 1), fs::delim);
|
||||||
vfs::mount("/dev_hdd0/game/" + dir, game_dir + '/');
|
vfs::mount("/dev_hdd0/game/" + dir, game_dir + '/');
|
||||||
|
@ -1844,11 +1845,11 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
|
||||||
sys_log.notice("Game: %s", new_ps3_game);
|
sys_log.notice("Game: %s", new_ps3_game);
|
||||||
|
|
||||||
// Store /dev_bdvd/PS3_GAME location
|
// Store /dev_bdvd/PS3_GAME location
|
||||||
if (m_games_config.add_game(m_title_id, new_ps3_game + "/./"))
|
if (games_config::result res = m_games_config.add_game(m_title_id, new_ps3_game + "/./"); res == games_config::result::success)
|
||||||
{
|
{
|
||||||
sys_log.notice("Registered BDVD/PS3_GAME game directory for title '%s': %s", m_title_id, new_ps3_game);
|
sys_log.notice("Registered BDVD/PS3_GAME game directory for title '%s': %s", m_title_id, new_ps3_game);
|
||||||
}
|
}
|
||||||
else
|
else if (res == games_config::result::failure)
|
||||||
{
|
{
|
||||||
sys_log.error("Failed to save BDVD/PS3_GAME location of title '%s' (error=%s)", m_title_id, fs::g_tls_error);
|
sys_log.error("Failed to save BDVD/PS3_GAME location of title '%s' (error=%s)", m_title_id, fs::g_tls_error);
|
||||||
}
|
}
|
||||||
|
@ -3626,14 +3627,16 @@ std::set<std::string> Emulator::GetGameDirs() const
|
||||||
return dirs;
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::AddGamesFromDir(const std::string& path)
|
u32 Emulator::AddGamesFromDir(const std::string& path)
|
||||||
{
|
{
|
||||||
|
u32 games_added = 0;
|
||||||
|
|
||||||
m_games_config.set_save_on_dirty(false);
|
m_games_config.set_save_on_dirty(false);
|
||||||
|
|
||||||
// search dropped path first or else the direct parent to an elf is wrongly skipped
|
// search dropped path first or else the direct parent to an elf is wrongly skipped
|
||||||
if (const auto error = AddGame(path); error == game_boot_result::no_errors)
|
if (const game_boot_result error = AddGame(path); error == game_boot_result::no_errors)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
games_added++;
|
||||||
}
|
}
|
||||||
|
|
||||||
process_qt_events();
|
process_qt_events();
|
||||||
|
@ -3648,9 +3651,9 @@ void Emulator::AddGamesFromDir(const std::string& path)
|
||||||
|
|
||||||
const std::string dir_path = path + '/' + dir_entry.name;
|
const std::string dir_path = path + '/' + dir_entry.name;
|
||||||
|
|
||||||
if (const auto error = AddGame(dir_path); error == game_boot_result::no_errors)
|
if (const game_boot_result error = AddGame(dir_path); error == game_boot_result::no_errors)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
games_added++;
|
||||||
}
|
}
|
||||||
|
|
||||||
process_qt_events();
|
process_qt_events();
|
||||||
|
@ -3662,6 +3665,8 @@ void Emulator::AddGamesFromDir(const std::string& path)
|
||||||
{
|
{
|
||||||
sys_log.error("Failed to save games.yml after adding games");
|
sys_log.error("Failed to save games.yml after adding games");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return games_added;
|
||||||
}
|
}
|
||||||
|
|
||||||
game_boot_result Emulator::AddGame(const std::string& path)
|
game_boot_result Emulator::AddGame(const std::string& path)
|
||||||
|
@ -3673,12 +3678,14 @@ game_boot_result Emulator::AddGame(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
game_boot_result result = game_boot_result::nothing_to_boot;
|
game_boot_result result = game_boot_result::nothing_to_boot;
|
||||||
|
bool result_set = false;
|
||||||
|
|
||||||
std::string elf;
|
std::string elf;
|
||||||
if (const game_boot_result res = GetElfPathFromDir(elf, path); res == game_boot_result::no_errors)
|
if (const game_boot_result res = GetElfPathFromDir(elf, path); res == game_boot_result::no_errors)
|
||||||
{
|
{
|
||||||
ensure(!elf.empty());
|
ensure(!elf.empty());
|
||||||
result = AddGameToYml(elf);
|
result = AddGameToYml(elf);
|
||||||
|
result_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto&& entry : fs::dir{ path })
|
for (auto&& entry : fs::dir{ path })
|
||||||
|
@ -3696,7 +3703,11 @@ game_boot_result Emulator::AddGame(const std::string& path)
|
||||||
{
|
{
|
||||||
if (const auto err = AddGameToYml(elf); err != game_boot_result::no_errors)
|
if (const auto err = AddGameToYml(elf); err != game_boot_result::no_errors)
|
||||||
{
|
{
|
||||||
result = err;
|
if (err != game_boot_result::already_added || !result_set)
|
||||||
|
{
|
||||||
|
result = err;
|
||||||
|
result_set = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3769,9 +3780,11 @@ game_boot_result Emulator::AddGameToYml(const std::string& path)
|
||||||
// Add HG games not in HDD0 to games.yml
|
// Add HG games not in HDD0 to games.yml
|
||||||
if (cat == "HG")
|
if (cat == "HG")
|
||||||
{
|
{
|
||||||
if (m_games_config.add_external_hdd_game(title_id, sfo_dir))
|
switch (m_games_config.add_external_hdd_game(title_id, sfo_dir))
|
||||||
{
|
{
|
||||||
return game_boot_result::no_errors;
|
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;
|
return game_boot_result::generic_error;
|
||||||
|
@ -3786,13 +3799,24 @@ game_boot_result Emulator::AddGameToYml(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store /dev_bdvd/ location
|
// Store /dev_bdvd/ location
|
||||||
if (m_games_config.add_game(title_id, bdvd_dir))
|
switch (m_games_config.add_game(title_id, bdvd_dir))
|
||||||
|
{
|
||||||
|
case games_config::result::failure:
|
||||||
|
{
|
||||||
|
sys_log.error("Failed to save BDVD location of title '%s' (error=%s)", title_id, fs::g_tls_error);
|
||||||
|
return game_boot_result::generic_error;
|
||||||
|
}
|
||||||
|
case games_config::result::success:
|
||||||
{
|
{
|
||||||
sys_log.notice("Registered BDVD game directory for title '%s': %s", title_id, bdvd_dir);
|
sys_log.notice("Registered BDVD game directory for title '%s': %s", title_id, bdvd_dir);
|
||||||
return game_boot_result::no_errors;
|
return game_boot_result::no_errors;
|
||||||
}
|
}
|
||||||
|
case games_config::result::exists:
|
||||||
|
{
|
||||||
|
return game_boot_result::already_added;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sys_log.error("Failed to save BDVD location of title '%s' (error=%s)", title_id, fs::g_tls_error);
|
|
||||||
return game_boot_result::generic_error;
|
return game_boot_result::generic_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ enum class game_boot_result : u32
|
||||||
savestate_corrupted,
|
savestate_corrupted,
|
||||||
savestate_version_unsupported,
|
savestate_version_unsupported,
|
||||||
still_running,
|
still_running,
|
||||||
|
already_added,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr bool is_error(game_boot_result res)
|
constexpr bool is_error(game_boot_result res)
|
||||||
|
@ -369,7 +370,7 @@ public:
|
||||||
void ConfigurePPUCache(bool with_title_id = true) const;
|
void ConfigurePPUCache(bool with_title_id = true) const;
|
||||||
|
|
||||||
std::set<std::string> GetGameDirs() const;
|
std::set<std::string> GetGameDirs() const;
|
||||||
void AddGamesFromDir(const std::string& path);
|
u32 AddGamesFromDir(const std::string& path);
|
||||||
game_boot_result AddGame(const std::string& path);
|
game_boot_result AddGame(const std::string& path);
|
||||||
game_boot_result AddGameToYml(const std::string& path);
|
game_boot_result AddGameToYml(const std::string& path);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ std::string games_config::get_path(const std::string& title_id) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool games_config::add_game(const std::string& key, const std::string& path)
|
games_config::result games_config::add_game(const std::string& key, const std::string& path)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(m_mutex);
|
std::lock_guard lock(m_mutex);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ bool games_config::add_game(const std::string& key, const std::string& path)
|
||||||
if (it->second == path)
|
if (it->second == path)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return true;
|
return result::exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
it->second = path;
|
it->second = path;
|
||||||
|
@ -64,15 +64,15 @@ bool games_config::add_game(const std::string& key, const std::string& path)
|
||||||
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
|
||||||
if (m_save_on_dirty)
|
if (m_save_on_dirty && !save_nl())
|
||||||
{
|
{
|
||||||
return save_nl();
|
return result::failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return result::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool games_config::add_external_hdd_game(const std::string& key, std::string& path)
|
games_config::result games_config::add_external_hdd_game(const std::string& key, std::string& path)
|
||||||
{
|
{
|
||||||
// Don't use the C00 subdirectory in our game list
|
// Don't use the C00 subdirectory in our game list
|
||||||
if (path.ends_with("/C00") || path.ends_with("\\C00"))
|
if (path.ends_with("/C00") || path.ends_with("\\C00"))
|
||||||
|
@ -80,14 +80,21 @@ bool games_config::add_external_hdd_game(const std::string& key, std::string& pa
|
||||||
path = path.substr(0, path.size() - 4);
|
path = path.substr(0, path.size() - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (add_game(key, path))
|
const result res = add_game(key, path);
|
||||||
|
|
||||||
|
switch (res)
|
||||||
{
|
{
|
||||||
|
case result::failure:
|
||||||
|
cfg_log.error("Failed to save HG game location of title '%s' (error=%s)", key, fs::g_tls_error);
|
||||||
|
break;
|
||||||
|
case result::success:
|
||||||
cfg_log.notice("Registered HG game directory for title '%s': %s", key, path);
|
cfg_log.notice("Registered HG game directory for title '%s': %s", key, path);
|
||||||
return true;
|
break;
|
||||||
|
case result::exists:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_log.error("Failed to save HG game location of title '%s' (error=%s)", key, fs::g_tls_error);
|
return res;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool games_config::save_nl()
|
bool games_config::save_nl()
|
||||||
|
|
|
@ -16,8 +16,14 @@ public:
|
||||||
|
|
||||||
std::string get_path(const std::string& title_id) const;
|
std::string get_path(const std::string& title_id) const;
|
||||||
|
|
||||||
bool add_game(const std::string& key, const std::string& path);
|
enum class result
|
||||||
bool add_external_hdd_game(const std::string& key, std::string& path);
|
{
|
||||||
|
failure,
|
||||||
|
success,
|
||||||
|
exists
|
||||||
|
};
|
||||||
|
result add_game(const std::string& key, const std::string& path);
|
||||||
|
result add_external_hdd_game(const std::string& key, std::string& path);
|
||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -346,7 +346,13 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
|
||||||
m_progress_dialog_timer->start();
|
m_progress_dialog_timer->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.AddGamesFromDir(g_cfg_vfs.get(g_cfg_vfs.games_dir, rpcs3::utils::get_emu_dir()));
|
const std::string games_dir = g_cfg_vfs.get(g_cfg_vfs.games_dir, rpcs3::utils::get_emu_dir());
|
||||||
|
const u32 games_added = Emu.AddGamesFromDir(games_dir);
|
||||||
|
|
||||||
|
if (games_added)
|
||||||
|
{
|
||||||
|
game_list_log.notice("Refresh added %d new entries found in %s", games_added, games_dir);
|
||||||
|
}
|
||||||
|
|
||||||
const std::string _hdd = Emu.GetCallbacks().resolve_path(rpcs3::utils::get_hdd0_dir()) + '/';
|
const std::string _hdd = Emu.GetCallbacks().resolve_path(rpcs3::utils::get_hdd0_dir()) + '/';
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,7 @@ void main_window::show_boot_error(game_boot_result status)
|
||||||
message = tr("A game or PS3 application is still running or has yet to be fully stopped.");
|
message = tr("A game or PS3 application is still running or has yet to be fully stopped.");
|
||||||
break;
|
break;
|
||||||
case game_boot_result::firmware_missing: // Handled elsewhere
|
case game_boot_result::firmware_missing: // Handled elsewhere
|
||||||
|
case game_boot_result::already_added: // Handled elsewhere
|
||||||
case game_boot_result::no_errors:
|
case game_boot_result::no_errors:
|
||||||
return;
|
return;
|
||||||
case game_boot_result::generic_error:
|
case game_boot_result::generic_error:
|
||||||
|
@ -3546,9 +3547,16 @@ void main_window::AddGamesFromDirs(QStringList&& paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 games_added = 0;
|
||||||
|
|
||||||
for (const QString& path : paths)
|
for (const QString& path : paths)
|
||||||
{
|
{
|
||||||
Emu.AddGamesFromDir(sstr(path));
|
games_added += Emu.AddGamesFromDir(sstr(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (games_added)
|
||||||
|
{
|
||||||
|
gui_log.notice("AddGamesFromDirs added %d new entries", games_added);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_game_list_frame->AddRefreshedSlot([this, paths = std::move(paths), existing = std::move(existing)](std::set<std::string>& claimed_paths)
|
m_game_list_frame->AddRefreshedSlot([this, paths = std::move(paths), existing = std::move(existing)](std::set<std::string>& claimed_paths)
|
||||||
|
@ -3580,7 +3588,11 @@ void main_window::AddGamesFromDirs(QStringList&& paths)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!paths_added.empty())
|
if (paths_added.empty())
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("Nothing to add!"), tr("Could not find any new software."));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), paths_added);
|
ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), paths_added);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue