From 6ee5dd24a579daf8f32a31a2a0960fe193866952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sat, 25 Sep 2021 09:50:11 +0200 Subject: [PATCH] use constructor consistently for colors --- src/engine/client/client.cpp | 2 +- src/engine/client/graphics_threaded.cpp | 2 +- src/game/client/components/menus.cpp | 6 ++--- src/game/client/components/menus_settings.cpp | 24 +++++++++---------- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index a65f564fa..d7698e99b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3129,7 +3129,7 @@ void CClient::Run() char aBuf[256]; str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion()); - m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA{0.7f, 0.7f, 1, 1.0f}); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA(0.7f, 0.7f, 1, 1.0f)); // connect to the server if wanted /* diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index df4c46f69..1f5c55ac1 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -678,7 +678,7 @@ void CGraphics_Threaded::ScreenshotDirect() // save png char aBuf[256]; str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath); - m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA{1.0f, 0.6f, 0.3f, 1.0f}); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "client", aBuf, ColorRGBA(1.0f, 0.6f, 0.3f, 1.0f)); png_open_file_write(&Png, aWholePath); // ignore_convention png_set_data(&Png, Image.m_Width, Image.m_Height, 8, PNG_TRUECOLOR_ALPHA, (unsigned char *)Image.m_pData); // ignore_convention png_close_file(&Png); // ignore_convention diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index ec7351170..c928dd7e2 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -761,7 +761,7 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current, Slider.y -= MarginH / 2; Slider.w += MarginW; Slider.h += MarginH; - RenderTools()->DrawUIRect(&Slider, ColorRGBA{0.15f, 0.15f, 0.15f, 1.0f}, CUI::CORNER_ALL, 5.0f); + RenderTools()->DrawUIRect(&Slider, ColorRGBA(0.15f, 0.15f, 0.15f, 1.0f), CUI::CORNER_ALL, 5.0f); Slider.Margin(2, &Slider); RenderTools()->DrawUIRect(&Slider, *pColorInner, CUI::CORNER_ALL, 3.0f); } @@ -1605,7 +1605,7 @@ int CMenus::Render() const char *pButtonText = ""; int ExtraAlign = 0; - ColorRGBA BgColor = ColorRGBA{0.0f, 0.0f, 0.0f, 0.5f}; + ColorRGBA BgColor = ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f); if(m_Popup == POPUP_MESSAGE) { pTitle = m_aMessageTopic; @@ -1744,7 +1744,7 @@ int CMenus::Render() } else if(m_Popup == POPUP_WARNING) { - BgColor = ColorRGBA{0.5f, 0.0f, 0.0f, 0.7f}; + BgColor = ColorRGBA(0.5f, 0.0f, 0.0f, 0.7f); pTitle = m_aMessageTopic; pExtraText = m_aMessageBody; pButtonText = m_aMessageButton; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 9bcee4bc8..4b1fd1a1f 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1733,17 +1733,15 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Graphics()->TextureClear(); { const float SizeBorder = 5.0f; - ColorRGBA SetColorRGBA{0.15f, 0.15f, 0.15f, 1}; - Graphics()->SetColor(SetColorRGBA); + Graphics()->SetColor(ColorRGBA(0.15f, 0.15f, 0.15f, 1)); int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x - SizeBorder / 2.0f, Preview.y - SizeBorder / 2.0f, Preview.w + SizeBorder, Preview.h + SizeBorder, 4.0f + SizeBorder / 2.0f, CUI::CORNER_ALL); Graphics()->RenderQuadContainer(TmpCont, -1); Graphics()->DeleteQuadContainer(TmpCont); } - ColorHSLA RenderColorHSLA{Color.r, Color.g, Color.b, Color.a}; + ColorHSLA RenderColorHSLA(Color.r, Color.g, Color.b, Color.a); if(ClampedLight) RenderColorHSLA = RenderColorHSLA.UnclampLighting(); - ColorRGBA SetColorRGBA = color_cast(RenderColorHSLA); - Graphics()->SetColor(SetColorRGBA); + Graphics()->SetColor(color_cast(RenderColorHSLA)); int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x, Preview.y, Preview.w, Preview.h, 4.0f, CUI::CORNER_ALL); Graphics()->RenderQuadContainer(TmpCont, -1); Graphics()->DeleteQuadContainer(TmpCont); @@ -2007,15 +2005,15 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Button.VSplitLeft(10.0f, 0, &Button); Button.VSplitLeft(100.0f, &Label, &Button); - RenderTools()->DrawUIRect(&Button, ColorRGBA{0.15f, 0.15f, 0.15f, 1.0f}, CUI::CORNER_ALL, 1.0f); + RenderTools()->DrawUIRect(&Button, ColorRGBA(0.15f, 0.15f, 0.15f, 1.0f), CUI::CORNER_ALL, 1.0f); Button.Margin(2.0f, &Button); str_format(aBuf, sizeof(aBuf), "%s: %03d", aLabels[i], (int)(*paComponent[i] * 255)); UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1); - ColorHSLA CurColorPureHSLA{RenderColorHSLA.r, 1, 0.5f, 1}; + ColorHSLA CurColorPureHSLA(RenderColorHSLA.r, 1, 0.5f, 1); ColorRGBA CurColorPure = color_cast(CurColorPureHSLA); - ColorRGBA ColorInner{1, 1, 1, 0.25f}; + ColorRGBA ColorInner(1, 1, 1, 0.25f); if(i == 0) { @@ -2025,25 +2023,25 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool else if(i == 1) { RenderHSLSatRect(&Button, CurColorPure); - ColorInner = color_cast(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], CurColorPureHSLA.b, 1}); + ColorInner = color_cast(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], CurColorPureHSLA.b, 1)); } else if(i == 2) { - ColorRGBA CurColorSat = color_cast(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], 0.5f, 1}); + ColorRGBA CurColorSat = color_cast(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], 0.5f, 1)); RenderHSLLightRect(&Button, CurColorSat); float LightVal = *paComponent[2]; if(ClampedLight) LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT); - ColorInner = color_cast(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], LightVal, 1}); + ColorInner = color_cast(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], LightVal, 1)); } else if(i == 3) { - ColorRGBA CurColorFull = color_cast(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], *paComponent[2], 1}); + ColorRGBA CurColorFull = color_cast(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], *paComponent[2], 1)); RenderHSLAlphaRect(&Button, CurColorFull); float LightVal = *paComponent[2]; if(ClampedLight) LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT); - ColorInner = color_cast(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], LightVal, *paComponent[3]}); + ColorInner = color_cast(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], LightVal, *paComponent[3])); } *paComponent[i] = DoScrollbarH(&((char *)pColor)[i], &Button, *paComponent[i], true, &ColorInner);