use constructor consistently for colors

This commit is contained in:
Robert Müller 2021-09-25 09:50:11 +02:00
parent 5fdf782eca
commit 6ee5dd24a5
4 changed files with 16 additions and 18 deletions

View file

@ -3129,7 +3129,7 @@ void CClient::Run()
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "version %s", GameClient()->NetVersion()); 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 // connect to the server if wanted
/* /*

View file

@ -678,7 +678,7 @@ void CGraphics_Threaded::ScreenshotDirect()
// save png // save png
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "saved screenshot to '%s'", aWholePath); 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_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_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 png_close_file(&Png); // ignore_convention

View file

@ -761,7 +761,7 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current,
Slider.y -= MarginH / 2; Slider.y -= MarginH / 2;
Slider.w += MarginW; Slider.w += MarginW;
Slider.h += MarginH; 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); Slider.Margin(2, &Slider);
RenderTools()->DrawUIRect(&Slider, *pColorInner, CUI::CORNER_ALL, 3.0f); RenderTools()->DrawUIRect(&Slider, *pColorInner, CUI::CORNER_ALL, 3.0f);
} }
@ -1605,7 +1605,7 @@ int CMenus::Render()
const char *pButtonText = ""; const char *pButtonText = "";
int ExtraAlign = 0; 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) if(m_Popup == POPUP_MESSAGE)
{ {
pTitle = m_aMessageTopic; pTitle = m_aMessageTopic;
@ -1744,7 +1744,7 @@ int CMenus::Render()
} }
else if(m_Popup == POPUP_WARNING) 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; pTitle = m_aMessageTopic;
pExtraText = m_aMessageBody; pExtraText = m_aMessageBody;
pButtonText = m_aMessageButton; pButtonText = m_aMessageButton;

View file

@ -1733,17 +1733,15 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool
Graphics()->TextureClear(); Graphics()->TextureClear();
{ {
const float SizeBorder = 5.0f; const float SizeBorder = 5.0f;
ColorRGBA SetColorRGBA{0.15f, 0.15f, 0.15f, 1}; Graphics()->SetColor(ColorRGBA(0.15f, 0.15f, 0.15f, 1));
Graphics()->SetColor(SetColorRGBA);
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); 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()->RenderQuadContainer(TmpCont, -1);
Graphics()->DeleteQuadContainer(TmpCont); 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) if(ClampedLight)
RenderColorHSLA = RenderColorHSLA.UnclampLighting(); RenderColorHSLA = RenderColorHSLA.UnclampLighting();
ColorRGBA SetColorRGBA = color_cast<ColorRGBA>(RenderColorHSLA); Graphics()->SetColor(color_cast<ColorRGBA>(RenderColorHSLA));
Graphics()->SetColor(SetColorRGBA);
int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x, Preview.y, Preview.w, Preview.h, 4.0f, CUI::CORNER_ALL); int TmpCont = RenderTools()->CreateRoundRectQuadContainer(Preview.x, Preview.y, Preview.w, Preview.h, 4.0f, CUI::CORNER_ALL);
Graphics()->RenderQuadContainer(TmpCont, -1); Graphics()->RenderQuadContainer(TmpCont, -1);
Graphics()->DeleteQuadContainer(TmpCont); Graphics()->DeleteQuadContainer(TmpCont);
@ -2007,15 +2005,15 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool
Button.VSplitLeft(10.0f, 0, &Button); Button.VSplitLeft(10.0f, 0, &Button);
Button.VSplitLeft(100.0f, &Label, &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); Button.Margin(2.0f, &Button);
str_format(aBuf, sizeof(aBuf), "%s: %03d", aLabels[i], (int)(*paComponent[i] * 255)); str_format(aBuf, sizeof(aBuf), "%s: %03d", aLabels[i], (int)(*paComponent[i] * 255));
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1); 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<ColorRGBA>(CurColorPureHSLA); ColorRGBA CurColorPure = color_cast<ColorRGBA>(CurColorPureHSLA);
ColorRGBA ColorInner{1, 1, 1, 0.25f}; ColorRGBA ColorInner(1, 1, 1, 0.25f);
if(i == 0) if(i == 0)
{ {
@ -2025,25 +2023,25 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool
else if(i == 1) else if(i == 1)
{ {
RenderHSLSatRect(&Button, CurColorPure); RenderHSLSatRect(&Button, CurColorPure);
ColorInner = color_cast<ColorRGBA>(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], CurColorPureHSLA.b, 1}); ColorInner = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], CurColorPureHSLA.b, 1));
} }
else if(i == 2) else if(i == 2)
{ {
ColorRGBA CurColorSat = color_cast<ColorRGBA>(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], 0.5f, 1}); ColorRGBA CurColorSat = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], 0.5f, 1));
RenderHSLLightRect(&Button, CurColorSat); RenderHSLLightRect(&Button, CurColorSat);
float LightVal = *paComponent[2]; float LightVal = *paComponent[2];
if(ClampedLight) if(ClampedLight)
LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT); LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT);
ColorInner = color_cast<ColorRGBA>(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], LightVal, 1}); ColorInner = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], LightVal, 1));
} }
else if(i == 3) else if(i == 3)
{ {
ColorRGBA CurColorFull = color_cast<ColorRGBA>(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], *paComponent[2], 1}); ColorRGBA CurColorFull = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], *paComponent[2], 1));
RenderHSLAlphaRect(&Button, CurColorFull); RenderHSLAlphaRect(&Button, CurColorFull);
float LightVal = *paComponent[2]; float LightVal = *paComponent[2];
if(ClampedLight) if(ClampedLight)
LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT); LightVal = ColorHSLA::DARKEST_LGT + LightVal * (1.0f - ColorHSLA::DARKEST_LGT);
ColorInner = color_cast<ColorRGBA>(ColorHSLA{CurColorPureHSLA.r, *paComponent[1], LightVal, *paComponent[3]}); ColorInner = color_cast<ColorRGBA>(ColorHSLA(CurColorPureHSLA.r, *paComponent[1], LightVal, *paComponent[3]));
} }
*paComponent[i] = DoScrollbarH(&((char *)pColor)[i], &Button, *paComponent[i], true, &ColorInner); *paComponent[i] = DoScrollbarH(&((char *)pColor)[i], &Button, *paComponent[i], true, &ColorInner);