diff --git a/rpcs3/Emu/GameInfo.h b/rpcs3/Emu/GameInfo.h index 99f46ea041..dbb5c2c4b7 100644 --- a/rpcs3/Emu/GameInfo.h +++ b/rpcs3/Emu/GameInfo.h @@ -6,42 +6,20 @@ struct GameInfo { std::string path; - std::string icon_path; - std::string name; - std::string serial; - std::string app_ver; - std::string version; - std::string category; - std::string fw; + + std::string name = "Unknown"; + std::string serial = "Unknown"; + std::string app_ver = "Unknown"; + std::string version = "Unknown"; + std::string category = "Unknown"; + std::string fw = "Unknown"; u32 attr = 0; u32 bootable = 0; u32 parental_lvl = 0; u32 sound_format = 0; u32 resolution = 0; + usz size_on_disk = umax; - - GameInfo() - { - Reset(); - } - - void Reset() - { - path.clear(); - - name = "Unknown"; - serial = "Unknown"; - app_ver = "Unknown"; - version = "Unknown"; - category = "Unknown"; - fw = "Unknown"; - - attr = 0; - bootable = 0; - parental_lvl = 0; - sound_format = 0; - resolution = 0; - } }; diff --git a/rpcs3/rpcs3qt/game_list.h b/rpcs3/rpcs3qt/game_list.h index e7005e35a8..8fce6d2088 100644 --- a/rpcs3/rpcs3qt/game_list.h +++ b/rpcs3/rpcs3qt/game_list.h @@ -12,7 +12,7 @@ class movie_item; /* Having the icons associated with the game info simplifies logic internally */ struct gui_game_info { - GameInfo info; + GameInfo info{}; QString localized_category; compat::status compat; QPixmap icon; diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index c89fd12be8..e23d14d57e 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -139,6 +139,12 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, std connect(&m_refresh_watcher, &QFutureWatcher::finished, this, &game_list_frame::OnRefreshFinished); connect(&m_refresh_watcher, &QFutureWatcher::canceled, this, [this]() { + if (m_size_watcher.isRunning()) + { + m_size_watcher.cancel(); + m_size_watcher.waitForFinished(); + } + if (m_repaint_watcher.isRunning()) { m_repaint_watcher.cancel(); @@ -159,6 +165,10 @@ game_list_frame::game_list_frame(std::shared_ptr gui_settings, std item->call_icon_func(); } }); + connect(&m_size_watcher, &QFutureWatcher::finished, this, [this]() + { + Refresh(); + }); connect(m_game_list, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu); connect(m_game_list, &QTableWidget::itemSelectionChanged, this, &game_list_frame::ItemSelectionChangedSlot); @@ -424,6 +434,12 @@ std::string game_list_frame::GetDataDirBySerial(const std::string& serial) void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) { + if (m_size_watcher.isRunning()) + { + m_size_watcher.cancel(); + m_size_watcher.waitForFinished(); + } + if (m_repaint_watcher.isRunning()) { m_repaint_watcher.cancel(); @@ -596,7 +612,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) return; } - GameInfo game; + GameInfo game{}; game.path = dir; game.serial = std::string(title_id); game.name = std::string(psf::get_string(psf, "TITLE", cat_unknown_localized)); @@ -609,7 +625,6 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) game.sound_format = psf::get_integer(psf, "SOUND_FORMAT", 0); game.bootable = psf::get_integer(psf, "BOOTABLE", 0); game.attr = psf::get_integer(psf, "ATTRIBUTE", 0); - game.size_on_disk = fs::get_dir_size(dir); if (m_show_custom_icons) { @@ -674,12 +689,15 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) m_mutex_cat.unlock(); - const auto compat = m_game_compat->GetCompatibility(game.serial); - const bool hasCustomConfig = fs::is_file(rpcs3::utils::get_custom_config_path(game.serial)); - const bool hasCustomPadConfig = fs::is_file(rpcs3::utils::get_custom_input_config_path(game.serial)); - const bool has_hover_gif = fs::is_file(game_icon_path + game.serial + "/hover.gif"); + gui_game_info info{}; + info.info = game; + info.localized_category = qt_cat; + info.compat = m_game_compat->GetCompatibility(game.serial); + info.hasCustomConfig = fs::is_file(rpcs3::utils::get_custom_config_path(game.serial)); + info.hasCustomPadConfig = fs::is_file(rpcs3::utils::get_custom_input_config_path(game.serial)); + info.has_hover_gif = fs::is_file(game_icon_path + game.serial + "/hover.gif"); - m_games.push(std::make_shared(gui_game_info{game, qt_cat, compat, {}, {}, hasCustomConfig, hasCustomPadConfig, has_hover_gif, nullptr})); + m_games.push(std::make_shared(std::move(info))); })); return; @@ -711,6 +729,12 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after) void game_list_frame::OnRefreshFinished() { + if (m_size_watcher.isRunning()) + { + m_size_watcher.cancel(); + m_size_watcher.waitForFinished(); + } + if (m_repaint_watcher.isRunning()) { m_repaint_watcher.cancel(); @@ -785,6 +809,11 @@ void game_list_frame::OnRefreshFinished() m_path_list.clear(); Refresh(); + + m_size_watcher.setFuture(QtConcurrent::map(m_game_data, [this](const game_info& game) -> void + { + if (game) game->info.size_on_disk = fs::get_dir_size(game->info.path); + })); } void game_list_frame::OnRepaintFinished() diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index fdba6d56e9..fe91eb2033 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -158,6 +158,7 @@ private: QSet m_serials; QMutex m_mutex_cat; lf_queue m_games; + QFutureWatcher m_size_watcher; QFutureWatcher m_refresh_watcher; QFutureWatcher m_repaint_watcher; QSet m_hidden_list;