diff --git a/CMakeLists.txt b/CMakeLists.txt index a5749acb..9dc1a6f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,7 +134,7 @@ find_package(ZLIB REQUIRED) find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED) find_package(glm REQUIRED) -find_package(fmt 9.1.0...<10 REQUIRED) +find_package(fmt 9 REQUIRED) find_package(PNG REQUIRED) # glslang versions older than 11.11.0 define targets without a namespace diff --git a/src/Cafe/CafeSystem.cpp b/src/Cafe/CafeSystem.cpp index 668def01..a3f42791 100644 --- a/src/Cafe/CafeSystem.cpp +++ b/src/Cafe/CafeSystem.cpp @@ -251,7 +251,7 @@ void InfoLog_PrintActiveSettings() if(!GetConfig().vk_accurate_barriers.GetValue()) cemuLog_log(LogType::Force, "Accurate barriers are disabled!"); } - cemuLog_log(LogType::Force, "Console language: {}", config.console_language); + cemuLog_log(LogType::Force, "Console language: {}", stdx::to_underlying(config.console_language.GetValue())); } struct SharedDataEntry diff --git a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp index 486b7bf5..334b4855 100644 --- a/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp +++ b/src/Cafe/HW/Latte/LegacyShaderDecompiler/LatteDecompilerEmitGLSL.cpp @@ -908,6 +908,11 @@ void _emitOperandInputCode(LatteDecompilerShaderContext* shaderContext, LatteDec { char floatAsStr[32]; size_t floatAsStrLen = fmt::format_to_n(floatAsStr, 32, "{:#}", *(float*)&constVal).size; + if(floatAsStrLen > 0 && floatAsStr[floatAsStrLen-1] == '.') + { + floatAsStr[floatAsStrLen] = '0'; + floatAsStrLen++; + } cemu_assert_debug(floatAsStrLen >= 3); // shortest possible form is "0.0" src->add(std::string_view(floatAsStr, floatAsStrLen)); } diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 8983c847..7d6499fe 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -70,21 +70,6 @@ bool cemuLog_log(LogType type, std::string_view text); bool cemuLog_log(LogType type, std::u8string_view text); void cemuLog_waitForFlush(); // wait until all log lines are written -template -auto ForwardEnum(T t) -{ - if constexpr (std::is_enum_v) - return fmt::underlying(t); - else - return std::forward(t); -} - -template -auto ForwardEnum(std::tuple t) -{ - return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t); -} - template bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) { @@ -98,7 +83,7 @@ bool cemuLog_log(LogType type, std::basic_string formatStr, TArgs&&... args) else { const auto format_view = fmt::basic_string_view(formatStr); - const auto text = fmt::vformat(format_view, fmt::make_format_args>(ForwardEnum(args)...)); + const auto text = fmt::vformat(format_view, fmt::make_format_args>(args...)); cemuLog_log(type, std::basic_string_view(text.data(), text.size())); } return true; diff --git a/src/Common/MemPtr.h b/src/Common/MemPtr.h index dc1ecd36..de787cc1 100644 --- a/src/Common/MemPtr.h +++ b/src/Common/MemPtr.h @@ -159,5 +159,5 @@ template struct fmt::formatter> : formatter { template - auto format(const MEMPTR& v, FormatContext& ctx) { return formatter::format(fmt::format("{:#x}", v.GetMPTR()), ctx); } + auto format(const MEMPTR& v, FormatContext& ctx) const -> format_context::iterator { return fmt::format_to(ctx.out(), "{:#x}", v.GetMPTR()); } }; diff --git a/src/Common/precompiled.h b/src/Common/precompiled.h index c55314d5..790a001a 100644 --- a/src/Common/precompiled.h +++ b/src/Common/precompiled.h @@ -552,6 +552,29 @@ inline uint32 GetTitleIdLow(uint64 titleId) #include "Cafe/HW/Espresso/PPCState.h" #include "Cafe/HW/Espresso/PPCCallback.h" +// generic formatter for enums (to underlying) +template + requires std::is_enum_v +struct fmt::formatter : fmt::formatter> +{ + auto format(const Enum& e, format_context& ctx) const + { + //return fmt::format_to(ctx.out(), "{}", fmt::underlying(e)); + + return formatter>::format(fmt::underlying(e), ctx); + } +}; + +// formatter for betype +template +struct fmt::formatter> : fmt::formatter +{ + auto format(const betype& e, format_context& ctx) const + { + return formatter::format(static_cast(e), ctx); + } +}; + // useful C++23 stuff that isn't yet widely supported // std::to_underlying @@ -561,5 +584,4 @@ namespace stdx constexpr std::underlying_type_t to_underlying(EnumT e) noexcept { return static_cast>(e); }; -} - +} \ No newline at end of file diff --git a/src/config/ConfigValue.h b/src/config/ConfigValue.h index 358af67a..43e2ad3b 100644 --- a/src/config/ConfigValue.h +++ b/src/config/ConfigValue.h @@ -232,19 +232,3 @@ private: const TType m_min_value; const TType m_max_value; }; - -template -struct fmt::formatter< ConfigValue > : formatter { - template - auto format(const ConfigValue& v, FormatContext& ctx) { - return formatter::format(v.GetValue(), ctx); - } -}; - -template -struct fmt::formatter< ConfigValueBounds > : formatter { - template - auto format(const ConfigValueBounds& v, FormatContext& ctx) { - return formatter::format(v.GetValue(), ctx); - } -}; \ No newline at end of file diff --git a/src/config/XMLConfig.h b/src/config/XMLConfig.h index 788dc9a7..2a32dc56 100644 --- a/src/config/XMLConfig.h +++ b/src/config/XMLConfig.h @@ -235,6 +235,12 @@ public: set(name, value.load()); } + template + void set(const char* name, const ConfigValue& value) + { + set(name, value.GetValue()); + } + void set(const char* name, uint64 value) { set(name, (sint64)value); @@ -462,4 +468,3 @@ public: private: T m_data; }; -