diff --git a/src/engine/shared/tater_variables.h b/src/engine/shared/tater_variables.h index d2934c23ba4..92854b3c013 100644 --- a/src/engine/shared/tater_variables.h +++ b/src/engine/shared/tater_variables.h @@ -127,7 +127,7 @@ MACRO_CONFIG_INT(ClAutoVerify, tc_auto_verify, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG // Rainbow MACRO_CONFIG_INT(ClRainbow, tc_rainbow, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Turn on rainbow client side") MACRO_CONFIG_INT(ClRainbowOthers, tc_rainbow_others, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Turn on rainbow client side for others") -MACRO_CONFIG_INT(ClRainbowMode, tc_rainbow_mode, 1, 1, 4, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow mode (1: rainbow, 2: pulse, 3: darkness)") +MACRO_CONFIG_INT(ClRainbowMode, tc_rainbow_mode, 1, 1, 4, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow mode (1: rainbow, 2: pulse, 3: darkness, 4: random)") // AAAAAAA MACRO_CONFIG_INT(ClAmIFrozen, EEEfrz, 0, 0, 1, CFGFLAG_CLIENT, "") diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 6aebbcc14ed..986b832a5a2 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -3608,7 +3608,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView) Ui()->DoLabel(&Label, Localize("Rainbow"), HeadlineFontSize, TEXTALIGN_ML); Column.HSplitTop(MarginSmall, nullptr, &Column); - static std::vector s_DropDownNames = {Localize("Rainbow"), Localize("Pulse"), Localize("Black")}; + static std::vector s_DropDownNames = {Localize("Rainbow"), Localize("Pulse"), Localize("Black"), Localize("Random")}; static CUi::SDropDownState s_RainbowDropDownState; static CScrollRegion s_RainbowDropDownScrollRegion; s_RainbowDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_RainbowDropDownScrollRegion; diff --git a/src/game/client/components/rainbow.cpp b/src/game/client/components/rainbow.cpp index e231ee288b0..79067270941 100644 --- a/src/game/client/components/rainbow.cpp +++ b/src/game/client/components/rainbow.cpp @@ -10,67 +10,67 @@ #include "rainbow.h" -void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pinfo) +template +T color_lerp(T a, T b, float c) { + T result; + for(size_t i = 0; i < 4; ++i) + result[i] = a[i] + c * (b[i] - a[i]); + return result; +} + +void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pInfo) { if(!Mode) return; - int DefTick = Tick % 255; - - const ColorHSLA PlayerColBody = ColorHSLA(g_Config.m_ClPlayerColorBody); - const ColorHSLA PlayerColFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet); + int DefTick = Tick % 256; - pinfo->m_CustomColoredSkin = true; + ColorRGBA Col; if(Mode == COLORMODE_RAINBOW) - { - const ColorRGBA Col = color_cast(ColorHSLA((float)DefTick / 255.0f, 1.0f, 0.5f)); - pinfo->m_ColorBody = Col; - pinfo->m_ColorFeet = Col; - pinfo->m_BloodColor = Col; - } + Col = color_cast(ColorHSLA((float)DefTick / 256.0f, 1.0f, 0.5f)); else if(Mode == COLORMODE_PULSE) - { - pinfo->m_ColorBody.s = 1.0f; - pinfo->m_ColorFeet.s = 1.0f; - pinfo->m_BloodColor.s = 1.0f; - pinfo->m_ColorBody.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); - pinfo->m_ColorFeet.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); - pinfo->m_BloodColor.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f); - pinfo->m_ColorBody.h = (float)DefTick / 255.0f; - pinfo->m_ColorFeet.h = (float)DefTick / 255.0f; - pinfo->m_BloodColor.h = (float)DefTick / 255.0f; - } + Col = color_cast(ColorHSLA((float)DefTick / 256.0f, 1.0f, 0.5f + std::fabs(((float)DefTick / 256.0f) - 0.5f))); else if(Mode == COLORMODE_DARKNESS) + Col = ColorRGBA(0.0f, 0.0f, 0.0f); + else if(Mode == COLORMODE_RANDOM) { - pinfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f); - pinfo->m_ColorFeet = ColorRGBA(0.0f, 0.0f, 0.0f); - pinfo->m_BloodColor = ColorRGBA(0.0f, 0.0f, 0.0f); - } - else - { - pinfo->m_CustomColoredSkin = true; - pinfo->m_ColorBody = color_cast(PlayerColBody); - pinfo->m_ColorFeet = color_cast(PlayerColFeet); - // pinfo->m_BloodColor = pinfo->m_BloodColor; // TODO reset blood color + static ColorHSLA Col1 = ColorHSLA(0.0f, 0.0f, 0.0f, 0.0f), Col2 = ColorHSLA(0.0f, 0.0f, 0.0f, 0.0f); + if(Col2.a == 0.0f) // Create first target + { + Col2 = ColorHSLA((float)rand() / (float)RAND_MAX, 1.0f, (float)rand() / (float)RAND_MAX, 1.0f); + } + if(Col1.a == 0.0f) // Shift target to source, create new target + { + Col1 = Col2; + Col2 = ColorHSLA((float)rand() / (float)RAND_MAX, 1.0f, (float)rand() / (float)RAND_MAX, 1.0f); + } + Col = color_cast(color_lerp(Col1, Col2, (float)DefTick / 256.0f)); + if (DefTick == 255) + Col1.a = 0.0f; } + pInfo->m_BloodColor = Col; + pInfo->m_ColorBody = Col; + pInfo->m_ColorFeet = Col; + pInfo->m_CustomColoredSkin = true; } void CRainbow::OnRender() { + static int Tick = 0; + ++Tick; for(int i = 0; i < MAX_CLIENTS; i++) { + if(!m_pClient->m_Snap.m_aCharacters[i].m_Active) + continue; + // check if local player bool Local = m_pClient->m_Snap.m_LocalClientId == i; CTeeRenderInfo *RenderInfo = &m_pClient->m_aClients[i].m_RenderInfo; // check if rainbow is enabled if(g_Config.m_ClRainbow && Local) // rainbow is enabled and is own player - { - TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo); - } + TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo); else if(g_Config.m_ClRainbowOthers && !Local) // rainbow is enabled and is not own player - { - TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo); - } + TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo); } } diff --git a/src/game/client/components/rainbow.h b/src/game/client/components/rainbow.h index f2c4958c1a3..e7d9dedf099 100644 --- a/src/game/client/components/rainbow.h +++ b/src/game/client/components/rainbow.h @@ -15,6 +15,7 @@ class CRainbow : public CComponent COLORMODE_RAINBOW = 1, COLORMODE_PULSE, COLORMODE_DARKNESS, + COLORMODE_RANDOM }; };