mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
Fix game list update for auto-detection VFS games folder
This commit is contained in:
parent
e80809f629
commit
c5c99ec438
4 changed files with 38 additions and 16 deletions
|
@ -4139,6 +4139,28 @@ game_boot_result Emulator::AddGameToYml(const std::string& path)
|
|||
return game_boot_result::invalid_file_or_folder;
|
||||
}
|
||||
|
||||
u32 Emulator::RemoveGamesFromDir(const std::string games_dir, const std::vector<std::string>& serials_to_remove_from_yml, bool save_on_disk)
|
||||
{
|
||||
// List of serials (title id) to remove in "games.yml" file (if any)
|
||||
std::vector<std::string> serials_to_remove = serials_to_remove_from_yml; // Initialize the list with the specified serials (if any)
|
||||
|
||||
// Scan game list to detect the titles belonging to auto-detection "games_dir" folder
|
||||
for (const auto& [serial, path] : Emu.GetGamesConfig().get_games()) // Loop on game list file
|
||||
{
|
||||
// NOTE: Used starts_with(games_dir) instead of Emu.IsPathInsideDir(path, games_dir) due the latter would check
|
||||
// also the existence of the paths
|
||||
//
|
||||
if (path.starts_with(games_dir)) // If game path belongs to auto-detection "games_dir" folder, add the serial to the removal list
|
||||
{
|
||||
serials_to_remove.push_back(serial);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the specified and detected serials (title id) belonging to "games_dir" from the game list in memory
|
||||
// or also in "games.yml" file according to the value of "save_on_disk"
|
||||
return RemoveGames(serials_to_remove, save_on_disk);
|
||||
}
|
||||
|
||||
u32 Emulator::RemoveGames(const std::vector<std::string>& title_id_list, bool save_on_disk)
|
||||
{
|
||||
if (title_id_list.empty())
|
||||
|
|
|
@ -454,6 +454,7 @@ public:
|
|||
u32 AddGamesFromDir(const std::string& path);
|
||||
game_boot_result AddGame(const std::string& path);
|
||||
game_boot_result AddGameToYml(const std::string& path);
|
||||
u32 RemoveGamesFromDir(const std::string games_dir, const std::vector<std::string>& serials_to_remove_from_yml = {}, bool save_on_disk = true);
|
||||
u32 RemoveGames(const std::vector<std::string>& title_id_list, bool save_on_disk = true);
|
||||
game_boot_result RemoveGameFromYml(const std::string& title_id);
|
||||
|
||||
|
|
|
@ -419,22 +419,9 @@ void game_list_frame::Refresh(const bool from_drive, const std::vector<std::stri
|
|||
|
||||
const std::string games_dir = rpcs3::utils::get_games_dir();
|
||||
|
||||
// List of serials (title id) to remove in "games.yml" file (if any)
|
||||
std::vector<std::string> serials_to_remove = serials_to_remove_from_yml; // Initialize the list with the specified serials (if any)
|
||||
|
||||
// Scan game list to detect the titles belonging to auto-detection "games" folder
|
||||
for (const auto& [serial, path] : Emu.GetGamesConfig().get_games()) // Loop on game list file
|
||||
{
|
||||
// NOTE: Used starts_with(games_dir) instead of Emu.IsPathInsideDir(path, games_dir) due the latter would check also the existence of the paths
|
||||
//
|
||||
if (path.starts_with(games_dir)) // If game path belongs to auto-detection "games" folder, add the serial to the removal list
|
||||
{
|
||||
serials_to_remove.push_back(serial);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the specified and detected serials (title id) only from the game list in memory (not yet in "games.yml" file)
|
||||
Emu.RemoveGames(serials_to_remove, false);
|
||||
// Remove the specified and detected serials (title id) belonging to "games_dir" folder only from the game list in memory
|
||||
// (not yet in "games.yml" file)
|
||||
Emu.RemoveGamesFromDir(games_dir, serials_to_remove_from_yml, false);
|
||||
|
||||
// Scan auto-detection "games" folder adding the detected titles to the game list plus flushing also all the other changes in "games.yml" file
|
||||
if (const u32 games_added = Emu.AddGamesFromDir(games_dir); games_added != 0)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <QVBoxLayout>
|
||||
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/system_utils.hpp"
|
||||
#include "Emu/vfs_config.h"
|
||||
|
||||
vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> _gui_settings, QWidget* parent)
|
||||
|
@ -76,6 +77,17 @@ vfs_dialog::vfs_dialog(std::shared_ptr<gui_settings> _gui_settings, QWidget* par
|
|||
{
|
||||
static_cast<vfs_dialog_usb_tab*>(tabs->widget(i))->set_settings();
|
||||
}
|
||||
else if (tabs->tabText(i) == "games")
|
||||
{
|
||||
if (rpcs3::utils::get_games_dir() != static_cast<vfs_dialog_tab*>(tabs->widget(i))->get_selected_path())
|
||||
{ // If folder on "games" tab has been changed, reconciliate the game list first
|
||||
|
||||
// Remove the detected serials (title id) belonging to old folder from the game list in memory and also in "games.yml" file
|
||||
Emu.RemoveGamesFromDir(rpcs3::utils::get_games_dir());
|
||||
}
|
||||
|
||||
static_cast<vfs_dialog_tab*>(tabs->widget(i))->set_settings(); // set new folder
|
||||
}
|
||||
else
|
||||
{
|
||||
static_cast<vfs_dialog_tab*>(tabs->widget(i))->set_settings();
|
||||
|
|
Loading…
Add table
Reference in a new issue