From d8968750b55003b21a6b033dfe9dba9f3c3627ca Mon Sep 17 00:00:00 2001 From: Chris Feger Date: Fri, 17 May 2024 23:22:56 -0400 Subject: [PATCH] Fix small compilation issues on latest devkitARM --- 3ds/source/app.cpp | 5 ++- 3ds/source/gui/gui.cpp | 20 ++++----- 3ds/source/gui/overlay/ViewOverlay.cpp | 5 ++- 3ds/source/gui/screen/BankSelectionScreen.cpp | 6 +-- 3ds/source/gui/screen/CloudScreen.cpp | 15 ++++--- 3ds/source/gui/screen/ConfigScreen.cpp | 28 +++++-------- 3ds/source/gui/screen/EditSelectorScreen.cpp | 6 +-- 3ds/source/gui/screen/GroupCloudScreen.cpp | 15 ++++--- 3ds/source/gui/screen/HexEditScreen.cpp | 31 ++++++-------- 3ds/source/gui/screen/MainMenu.cpp | 25 ++++++----- 3ds/source/gui/screen/StorageScreen.cpp | 12 +++--- 3ds/source/gui/scripts/BankChoice.cpp | 6 +-- 3ds/source/picoc/pksm_api.cpp | 38 ++++++++--------- 3ds/source/utils/pksmbridge.cpp | 6 +-- common/include/utils/format.hpp | 42 +++++++++++++++++++ common/source/picoc/library_pksm.c | 2 +- common/source/utils/fetch.cpp | 1 + core | 2 +- 18 files changed, 146 insertions(+), 119 deletions(-) create mode 100644 common/include/utils/format.hpp diff --git a/3ds/source/app.cpp b/3ds/source/app.cpp index 49f72581..df16228b 100644 --- a/3ds/source/app.cpp +++ b/3ds/source/app.cpp @@ -43,6 +43,7 @@ #include "thread.hpp" #include "TitleLoadScreen.hpp" #include "utils/crypto.hpp" +#include "utils/format.hpp" #include "website.h" #include <3ds.h> #include @@ -818,8 +819,8 @@ namespace while (filesDone != filesToDownload) { - Gui::waitFrame(std::vformat(i18n::localize("MYSTERY_GIFT_DOWNLOAD"), - std::make_format_args((size_t)filesDone, filesToDownload))); + Gui::waitFrame(pksm::format( + i18n::localize("MYSTERY_GIFT_DOWNLOAD"), (size_t)filesDone, filesToDownload)); svcSleepThread(50'000'000); } diff --git a/3ds/source/gui/gui.cpp b/3ds/source/gui/gui.cpp index ed66b331..146c2df3 100644 --- a/3ds/source/gui/gui.cpp +++ b/3ds/source/gui/gui.cpp @@ -33,8 +33,7 @@ #include "pkx/PKX.hpp" #include "sound.hpp" #include "TextParse.hpp" -#include "thread.hpp" -#include +#include "utils/format.hpp" #include namespace @@ -2041,8 +2040,8 @@ void Gui::showRestoreProgress(u32 partial, u32 total) sprite(ui_sheet_part_info_top_idx, 0, 0); text(i18n::localize("SAVING"), 200, 95, FONT_SIZE_15, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); - text(std::vformat(i18n::localize("SAVE_PROGRESS"), std::make_format_args(partial, total)), 200, - 130, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); + text(pksm::format(i18n::localize("SAVE_PROGRESS"), partial, total), 200, 130, FONT_SIZE_12, + COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); flushText(); target(GFX_BOTTOM); @@ -2070,10 +2069,10 @@ void Gui::showDownloadProgress(const std::string& path, u32 partial, u32 total) Gui::clearScreen(GFX_BOTTOM); target(GFX_TOP); sprite(ui_sheet_part_info_top_idx, 0, 0); - text(std::vformat(i18n::localize("DOWNLOADING_FILE"), std::make_format_args(path)), 200, 95, - FONT_SIZE_15, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); - text(std::vformat(i18n::localize("SAVE_PROGRESS"), std::make_format_args(partial, total)), 200, - 130, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); + text(pksm::format(i18n::localize("DOWNLOADING_FILE"), path), 200, 95, FONT_SIZE_15, COLOR_WHITE, + TextPosX::CENTER, TextPosY::TOP); + text(pksm::format(i18n::localize("SAVE_PROGRESS"), partial, total), 200, 130, FONT_SIZE_12, + COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); flushText(); target(GFX_BOTTOM); @@ -2138,9 +2137,8 @@ void Gui::error(const std::string& message, Result errorCode) u8 transparency = transparencyWaver(); text(message, 200, 85, FONT_SIZE_15, PKSM_Color(255, 255, 255, transparency), TextPosX::CENTER, TextPosY::TOP); - text(std::vformat(i18n::localize("ERROR_CODE"), std::make_format_args((u32)errorCode)), 200, - 105, FONT_SIZE_15, PKSM_Color(255, 255, 255, transparency), TextPosX::CENTER, - TextPosY::TOP); + text(pksm::format(i18n::localize("ERROR_CODE"), (u32)errorCode), 200, 105, FONT_SIZE_15, + PKSM_Color(255, 255, 255, transparency), TextPosX::CENTER, TextPosY::TOP); text(i18n::localize("CONTINUE"), 200, 130, FONT_SIZE_11, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); diff --git a/3ds/source/gui/overlay/ViewOverlay.cpp b/3ds/source/gui/overlay/ViewOverlay.cpp index 26554e87..2d8f8155 100644 --- a/3ds/source/gui/overlay/ViewOverlay.cpp +++ b/3ds/source/gui/overlay/ViewOverlay.cpp @@ -32,6 +32,7 @@ #include "pkx/PK1.hpp" #include "pkx/PK2.hpp" #include "pkx/PK3.hpp" +#include "utils/format.hpp" #include namespace @@ -226,8 +227,8 @@ void ViewOverlay::drawPkm(pksm::PKX& pkm) const case pksm::Gender::INVALID: break; } - Gui::text(std::vformat(i18n::localize("LVL"), std::make_format_args(pkm.level())), 143, 10, - FONT_SIZE_9, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); + Gui::text(pksm::format(i18n::localize("LVL"), pkm.level()), 143, 10, FONT_SIZE_9, COLOR_WHITE, + TextPosX::LEFT, TextPosY::TOP); if (pkm.shiny()) { Gui::sprite(ui_sheet_icon_shiny_idx, 191, 5); diff --git a/3ds/source/gui/screen/BankSelectionScreen.cpp b/3ds/source/gui/screen/BankSelectionScreen.cpp index 5de89ea2..dbac9205 100644 --- a/3ds/source/gui/screen/BankSelectionScreen.cpp +++ b/3ds/source/gui/screen/BankSelectionScreen.cpp @@ -29,8 +29,8 @@ #include "Configuration.hpp" #include "gui.hpp" #include "i18n_ext.hpp" +#include "utils/format.hpp" #include -#include BankSelectionScreen::BankSelectionScreen(int& storageBox) : hid(40, 2), strings(Banks::bankNames()), storageBox(storageBox) @@ -129,8 +129,8 @@ void BankSelectionScreen::update(touchPosition* touch) } if (strings.size() > 2) { - if (Gui::showChoiceMessage(std::vformat(i18n::localize("BANK_DELETE"), - std::make_format_args(strings[hid.fullIndex()].first)))) + if (Gui::showChoiceMessage( + pksm::format(i18n::localize("BANK_DELETE"), strings[hid.fullIndex()].first))) { auto i = strings.begin() + hid.fullIndex(); Banks::removeBank(i->first); diff --git a/3ds/source/gui/screen/CloudScreen.cpp b/3ds/source/gui/screen/CloudScreen.cpp index d3b08523..09bcfcfb 100644 --- a/3ds/source/gui/screen/CloudScreen.cpp +++ b/3ds/source/gui/screen/CloudScreen.cpp @@ -45,6 +45,7 @@ #include "QRScanner.hpp" #include "revision.h" #include "sav/Sav.hpp" +#include "utils/format.hpp" #include "website.h" #include #include @@ -208,8 +209,8 @@ void CloudScreen::drawTop() const "\uE004", 45 + 24 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); Gui::text( "\uE005", 225 + 24 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("CLOUD_BOX"), std::make_format_args(access.page())), - 69 + 156 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); + Gui::text(pksm::format(i18n::localize("CLOUD_BOX"), access.page()), 69 + 156 / 2, 24, + FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); Gui::sprite(ui_sheet_storagemenu_cross_idx, 36, 50); Gui::sprite(ui_sheet_storagemenu_cross_idx, 246, 50); @@ -344,8 +345,8 @@ void CloudScreen::update(touchPosition* touch) { if (access.currentPageError() != 0) { - Gui::warn(std::vformat(i18n::localize("GPSS_COMMUNICATION_ERROR"), - std::make_format_args(access.currentPageError()))); + Gui::warn(pksm::format( + i18n::localize("GPSS_COMMUNICATION_ERROR"), access.currentPageError())); } else { @@ -644,8 +645,7 @@ bool CloudScreen::prevBoxTop() { if (*err != 0) { - Gui::warn(std::vformat( - i18n::localize("GPSS_COMMUNICATION_ERROR"), std::make_format_args(*err))); + Gui::warn(pksm::format(i18n::localize("GPSS_COMMUNICATION_ERROR"), *err)); } else { @@ -680,8 +680,7 @@ bool CloudScreen::nextBoxTop() { if (*err != 0) { - Gui::warn(std::vformat( - i18n::localize("GPSS_COMMUNICATION_ERROR"), std::make_format_args(*err))); + Gui::warn(pksm::format(i18n::localize("GPSS_COMMUNICATION_ERROR"), *err)); } else { diff --git a/3ds/source/gui/screen/ConfigScreen.cpp b/3ds/source/gui/screen/ConfigScreen.cpp index 78425fcf..2baaee92 100644 --- a/3ds/source/gui/screen/ConfigScreen.cpp +++ b/3ds/source/gui/screen/ConfigScreen.cpp @@ -41,6 +41,7 @@ #include "thread.hpp" #include "TitleIdOverlay.hpp" #include "ToggleButton.hpp" +#include "utils/format.hpp" #include namespace @@ -654,32 +655,23 @@ void ConfigScreen::drawBottom() const } else if (currentTab == 1) { - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::ONE)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::ONE), 19, 30, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::TWO)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::TWO), 19, 46, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::THREE)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::THREE), 19, 62, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::FOUR)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::FOUR), 19, 78, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::FIVE)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::FIVE), 19, 94, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::SIX)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::SIX), 19, 110, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::SEVEN)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::SEVEN), 19, 126, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::LGPE)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::LGPE), 19, 142, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)pksm::Generation::EIGHT)), + Gui::text(pksm::format(i18n::localize("GENERATION"), (std::string)pksm::Generation::EIGHT), 19, 158, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); Gui::text(i18n::localize("DAY"), 19, 174, FONT_SIZE_12, COLOR_WHITE, TextPosX::LEFT, TextPosY::TOP); diff --git a/3ds/source/gui/screen/EditSelectorScreen.cpp b/3ds/source/gui/screen/EditSelectorScreen.cpp index 9ff35f21..8c22d912 100644 --- a/3ds/source/gui/screen/EditSelectorScreen.cpp +++ b/3ds/source/gui/screen/EditSelectorScreen.cpp @@ -40,6 +40,7 @@ #include "pkx/PK8.hpp" #include "QRScanner.hpp" #include "sav/SavLGPE.hpp" +#include "utils/format.hpp" #include "ViewOverlay.hpp" #include #include @@ -410,9 +411,8 @@ void EditSelectorScreen::drawBottom() const if (infoMon) { - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(infoMon->formatTID(), infoMon->formatSID(), infoMon->TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), infoMon->formatTID(), + infoMon->formatSID(), infoMon->TSV()), 160, 224, FONT_SIZE_9, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); } diff --git a/3ds/source/gui/screen/GroupCloudScreen.cpp b/3ds/source/gui/screen/GroupCloudScreen.cpp index b3d3a774..3e58c26a 100644 --- a/3ds/source/gui/screen/GroupCloudScreen.cpp +++ b/3ds/source/gui/screen/GroupCloudScreen.cpp @@ -43,6 +43,7 @@ #include "pkx/PKFilter.hpp" #include "QRScanner.hpp" #include "sav/Sav.hpp" +#include "utils/format.hpp" #include "website.h" #include #include @@ -221,8 +222,8 @@ void GroupCloudScreen::drawTop() const "\uE004", 45 + 24 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); Gui::text( "\uE005", 225 + 24 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); - Gui::text(std::vformat(i18n::localize("CLOUD_BOX"), std::make_format_args(access.page())), - 69 + 156 / 2, 24, FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); + Gui::text(pksm::format(i18n::localize("CLOUD_BOX"), access.page()), 69 + 156 / 2, 24, + FONT_SIZE_14, COLOR_BLACK, TextPosX::CENTER, TextPosY::TOP); Gui::sprite(ui_sheet_storagemenu_cross_idx, 36, 50); Gui::sprite(ui_sheet_storagemenu_cross_idx, 246, 50); @@ -364,8 +365,8 @@ void GroupCloudScreen::update(touchPosition* touch) { if (access.currentPageError() != 0) { - Gui::warn(std::vformat(i18n::localize("GPSS_COMMUNICATION_ERROR"), - std::make_format_args(access.currentPageError()))); + Gui::warn(pksm::format( + i18n::localize("GPSS_COMMUNICATION_ERROR"), access.currentPageError())); } else { @@ -647,8 +648,7 @@ bool GroupCloudScreen::prevBoxTop() { if (*err != 0) { - Gui::warn(std::vformat( - i18n::localize("GPSS_COMMUNICATION_ERROR"), std::make_format_args(*err))); + Gui::warn(pksm::format(i18n::localize("GPSS_COMMUNICATION_ERROR"), *err)); } else { @@ -683,8 +683,7 @@ bool GroupCloudScreen::nextBoxTop() { if (*err != 0) { - Gui::warn(std::vformat( - i18n::localize("GPSS_COMMUNICATION_ERROR"), std::make_format_args(*err))); + Gui::warn(pksm::format(i18n::localize("GPSS_COMMUNICATION_ERROR"), *err)); } else { diff --git a/3ds/source/gui/screen/HexEditScreen.cpp b/3ds/source/gui/screen/HexEditScreen.cpp index afb2fae4..8727c051 100644 --- a/3ds/source/gui/screen/HexEditScreen.cpp +++ b/3ds/source/gui/screen/HexEditScreen.cpp @@ -38,6 +38,7 @@ #include "pkx/PK6.hpp" #include "pkx/PK7.hpp" #include "sav/Sav.hpp" +#include "utils/format.hpp" #include namespace @@ -2684,9 +2685,8 @@ void HexEditScreen::drawMeaning() const 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0xF ... 0x10: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; } @@ -2710,9 +2710,8 @@ void HexEditScreen::drawMeaning() const 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x9: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x21: @@ -2725,9 +2724,8 @@ void HexEditScreen::drawMeaning() const switch (i) { case 0x4 ... 0x7: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x8 ... 0x11: @@ -2777,9 +2775,8 @@ void HexEditScreen::drawMeaning() const 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0xC ... 0xF: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x15: @@ -2837,9 +2834,8 @@ void HexEditScreen::drawMeaning() const 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0xC ... 0xF: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x14: @@ -2986,9 +2982,8 @@ void HexEditScreen::drawMeaning() const 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0xC ... 0xF: - Gui::text( - std::vformat(i18n::localize("EDITOR_IDS"), - std::make_format_args(pkm.formatTID(), pkm.formatSID(), pkm.TSV())), + Gui::text(pksm::format(i18n::localize("EDITOR_IDS"), pkm.formatTID(), + pkm.formatSID(), pkm.TSV()), 160, 100, FONT_SIZE_12, COLOR_WHITE, TextPosX::CENTER, TextPosY::TOP); break; case 0x14 ... 0x15: diff --git a/3ds/source/gui/screen/MainMenu.cpp b/3ds/source/gui/screen/MainMenu.cpp index bcb490aa..f0f92568 100644 --- a/3ds/source/gui/screen/MainMenu.cpp +++ b/3ds/source/gui/screen/MainMenu.cpp @@ -39,6 +39,7 @@ #include "ScriptScreen.hpp" #include "StorageScreen.hpp" #include "utils/crypto.hpp" +#include "utils/format.hpp" #include namespace @@ -205,13 +206,12 @@ void MainMenu::drawTop() const switch (i) { case 0: - Gui::text(std::vformat(i18n::localize("GENERATION"), - std::make_format_args((std::string)TitleLoader::save->generation())), + Gui::text(pksm::format(i18n::localize("GENERATION"), + (std::string)TitleLoader::save->generation()), 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 1: - Gui::text(std::vformat(i18n::localize("TRAINER_NAME"), - std::make_format_args(TitleLoader::save->otName())), + Gui::text(pksm::format(i18n::localize("TRAINER_NAME"), TitleLoader::save->otName()), 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 2: @@ -221,26 +221,25 @@ void MainMenu::drawTop() const 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 3: - Gui::text(std::vformat(TitleLoader::save->generation() == pksm::Generation::SEVEN + Gui::text(pksm::format(TitleLoader::save->generation() == pksm::Generation::SEVEN ? i18n::localize("STAMPS") : i18n::localize("BADGES"), - std::make_format_args(TitleLoader::save->badges())), + TitleLoader::save->badges()), 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 4: - Gui::text(std::vformat(i18n::localize("WC_NUM"), - std::make_format_args(TitleLoader::save->currentGiftAmount())), + Gui::text( + pksm::format(i18n::localize("WC_NUM"), TitleLoader::save->currentGiftAmount()), 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 5: - Gui::text(std::vformat(i18n::localize("DEX_SEEN"), - std::make_format_args(TitleLoader::save->dexSeen())), + Gui::text(pksm::format(i18n::localize("DEX_SEEN"), TitleLoader::save->dexSeen()), 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; case 6: - Gui::text(std::vformat(i18n::localize("DEX_CAUGHT"), - std::make_format_args(TitleLoader::save->dexCaught())), - 10, y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); + Gui::text( + pksm::format(i18n::localize("DEX_CAUGHT"), TitleLoader::save->dexCaught()), 10, + y, FONT_SIZE_12, COLOR_BLACK, TextPosX::LEFT, TextPosY::TOP); break; default: break; diff --git a/3ds/source/gui/screen/StorageScreen.cpp b/3ds/source/gui/screen/StorageScreen.cpp index 177cbeb6..d354c873 100644 --- a/3ds/source/gui/screen/StorageScreen.cpp +++ b/3ds/source/gui/screen/StorageScreen.cpp @@ -45,6 +45,7 @@ #include "StorageOverlay.hpp" #include "StorageViewOverlay.hpp" #include "TitleLoadScreen.hpp" +#include "utils/format.hpp" #include #include #include @@ -1311,9 +1312,8 @@ void StorageScreen::putDownSwap() bankMon = TitleLoader::save->transfer(*bankMon); if (!bankMon) { - Gui::warn(std::vformat(i18n::localize("NO_TRANSFER_PATH_SINGLE"), - std::make_format_args( - (std::string)origGen, (std::string)TitleLoader::save->generation()))); + Gui::warn(pksm::format(i18n::localize("NO_TRANSFER_PATH_SINGLE"), (std::string)origGen, + (std::string)TitleLoader::save->generation())); return; } if (bankMon->species() == pksm::Species::None || @@ -1419,9 +1419,9 @@ void StorageScreen::putDownNonSwap() { if (moveMon.size() == 1) { - Gui::warn(std::vformat(i18n::localize("NO_TRANSFER_PATH_SINGLE"), - std::make_format_args((std::string)moveMon[index]->generation(), - (std::string)TitleLoader::save->generation()))); + Gui::warn(pksm::format(i18n::localize("NO_TRANSFER_PATH_SINGLE"), + (std::string)moveMon[index]->generation(), + (std::string)TitleLoader::save->generation())); } continue; } diff --git a/3ds/source/gui/scripts/BankChoice.cpp b/3ds/source/gui/scripts/BankChoice.cpp index d2e6dbd3..faa0bc49 100644 --- a/3ds/source/gui/scripts/BankChoice.cpp +++ b/3ds/source/gui/scripts/BankChoice.cpp @@ -28,8 +28,8 @@ #include "banks.hpp" #include "Configuration.hpp" #include "gui.hpp" +#include "utils/format.hpp" #include -#include BankChoice::BankChoice() : RunnableScreen(nullptr), hid(40, 2), strings(Banks::bankNames()) { @@ -119,8 +119,8 @@ void BankChoice::update(touchPosition* touch) } if (strings.size() > 2) { - if (Gui::showChoiceMessage(std::vformat(i18n::localize("BANK_DELETE"), - std::make_format_args(strings[hid.fullIndex()].first)))) + if (Gui::showChoiceMessage( + pksm::format(i18n::localize("BANK_DELETE"), strings[hid.fullIndex()].first))) { auto i = strings.begin() + hid.fullIndex(); Banks::removeBank(i->first); diff --git a/3ds/source/picoc/pksm_api.cpp b/3ds/source/picoc/pksm_api.cpp index 793ceb14..ebc45019 100644 --- a/3ds/source/picoc/pksm_api.cpp +++ b/3ds/source/picoc/pksm_api.cpp @@ -52,6 +52,7 @@ #include "STDirectory.hpp" #include "ThirtyChoice.hpp" #include "utils/flagUtil.hpp" +#include "utils/format.hpp" #include "utils/genToPkx.hpp" #include "utils/random.hpp" #include "utils/utils.hpp" @@ -425,9 +426,8 @@ void sav_inject_pkx( pkm = TitleLoader::save->transfer(*pkm); if (!pkm) { - Gui::warn(std::vformat(i18n::localize("NO_TRANSFER_PATH_SINGLE"), - std::make_format_args( - (std::string)gen, (std::string)TitleLoader::save->generation()))); + Gui::warn(pksm::format(i18n::localize("NO_TRANSFER_PATH_SINGLE"), (std::string)gen, + (std::string)TitleLoader::save->generation())); return; } auto invalidReason = TitleLoader::save->invalidTransferReason(*pkm); @@ -855,9 +855,8 @@ void party_inject_pkx( pkm = TitleLoader::save->transfer(*pkm); if (!pkm) { - Gui::warn(std::vformat(i18n::localize("NO_TRANSFER_PATH_SINGLE"), - std::make_format_args( - (std::string)gen, (std::string)TitleLoader::save->generation()))); + Gui::warn(pksm::format(i18n::localize("NO_TRANSFER_PATH_SINGLE"), (std::string)gen, + (std::string)TitleLoader::save->generation())); return; } auto invalidReason = TitleLoader::save->invalidTransferReason(*pkm); @@ -2166,18 +2165,19 @@ void pkx_ribbon_exists( struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) { pksm::Generation gen = pksm::Generation(Param[0]->Val->Integer); - pksm::Ribbon ribbon = pksm::Ribbon(Param[1]->Val->Integer); + pksm::Ribbon ribbon = pksm::Ribbon(Param[1]->Val->Integer); checkGen(Parser, gen); ReturnValue->Val->Integer = PkmUtils::getDefault(gen)->hasRibbon(ribbon) ? 1 : 0; } -void pkx_get_ribbon(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) +void pkx_get_ribbon( + struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) { - u8* data = (u8*)Param[0]->Val->Pointer; + u8* data = (u8*)Param[0]->Val->Pointer; pksm::Generation gen = pksm::Generation(Param[1]->Val->Integer); - pksm::Ribbon ribbon = pksm::Ribbon(Param[2]->Val->Integer); + pksm::Ribbon ribbon = pksm::Ribbon(Param[2]->Val->Integer); checkGen(Parser, gen); @@ -2186,12 +2186,13 @@ void pkx_get_ribbon(struct ParseState* Parser, struct Value* ReturnValue, struct ReturnValue->Val->Integer = pkm->ribbon(ribbon) ? 1 : 0; } -void pkx_set_ribbon(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) +void pkx_set_ribbon( + struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) { - u8* data = (u8*)Param[0]->Val->Pointer; + u8* data = (u8*)Param[0]->Val->Pointer; pksm::Generation gen = pksm::Generation(Param[1]->Val->Integer); - pksm::Ribbon ribbon = pksm::Ribbon(Param[2]->Val->Integer); - int shouldHave = Param[3]->Val->Integer; + pksm::Ribbon ribbon = pksm::Ribbon(Param[2]->Val->Integer); + int shouldHave = Param[3]->Val->Integer; checkGen(Parser, gen); @@ -2210,7 +2211,7 @@ void sav_get_palpark( { Gui::warn("PalPark is only in Gen 4"); ReturnValue->Val->Integer = 0; - *outSize = 0; + *outSize = 0; return; } @@ -2221,7 +2222,7 @@ void sav_get_palpark( { Gui::warn("No PalPark Pokemon Stored"); ReturnValue->Val->Integer = 0; - *outSize = 0; + *outSize = 0; return; } @@ -2282,9 +2283,8 @@ void sav_set_palpark( { if (!mons[i]) { - Gui::warn(std::vformat(i18n::localize("NO_TRANSFER_PATH_SINGLE"), - std::make_format_args( - (std::string)generations[i], (std::string)TitleLoader::save->generation()))); + Gui::warn(pksm::format(i18n::localize("NO_TRANSFER_PATH_SINGLE"), + (std::string)generations[i], (std::string)TitleLoader::save->generation())); ReturnValue->Val->Integer = 0; return; } diff --git a/3ds/source/utils/pksmbridge.cpp b/3ds/source/utils/pksmbridge.cpp index f515f9fe..67a476f1 100644 --- a/3ds/source/utils/pksmbridge.cpp +++ b/3ds/source/utils/pksmbridge.cpp @@ -33,6 +33,7 @@ #include "printerator.hpp" #include "Sav.hpp" #include "TitleLoadScreen.hpp" +#include "utils/format.hpp" #include #include #include @@ -62,9 +63,8 @@ void setLoadedSaveFromBridge(bool v) bool receiveSaveFromBridge(void) { - if (!Gui::showChoiceMessage( - i18n::localize("WIRELESS_WARNING") + '\n' + - std::vformat(i18n::localize("WIRELESS_IP"), std::make_format_args(getHostId())))) + if (!Gui::showChoiceMessage(i18n::localize("WIRELESS_WARNING") + '\n' + + pksm::format(i18n::localize("WIRELESS_IP"), getHostId()))) { return false; } diff --git a/common/include/utils/format.hpp b/common/include/utils/format.hpp new file mode 100644 index 00000000..3fa091d2 --- /dev/null +++ b/common/include/utils/format.hpp @@ -0,0 +1,42 @@ +/* + * This file is part of PKSM + * Copyright (C) 2016-2022 Bernardo Giordano, Admiral Fish, piepie62, Allen Lydiard + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Additional Terms 7.b and 7.c of GPLv3 apply to this file: + * * Requiring preservation of specified reasonable legal notices or + * author attributions in that material or in the Appropriate Legal + * Notices displayed by works containing it. + * * Prohibiting misrepresentation of the origin of that material, + * or requiring that modified versions of such material be marked in + * reasonable ways as different from the original version. + */ + +#ifndef FORMAT_HPP +#define FORMAT_HPP + +#include +#include + +namespace pksm +{ + template + std::string format(std::string_view fmt, const Ts&... args) + { + return std::vformat(fmt, std::make_format_args(args...)); + } +} + +#endif diff --git a/common/source/picoc/library_pksm.c b/common/source/picoc/library_pksm.c index ed7036c4..8227084c 100644 --- a/common/source/picoc/library_pksm.c +++ b/common/source/picoc/library_pksm.c @@ -49,7 +49,7 @@ struct LibraryFunction UnixFunctions[] = { sav_get_string, "char* sav_get_string(int off1, int off2, unsigned int codepoints);" }, { sav_set_string, "void sav_set_string(char* string, int off1, int off2, unsigned int codepoints);" }, { sav_get_palpark, "int sav_get_palpark(char** out, int* outSize);" }, - { sav_set_palpark, "int sav_set_palpark(char** data, enum Generation* gen, int inSize);" }, + { sav_set_palpark, "int sav_set_palpark(char** data, enum Generation* gens, int inSize);" }, // pkm { pkx_encrypt, "void pkx_decrypt(char* data, enum Generation type, int isParty);" }, { pkx_decrypt, "void pkx_encrypt(char* data, enum Generation type, int isParty);" }, diff --git a/common/source/utils/fetch.cpp b/common/source/utils/fetch.cpp index c4674359..61d12919 100644 --- a/common/source/utils/fetch.cpp +++ b/common/source/utils/fetch.cpp @@ -26,6 +26,7 @@ #include "fetch.hpp" #include "thread.hpp" +#include #include #include #include diff --git a/core b/core index 74eb4c7a..0e90fb11 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 74eb4c7a6577cb16d3626bdc3878d552dd4a14db +Subproject commit 0e90fb11eb600611dc688c716b055fdcb2a83f1e