Skip to content

Commit

Permalink
Don't include fmt.h in text_types.h
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Sep 6, 2024
1 parent 958641d commit 7b36b84
Show file tree
Hide file tree
Showing 40 changed files with 85 additions and 39 deletions.
1 change: 1 addition & 0 deletions gframe/Android/COSAndroidOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ static inline int android_get_device_api_level() {
#endif
#include "COSAndroidOperator.h"
#include "porting_android.h"
#include "../fmt.h"

namespace irr {

Expand Down
9 changes: 5 additions & 4 deletions gframe/CGUISkinSystem/CGUISkinSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <string>
#include <set>
#include "../utils.h"
#include "../fmt.h"

using namespace irr;

Expand Down Expand Up @@ -119,7 +120,7 @@ gui::CImageGUISkin* CGUISkinSystem::loadSkinFromFile(const fschar_t *skinname) {
// is to make the registry write out the root node and see what comes out.
//registry->writeFile("Skin",".");

// To switch on the fly, we have to set the skin to the fallback skin first
// To switch on the fly, we have to set the skin to the fallback skin first
tmp = registry->getValueAsCStr(L"skin", L"Skin/Properties/Fallback");
// Always default to metalic
fallbackType = gui::EGST_WINDOWS_METALLIC;
Expand Down Expand Up @@ -156,7 +157,7 @@ gui::CImageGUISkin* CGUISkinSystem::loadSkinFromFile(const fschar_t *skinname) {
skinConfig.CheckBoxColor = registry->getValueAsColor(L"Skin/Global/CheckBoxColor");

// If there was no progress bar colors set, set them in the config to the defaults
// otherwise their 0,0,0,0. This is neccicary for the old klagui.
// otherwise their 0,0,0,0. This is neccicary for the old klagui.

if(skinConfig.ProgressBarFilled.Color == 0)
skinConfig.ProgressBarFilled.Color = video::SColor(255, 255, 0, 0);
Expand Down Expand Up @@ -380,10 +381,10 @@ bool CGUISkinSystem::applySkin(const fschar_t *skinname) {
}
device->getGUIEnvironment()->setSkin(skin);
loaded_skin = skin;
// If we're going to switch skin we need to find all the progress bars and overwrite their colors
// If we're going to switch skin we need to find all the progress bars and overwrite their colors
skin->drop();
registry = nullptr;
//fs->changeWorkingDirectoryTo(oldpath);

return true;
}
}
1 change: 1 addition & 0 deletions gframe/CGUITTFont/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <IMeshSceneNode.h>
#include <unordered_set>
#include <climits>
#include "../fmt.h"
#ifdef YGOPRO_USE_BUNDLED_FONT
extern const char* bundled_font_name;
extern const size_t bundled_font_len;
Expand Down
13 changes: 6 additions & 7 deletions gframe/address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "address.h"
#include "bufferio.h"
#include "config.h"
#include "fmt.h"
#if EDOPRO_ANDROID
#include <netinet/in.h>
#endif
Expand Down Expand Up @@ -42,19 +43,17 @@ void Address::toIn6Addr(in6_addr& sin6_addr) const {
memcpy(sin6_addr.s6_addr, buffer, sizeof(in6_addr::s6_addr));
}

template<>
std::basic_string<char> Address::format() const {
if(family == UNK)
std::string format_address(const Address& address) {
if(address.family == address.UNK)
return "";
char ret[50]{};
if(evutil_inet_ntop(family == INET ? AF_INET : AF_INET6, buffer, ret, sizeof(ret)) == nullptr)
if(evutil_inet_ntop(address.family == address.INET ? AF_INET : AF_INET6, address.buffer, ret, sizeof(ret)) == nullptr)
return "";
return ret;
}

template<>
std::basic_string<wchar_t> Address::format() const {
return BufferIO::DecodeUTF8(format<char>());
std::wstring wformat_address(const Address& address) {
return BufferIO::DecodeUTF8(format_address(address));
}

bool Host::operator==(const Host& other) const {
Expand Down
23 changes: 4 additions & 19 deletions gframe/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <cstdint>
#include <string>
#include "fmt.h"
#include "bufferio.h"
#include "text_types.h"

Expand All @@ -16,6 +15,7 @@ namespace epro {

struct Address {
friend struct Host;
friend std::string format_address(const Address& address);
private:
uint8_t buffer[32]{}; //buffer big enough to store an ipv6
public:
Expand All @@ -30,8 +30,6 @@ struct Address {
AF family;
void setIP4(const uint32_t* ip);
void setIP6(const void* ip);
template<typename T>
std::basic_string<T> format() const;
void toInAddr(in_addr& sin_addr) const;
void toIn6Addr(in6_addr& sin6_addr) const;
};
Expand All @@ -46,22 +44,9 @@ struct Host {
static Host resolve(epro::stringview address, uint16_t port);
};

template<>
std::basic_string<char> Address::format() const;
template<>
std::basic_string<wchar_t> Address::format() const;
}

template<typename T>
struct fmt::formatter<epro::Address, T> {
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx) const { return ctx.begin(); }
std::string format_address(const Address&);
std::wstring wformat_address(const Address&);

template<typename FormatContext>
auto format(const epro::Address& address, FormatContext& ctx) const {
static constexpr auto format_str = CHAR_T_STRINGVIEW(T, "{}");
return format_to(ctx.out(), format_str, address.format<T>());
}
};
}

#endif //ADDRESS_H
1 change: 1 addition & 0 deletions gframe/bufferio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef BUFFERIO_H
#define BUFFERIO_H

#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
Expand Down
1 change: 1 addition & 0 deletions gframe/client_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "data_manager.h"
#include "common.h"
#include "client_card.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/client_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "CGUIImageButton/CGUIImageButton.h"
#include "CGUITTFont/CGUITTFont.h"
#include "custom_skin_enum.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/client_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "utils.h"
#include "porting.h"
#include "game_config.h"
#include "fmt.h"

#define LOCKFILE EPRO_TEXT("./.edopro_lock")
#define UPDATES_FOLDER EPRO_TEXT("./updates/{}")
Expand Down
1 change: 1 addition & 0 deletions gframe/data_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "utils_gui.h"
#include "deck_manager.h"
#include "logging.h"
#include "fmt.h"
#include "utils.h"
#include "windbot.h"
#include "windbot_panel.h"
Expand Down
1 change: 1 addition & 0 deletions gframe/data_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "utils.h"
#include "common.h"
#include "file_stream.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "duelclient.h"
#include "single_mode.h"
#include "client_card.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/deck_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "utils.h"
#include "client_card.h"
#include "file_stream.h"
#include "fmt.h"

namespace ygo {
const CardDataC* DeckManager::GetDummyOrMappedCardData(uint32_t code) const {
Expand Down
1 change: 1 addition & 0 deletions gframe/discord_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "logging.h"
#include "config.h"
#include "server_lobby.h"
#include "fmt.h"
#endif
#include "text_types.h"
#include "discord_wrapper.h"
Expand Down
1 change: 1 addition & 0 deletions gframe/dllinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "config.h"
#include "dllinterface.h"
#include "utils.h"
#include "fmt.h"

#if EDOPRO_WINDOWS
#define CORENAME EPRO_TEXT("ocgcore.dll")
Expand Down
1 change: 1 addition & 0 deletions gframe/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "CGUIImageButton/CGUIImageButton.h"
#include "custom_skin_enum.h"
#include "image_manager.h"
#include "fmt.h"

namespace ygo {
void Game::DrawSelectionLine(const Materials::QuadVertex vec, bool strip, int width, irr::video::SColor color) {
Expand Down
1 change: 1 addition & 0 deletions gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "progressivebuffer.h"
#include "utils.h"
#include "porting.h"
#include "fmt.h"

#define DEFAULT_DUEL_RULE 5
namespace ygo {
Expand Down
1 change: 1 addition & 0 deletions gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "joystick_wrapper.h"
#include "porting.h"
#include "config.h"
#include "fmt.h"

namespace {

Expand Down
27 changes: 26 additions & 1 deletion gframe/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,32 @@ struct fmt::formatter<irr::core::string<CharT, TAlloc>, CharT> {
constexpr auto parse(ParseContext& ctx) { return ctx.begin(); }
template <typename ParseContext>
constexpr auto format(const irr::core::string<CharT, TAlloc>& s, ParseContext& ctx) const {
return format_to(ctx.out(), fmt::basic_string_view{s.data(), s.size()});
return format_to(ctx.out(), basic_string_view{s.data(), s.size()});
}
};

namespace epro {
struct Address;
std::string format_address(const Address&);
std::wstring wformat_address(const Address&);
}

template<typename T>
struct fmt::formatter<epro::Address, T> {
template<typename ParseContext>
constexpr auto parse(ParseContext& ctx) const { return ctx.begin(); }

template<typename FormatContext>
auto format(const epro::Address& address, FormatContext& ctx) const {
static constexpr auto format_str = CHAR_T_STRINGVIEW(T, "{}");
const auto formatted = [&] {
if constexpr(std::is_same_v<T, wchar_t>) {
return wformat_address(address);
} else {
return format_address(address);
}
}();
return format_to(ctx.out(), format_str, formatted);
}
};

Expand Down
1 change: 1 addition & 0 deletions gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "CGUIWindowedTabControl/CGUIWindowedTabControl.h"
#include "file_stream.h"
#include "porting.h"
#include "fmt.h"

#if EDOPRO_ANDROID || EDOPRO_IOS
#include "CGUICustomComboBox/CGUICustomComboBox.h"
Expand Down
1 change: 1 addition & 0 deletions gframe/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "config.h"
#include "logging.h"
#include "file_stream.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/gframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "log.h"
#include "joystick_wrapper.h"
#include "utils_gui.h"
#include "fmt.h"
#if EDOPRO_MACOS
#include "osx_menu.h"
#endif
Expand Down
2 changes: 1 addition & 1 deletion gframe/iOS/COSiOSOperator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#import <UIKit/UIPasteboard.h>
#include <sys/utsname.h>
#include <fmt/format.h>
#include "../bufferio.h"
#include "../text_types.h"
#include "../fmt.h"
#include "COSiOSOperator.h"

namespace irr {
Expand Down
1 change: 1 addition & 0 deletions gframe/image_downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "utils.h"
#include "game_config.h"
#include "file_stream.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/image_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "image_downloader.h"
#include "game.h"
#include "config.h"
#include "fmt.h"

#define BASE_PATH EPRO_TEXT("./textures/")

Expand Down
1 change: 1 addition & 0 deletions gframe/logging.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "logging.h"
#include <ctime>
#include "fmt.h"
#include "file_stream.h"

namespace ygo {
Expand Down
1 change: 1 addition & 0 deletions gframe/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define LOGGING_H

#include "text_types.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/menu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <IGUITable.h>
#include <IGUIWindow.h>
#include "address.h"
#include "fmt.h"

namespace ygo {

Expand Down
1 change: 1 addition & 0 deletions gframe/old_replay_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "duelclient.h"
#include "game.h"
#include "single_mode.h"
#include "fmt.h"

namespace ygo {
bool ReplayMode::ReadReplayResponse() {
Expand Down
1 change: 1 addition & 0 deletions gframe/replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common.h"
#include "utils.h"
#include "file_stream.h"
#include "fmt.h"

namespace ygo {
void Replay::BeginRecord(bool write, epro::path_string name) {
Expand Down
1 change: 1 addition & 0 deletions gframe/repo_cloner.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "repo_cloner.h"

#include "config.h"
#include "fmt.h"
#include "game_config.h"
#include "porting.h"
#include "repo_manager.h"
Expand Down
1 change: 1 addition & 0 deletions gframe/repo_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "logging.h"
#include "utils.h"
#include "libgit2.hpp"
#include "fmt.h"

static constexpr int MAX_HISTORY_LENGTH = 100;
static constexpr int FETCH_OBJECTS_PERCENTAGE = 60;
Expand Down
1 change: 1 addition & 0 deletions gframe/server_lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "custom_skin_enum.h"
#include "game_config.h"
#include "address.h"
#include "fmt.h"

namespace ygo {

Expand Down
Loading

0 comments on commit 7b36b84

Please sign in to comment.