mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	citra_qt, core: game list "Open XXX Location" improvements
This commit is contained in:
		
							parent
							
								
									41688b2f2a
								
							
						
					
					
						commit
						bbf391abb9
					
				
					 11 changed files with 120 additions and 19 deletions
				
			
		|  | @ -27,6 +27,8 @@ | |||
| #include "citra_qt/ui_settings.h" | ||||
| #include "common/common_paths.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/file_sys/archive_extsavedata.h" | ||||
| #include "core/file_sys/archive_source_sd_savedata.h" | ||||
| #include "core/hle/service/fs/archive.h" | ||||
| #include "core/loader/loader.h" | ||||
| 
 | ||||
|  | @ -409,7 +411,9 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { | |||
|     QMenu context_menu; | ||||
|     switch (selected.data(GameListItem::TypeRole).value<GameListItemType>()) { | ||||
|     case GameListItemType::Game: | ||||
|         AddGamePopup(context_menu, selected.data(GameListItemPath::ProgramIdRole).toULongLong()); | ||||
|         AddGamePopup(context_menu, selected.data(GameListItemPath::FullPathRole).toString(), | ||||
|                      selected.data(GameListItemPath::ProgramIdRole).toULongLong(), | ||||
|                      selected.data(GameListItemPath::ExtdataIdRole).toULongLong()); | ||||
|         break; | ||||
|     case GameListItemType::CustomDir: | ||||
|         AddPermDirPopup(context_menu, selected); | ||||
|  | @ -423,23 +427,46 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { | |||
|     context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); | ||||
| } | ||||
| 
 | ||||
| void GameList::AddGamePopup(QMenu& context_menu, u64 program_id) { | ||||
| void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 program_id, | ||||
|                             u64 extdata_id) { | ||||
|     QAction* open_save_location = context_menu.addAction(tr("Open Save Data Location")); | ||||
|     QAction* open_extdata_location = context_menu.addAction(tr("Open Extra Data Location")); | ||||
|     QAction* open_application_location = context_menu.addAction(tr("Open Application Location")); | ||||
|     QAction* open_update_location = context_menu.addAction(tr("Open Update Data Location")); | ||||
|     QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry")); | ||||
| 
 | ||||
|     open_save_location->setEnabled(program_id != 0); | ||||
|     open_application_location->setVisible(FileUtil::Exists( | ||||
|         Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, program_id))); | ||||
|     open_update_location->setEnabled(0x0004000000000000 <= program_id && | ||||
|                                      program_id <= 0x00040000FFFFFFFF); | ||||
|     const bool is_application = | ||||
|         0x0004000000000000 <= program_id && program_id <= 0x00040000FFFFFFFF; | ||||
| 
 | ||||
|     std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); | ||||
|     open_save_location->setVisible( | ||||
|         is_application && FileUtil::Exists(FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor( | ||||
|                               sdmc_dir, program_id))); | ||||
| 
 | ||||
|     if (extdata_id) { | ||||
|         open_extdata_location->setVisible( | ||||
|             is_application && | ||||
|             FileUtil::Exists(FileSys::GetExtDataPathFromId(sdmc_dir, extdata_id))); | ||||
|     } else { | ||||
|         open_extdata_location->setVisible(false); | ||||
|     } | ||||
| 
 | ||||
|     auto media_type = Service::AM::GetTitleMediaType(program_id); | ||||
|     open_application_location->setVisible(path.toStdString() == | ||||
|                                           Service::AM::GetTitleContentPath(media_type, program_id)); | ||||
|     open_update_location->setVisible( | ||||
|         is_application && FileUtil::Exists(Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, | ||||
|                                                                      program_id + 0xe00000000) + | ||||
|                                            "content/")); | ||||
|     auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); | ||||
|     navigate_to_gamedb_entry->setVisible(it != compatibility_list.end()); | ||||
| 
 | ||||
|     connect(open_save_location, &QAction::triggered, [this, program_id] { | ||||
|         emit OpenFolderRequested(program_id, GameListOpenTarget::SAVE_DATA); | ||||
|     }); | ||||
|     connect(open_extdata_location, &QAction::triggered, [this, extdata_id] { | ||||
|         emit OpenFolderRequested(extdata_id, GameListOpenTarget::EXT_DATA); | ||||
|     }); | ||||
|     connect(open_application_location, &QAction::triggered, [this, program_id] { | ||||
|         emit OpenFolderRequested(program_id, GameListOpenTarget::APPLICATION); | ||||
|     }); | ||||
|  | @ -651,6 +678,9 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
|             u64 program_id = 0; | ||||
|             loader->ReadProgramId(program_id); | ||||
| 
 | ||||
|             u64 extdata_id = 0; | ||||
|             loader->ReadExtdataId(extdata_id); | ||||
| 
 | ||||
