From 4b139b39736a976567fccd1cba8e0ac8ffaa4481 Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 3 Mar 2025 17:39:43 -0500 Subject: [PATCH] Add conditional inclusion of and implement ColorToHexString using std::format or absl::StrFormat --- src/app/gui/color.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/gui/color.h b/src/app/gui/color.h index 9b47886d..a14413a1 100644 --- a/src/app/gui/color.h +++ b/src/app/gui/color.h @@ -1,10 +1,13 @@ #ifndef YAZE_GUI_COLOR_H #define YAZE_GUI_COLOR_H -// #include +#if defined(__clang__) +#include +#endif #include #include "absl/status/status.h" +#include "absl/strings/str_format.h" #include "app/gfx/snes_palette.h" #include "imgui/imgui.h" @@ -23,11 +26,17 @@ inline ImVec4 ConvertColorToImVec4(const Color &color) { } inline std::string ColorToHexString(const Color &color) { - return ""; -/* std::format( +#if defined(__clang__) + return std::format( "{:02X}{:02X}{:02X}{:02X}", static_cast(color.red * 255), static_cast(color.green * 255), static_cast(color.blue * 255), - static_cast(color.alpha * 255)); */ + static_cast(color.alpha * 255)); +#else + return absl::StrFormat("%02X%02X%02X%02X", static_cast(color.red * 255), + static_cast(color.green * 255), + static_cast(color.blue * 255), + static_cast(color.alpha * 255)); +#endif } // A utility function to convert an SnesColor object to an ImVec4 with