diff options
| author | 2018-08-22 01:30:08 -0400 | |
|---|---|---|
| committer | 2018-08-22 01:30:08 -0400 | |
| commit | b38d67d940ddd4c03d833dc443126609e0981987 (patch) | |
| tree | faf5f641c5d21df58b18fd22f1ece2af6f964083 /src | |
| parent | Merge pull request #840 from FearlessTobi/port-3353 (diff) | |
| parent | qt/main: Port part of citra(#3411), open savedata works (diff) | |
| download | yuzu-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.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.h | 6 | ||||
| -rw-r--r-- | src/yuzu/game_list.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/game_list.h | 6 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 37 | ||||
| -rw-r--r-- | src/yuzu/main.h | 3 |
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 | ||
| 75 | std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | 75 | std::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 | |||
| 52 | private: | 55 | private: |
| 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 | ||
| 22 | class GameListWorker; | 22 | class GameListWorker; |
| 23 | 23 | ||
| 24 | enum class GameListOpenTarget { SaveData }; | ||
| 25 | |||
| 24 | class GameList : public QWidget { | 26 | class GameList : public QWidget { |
| 25 | Q_OBJECT | 27 | Q_OBJECT |
| 26 | 28 | ||
| @@ -76,7 +78,7 @@ public: | |||
| 76 | signals: | 78 | signals: |
| 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 | ||
| 81 | private slots: | 83 | private 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 | |||
| 105 | Q_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 | ||
| 338 | void GMainWindow::ConnectWidgetEvents() { | 339 | void 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 | ||
| 627 | void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) { | 627 | void 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 | ||
| 631 | void GMainWindow::OnMenuLoadFile() { | 660 | void 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; | |||
| 21 | class MicroProfileDialog; | 21 | class MicroProfileDialog; |
| 22 | class ProfilerWidget; | 22 | class ProfilerWidget; |
| 23 | class WaitTreeWidget; | 23 | class WaitTreeWidget; |
| 24 | enum class GameListOpenTarget; | ||
| 24 | 25 | ||
| 25 | namespace Tegra { | 26 | namespace Tegra { |
| 26 | class DebugContext; | 27 | class 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(); |