isle/LEGO1/legobackgroundcolor.cpp

54 lines
1.5 KiB
C++
Raw Normal View History

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);
}
// 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
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-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
}
free(colorStringCopy);
2023-06-24 14:47:05 -04:00
}
2023-06-24 13:38:10 -04:00
}