From 5aaafa6a56101a18759264bbf1ef9293d424f899 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Sun, 5 May 2019 03:07:09 +0200 Subject: [PATCH] Separate UserNand and Sdmc directories --- src/yuzu/configuration/config.cpp | 6 ++++-- src/yuzu/game_list.cpp | 23 ++++++++++++++++------- src/yuzu/game_list_p.h | 29 ++++++++++++++++++++--------- src/yuzu/game_list_worker.cpp | 25 ++++++++++++++----------- src/yuzu/main.cpp | 8 +++++--- 5 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index b2683faf8..f594106bf 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -535,10 +535,12 @@ void Config::ReadPathValues() { // also carries over old game list settings if present if (UISettings::values.game_dirs.isEmpty()) { UISettings::GameDir game_dir; - game_dir.path = QStringLiteral("INSTALLED"); + game_dir.path = QStringLiteral("SDMC"); game_dir.expanded = true; UISettings::values.game_dirs.append(game_dir); - game_dir.path = QStringLiteral("SYSTEM"); + game_dir.path = QStringLiteral("UserNAND"); + UISettings::values.game_dirs.append(game_dir); + game_dir.path = QStringLiteral("SysNAND"); UISettings::values.game_dirs.append(game_dir); if (UISettings::values.game_dir_deprecated != QStringLiteral(".")) { game_dir.path = UISettings::values.game_dir_deprecated; diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 51ced635b..cab982385 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -161,8 +161,8 @@ static bool ContainsAllWords(const QString& haystack, const QString& userinput) // Syncs the expanded state of Game Directories with settings to persist across sessions void GameList::onItemExpanded(const QModelIndex& item) { const auto type = item.data(GameListItem::TypeRole).value(); - if (type == GameListItemType::CustomDir || type == GameListItemType::InstalledDir || - type == GameListItemType::SystemDir) + if (type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || + type == GameListItemType::UserNandDir || type == GameListItemType::SysNandDir) item.data(GameListDir::GameDirRole).value()->expanded = tree_view->isExpanded(item); } @@ -232,14 +232,21 @@ void GameList::onUpdateThemedIcons() { const int icon_size = UISettings::values.icon_size; switch (child->data(GameListItem::TypeRole).value()) { - case GameListItemType::InstalledDir: + case GameListItemType::SdmcDir: child->setData( QIcon::fromTheme(QStringLiteral("sd_card")) .pixmap(icon_size) .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); break; - case GameListItemType::SystemDir: + case GameListItemType::UserNandDir: + child->setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + break; + case GameListItemType::SysNandDir: child->setData( QIcon::fromTheme(QStringLiteral("chip")) .pixmap(icon_size) @@ -394,7 +401,8 @@ bool GameList::isEmpty() const { const QStandardItem* child = item_model->invisibleRootItem()->child(i); const auto type = static_cast(child->type()); if (!child->hasChildren() && - (type == GameListItemType::InstalledDir || type == GameListItemType::SystemDir)) { + (type == GameListItemType::SdmcDir || type == GameListItemType::UserNandDir || + type == GameListItemType::SysNandDir)) { item_model->invisibleRootItem()->removeRow(child->row()); i--; }; @@ -450,8 +458,9 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { AddPermDirPopup(context_menu, selected); AddCustomDirPopup(context_menu, selected); break; - case GameListItemType::InstalledDir: - case GameListItemType::SystemDir: + case GameListItemType::SdmcDir: + case GameListItemType::UserNandDir: + case GameListItemType::SysNandDir: AddPermDirPopup(context_menu, selected); break; } diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 047061e6c..87eb71c17 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h @@ -26,9 +26,10 @@ enum class GameListItemType { Game = QStandardItem::UserType + 1, CustomDir = QStandardItem::UserType + 2, - InstalledDir = QStandardItem::UserType + 3, - SystemDir = QStandardItem::UserType + 4, - AddDir = QStandardItem::UserType + 5 + SdmcDir = QStandardItem::UserType + 3, + UserNandDir = QStandardItem::UserType + 4, + SysNandDir = QStandardItem::UserType + 5, + AddDir = QStandardItem::UserType + 6 }; Q_DECLARE_METATYPE(GameListItemType); @@ -222,18 +223,28 @@ public: const int icon_size = UISettings::values.icon_size; switch (dir_type) { - case GameListItemType::InstalledDir: + case GameListItemType::SdmcDir: setData( QIcon::fromTheme(QStringLiteral("sd_card")) .pixmap(icon_size) .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), Qt::DecorationRole); - setData(QObject::tr("Installed Titles"), Qt::DisplayRole); + setData(QObject::tr("Installed SD Titles"), Qt::DisplayRole); break; - case GameListItemType::SystemDir: - setData(QIcon::fromTheme("chip").pixmap(icon_size).scaled( - icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), - Qt::DecorationRole); + case GameListItemType::UserNandDir: + setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + setData(QObject::tr("Installed NAND Titles"), Qt::DisplayRole); + break; + case GameListItemType::SysNandDir: + setData( + QIcon::fromTheme(QStringLiteral("chip")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); setData(QObject::tr("System Titles"), Qt::DisplayRole); break; case GameListItemType::CustomDir: diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index e1e69bc1a..c715bcef4 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -240,15 +240,14 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) { std::vector> installed_games; installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application, ContentRecordType::Program); - if (parent_dir->type() == static_cast(GameListItemType::InstalledDir)) { + + if (parent_dir->type() == static_cast(GameListItemType::SdmcDir)) { + installed_games = cache.ListEntriesFilterOrigin( + ContentProviderUnionSlot::SDMC, TitleType::Application, ContentRecordType::Program); + } else if (parent_dir->type() == static_cast(GameListItemType::UserNandDir)) { installed_games = cache.ListEntriesFilterOrigin( ContentProviderUnionSlot::UserNAND, TitleType::Application, ContentRecordType::Program); - auto installed_sdmc_games = cache.ListEntriesFilterOrigin( - ContentProviderUnionSlot::SDMC, TitleType::Application, ContentRecordType::Program); - - installed_games.insert(installed_games.end(), installed_sdmc_games.begin(), - installed_sdmc_games.end()); - } else if (parent_dir->type() == static_cast(GameListItemType::SystemDir)) { + } else if (parent_dir->type() == static_cast(GameListItemType::SysNandDir)) { installed_games = cache.ListEntriesFilterOrigin( ContentProviderUnionSlot::SysNAND, TitleType::Application, ContentRecordType::Program); } @@ -353,12 +352,16 @@ void GameListWorker::run() { stop_processing = false; for (UISettings::GameDir& game_dir : game_dirs) { - if (game_dir.path == "INSTALLED") { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); + if (game_dir.path == QStringLiteral("SDMC")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SdmcDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); - } else if (game_dir.path == "SYSTEM") { - auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); + } else if (game_dir.path == QStringLiteral("UserNAND")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::UserNandDir); + emit DirEntryReady({game_list_dir}); + AddTitlesToGameList(game_list_dir); + } else if (game_dir.path == QStringLiteral("SysNAND")) { + auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SysNandDir); emit DirEntryReady({game_list_dir}); AddTitlesToGameList(game_list_dir); } else { diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 72c3eb069..6d249cb3e 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1311,11 +1311,13 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, void GMainWindow::OnGameListOpenDirectory(const QString& directory) { QString path; - if (directory == QStringLiteral("INSTALLED")) { - // TODO: Find a better solution when installing files to the SD card gets implemented + if (directory == QStringLiteral("SDMC")) { + path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + + "Nintendo/Contents/registered"); + } else if (directory == QStringLiteral("UserNAND")) { path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "user/Contents/registered"); - } else if (directory == QStringLiteral("SYSTEM")) { + } else if (directory == QStringLiteral("SysNAND")) { path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + "system/Contents/registered"); } else {