diff --git a/sphaira/include/ui/error_box.hpp b/sphaira/include/ui/error_box.hpp index 2ac0dba..d1721cf 100644 --- a/sphaira/include/ui/error_box.hpp +++ b/sphaira/include/ui/error_box.hpp @@ -17,6 +17,7 @@ private: std::optional m_code{}; std::string m_message{}; std::string m_code_message{}; + std::string m_code_module{}; }; } // namespace sphaira::ui diff --git a/sphaira/source/ui/error_box.cpp b/sphaira/source/ui/error_box.cpp index 981cad9..8dc49fe 100644 --- a/sphaira/source/ui/error_box.cpp +++ b/sphaira/source/ui/error_box.cpp @@ -6,11 +6,35 @@ namespace sphaira::ui { namespace { +auto GetModule(Result rc) -> const char* { + switch (R_MODULE(rc)) { + case Module_Svc: return "Svc"; + case Module_Fs: return "Fs"; + case Module_Os: return "Os"; + case Module_Ncm: return "Ncm"; + case Module_Ns: return "Ns"; + case Module_Spl: return "Spl"; + case Module_Applet: return "Applet"; + case Module_Usb: return "Usb"; + case Module_Irsensor: return "Irsensor"; + case Module_Libnx: return "Libnx"; + case Module_Sphaira: return "Sphaira"; + } + + return nullptr; +} auto GetCodeMessage(Result rc) -> const char* { switch (rc) { + case SvcError_TimedOut: return "SvcError_TimedOut"; + case SvcError_Cancelled: return "SvcError_Cancelled"; + case FsError_PathNotFound: return "FsError_PathNotFound"; case FsError_PathAlreadyExists: return "FsError_PathAlreadyExists"; case FsError_TargetLocked: return "FsError_TargetLocked"; + case FsError_TooLongPath: return "FsError_TooLongPath"; + case FsError_InvalidCharacter: return "FsError_InvalidCharacter"; + case FsError_InvalidOffset: return "FsError_InvalidOffset"; + case FsError_InvalidSize: return "FsError_InvalidSize"; case Result_TransferCancelled: return "SphairaError_TransferCancelled"; case Result_StreamBadSeek: return "SphairaError_StreamBadSeek"; @@ -143,7 +167,11 @@ ErrorBox::ErrorBox(const std::string& message) : m_message{message} { ErrorBox::ErrorBox(Result code, const std::string& message) : ErrorBox{message} { m_code = code; m_code_message = GetCodeMessage(code); - log_write("[ERROR] Code: 0x%X Module: %u Description: %u\n", R_VALUE(code), R_MODULE(code), R_DESCRIPTION(code)); + m_code_module = std::to_string(R_MODULE(code)); + if (auto str = GetModule(code)) { + m_code_module += " (" + std::string(str) + ")"; + } + log_write("[ERROR] Code: 0x%X Module: %s Description: %u\n", R_VALUE(code), m_code_module.c_str(), R_DESCRIPTION(code)); } auto ErrorBox::Update(Controller* controller, TouchInfo* touch) -> void { @@ -161,7 +189,7 @@ auto ErrorBox::Draw(NVGcontext* vg, Theme* theme) -> void { if (m_code.has_value()) { const auto code = m_code.value(); if (m_code_message.empty()) { - gfx::drawTextArgs(vg, center_x, 270, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, theme->GetColour(ThemeEntryID_TEXT), "Code: 0x%X Module: %u Description: 0x%X", R_VALUE(code), R_MODULE(code), R_DESCRIPTION(code)); + gfx::drawTextArgs(vg, center_x, 270, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, theme->GetColour(ThemeEntryID_TEXT), "Code: 0x%X Module: %s", R_VALUE(code), m_code_module.c_str()); } else { gfx::drawTextArgs(vg, center_x, 270, 25, NVG_ALIGN_CENTER | NVG_ALIGN_TOP, theme->GetColour(ThemeEntryID_TEXT), "%s", m_code_message.c_str()); } diff --git a/sphaira/source/ui/menus/themezer.cpp b/sphaira/source/ui/menus/themezer.cpp index d95412f..bfb49ef 100644 --- a/sphaira/source/ui/menus/themezer.cpp +++ b/sphaira/source/ui/menus/themezer.cpp @@ -13,6 +13,7 @@ #include "i18n.hpp" #include "threaded_file_transfer.hpp" #include "image.hpp" +#include "title_info.hpp" #include #include @@ -260,9 +261,17 @@ auto InstallTheme(ProgressBox* pbox, const PackListEntry& entry) -> Result { ON_SCOPE_EXIT(fs.DeleteFile(zip_out)); - // create directories + // replace invalid characters in the name. + fs::FsPath name_buf{entry.details.name}; + title::utilsReplaceIllegalCharacters(name_buf, false); + + // replace invalid characters in the author. + fs::FsPath author_buf{entry.creator.display_name}; + title::utilsReplaceIllegalCharacters(author_buf, false); + + // create directories. fs::FsPath dir_path; - std::snprintf(dir_path, sizeof(dir_path), "%s/%s - By %s", THEME_FOLDER.s, entry.details.name.c_str(), entry.creator.display_name.c_str()); + std::snprintf(dir_path, sizeof(dir_path), "%s/%s - By %s", THEME_FOLDER.s, name_buf.s, author_buf.s); fs.CreateDirectoryRecursively(dir_path); // 3. extract the zip