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
This commit is contained in:
Exzap 2023-08-03 19:53:46 +02:00
parent 911573e0dd
commit a17111e6b0
4 changed files with 27 additions and 21 deletions

View File

@ -3,7 +3,7 @@
#include "nn_olv_OfflineDB.h" #include "nn_olv_OfflineDB.h"
#include "Cemu/ncrypto/ncrypto.h" // for base64 encoder/decoder #include "Cemu/ncrypto/ncrypto.h" // for base64 encoder/decoder
#include "util/helpers/helpers.h" #include "util/helpers/helpers.h"
#include "Config/ActiveSettings.h" #include "config/ActiveSettings.h"
#include "Cafe/CafeSystem.h" #include "Cafe/CafeSystem.h"
#include <pugixml.hpp> #include <pugixml.hpp>
#include <zlib.h> #include <zlib.h>

View File

@ -148,7 +148,7 @@ public:
return m_parsedMetaXml; 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/.../..." std::string GetInstallPath() const; // installation subpath, relative to storage base. E.g. "usr/title/.../..." or "sys/title/.../..."
static std::string GetUniqueTempMountingPath(); static std::string GetUniqueTempMountingPath();

View File

@ -242,7 +242,7 @@ boost::optional<const wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetTi
return {}; return {};
} }
void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId) void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID)
{ {
TitleInfo titleInfo_base; TitleInfo titleInfo_base;
TitleInfo titleInfo_update; TitleInfo titleInfo_update;
@ -269,22 +269,26 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId)
{ {
if (!titleInfo_base.IsValid()) if (!titleInfo_base.IsValid())
{ {
titleInfo_base = TitleInfo(data->entry.path); titleInfo_base = CafeTitleList::GetTitleInfoByUID(data->entry.location_uid);
} if(data->entry.location_uid == rightClickedUID)
else break; // prefer the users selection
{
// duplicate entry
} }
} }
if (hasUpdateTitleId && data->entry.title_id == updateTitleId) if (hasUpdateTitleId && data->entry.title_id == updateTitleId)
{ {
if (!titleInfo_update.IsValid()) 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 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) 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"); msg.append("\n \n");
if (titleInfo_base.IsValid()) 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 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()) 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 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()) 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 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); const int answer = wxMessageBox(wxString::FromUTF8(msg), _("Confirmation"), wxOK | wxCANCEL | wxCENTRE | wxICON_QUESTION, this);
if (answer != wxOK) if (answer != wxOK)
@ -884,7 +890,7 @@ void wxTitleManagerList::OnContextMenuSelected(wxCommandEvent& event)
break; break;
case kContextMenuConvertToWUA: case kContextMenuConvertToWUA:
OnConvertToCompressedFormat(entry.value().title_id); OnConvertToCompressedFormat(entry.value().title_id, entry.value().location_uid);
break; break;
} }
} }

View File

@ -108,7 +108,7 @@ private:
[[nodiscard]] boost::optional<TitleEntry&> GetTitleEntry(const fs::path& path); [[nodiscard]] boost::optional<TitleEntry&> GetTitleEntry(const fs::path& path);
bool VerifyEntryFiles(TitleEntry& entry); bool VerifyEntryFiles(TitleEntry& entry);
void OnConvertToCompressedFormat(uint64 titleId); void OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID);
bool DeleteEntry(long index, const TitleEntry& entry); bool DeleteEntry(long index, const TitleEntry& entry);
void RemoveItem(long item); void RemoveItem(long item);