Fixed merge issues.

This commit is contained in:
Nicholas Estelami 2022-07-25 23:11:45 -04:00
parent 44bf5af33a
commit 3bb234e6a6
5 changed files with 27 additions and 60 deletions

View File

@ -9,7 +9,7 @@
std::map<std::string, std::unique_ptr<CVar>, 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;
}

View File

@ -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 <ultra64.h>
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 <functional>
#include <memory>
extern "C" CVar * CVar_Get(const char* name);
//extern "C" CVar * CVar_Get(const char* name);
extern std::map<std::string, std::unique_ptr<CVar>, std::less<>> cvars;
void CVar_SetFloat(const char* name, float value);
#endif

View File

@ -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;

View File

@ -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

View File

@ -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<std::string>().c_str());
if (StringHelper::StartsWith(value.get<std::string>(), "#"))
{
uint32_t val = std::stoul(&value.get<std::string>().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<std::string>().c_str());
break;
case nlohmann::detail::value_t::boolean:
CVar_SetS32(item.key().c_str(), value.get<bool>());
@ -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);
}
}