From 3bb234e6a66a368a2bfaeb2935993c29b553f98a Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Mon, 25 Jul 2022 23:11:45 -0400 Subject: [PATCH] Fixed merge issues. --- libultraship/libultraship/Cvar.cpp | 2 +- libultraship/libultraship/Cvar.h | 5 ++- libultraship/libultraship/ImGuiImpl.cpp | 44 ------------------------- libultraship/libultraship/color.h | 18 +++++----- soh/soh/Enhancements/debugconsole.cpp | 18 ++++++++-- 5 files changed, 27 insertions(+), 60 deletions(-) diff --git a/libultraship/libultraship/Cvar.cpp b/libultraship/libultraship/Cvar.cpp index eb6147baf..3a5ab6e04 100644 --- a/libultraship/libultraship/Cvar.cpp +++ b/libultraship/libultraship/Cvar.cpp @@ -9,7 +9,7 @@ std::map, std::less<>> cvars; -extern "C" CVar* CVar_Get(const char* name) { +CVar* CVar_Get(const char* name) { auto it = cvars.find(name); return (it != cvars.end()) ? it->second.get() : nullptr; } diff --git a/libultraship/libultraship/Cvar.h b/libultraship/libultraship/Cvar.h index 759d7f895..b8f294be6 100644 --- a/libultraship/libultraship/Cvar.h +++ b/libultraship/libultraship/Cvar.h @@ -25,7 +25,7 @@ typedef struct CVar { } value; } CVar; -CVar* CVar_Get(char* name); +extern "C" CVar * CVar_Get(const char* name); #endif #ifdef __cplusplus @@ -34,7 +34,6 @@ extern "C" #endif //#include -CVar* CVar_Get(const char* name); int32_t CVar_GetS32(const char* name, int32_t defaultValue); float CVar_GetFloat(const char* name, float defaultValue); const char* CVar_GetString(const char* name, const char* defaultValue); @@ -60,7 +59,7 @@ void CVar_RegisterRGBA(const char* name, Color_RGBA8 defaultValue); #include #include -extern "C" CVar * CVar_Get(const char* name); +//extern "C" CVar * CVar_Get(const char* name); extern std::map, std::less<>> cvars; void CVar_SetFloat(const char* name, float value); #endif diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index a15698db3..8997f6192 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -280,50 +280,6 @@ namespace SohImGui { stbi_image_free(img_data); } - void LoadRainbowColor() { - u8 arrayLength = sizeof(RainbowColorCvarList) / sizeof(*RainbowColorCvarList); - for (u8 s = 0; s < arrayLength; s++) { - std::string cvarName = RainbowColorCvarList[s]; - std::string Cvar_Red = cvarName; - Cvar_Red += "R"; - std::string Cvar_Green = cvarName; - Cvar_Green += "G"; - std::string Cvar_Blue = cvarName; - Cvar_Blue += "B"; - std::string Cvar_RBM = cvarName; - Cvar_RBM += "RBM"; - std::string RBM_HUE = cvarName; - RBM_HUE += "Hue"; - f32 Canon = 10.f * s; - ImVec4 NewColor; - const f32 deltaTime = 1.0f / ImGui::GetIO().Framerate; - f32 hue = CVar_GetFloat(RBM_HUE.c_str(), 0.0f); - f32 newHue = hue + CVar_GetS32("gColorRainbowSpeed", 1) * 36.0f * deltaTime; - if (newHue >= 360) - newHue = 0; - CVar_SetFloat(RBM_HUE.c_str(), newHue); - f32 current_hue = CVar_GetFloat(RBM_HUE.c_str(), 0); - u8 i = current_hue / 60 + 1; - u8 a = (-current_hue / 60.0f + i) * 255; - u8 b = (current_hue / 60.0f + (1 - i)) * 255; - - switch (i) { - case 1: NewColor.x = 255; NewColor.y = b; NewColor.z = 0; break; - case 2: NewColor.x = a; NewColor.y = 255; NewColor.z = 0; break; - case 3: NewColor.x = 0; NewColor.y = 255; NewColor.z = b; break; - case 4: NewColor.x = 0; NewColor.y = a; NewColor.z = 255; break; - case 5: NewColor.x = b; NewColor.y = 0; NewColor.z = 255; break; - case 6: NewColor.x = 255; NewColor.y = 0; NewColor.z = a; break; - } - - if (CVar_GetS32(Cvar_RBM.c_str(), 0) != 0) { - CVar_SetS32(Cvar_Red.c_str(), ClampFloatToInt(NewColor.x, 0, 255)); - CVar_SetS32(Cvar_Green.c_str(), ClampFloatToInt(NewColor.y, 0, 255)); - CVar_SetS32(Cvar_Blue.c_str(), ClampFloatToInt(NewColor.z, 0, 255)); - } - } - } - void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) { Color_RGBA8 defaultColors; diff --git a/libultraship/libultraship/color.h b/libultraship/libultraship/color.h index a260869a7..3e39389be 100644 --- a/libultraship/libultraship/color.h +++ b/libultraship/libultraship/color.h @@ -4,11 +4,11 @@ #include "endianness.h" typedef struct { - u8 r, g, b; + uint8_t r, g, b; } Color_RGB8; typedef struct { - u8 r, g, b, a; + uint8_t r, g, b, a; } Color_RGBA8; // only use when necessary for alignment purposes @@ -20,21 +20,21 @@ typedef union { u8 a, b, g, r; #endif }; - u32 rgba; + uint32_t rgba; } Color_RGBA8_u32; typedef struct { - f32 r, g, b, a; + float r, g, b, a; } Color_RGBAf; typedef union { struct { - u16 r : 5; - u16 g : 5; - u16 b : 5; - u16 a : 1; + uint16_t r : 5; + uint16_t g : 5; + uint16_t b : 5; + uint16_t a : 1; }; - u16 rgba; + uint16_t rgba; } Color_RGBA16; #ifdef __cplusplus diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp index bdae7754e..85a8c3829 100644 --- a/soh/soh/Enhancements/debugconsole.cpp +++ b/soh/soh/Enhancements/debugconsole.cpp @@ -569,7 +569,19 @@ void DebugConsole_LoadCVars() { case nlohmann::detail::value_t::array: break; case nlohmann::detail::value_t::string: - CVar_SetString(item.key().c_str(), value.get().c_str()); + if (StringHelper::StartsWith(value.get(), "#")) + { + uint32_t val = std::stoul(&value.get().c_str()[1], nullptr, 16); + Color_RGBA8 clr; + clr.r = val >> 24; + clr.g = val >> 16; + clr.b = val >> 8; + clr.a = val & 0xFF; + + CVar_SetRGBA(item.key().c_str(), clr); + } + else + CVar_SetString(item.key().c_str(), value.get().c_str()); break; case nlohmann::detail::value_t::boolean: CVar_SetS32(item.key().c_str(), value.get()); @@ -608,8 +620,8 @@ void DebugConsole_SaveCVars() { Color_RGBA8 clr = cvar.second->value.valueRGBA; uint32_t val = (clr.r << 24) + (clr.g << 16) + (clr.b << 8) + clr.a; - Conf->setRGBA(clr); - //output += StringHelper::Sprintf("%s = #%08X\n", cvar.first.c_str(), val); + std::string str = StringHelper::Sprintf("#%08X", val); + pConf->setString(key, str); } }