mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-29 11:06:05 -05:00
54 lines
No EOL
1.5 KiB
C++
54 lines
No EOL
1.5 KiB
C++
#include "legobackgroundcolor.h"
|
|
#include "legoomni.h"
|
|
#include "legoutil.h"
|
|
#include "legovideomanager.h"
|
|
const char *Delimiter = "\t";
|
|
const char *set = "set";
|
|
const char *reset = "reset";
|
|
// OFFSET: LEGO1 0x1003bfb0
|
|
LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorString)
|
|
{
|
|
this->m_name.operator=(name);
|
|
this->m_name.ToUpperCase();
|
|
SetColorString(colorString);
|
|
}
|
|
|
|
// OFFSET: LEGO1 0x1003c070
|
|
void LegoBackgroundColor::SetColorString(const char *colorString)
|
|
{
|
|
|
|
m_colorString.operator=(colorString);
|
|
m_colorString.ToLowerCase();
|
|
|
|
float converted_r;
|
|
float converted_b;
|
|
float converted_g;
|
|
LegoVideoManager *videomanager = VideoManager();
|
|
|
|
if (videomanager && colorString)
|
|
{
|
|
int length = strlen(colorString) + 1;
|
|
char *colorStringCopy = (char *)malloc(length);
|
|
strcpy(colorStringCopy, colorString);
|
|
char *colorStringSplit = strtok(colorStringCopy, Delimiter);
|
|
if (!strcmp(colorStringSplit, set))
|
|
{
|
|
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;
|
|
}
|
|
else if (!strcmp(colorStringSplit, reset))
|
|
{
|
|
// reset it
|
|
ConvertHSVToRGB(this->h, this->s, this->v, &converted_r, &converted_g, &converted_b);
|
|
videomanager->SetSkyColor(converted_r, converted_g, converted_b);
|
|
}
|
|
free(colorStringCopy);
|
|
}
|
|
} |