summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-08-22 01:30:08 -0400
committerGravatar GitHub2018-08-22 01:30:08 -0400
commitb38d67d940ddd4c03d833dc443126609e0981987 (patch)
treefaf5f641c5d21df58b18fd22f1ece2af6f964083 /src
parentMerge pull request #840 from FearlessTobi/port-3353 (diff)
parentqt/main: Port part of citra(#3411), open savedata works (diff)
downloadyuzu-b38d67d940ddd4c03d833dc443126609e0981987.tar.gz
yuzu-b38d67d940ddd4c03d833dc443126609e0981987.tar.xz
yuzu-b38d67d940ddd4c03d833dc443126609e0981987.zip
Merge pull request #1136 from tech4me/master
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 62ff7a2d7..c62360bd4 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"
@@ -337,8 +338,7 @@ void GMainWindow::RestoreUIState() {
337 338
338void GMainWindow::ConnectWidgetEvents() { 339void GMainWindow::ConnectWidgetEvents() {
339 connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); 340 connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
340 connect(game_list, &GameList::OpenSaveFolderRequested, this, 341 connect(game_list, &GameList::OpenFolderRequested, this, &GMainWindow::OnGameListOpenFolder);
341 &GMainWindow::OnGameListOpenSaveFolder);
342 342
343 connect(this, &GMainWindow::EmulationStarting, render_window, 343 connect(this, &GMainWindow::EmulationStarting, render_window,
344 &GRenderWindow::OnEmulationStarting); 344 &GRenderWindow::OnEmulationStarting);
@@ -624,8 +624,37 @@ void GMainWindow::OnGameListLoadFile(QString game_path) {
624 BootGame(game_path); 624 BootGame(game_path);
625} 625}
626 626
627void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) { 627void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target) {
628 UNIMPLEMENTED(); 628 std::string path;
629 std::string open_target;
630 switch (target) {
631 case GameListOpenTarget::SaveData: {
632 open_target = "Save Data";
633 const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
634 ASSERT(program_id != 0);
635 // TODO(tech4me): Update this to work with arbitrary user profile
636 // Refer to core/hle/service/acc/profile_manager.cpp ProfileManager constructor
637 constexpr u128 user_id = {1, 0};
638 path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser,
639 FileSys::SaveDataType::SaveData,
640 program_id, user_id, 0);
641 break;
642 }
643 default:
644 UNIMPLEMENTED();
645 }
646
647 const QString qpath = QString::fromStdString(path);
648
649 const QDir dir(qpath);
650 if (!dir.exists()) {
651 QMessageBox::warning(this,
652 tr("Error Opening %1 Folder").arg(QString::fromStdString(open_target)),
653 tr("Folder does not exist!"));
654 return;
655 }
656 LOG_INFO(Frontend, "Opening {} path for program_id={:016x}", open_target, program_id);
657 QDesktopServices::openUrl(QUrl::fromLocalFile(qpath));
629} 658}
630 659
631void GMainWindow::OnMenuLoadFile() { 660void GMainWindow::OnMenuLoadFile() {
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 0534d4f99..d1d34552b 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();