From e817a179da69683d4ef209b8b6e2650279bbde1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Wed, 28 Oct 2020 05:59:50 +0300 Subject: [PATCH 01/12] Started making color picker --- src/game/client/components/menus.cpp | 144 ++++++++++++++++++ src/game/client/components/menus.h | 22 +++ src/game/client/components/menus_settings.cpp | 131 ++++++++++++---- src/game/client/render.cpp | 13 ++ src/game/client/render.h | 1 + 5 files changed, 279 insertions(+), 32 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 12dfaf728..5d68a2d75 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -53,6 +53,10 @@ ColorRGBA CMenus::ms_ColorTabbarInactiveIngame; ColorRGBA CMenus::ms_ColorTabbarActiveIngame; ColorRGBA CMenus::ms_ColorTabbarHoverIngame; +SColorPicker CMenus::ms_ColorPicker; +int CMenus::ms_ColorPickerID; +int CMenus::ms_HuePickerID; + float CMenus::ms_ButtonHeight = 25.0f; float CMenus::ms_ListheaderHeight = 17.0f; float CMenus::ms_FontmodHeight = 0.8f; @@ -1143,6 +1147,143 @@ bool CMenus::CanDisplayWarning() return m_Popup == POPUP_NONE; } +void CMenus::RenderColorPicker() +{ + if(!ms_ColorPicker.m_Active) + return; + + // First check if we should disable color picker + CUIRect PickerRect; + PickerRect.x = ms_ColorPicker.m_X; + PickerRect.y = ms_ColorPicker.m_Y; + PickerRect.w = ms_ColorPicker.ms_Width; + PickerRect.h = ms_ColorPicker.ms_Height; + + if(UI()->MouseButtonClicked(0) && !UI()->MouseInside(&PickerRect) && !UI()->MouseInside(&ms_ColorPicker.m_AttachedRect)) + { + ms_ColorPicker.m_Active = false; + return; + } + + // Render + ColorRGBA BackgroundColor(0.1f, 0.1f, 0.1f, 1.0f); + ColorRGBA OutlineColor(0.21f, 0.21f, 0.21f, 1); + RenderTools()->DrawUIRect(&PickerRect, BackgroundColor, 0, 0); + + CUIRect ColorsArea, HueArea, BottomArea, AlphaSliderArea, HexCodeArea; + PickerRect.Margin(3, &ColorsArea); + + ColorsArea.HSplitBottom(ms_ColorPicker.ms_Height - 140.0f, &ColorsArea, &BottomArea); + ColorsArea.VSplitRight(20, &ColorsArea, &HueArea); + + BottomArea.HSplitTop(3, 0x0, &BottomArea); + HueArea.VSplitLeft(3, 0x0, &HueArea); + + BottomArea.HSplitBottom(14, &AlphaSliderArea, &HexCodeArea); + AlphaSliderArea.HSplitBottom(3, &AlphaSliderArea, 0x0); + + RenderTools()->DrawUIRect(&HueArea, OutlineColor, 0, 0); + HueArea.Margin(1, &HueArea); + + RenderTools()->DrawUIRect(&ColorsArea, OutlineColor, 0, 0); + ColorsArea.Margin(1, &ColorsArea); + + ColorHSLA HSLColor(*ms_ColorPicker.m_pColor, false); + ColorHSVA PickerColor = color_cast(HSLColor); + + // Color Area + ColorRGBA rgb; + rgb = color_cast(ColorHSVA(PickerColor.x, 0.0f, 1.0f)); + vec4 TL(rgb.r, rgb.g, rgb.b, 1.0f); + rgb = color_cast(ColorHSVA(PickerColor.x, 1.0f, 1.0f)); + vec4 TR(rgb.r, rgb.g, rgb.b, 1.0f); + rgb = color_cast(ColorHSVA(PickerColor.x, 0.0f, 1.0f)); + vec4 BL(rgb.r, rgb.g, rgb.b, 1.0f); + rgb = color_cast(ColorHSVA(PickerColor.x, 1.0f, 1.0f)); + vec4 BR(rgb.r, rgb.g, rgb.b, 1.0f); + + RenderTools()->DrawUIRect4NoRounding(&ColorsArea, TL, TR, BL, BR); + + TL = vec4(0.0f, 0.0f, 0.0f, 0.0f); + TR = vec4(0.0f, 0.0f, 0.0f, 0.0f); + BL = vec4(0.0f, 0.0f, 0.0f, 1.0f); + BR = vec4(0.0f, 0.0f, 0.0f, 1.0f); + + RenderTools()->DrawUIRect4NoRounding(&ColorsArea, TL, TR, BL, BR); + + // Hue Area + static const float s_aColorIndices[7][3] = { + {1.0f, 0.0f, 0.0f}, // red + {1.0f, 0.0f, 1.0f}, // magenta + {0.0f, 0.0f, 1.0f}, // blue + {0.0f, 1.0f, 1.0f}, // cyan + {0.0f, 1.0f, 0.0f}, // green + {1.0f, 1.0f, 0.0f}, // yellow + {1.0f, 0.0f, 0.0f} // red + }; + + float HuePickerOffset = HueArea.h / 6.0f; + CUIRect HuePartialArea = HueArea; + HuePartialArea.h = HuePickerOffset; + + for(int j = 0; j < 6; j++) + { + TL = vec4(s_aColorIndices[j][0], s_aColorIndices[j][1], s_aColorIndices[j][2], 1.0f); + BL = vec4(s_aColorIndices[j + 1][0], s_aColorIndices[j + 1][1], s_aColorIndices[j + 1][2], 1.0f); + + HuePartialArea.y = HueArea.y + HuePickerOffset * j; + RenderTools()->DrawUIRect4NoRounding(&HuePartialArea, TL, TL, BL, BL); + } + + //Hex Code Area FIX <<<<<< + rgb = color_cast(PickerColor); + char Hex[16]; + + str_format(Hex, sizeof(Hex), "#%06X", rgb.Pack(false)); + + static float HexID = 0; + DoEditBox(&HexID, &HexCodeArea, Hex, sizeof(Hex), 12.0f, &HexID); + + // Logic + float PickerX, PickerY; + bool PickerClicked = false; + + if(UI()->HotItem() != &ms_HuePickerID) + { + if(UI()->DoPickerLogic(&ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) + { + PickerColor.y = PickerX / ColorsArea.w; + PickerColor.z = 1.0f - PickerY / ColorsArea.h; + PickerClicked = true; + } + } + + if(UI()->HotItem() != &ms_ColorPickerID) + { + if(UI()->DoPickerLogic(&ms_HuePickerID, &HueArea, &PickerX, &PickerY)) + { + PickerColor.x = 1.0f - PickerY / HueArea.h; + PickerClicked = true; + } + } + + // Marker Color Area + float MarkerX = ColorsArea.x + ColorsArea.w * PickerColor.y; + float MarkerY = ColorsArea.y + ColorsArea.h * (1.0f - PickerColor.z); + + int MarkerOutlineInd = PickerColor.z > 0.5f ? 0.0f : 1.0f; + ColorRGBA MarkerOutline(MarkerOutlineInd, MarkerOutlineInd, MarkerOutlineInd, 1.0f); + + Graphics()->QuadsBegin(); + Graphics()->SetColor(MarkerOutline); + RenderTools()->DrawCircle(MarkerX, MarkerY, 5.0f, 32); + Graphics()->SetColor(rgb); + RenderTools()->DrawCircle(MarkerX, MarkerY, 4.0f, 32); + Graphics()->QuadsEnd(); + + *ms_ColorPicker.m_pColor = color_cast(PickerColor).Pack(false); +} + int CMenus::Render() { if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_Popup == POPUP_NONE) @@ -1288,6 +1429,9 @@ int CMenus::Render() else if(m_MenuPage == PAGE_SETTINGS) { RenderSettings(MainView); + + // Render Color Picker only on settings page and last + RenderColorPicker(); } // do tab bar diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 797c4f8b7..ee6b9ae98 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -24,6 +24,21 @@ struct CServerProcess CLineReader LineReader; }; +struct SColorPicker +{ +public: + const float ms_Width = 160.0f; + const float ms_Height = 200.0f; + + float m_X; + float m_Y; + + bool m_Active; + + CUIRect m_AttachedRect; + unsigned int *m_pColor; +}; + // compnent to fetch keypresses, override all other input class CMenusKeyBinder : public CComponent { @@ -49,6 +64,10 @@ class CMenus : public CComponent static ColorRGBA ms_ColorTabbarActive; static ColorRGBA ms_ColorTabbarHover; + static SColorPicker ms_ColorPicker; + static int ms_ColorPickerID; + static int ms_HuePickerID; + char m_aLocalStringHelper[1024]; float ButtonColorMulActive() { return 0.5f; } @@ -94,6 +113,8 @@ class CMenus : public CComponent //static int ui_do_key_reader(void *id, const CUIRect *rect, int key); void UiDoGetButtons(int Start, int Stop, CUIRect View, CUIRect ScopeView); + void RenderColorPicker(); + // new gui with gui elements template int DoButtonMenu(CUIElement &UIElement, const void *pID, T &&GetTextLambda, int Checked, const CUIRect *pRect, bool HintRequiresStringCheck, bool HintCanChangePositionOrSize = false, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1) @@ -634,6 +655,7 @@ private: // found in menus_settings.cpp void RenderSettingsDDNet(CUIRect MainView); void RenderSettingsHUD(CUIRect MainView); + ColorHSLA RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, bool Alpha); ColorHSLA RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha = false); CServerProcess m_ServerProcess; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 35879ea27..daa07033c 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1564,6 +1564,55 @@ void CMenus::RenderSettings(CUIRect MainView) UI()->DoLabelScaled(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, -1); } +ColorHSLA CMenus::RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, bool Alpha) +{ + ColorHSLA HSLColor(*pColor, false); + ColorRGBA RGBColor = color_cast(HSLColor); + + float OutlineCol = UI()->MouseInside(pRect) ? 0.7f : 0.5f; + + ColorRGBA Outline(OutlineCol, OutlineCol, OutlineCol, 1); + + const float OutlineSize = 2.0f; + + CUIRect Rect; + pRect->Margin(OutlineSize, &Rect); + + RenderTools()->DrawUIRect(pRect, Outline, 0, 0); + RenderTools()->DrawUIRect(&Rect, RGBColor, 0, 0); + + if(UI()->DoButtonLogic(pColor, 0, pRect)) + { + if(ms_ColorPicker.m_Active) + { + CUIRect PickerRect; + PickerRect.x = ms_ColorPicker.m_X; + PickerRect.y = ms_ColorPicker.m_Y; + PickerRect.w = ms_ColorPicker.ms_Width; + PickerRect.h = ms_ColorPicker.ms_Height; + + if(ms_ColorPicker.m_pColor != pColor && !UI()->MouseInside(&PickerRect)) + { + ms_ColorPicker.m_X = UI()->MouseX(); + ms_ColorPicker.m_Y = UI()->MouseY(); + ms_ColorPicker.m_pColor = pColor; + ms_ColorPicker.m_Active = true; + ms_ColorPicker.m_AttachedRect = *pRect; + } + } + else + { + ms_ColorPicker.m_X = UI()->MouseX(); + ms_ColorPicker.m_Y = UI()->MouseY(); + ms_ColorPicker.m_pColor = pColor; + ms_ColorPicker.m_Active = true; + ms_ColorPicker.m_AttachedRect = *pRect; + } + } + + return HSLColor; +} + ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha) { ColorHSLA Color(*pColor, Alpha); @@ -1591,9 +1640,12 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) { static int pIDP1 = 0, pIDP2 = 0; static int Page = 1; - CUIRect Left, Right, HUD, Messages, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable, Heart; + CUIRect Left, Right, HUD, Chat, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable, Heart; - MainView.HSplitTop(150.0f, &HUD, &MainView); + MainView.VSplitMid(&HUD, &Chat); + + ColorRGBA test(1, 1, 1, 0.1f); + RenderTools()->DrawUIRect(&MainView, test, 0, 0); HUD.HSplitTop(30.0f, &Label, &HUD); float tw = TextRender()->TextWidth(0, 20.0f, Localize("HUD"), -1, -1.0f); @@ -1631,13 +1683,13 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) g_Config.m_ClShowIDs ^= 1; } - Right.HSplitTop(20.0f, &Button, &Right); + Left.HSplitTop(20.0f, &Button, &Left); if(DoButton_CheckBox(&g_Config.m_ClShowhudScore, Localize("Show score"), g_Config.m_ClShowhudScore, &Button)) { g_Config.m_ClShowhudScore ^= 1; } - Right.HSplitTop(20.0f, &Button, &Right); + Left.HSplitTop(20.0f, &Button, &Left); if(DoButton_CheckBox(&g_Config.m_ClShowhudHealthAmmo, Localize("Show health + ammo"), g_Config.m_ClShowhudHealthAmmo, &Button)) { g_Config.m_ClShowhudHealthAmmo ^= 1; @@ -1649,9 +1701,32 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) g_Config.m_ClShowChat ^= 1; } - bool IsOldChat = !(g_Config.m_ClChatTee || g_Config.m_ClChatBackground); + Left.HSplitTop(20.0f, &Button, &Left); + if(DoButton_CheckBox(&g_Config.m_ClChatTeamColors, Localize("Show names in chat in team colors"), g_Config.m_ClChatTeamColors, &Button)) + { + g_Config.m_ClChatTeamColors ^= 1; + } Left.HSplitTop(20.0f, &Button, &Left); + if(DoButton_CheckBox(&g_Config.m_ClShowKillMessages, Localize("Show kill messages"), g_Config.m_ClShowKillMessages, &Button)) + { + g_Config.m_ClShowKillMessages ^= 1; + } + + Left.HSplitTop(20.0f, &Button, &Left); + if(DoButton_CheckBox(&g_Config.m_ClShowVotesAfterVoting, Localize("Show votes window after voting"), g_Config.m_ClShowVotesAfterVoting, &Button)) + { + g_Config.m_ClShowVotesAfterVoting ^= 1; + } + + // Chat + + Chat.HSplitTop(30.0f, &Label, &Chat); + UI()->DoLabelScaled(&Label, Localize("Chat"), 20.0f, -1); + + bool IsOldChat = !(g_Config.m_ClChatTee || g_Config.m_ClChatBackground); + + Chat.HSplitTop(20.0f, &Button, &Chat); if(DoButton_CheckBox(&g_Config.m_ClChatTee, Localize("Use old chat style"), IsOldChat, &Button)) { if(IsOldChat) @@ -1666,32 +1741,18 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) } GameClient()->m_pChat->RebuildChat(); } - - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_CheckBox(&g_Config.m_ClChatTeamColors, Localize("Show names in chat in team colors"), g_Config.m_ClChatTeamColors, &Button)) - { - g_Config.m_ClChatTeamColors ^= 1; - } - - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_CheckBox(&g_Config.m_ClShowKillMessages, Localize("Show kill messages"), g_Config.m_ClShowKillMessages, &Button)) - { - g_Config.m_ClShowKillMessages ^= 1; - } - - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_CheckBox(&g_Config.m_ClShowVotesAfterVoting, Localize("Show votes window after voting"), g_Config.m_ClShowVotesAfterVoting, &Button)) - { - g_Config.m_ClShowVotesAfterVoting ^= 1; - } - MainView.HSplitTop(170.0f, &Messages, &MainView); - Messages.HSplitTop(30.0f, &Label, &Messages); - Label.VSplitMid(&Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Messages"), 20.0f, -1); - Messages.Margin(5.0f, &Messages); - Messages.VSplitMid(&Left, &Right); + /* + Right.HSplitTop(170.0f, &Chat, &MainView); + Chat.HSplitTop(30.0f, &Label, &Chat); + UI()->DoLabelScaled(&Label, Localize("Chat"), 20.0f, -1); + Chat.Margin(5.0f, &Chat); + Chat.VSplitMid(&Left, &Right); + Left = Right; Left.VSplitRight(5.0f, &Left, 0); Right.VMargin(5.0f, &Right); + */ + /* + { char aBuf[64]; Left.HSplitTop(20.0f, &Label, &Left); @@ -1700,6 +1761,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) if(DoButton_CheckBox(&g_Config.m_ClShowChatSystem, "", g_Config.m_ClShowChatSystem, &Enable)) g_Config.m_ClShowChatSystem ^= 1; + UI()->DoLabelScaled(&Label, Localize("System message"), 16.0f, -1); { static int s_DefaultButton = 0; @@ -1710,11 +1772,16 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) } } - ColorHSLA SMColor = RenderHSLScrollbars(&Left, &g_Config.m_ClMessageSystemColor); + CUIRect PickerRect; + Left.HSplitTop(5.0f, 0x0, &Left); + Left.HSplitTop(25.0f, &PickerRect, &Left); + PickerRect.w = 25.0f; + + ColorHSLA SMColor = RenderHSLColorPicker(&PickerRect, &g_Config.m_ClMessageSystemColor, false); + ColorRGBA rgb = color_cast(SMColor); Left.HSplitTop(10.0f, &Label, &Left); - ColorRGBA rgb = color_cast(SMColor); TextRender()->TextColor(rgb); char aName[16]; @@ -1896,7 +1963,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) UI()->DoLabelScaled(&Label, "*** Dynamic camera activated", 12.0f, -1); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); Right.HSplitTop(20.0f, 0, &Right); - } + }*/ } else if(Page == 2) { diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 00ad48678..f01a8b3f0 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -508,6 +508,19 @@ void CRenderTools::DrawUIRect4(const CUIRect *r, vec4 ColorTopLeft, vec4 ColorTo Graphics()->QuadsEnd(); } +void CRenderTools::DrawUIRect4NoRounding(const CUIRect *r, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight) +{ + Graphics()->TextureClear(); + + Graphics()->QuadsBegin(); + + Graphics()->SetColor4(ColorTopLeft, ColorTopRight, ColorBottomLeft, ColorBottomRight); + IGraphics::CQuadItem ItemQ = IGraphics::CQuadItem(r->x, r->y, r->w, r->h); + Graphics()->QuadsDrawTL(&ItemQ, 1); + + Graphics()->QuadsEnd(); +} + void CRenderTools::DrawCircle(float x, float y, float r, int Segments) { IGraphics::CFreeformItem Array[32]; diff --git a/src/game/client/render.h b/src/game/client/render.h index d88ee34b6..7a18e4cb0 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -89,6 +89,7 @@ public: void DrawUIRect(const CUIRect *pRect, ColorRGBA Color, int Corners, float Rounding); void DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding); + void DrawUIRect4NoRounding(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight); void DrawCircle(float x, float y, float r, int Segments); From 94e227c8c3c58922a23ed0ede00f4583baa97ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Thu, 29 Oct 2020 03:55:01 +0300 Subject: [PATCH 02/12] Color picker: Settings UI + Picker Logic, Editboxes left --- src/engine/client/text.cpp | 6 + src/engine/textrender.h | 1 + src/game/client/components/chat.h | 14 +- src/game/client/components/menus.cpp | 170 ++++- src/game/client/components/menus.h | 12 +- src/game/client/components/menus_settings.cpp | 705 +++++++----------- src/game/client/ui.h | 1 + 7 files changed, 447 insertions(+), 462 deletions(-) diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp index bf74d699c..d8bc37cdf 100644 --- a/src/engine/client/text.cpp +++ b/src/engine/client/text.cpp @@ -775,6 +775,12 @@ public: pCursor->m_Y += y; } + virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) + { + pCursor->m_X = x; + pCursor->m_Y = y; + } + virtual void Text(void *pFontSetV, float x, float y, float Size, const char *pText, float LineWidth) { CTextCursor Cursor; diff --git a/src/engine/textrender.h b/src/engine/textrender.h index e791d0d00..6c0517f3e 100644 --- a/src/engine/textrender.h +++ b/src/engine/textrender.h @@ -85,6 +85,7 @@ class ITextRender : public IInterface public: virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) = 0; virtual void MoveCursor(CTextCursor *pCursor, float x, float y) = 0; + virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) = 0; virtual CFont *LoadFont(const char *pFilename, const unsigned char *pBuf, size_t Size) = 0; virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size) = 0; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 316010146..ea1764cbb 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -11,13 +11,6 @@ class CChat : public CComponent { CLineInput m_Input; - static constexpr float MESSAGE_PADDING_X = 5.0f; - static constexpr float MESSAGE_TEE_SIZE = 8.0f; - static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f; - static constexpr float FONT_SIZE = 6.0f; - static constexpr float MESSAGE_PADDING_Y = 3.f; - static_assert(FONT_SIZE + MESSAGE_PADDING_Y >= 8.0f, "Corners for background chat are too huge for this combination of font size and message padding."); - enum { MAX_LINES = 25 @@ -119,6 +112,13 @@ class CChat : public CComponent public: CChat(); + static constexpr float MESSAGE_PADDING_X = 5.0f; + static constexpr float MESSAGE_TEE_SIZE = 8.0f; + static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f; + static constexpr float FONT_SIZE = 6.0f; + static constexpr float MESSAGE_PADDING_Y = 3.f; + static_assert(FONT_SIZE + MESSAGE_PADDING_Y >= 8.0f, "Corners for background chat are too huge for this combination of font size and message padding."); + bool IsActive() const { return m_Mode != MODE_NONE; } void AddLine(int ClientID, int Team, const char *pLine); void EnableMode(int Team); diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 5d68a2d75..e66d596f1 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -159,11 +159,28 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, return Active ? UI()->DoButtonLogic(pID, "", Checked, pRect) : 0; } -int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically) +int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, int AlignVertically, bool CheckForActiveColorPicker) { CUIRect Text = *pRect; - Color.a *= ButtonColorMul(pID); + bool MouseInsideColorPicker = false; + + if(CheckForActiveColorPicker) + { + if(ms_ColorPicker.m_Active) + { + CUIRect PickerRect; + PickerRect.x = ms_ColorPicker.m_X; + PickerRect.y = ms_ColorPicker.m_Y; + PickerRect.w = ms_ColorPicker.ms_Width; + PickerRect.h = ms_ColorPicker.ms_Height; + + MouseInsideColorPicker = UI()->MouseInside(&PickerRect); + } + } + + if(!MouseInsideColorPicker) + Color.a *= ButtonColorMul(pID); RenderTools()->DrawUIRect(pRect, Color, Corners, r); if(pImageName) @@ -189,6 +206,10 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text); Text.HMargin((Text.h * FontFactor) / 2.0f, &Text); UI()->DoLabel(&Text, pText, Text.h * ms_FontmodHeight, 0, -1, AlignVertically); + + if(MouseInsideColorPicker) + return 0; + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } @@ -273,6 +294,120 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c return UI()->DoButtonLogic(pID, pText, 0, pRect); } +void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineColor, const ColorHSLA LaserInnerColor) +{ + ColorRGBA LaserRGB; + CUIRect Section = *pRect; + vec2 From = vec2(Section.x, Section.y + Section.h / 2.0f); + vec2 Pos = vec2(Section.x + Section.w - 10.0f, Section.y + Section.h / 2.0f); + + vec2 Out, Border; + + Graphics()->BlendNormal(); + Graphics()->TextureClear(); + Graphics()->QuadsBegin(); + + LaserRGB = color_cast(LaserOutlineColor); + ColorRGBA OuterColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f); + Graphics()->SetColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f); + Out = vec2(0.0f, -1.0f) * (3.15f); + + IGraphics::CFreeformItem Freeform(From.x - Out.x, From.y - Out.y, From.x + Out.x, From.y + Out.y, Pos.x - Out.x, Pos.y - Out.y, Pos.x + Out.x, Pos.y + Out.y); + Graphics()->QuadsDrawFreeform(&Freeform, 1); + + LaserRGB = color_cast(LaserInnerColor); + ColorRGBA InnerColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f); + Out = vec2(0.0f, -1.0f) * (2.25f); + Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); + + Freeform = IGraphics::CFreeformItem(From.x - Out.x, From.y - Out.y, From.x + Out.x, From.y + Out.y, Pos.x - Out.x, Pos.y - Out.y, Pos.x + Out.x, Pos.y + Out.y); + Graphics()->QuadsDrawFreeform(&Freeform, 1); + Graphics()->QuadsEnd(); + + Graphics()->BlendNormal(); + int SpriteIndex = time_get() % 3; + Graphics()->TextureSet(GameClient()->m_ParticlesSkin.m_SpriteParticleSplat[SpriteIndex]); + Graphics()->QuadsBegin(); + Graphics()->QuadsSetRotation(time_get()); + Graphics()->SetColor(OuterColor.r, OuterColor.g, OuterColor.b, 1.0f); + IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 24, 24); + Graphics()->QuadsDraw(&QuadItem, 1); + Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); + QuadItem = IGraphics::CQuadItem(Pos.x, Pos.y, 20, 20); + Graphics()->QuadsDraw(&QuadItem, 1); + Graphics()->QuadsEnd(); + + Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteWeaponLaser); + Graphics()->QuadsBegin(); + RenderTools()->SelectSprite(SPRITE_WEAPON_LASER_BODY); + Graphics()->QuadsSetSubset(0, 0, 1, 1); + RenderTools()->DrawSprite(Section.x, Section.y + Section.h / 2.0f, 60.0f); + Graphics()->QuadsEnd(); +} + +ColorHSLA CMenus::DoLine_ColorPicker(int *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing, bool UseCheckBox, int *pCheckBoxValue) +{ + CUIRect Section, Button, Label; + + pMainRect->HSplitTop(LineSize, &Section, pMainRect); + pMainRect->HSplitTop(BottomMargin, 0x0, pMainRect); + + float SectionWidth = Section.w; + + if(CheckBoxSpacing || UseCheckBox) + Section.VSplitLeft(20.0f, &Button, &Section); + + if(UseCheckBox) + { + CUIRect CheckBox; + Button.Margin(2.0f, &CheckBox); + + if(DoButton_CheckBox(pCheckBoxValue, "", *pCheckBoxValue, &CheckBox)) + *pCheckBoxValue ^= 1; + } + + Section.VSplitLeft(5.0f, 0x0, &Section); + float LabelWidth = TextRender()->TextWidth(0, 14.0f, pText, -1, -1.0f); + Section.VSplitLeft(LabelWidth, &Label, &Section); + + UI()->DoLabelScaled(&Label, pText, LabelSize, -1); + + float Cut = WantedPickerPosition - (SectionWidth - Section.w); + if(Cut < 5) + Cut = 5.0f; + + Section.VSplitLeft(Cut, 0x0, &Section); + Section.VSplitLeft(LineSize, &Button, &Section); + + ColorHSLA PickedColor = RenderHSLColorPicker(&Button, pColorValue, false); + + Section.VSplitLeft(7.5f, 0x0, &Section); + Section.VSplitLeft(55.0f, &Button, &Section); + Button.HSplitTop(2.0f, 0x0, &Button); + Button.HSplitBottom(2.0f, &Button, 0x0); + + if(DoButton_Menu(pResetID, Localize("Reset"), 0, &Button, 0, CUI::CORNER_ALL, 8.0f, 0, vec4(1, 1, 1, 0.5f), vec4(1, 1, 1, 0.25f), 1, true)) + { + ColorHSLA HSL = color_cast(DefaultColor); + *pColorValue = HSL.Pack(false); + } + + return PickedColor; +} + +int CMenus::DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin) +{ + CUIRect CheckBoxRect; + pRect->HSplitTop(VMargin, &CheckBoxRect, pRect); + + int Logic = DoButton_CheckBox_Common(pID, pText, *pValue ? "X" : "", &CheckBoxRect); + + if(Logic) + *pValue ^= 1; + + return Logic; +} + int CMenus::DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect) { return DoButton_CheckBox_Common(pID, pText, Checked ? "X" : "", pRect); @@ -1158,16 +1293,16 @@ void CMenus::RenderColorPicker() PickerRect.y = ms_ColorPicker.m_Y; PickerRect.w = ms_ColorPicker.ms_Width; PickerRect.h = ms_ColorPicker.ms_Height; - - if(UI()->MouseButtonClicked(0) && !UI()->MouseInside(&PickerRect) && !UI()->MouseInside(&ms_ColorPicker.m_AttachedRect)) + + if(UI()->MouseButtonReleased(1) || (UI()->MouseButtonClicked(0) && !UI()->MouseInside(&PickerRect) && !UI()->MouseInside(&ms_ColorPicker.m_AttachedRect))) { ms_ColorPicker.m_Active = false; return; } // Render - ColorRGBA BackgroundColor(0.1f, 0.1f, 0.1f, 1.0f); - ColorRGBA OutlineColor(0.21f, 0.21f, 0.21f, 1); + ColorRGBA BackgroundColor(0.15f, 0.15f, 0.15f, 1.0f); + ColorRGBA OutlineColor(0.25f, 0.25f, 0.25f, 1); RenderTools()->DrawUIRect(&PickerRect, BackgroundColor, 0, 0); CUIRect ColorsArea, HueArea, BottomArea, AlphaSliderArea, HexCodeArea; @@ -1188,8 +1323,7 @@ void CMenus::RenderColorPicker() RenderTools()->DrawUIRect(&ColorsArea, OutlineColor, 0, 0); ColorsArea.Margin(1, &ColorsArea); - ColorHSLA HSLColor(*ms_ColorPicker.m_pColor, false); - ColorHSVA PickerColor = color_cast(HSLColor); + ColorHSVA PickerColor = ms_ColorPicker.m_HSVColor; // Color Area ColorRGBA rgb; @@ -1246,7 +1380,6 @@ void CMenus::RenderColorPicker() // Logic float PickerX, PickerY; - bool PickerClicked = false; if(UI()->HotItem() != &ms_HuePickerID) { @@ -1254,17 +1387,13 @@ void CMenus::RenderColorPicker() { PickerColor.y = PickerX / ColorsArea.w; PickerColor.z = 1.0f - PickerY / ColorsArea.h; - PickerClicked = true; } } if(UI()->HotItem() != &ms_ColorPickerID) { if(UI()->DoPickerLogic(&ms_HuePickerID, &HueArea, &PickerX, &PickerY)) - { PickerColor.x = 1.0f - PickerY / HueArea.h; - PickerClicked = true; - } } // Marker Color Area @@ -1281,6 +1410,21 @@ void CMenus::RenderColorPicker() RenderTools()->DrawCircle(MarkerX, MarkerY, 4.0f, 32); Graphics()->QuadsEnd(); + + // Marker Hue Area + CUIRect HueMarker; + HueArea.Margin(-2.5f, &HueMarker); + HueMarker.h = 5.0f; + HueMarker.y = (HueArea.y + HueArea.h * (1.0f - PickerColor.x)) - HueMarker.h / 2.0f; + + ColorRGBA HueMarkerOutline(1 * PickerColor.x, 1 * PickerColor.x, 1 * PickerColor.x, 1); + ColorRGBA HueMarkerColor = color_cast(ColorHSVA(PickerColor.x, 1, 1, 1)); + + RenderTools()->DrawUIRect(&HueMarker, HueMarkerOutline, 0, 0); + HueMarker.Margin(1, &HueMarker); + RenderTools()->DrawUIRect(&HueMarker, HueMarkerColor, 0, 0); + + ms_ColorPicker.m_HSVColor = PickerColor; *ms_ColorPicker.m_pColor = color_cast(PickerColor).Pack(false); } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index ee6b9ae98..40e470477 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -30,6 +30,9 @@ public: const float ms_Width = 160.0f; const float ms_Height = 200.0f; + static int ms_ColorPickerID; + static int ms_HuePickerID; + float m_X; float m_Y; @@ -37,6 +40,7 @@ public: CUIRect m_AttachedRect; unsigned int *m_pColor; + ColorHSVA m_HSVColor; }; // compnent to fetch keypresses, override all other input @@ -78,13 +82,15 @@ class CMenus : public CComponent int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); - int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = 0, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1); + int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = 0, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); + int DoButton_CheckBoxAutoVMarginAndSet(const void *pID, const char *pText, int *pValue, CUIRect *pRect, float VMargin); int DoButton_CheckBox_Number(const void *pID, const char *pText, int Checked, const CUIRect *pRect); - + ColorHSLA DoLine_ColorPicker(int *pResetID, const float LineSize, const float WantedPickerPosition, const float LabelSize, const float BottomMargin, CUIRect *pMainRect, const char *pText, unsigned int *pColorValue, const ColorRGBA DefaultColor, bool CheckBoxSpacing = true, bool UseCheckBox = false, int *pCheckBoxValue = NULL); + void DoLaserPreview(const CUIRect *pRect, const ColorHSLA OutlineColor, const ColorHSLA InnerColor); /*static void ui_draw_menu_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); static void ui_draw_keyselect_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); static void ui_draw_menu_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); @@ -655,7 +661,7 @@ private: // found in menus_settings.cpp void RenderSettingsDDNet(CUIRect MainView); void RenderSettingsHUD(CUIRect MainView); - ColorHSLA RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, bool Alpha); + ColorHSLA RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha); ColorHSLA RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha = false); CServerProcess m_ServerProcess; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index daa07033c..851a2d6d6 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1564,22 +1564,20 @@ void CMenus::RenderSettings(CUIRect MainView) UI()->DoLabelScaled(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, -1); } -ColorHSLA CMenus::RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, bool Alpha) +ColorHSLA CMenus::RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha) { ColorHSLA HSLColor(*pColor, false); ColorRGBA RGBColor = color_cast(HSLColor); - - float OutlineCol = UI()->MouseInside(pRect) ? 0.7f : 0.5f; - - ColorRGBA Outline(OutlineCol, OutlineCol, OutlineCol, 1); - - const float OutlineSize = 2.0f; + + ColorRGBA Outline(1, 1, 1, 0.25f); + const float OutlineSize = 2.5f; + Outline.a *= ButtonColorMul(pColor); CUIRect Rect; pRect->Margin(OutlineSize, &Rect); - RenderTools()->DrawUIRect(pRect, Outline, 0, 0); - RenderTools()->DrawUIRect(&Rect, RGBColor, 0, 0); + RenderTools()->DrawUIRect(pRect, Outline, CUI::CORNER_ALL, 4.0f); + RenderTools()->DrawUIRect(&Rect, RGBColor, CUI::CORNER_ALL, 4.0f); if(UI()->DoButtonLogic(pColor, 0, pRect)) { @@ -1598,6 +1596,7 @@ ColorHSLA CMenus::RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, boo ms_ColorPicker.m_pColor = pColor; ms_ColorPicker.m_Active = true; ms_ColorPicker.m_AttachedRect = *pRect; + ms_ColorPicker.m_HSVColor = color_cast(HSLColor); } } else @@ -1607,6 +1606,7 @@ ColorHSLA CMenus::RenderHSLColorPicker(CUIRect *pRect, unsigned int *pColor, boo ms_ColorPicker.m_pColor = pColor; ms_ColorPicker.m_Active = true; ms_ColorPicker.m_AttachedRect = *pRect; + ms_ColorPicker.m_HSVColor = color_cast(HSLColor); } } @@ -1638,459 +1638,286 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool void CMenus::RenderSettingsHUD(CUIRect MainView) { - static int pIDP1 = 0, pIDP2 = 0; - static int Page = 1; - CUIRect Left, Right, HUD, Chat, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable, Heart; + CUIRect HUD, Chat, Section, SectionTwo; MainView.VSplitMid(&HUD, &Chat); - ColorRGBA test(1, 1, 1, 0.1f); - RenderTools()->DrawUIRect(&MainView, test, 0, 0); + HUD.HSplitTop(30.0f, &Section, &HUD); + UI()->DoLabelScaled(&Section, Localize("HUD"), 20.0f, -1); + HUD.VSplitLeft(5.0f, 0x0, &HUD); + HUD.HSplitTop(5.0f, 0x0, &HUD); - HUD.HSplitTop(30.0f, &Label, &HUD); - float tw = TextRender()->TextWidth(0, 20.0f, Localize("HUD"), -1, -1.0f); - Label.VSplitLeft(tw + 10.0f, &Label, &Page1Tab); - Page1Tab.VSplitLeft(60.0f, &Page1Tab, 0); - Page1Tab.VSplitLeft(30.0f, &Page1Tab, &Page2Tab); + Chat.HSplitTop(30.0f, &Section, &Chat); + UI()->DoLabelScaled(&Section, Localize("Chat"), 20.0f, -1); + Chat.VSplitLeft(5.0f, 0x0, &Chat); + Chat.HSplitTop(5.0f, 0x0, &Chat); - UI()->DoLabelScaled(&Label, Localize("HUD"), 20.0f, -1); - if(DoButton_MenuTab((void *)&pIDP1, "1", Page == 1, &Page1Tab, 5)) - Page = 1; - if(DoButton_MenuTab((void *)&pIDP2, "2", Page == 2, &Page2Tab, 10)) - Page = 2; + const float LineMargin = 20.0f; - HUD.Margin(5.0f, &HUD); - HUD.VSplitMid(&Left, &Right); - Left.VSplitRight(5.0f, &Left, 0); - Right.VMargin(5.0f, &Right); + // ***** HUD ***** // - if(Page == 1) + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowhud, Localize("Show ingame HUD"), &g_Config.m_ClShowhud, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClDDRaceScoreBoard, Localize("Use DDRace Scoreboard"), &g_Config.m_ClDDRaceScoreBoard, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowIDs, Localize("Show client IDs"), &g_Config.m_ClShowIDs, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowhudScore, Localize("Show score"), &g_Config.m_ClShowhudScore, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowhudHealthAmmo, Localize("Show health + ammo"), &g_Config.m_ClShowhudHealthAmmo, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowChat, Localize("Show chat"), &g_Config.m_ClShowChat, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatTeamColors, Localize("Show names in chat in team colors"), &g_Config.m_ClChatTeamColors, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowKillMessages, Localize("Show kill messages"), &g_Config.m_ClShowKillMessages, &HUD, LineMargin); + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowVotesAfterVoting, Localize("Show votes window after voting"), &g_Config.m_ClShowVotesAfterVoting, &HUD, LineMargin); + + // Laser + + HUD.HSplitTop(15.0f, 0x0, &HUD); + HUD.HSplitTop(50.0f, &Section, &HUD); + Section.VSplitRight(110.0f, &Section, 0x0); + HUD.HSplitTop(25.0f, &SectionTwo, &HUD); + + static int LasterOutResetID, LaserInResetID; + + ColorHSLA LaserOutlineColor = DoLine_ColorPicker(&LasterOutResetID, 25.0f, 194.0f, 13.0f, 5.0f, &SectionTwo, Localize("Laser Outline Color"), &g_Config.m_ClLaserOutlineColor, ColorRGBA(0.074402f, 0.074402f, 0.247166f, 1.0f), false); + + HUD.HSplitTop(5.0f, 0x0, &HUD); + HUD.HSplitTop(25.0f, &SectionTwo, &HUD); + + ColorHSLA LaserInnerColor = DoLine_ColorPicker(&LaserInResetID, 25.0f, 194.0f, 13.0f, 5.0f, &SectionTwo, Localize("Laser Inner Color"), &g_Config.m_ClLaserInnerColor, ColorRGBA(0.498039f, 0.498039f, 1.0f, 1.0f), false); + + Section.VSplitLeft(30.0f, 0, &Section); + + DoLaserPreview(&Section, LaserOutlineColor, LaserInnerColor); + + // ***** Chat ***** // + + if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatTee, Localize("Show Tee icons in chat"), &g_Config.m_ClChatTee, &Chat, LineMargin)) + GameClient()->m_pChat->RebuildChat(); + + if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatBackground, Localize("Show backgrounds for chat messages"), &g_Config.m_ClChatBackground, &Chat, LineMargin)) + GameClient()->m_pChat->RebuildChat(); + + Chat.HSplitTop(30.0f, 0x0, &Chat); + + // Message Colors and extra + + Chat.HSplitTop(20.0f, &Section, &Chat); + Chat.HSplitTop(10.0f, 0x0, &Chat); + + UI()->DoLabelScaled(&Section, Localize("Messages"), 20.0f, -1); + + const float LineSize = 25.0f; + const float WantedPickerPosition = 194.0f; + const float LabelSize = 13.0f; + const float LineSpacing = 5.0f; + + char aBuf[64]; + + int i = 0; + static int ResetIDs[24]; + + + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("System message"), &g_Config.m_ClMessageSystemColor, ColorRGBA(1.0f, 1.0f, 0.5f), true, true, &g_Config.m_ClShowChatSystem); + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("Highlighted message"), &g_Config.m_ClMessageHighlightColor, ColorRGBA(1.0f, 0.5f, 0.5f)); + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("Team message"), &g_Config.m_ClMessageTeamColor, ColorRGBA(0.65f, 1.0f, 0.65f)); + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("Friend message"), &g_Config.m_ClMessageFriendColor, ColorRGBA(1.0f, 0.137f, 0.137f), true, true, & g_Config.m_ClMessageFriend); + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("Normal message"), &g_Config.m_ClMessageColor, ColorRGBA(1.0f, 1.0f, 1.0f)); + + str_format(aBuf, sizeof(aBuf), "%s (echo)", Localize("Client message")); + DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, aBuf, &g_Config.m_ClMessageClientColor, ColorRGBA(0.5f, 0.78f, 1.0f)); + + + // ***** Chat Preview ***** // + + Chat.HSplitTop(10.0f, 0x0, &Chat); + Chat.HSplitTop(20.0f, &Section, &Chat); + + UI()->DoLabelScaled(&Section, Localize("Preview"), 20.0f, -1); + + Chat.HSplitTop(10.0f, 0x0, &Chat); + Chat.VSplitRight(100.0f, &Chat, 0x0); + RenderTools()->DrawUIRect(&Chat, ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f), CUI::CORNER_ALL, 8.0f); + Chat.HSplitTop(10.0f, 0x0, &Chat); + + ColorRGBA SystemColor = color_cast(ColorHSLA(g_Config.m_ClMessageSystemColor)); + ColorRGBA HighlightedColor = color_cast(ColorHSLA(g_Config.m_ClMessageHighlightColor)); + ColorRGBA TeamColor = color_cast(ColorHSLA(g_Config.m_ClMessageTeamColor)); + ColorRGBA FriendColor = color_cast(ColorHSLA(g_Config.m_ClMessageFriendColor)); + ColorRGBA NormalColor = color_cast(ColorHSLA(g_Config.m_ClMessageColor)); + ColorRGBA ClientColor = color_cast(ColorHSLA(g_Config.m_ClMessageClientColor)); + ColorRGBA DefaultNameColor(0.8f, 0.8f, 0.8f, 1.0f); + + constexpr float RealFontSize = CChat::FONT_SIZE * 2; + const float RealMsgPaddingX = (g_Config.m_ClChatBackground ? CChat::MESSAGE_PADDING_X : 0) * 2; + const float RealMsgPaddingY = (g_Config.m_ClChatBackground ? CChat::MESSAGE_PADDING_Y : (g_Config.m_ClChatTee ? (CChat::MESSAGE_TEE_SIZE - CChat::FONT_SIZE) : 0)) * 2; + const float RealMsgPaddingTee = (g_Config.m_ClChatTee ? CChat::MESSAGE_TEE_SIZE + CChat::MESSAGE_TEE_PADDING_RIGHT : 0) * 2; + const float RealOffsetY = RealFontSize + RealMsgPaddingY; + + const float X = 5.0f + RealMsgPaddingX / 2.0f + Chat.x; + float Y = Chat.y; + + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, X, Y, RealFontSize, TEXTFLAG_RENDER); + + str_copy(aBuf, Client()->PlayerName(), sizeof(aBuf)); + + // Backgrounds first + if(g_Config.m_ClChatBackground) { - // show hud1 - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowhud, Localize("Show ingame HUD"), g_Config.m_ClShowhud, &Button)) - g_Config.m_ClShowhud ^= 1; - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClDDRaceScoreBoard, Localize("Use DDRace Scoreboard"), g_Config.m_ClDDRaceScoreBoard, &Button)) - { - g_Config.m_ClDDRaceScoreBoard ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowIDs, Localize("Show client IDs in Scoreboard"), g_Config.m_ClShowIDs, &Button)) - { - g_Config.m_ClShowIDs ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowhudScore, Localize("Show score"), g_Config.m_ClShowhudScore, &Button)) - { - g_Config.m_ClShowhudScore ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowhudHealthAmmo, Localize("Show health + ammo"), g_Config.m_ClShowhudHealthAmmo, &Button)) - { - g_Config.m_ClShowhudHealthAmmo ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowChat, Localize("Show chat"), g_Config.m_ClShowChat, &Button)) - { - g_Config.m_ClShowChat ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClChatTeamColors, Localize("Show names in chat in team colors"), g_Config.m_ClChatTeamColors, &Button)) - { - g_Config.m_ClChatTeamColors ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowKillMessages, Localize("Show kill messages"), g_Config.m_ClShowKillMessages, &Button)) - { - g_Config.m_ClShowKillMessages ^= 1; - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClShowVotesAfterVoting, Localize("Show votes window after voting"), g_Config.m_ClShowVotesAfterVoting, &Button)) - { - g_Config.m_ClShowVotesAfterVoting ^= 1; - } - - // Chat - - Chat.HSplitTop(30.0f, &Label, &Chat); - UI()->DoLabelScaled(&Label, Localize("Chat"), 20.0f, -1); - - bool IsOldChat = !(g_Config.m_ClChatTee || g_Config.m_ClChatBackground); - - Chat.HSplitTop(20.0f, &Button, &Chat); - if(DoButton_CheckBox(&g_Config.m_ClChatTee, Localize("Use old chat style"), IsOldChat, &Button)) - { - if(IsOldChat) - { - g_Config.m_ClChatTee = 1; - g_Config.m_ClChatBackground = 1; - } - else - { - g_Config.m_ClChatTee = 0; - g_Config.m_ClChatBackground = 0; - } - GameClient()->m_pChat->RebuildChat(); - } - /* - Right.HSplitTop(170.0f, &Chat, &MainView); - Chat.HSplitTop(30.0f, &Label, &Chat); - UI()->DoLabelScaled(&Label, Localize("Chat"), 20.0f, -1); - Chat.Margin(5.0f, &Chat); - Chat.VSplitMid(&Left, &Right); - Left = Right; - Left.VSplitRight(5.0f, &Left, 0); - Right.VMargin(5.0f, &Right); - */ - /* - - { - char aBuf[64]; - Left.HSplitTop(20.0f, &Label, &Left); - Label.VSplitRight(50.0f, &Label, &Button); - Label.VSplitLeft(25.0f, &Enable, &Label); - - if(DoButton_CheckBox(&g_Config.m_ClShowChatSystem, "", g_Config.m_ClShowChatSystem, &Enable)) - g_Config.m_ClShowChatSystem ^= 1; - - UI()->DoLabelScaled(&Label, Localize("System message"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(1.0f, 1.0f, 0.5f)); - g_Config.m_ClMessageSystemColor = HSL.Pack(false); - } - } - - CUIRect PickerRect; - Left.HSplitTop(5.0f, 0x0, &Left); - Left.HSplitTop(25.0f, &PickerRect, &Left); - PickerRect.w = 25.0f; - - ColorHSLA SMColor = RenderHSLColorPicker(&PickerRect, &g_Config.m_ClMessageSystemColor, false); - ColorRGBA rgb = color_cast(SMColor); - - Left.HSplitTop(10.0f, &Label, &Left); - - TextRender()->TextColor(rgb); - - char aName[16]; - str_copy(aName, Client()->PlayerName(), sizeof(aName)); - str_format(aBuf, sizeof(aBuf), "*** '%s' entered and joined the spectators", aName); - while(TextRender()->TextWidth(0, 12.0f, aBuf, -1, -1.0f) > Label.w) - { - aName[str_length(aName) - 1] = 0; - str_format(aBuf, sizeof(aBuf), "*** '%s' entered and joined the spectators", aName); - } - UI()->DoLabelScaled(&Label, aBuf, 12.0f, -1); - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - Left.HSplitTop(20.0f, 0, &Left); - } - { - char aBuf[64]; - Right.HSplitTop(20.0f, &Label, &Right); - Label.VSplitRight(50.0f, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Highlighted message"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(1.0f, 0.5f, 0.5f)); - g_Config.m_ClMessageHighlightColor = HSL.Pack(false); - } - } - - ColorHSLA HMColor = RenderHSLScrollbars(&Right, &g_Config.m_ClMessageHighlightColor); - - Right.HSplitTop(10.0f, &Label, &Right); - - TextRender()->TextColor(0.75f, 0.5f, 0.75f, 1.0f); - float tw = TextRender()->TextWidth(0, 12.0f, Localize("Spectator"), -1, -1.0f); - Label.VSplitLeft(tw, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Spectator"), 12.0f, -1); - - ColorRGBA rgb = color_cast(HMColor); - TextRender()->TextColor(rgb); - char aName[16]; - str_copy(aName, Client()->PlayerName(), sizeof(aName)); - str_format(aBuf, sizeof(aBuf), ": %s: %s", aName, Localize("Look out!")); - while(TextRender()->TextWidth(0, 12.0f, aBuf, -1, -1.0f) > Button.w) - { - aName[str_length(aName) - 1] = 0; - str_format(aBuf, sizeof(aBuf), ": %s: %s", aName, Localize("Look out!")); - } - UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1); - - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - Right.HSplitTop(20.0f, 0, &Right); - } - { - char aBuf[64]; - Left.HSplitTop(20.0f, &Label, &Left); - Label.VSplitRight(50.0f, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Team message"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(0.65f, 1.0f, 0.65f)); - g_Config.m_ClMessageTeamColor = HSL.Pack(false); - } - } - - ColorHSLA TMColor = RenderHSLScrollbars(&Left, &g_Config.m_ClMessageTeamColor); - - Left.HSplitTop(10.0f, &Label, &Left); - - ColorRGBA rgbn = CalculateNameColor(TMColor); - TextRender()->TextColor(rgbn); - float tw = TextRender()->TextWidth(0, 12.0f, Localize("Player"), -1, -1.0f); - Label.VSplitLeft(tw, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Player"), 12.0f, -1); - - ColorRGBA rgb = color_cast(TMColor); - TextRender()->TextColor(rgb); - str_format(aBuf, sizeof(aBuf), ": %s!", Localize("We will win")); - UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1); - - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - Left.HSplitTop(20.0f, 0, &Left); - } - { - char aBuf[64]; - Right.HSplitTop(20.0f, &Label, &Right); - Label.VSplitRight(50.0f, &Label, &Button); - float twh = TextRender()->TextWidth(0, 16.0f, Localize("Friend message"), -1, -1.0f); - Label.VSplitLeft(twh + 5.0f, &Label, &Enable); - Enable.VSplitLeft(20.0f, &Enable, 0); - UI()->DoLabelScaled(&Label, Localize("Friend message"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - g_Config.m_ClMessageFriendColor = ColorHSLA(0, 1, 145 / 255.0f).Pack(false); - } - - if(DoButton_CheckBox(&g_Config.m_ClMessageFriend, Localize("Highlight"), g_Config.m_ClMessageFriend, &Enable)) - { - g_Config.m_ClMessageFriend ^= 1; - } - - ColorHSLA FMColor = RenderHSLScrollbars(&Right, &g_Config.m_ClMessageFriendColor); - - Right.HSplitTop(10.0f, &Label, &Right); - - ColorRGBA rgbf = color_cast(FMColor); - TextRender()->TextColor(rgbf); - float hw = TextRender()->TextWidth(0, 12.0f, "♥ ", -1, -1.0f); - Label.VSplitLeft(hw, &Heart, &Label); - UI()->DoLabelScaled(&Heart, "♥ ", 12.0f, -1); - - TextRender()->TextColor(0.8f, 0.8f, 0.8f, 1.0f); - float tw = TextRender()->TextWidth(0, 12.0f, Localize("Friend"), -1, -1.0f); - Label.VSplitLeft(tw, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Friend"), 12.0f, -1); - - ColorRGBA rgb = color_cast(FMColor); - TextRender()->TextColor(rgb); - str_format(aBuf, sizeof(aBuf), ": %s", Localize("Hi o/")); - UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1); - - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - Right.HSplitTop(20.0f, 0, &Right); - } - { - char aBuf[64]; - Left.HSplitTop(20.0f, &Label, &Left); - Label.VSplitRight(50.0f, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Normal message"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(1.0f, 1.0f, 1.0f)); - g_Config.m_ClMessageColor = HSL.Pack(false); - } - } - - ColorHSLA MColor = RenderHSLScrollbars(&Left, &g_Config.m_ClMessageColor); - - Left.HSplitTop(10.0f, &Label, &Left); - - TextRender()->TextColor(0.8f, 0.8f, 0.8f, 1.0f); - float tw = TextRender()->TextWidth(0, 12.0f, Localize("Player"), -1, -1.0f); - Label.VSplitLeft(tw, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Player"), 12.0f, -1); - - ColorRGBA rgb = color_cast(MColor); - TextRender()->TextColor(rgb); - str_format(aBuf, sizeof(aBuf), ": %s :D", Localize("Hello and welcome")); - UI()->DoLabelScaled(&Button, aBuf, 12.0f, -1); - - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - } - { - char aBuf[64]; - Right.HSplitTop(20.0f, &Label, &Right); - Label.VSplitRight(50.0f, &Label, &Button); - str_format(aBuf, sizeof(aBuf), "%s (echo)", Localize("Client message")); - UI()->DoLabelScaled(&Label, aBuf, 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(0.5f, 0.78f, 1.0f)); - g_Config.m_ClMessageClientColor = HSL.Pack(false); - } - } - - ColorHSLA CMColor = RenderHSLScrollbars(&Right, &g_Config.m_ClMessageClientColor); - - Right.HSplitTop(10.0f, &Label, &Right); - - ColorRGBA rgb = color_cast(CMColor); - TextRender()->TextColor(rgb); - - UI()->DoLabelScaled(&Label, "*** Dynamic camera activated", 12.0f, -1); - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - Right.HSplitTop(20.0f, 0, &Right); - }*/ - } - else if(Page == 2) - { - Left.HSplitTop(220.0f, &Laser, &Left); - //RenderTools()->DrawUIRect(&Laser, vec4(1.0f, 1.0f, 1.0f, 0.1f), CUI::CORNER_ALL, 5.0f); - //Laser.Margin(10.0f, &Laser); - Laser.HSplitTop(30.0f, &Label, &Laser); - Label.VSplitLeft(TextRender()->TextWidth(0, 20.0f, Localize("Laser"), -1, -1.0f) + 5.0f, &Label, &Weapon); - UI()->DoLabelScaled(&Label, Localize("Laser"), 20.0f, -1); - - Laser.HSplitTop(20.0f, &Label, &Laser); - Label.VSplitLeft(5.0f, 0, &Label); - Label.VSplitRight(50.0f, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Inner color"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(0.5f, 0.5f, 1.0f)); - g_Config.m_ClLaserInnerColor = HSL.Pack(false); - } - } - - ColorHSLA LIColor = RenderHSLScrollbars(&Laser, &g_Config.m_ClLaserInnerColor); - - Laser.HSplitTop(10.0f, 0, &Laser); - - Laser.HSplitTop(20.0f, &Label, &Laser); - Label.VSplitLeft(5.0f, 0, &Label); - Label.VSplitRight(50.0f, &Label, &Button); - UI()->DoLabelScaled(&Label, Localize("Outline color"), 16.0f, -1); - { - static int s_DefaultButton = 0; - if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button)) - { - ColorHSLA HSL = color_cast(ColorRGBA(0.075f, 0.075f, 0.25f)); - g_Config.m_ClLaserOutlineColor = HSL.Pack(false); - } - } - - ColorHSLA LOColor = RenderHSLScrollbars(&Laser, &g_Config.m_ClLaserOutlineColor); - - Weapon.VSplitLeft(30.0f, 0, &Weapon); - - ColorRGBA RGB; - vec2 From = vec2(Weapon.x, Weapon.y + Weapon.h / 2.0f); - vec2 Pos = vec2(Weapon.x + Weapon.w - 10.0f, Weapon.y + Weapon.h / 2.0f); - - vec2 Out, Border; - - Graphics()->BlendNormal(); Graphics()->TextureClear(); Graphics()->QuadsBegin(); + Graphics()->SetColor(0, 0, 0, 0.12f); - // do outline - RGB = color_cast(LOColor); - ColorRGBA OuterColor(RGB.r, RGB.g, RGB.b, 1.0f); - Graphics()->SetColor(RGB.r, RGB.g, RGB.b, 1.0f); // outline - Out = vec2(0.0f, -1.0f) * (3.15f); + char LineBuilder[128]; + float Width; + float TempY = Y; - IGraphics::CFreeformItem Freeform( - From.x - Out.x, From.y - Out.y, - From.x + Out.x, From.y + Out.y, - Pos.x - Out.x, Pos.y - Out.y, - Pos.x + Out.x, Pos.y + Out.y); - Graphics()->QuadsDrawFreeform(&Freeform, 1); - - // do inner - RGB = color_cast(LIColor); - ColorRGBA InnerColor(RGB.r, RGB.g, RGB.b, 1.0f); - Out = vec2(0.0f, -1.0f) * (2.25f); - Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); // center - - Freeform = IGraphics::CFreeformItem( - From.x - Out.x, From.y - Out.y, - From.x + Out.x, From.y + Out.y, - Pos.x - Out.x, Pos.y - Out.y, - Pos.x + Out.x, Pos.y + Out.y); - Graphics()->QuadsDrawFreeform(&Freeform, 1); - - Graphics()->QuadsEnd(); - - // render head + if(g_Config.m_ClShowChatSystem) { - Graphics()->BlendNormal(); - int SpriteIndex = time_get() % 3; - Graphics()->TextureSet(GameClient()->m_ParticlesSkin.m_SpriteParticleSplat[SpriteIndex]); - Graphics()->QuadsBegin(); - - Graphics()->QuadsSetRotation(time_get()); - Graphics()->SetColor(OuterColor.r, OuterColor.g, OuterColor.b, 1.0f); - IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 24, 24); - Graphics()->QuadsDraw(&QuadItem, 1); - Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); - QuadItem = IGraphics::CQuadItem(Pos.x, Pos.y, 20, 20); - Graphics()->QuadsDraw(&QuadItem, 1); - Graphics()->QuadsEnd(); + Width = TextRender()->TextWidth(0, RealFontSize, "*** 'Evgesha' entered and joined the game", -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; } - // draw laser weapon - Graphics()->TextureSet(GameClient()->m_GameSkin.m_SpriteWeaponLaser); - Graphics()->QuadsBegin(); - RenderTools()->SelectSprite(SPRITE_WEAPON_LASER_BODY); - Graphics()->QuadsSetSubset(0, 0, 1, 1); - RenderTools()->DrawSprite(Weapon.x, Weapon.y + Weapon.h / 2.0f, 60.0f); + if(g_Config.m_ClShowIDs) + str_copy(LineBuilder, " 7: DDRacer2002: Hey, how are you ", sizeof(LineBuilder)); + else + str_copy(LineBuilder, "DDRacer2002: Hey, how are you ", sizeof(LineBuilder)); + str_append(LineBuilder, aBuf, sizeof(LineBuilder)); + Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; + + if(g_Config.m_ClShowIDs) + str_copy(LineBuilder, "11: Your Teammate: Let's speedrun this!", sizeof(LineBuilder)); + else + str_copy(LineBuilder, "Your Teammate: Let's speedrun this!", sizeof(LineBuilder)); + Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; + + if(g_Config.m_ClShowIDs) + str_copy(LineBuilder, "♥ 8: Friend: Hello there", sizeof(LineBuilder)); + else + str_copy(LineBuilder, "♥ Friend: Hello there", sizeof(LineBuilder)); + Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; + + if(g_Config.m_ClShowIDs) + str_copy(LineBuilder, " 9: Spammer [6]: Hey fools, I'm spamming here!", sizeof(LineBuilder)); + else + str_copy(LineBuilder, "Spammer [6]: Hey fools, I'm spamming here!", sizeof(LineBuilder)); + Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; + + Width = TextRender()->TextWidth(0, RealFontSize, "*** Echo command executed", -1, -1); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + TempY += RealOffsetY; Graphics()->QuadsEnd(); } - /* - Left.VSplitLeft(20.0f, 0, &Left); - Left.HSplitTop(20.0f, &Label, &Left); - Button.VSplitRight(20.0f, &Button, 0); - char aBuf[64]; - if(g_Config.m_ClReconnectTimeout == 1) + + CAnimState *pIdleState = CAnimState::GetIdle(); + constexpr int PreviewTeeCount = 4; + constexpr float RealTeeSize = CChat::MESSAGE_TEE_SIZE * 2; + constexpr float RealTeeSizeHalved = CChat::MESSAGE_TEE_SIZE; + constexpr float TWSkinUnreliableOffset = 0.5f; + constexpr float OffsetTeeY = RealTeeSizeHalved / 2.0f; + const float FullHeightMinusTee = RealOffsetY - RealTeeSize; + + CTeeRenderInfo RenderInfo[PreviewTeeCount]; + + if(g_Config.m_ClChatTee) { - str_format(aBuf, sizeof(aBuf), "%s %i %s", Localize("Wait before try for"), g_Config.m_ClReconnectTimeout, Localize("second")); + int DefaultInd = GameClient()->m_pSkins->Find("default"); + + for(int i = 0; i < PreviewTeeCount; i++) + { + RenderInfo[i].m_Size = RealTeeSize; + RenderInfo[i].m_CustomColoredSkin = false; + } + + int ind = -1; + int i = 0; + + RenderInfo[i++].m_OriginalRenderSkin = GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("bluekitty")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("cammostripes")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("beast")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; } + + // System + if(g_Config.m_ClShowChatSystem) + { + TextRender()->TextColor(SystemColor); + TextRender()->TextEx(&Cursor, "*** 'Evgesha' entered and joined the game", -1); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + } + + // Highlighted + TextRender()->MoveCursor(&Cursor, RealMsgPaddingTee, 0); + TextRender()->TextColor(DefaultNameColor); + if(g_Config.m_ClShowIDs) + TextRender()->TextEx(&Cursor, " 7: DDRacer2002: ", -1); else + TextRender()->TextEx(&Cursor, "DDRacer2002: ", -1); + TextRender()->TextColor(HighlightedColor); + TextRender()->TextEx(&Cursor, "Hey, how are you ", -1); + TextRender()->TextEx(&Cursor, aBuf, -1); + if(g_Config.m_ClChatTee) + RenderTools()->RenderTee(pIdleState, &RenderInfo[0], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + + // Team + TextRender()->MoveCursor(&Cursor, RealMsgPaddingTee, 0); + TextRender()->TextColor(TeamColor); + if(g_Config.m_ClShowIDs) + TextRender()->TextEx(&Cursor, "11: Your Teammate: ", -1); + else + TextRender()->TextEx(&Cursor, "Your Teammate: ", -1); + TextRender()->TextEx(&Cursor, "Let's speedrun this!", -1); + if(g_Config.m_ClChatTee) + RenderTools()->RenderTee(pIdleState, &RenderInfo[1], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + + // Friend + TextRender()->MoveCursor(&Cursor, RealMsgPaddingTee, 0); + if(g_Config.m_ClMessageFriend) { - str_format(aBuf, sizeof(aBuf), "%s %i %s", Localize("Wait before try for"), g_Config.m_ClReconnectTimeout, Localize("seconds")); + TextRender()->TextColor(FriendColor); + TextRender()->TextEx(&Cursor, "♥ ", -1); } - UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1); - Left.HSplitTop(20.0f, &Button, 0); - Button.HMargin(2.0f, &Button); - g_Config.m_ClReconnectTimeout = static_cast(DoScrollbarH(&g_Config.m_ClReconnectTimeout, &Button, g_Config.m_ClReconnectTimeout / 120.0f) * 120.0f); - if(g_Config.m_ClReconnectTimeout < 5) - g_Config.m_ClReconnectTimeout = 5;*/ + TextRender()->TextColor(DefaultNameColor); + if(g_Config.m_ClShowIDs) + TextRender()->TextEx(&Cursor, " 8: Friend: ", -1); + else + TextRender()->TextEx(&Cursor, "Friend: ", -1); + TextRender()->TextColor(NormalColor); + TextRender()->TextEx(&Cursor, "Hello there", -1); + if(g_Config.m_ClChatTee) + RenderTools()->RenderTee(pIdleState, &RenderInfo[2], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + + // Normal + TextRender()->MoveCursor(&Cursor, RealMsgPaddingTee, 0); + TextRender()->TextColor(DefaultNameColor); + if(g_Config.m_ClShowIDs) + TextRender()->TextEx(&Cursor, " 9: Spammer ", -1); + else + TextRender()->TextEx(&Cursor, "Spammer ", -1); + TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.3f); + TextRender()->TextEx(&Cursor, "[6]", -1); + TextRender()->TextColor(NormalColor); + TextRender()->TextEx(&Cursor, ": Hey fools, I'm spamming here!", -1); + if(g_Config.m_ClChatTee) + RenderTools()->RenderTee(pIdleState, &RenderInfo[3], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + + // Client + TextRender()->TextColor(ClientColor); + TextRender()->TextEx(&Cursor, "*** Echo command executed", -1); + TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + + TextRender()->TextColor(1, 1, 1, 1); } void CMenus::RenderSettingsDDNet(CUIRect MainView) diff --git a/src/game/client/ui.h b/src/game/client/ui.h index f98843d78..e2d5a19d7 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -224,6 +224,7 @@ public: float MouseWorldY() const { return m_MouseWorldY; } int MouseButton(int Index) const { return (m_MouseButtons >> Index) & 1; } int MouseButtonClicked(int Index) { return MouseButton(Index) && !((m_LastMouseButtons >> Index) & 1); } + int MouseButtonReleased(int Index) {return ((m_LastMouseButtons >> Index) & 1) && !MouseButton(Index); } void SetHotItem(const void *pID) { m_pBecommingHotItem = pID; } void SetActiveItem(const void *pID) From 0f0e0caab94c7d3eb558ba15cc9dda3b0f5eb047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Fri, 30 Oct 2020 00:39:07 +0300 Subject: [PATCH 03/12] ColorPicker --- src/game/client/components/menus.cpp | 10 ++++------ src/game/client/components/menus.h | 6 ++---- src/game/client/components/menus_settings.cpp | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index e66d596f1..becdd795f 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -54,8 +54,6 @@ ColorRGBA CMenus::ms_ColorTabbarActiveIngame; ColorRGBA CMenus::ms_ColorTabbarHoverIngame; SColorPicker CMenus::ms_ColorPicker; -int CMenus::ms_ColorPickerID; -int CMenus::ms_HuePickerID; float CMenus::ms_ButtonHeight = 25.0f; float CMenus::ms_ListheaderHeight = 17.0f; @@ -1381,18 +1379,18 @@ void CMenus::RenderColorPicker() // Logic float PickerX, PickerY; - if(UI()->HotItem() != &ms_HuePickerID) + if(UI()->HotItem() != &SColorPicker::ms_HuePickerID) { - if(UI()->DoPickerLogic(&ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) + if(UI()->DoPickerLogic(&SColorPicker::ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) { PickerColor.y = PickerX / ColorsArea.w; PickerColor.z = 1.0f - PickerY / ColorsArea.h; } } - if(UI()->HotItem() != &ms_ColorPickerID) + if(UI()->HotItem() != &SColorPicker::ms_ColorPickerID) { - if(UI()->DoPickerLogic(&ms_HuePickerID, &HueArea, &PickerX, &PickerY)) + if(UI()->DoPickerLogic(&SColorPicker::ms_HuePickerID, &HueArea, &PickerX, &PickerY)) PickerColor.x = 1.0f - PickerY / HueArea.h; } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 40e470477..b2e23282e 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -30,8 +30,8 @@ public: const float ms_Width = 160.0f; const float ms_Height = 200.0f; - static int ms_ColorPickerID; - static int ms_HuePickerID; + const static int ms_ColorPickerID = 0; + const static int ms_HuePickerID = 0; float m_X; float m_Y; @@ -69,8 +69,6 @@ class CMenus : public CComponent static ColorRGBA ms_ColorTabbarHover; static SColorPicker ms_ColorPicker; - static int ms_ColorPickerID; - static int ms_HuePickerID; char m_aLocalStringHelper[1024]; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 851a2d6d6..931d34069 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1570,7 +1570,7 @@ ColorHSLA CMenus::RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColo ColorRGBA RGBColor = color_cast(HSLColor); ColorRGBA Outline(1, 1, 1, 0.25f); - const float OutlineSize = 2.5f; + const float OutlineSize = 3.0f; Outline.a *= ButtonColorMul(pColor); CUIRect Rect; From c77648362d6cacd91ff8055aad6f4d6f7c00f9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Fri, 30 Oct 2020 22:30:06 +0300 Subject: [PATCH 04/12] Some fixes to color picker --- src/game/client/components/menus_settings.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 931d34069..27b8b3b00 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1768,11 +1768,12 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) char LineBuilder[128]; float Width; float TempY = Y; + constexpr float RealBackgroundRounding = CChat::MESSAGE_ROUNDING * 2.0f; if(g_Config.m_ClShowChatSystem) { Width = TextRender()->TextWidth(0, RealFontSize, "*** 'Evgesha' entered and joined the game", -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; } @@ -1782,7 +1783,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) str_copy(LineBuilder, "DDRacer2002: Hey, how are you ", sizeof(LineBuilder)); str_append(LineBuilder, aBuf, sizeof(LineBuilder)); Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; if(g_Config.m_ClShowIDs) @@ -1790,7 +1791,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) else str_copy(LineBuilder, "Your Teammate: Let's speedrun this!", sizeof(LineBuilder)); Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; if(g_Config.m_ClShowIDs) @@ -1798,7 +1799,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) else str_copy(LineBuilder, "♥ Friend: Hello there", sizeof(LineBuilder)); Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; if(g_Config.m_ClShowIDs) @@ -1806,11 +1807,11 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) else str_copy(LineBuilder, "Spammer [6]: Hey fools, I'm spamming here!", sizeof(LineBuilder)); Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; Width = TextRender()->TextWidth(0, RealFontSize, "*** Echo command executed", -1, -1); - RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, 8.0f, CUI::CORNER_ALL); + RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; Graphics()->QuadsEnd(); @@ -1820,12 +1821,13 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) constexpr int PreviewTeeCount = 4; constexpr float RealTeeSize = CChat::MESSAGE_TEE_SIZE * 2; constexpr float RealTeeSizeHalved = CChat::MESSAGE_TEE_SIZE; - constexpr float TWSkinUnreliableOffset = 0.5f; - constexpr float OffsetTeeY = RealTeeSizeHalved / 2.0f; + constexpr float TWSkinUnreliableOffset = -0.25f; + constexpr float OffsetTeeY = RealTeeSizeHalved; const float FullHeightMinusTee = RealOffsetY - RealTeeSize; CTeeRenderInfo RenderInfo[PreviewTeeCount]; + // Load skins if needed if(g_Config.m_ClChatTee) { int DefaultInd = GameClient()->m_pSkins->Find("default"); From 77f84ac831f8d8e9d9c8c48091911a3838eee130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 14 Dec 2020 03:51:31 +0300 Subject: [PATCH 05/12] Ready --- src/game/client/components/menus.cpp | 260 ++++++++++++++---- src/game/client/components/menus.h | 7 +- src/game/client/components/menus_settings.cpp | 78 +++--- src/game/client/ui.cpp | 22 +- src/game/client/ui.h | 3 + 5 files changed, 268 insertions(+), 102 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 612e39cd5..20dc0e777 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -56,6 +56,7 @@ ColorRGBA CMenus::ms_ColorTabbarActiveIngame; ColorRGBA CMenus::ms_ColorTabbarHoverIngame; SColorPicker CMenus::ms_ColorPicker; +bool CMenus::ms_ValueSelectorTextMode; float CMenus::ms_ButtonHeight = 25.0f; float CMenus::ms_ListheaderHeight = 17.0f; @@ -420,6 +421,127 @@ int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Che return DoButton_CheckBox_Common(pID, pText, aBuf, pRect); } +int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *Color) +{ + // logic + static float s_Value; + static char s_NumStr[64]; + static void *s_LastTextpID = pID; + int Inside = UI()->MouseInside(pRect); + + if(Inside) + UI()->SetHotItem(pID); + + if(UI()->MouseButtonReleased(1) && UI()->HotItem() == pID) + { + s_LastTextpID = pID; + ms_ValueSelectorTextMode = true; + if(IsHex) + str_format(s_NumStr, sizeof(s_NumStr), "%06X", Current); + else + str_format(s_NumStr, sizeof(s_NumStr), "%d", Current); + } + + if(UI()->ActiveItem() == pID) + { + if(!UI()->MouseButton(0)) + { + //m_LockMouse = false; + UI()->SetActiveItem(0); + ms_ValueSelectorTextMode = false; + } + } + + if(ms_ValueSelectorTextMode && s_LastTextpID == pID) + { + static float s_NumberBoxID = 0; + DoEditBox(&s_NumberBoxID, pRect, s_NumStr, sizeof(s_NumStr), 10.0f, &s_NumberBoxID, false, CUI::CORNER_ALL); + + UI()->SetActiveItem(&s_NumberBoxID); + + if(Input()->KeyIsPressed(KEY_RETURN) || Input()->KeyIsPressed(KEY_KP_ENTER) || + ((UI()->MouseButtonClicked(1) || UI()->MouseButtonClicked(0)) && !Inside)) + { + if(IsHex) + Current = clamp(str_toint_base(s_NumStr, 16), Min, Max); + else + Current = clamp(str_toint(s_NumStr), Min, Max); + //m_LockMouse = false; + UI()->SetActiveItem(0); + ms_ValueSelectorTextMode = false; + } + + if(Input()->KeyIsPressed(KEY_ESCAPE)) + { + //m_LockMouse = false; + UI()->SetActiveItem(0); + ms_ValueSelectorTextMode = false; + } + } + else + { + if(UI()->ActiveItem() == pID) + { + if(UseScroll) + { + if(UI()->MouseButton(0)) + { + float delta = UI()->MouseDeltaX(); + + if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) + s_Value += delta * 0.05f; + else + s_Value += delta; + + if(absolute(s_Value) > Scale) + { + int Count = (int)(s_Value / Scale); + s_Value = fmod(s_Value, Scale); + Current += Step * Count; + Current = clamp(Current, Min, Max); + + // Constrain to discrete steps + if(Count > 0) + Current = Current / Step * Step; + else + Current = round_ceil(Current / (float)Step) * Step; + } + } + } + } + else if(UI()->HotItem() == pID) + { + if(UI()->MouseButtonClicked(0)) + { + //m_LockMouse = true; + s_Value = 0; + UI()->SetActiveItem(pID); + } + } + + // render + char aBuf[128]; + if(pLabel[0] != '\0') + { + if(IsHex) + str_format(aBuf, sizeof(aBuf), "%s #%06X", pLabel, Current); + else + str_format(aBuf, sizeof(aBuf), "%s %d", pLabel, Current); + } + else + { + if(IsHex) + str_format(aBuf, sizeof(aBuf), "#%06X", Current); + else + str_format(aBuf, sizeof(aBuf), "%d", Current); + } + RenderTools()->DrawUIRect(pRect, *Color, CUI::CORNER_ALL, Round); + UI()->DoLabel(pRect, aBuf, 10, 0, -1); + } + + return Current; +} + int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners, const char *pEmptyText) { int Inside = UI()->MouseInside(pRect); @@ -1295,46 +1417,75 @@ void CMenus::RenderColorPicker() PickerRect.w = ms_ColorPicker.ms_Width; PickerRect.h = ms_ColorPicker.ms_Height; - if(UI()->MouseButtonReleased(1) || (UI()->MouseButtonClicked(0) && !UI()->MouseInside(&PickerRect) && !UI()->MouseInside(&ms_ColorPicker.m_AttachedRect))) + if(UI()->MouseButtonClicked(0) && !UI()->MouseInside(&PickerRect) && !UI()->MouseInside(&ms_ColorPicker.m_AttachedRect)) { ms_ColorPicker.m_Active = false; + ms_ValueSelectorTextMode = false; + UI()->SetActiveItem(0); return; } // Render - ColorRGBA BackgroundColor(0.15f, 0.15f, 0.15f, 1.0f); - ColorRGBA OutlineColor(0.25f, 0.25f, 0.25f, 1); + ColorRGBA BackgroundColor(0.1f, 0.1f, 0.1f, 1.0f); RenderTools()->DrawUIRect(&PickerRect, BackgroundColor, 0, 0); - CUIRect ColorsArea, HueArea, BottomArea, AlphaSliderArea, HexCodeArea; + CUIRect ColorsArea, HueArea, ValuesHitbox, BottomArea, HSVHRect, HSVSRect, HSVVRect, HEXRect, ALPHARect; PickerRect.Margin(3, &ColorsArea); - ColorsArea.HSplitBottom(ms_ColorPicker.ms_Height - 140.0f, &ColorsArea, &BottomArea); + ColorsArea.HSplitBottom(ms_ColorPicker.ms_Height - 140.0f, &ColorsArea, &ValuesHitbox); ColorsArea.VSplitRight(20, &ColorsArea, &HueArea); + BottomArea = ValuesHitbox; BottomArea.HSplitTop(3, 0x0, &BottomArea); HueArea.VSplitLeft(3, 0x0, &HueArea); - BottomArea.HSplitBottom(14, &AlphaSliderArea, &HexCodeArea); - AlphaSliderArea.HSplitBottom(3, &AlphaSliderArea, 0x0); + BottomArea.HSplitTop(20, &HSVHRect, &BottomArea); + BottomArea.HSplitTop(3, 0x0, &BottomArea); - RenderTools()->DrawUIRect(&HueArea, OutlineColor, 0, 0); + constexpr float ValuePadding = 5.0f; + const float HSVValueWidth = (HSVHRect.w - ValuePadding * 2) / 3.0f; + const float HEXValueWidth = HSVValueWidth * 2 + ValuePadding; + + HSVHRect.VSplitLeft(HSVValueWidth, &HSVHRect, &HSVSRect); + HSVSRect.VSplitLeft(ValuePadding, 0x0, &HSVSRect); + HSVSRect.VSplitLeft(HSVValueWidth, &HSVSRect, &HSVVRect); + HSVVRect.VSplitLeft(ValuePadding, 0x0, &HSVVRect); + + BottomArea.HSplitTop(20, &HEXRect, &BottomArea); + HEXRect.VSplitLeft(HEXValueWidth, &HEXRect, &ALPHARect); + ALPHARect.VSplitLeft(ValuePadding, 0x0, &ALPHARect); + + if(UI()->MouseButtonReleased(1) && !UI()->MouseInside(&ValuesHitbox)) + { + ms_ColorPicker.m_Active = false; + ms_ValueSelectorTextMode = false; + UI()->SetActiveItem(0); + return; + } + + ColorRGBA BlackColor(0, 0, 0, 0.5f); + + RenderTools()->DrawUIRect(&HueArea, BlackColor, 0, 0); HueArea.Margin(1, &HueArea); - RenderTools()->DrawUIRect(&ColorsArea, OutlineColor, 0, 0); + RenderTools()->DrawUIRect(&ColorsArea, BlackColor, 0, 0); ColorsArea.Margin(1, &ColorsArea); - ColorHSVA PickerColor = ms_ColorPicker.m_HSVColor; + unsigned int H = ms_ColorPicker.m_HSVColor / (1 << 16); + unsigned int S = (ms_ColorPicker.m_HSVColor - (H << 16)) / (1 << 8); + unsigned int V = ms_ColorPicker.m_HSVColor % (1 << 8); + + ColorHSVA PickerColorHSV(ms_ColorPicker.m_HSVColor); // Color Area ColorRGBA rgb; - rgb = color_cast(ColorHSVA(PickerColor.x, 0.0f, 1.0f)); + rgb = color_cast(ColorHSVA(PickerColorHSV.x, 0.0f, 1.0f)); vec4 TL(rgb.r, rgb.g, rgb.b, 1.0f); - rgb = color_cast(ColorHSVA(PickerColor.x, 1.0f, 1.0f)); + rgb = color_cast(ColorHSVA(PickerColorHSV.x, 1.0f, 1.0f)); vec4 TR(rgb.r, rgb.g, rgb.b, 1.0f); - rgb = color_cast(ColorHSVA(PickerColor.x, 0.0f, 1.0f)); + rgb = color_cast(ColorHSVA(PickerColorHSV.x, 0.0f, 1.0f)); vec4 BL(rgb.r, rgb.g, rgb.b, 1.0f); - rgb = color_cast(ColorHSVA(PickerColor.x, 1.0f, 1.0f)); + rgb = color_cast(ColorHSVA(PickerColorHSV.x, 1.0f, 1.0f)); vec4 BR(rgb.r, rgb.g, rgb.b, 1.0f); RenderTools()->DrawUIRect4NoRounding(&ColorsArea, TL, TR, BL, BR); @@ -1370,63 +1521,76 @@ void CMenus::RenderColorPicker() RenderTools()->DrawUIRect4NoRounding(&HuePartialArea, TL, TL, BL, BL); } - //Hex Code Area FIX <<<<<< - rgb = color_cast(PickerColor); - char Hex[16]; + //Editboxes Area + ColorRGBA EditboxBackground(0, 0, 0, 0.4f); - str_format(Hex, sizeof(Hex), "#%06X", rgb.Pack(false)); + static int RGBRID = 0; + static int RGBGID = 0; + static int RGBBID = 0; - static float HexID = 0; - DoEditBox(&HexID, &HexCodeArea, Hex, sizeof(Hex), 12.0f, &HexID); + H = DoValueSelector(&RGBRID, &HSVHRect, "H:", true, H, 0, 255, 1, 1, false, 5.0f, &EditboxBackground); + S = DoValueSelector(&RGBGID, &HSVSRect, "S:", true, S, 0, 255, 1, 1, false, 5.0f, &EditboxBackground); + V = DoValueSelector(&RGBBID, &HSVVRect, "V:", true, V, 0, 255, 1, 1, false, 5.0f, &EditboxBackground); + + PickerColorHSV = ColorHSVA((H << 16) + (S << 8) + V); + + unsigned int HEX = color_cast(PickerColorHSV).Pack(false); + static int HEXID = 0; + + unsigned int NEWHEX = DoValueSelector(&HEXID, &HEXRect, "HEX:", false, HEX, 0, 0xFFFFFF, 1, 1, true, 5.0f, &EditboxBackground); + + if(HEX != NEWHEX) + PickerColorHSV = color_cast(NEWHEX); + + static int ALPHAID = 0; + + // TODO : ALPHA SUPPORT + UI()->DoLabel(&ALPHARect, "A: 255", 10, 0, -1); + RenderTools()->DrawUIRect(&ALPHARect, ColorRGBA(0, 0, 0, 0.65f), CUI::CORNER_ALL, 5.0f); // Logic float PickerX, PickerY; - if(UI()->HotItem() != &SColorPicker::ms_HuePickerID) + if(UI()->DoPickerLogic(&SColorPicker::ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) { - if(UI()->DoPickerLogic(&SColorPicker::ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) - { - PickerColor.y = PickerX / ColorsArea.w; - PickerColor.z = 1.0f - PickerY / ColorsArea.h; - } - } - - if(UI()->HotItem() != &SColorPicker::ms_ColorPickerID) - { - if(UI()->DoPickerLogic(&SColorPicker::ms_HuePickerID, &HueArea, &PickerX, &PickerY)) - PickerColor.x = 1.0f - PickerY / HueArea.h; + PickerColorHSV.y = PickerX / ColorsArea.w; + PickerColorHSV.z = 1.0f - PickerY / ColorsArea.h; } + if(UI()->DoPickerLogic(&SColorPicker::ms_HuePickerID, &HueArea, &PickerX, &PickerY)) + PickerColorHSV.x = 1.0f - PickerY / HueArea.h; + // Marker Color Area - float MarkerX = ColorsArea.x + ColorsArea.w * PickerColor.y; - float MarkerY = ColorsArea.y + ColorsArea.h * (1.0f - PickerColor.z); + float MarkerX = ColorsArea.x + ColorsArea.w * PickerColorHSV.y; + float MarkerY = ColorsArea.y + ColorsArea.h * (1.0f - PickerColorHSV.z); - int MarkerOutlineInd = PickerColor.z > 0.5f ? 0.0f : 1.0f; + int MarkerOutlineInd = PickerColorHSV.z > 0.5f ? 0.0f : 1.0f; ColorRGBA MarkerOutline(MarkerOutlineInd, MarkerOutlineInd, MarkerOutlineInd, 1.0f); + Graphics()->TextureClear(); Graphics()->QuadsBegin(); Graphics()->SetColor(MarkerOutline); - RenderTools()->DrawCircle(MarkerX, MarkerY, 5.0f, 32); - Graphics()->SetColor(rgb); - RenderTools()->DrawCircle(MarkerX, MarkerY, 4.0f, 32); + RenderTools()->DrawCircle(MarkerX, MarkerY, 4.5f, 32); + Graphics()->SetColor(color_cast(PickerColorHSV)); + RenderTools()->DrawCircle(MarkerX, MarkerY, 3.5f, 32); Graphics()->QuadsEnd(); - // Marker Hue Area CUIRect HueMarker; HueArea.Margin(-2.5f, &HueMarker); - HueMarker.h = 5.0f; - HueMarker.y = (HueArea.y + HueArea.h * (1.0f - PickerColor.x)) - HueMarker.h / 2.0f; + HueMarker.h = 6.5f; + HueMarker.y = (HueArea.y + HueArea.h * (1.0f - PickerColorHSV.x)) - HueMarker.h / 2.0f; - ColorRGBA HueMarkerOutline(1 * PickerColor.x, 1 * PickerColor.x, 1 * PickerColor.x, 1); - ColorRGBA HueMarkerColor = color_cast(ColorHSVA(PickerColor.x, 1, 1, 1)); + ColorRGBA HueMarkerColor = color_cast(ColorHSVA(PickerColorHSV.x, 1, 1, 1)); + const float HMOColor = PickerColorHSV.x > 0.75f ? 1.0f : 0.0f; + ColorRGBA HueMarkerOutline(HMOColor, HMOColor, HMOColor, 1); - RenderTools()->DrawUIRect(&HueMarker, HueMarkerOutline, 0, 0); - HueMarker.Margin(1, &HueMarker); - RenderTools()->DrawUIRect(&HueMarker, HueMarkerColor, 0, 0); + RenderTools()->DrawUIRect(&HueMarker, HueMarkerOutline, CUI::CORNER_ALL, 1.2f); + HueMarker.Margin(1.2f, &HueMarker); + RenderTools()->DrawUIRect(&HueMarker, HueMarkerColor, CUI::CORNER_ALL, 1.2f); - ms_ColorPicker.m_HSVColor = PickerColor; - *ms_ColorPicker.m_pColor = color_cast(PickerColor).Pack(false); + ms_ColorPicker.m_HSVColor = PickerColorHSV.Pack(false); + *ms_ColorPicker.m_pColor = color_cast(PickerColorHSV).Pack(false); } int CMenus::Render() diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index b274f2c76..e93abc908 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -28,7 +28,7 @@ struct SColorPicker { public: const float ms_Width = 160.0f; - const float ms_Height = 200.0f; + const float ms_Height = 186.0f; const static int ms_ColorPickerID = 0; const static int ms_HuePickerID = 0; @@ -40,7 +40,7 @@ public: CUIRect m_AttachedRect; unsigned int *m_pColor; - ColorHSVA m_HSVColor; + unsigned int m_HSVColor; }; // compnent to fetch keypresses, override all other input @@ -69,6 +69,7 @@ class CMenus : public CComponent static ColorRGBA ms_ColorTabbarHover; static SColorPicker ms_ColorPicker; + static bool ms_ValueSelectorTextMode; char m_aLocalStringHelper[1024]; @@ -94,7 +95,7 @@ class CMenus : public CComponent static void ui_draw_menu_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); */ - + int DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool UseScroll, int Current, int Min, int Max, int Step, float Scale, bool IsHex, float Round, ColorRGBA *Color); int DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect); int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index ce3577372..b5d8dd00f 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1594,7 +1594,7 @@ ColorHSLA CMenus::RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColo ms_ColorPicker.m_pColor = pColor; ms_ColorPicker.m_Active = true; ms_ColorPicker.m_AttachedRect = *pRect; - ms_ColorPicker.m_HSVColor = color_cast(HSLColor); + ms_ColorPicker.m_HSVColor = color_cast(HSLColor).Pack(false); } } else @@ -1604,7 +1604,7 @@ ColorHSLA CMenus::RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColo ms_ColorPicker.m_pColor = pColor; ms_ColorPicker.m_Active = true; ms_ColorPicker.m_AttachedRect = *pRect; - ms_ColorPicker.m_HSVColor = color_cast(HSLColor); + ms_ColorPicker.m_HSVColor = color_cast(HSLColor).Pack(false); } } @@ -1686,10 +1686,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) // ***** Chat ***** // - if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatTee, Localize("Show Tee icons in chat"), &g_Config.m_ClChatTee, &Chat, LineMargin)) - GameClient()->m_pChat->RebuildChat(); - - if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatBackground, Localize("Show backgrounds for chat messages"), &g_Config.m_ClChatBackground, &Chat, LineMargin)) + if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatOld, Localize("Use old chat style"), &g_Config.m_ClChatOld, &Chat, LineMargin)) GameClient()->m_pChat->RebuildChat(); Chat.HSplitTop(30.0f, 0x0, &Chat); @@ -1731,7 +1728,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) Chat.HSplitTop(10.0f, 0x0, &Chat); Chat.VSplitRight(100.0f, &Chat, 0x0); - RenderTools()->DrawUIRect(&Chat, ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f), CUI::CORNER_ALL, 8.0f); + RenderTools()->DrawUIRect(&Chat, ColorRGBA(1, 1, 1, 0.1f), CUI::CORNER_ALL, 8.0f); Chat.HSplitTop(10.0f, 0x0, &Chat); ColorRGBA SystemColor = color_cast(ColorHSLA(g_Config.m_ClMessageSystemColor)); @@ -1743,9 +1740,9 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) ColorRGBA DefaultNameColor(0.8f, 0.8f, 0.8f, 1.0f); constexpr float RealFontSize = CChat::FONT_SIZE * 2; - const float RealMsgPaddingX = (g_Config.m_ClChatBackground ? CChat::MESSAGE_PADDING_X : 0) * 2; - const float RealMsgPaddingY = (g_Config.m_ClChatBackground ? CChat::MESSAGE_PADDING_Y : (g_Config.m_ClChatTee ? (CChat::MESSAGE_TEE_SIZE - CChat::FONT_SIZE) : 0)) * 2; - const float RealMsgPaddingTee = (g_Config.m_ClChatTee ? CChat::MESSAGE_TEE_SIZE + CChat::MESSAGE_TEE_PADDING_RIGHT : 0) * 2; + const float RealMsgPaddingX = (!g_Config.m_ClChatOld ? CChat::MESSAGE_PADDING_X : 0) * 2; + const float RealMsgPaddingY = (!g_Config.m_ClChatOld ? CChat::MESSAGE_PADDING_Y : 0) * 2; + const float RealMsgPaddingTee = (!g_Config.m_ClChatOld ? CChat::MESSAGE_TEE_SIZE + CChat::MESSAGE_TEE_PADDING_RIGHT : 0) * 2; const float RealOffsetY = RealFontSize + RealMsgPaddingY; const float X = 5.0f + RealMsgPaddingX / 2.0f + Chat.x; @@ -1756,8 +1753,18 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) str_copy(aBuf, Client()->PlayerName(), sizeof(aBuf)); + CAnimState *pIdleState = CAnimState::GetIdle(); + constexpr int PreviewTeeCount = 4; + constexpr float RealTeeSize = CChat::MESSAGE_TEE_SIZE * 2; + constexpr float RealTeeSizeHalved = CChat::MESSAGE_TEE_SIZE; + constexpr float TWSkinUnreliableOffset = -0.25f; + constexpr float OffsetTeeY = RealTeeSizeHalved; + const float FullHeightMinusTee = RealOffsetY - RealTeeSize; + + CTeeRenderInfo RenderInfo[PreviewTeeCount]; + // Backgrounds first - if(g_Config.m_ClChatBackground) + if(!g_Config.m_ClChatOld) { Graphics()->TextureClear(); Graphics()->QuadsBegin(); @@ -1770,15 +1777,18 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) if(g_Config.m_ClShowChatSystem) { - Width = TextRender()->TextWidth(0, RealFontSize, "*** 'Evgesha' entered and joined the game", -1, -1); + str_copy(LineBuilder, "*** '", sizeof(LineBuilder)); + str_append(LineBuilder, aBuf, sizeof(LineBuilder)); + str_append(LineBuilder, "' entered and joined the game", sizeof(LineBuilder)); + Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); TempY += RealOffsetY; } if(g_Config.m_ClShowIDs) - str_copy(LineBuilder, " 7: DDRacer2002: Hey, how are you ", sizeof(LineBuilder)); + str_copy(LineBuilder, " 7: Evgesha: Hey, how are you ", sizeof(LineBuilder)); else - str_copy(LineBuilder, "DDRacer2002: Hey, how are you ", sizeof(LineBuilder)); + str_copy(LineBuilder, "Evgesha: Hey, how are you ", sizeof(LineBuilder)); str_append(LineBuilder, aBuf, sizeof(LineBuilder)); Width = TextRender()->TextWidth(0, RealFontSize, LineBuilder, -1, -1); RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); @@ -1813,21 +1823,9 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) TempY += RealOffsetY; Graphics()->QuadsEnd(); - } - CAnimState *pIdleState = CAnimState::GetIdle(); - constexpr int PreviewTeeCount = 4; - constexpr float RealTeeSize = CChat::MESSAGE_TEE_SIZE * 2; - constexpr float RealTeeSizeHalved = CChat::MESSAGE_TEE_SIZE; - constexpr float TWSkinUnreliableOffset = -0.25f; - constexpr float OffsetTeeY = RealTeeSizeHalved; - const float FullHeightMinusTee = RealOffsetY - RealTeeSize; + // Load skins - CTeeRenderInfo RenderInfo[PreviewTeeCount]; - - // Load skins if needed - if(g_Config.m_ClChatTee) - { int DefaultInd = GameClient()->m_pSkins->Find("default"); for(int i = 0; i < PreviewTeeCount; i++) @@ -1840,16 +1838,18 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) int i = 0; RenderInfo[i++].m_OriginalRenderSkin = GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("bluekitty")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("cammostripes")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("beast")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("planet_uranus")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("cammostripes")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("beast")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; } // System if(g_Config.m_ClShowChatSystem) { TextRender()->TextColor(SystemColor); - TextRender()->TextEx(&Cursor, "*** 'Evgesha' entered and joined the game", -1); + TextRender()->TextEx(&Cursor, "*** '", -1); + TextRender()->TextEx(&Cursor, aBuf, -1); + TextRender()->TextEx(&Cursor, "' entered and joined the game", -1); TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); } @@ -1857,14 +1857,14 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) TextRender()->MoveCursor(&Cursor, RealMsgPaddingTee, 0); TextRender()->TextColor(DefaultNameColor); if(g_Config.m_ClShowIDs) - TextRender()->TextEx(&Cursor, " 7: DDRacer2002: ", -1); + TextRender()->TextEx(&Cursor, " 7: Evgesha: ", -1); else - TextRender()->TextEx(&Cursor, "DDRacer2002: ", -1); + TextRender()->TextEx(&Cursor, "Evgesha: ", -1); TextRender()->TextColor(HighlightedColor); TextRender()->TextEx(&Cursor, "Hey, how are you ", -1); TextRender()->TextEx(&Cursor, aBuf, -1); - if(g_Config.m_ClChatTee) - RenderTools()->RenderTee(pIdleState, &RenderInfo[0], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + if(!g_Config.m_ClChatOld) + RenderTools()->RenderTee(pIdleState, &RenderInfo[1], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); // Team @@ -1875,8 +1875,8 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) else TextRender()->TextEx(&Cursor, "Your Teammate: ", -1); TextRender()->TextEx(&Cursor, "Let's speedrun this!", -1); - if(g_Config.m_ClChatTee) - RenderTools()->RenderTee(pIdleState, &RenderInfo[1], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); + if(!g_Config.m_ClChatOld) + RenderTools()->RenderTee(pIdleState, &RenderInfo[0], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); // Friend @@ -1893,7 +1893,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) TextRender()->TextEx(&Cursor, "Friend: ", -1); TextRender()->TextColor(NormalColor); TextRender()->TextEx(&Cursor, "Hello there", -1); - if(g_Config.m_ClChatTee) + if(!g_Config.m_ClChatOld) RenderTools()->RenderTee(pIdleState, &RenderInfo[2], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); @@ -1908,7 +1908,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) TextRender()->TextEx(&Cursor, "[6]", -1); TextRender()->TextColor(NormalColor); TextRender()->TextEx(&Cursor, ": Hey fools, I'm spamming here!", -1); - if(g_Config.m_ClChatTee) + if(!g_Config.m_ClChatOld) RenderTools()->RenderTee(pIdleState, &RenderInfo[3], EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); diff --git a/src/game/client/ui.cpp b/src/game/client/ui.cpp index 2ca049907..760ecac74 100644 --- a/src/game/client/ui.cpp +++ b/src/game/client/ui.cpp @@ -103,6 +103,8 @@ void CUI::OnLanguageChange() int CUI::Update(float Mx, float My, float Mwx, float Mwy, int Buttons) { + m_MouseDeltaX = Mx - m_MouseX; + m_MouseDeltaY = My - m_MouseY; m_MouseX = Mx; m_MouseY = My; m_MouseWorldX = Mwx; @@ -385,20 +387,16 @@ int CUI::DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float * { int Inside = MouseInside(pRect); - if(ActiveItem() == pID) - { - if(!MouseButton(0)) - SetActiveItem(0); - } - else if(HotItem() == pID) - { - if(MouseButton(0)) - SetActiveItem(pID); - } - else if(Inside) + if(Inside) SetHotItem(pID); - if(!Inside || !MouseButton(0)) + if(HotItem() == pID && MouseButtonClicked(0)) + SetActiveItem(pID); + + if(ActiveItem() == pID && !MouseButton(0)) + SetActiveItem(0); + + if(ActiveItem() != pID) return 0; if(pX) diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 913b7d830..47c29f118 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -168,6 +168,7 @@ class CUI const void *m_pLastActiveItem; const void *m_pBecommingHotItem; float m_MouseX, m_MouseY; // in gui space + float m_MouseDeltaX, m_MouseDeltaY; // in gui space float m_MouseWorldX, m_MouseWorldY; // in world space unsigned m_MouseButtons; unsigned m_LastMouseButtons; @@ -218,6 +219,8 @@ public: int Update(float mx, float my, float Mwx, float Mwy, int m_Buttons); + float MouseDeltaX() const { return m_MouseDeltaX; } + float MouseDeltaY() const { return m_MouseDeltaY; } float MouseX() const { return m_MouseX; } float MouseY() const { return m_MouseY; } float MouseWorldX() const { return m_MouseWorldX; } From c084c9cde26f5df72a341a863279aa91f9c7133f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 14 Dec 2020 04:18:04 +0300 Subject: [PATCH 06/12] Fix Mac & Linux build --- src/game/client/components/menus.cpp | 7 ++----- src/game/client/components/menus_settings.cpp | 2 +- src/game/client/ui.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 20dc0e777..b21d8adc2 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -302,8 +302,6 @@ void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineCo vec2 From = vec2(Section.x, Section.y + Section.h / 2.0f); vec2 Pos = vec2(Section.x + Section.w - 10.0f, Section.y + Section.h / 2.0f); - vec2 Out, Border; - Graphics()->BlendNormal(); Graphics()->TextureClear(); Graphics()->QuadsBegin(); @@ -311,7 +309,7 @@ void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineCo LaserRGB = color_cast(LaserOutlineColor); ColorRGBA OuterColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f); Graphics()->SetColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f); - Out = vec2(0.0f, -1.0f) * (3.15f); + vec2 Out = vec2(0.0f, -1.0f) * (3.15f); IGraphics::CFreeformItem Freeform(From.x - Out.x, From.y - Out.y, From.x + Out.x, From.y + Out.y, Pos.x - Out.x, Pos.y - Out.y, Pos.x + Out.x, Pos.y + Out.y); Graphics()->QuadsDrawFreeform(&Freeform, 1); @@ -1542,9 +1540,8 @@ void CMenus::RenderColorPicker() if(HEX != NEWHEX) PickerColorHSV = color_cast(NEWHEX); - static int ALPHAID = 0; - // TODO : ALPHA SUPPORT + //static int ALPHAID = 0; UI()->DoLabel(&ALPHARect, "A: 255", 10, 0, -1); RenderTools()->DrawUIRect(&ALPHARect, ColorRGBA(0, 0, 0, 0.65f), CUI::CORNER_ALL, 5.0f); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index b5d8dd00f..0650b68ec 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1750,7 +1750,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) CTextCursor Cursor; TextRender()->SetCursor(&Cursor, X, Y, RealFontSize, TEXTFLAG_RENDER); - + str_copy(aBuf, Client()->PlayerName(), sizeof(aBuf)); CAnimState *pIdleState = CAnimState::GetIdle(); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 47c29f118..aa3b19cbb 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -227,7 +227,7 @@ public: float MouseWorldY() const { return m_MouseWorldY; } int MouseButton(int Index) const { return (m_MouseButtons >> Index) & 1; } int MouseButtonClicked(int Index) { return MouseButton(Index) && !((m_LastMouseButtons >> Index) & 1); } - int MouseButtonReleased(int Index) {return ((m_LastMouseButtons >> Index) & 1) && !MouseButton(Index); } + int MouseButtonReleased(int Index) { return ((m_LastMouseButtons >> Index) & 1) && !MouseButton(Index); } void SetHotItem(const void *pID) { m_pBecommingHotItem = pID; } void SetActiveItem(const void *pID) From ebee286f00045e2e828b2af4f7260a9fc52bbd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 14 Dec 2020 04:49:24 +0300 Subject: [PATCH 07/12] Another attempt to fix Lin & Mac build --- src/game/client/components/menus.cpp | 7 +++++-- src/game/client/components/menus.h | 5 +---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index b21d8adc2..63c43fc1c 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1548,13 +1548,16 @@ void CMenus::RenderColorPicker() // Logic float PickerX, PickerY; - if(UI()->DoPickerLogic(&SColorPicker::ms_ColorPickerID, &ColorsArea, &PickerX, &PickerY)) + static int ColorPickerID = 0; + static int HuePickerID = 0; + + if(UI()->DoPickerLogic(&ColorPickerID, &ColorsArea, &PickerX, &PickerY)) { PickerColorHSV.y = PickerX / ColorsArea.w; PickerColorHSV.z = 1.0f - PickerY / ColorsArea.h; } - if(UI()->DoPickerLogic(&SColorPicker::ms_HuePickerID, &HueArea, &PickerX, &PickerY)) + if(UI()->DoPickerLogic(&HuePickerID, &HueArea, &PickerX, &PickerY)) PickerColorHSV.x = 1.0f - PickerY / HueArea.h; // Marker Color Area diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index e93abc908..a5d4db3ec 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -30,9 +30,6 @@ public: const float ms_Width = 160.0f; const float ms_Height = 186.0f; - const static int ms_ColorPickerID = 0; - const static int ms_HuePickerID = 0; - float m_X; float m_Y; @@ -82,7 +79,7 @@ class CMenus : public CComponent int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = 0, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); - int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); + int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = NULL, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); From d80cdd20d4314a8859491c936888d50d60ca5020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Mon, 14 Dec 2020 22:18:00 +0300 Subject: [PATCH 08/12] Fix merge conflicts --- src/game/client/components/menus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index a5d4db3ec..59f4c9e23 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -79,7 +79,7 @@ class CMenus : public CComponent int DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = 0, int Corners = CUI::CORNER_ALL, float r = 5.0f, float FontFactor = 0.0f, vec4 ColorHot = vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4 Color = vec4(1, 1, 1, 0.5f), int AlignVertically = 1, bool CheckForActiveColorPicker = false); - int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = NULL, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); + int DoButton_MenuTab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners, const ColorRGBA *pDefaultColor = NULL, const ColorRGBA *pActiveColor = NULL, const ColorRGBA *pHoverColor = NULL, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); int DoButton_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect); From f4b8033056ce797d6f625b8cb4a0931722bcad87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Wed, 16 Dec 2020 07:55:41 +0300 Subject: [PATCH 09/12] Fixes --- src/game/client/components/menus.cpp | 12 +++--- src/game/client/components/menus.h | 2 + src/game/client/components/menus_settings.cpp | 41 ++++++++++--------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 63c43fc1c..353006cf1 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1249,7 +1249,10 @@ int CMenus::RenderMenubar(CUIRect r) if(Client()->State() == IClient::STATE_OFFLINE) SetMenuPage(NewPage); else + { + m_PrevGamePage = m_GamePage; m_GamePage = NewPage; + } } return 0; @@ -1736,13 +1739,8 @@ int CMenus::Render() RenderServerbrowser(MainView); } else if(m_MenuPage == PAGE_SETTINGS) - { RenderSettings(MainView); - // Render Color Picker only on settings page and last - RenderColorPicker(); - } - // do tab bar RenderMenubar(TabBar); } @@ -2640,7 +2638,10 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header) void CMenus::SetActive(bool Active) { if(Active != m_MenuActive) + { + ms_ColorPicker.m_Active = false; Input()->SetIMEState(Active); + } m_MenuActive = Active; if(!m_MenuActive) { @@ -3091,6 +3092,7 @@ const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName) void CMenus::SetMenuPage(int NewPage) { + m_PrevMenuPage = m_MenuPage; m_MenuPage = NewPage; if(NewPage >= PAGE_INTERNET && NewPage <= PAGE_KOG) g_Config.m_UiPage = NewPage; diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 59f4c9e23..40b102cbc 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -271,7 +271,9 @@ protected: void ClearCustomItems(int CurTab); int m_MenuPage; + int m_PrevMenuPage; int m_GamePage; + int m_PrevGamePage; int m_Popup; int m_ActivePage; bool m_ShowStart; diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 0650b68ec..ad89d33ee 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1490,6 +1490,7 @@ void CMenus::RenderSettings(CUIRect MainView) Localize("Assets")}; int NumTabs = (int)(sizeof(aTabs) / sizeof(*aTabs)); + int PreviousPage = g_Config.m_UiSettingsPage; for(int i = 0; i < NumTabs; i++) { @@ -1499,6 +1500,9 @@ void CMenus::RenderSettings(CUIRect MainView) g_Config.m_UiSettingsPage = i; } + if(PreviousPage != g_Config.m_UiSettingsPage) + ms_ColorPicker.m_Active = false; + MainView.Margin(10.0f, &MainView); if(g_Config.m_UiSettingsPage == SETTINGS_LANGUAGE) @@ -1560,6 +1564,8 @@ void CMenus::RenderSettings(CUIRect MainView) } else if(m_NeedRestartGeneral || m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound || m_NeedRestartDDNet) UI()->DoLabelScaled(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, -1); + + RenderColorPicker(); } ColorHSLA CMenus::RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha) @@ -1707,7 +1713,6 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) int i = 0; static int ResetIDs[24]; - DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("System message"), &g_Config.m_ClMessageSystemColor, ColorRGBA(1.0f, 1.0f, 0.5f), true, true, &g_Config.m_ClShowChatSystem); DoLine_ColorPicker(&ResetIDs[i++], LineSize, WantedPickerPosition, LabelSize, LineSpacing, &Chat, Localize("Highlighted message"), &g_Config.m_ClMessageHighlightColor, ColorRGBA(1.0f, 0.5f, 0.5f)); @@ -2121,36 +2126,32 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) if(CheckSettings) m_NeedRestartDDNet = s_InpMouseOld != g_Config.m_InpMouseOld; - CUIRect aRects[2]; Left.HSplitTop(5.0f, &Button, &Left); Right.HSplitTop(25.0f, &Button, &Right); - aRects[0] = Left; - aRects[1] = Right; - aRects[0].VSplitRight(10.0f, &aRects[0], 0); - aRects[1].VSplitLeft(10.0f, 0, &aRects[1]); + Left.VSplitRight(10.0f, &Left, 0x0); + Right.VSplitLeft(10.0f, 0x0, &Right); + Left.HSplitTop(25.0f, 0x0, &Left); + CUIRect TempLabel; + Right.HSplitTop(25.0f, &TempLabel, &Right); + Right.HSplitTop(5.0f, 0x0, &Right); - unsigned *paColors[2] = {&g_Config.m_ClBackgroundColor, &g_Config.m_ClBackgroundEntitiesColor}; - const char *paParts[2] = {Localize("Background (regular)"), Localize("Background (entities)")}; + static int ResetID1 = 0; + static int ResetID2 = 0; + ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); + DoLine_ColorPicker(&ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Background (regular)"), &g_Config.m_ClBackgroundColor, GreyDefault, false); + DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Background (entities)"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); - for(int i = 0; i < 2; i++) - { - aRects[i].HSplitTop(20.0f, &Label, &aRects[i]); - UI()->DoLabelScaled(&Label, paParts[i], 14.0f, -1); - aRects[i].VSplitLeft(10.0f, 0, &aRects[i]); - aRects[i].HSplitTop(2.5f, 0, &aRects[i]); - - RenderHSLScrollbars(&aRects[i], paColors[i]); - } + UI()->DoLabelScaled(&TempLabel, Localize("Background (entities)"), 20.0f, -1); { static float s_Map = 0.0f; - aRects[1].HSplitTop(25.0f, &Background, &aRects[1]); + Right.HSplitTop(25.0f, &Background, &Right); Background.HSplitTop(20.0f, &Background, 0); Background.VSplitLeft(100.0f, &Label, &Left); UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1); DoEditBox(g_Config.m_ClBackgroundEntities, &Left, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); - aRects[1].HSplitTop(20.0f, &Button, &aRects[1]); + Right.HSplitTop(20.0f, &Button, &Right); bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0; if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button)) { @@ -2160,7 +2161,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_copy(g_Config.m_ClBackgroundEntities, CURRENT_MAP, sizeof(g_Config.m_ClBackgroundEntities)); } - aRects[1].HSplitTop(20.0f, &Button, 0); + Right.HSplitTop(20.0f, &Button, 0); if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button)) { g_Config.m_ClBackgroundShowTilesLayers ^= 1; From 9d77b8f716d6dd292e85224555c3375f4e0500c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Wed, 16 Dec 2020 07:59:45 +0300 Subject: [PATCH 10/12] Discard unnesaccery changes --- src/game/client/components/menus.cpp | 4 ---- src/game/client/components/menus.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 353006cf1..718266262 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1249,10 +1249,7 @@ int CMenus::RenderMenubar(CUIRect r) if(Client()->State() == IClient::STATE_OFFLINE) SetMenuPage(NewPage); else - { - m_PrevGamePage = m_GamePage; m_GamePage = NewPage; - } } return 0; @@ -3092,7 +3089,6 @@ const CMenus::CMenuImage *CMenus::FindMenuImage(const char *pName) void CMenus::SetMenuPage(int NewPage) { - m_PrevMenuPage = m_MenuPage; m_MenuPage = NewPage; if(NewPage >= PAGE_INTERNET && NewPage <= PAGE_KOG) g_Config.m_UiPage = NewPage; diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 40b102cbc..59f4c9e23 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -271,9 +271,7 @@ protected: void ClearCustomItems(int CurTab); int m_MenuPage; - int m_PrevMenuPage; int m_GamePage; - int m_PrevGamePage; int m_Popup; int m_ActivePage; bool m_ShowStart; From b57d934b699b98db5419bdc748a39492379a53a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Fri, 18 Dec 2020 23:28:33 +0300 Subject: [PATCH 11/12] Polish --- src/game/client/components/menus_settings.cpp | 75 ++++++++++--------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index ad89d33ee..2684d8a76 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1825,7 +1825,6 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) Width = TextRender()->TextWidth(0, RealFontSize, "*** Echo command executed", -1, -1); RenderTools()->DrawRoundRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, CUI::CORNER_ALL); - TempY += RealOffsetY; Graphics()->QuadsEnd(); @@ -1833,10 +1832,10 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) int DefaultInd = GameClient()->m_pSkins->Find("default"); - for(int i = 0; i < PreviewTeeCount; i++) + for(auto & i : RenderInfo) { - RenderInfo[i].m_Size = RealTeeSize; - RenderInfo[i].m_CustomColoredSkin = false; + i.m_Size = RealTeeSize; + i.m_CustomColoredSkin = false; } int ind = -1; @@ -1920,7 +1919,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) // Client TextRender()->TextColor(ClientColor); TextRender()->TextEx(&Cursor, "*** Echo command executed", -1); - TextRender()->SetCursorPosition(&Cursor, X, Y += RealOffsetY); + TextRender()->SetCursorPosition(&Cursor, X, Y); TextRender()->TextColor(1, 1, 1, 1); } @@ -2132,26 +2131,32 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) Right.VSplitLeft(10.0f, 0x0, &Right); Left.HSplitTop(25.0f, 0x0, &Left); CUIRect TempLabel; + Left.HSplitTop(25.0f, &TempLabel, &Left); + Left.HSplitTop(5.0f, 0x0, &Left); + + UI()->DoLabelScaled(&TempLabel, Localize("Background"), 20.0f, -1); + + Right.HSplitTop(25.0f, 0x0, &Right); Right.HSplitTop(25.0f, &TempLabel, &Right); - Right.HSplitTop(5.0f, 0x0, &Right); + Right.HSplitTop(5.0f, 0x0, &Miscellaneous); + + UI()->DoLabelScaled(&TempLabel, Localize("Miscellaneous"), 20.0f, -1); static int ResetID1 = 0; static int ResetID2 = 0; ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); - DoLine_ColorPicker(&ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Background (regular)"), &g_Config.m_ClBackgroundColor, GreyDefault, false); - DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Background (entities)"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); - - UI()->DoLabelScaled(&TempLabel, Localize("Background (entities)"), 20.0f, -1); + DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); { static float s_Map = 0.0f; - Right.HSplitTop(25.0f, &Background, &Right); + Left.VSplitLeft(5.0f, 0x0, &Left); + Left.HSplitTop(25.0f, &Background, &Left); Background.HSplitTop(20.0f, &Background, 0); - Background.VSplitLeft(100.0f, &Label, &Left); + Background.VSplitLeft(100.0f, &Label, &TempLabel); UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1); - DoEditBox(g_Config.m_ClBackgroundEntities, &Left, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); + DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); - Right.HSplitTop(20.0f, &Button, &Right); + Left.HSplitTop(20.0f, &Button, &Left); bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0; if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button)) { @@ -2161,30 +2166,39 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) str_copy(g_Config.m_ClBackgroundEntities, CURRENT_MAP, sizeof(g_Config.m_ClBackgroundEntities)); } - Right.HSplitTop(20.0f, &Button, 0); + Left.HSplitTop(20.0f, &Button, &Left); if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button)) { g_Config.m_ClBackgroundShowTilesLayers ^= 1; } } - MainView.HSplitTop(30.0f, &Label, &Miscellaneous); - UI()->DoLabelScaled(&Label, Localize("Miscellaneous"), 20.0f, -1); - Miscellaneous.VMargin(5.0f, &Miscellaneous); - Miscellaneous.VSplitMid(&Left, &Right); - Left.VSplitRight(5.0f, &Left, 0); - Right.VMargin(5.0f, &Right); - Left.HSplitTop(20.0f, &Button, &Left); + Miscellaneous.HSplitTop(25.0f, &Button, &Right); + DoLine_ColorPicker(&ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Button, Localize("Regular Background Color"), &g_Config.m_ClBackgroundColor, GreyDefault, false); + Right.HSplitTop(5.0f, 0x0, &Right); + Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_CheckBox(&g_Config.m_ClHttpMapDownload, Localize("Try fast HTTP map download first"), g_Config.m_ClHttpMapDownload, &Button)) { g_Config.m_ClHttpMapDownload ^= 1; } - // Updater + { + static int s_ButtonTimeout = 0; + Right.HSplitTop(10.0f, 0x0, &Right); + Right.HSplitTop(20.0f, &Button, &Right); + if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) + { + Client()->GenerateTimeoutSeed(); + } + } + + // Updater #if defined(CONF_AUTOUPDATE) { - Left.HSplitTop(20.0f, &Label, &Left); + MainView.VSplitMid(&Left, &Right); + Left.w += 20.0f; + Left.HSplitBottom(25.0f, 0x0, &Label); bool NeedUpdate = str_comp(Client()->LatestVersion(), "0"); char aBuf[256]; int State = Updater()->GetCurrentState(); @@ -2196,8 +2210,10 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); static int s_ButtonUpdate = 0; - if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) + if (DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) + { Updater()->InitiateUpdate(); + } } else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART) str_format(aBuf, sizeof(aBuf), Localize("Updating...")); @@ -2221,13 +2237,4 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } #endif - - { - static int s_ButtonTimeout = 0; - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) - { - Client()->GenerateTimeoutSeed(); - } - } } From b745feec7310ea297472ea29c70bf8cf56865d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D1=8F=D0=B4=D1=8F=20=D0=96=D0=B5=D0=BD=D1=8F?= Date: Fri, 18 Dec 2020 23:35:22 +0300 Subject: [PATCH 12/12] Format --- src/game/client/components/menus_settings.cpp | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 2613dfa18..72fc61415 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -1831,7 +1831,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) int DefaultInd = GameClient()->m_pSkins->Find("default"); - for(auto & i : RenderInfo) + for(auto &i : RenderInfo) { i.m_Size = RealTeeSize; i.m_CustomColoredSkin = false; @@ -2146,53 +2146,43 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); DoLine_ColorPicker(&ResetID2, 25.0f, 194.0f, 13.0f, 5.0f, &Left, Localize("Entities Background color"), &g_Config.m_ClBackgroundEntitiesColor, GreyDefault, false); + static float s_Map = 0.0f; + Left.VSplitLeft(5.0f, 0x0, &Left); + Left.HSplitTop(25.0f, &Background, &Left); + Background.HSplitTop(20.0f, &Background, 0); + Background.VSplitLeft(100.0f, &Label, &TempLabel); + UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1); + DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); + + Left.HSplitTop(20.0f, &Button, &Left); + bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0; + if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button)) { - static float s_Map = 0.0f; - Left.VSplitLeft(5.0f, 0x0, &Left); - Left.HSplitTop(25.0f, &Background, &Left); - Background.HSplitTop(20.0f, &Background, 0); - Background.VSplitLeft(100.0f, &Label, &TempLabel); - UI()->DoLabelScaled(&Label, Localize("Map"), 14.0f, -1); - DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); - - Left.HSplitTop(20.0f, &Button, &Left); - bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0; - if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button)) - { - if(UseCurrentMap) - g_Config.m_ClBackgroundEntities[0] = '\0'; - else - str_copy(g_Config.m_ClBackgroundEntities, CURRENT_MAP, sizeof(g_Config.m_ClBackgroundEntities)); - } - - Left.HSplitTop(20.0f, &Button, &Left); - if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button)) - { - g_Config.m_ClBackgroundShowTilesLayers ^= 1; - } + if(UseCurrentMap) + g_Config.m_ClBackgroundEntities[0] = '\0'; + else + str_copy(g_Config.m_ClBackgroundEntities, CURRENT_MAP, sizeof(g_Config.m_ClBackgroundEntities)); } + Left.HSplitTop(20.0f, &Button, &Left); + if(DoButton_CheckBox(&g_Config.m_ClBackgroundShowTilesLayers, Localize("Show tiles layers from BG map"), g_Config.m_ClBackgroundShowTilesLayers, &Button)) + g_Config.m_ClBackgroundShowTilesLayers ^= 1; Miscellaneous.HSplitTop(25.0f, &Button, &Right); DoLine_ColorPicker(&ResetID1, 25.0f, 194.0f, 13.0f, 5.0f, &Button, Localize("Regular Background Color"), &g_Config.m_ClBackgroundColor, GreyDefault, false); Right.HSplitTop(5.0f, 0x0, &Right); Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_CheckBox(&g_Config.m_ClHttpMapDownload, Localize("Try fast HTTP map download first"), g_Config.m_ClHttpMapDownload, &Button)) - { g_Config.m_ClHttpMapDownload ^= 1; - } + static int s_ButtonTimeout = 0; + Right.HSplitTop(10.0f, 0x0, &Right); + Right.HSplitTop(20.0f, &Button, &Right); + if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) { - static int s_ButtonTimeout = 0; - Right.HSplitTop(10.0f, 0x0, &Right); - Right.HSplitTop(20.0f, &Button, &Right); - if(DoButton_Menu(&s_ButtonTimeout, Localize("New random timeout code"), 0, &Button)) - { - Client()->GenerateTimeoutSeed(); - } + Client()->GenerateTimeoutSeed(); } - - // Updater + // Updater #if defined(CONF_AUTOUPDATE) { MainView.VSplitMid(&Left, &Right); @@ -2209,7 +2199,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView) Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); static int s_ButtonUpdate = 0; - if (DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) + if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button)) { Updater()->InitiateUpdate(); }