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
|
|
|
{
|
|
|
|
this->m_name.operator=(name);
|
|
|
|
this->m_name.ToUpperCase();
|
|
|
|
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-25 10:03:14 -04:00
|
|
|
|
2023-06-24 13:47:03 -04:00
|
|
|
m_colorString.operator=(colorString);
|
|
|
|
m_colorString.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;
|
|
|
|
char *colorStringCopy = (char *)malloc(length);
|
2023-06-25 05:23:47 -04:00
|
|
|
strcpy(colorStringCopy, colorString);
|
|
|
|
char *colorStringSplit = strtok(colorStringCopy, Delimiter);
|
|
|
|
if (!strcmp(colorStringSplit, set))
|
|
|
|
{
|
2023-06-26 06:24:11 -04:00
|
|
|
//TODO: the names of these variables are incorrect as I can't figure out what color format ConvertColor() uses
|
2023-06-25 05:23:47 -04:00
|
|
|
char *blue = strtok(0, Delimiter);
|
|
|
|
if (blue)
|
|
|
|
b = atoi(blue) * 0.01;
|
|
|
|
char *green = strtok(0, Delimiter);
|
|
|
|
if (green)
|
|
|
|
g = atoi(green) * 0.01;
|
2023-06-25 10:03:14 -04:00
|
|
|
char *red = strtok(0, Delimiter);
|
|
|
|
if (red)
|
|
|
|
r = atoi(red) * 0.01;
|
2023-06-25 05:23:47 -04:00
|
|
|
}
|
|
|
|
else if (!strcmp(colorStringSplit, reset))
|
|
|
|
{
|
|
|
|
// reset it
|
2023-06-25 10:03:14 -04:00
|
|
|
|
2023-06-26 06:24:11 -04:00
|
|
|
ConvertColor(this->b, this->g, this->r, &converted_r, &converted_g, &converted_b);
|
|
|
|
videomanager->SetSkyColor(converted_r, converted_g, converted_b);
|
2023-06-25 05:23:47 -04:00
|
|
|
}
|
|
|
|
free(colorStringCopy);
|
2023-06-24 14:47:05 -04:00
|
|
|
}
|
2023-06-24 13:38:10 -04:00
|
|
|
}
|