90% match

This commit is contained in:
Misha 2023-06-25 17:03:14 +03:00
parent 2208573eb2
commit 3d16867a90
4 changed files with 29 additions and 13 deletions

View file

@ -16,35 +16,42 @@ LegoBackgroundColor::LegoBackgroundColor(const char *name, const char *colorStri
// OFFSET: LEGO1 0x1003c070 // OFFSET: LEGO1 0x1003c070
void LegoBackgroundColor::SetColorString(const char *colorString) void LegoBackgroundColor::SetColorString(const char *colorString)
{ {
m_colorString.operator=(colorString); m_colorString.operator=(colorString);
m_colorString.ToLowerCase(); m_colorString.ToLowerCase();
float converted_b;
float converted_g;
float converted_r;
LegoVideoManager *videomanager = VideoManager(); LegoVideoManager *videomanager = VideoManager();
if (videomanager && colorString) if (videomanager && colorString)
{ {
char *colorStringCopy = (char *)malloc(strlen(colorString) + 1); int length = strlen(colorString) + 1;
char *colorStringCopy = (char *)malloc(length);
strcpy(colorStringCopy, colorString); strcpy(colorStringCopy, colorString);
char *colorStringSplit = strtok(colorStringCopy, Delimiter); char *colorStringSplit = strtok(colorStringCopy, Delimiter);
if (!strcmp(colorStringSplit, set)) if (!strcmp(colorStringSplit, set))
{ {
// set it // set it
char *red = strtok(0, Delimiter);
if (red) //TODO: I think this is in BGR because of the order of local variables
r = atoi(red) * 0.01;
char *blue = strtok(0, Delimiter); char *blue = strtok(0, Delimiter);
if (blue) if (blue)
b = atoi(blue) * 0.01; b = atoi(blue) * 0.01;
char *green = strtok(0, Delimiter); char *green = strtok(0, Delimiter);
if (green) if (green)
g = atoi(green) * 0.01; g = atoi(green) * 0.01;
char *red = strtok(0, Delimiter);
if (red)
r = atoi(red) * 0.01;
} }
else if (!strcmp(colorStringSplit, reset)) else if (!strcmp(colorStringSplit, reset))
{ {
// reset it // reset it
float converted_r;
float converted_b; ConvertColor(this->b, this->g, this->r, &converted_b, &converted_g, &converted_r);
float converted_g; videomanager->SetSkyColor(converted_b, converted_g, converted_r);
ConvertColor(this->r, this->g, this->b, &converted_r, &converted_g, &converted_b);
videomanager->SetSkyColor(converted_r, converted_g, converted_b);
} }
free(colorStringCopy); free(colorStringCopy);
} }

View file

@ -7,7 +7,12 @@ class LegoBackgroundColor : public MxBackgroundColor
{ {
public: public:
__declspec(dllexport) LegoBackgroundColor(const char *, const char *); __declspec(dllexport) LegoBackgroundColor(const char *, const char *);
void SetColorString(const char* colorString); void SetColorString(const char *colorString);
protected:
float b;
float g;
float r;
}; };
#endif // LEGOBACKGROUNDCOLOR_H #endif // LEGOBACKGROUNDCOLOR_H

View file

@ -1,6 +1,12 @@
#include "mxbackgroundcolor.h" #include "mxbackgroundcolor.h"
#include "mxstring.h" #include "mxstring.h"
// OFFSET: LEGO1 0x1003bec0
MxBackgroundColor::~MxBackgroundColor()
{
m_colorString.~MxString();
m_name.~MxString();
}
// OFFSET: LEGO1 0x1003bea0 // OFFSET: LEGO1 0x1003bea0
MxString* MxBackgroundColor::GetColorString() MxString* MxBackgroundColor::GetColorString()

View file

@ -9,12 +9,10 @@ class MxBackgroundColor
MxBackgroundColor(){} MxBackgroundColor(){}
virtual MxString* GetColorString(); virtual MxString* GetColorString();
virtual void SetColorString(const char* colorString); virtual void SetColorString(const char* colorString);
virtual ~MxBackgroundColor();
protected: protected:
MxString m_name; MxString m_name;
MxString m_colorString; MxString m_colorString;
float r;
float g;
float b;
}; };
#endif // MXBACKGROUNDCOLOR_H #endif // MXBACKGROUNDCOLOR_H