From a17111e6b0e4802044c90f4bedd66478de689070 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 3 Aug 2023 19:53:46 +0200 Subject: [PATCH] TitleManager: Improvements for .wua conversion - Print more detailed paths in confirmation dialogue - Prefer the title right clicked by the user - When sourcing titles from other .wua files, use the correct subpath Fix include path --- src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp | 2 +- src/Cafe/TitleList/TitleInfo.h | 2 +- src/gui/components/wxTitleManagerList.cpp | 42 +++++++++++--------- src/gui/components/wxTitleManagerList.h | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp index 241630aa..e6cea082 100644 --- a/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp +++ b/src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp @@ -3,7 +3,7 @@ #include "nn_olv_OfflineDB.h" #include "Cemu/ncrypto/ncrypto.h" // for base64 encoder/decoder #include "util/helpers/helpers.h" -#include "Config/ActiveSettings.h" +#include "config/ActiveSettings.h" #include "Cafe/CafeSystem.h" #include #include diff --git a/src/Cafe/TitleList/TitleInfo.h b/src/Cafe/TitleList/TitleInfo.h index 9b8fa722..da430adc 100644 --- a/src/Cafe/TitleList/TitleInfo.h +++ b/src/Cafe/TitleList/TitleInfo.h @@ -148,7 +148,7 @@ public: return m_parsedMetaXml; } - std::string GetPrintPath() const; // formatted path for log writing + std::string GetPrintPath() const; // formatted path including type and WUA subpath. Intended for logging and user-facing information std::string GetInstallPath() const; // installation subpath, relative to storage base. E.g. "usr/title/.../..." or "sys/title/.../..." static std::string GetUniqueTempMountingPath(); diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index 257f84d2..6572a702 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -242,7 +242,7 @@ boost::optional wxTitleManagerList::GetTi return {}; } -void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId) +void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID) { TitleInfo titleInfo_base; TitleInfo titleInfo_update; @@ -269,22 +269,26 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId) { if (!titleInfo_base.IsValid()) { - titleInfo_base = TitleInfo(data->entry.path); - } - else - { - // duplicate entry + titleInfo_base = CafeTitleList::GetTitleInfoByUID(data->entry.location_uid); + if(data->entry.location_uid == rightClickedUID) + break; // prefer the users selection } } if (hasUpdateTitleId && data->entry.title_id == updateTitleId) { if (!titleInfo_update.IsValid()) { - titleInfo_update = TitleInfo(data->entry.path); + titleInfo_update = CafeTitleList::GetTitleInfoByUID(data->entry.location_uid); + if(data->entry.location_uid == rightClickedUID) + break; } else { - // duplicate entry + // if multiple updates are present use the newest one + if (titleInfo_update.GetAppTitleVersion() < data->entry.version) + titleInfo_update = CafeTitleList::GetTitleInfoByUID(data->entry.location_uid); + if(data->entry.location_uid == rightClickedUID) + break; } } } @@ -293,7 +297,9 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId) { if (data->entry.title_id == aocTitleId) { - titleInfo_aoc = TitleInfo(data->entry.path); + titleInfo_aoc = CafeTitleList::GetTitleInfoByUID(data->entry.location_uid); + if(data->entry.location_uid == rightClickedUID) + break; } } @@ -301,23 +307,23 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId) msg.append("\n \n"); if (titleInfo_base.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game: {}"))), _pathToUtf8(titleInfo_base.GetPath()))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game:\n{}"))), titleInfo_base.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game: Not installed"))))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game:\nNot installed"))))); - msg.append("\n"); + msg.append("\n\n"); if (titleInfo_update.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update: {}"))), _pathToUtf8(titleInfo_update.GetPath()))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update:\n{}"))), titleInfo_update.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update: Not installed"))))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update:\nNot installed"))))); - msg.append("\n"); + msg.append("\n\n"); if (titleInfo_aoc.IsValid()) - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC: {}"))), _pathToUtf8(titleInfo_aoc.GetPath()))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC:\n{}"))), titleInfo_aoc.GetPrintPath())); else - msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC: Not installed"))))); + msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC:\nNot installed"))))); const int answer = wxMessageBox(wxString::FromUTF8(msg), _("Confirmation"), wxOK | wxCANCEL | wxCENTRE | wxICON_QUESTION, this); if (answer != wxOK) @@ -884,7 +890,7 @@ void wxTitleManagerList::OnContextMenuSelected(wxCommandEvent& event) break; case kContextMenuConvertToWUA: - OnConvertToCompressedFormat(entry.value().title_id); + OnConvertToCompressedFormat(entry.value().title_id, entry.value().location_uid); break; } } diff --git a/src/gui/components/wxTitleManagerList.h b/src/gui/components/wxTitleManagerList.h index 706de2e7..547310c2 100644 --- a/src/gui/components/wxTitleManagerList.h +++ b/src/gui/components/wxTitleManagerList.h @@ -108,7 +108,7 @@ private: [[nodiscard]] boost::optional GetTitleEntry(const fs::path& path); bool VerifyEntryFiles(TitleEntry& entry); - void OnConvertToCompressedFormat(uint64 titleId); + void OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID); bool DeleteEntry(long index, const TitleEntry& entry); void RemoveItem(long item);