summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/game_list.cpp14
-rw-r--r--src/yuzu/game_list.h32
-rw-r--r--src/yuzu/game_list_p.h40
-rw-r--r--src/yuzu/main.cpp92
4 files changed, 97 insertions, 81 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index 991ae10cd..67890455a 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -26,10 +26,10 @@
#include "yuzu/main.h"
#include "yuzu/ui_settings.h"
-GameList::SearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {}
+GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {}
// EventFilter in order to process systemkeys while editing the searchfield
-bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
+bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) {
// If it isn't a KeyRelease event then continue with standard event processing
if (event->type() != QEvent::KeyRelease)
return QObject::eventFilter(obj, event);
@@ -88,21 +88,21 @@ bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* e
return QObject::eventFilter(obj, event);
}
-void GameList::SearchField::setFilterResult(int visible, int total) {
+void GameListSearchField::setFilterResult(int visible, int total) {
label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible));
}
-void GameList::SearchField::clear() {
+void GameListSearchField::clear() {
edit_filter->setText("");
}
-void GameList::SearchField::setFocus() {
+void GameListSearchField::setFocus() {
if (edit_filter->isVisible()) {
edit_filter->setFocus();
}
}
-GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} {
+GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} {
KeyReleaseEater* keyReleaseEater = new KeyReleaseEater(parent);
layout_filter = new QHBoxLayout;
layout_filter->setMargin(8);
@@ -202,7 +202,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, GMainWindow* parent)
this->main_window = parent;
layout = new QVBoxLayout;
tree_view = new QTreeView;
- search_field = new SearchField(this);
+ search_field = new GameListSearchField(this);
item_model = new QStandardItemModel(tree_view);
tree_view->setModel(item_model);
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index 3bf51870e..05e115e19 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -22,6 +22,7 @@
#include "yuzu/compatibility_list.h"
class GameListWorker;
+class GameListSearchField;
class GMainWindow;
namespace FileSys {
@@ -46,33 +47,6 @@ public:
COLUMN_COUNT, // Number of columns
};
- class SearchField : public QWidget {
- public:
- void setFilterResult(int visible, int total);
- void clear();
- void setFocus();
- explicit SearchField(GameList* parent = nullptr);
-
- private:
- class KeyReleaseEater : public QObject {
- public:
- explicit KeyReleaseEater(GameList* gamelist);
-
- private:
- GameList* gamelist = nullptr;
- QString edit_filter_text_old;
-
- protected:
- bool eventFilter(QObject* obj, QEvent* event) override;
- };
- QHBoxLayout* layout_filter = nullptr;
- QTreeView* tree_view = nullptr;
- QLabel* label_filter = nullptr;
- QLineEdit* edit_filter = nullptr;
- QLabel* label_filter_result = nullptr;
- QToolButton* button_filter_close = nullptr;
- };
-
explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs, GMainWindow* parent = nullptr);
~GameList() override;
@@ -110,7 +84,7 @@ private:
void RefreshGameDirectory();
std::shared_ptr<FileSys::VfsFilesystem> vfs;
- SearchField* search_field;
+ GameListSearchField* search_field;
GMainWindow* main_window = nullptr;
QVBoxLayout* layout = nullptr;
QTreeView* tree_view = nullptr;
@@ -118,6 +92,8 @@ private:
GameListWorker* current_worker = nullptr;
QFileSystemWatcher* watcher = nullptr;
CompatibilityList compatibility_list;
+
+ friend class GameListSearchField;
};
Q_DECLARE_METATYPE(GameListOpenTarget);
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h
index cee109730..3db0e90da 100644
--- a/src/yuzu/game_list_p.h
+++ b/src/yuzu/game_list_p.h
@@ -16,6 +16,7 @@
#include <QObject>
#include <QStandardItem>
#include <QString>
+#include <QWidget>
#include "common/common_types.h"
#include "common/logging/log.h"
@@ -176,3 +177,42 @@ public:
return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong();
}
};
+
+class GameList;
+class QHBoxLayout;
+class QTreeView;
+class QLabel;
+class QLineEdit;
+class QToolButton;
+
+class GameListSearchField : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit GameListSearchField(GameList* parent = nullptr);
+
+ void setFilterResult(int visible, int total);
+
+ void clear();
+ void setFocus();
+
+private:
+ class KeyReleaseEater : public QObject {
+ public:
+ explicit KeyReleaseEater(GameList* gamelist);
+
+ private:
+ GameList* gamelist = nullptr;
+ QString edit_filter_text_old;
+
+ protected:
+ // EventFilter in order to process systemkeys while editing the searchfield
+ bool eventFilter(QObject* obj, QEvent* event) override;
+ };
+ QHBoxLayout* layout_filter = nullptr;
+ QTreeView* tree_view = nullptr;
+ QLabel* label_filter = nullptr;
+ QLineEdit* edit_filter = nullptr;
+ QLabel* label_filter_result = nullptr;
+ QToolButton* button_filter_close = nullptr;
+};
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index cb37796fa..27015d02c 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -622,9 +622,9 @@ void GMainWindow::BootGame(const QString& filename) {
std::string title_name;
const auto res = Core::System::GetInstance().GetGameName(title_name);
if (res != Loader::ResultStatus::Success) {
- const u64 program_id = Core::System::GetInstance().CurrentProcess()->program_id;
+ const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
- const auto [nacp, icon_file] = FileSys::PatchManager(program_id).GetControlMetadata();
+ const auto [nacp, icon_file] = FileSys::PatchManager(title_id).GetControlMetadata();
if (nacp != nullptr)
title_name = nacp->GetApplicationName();
@@ -756,11 +756,51 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
}
+static std::size_t CalculateRomFSEntrySize(const FileSys::VirtualDir& dir, bool full) {
+ std::size_t out = 0;
+
+ for (const auto& subdir : dir->GetSubdirectories()) {
+ out += 1 + CalculateRomFSEntrySize(subdir, full);
+ }
+
+ return out + (full ? dir->GetFiles().size() : 0);
+}
+
+static bool RomFSRawCopy(QProgressDialog& dialog, const FileSys::VirtualDir& src,
+ const FileSys::VirtualDir& dest, std::size_t block_size, bool full) {
+ if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
+ return false;
+ if (dialog.wasCanceled())
+ return false;
+
+ if (full) {
+ for (const auto& file : src->GetFiles()) {
+ const auto out = VfsDirectoryCreateFileWrapper(dest, file->GetName());
+ if (!FileSys::VfsRawCopy(file, out, block_size))
+ return false;
+ dialog.setValue(dialog.value() + 1);
+ if (dialog.wasCanceled())
+ return false;
+ }
+ }
+
+ for (const auto& dir : src->GetSubdirectories()) {
+ const auto out = dest->CreateSubdirectory(dir->GetName());
+ if (!RomFSRawCopy(dialog, dir, out, block_size, full))
+ return false;
+ dialog.setValue(dialog.value() + 1);
+ if (dialog.wasCanceled())
+ return false;
+ }
+
+ return true;
+}
+
void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_path) {
const auto path = fmt::format("{}{:016X}/romfs",
FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id);
- auto failed = [this, &path]() {
+ const auto failed = [this, &path] {
QMessageBox::warning(this, tr("RomFS Extraction Failed!"),
tr("There was an error copying the RomFS files or the user "
"cancelled the operation."));
@@ -808,53 +848,13 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
failed();
const auto full = res == "Full";
-
- const static std::function<size_t(const FileSys::VirtualDir&, bool)> calculate_entry_size =
- [](const FileSys::VirtualDir& dir, bool full) {
- size_t out = 0;
- for (const auto& subdir : dir->GetSubdirectories())
- out += 1 + calculate_entry_size(subdir, full);
- return out + full ? dir->GetFiles().size() : 0;
- };
- const auto entry_size = calculate_entry_size(extracted, full);
+ const auto entry_size = CalculateRomFSEntrySize(extracted, full);
QProgressDialog progress(tr("Extracting RomFS..."), tr("Cancel"), 0, entry_size, this);
progress.setWindowModality(Qt::WindowModal);
progress.setMinimumDuration(100);
- const static std::function<bool(QProgressDialog&, const FileSys::VirtualDir&,
- const FileSys::VirtualDir&, size_t, bool)>
- qt_raw_copy = [](QProgressDialog& dialog, const FileSys::VirtualDir& src,
- const FileSys::VirtualDir& dest, size_t block_size, bool full) {
- if (src == nullptr || dest == nullptr || !src->IsReadable() || !dest->IsWritable())
- return false;
- if (dialog.wasCanceled())
- return false;
-
- if (full) {
- for (const auto& file : src->GetFiles()) {
- const auto out = VfsDirectoryCreateFileWrapper(dest, file->GetName());
- if (!FileSys::VfsRawCopy(file, out, block_size))
- return false;
- dialog.setValue(dialog.value() + 1);
- if (dialog.wasCanceled())
- return false;
- }
- }
-
- for (const auto& dir : src->GetSubdirectories()) {
- const auto out = dest->CreateSubdirectory(dir->GetName());
- if (!qt_raw_copy(dialog, dir, out, block_size, full))
- return false;
- dialog.setValue(dialog.value() + 1);
- if (dialog.wasCanceled())
- return false;
- }
-
- return true;
- };
-
- if (qt_raw_copy(progress, extracted, out, 0x400000, full)) {
+ if (RomFSRawCopy(progress, extracted, out, 0x400000, full)) {
progress.close();
QMessageBox::information(this, tr("RomFS Extraction Succeeded!"),
tr("The operation completed successfully."));
@@ -931,7 +931,7 @@ void GMainWindow::OnMenuInstallToNAND() {
}
const auto qt_raw_copy = [this](const FileSys::VirtualFile& src,
- const FileSys::VirtualFile& dest, size_t block_size) {
+ const FileSys::VirtualFile& dest, std::size_t block_size) {
if (src == nullptr || dest == nullptr)
return false;
if (!dest->Resize(src->GetSize()))