2023-06-24 13:38:10 -04:00
|
|
|
#include "legobackgroundcolor.h"
|
|
|
|
#include "legoomni.h"
|
|
|
|
#include "legoutil.h"
|
2023-06-25 05:23:47 -04:00
|
|
|
#include "legovideomanager.h"
|
|
|
|
const char *Delimiter = "\t";
|
|
|
|
const char *set = "set";
|
|
|
|
const char *reset = "reset";
|
2023-06-24 13:38:10 -04:00
|
|
|
// OFFSET: LEGO1 0x1003bfb0
|
2023-06-25 05:23:47 -04:00
|
|
|
LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorString)
|
2023-06-24 13:38:10 -04:00
|
|
|
{
|
2023-06-29 06:34:15 -04:00
|
|
|
m_name = name;
|
|
|
|
m_name.ToUpperCase();
|
2023-06-24 13:38:10 -04:00
|
|
|
SetColorString(colorString);
|
|
|
|
}
|
|
|
|
|
2023-06-24 13:47:03 -04:00
|
|
|
// OFFSET: LEGO1 0x1003c070
|
2023-06-25 05:23:47 -04:00
|
|
|
void LegoBackgroundColor::SetColorString(const char *colorString)
|
2023-06-24 13:38:10 -04:00
|
|
|
{
|
2023-06-28 11:15:42 -04:00
|
|
|
m_name = colorString;
|
2023-06-28 11:22:35 -04:00
|
|
|
m_string.ToLowerCase();
|
2023-06-25 10:03:14 -04:00
|
|
|
|
2023-06-26 06:24:11 -04:00
|
|
|
float converted_r;
|
2023-06-25 10:03:14 -04:00
|
|
|
float converted_b;
|
|
|
|
float converted_g;
|
2023-06-25 05:23:47 -04:00
|
|
|
LegoVideoManager *videomanager = VideoManager();
|
2023-06-25 10:03:14 -04:00
|
|
|
|
2023-06-25 05:23:47 -04:00
|
|
|
if (videomanager && colorString)
|
2023-06-24 14:47:05 -04:00
|
|
|
{
|
2023-06-25 10:03:14 -04:00
|
|
|
int length = strlen(colorString) + 1;
|
2023-06-28 11:15:42 -04:00
|
|
|
char *colorStringCopy = new char[length];
|
2023-06-25 05:23:47 -04:00
|
|
|
strcpy(colorStringCopy, colorString);
|
|
|
|
char *colorStringSplit = strtok(colorStringCopy, Delimiter);
|
|
|
|
if (!strcmp(colorStringSplit, set))
|
|
|
|
{
|
2023-06-27 11:35:58 -04:00
|
|
|
char *hue = strtok(0, Delimiter);
|
|
|
|
if (hue)
|
|
|
|
h = atoi(hue) * 0.01;
|
|
|
|
char *sat = strtok(0, Delimiter);
|
|
|
|
if (sat)
|
|
|
|
s = atoi(sat) * 0.01;
|
|
|
|
char *val = strtok(0, Delimiter);
|
|
|
|
if (val)
|
|
|
|
v = atoi(val) * 0.01;
|
2023-06-25 05:23:47 -04:00
|
|
|
}
|
|
|
|
else if (!strcmp(colorStringSplit, reset))
|
|
|
|
{
|
|
|
|
// reset it
|
2023-06-27 11:35:58 -04:00
|
|
|
ConvertHSVToRGB(this->h, this->s, this->v, &converted_r, &converted_g, &converted_b);
|
2023-06-26 06:24:11 -04:00
|
|
|
videomanager->SetSkyColor(converted_r, converted_g, converted_b);
|
2023-06-25 05:23:47 -04:00
|
|
|
}
|
2023-06-28 11:15:42 -04:00
|
|
|
delete[] colorStringCopy;
|
2023-06-24 14:47:05 -04:00
|
|
|
}
|
2023-06-28 11:15:42 -04:00
|
|
|
}
|