|             std::vector<u8> smdh = [program_id, &loader]() -> std::vector<u8> { | ||||
|                 std::vector<u8> original_smdh; | ||||
|                 loader->ReadIcon(original_smdh); | ||||
|  | @ -683,7 +713,8 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 
 | ||||
|             emit EntryReady( | ||||
|                 { | ||||
|                     new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id), | ||||
|                     new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id, | ||||
|                                          extdata_id), | ||||
|                     new GameListItemCompat(compatibility), | ||||
|                     new GameListItemRegion(smdh), | ||||
|                     new GameListItem( | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ class QTreeView; | |||
| class QToolButton; | ||||
| class QVBoxLayout; | ||||
| 
 | ||||
| enum class GameListOpenTarget { SAVE_DATA = 0, APPLICATION = 1, UPDATE_DATA = 2 }; | ||||
| enum class GameListOpenTarget { SAVE_DATA = 0, EXT_DATA = 1, APPLICATION = 2, UPDATE_DATA = 3 }; | ||||
| 
 | ||||
| class GameList : public QWidget { | ||||
|     Q_OBJECT | ||||
|  | @ -89,7 +89,7 @@ private: | |||
|     void RefreshGameDirectory(); | ||||
| 
 | ||||
|     void PopupContextMenu(const QPoint& menu_location); | ||||
|     void AddGamePopup(QMenu& context_menu, u64 program_id); | ||||
|     void AddGamePopup(QMenu& context_menu, const QString& path, u64 program_id, u64 extdata_id); | ||||
|     void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); | ||||
|     void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); | ||||
| 
 | ||||
|  |  | |||
|  | @ -135,12 +135,15 @@ public: | |||
|     static const int TitleRole = SortRole; | ||||
|     static const int FullPathRole = SortRole + 1; | ||||
|     static const int ProgramIdRole = SortRole + 2; | ||||
|     static const int ExtdataIdRole = SortRole + 3; | ||||
| 
 | ||||
|     GameListItemPath() = default; | ||||
|     GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id) { | ||||
|     GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id, | ||||
|                      u64 extdata_id) { | ||||
|         setData(type(), TypeRole); | ||||
|         setData(game_path, FullPathRole); | ||||
|         setData(qulonglong(program_id), ProgramIdRole); | ||||
|         setData(qulonglong(extdata_id), ExtdataIdRole); | ||||
| 
 | ||||
|         if (!Loader::IsValidSMDH(smdh_data)) { | ||||
|             // SMDH is not valid, set a default icon
 | ||||
|  |  | |||
|  | @ -52,6 +52,7 @@ | |||
| #include "common/scm_rev.h" | ||||
| #include "common/scope_exit.h" | ||||
| #include "core/core.h" | ||||
| #include "core/file_sys/archive_extsavedata.h" | ||||
| #include "core/file_sys/archive_source_sd_savedata.h" | ||||
| #include "core/frontend/applets/default_applets.h" | ||||
| #include "core/gdbstub/gdbstub.h" | ||||
|  | @ -879,7 +880,7 @@ void GMainWindow::OnGameListLoadFile(QString game_path) { | |||
|     BootGame(game_path); | ||||
| } | ||||
| 
 | ||||
| void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target) { | ||||
| void GMainWindow::OnGameListOpenFolder(u64 data_id, GameListOpenTarget target) { | ||||
|     std::string path; | ||||
|     std::string open_target; | ||||
| 
 | ||||
|  | @ -887,16 +888,24 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
|     case GameListOpenTarget::SAVE_DATA: { | ||||
|         open_target = "Save Data"; | ||||
|         std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); | ||||
|         path = FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor(sdmc_dir, program_id); | ||||
|         path = FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor(sdmc_dir, data_id); | ||||
|         break; | ||||
|     } | ||||
|     case GameListOpenTarget::APPLICATION: | ||||
|         open_target = "Application"; | ||||
|         path = Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, program_id) + "content/"; | ||||
|     case GameListOpenTarget::EXT_DATA: { | ||||
|         open_target = "Extra Data"; | ||||
|         std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); | ||||
|         path = FileSys::GetExtDataPathFromId(sdmc_dir, data_id); | ||||
|         break; | ||||
|     } | ||||
|     case GameListOpenTarget::APPLICATION: { | ||||
|         open_target = "Application"; | ||||
|         auto media_type = Service::AM::GetTitleMediaType(data_id); | ||||
|         path = Service::AM::GetTitlePath(media_type, data_id) + "content/"; | ||||
|         break; | ||||
|     } | ||||
|     case GameListOpenTarget::UPDATE_DATA: | ||||
|         open_target = "Update Data"; | ||||
|         path = Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, program_id + 0xe00000000) + | ||||
|         path = Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, data_id + 0xe00000000) + | ||||
|                "content/"; | ||||
|         break; | ||||
|     default: | ||||
|  | @ -914,7 +923,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     LOG_INFO(Frontend, "Opening {} path for program_id={:016x}", open_target, program_id); | ||||
|     LOG_INFO(Frontend, "Opening {} path for data_id={:016x}", open_target, data_id); | ||||
| 
 | ||||
|     QDesktopServices::openUrl(QUrl::fromLocalFile(qpath)); | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue