mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-26 17:46:38 -05:00
bc5ca621a4
* Add ncc tool * Add symlink * Fixes * Try this * Try this * Try this * Try this * Add include path * Update style * Update style * Add more rules * Fix style * Update styles * Fix name parameter * Fix MxParam p * Fix m_unk0x pattern * Allow 4 digits for relative hex * Add missing offset * Fix some parameters * Fix some vtables * Fix more vtables * Update rules, fixes * More fixes * More fixes * More fixes * More fixes * More fixes * More fixes * More fixes * Fix last issue * Update readme * Update readme * Update CONTRIBUTING.md * Fix annotations * Rename * Update CONTRIBUTING.md * Update README.md
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#include "legobackgroundcolor.h"
|
|
|
|
#include "decomp.h"
|
|
#include "legoomni.h"
|
|
#include "legoutil.h"
|
|
#include "legovideomanager.h"
|
|
|
|
DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30)
|
|
|
|
const char* g_delimiter = "\t";
|
|
const char* g_set = "set";
|
|
const char* g_reset = "reset";
|
|
|
|
// FUNCTION: LEGO1 0x1003bfb0
|
|
LegoBackgroundColor::LegoBackgroundColor(const char* p_key, const char* p_value)
|
|
{
|
|
m_key = p_key;
|
|
m_key.ToUpperCase();
|
|
SetValue(p_value);
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x1003c070
|
|
void LegoBackgroundColor::SetValue(const char* p_colorString)
|
|
{
|
|
m_value = p_colorString;
|
|
m_value.ToLowerCase();
|
|
|
|
LegoVideoManager* videomanager = VideoManager();
|
|
if (!videomanager || !p_colorString)
|
|
return;
|
|
|
|
float convertedR, convertedG, convertedB;
|
|
char* colorStringCopy = strcpy(new char[strlen(p_colorString) + 1], p_colorString);
|
|
char* colorStringSplit = strtok(colorStringCopy, g_delimiter);
|
|
|
|
if (!strcmp(colorStringSplit, g_set)) {
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
if (colorStringSplit)
|
|
m_h = (float) (atoi(colorStringSplit) * 0.01);
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
if (colorStringSplit)
|
|
m_s = (float) (atoi(colorStringSplit) * 0.01);
|
|
colorStringSplit = strtok(0, g_delimiter);
|
|
if (colorStringSplit)
|
|
m_v = (float) (atoi(colorStringSplit) * 0.01);
|
|
|
|
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
|
videomanager->SetSkyColor(convertedR, convertedG, convertedB);
|
|
}
|
|
else if (!strcmp(colorStringSplit, g_reset)) {
|
|
ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB);
|
|
videomanager->SetSkyColor(convertedR, convertedG, convertedB);
|
|
}
|
|
|
|
delete[] colorStringCopy;
|
|
}
|