diff --git a/gframe/Android/COSAndroidOperator.cpp b/gframe/Android/COSAndroidOperator.cpp index d0589d065..a102488f5 100644 --- a/gframe/Android/COSAndroidOperator.cpp +++ b/gframe/Android/COSAndroidOperator.cpp @@ -6,7 +6,6 @@ #include #include -#include #include "COSAndroidOperator.h" #include "porting_android.h" @@ -19,7 +18,7 @@ COSAndroidOperator::COSAndroidOperator() { #endif struct utsname LinuxInfo; uname(&LinuxInfo); - const auto verstring = fmt::format("Android version: {} {} {} {} {}", + const auto verstring = epro::format("Android version: {} {} {} {} {}", android_get_device_api_level(), LinuxInfo.sysname, LinuxInfo.release, LinuxInfo.version, LinuxInfo.machine); OperatingSystem = { verstring.data(), (u32)verstring.size() }; } diff --git a/gframe/CGUITTFont/CGUITTFont.cpp b/gframe/CGUITTFont/CGUITTFont.cpp index e458b48bb..1b6205035 100644 --- a/gframe/CGUITTFont/CGUITTFont.cpp +++ b/gframe/CGUITTFont/CGUITTFont.cpp @@ -454,7 +454,7 @@ CGUITTGlyphPage* CGUITTFont::getLastGlyphPage() const { CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode) { // Name of our page. - auto name = fmt::format("TTFontGlyphPage_{}.{}.{}._{}", + auto name = epro::format("TTFontGlyphPage_{}.{}.{}._{}", tt_face->family_name, tt_face->style_name, size, Glyph_Pages.size()); // The newly created page will be at the end of the collection. // Create the new page. diff --git a/gframe/address.cpp b/gframe/address.cpp index 7b6aed952..d7a0ec483 100644 --- a/gframe/address.cpp +++ b/gframe/address.cpp @@ -78,7 +78,7 @@ Host Host::resolve(epro::stringview address, uint16_t port) { hints.ai_flags = EVUTIL_AI_ADDRCONFIG; auto getAddrInfo = [&](auto ai_family) { hints.ai_family = ai_family; - return evutil_getaddrinfo(address.data(), fmt::to_string(port).data(), &hints, &answer) == 0; + return evutil_getaddrinfo(address.data(), epro::to_string(port).data(), &hints, &answer) == 0; }; //Give priority to ipv4 addresses if(getAddrInfo(AF_INET)) { diff --git a/gframe/client_card.cpp b/gframe/client_card.cpp index 6d8a9e2b0..3a314cc6f 100644 --- a/gframe/client_card.cpp +++ b/gframe/client_card.cpp @@ -52,7 +52,7 @@ void ClientCard::UpdateInfo(const CoreUtils::Query& query) { if(attack < 0) { atkstring = L"?"; } else - atkstring = fmt::to_wstring(attack); + atkstring = epro::to_wstring(attack); } } if(query.flag & QUERY_DEFENSE) { @@ -60,7 +60,7 @@ void ClientCard::UpdateInfo(const CoreUtils::Query& query) { if(defense < 0) { defstring = L"?"; } else - defstring = fmt::to_wstring(defense); + defstring = epro::to_wstring(defense); } } /*if(query.flag & QUERY_REASON_CARD) { @@ -100,11 +100,11 @@ void ClientCard::UpdateInfo(const CoreUtils::Query& query) { } if(query.flag & QUERY_LSCALE) { if(IsDifferent(lscale, query.lscale) || lscstring.empty()) - lscstring = fmt::to_wstring(lscale); + lscstring = epro::to_wstring(lscale); } if(query.flag & QUERY_RSCALE) { if(IsDifferent(rscale, query.rscale) || rscstring.empty()) - rscstring = fmt::to_wstring(rscale); + rscstring = epro::to_wstring(rscale); } if(query.flag & QUERY_LINK) { if(IsDifferent(link, query.link) || linkstring.empty()) diff --git a/gframe/client_field.cpp b/gframe/client_field.cpp index e82e7e87a..cc239157d 100644 --- a/gframe/client_field.cpp +++ b/gframe/client_field.cpp @@ -427,7 +427,7 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) { } } else { if(sort_list[i]) { - curstring->setText(fmt::to_wstring(sort_list[i]).data()); + curstring->setText(epro::to_wstring(sort_list[i]).data()); } else curstring->setText(L""); curstring->setBackgroundColor(skin::DUELFIELD_CARD_SELF_WINDOW_BACKGROUND_VAL); diff --git a/gframe/data_manager.cpp b/gframe/data_manager.cpp index ee48e342d..c382efeab 100644 --- a/gframe/data_manager.cpp +++ b/gframe/data_manager.cpp @@ -410,7 +410,7 @@ std::vector DataManager::GetSetCode(const std::vector 7) { mainGame->scrFilter->setVisible(true); diff --git a/gframe/deck_manager.cpp b/gframe/deck_manager.cpp index 93a23bf29..d835dcb2e 100644 --- a/gframe/deck_manager.cpp +++ b/gframe/deck_manager.cpp @@ -419,7 +419,7 @@ bool DeckManager::SaveDeck(epro::path_stringview name, const Deck& deck) { deckfile << "#created by " << BufferIO::EncodeUTF8(mainGame->ebNickName->getText()) << "\n#main\n"; auto serializeDeck = [&deckfile](const auto& deck) { for(auto card : deck) - deckfile << fmt::to_string(card->getRealCode()) << "\n"; + deckfile << epro::to_string(card->getRealCode()) << "\n"; }; serializeDeck(deck.main); deckfile << "#extra\n"; @@ -435,13 +435,13 @@ bool DeckManager::SaveDeck(epro::path_stringview name, const cardlist_type& main return false; deckfile << "#created by " << BufferIO::EncodeUTF8(mainGame->ebNickName->getText()) << "\n#main\n"; for(auto card : mainlist) - deckfile << fmt::to_string(card) << "\n"; + deckfile << epro::to_string(card) << "\n"; deckfile << "#extra\n"; for(auto card : extralist) - deckfile << fmt::to_string(card) << "\n"; + deckfile << epro::to_string(card) << "\n"; deckfile << "!side\n"; for(auto card : sidelist) - deckfile << fmt::to_string(card) << "\n"; + deckfile << epro::to_string(card) << "\n"; return true; } const wchar_t* DeckManager::ExportDeckBase64(const Deck& deck) { diff --git a/gframe/discord_wrapper.cpp b/gframe/discord_wrapper.cpp index 858343181..2bc94b67f 100644 --- a/gframe/discord_wrapper.cpp +++ b/gframe/discord_wrapper.cpp @@ -59,7 +59,7 @@ void DiscordWrapper::UpdatePresence(PresenceType type) { // a->address // p->port // s->password - auto ret = fmt::format_to_n(secret_buf, sizeof(secret_buf) - 1, R"({{"i":{},"a":"{}","p":{},"s":"{}"}})", + auto ret = epro::format_to_n(secret_buf, sizeof(secret_buf) - 1, R"({{"i":{},"a":"{}","p":{},"s":"{}"}})", secret.game_id, secret.host.address, secret.host.port, BufferIO::EncodeUTF8(secret.pass)); *ret.out = '\0'; } diff --git a/gframe/drawing.cpp b/gframe/drawing.cpp index ff2e8395f..97fcba5f7 100644 --- a/gframe/drawing.cpp +++ b/gframe/drawing.cpp @@ -559,7 +559,7 @@ void Game::DrawMisc() { if(lpframe > 0 && delta_frames) { dInfo.lp[lpplayer] -= lpd * delta_frames; - dInfo.strLP[lpplayer] = fmt::to_wstring(std::max(0, dInfo.lp[lpplayer])); + dInfo.strLP[lpplayer] = epro::to_wstring(std::max(0, dInfo.lp[lpplayer])); lpcalpha -= 0x19 * delta_frames; lpframe -= delta_frames; } @@ -1251,7 +1251,7 @@ void Game::DrawDeckBd() { const auto GetDeckSizeStr = [&](const Deck::Vector& deck, const Deck::Vector& pre_deck)->std::wstring { if(is_siding) return epro::format(L"{} ({})", deck.size(), pre_deck.size()); - return fmt::to_wstring(deck.size()); + return epro::to_wstring(deck.size()); }; const auto& current_deck = deckBuilder.GetCurrentDeck(); diff --git a/gframe/duelclient.cpp b/gframe/duelclient.cpp index 4e7b2cda3..6a77638f8 100644 --- a/gframe/duelclient.cpp +++ b/gframe/duelclient.cpp @@ -1667,8 +1667,8 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { mainGame->dInfo.startlp = mainGame->dInfo.lp[mainGame->LocalPlayer(0)]; else mainGame->dInfo.startlp = 8000; - mainGame->dInfo.strLP[0] = fmt::to_wstring(mainGame->dInfo.lp[0]); - mainGame->dInfo.strLP[1] = fmt::to_wstring(mainGame->dInfo.lp[1]); + mainGame->dInfo.strLP[0] = epro::to_wstring(mainGame->dInfo.lp[0]); + mainGame->dInfo.strLP[1] = epro::to_wstring(mainGame->dInfo.lp[1]); uint16_t deckc = BufferIO::Read(pbuf); uint16_t extrac = BufferIO::Read(pbuf); mainGame->dField.Initial(mainGame->LocalPlayer(0), deckc, extrac); @@ -3566,7 +3566,7 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { mainGame->lpcstring = L""; } mainGame->dInfo.lp[player] = final; - mainGame->dInfo.strLP[player] = fmt::to_wstring(mainGame->dInfo.lp[player]); + mainGame->dInfo.strLP[player] = epro::to_wstring(mainGame->dInfo.lp[player]); return true; } case MSG_RECOVER: { @@ -3588,7 +3588,7 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { mainGame->lpcstring = L""; } mainGame->dInfo.lp[player] = final; - mainGame->dInfo.strLP[player] = fmt::to_wstring(mainGame->dInfo.lp[player]); + mainGame->dInfo.strLP[player] = epro::to_wstring(mainGame->dInfo.lp[player]); return true; } case MSG_EQUIP: { @@ -3625,7 +3625,7 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { mainGame->WaitFrameSignal(11, lock); } mainGame->dInfo.lp[player] = val; - mainGame->dInfo.strLP[player] = fmt::to_wstring(mainGame->dInfo.lp[player]); + mainGame->dInfo.strLP[player] = epro::to_wstring(mainGame->dInfo.lp[player]); return true; } case MSG_UNEQUIP: { @@ -3694,7 +3694,7 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { mainGame->lpcstring = L""; } mainGame->dInfo.lp[player] = final; - mainGame->dInfo.strLP[player] = fmt::to_wstring(mainGame->dInfo.lp[player]); + mainGame->dInfo.strLP[player] = epro::to_wstring(mainGame->dInfo.lp[player]); return true; } case MSG_ADD_COUNTER: { @@ -3795,21 +3795,21 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { ClientCard* pcard = mainGame->dField.GetCard(info1.controler, info1.location, info1.sequence); if(aatk != pcard->attack) { pcard->attack = aatk; - pcard->atkstring = fmt::to_wstring(aatk); + pcard->atkstring = epro::to_wstring(aatk); } if(adef != pcard->defense) { pcard->defense = adef; - pcard->defstring = fmt::to_wstring(adef); + pcard->defstring = epro::to_wstring(adef); } if(info2.location) { pcard = mainGame->dField.GetCard(info2.controler, info2.location, info2.sequence); if(datk != pcard->attack) { pcard->attack = datk; - pcard->atkstring = fmt::to_wstring(datk); + pcard->atkstring = epro::to_wstring(datk); } if(ddef != pcard->defense) { pcard->defense = ddef; - pcard->defstring = fmt::to_wstring(ddef); + pcard->defstring = epro::to_wstring(ddef); } } return true; @@ -4142,7 +4142,7 @@ int DuelClient::ClientAnalyze(const uint8_t* msg, uint32_t len) { for(int i = 0; i < 2; ++i) { int p = mainGame->LocalPlayer(i); mainGame->dInfo.lp[p] = BufferIO::Read(pbuf); - mainGame->dInfo.strLP[p] = fmt::to_wstring(mainGame->dInfo.lp[p]); + mainGame->dInfo.strLP[p] = epro::to_wstring(mainGame->dInfo.lp[p]); for(int seq = 0; seq < 7; ++seq) { const auto is_zone_used = !!BufferIO::Read(pbuf); if(!is_zone_used) diff --git a/gframe/event_handler.cpp b/gframe/event_handler.cpp index 45f799a23..c24673e3e 100644 --- a/gframe/event_handler.cpp +++ b/gframe/event_handler.cpp @@ -774,13 +774,13 @@ bool ClientField::OnEvent(const irr::SEvent& event) { if(offset + i >= select_max) break; if(sort_list[offset + i]) { - mainGame->stCardPos[i]->setText(fmt::to_wstring(sort_list[offset + i]).data()); + mainGame->stCardPos[i]->setText(epro::to_wstring(sort_list[offset + i]).data()); } else mainGame->stCardPos[i]->setText(L""); } } else { select_min++; sort_list[sel_seq] = select_min; - mainGame->stCardPos[id - BUTTON_CARD_0]->setText(fmt::to_wstring(select_min).data()); + mainGame->stCardPos[id - BUTTON_CARD_0]->setText(epro::to_wstring(select_min).data()); if(select_min == select_max) { uint8_t respbuf[64]; for(uint32_t i = 0; i < select_max; ++i) @@ -927,7 +927,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { std::wstring text = L""; if(sort_list.size()) { if(sort_list[pos + i] > 0) - text = fmt::to_wstring(sort_list[pos + i]); + text = epro::to_wstring(sort_list[pos + i]); } else { if(conti_selecting) text = std::wstring{ DataManager::unknown_string }; @@ -1907,7 +1907,7 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event, bool& stopPropagation) try { gGameConfig->maxFPS = static_cast(std::stol(mainGame->gSettings.ebFPSCap->getText())); } catch (...) { - mainGame->gSettings.ebFPSCap->setText(fmt::to_wstring(gGameConfig->maxFPS).data()); + mainGame->gSettings.ebFPSCap->setText(epro::to_wstring(gGameConfig->maxFPS).data()); } break; } diff --git a/gframe/fmt.h b/gframe/fmt.h index f42fa992a..e3bf6bd59 100644 --- a/gframe/fmt.h +++ b/gframe/fmt.h @@ -37,6 +37,18 @@ namespace epro { using fmt::format; using fmt::sprintf; using fmt::print; +using fmt::format_to_n; +#if FMT_VERSION >= 60000 +using fmt::to_string; +using fmt::to_wstring; +#else +template inline std::string to_string(const T& value) { + return format("{}", value); +} +template inline std::wstring to_wstring(const T& value) { + return format(L"{}", value); +} +#endif } #endif diff --git a/gframe/game.cpp b/gframe/game.cpp index 8a32f2d55..8b3d60044 100644 --- a/gframe/game.cpp +++ b/gframe/game.cpp @@ -1182,7 +1182,7 @@ void Game::PopulateGameHostWindows() { ReloadCBRule(); cbRule->setSelected(gGameConfig->lastallowedcards); defaultStrings.emplace_back(env->addStaticText(gDataManager->GetSysString(1227).data(), Scale(20, 70, 220, 90), false, false, tDuelSettings), 1227); -#define WStr(i) fmt::to_wstring(i).data() +#define WStr(i) epro::to_wstring(i).data() ebTeam1 = env->addEditBox(WStr(gGameConfig->team1count), Scale(140, 65, 170, 90), true, tDuelSettings, EDITBOX_TEAM_COUNT); ebTeam1->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); auto vsstring = env->addStaticText(gDataManager->GetSysString(1380).data(), Scale(175, 65, 195, 90), false, false, tDuelSettings); @@ -2751,7 +2751,7 @@ void Game::UpdateRepoInfo(const GitRepo* repo, RepoGui* grepo) { grepo->history_button2->setEnabled(true); if(!repo->is_language) { script_dirs.insert(script_dirs.begin(), Utils::ToPathString(repo->script_path)); - auto init_script = fmt::format(EPRO_TEXT("{}{}"), script_dirs.front(), EPRO_TEXT("init.lua")); + auto init_script = epro::format(EPRO_TEXT("{}{}"), script_dirs.front(), EPRO_TEXT("init.lua")); if(Utils::FileExists(init_script)) init_scripts.push_back(std::move(init_script)); auto script_subdirs = Utils::FindSubfolders(Utils::ToPathString(repo->script_path), 2); diff --git a/gframe/game_config.cpp b/gframe/game_config.cpp index 9cd47cbc8..bb72a0e68 100644 --- a/gframe/game_config.cpp +++ b/gframe/game_config.cpp @@ -158,12 +158,12 @@ uint8_t parseOption(std::string& v template std::string serializeOption(const T& value) { - return fmt::to_string(value); + return epro::to_string(value); } template<> std::string serializeOption(const uint8_t& value) { - return fmt::to_string((int)value); + return epro::to_string((int)value); } template<> @@ -173,7 +173,7 @@ std::string serializeOption(const float& value) { template<> std::string serializeOption(const bool& value) { - return fmt::to_string((int)value); + return epro::to_string((int)value); } template<> diff --git a/gframe/menu_handler.cpp b/gframe/menu_handler.cpp index 73b47ab86..a86f09b16 100644 --- a/gframe/menu_handler.cpp +++ b/gframe/menu_handler.cpp @@ -664,8 +664,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { if(sel == -1) break; const auto& selection = DuelClient::hosts[sel]; - mainGame->ebJoinHost->setText(fmt::format(L"{}", selection.address).data()); - mainGame->ebJoinPort->setText(fmt::to_wstring(selection.port).data()); + mainGame->ebJoinHost->setText(epro::to_wstring(selection.address).data()); + mainGame->ebJoinPort->setText(epro::to_wstring(selection.port).data()); break; } case LISTBOX_REPLAY_LIST: { @@ -965,12 +965,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { switch (id) { case COMBOBOX_DUEL_RULE: { auto setDeckSizes = [&](const DeckSizes& size) { - mainGame->ebMainMin->setText(fmt::to_wstring(size.main.min).data()); - mainGame->ebMainMax->setText(fmt::to_wstring(size.main.max).data()); - mainGame->ebExtraMin->setText(fmt::to_wstring(size.extra.min).data()); - mainGame->ebExtraMax->setText(fmt::to_wstring(size.extra.max).data()); - mainGame->ebSideMin->setText(fmt::to_wstring(size.side.min).data()); - mainGame->ebSideMax->setText(fmt::to_wstring(size.side.max).data()); + mainGame->ebMainMin->setText(epro::to_wstring(size.main.min).data()); + mainGame->ebMainMax->setText(epro::to_wstring(size.main.max).data()); + mainGame->ebExtraMin->setText(epro::to_wstring(size.extra.min).data()); + mainGame->ebExtraMax->setText(epro::to_wstring(size.extra.max).data()); + mainGame->ebSideMin->setText(epro::to_wstring(size.side.min).data()); + mainGame->ebSideMax->setText(epro::to_wstring(size.side.max).data()); }; static constexpr DeckSizes ocg_deck_sizes{ {40,60}, {0,15}, {0,15} }; static constexpr DeckSizes rush_deck_sizes{ {40,60}, {0,15}, {0,15} }; diff --git a/gframe/old_replay_mode.cpp b/gframe/old_replay_mode.cpp index c410d64a2..3b6ee650f 100644 --- a/gframe/old_replay_mode.cpp +++ b/gframe/old_replay_mode.cpp @@ -124,7 +124,7 @@ namespace ygo { mainGame->dInfo.lp[0] = start_lp; mainGame->dInfo.lp[1] = start_lp; mainGame->dInfo.startlp = start_lp; - mainGame->dInfo.strLP[0] = fmt::to_wstring(start_lp); + mainGame->dInfo.strLP[0] = epro::to_wstring(start_lp); mainGame->dInfo.strLP[1] = mainGame->dInfo.strLP[0]; mainGame->dInfo.turn = 0; if (!mainGame->dInfo.isSingleMode || (replay_header.base.flag & REPLAY_HAND_TEST)) { diff --git a/gframe/repo_cloner.cpp b/gframe/repo_cloner.cpp index cec898a59..9e5758744 100644 --- a/gframe/repo_cloner.cpp +++ b/gframe/repo_cloner.cpp @@ -106,7 +106,7 @@ int repo_cloner_main(const args_t& args) { } if(should_print) { // prints a json array contaning all the info about the repos being cloned - fmt::print("[{{{}}}]\n", fmt::join(repos_to_clone.begin(), repos_to_clone.end(), "},{")); + epro::print("[{{{}}}]\n", fmt::join(repos_to_clone.begin(), repos_to_clone.end(), "},{")); std::fflush(stdout); } std::this_thread::sleep_for(std::chrono::milliseconds(500)); diff --git a/gframe/single_mode.cpp b/gframe/single_mode.cpp index 6daf3a531..997b63173 100644 --- a/gframe/single_mode.cpp +++ b/gframe/single_mode.cpp @@ -96,7 +96,7 @@ int SingleMode::SinglePlayThread(DuelOptions&& duelOptions) { mainGame->dInfo.compat_mode = false; mainGame->dInfo.legacy_race_size = false; mainGame->dInfo.startlp = mainGame->dInfo.lp[0] = mainGame->dInfo.lp[1] = duelOptions.startingLP; - mainGame->dInfo.strLP[0] = mainGame->dInfo.strLP[1] = fmt::to_wstring(mainGame->dInfo.lp[0]); + mainGame->dInfo.strLP[0] = mainGame->dInfo.strLP[1] = epro::to_wstring(mainGame->dInfo.lp[0]); mainGame->dInfo.selfnames = { mainGame->ebNickName->getText() }; mainGame->dInfo.opponames = { L"" }; mainGame->dInfo.player_type = 0; diff --git a/gframe/windbot.cpp b/gframe/windbot.cpp index e81267220..73890e33c 100644 --- a/gframe/windbot.cpp +++ b/gframe/windbot.cpp @@ -55,11 +55,11 @@ WindBot::launch_ret_t WindBot::Launch(int port, epro::wstringview pass, bool cha nlohmann::json param({ {"HostInfo", BufferIO::EncodeUTF8(pass)}, {"Deck", BufferIO::EncodeUTF8(deck)}, - {"Port", fmt::to_string(port)}, - {"Version", fmt::to_string(version)}, + {"Port", epro::to_string(port)}, + {"Version", epro::to_string(version)}, {"Name", BufferIO::EncodeUTF8(name)}, - {"Chat", fmt::to_string(static_cast(chat))}, - {"Hand", fmt::to_string(hand)} + {"Chat", epro::to_string(static_cast(chat))}, + {"Hand", epro::to_string(hand)} }); if(overridedeck) param["DeckFile"] = BufferIO::EncodeUTF8(overridedeck); diff --git a/gframe/windbot_panel.cpp b/gframe/windbot_panel.cpp index 5a3a52789..de08542fa 100644 --- a/gframe/windbot_panel.cpp +++ b/gframe/windbot_panel.cpp @@ -72,7 +72,7 @@ void WindBotPanel::UpdateDescription() { for (auto rule : bot.masterRules) { if (mr.size()) mr.push_back(L','); - mr.append(fmt::to_wstring(rule)); + mr.append(epro::to_wstring(rule)); } params.append(epro::format(gDataManager->GetSysString(2057), mr)).push_back(L'\n'); }