From fd1b3718649e0ce82f2fbcfc385d602adda06feb Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:22:11 -0400 Subject: [PATCH] Implement a few LegoBackgroundColor functions (#694) * Update legobackgroundcolor.cpp * Update legobackgroundcolor.cpp * minor style * minor style --------- Co-authored-by: Christian Semmler --- .../src/common/legobackgroundcolor.cpp | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp b/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp index 07a8e3ca..5cf43c65 100644 --- a/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp +++ b/LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp @@ -67,16 +67,50 @@ void LegoBackgroundColor::SetValue(const char* p_colorString) delete[] colorStringCopy; } -// STUB: LEGO1 0x1003c230 -void LegoBackgroundColor::ToggleDayNight(MxBool) +// FUNCTION: LEGO1 0x1003c230 +void LegoBackgroundColor::ToggleDayNight(MxBool p_sun) { - // TODO + char buffer[30]; + + if (p_sun) { + m_s += 0.1; + if (m_s > 0.9) { + m_s = 1.0; + } + } + else { + m_s -= 0.1; + if (m_s < 0.1) { + m_s = 0.1; + } + } + + sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f)); + m_value = buffer; + + float convertedR, convertedG, convertedB; + ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB); + VideoManager()->SetSkyColor(convertedR, convertedG, convertedB); + SetLights(convertedR, convertedG, convertedB); } -// STUB: LEGO1 0x1003c330 +// FUNCTION: LEGO1 0x1003c330 void LegoBackgroundColor::ToggleSkyColor() { - // TODO + char buffer[30]; + + m_h += 0.05; + if (m_h > 1.0) { + m_h -= 1.0; + } + + sprintf(buffer, "set %d %d %d", (MxU32) (m_h * 100.0f), (MxU32) (m_s * 100.0f), (MxU32) (m_v * 100.0f)); + m_value = buffer; + + float convertedR, convertedG, convertedB; + ConvertHSVToRGB(m_h, m_s, m_v, &convertedR, &convertedG, &convertedB); + VideoManager()->SetSkyColor(convertedR, convertedG, convertedB); + SetLights(convertedR, convertedG, convertedB); } // STUB: LEGO1 0x1003c400