diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index acf1b8af35..ee75be694c 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -1420,13 +1420,13 @@ void game_list_frame::ShowSingleSelectionContextMenu(const game_info& gameinfo, switch (type) { case icon_type::game_list: - msg = tr("Remove Custom Icon of %0?").arg(serial); + msg = tr("Remove Custom Icon of %0?").arg(QString::fromStdString(serial)); break; case icon_type::hover_gif: - msg = tr("Remove Custom Hover Gif of %0?").arg(serial); + msg = tr("Remove Custom Hover Gif of %0?").arg(QString::fromStdString(serial)); break; case icon_type::shader_load: - msg = tr("Remove Custom Shader Loading Background of %0?").arg(serial); + msg = tr("Remove Custom Shader Loading Background of %0?").arg(QString::fromStdString(serial)); break; } @@ -1995,12 +1995,12 @@ void game_list_frame::ShowContextMenu(const QPoint& pos) } } -void game_list_frame::SetContentList(u16 contentTypes, const ContentInfo& contentInfo) +void game_list_frame::SetContentList(u16 content_types, const content_info& content_info) { - this->contentInfo = contentInfo; + m_content_info = content_info; - this->contentInfo.contentTypes = contentTypes; - this->contentInfo.clearOnFinish = true; // Always overridden by BatchRemoveContentLists() + m_content_info.content_types = content_types; + m_content_info.clear_on_finish = true; // Always overridden by BatchRemoveContentLists() } void game_list_frame::ClearContentList(bool refresh) @@ -2010,7 +2010,7 @@ void game_list_frame::ClearContentList(bool refresh) std::vector serials_to_remove_from_yml; // Prepare the list of serials (title id) to remove in "games.yml" file (if any) - for (auto& removedDisc : contentInfo.removedDiscList) + for (const auto& removedDisc : m_content_info.removed_disc_list) { serials_to_remove_from_yml.push_back(removedDisc); } @@ -2020,24 +2020,24 @@ void game_list_frame::ClearContentList(bool refresh) Refresh(true, serials_to_remove_from_yml); } - contentInfo = {NO_CONTENT}; + m_content_info = {NO_CONTENT}; } -game_list_frame::ContentInfo game_list_frame::GetContentInfo(const std::vector& games) +game_list_frame::content_info game_list_frame::GetContentInfo(const std::vector& games) { - ContentInfo contentInfo = {NO_CONTENT}; + content_info content_info = {NO_CONTENT}; - if (games.size() == 0) - return contentInfo; + if (games.empty()) + return content_info; bool is_disc_game = false; u64 total_disc_size = 0; u64 total_data_size = 0; QString text; - // Fill in contentInfo + // Fill in content_info - contentInfo.isSingleSelection = games.size() == 1; + content_info.is_single_selection = games.size() == 1; for (const auto& game : games) { @@ -2046,10 +2046,10 @@ game_list_frame::ContentInfo game_list_frame::GetContentInfo(const std::vector data_dir_list = rpcs3::utils::get_dir_list(rpcs3::utils::get_hdd0_game_dir(), current_game.serial); @@ -2065,19 +2065,19 @@ game_list_frame::ContentInfo game_list_frame::GetContentInfo(const std::vectorinfo; @@ -2092,7 +2092,7 @@ game_list_frame::ContentInfo game_list_frame::GetContentInfo(const std::vectorlocalized_category); @@ -2113,7 +2113,7 @@ game_list_frame::ContentInfo game_list_frame::GetContentInfo(const std::vector& games) { - if (games.size() == 0) + if (games.empty()) return; - ContentInfo contentInfo = GetContentInfo(games); - QString text = contentInfo.info; + content_info content_info = GetContentInfo(games); + QString text = content_info.info; QCheckBox* disc = new QCheckBox(tr("Remove title from game list (Disc Game path is not removed!)")); QCheckBox* caches = new QCheckBox(tr("Remove caches and custom configs")); @@ -2214,16 +2214,16 @@ void game_list_frame::DialogRemoveGame(const std::vector& games) QCheckBox* recordings = new QCheckBox(tr("Remove recordings")); QCheckBox* screenshots = new QCheckBox(tr("Remove screenshots")); - if (contentInfo.discList.size()) + if (content_info.disc_list.size()) { - if (contentInfo.inGamesDirCount == contentInfo.discList.size()) + if (content_info.in_games_dir_count == content_info.disc_list.size()) { disc->setToolTip(tr("Title located under auto-detection VFS \"games\" folder cannot be removed")); disc->setDisabled(true); } else { - if (!contentInfo.isSingleSelection) // Multi selection + if (!content_info.is_single_selection) // Multi selection disc->setToolTip(tr("Title located under auto-detection VFS \"games\" folder cannot be removed")); disc->setChecked(true); @@ -2235,10 +2235,10 @@ void game_list_frame::DialogRemoveGame(const std::vector& games) disc->setVisible(false); } - if (contentInfo.pathList.size()) // If a path is present + if (content_info.path_list.size()) // If a path is present { text += tr("\nPermanently remove %0 and selected (optional) contents from drive?\n") - .arg((contentInfo.discList.size() || !contentInfo.isSingleSelection) + .arg((content_info.disc_list.size() || !content_info.is_single_selection) ? tr("Game Data") : games[0]->localized_category); } else @@ -2267,36 +2267,36 @@ void game_list_frame::DialogRemoveGame(const std::vector& games) return; // Remove data path in "dev_hdd0/game" folder (if any) and lock file in "dev_hdd0/game/$locks" folder (if any) - u16 contentTypes = DATA | LOCKS; + u16 content_types = DATA | LOCKS; // Remove serials (title id) in "games.yml" file (if any) if (disc->isChecked()) - contentTypes |= DISC; + content_types |= DISC; // Remove caches in "cache" and "dev_hdd1/caches" folders (if any) and custom configs in "config/custom_config" folder (if any) if (caches->isChecked()) - contentTypes |= CACHES | CUSTOM_CONFIG; + content_types |= CACHES | CUSTOM_CONFIG; // Remove icons in "Icons/game_icons" folder (if any) and // shortcuts in "games/shortcuts" folder and from desktop / start menu (if any) if (icons->isChecked()) - contentTypes |= ICONS | SHORTCUTS; + content_types |= ICONS | SHORTCUTS; if (savestate->isChecked()) - contentTypes |= SAVESTATES; + content_types |= SAVESTATES; if (captures->isChecked()) - contentTypes |= CAPTURES; + content_types |= CAPTURES; if (recordings->isChecked()) - contentTypes |= RECORDINGS; + content_types |= RECORDINGS; if (screenshots->isChecked()) - contentTypes |= SCREENSHOTS; + content_types |= SCREENSHOTS; - SetContentList(contentTypes, contentInfo); + SetContentList(content_types, content_info); - if (contentInfo.isSingleSelection) // Single selection + if (content_info.is_single_selection) // Single selection { if (!RemoveContentList(games[0]->info.serial, true)) { @@ -2315,7 +2315,7 @@ void game_list_frame::DialogRemoveGame(const std::vector& games) void game_list_frame::DialogGameInfo(const std::vector& games) { - if (games.size() == 0) + if (games.empty()) return; QMessageBox::information(this, tr("Game Info"), GetContentInfo(games).info); @@ -2326,11 +2326,6 @@ bool game_list_frame::IsGameRunning(const std::string& serial) return !Emu.IsStopped(true) && (serial == Emu.GetTitleID() || (serial == "vsh.self" && Emu.IsVsh())); } -bool game_list_frame::IsEmulatorRunning() -{ - return Emu.GetStatus(false) != system_state::stopped; -} - bool game_list_frame::ValidateRemoval(const std::string& serial, const std::string& path, const std::string& desc, bool is_interactive) { if (serial.empty()) @@ -2358,7 +2353,7 @@ bool game_list_frame::ValidateRemoval(const std::string& serial, const std::stri return false; } - if (QMessageBox::question(this, tr("Confirm Removal"), tr("Remove %0?").arg(desc)) != QMessageBox::Yes) + if (QMessageBox::question(this, tr("Confirm Removal"), tr("Remove %0?").arg(QString::fromStdString(desc))) != QMessageBox::Yes) return false; } @@ -2367,7 +2362,7 @@ bool game_list_frame::ValidateRemoval(const std::string& serial, const std::stri bool game_list_frame::ValidateBatchRemoval(const std::string& desc, bool is_interactive) { - if (IsEmulatorRunning()) + if (!Emu.IsStopped(true)) { game_list_log.error("Removal of %s not allowed due to emulator is running!", desc); @@ -2382,7 +2377,7 @@ bool game_list_frame::ValidateBatchRemoval(const std::string& desc, bool is_inte if (is_interactive) { - if (QMessageBox::question(this, tr("Confirm Removal"), tr("Remove %0?").arg(desc)) != QMessageBox::Yes) + if (QMessageBox::question(this, tr("Confirm Removal"), tr("Remove %0?").arg(QString::fromStdString(desc))) != QMessageBox::Yes) return false; } @@ -2711,22 +2706,22 @@ bool game_list_frame::RemoveContentList(const std::string& serial, bool is_inter // Just used for confirmation, if requested. Folder returned by fs::get_config_dir() is always present! if (!ValidateRemoval(serial, fs::get_config_dir(), "selected content", is_interactive)) { - if (contentInfo.clearOnFinish) + if (m_content_info.clear_on_finish) ClearContentList(); // Clear only the content's info return true; } - u16 contentTypes = contentInfo.contentTypes; + u16 content_types = m_content_info.content_types; // Remove data path in "dev_hdd0/game" folder (if any) - if (contentTypes & DATA) + if (content_types & DATA) { - if (const auto it = contentInfo.pathList.find(serial); it != contentInfo.pathList.cend()) + if (const auto it = m_content_info.path_list.find(serial); it != m_content_info.path_list.cend()) { if (RemoveContentPathList(it->second, "data") != it->second.size()) { - if (contentInfo.clearOnFinish) + if (m_content_info.clear_on_finish) ClearContentList(); // Clear only the content's info // Skip the removal of the remaining selected contents in case some data paths could not be removed @@ -2736,28 +2731,28 @@ bool game_list_frame::RemoveContentList(const std::string& serial, bool is_inter } // Add serial (title id) to the list of serials to be removed in "games.yml" file (if any) - if (contentTypes & DISC) + if (content_types & DISC) { - if (const auto it = contentInfo.discList.find(serial); it != contentInfo.discList.cend()) - contentInfo.removedDiscList.insert(serial); + if (const auto it = m_content_info.disc_list.find(serial); it != m_content_info.disc_list.cend()) + m_content_info.removed_disc_list.insert(serial); } // Remove lock file in "dev_hdd0/game/$locks" folder (if any) - if (contentTypes & LOCKS) + if (content_types & LOCKS) { if (ValidateRemoval(serial, rpcs3::utils::get_hdd0_locks_dir(), "lock")) RemoveContentBySerial(rpcs3::utils::get_hdd0_locks_dir(), serial, "lock"); } // Remove caches in "cache" and "dev_hdd1/caches" folders (if any) - if (contentTypes & CACHES) + if (content_types & CACHES) { if (ValidateRemoval(serial, rpcs3::utils::get_cache_dir_by_serial(serial), "all caches")) RemoveAllCaches(serial); } // Remove custom configs in "config/custom_config" folder (if any) - if (contentTypes & CUSTOM_CONFIG) + if (content_types & CUSTOM_CONFIG) { if (ValidateRemoval(serial, rpcs3::utils::get_custom_config_path(serial), "custom configuration")) RemoveCustomConfiguration(serial); @@ -2767,16 +2762,16 @@ bool game_list_frame::RemoveContentList(const std::string& serial, bool is_inter } // Remove icons in "Icons/game_icons" folder (if any) - if (contentTypes & ICONS) + if (content_types & ICONS) { if (ValidateRemoval(serial, rpcs3::utils::get_icons_dir(serial), "icons")) RemoveContentBySerial(rpcs3::utils::get_icons_dir(), serial, "icons"); } // Remove shortcuts in "games/shortcuts" folder and from desktop / start menu (if any) - if (contentTypes & SHORTCUTS) + if (content_types & SHORTCUTS) { - if (const auto it = contentInfo.nameList.find(serial); it != contentInfo.nameList.cend()) + if (const auto it = m_content_info.name_list.find(serial); it != m_content_info.name_list.cend()) { const bool remove_rpcs3_links = ValidateRemoval(serial, rpcs3::utils::get_games_shortcuts_dir(), "link"); @@ -2794,31 +2789,31 @@ bool game_list_frame::RemoveContentList(const std::string& serial, bool is_inter } } - if (contentTypes & SAVESTATES) + if (content_types & SAVESTATES) { if (ValidateRemoval(serial, rpcs3::utils::get_savestates_dir(serial), "savestates")) RemoveContentBySerial(rpcs3::utils::get_savestates_dir(), serial, "savestates"); } - if (contentTypes & CAPTURES) + if (content_types & CAPTURES) { if (ValidateRemoval(serial, rpcs3::utils::get_captures_dir(), "captures")) RemoveContentBySerial(rpcs3::utils::get_captures_dir(), serial, "captures"); } - if (contentTypes & RECORDINGS) + if (content_types & RECORDINGS) { if (ValidateRemoval(serial, rpcs3::utils::get_recordings_dir(serial), "recordings")) RemoveContentBySerial(rpcs3::utils::get_recordings_dir(), serial, "recordings"); } - if (contentTypes & SCREENSHOTS) + if (content_types & SCREENSHOTS) { if (ValidateRemoval(serial, rpcs3::utils::get_screenshots_dir(serial), "screenshots")) RemoveContentBySerial(rpcs3::utils::get_screenshots_dir(), serial, "screenshots"); } - if (contentInfo.clearOnFinish) + if (m_content_info.clear_on_finish) ClearContentList(true); // Update the game list and clear the content's info once removed return true; @@ -3203,7 +3198,7 @@ void game_list_frame::BatchRemoveAllCaches(const std::vector& games, void game_list_frame::BatchRemoveContentLists(const std::vector& games, bool is_interactive) { // Let the batch process (not RemoveContentList()) make cleanup when terminated - contentInfo.clearOnFinish = false; + m_content_info.clear_on_finish = false; if (!ValidateBatchRemoval("selected content", is_interactive)) { diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index cdfd2c87e4..3b6f9016c9 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -63,7 +63,7 @@ public: bool IsEntryVisible(const game_info& game, bool search_fallback = false) const; - enum ContentType + enum content_type { NO_CONTENT = 0, DISC = (1 << 0), @@ -79,18 +79,18 @@ public: SCREENSHOTS = (1 << 10) }; - struct ContentInfo + struct content_info { - u16 contentTypes = NO_CONTENT; // Always set by SetContentList() - bool clearOnFinish = true; // Always overridden by BatchRemoveContentLists() + u16 content_types = NO_CONTENT; // Always set by SetContentList() + bool clear_on_finish = true; // Always overridden by BatchRemoveContentLists() - bool isSingleSelection = false; - u16 inGamesDirCount = 0; + bool is_single_selection = false; + u16 in_games_dir_count = 0; QString info; - std::map> nameList; - std::map> pathList; - std::set discList; - std::set removedDiscList; // Filled in by RemoveContentList() + std::map> name_list; + std::map> path_list; + std::set disc_list; + std::set removed_disc_list; // Filled in by RemoveContentList() }; public Q_SLOTS: @@ -108,7 +108,7 @@ public Q_SLOTS: // - RemoveContentList() // - BatchRemoveContentLists() // - void SetContentList(u16 contentTypes, const ContentInfo& contentInfo); + void SetContentList(u16 content_types, const content_info& content_info); void BatchRemoveContentLists(const std::vector& games = {}, bool is_interactive = false); void SetListMode(const bool& is_list); @@ -175,23 +175,22 @@ private: void ShowMultiSelectionContextMenu(const std::vector& games, QPoint& global_pos); // NOTE: - // contentInfo is used by: + // m_content_info is used by: // - SetContentList() // - ClearContentList() // - GetContentInfo() // - RemoveContentList() // - BatchRemoveContentLists() // - ContentInfo contentInfo; + content_info m_content_info; void ClearContentList(bool refresh = false); - ContentInfo GetContentInfo(const std::vector& games); + content_info GetContentInfo(const std::vector& games); void DialogRemoveGame(const std::vector& games); void DialogGameInfo(const std::vector& games); static bool IsGameRunning(const std::string& serial); - static bool IsEmulatorRunning(); bool ValidateRemoval(const std::string& serial, const std::string& path, const std::string& desc, bool is_interactive = false); bool ValidateBatchRemoval(const std::string& desc, bool is_interactive = false); diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 1f6816cad3..d7b84c2abc 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -2765,42 +2765,42 @@ void main_window::CreateConnects() }); connect(ui->exitAct, &QAction::triggered, this, &QWidget::close); - connect(ui->batchCreateCPUCachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchCreateCPUCachesAct, &QAction::triggered, this, [this]() { - list->BatchCreateCPUCaches({}, false, true); + m_game_list_frame->BatchCreateCPUCaches({}, false, true); }); - connect(ui->batchRemoveCustomConfigurationsAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchRemoveCustomConfigurationsAct, &QAction::triggered, this, [this]() { - list->BatchRemoveCustomConfigurations({}, true); + m_game_list_frame->BatchRemoveCustomConfigurations({}, true); }); - connect(ui->batchRemoveCustomPadConfigurationsAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchRemoveCustomPadConfigurationsAct, &QAction::triggered, this, [this]() { - list->BatchRemoveCustomPadConfigurations({}, true); + m_game_list_frame->BatchRemoveCustomPadConfigurations({}, true); }); - connect(ui->batchRemoveShaderCachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchRemoveShaderCachesAct, &QAction::triggered, this, [this]() { - list->BatchRemoveShaderCaches({}, true); + m_game_list_frame->BatchRemoveShaderCaches({}, true); }); - connect(ui->batchRemovePPUCachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchRemovePPUCachesAct, &QAction::triggered, this, [this]() { - list->BatchRemovePPUCaches({}, true); + m_game_list_frame->BatchRemovePPUCaches({}, true); }); - connect(ui->batchRemoveSPUCachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->batchRemoveSPUCachesAct, &QAction::triggered, this, [this]() { - list->BatchRemoveSPUCaches({}, true); + m_game_list_frame->BatchRemoveSPUCaches({}, true); }); - connect(ui->removeHDD1CachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->removeHDD1CachesAct, &QAction::triggered, this, [this]() { - list->BatchRemoveHDD1Caches({}, true); + m_game_list_frame->BatchRemoveHDD1Caches({}, true); }); - connect(ui->removeAllCachesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->removeAllCachesAct, &QAction::triggered, this, [this]() { - list->BatchRemoveAllCaches({}, true); + m_game_list_frame->BatchRemoveAllCaches({}, true); }); - connect(ui->removeSavestatesAct, &QAction::triggered, m_game_list_frame, [list = m_game_list_frame]() + connect(ui->removeSavestatesAct, &QAction::triggered, this, [this]() { - list->SetContentList(game_list_frame::ContentType::SAVESTATES, {}); - list->BatchRemoveContentLists({}, true); + m_game_list_frame->SetContentList(game_list_frame::content_type::SAVESTATES, {}); + m_game_list_frame->BatchRemoveContentLists({}, true); }); connect(ui->cleanUpGameListAct, &QAction::triggered, this, &main_window::CleanUpGameList);