summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2020-07-17 05:21:26 -0400
committerGravatar Morph2020-07-29 06:50:30 -0400
commit85e1facfe618967e4a4b865e0b4f6fcb95a786a5 (patch)
tree1c43e475470115b0131939d6483dd13ba3d62a4e /src
parentgame_list: Add "Remove" context menu (diff)
downloadyuzu-85e1facfe618967e4a4b865e0b4f6fcb95a786a5.tar.gz
yuzu-85e1facfe618967e4a4b865e0b4f6fcb95a786a5.tar.xz
yuzu-85e1facfe618967e4a4b865e0b4f6fcb95a786a5.zip
main: Connect game list remove signals to removal functions
Diffstat (limited to 'src')
-rw-r--r--src/yuzu/main.cpp168
-rw-r--r--src/yuzu/main.h4
2 files changed, 167 insertions, 5 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 31a635176..e94785101 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -847,6 +847,9 @@ void GMainWindow::ConnectWidgetEvents() {
847 connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder); 847 connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
848 connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this, 848 connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this,
849 &GMainWindow::OnTransferableShaderCacheOpenFile); 849 &GMainWindow::OnTransferableShaderCacheOpenFile);
850 connect(game_list, &GameList::RemoveInstalledEntryRequested, this,
851 &GMainWindow::OnGameListRemoveInstalledEntry);
852 connect(game_list, &GameList::RemoveFileRequested, this, &GMainWindow::OnGameListRemoveFile);
850 connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS); 853 connect(game_list, &GameList::DumpRomFSRequested, this, &GMainWindow::OnGameListDumpRomFS);
851 connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID); 854 connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
852 connect(game_list, &GameList::NavigateToGamedbEntryRequested, this, 855 connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
@@ -1322,14 +1325,12 @@ void GMainWindow::OnGameListOpenFolder(GameListOpenTarget target, const std::str
1322} 1325}
1323 1326
1324void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) { 1327void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
1325 ASSERT(program_id != 0);
1326
1327 const QString shader_dir = 1328 const QString shader_dir =
1328 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)); 1329 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir));
1329 const QString tranferable_shader_cache_folder_path = 1330 const QString transferable_shader_cache_folder_path =
1330 shader_dir + QStringLiteral("opengl") + QDir::separator() + QStringLiteral("transferable"); 1331 shader_dir + QStringLiteral("opengl") + QDir::separator() + QStringLiteral("transferable");
1331 const QString transferable_shader_cache_file_path = 1332 const QString transferable_shader_cache_file_path =
1332 tranferable_shader_cache_folder_path + QDir::separator() + 1333 transferable_shader_cache_folder_path + QDir::separator() +
1333 QString::fromStdString(fmt::format("{:016X}.bin", program_id)); 1334 QString::fromStdString(fmt::format("{:016X}.bin", program_id));
1334 1335
1335 if (!QFile::exists(transferable_shader_cache_file_path)) { 1336 if (!QFile::exists(transferable_shader_cache_file_path)) {
@@ -1350,7 +1351,7 @@ void GMainWindow::OnTransferableShaderCacheOpenFile(u64 program_id) {
1350 param << QDir::toNativeSeparators(transferable_shader_cache_file_path); 1351 param << QDir::toNativeSeparators(transferable_shader_cache_file_path);
1351 QProcess::startDetached(explorer, param); 1352 QProcess::startDetached(explorer, param);
1352#else 1353#else
1353 QDesktopServices::openUrl(QUrl::fromLocalFile(tranferable_shader_cache_folder_path)); 1354 QDesktopServices::openUrl(QUrl::fromLocalFile(transferable_shader_cache_folder_path));
1354#endif 1355#endif
1355} 1356}
1356 1357
@@ -1394,6 +1395,163 @@ static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src
1394 return true; 1395 return true;
1395} 1396}
1396 1397
1398void GMainWindow::OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type) {
1399 QString entry_type;
1400
1401 switch (type) {
1402 case InstalledEntryType::Game:
1403 entry_type = tr("Contents");
1404 break;
1405 case InstalledEntryType::Update:
1406 entry_type = tr("Update");
1407 break;
1408 case InstalledEntryType::AddOnContent:
1409 entry_type = tr("DLC");
1410 break;
1411 }
1412
1413 if (QMessageBox::question(
1414 this, tr("Remove Entry"), tr("Remove Installed Game %1?").arg(entry_type),
1415 QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes) {
1416 return;
1417 }
1418
1419 bool res;
1420
1421 switch (type) {
1422 case InstalledEntryType::Game:
1423 res = Core::System::GetInstance()
1424 .GetFileSystemController()
1425 .GetUserNANDContents()
1426 ->RemoveExistingEntry(program_id);
1427
1428 if (res) {
1429 QMessageBox::information(this, tr("Successfully Removed"),
1430 tr("Successfully removed the installed base game."));
1431 } else {
1432 QMessageBox::warning(
1433 this, tr("Error Removing %1").arg(entry_type),
1434 tr("The base game is not installed in the NAND and cannot be removed."));
1435 }
1436 [[fallthrough]];
1437 case InstalledEntryType::Update:
1438 res = Core::System::GetInstance()
1439 .GetFileSystemController()
1440 .GetUserNANDContents()
1441 ->RemoveExistingEntry(program_id | 0x800);
1442
1443 if (res) {
1444 QMessageBox::information(this, tr("Successfully Removed"),
1445 tr("Successfully removed the installed update."));
1446 } else {
1447 QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
1448 tr("There is no update installed for this title."));
1449 }
1450
1451 if (type == InstalledEntryType::Game) {
1452 [[fallthrough]];
1453 } else {
1454 break;
1455 }
1456 case InstalledEntryType::AddOnContent:
1457 u32 count{};
1458 const auto dlc_entries = Core::System::GetInstance().GetContentProvider().ListEntriesFilter(
1459 FileSys::TitleType::AOC, FileSys::ContentRecordType::Data);
1460
1461 for (const auto& entry : dlc_entries) {
1462 if ((entry.title_id & DLC_BASE_TITLE_ID_MASK) == program_id) {
1463 res = Core::System::GetInstance()
1464 .GetFileSystemController()
1465 .GetUserNANDContents()
1466 ->RemoveExistingEntry(entry.title_id);
1467 if (res) {
1468 ++count;
1469 }
1470 }
1471 }
1472
1473 if (count == 0) {
1474 QMessageBox::warning(this, tr("Error Removing %1").arg(entry_type),
1475 tr("There are no DLC installed for this title."));
1476 break;
1477 }
1478
1479 QMessageBox::information(this, tr("Successfully Removed"),
1480 tr("Successfully removed %1 installed DLC.").arg(count));
1481 break;
1482 }
1483 game_list->PopulateAsync(UISettings::values.game_dirs);
1484 FileUtil::DeleteDirRecursively(FileUtil::GetUserPath(FileUtil::UserPath::CacheDir) + DIR_SEP +
1485 "game_list");
1486}
1487
1488void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target) {
1489 QString question;
1490
1491 switch (target) {
1492 case GameListRemoveTarget::ShaderCache:
1493 question = tr("Delete Transferable Shader Cache?");
1494 break;
1495 case GameListRemoveTarget::CustomConfiguration:
1496 question = tr("Remove Custom Game Configuration?");
1497 break;
1498 }
1499
1500 if (QMessageBox::question(this, tr("Remove File"), question, QMessageBox::Yes | QMessageBox::No,
1501 QMessageBox::No) != QMessageBox::Yes) {
1502 return;
1503 }
1504
1505 switch (target) {
1506 case GameListRemoveTarget::ShaderCache: {
1507 const QString shader_dir =
1508 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir));
1509 const QString transferable_shader_cache_folder_path =
1510 shader_dir + QStringLiteral("opengl") + QDir::separator() +
1511 QStringLiteral("transferable");
1512 const QString transferable_shader_cache_file_path =
1513 transferable_shader_cache_folder_path + QDir::separator() +
1514 QString::fromStdString(fmt::format("{:016X}.bin", program_id));
1515
1516 if (!QFile::exists(transferable_shader_cache_file_path)) {
1517 QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
1518 tr("A shader cache for this title does not exist."));
1519 break;
1520 }
1521
1522 if (QFile::remove(transferable_shader_cache_file_path)) {
1523 QMessageBox::information(this, tr("Successfully Removed"),
1524 tr("Successfully removed the transferable shader cache."));
1525 } else {
1526 QMessageBox::warning(this, tr("Error Removing Transferable Shader Cache"),
1527 tr("Failed to remove the transferable shader cache."));
1528 }
1529 break;
1530 }
1531 case GameListRemoveTarget::CustomConfiguration: {
1532 const QString config_dir =
1533 QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir));
1534 const QString custom_config_file_path =
1535 config_dir + QString::fromStdString(fmt::format("{:016X}.ini", program_id));
1536
1537 if (!QFile::exists(custom_config_file_path)) {
1538 QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
1539 tr("A custom configuration for this title does not exist."));
1540 break;
1541 }
1542
1543 if (QFile::remove(custom_config_file_path)) {
1544 QMessageBox::information(this, tr("Successfully Removed"),
1545 tr("Successfully removed the custom game configuration."));
1546 } else {
1547 QMessageBox::warning(this, tr("Error Removing Custom Configuration"),
1548 tr("Failed to remove the custom game configuration."));
1549 }
1550 break;
1551 }
1552 }
1553}
1554
1397void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) { 1555void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
1398 const auto failed = [this] { 1556 const auto failed = [this] {
1399 QMessageBox::warning(this, tr("RomFS Extraction Failed!"), 1557 QMessageBox::warning(this, tr("RomFS Extraction Failed!"),
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index db573d606..bbdf7ae51 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -32,6 +32,8 @@ class QPushButton;
32class QProgressDialog; 32class QProgressDialog;
33class WaitTreeWidget; 33class WaitTreeWidget;
34enum class GameListOpenTarget; 34enum class GameListOpenTarget;
35enum class GameListRemoveTarget;
36enum class InstalledEntryType;
35class GameListPlaceholder; 37class GameListPlaceholder;
36 38
37namespace Core::Frontend { 39namespace Core::Frontend {
@@ -198,6 +200,8 @@ private slots:
198 void OnGameListLoadFile(QString game_path); 200 void OnGameListLoadFile(QString game_path);
199 void OnGameListOpenFolder(GameListOpenTarget target, const std::string& game_path); 201 void OnGameListOpenFolder(GameListOpenTarget target, const std::string& game_path);
200 void OnTransferableShaderCacheOpenFile(u64 program_id); 202 void OnTransferableShaderCacheOpenFile(u64 program_id);
203 void OnGameListRemoveInstalledEntry(u64 program_id, InstalledEntryType type);
204 void OnGameListRemoveFile(u64 program_id, GameListRemoveTarget target);
201 void OnGameListDumpRomFS(u64 program_id, const std::string& game_path); 205 void OnGameListDumpRomFS(u64 program_id, const std::string& game_path);
202 void OnGameListCopyTID(u64 program_id); 206 void OnGameListCopyTID(u64 program_id);
203 void OnGameListNavigateToGamedbEntry(u64 program_id, 207 void OnGameListNavigateToGamedbEntry(u64 program_id,