diff options
| author | 2018-08-20 21:46:40 -0700 | |
|---|---|---|
| committer | 2018-08-21 02:04:33 -0700 | |
| commit | cc71832b19ed9d3579160ddb8fe6e4f9a8269553 (patch) | |
| tree | b92c24231393ccc10544b2fddef8017f8d7023e1 /src | |
| parent | Merge pull request #1123 from lioncash/screen (diff) | |
| download | yuzu-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.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 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 | ||
| 304 | void GMainWindow::ConnectWidgetEvents() { | 305 | void 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 | ||
| 587 | void GMainWindow::OnGameListOpenSaveFolder(u64 program_id) { | 587 | void 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 | ||
| 591 | void GMainWindow::OnMenuLoadFile() { | 620 | void 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; | |||
| 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(); |