summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar tech4me2018-08-20 21:46:40 -0700
committerGravatar tech4me2018-08-21 02:04:33 -0700
commitcc71832b19ed9d3579160ddb8fe6e4f9a8269553 (patch)
treeb92c24231393ccc10544b2fddef8017f8d7023e1 /src
parentMerge pull request #1123 from lioncash/screen (diff)
downloadyuzu-cc71832b19ed9d3579160ddb8fe6e4f9a8269553.tar.gz
yuzu-cc71832b19ed9d3579160ddb8fe6e4f9a8269553.tar.xz
yuzu-cc71832b19ed9d3579160ddb8fe6e4f9a8269553.zip
qt/main: Port part of citra(#3411), open savedata works
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/savedata_factory.cpp2
-rw-r--r--src/core/file_sys/savedata_factory.h6
-rw-r--r--src/yuzu/game_list.cpp2
-rw-r--r--src/yuzu/game_list.h6
-rw-r--r--src/yuzu/main.cpp37
-rw-r--r--src/yuzu/main.h3
6 files changed, 45 insertions, 11 deletions
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index dfdca83d6..034d3a78f 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -73,7 +73,7 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr
73} 73}
74 74
75std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, 75std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
76 u128 user_id, u64 save_id) const { 76 u128 user_id, u64 save_id) {
77 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should 77 // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should
78 // be interpreted as the title id of the current process. 78 // be interpreted as the title id of the current process.
79 if (type == SaveDataType::SaveData && title_id == 0) 79 if (type == SaveDataType::SaveData && title_id == 0)
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h
index f3cf50d5a..368b36017 100644
--- a/src/core/file_sys/savedata_factory.h
+++ b/src/core/file_sys/savedata_factory.h
@@ -49,11 +49,11 @@ public:
49 49
50 ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); 50 ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta);
51 51
52 static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id,
53 u128 user_id, u64 save_id);
54
52private: 55private:
53 VirtualDir dir; 56 VirtualDir dir;
54
55 std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, u128 user_id,
56 u64 save_id) const;
57}; 57};
58 58
59} // namespace FileSys 59} // namespace FileSys
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp
index a974fb933..d5726b8b3 100644
--- a/src/yuzu/game_list.cpp
+++ b/src/yuzu/game_list.cpp
@@ -327,7 +327,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
327 QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); 327 QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location"));
328 open_save_location->setEnabled(program_id != 0); 328 open_save_location->setEnabled(program_id != 0);
329 connect(open_save_location, &QAction::triggered, 329 connect(open_save_location, &QAction::triggered,
330 [&]() { emit OpenSaveFolderRequested(program_id); }); 330 [&]() { emit OpenFolderRequested(program_id, GameListOpenTarget::SaveData); });
331 context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); 331 context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
332} 332}
333 333
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h
index afe624b32..20252e778 100644
--- a/src/yuzu/game_list.h
+++ b/src/yuzu/game_list.h
@@ -21,6 +21,8 @@
21 21
22class GameListWorker; 22class GameListWorker;
23 23
24enum class GameListOpenTarget { SaveData };
25
24class GameList : public QWidget { 26class GameList : public QWidget {
25 Q_OBJECT 27 Q_OBJECT
26 28
@@ -76,7 +78,7 @@ public:
76signals: 78signals:
77 void GameChosen(QString game_path); 79 void GameChosen(QString game_path);
78 void ShouldCancelWorker(); 80 void ShouldCancelWorker();
79 void OpenSaveFolderRequested(u64 program_id); 81 void OpenFolderRequested(u64 program_id, GameListOpenTarget target);
80 82
81private slots: 83private slots:
82 void onTextChanged(const QString& newText); 84 void onTextChanged(const QString& newText);
@@ -99,3 +101,5 @@ private:
99 GameListWorker* current_worker = nullptr; 101 GameListWorker* current_worker = nullptr;
100 QFileSystemWatcher* watcher = nullptr; 102 QFileSystemWatcher* watcher = nullptr;
101}; 103};
104
105Q_DECLARE_METATYPE(GameListOpenTarget);
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 3db3f9d98..e4cac5984 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -30,6 +30,7 @@
30#include "core/file_sys/bis_factory.h" 30#include "core/file_sys/bis_factory.h"
31#include "core/file_sys/card_image.h" 31#include "core/file_sys/card_image.h"
32#include "core/file_sys/registered_cache.h" 32#include "core/file_sys/registered_cache.h"
33#include "core/file_sys/savedata_factory.h"
33#include "core/file_sys/vfs_real.h" 34#include "core/file_sys/vfs_real.h"
34#include "core/gdbstub/gdbstub.h" 35#include "core/gdbstub/gdbstub.h"
35#include "core/loader/loader.h" 36#include "core/loader/loader.h"
@@ -303,8 +304,7 @@ void GMainWindow::RestoreUIState() {
303 304
304void GMainWindow::ConnectWidgetEvents() { 305void GMainWindow::ConnectWidgetEvents() {
305 connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); 306 connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
306 connect(game_list, &GameList::OpenSaveFolderRequested, this, 307 connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
307 &GMainWindow::OnGameListOpenSaveFolder);
308 308
309 connect(this, &GMainWindow::EmulationStarting, render_window, 309 connect(this, &GMainWindow::EmulationStarting, render_window,
310 &GRenderWindow::OnEmulationStarting); 310 &GRenderWindow::OnEmulationStarting);
@@ -584,8 +584,37 @@ void GMainWindow::OnGameListLoadFile(QString game_path) {
584 BootGame(game_path); 584 BootGame(game_path);
585} 585}
586 586
587void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) { 587void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target) {
588 UNIMPLEMENTED(); 588 std::string path;
589 std::string open_target;
590 switch (target) {
591 case GameListOpenTarget::SaveData: {
592 open_target = "Save Data";
593 const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
594 ASSERT(program_id != 0);
595 // TODO(tech4me): Update this to work with arbitrary user profile
596 // Refer to core/hle/service/acc/profile_manager.cpp ProfileManager constructor
597 constexpr u128 user_id = {1, 0};
598 path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser,
599 FileSys::SaveDataType::SaveData,
600 program_id, user_id, 0);
601 break;
602 }
603 default:
604 UNIMPLEMENTED();
605 }
606
607 const QString qpath = QString::fromStdString(path);
608
609 const QDir dir(qpath);
610 if (!dir.exists()) {
611 QMessageBox::warning(this,
612 tr("Error Opening %1 Folder").arg(QString::fromStdString(open_target)),
613 tr("Folder does not exist!"));
614 return;
615 }
616 LOG_INFO(Frontend, "Opening {} path for program_id={:016x}", open_target, program_id);
617 QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
589} 618}
590 619
591void GMainWindow::OnMenuLoadFile() { 620void GMainWindow::OnMenuLoadFile() {
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 5f4d2ab9a..02df30878 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -21,6 +21,7 @@ class GRenderWindow;
21class MicroProfileDialog; 21class MicroProfileDialog;
22class ProfilerWidget; 22class ProfilerWidget;
23class WaitTreeWidget; 23class WaitTreeWidget;
24enum class GameListOpenTarget;
24 25
25namespace Tegra { 26namespace Tegra {
26class DebugContext; 27class DebugContext;
@@ -122,7 +123,7 @@ private slots:
122 void OnStopGame(); 123 void OnStopGame();
123 /// Called whenever a user selects a game in the game list widget. 124 /// Called whenever a user selects a game in the game list widget.
124 void OnGameListLoadFile(QString game_path); 125 void OnGameListLoadFile(QString game_path);
125 void OnGameListOpenSaveFolder(u64 program_id); 126 void OnGameListOpenFolder(u64 program_id, GameListOpenTarget target);
126 void OnMenuLoadFile(); 127 void OnMenuLoadFile();
127 void OnMenuLoadFolder(); 128 void OnMenuLoadFolder();
128 void OnMenuInstallToNAND(); 129 void OnMenuInstallToNAND();