2023-06-30 14:34:39 -04:00
|
|
|
#include "legobackgroundcolor.h"
|
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "decomp.h"
|
2023-06-30 19:33:59 -04:00
|
|
|
#include "legoomni.h"
|
|
|
|
#include "legoutil.h"
|
|
|
|
#include "legovideomanager.h"
|
2023-09-29 16:38:08 -04:00
|
|
|
|
|
|
|
DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30)
|
2023-06-30 19:33:59 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
const char* g_delimiter = "\t";
|
|
|
|
const char* g_set = "set";
|
|
|
|
const char* g_reset = "reset";
|
2023-06-30 19:33:59 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bfb0
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoBackgroundColor::LegoBackgroundColor(const char* p_key, const char* p_value)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
m_key = p_key;
|
|
|
|
m_key.ToUpperCase();
|
|
|
|
SetValue(p_value);
|
2023-06-30 19:33:59 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003c070
|
2023-10-24 19:38:27 -04:00
|
|
|
void LegoBackgroundColor::SetValue(const char* p_colorString)
|
2023-06-30 19:33:59 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
m_value = p_colorString;
|
|
|
|
m_value.ToLowerCase();
|
|
|
|
|
|
|
|
LegoVideoManager* videomanager = VideoManager();
|
|
|
|
if (!videomanager || !p_colorString)
|
|
|
|
return;
|
|
|
|
|
2023-12-13 05:48:14 -05:00
|
|
|
float convertedR, convertedG, convertedB;
|
2023-10-24 19:38:27 -04:00
|
|
|
char* colorStringCopy = strcpy(new char[strlen(p_colorString) + 1], p_colorString);
|
|
|
|
char* colorStringSplit = strtok(colorStringCopy, g_delimiter);
|
|
|
|
|
|
|
|
if (!strcmp(colorStringSplit, g_set)) {
|
|
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
|
|
if (colorStringSplit)
|
2023-12-13 05:48:14 -05:00
|
|
|
m_h = (float) (atoi(colorStringSplit) * 0.01);
|
2023-10-24 19:38:27 -04:00
|
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
|
|
if (colorStringSplit)
|
2023-12-13 05:48:14 -05:00
|
|
|
m_s = (float) (atoi(colorStringSplit) * 0.01);
|
2023-10-24 19:38:27 -04:00
|
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
|
|
if (colorStringSplit)
|
2023-12-13 05:48:14 -05:00
|
|
|
m_v = (float) (atoi(colorStringSplit) * 0.01);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2023-12-13 05:48:14 -05:00
|
|
|
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
|
|
|
videomanager->SetSkyColor(convertedR, convertedG, convertedB);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
else if (!strcmp(colorStringSplit, g_reset)) {
|
2023-12-13 05:48:14 -05:00
|
|
|
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
|
|
|
videomanager->SetSkyColor(convertedR, convertedG, convertedB);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] colorStringCopy;
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|