From c3916fee9cf03d2cfcd814cb331a95236b17cd93 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 15 Jun 2018 17:50:53 +0200 Subject: [PATCH] Qt: add DeleteSPUCache option --- rpcs3/rpcs3qt/game_list_frame.cpp | 33 +++++++++++++++++++++++++++++++ rpcs3/rpcs3qt/game_list_frame.h | 1 + 2 files changed, 34 insertions(+) diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 146a593e8f..6f5864cb3c 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -633,6 +633,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) QAction* removeConfig = myMenu.addAction(tr("&Remove Custom Configuration")); QAction* deleteShadersCache = myMenu.addAction(tr("&Delete Shaders Cache")); QAction* deleteLLVMCache = myMenu.addAction(tr("&Delete LLVM Cache")); + QAction* deleteSPUCache = myMenu.addAction(tr("&Delete SPU Cache")); myMenu.addSeparator(); QAction* openGameFolder = myMenu.addAction(tr("&Open Install Folder")); QAction* openConfig = myMenu.addAction(tr("&Open Config Folder")); @@ -695,6 +696,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) { DeleteShadersCache(config_base_dir); DeleteLLVMCache(config_base_dir); + DeleteSPUCache(config_base_dir); RemoveCustomConfiguration(config_base_dir); } fs::remove_all(currGame.path); @@ -725,6 +727,10 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) { DeleteLLVMCache(config_base_dir, true); }); + connect(deleteSPUCache, &QAction::triggered, [=]() + { + DeleteSPUCache(config_base_dir, true); + }); connect(openGameFolder, &QAction::triggered, [=]() { open_dir(currGame.path); @@ -796,6 +802,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) { deleteShadersCache->setEnabled(false); deleteLLVMCache->setEnabled(false); + deleteSPUCache->setEnabled(false); } myMenu.exec(globalPos); @@ -876,6 +883,32 @@ bool game_list_frame::DeleteLLVMCache(const std::string& base_dir, bool is_inter return true; } +bool game_list_frame::DeleteSPUCache(const std::string& base_dir, bool is_interactive) +{ + if (!fs::is_dir(base_dir)) + return false; + + if (is_interactive && QMessageBox::question(this, tr("Confirm Delete"), tr("Delete SPU cache?")) != QMessageBox::Yes) + return false; + + QDirIterator dir_iter(qstr(base_dir), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + while (dir_iter.hasNext()) + { + const QString filepath = dir_iter.next(); + + if (dir_iter.fileInfo().absoluteFilePath().endsWith(".dat", Qt::CaseInsensitive)) + { + if (QFile::remove(filepath)) + LOG_NOTICE(GENERAL, "Removed SPU cache file: %s", sstr(filepath)); + else + LOG_WARNING(GENERAL, "Could not remove SPU cache file: %s", sstr(filepath)); + } + } + + LOG_SUCCESS(GENERAL, "Removed SPU cache in %s", base_dir); + return true; +} + QPixmap game_list_frame::PaintedPixmap(const QImage& img, bool paintConfigIcon) { QImage scaled = QImage(m_Icon_Size, QImage::Format_ARGB32); diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index 71b71936f7..783ef102ac 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -214,6 +214,7 @@ private Q_SLOTS: bool RemoveCustomConfiguration(const std::string& base_dir, bool is_interactive = false); bool DeleteShadersCache(const std::string& base_dir, bool is_interactive = false); bool DeleteLLVMCache(const std::string& base_dir, bool is_interactive = false); + bool DeleteSPUCache(const std::string& base_dir, bool is_interactive = false); void OnColClicked(int col); void ShowContextMenu(const QPoint &pos); void doubleClickedSlot(QTableWidgetItem *item);