Skip to content

Commit

Permalink
TitleManager: Improvements for .wua conversion
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Exzap committed Aug 3, 2023
1 parent 911573e commit a17111e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Cafe/OS/libs/nn_olv/nn_olv_OfflineDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pugixml.hpp>
#include <zlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/TitleList/TitleInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TitleInfo
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();
Expand Down
42 changes: 24 additions & 18 deletions src/gui/components/wxTitleManagerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ boost::optional<const wxTitleManagerList::TitleEntry&> wxTitleManagerList::GetTi
return {};
}

void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId)
void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId, uint64 rightClickedUID)
{
TitleInfo titleInfo_base;
TitleInfo titleInfo_update;
Expand All @@ -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;
}
}
}
Expand All @@ -293,31 +297,33 @@ 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;
}
}

std::string msg = wxHelper::MakeUTF8(_("The following content will be converted to a compressed Wii U archive file (.wua):"));
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)
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/components/wxTitleManagerList.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class wxTitleManagerList : public wxListCtrl
[[nodiscard]] boost::optional<TitleEntry&> 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);
Expand Down

0 comments on commit a17111e

Please sign in to comment.