From 92fa5e65f91a3b108dbe9ff4813f2c6743cad7be Mon Sep 17 00:00:00 2001 From: StA Date: Sat, 16 Dec 2023 04:44:39 +0300 Subject: [PATCH] rainbow fix + buttons --- src/game/client/components/menus_settings.cpp | 362 +----------------- src/game/client/components/players.cpp | 9 - 2 files changed, 14 insertions(+), 357 deletions(-) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index bb5b5ff27..367f03558 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -3476,354 +3476,13 @@ void CMenus::RenderSettingsStA(CUIRect MainView) if(s_CurTab == STA_TAB_PAGE2) { - CChat &Chat = GameClient()->m_Chat; - CUIRect TopView, PreviewView, LeftView, RightView; - MainView.h += 20.f; // Increase height a little - MainView.HSplitTop(MainView.h - 260, &TopView, &PreviewView); - TopView.VSplitMid(&LeftView, &RightView); - - // ***** Chat ***** // - LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); - UI()->DoLabel(&Label, Localize("Chat"), HeadlineFontSize, TEXTALIGN_ML); - - // General chat settings - LeftView.HSplitTop(SectionTotalMargin + 7 * LineSize, &Section, &LeftView); - Section.Margin(SectionMargin, &Section); - - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatTeamColors, Localize("Show names in chat in team colors"), &g_Config.m_ClChatTeamColors, &Section, LineSize); - DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClShowChatFriends, Localize("Show only chat messages from friends"), &g_Config.m_ClShowChatFriends, &Section, LineSize); - - if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatOld, Localize("Use old chat style"), &g_Config.m_ClChatOld, &Section, LineSize)) - GameClient()->m_Chat.RebuildChat(); - - Section.HSplitTop(2 * LineSize, &Button, &Section); - int PrevFontSize = g_Config.m_ClChatFontSize; - UI()->DoScrollbarOption(&g_Config.m_ClChatFontSize, &g_Config.m_ClChatFontSize, &Button, Localize("Chat font size"), 10, 100, &CUI::ms_LinearScrollbarScale, CUI::SCROLLBAR_OPTION_MULTILINE); - if(PrevFontSize != g_Config.m_ClChatFontSize) - { - Chat.EnsureCoherentWidth(); - Chat.RebuildChat(); - } - - Section.HSplitTop(2 * LineSize, &Button, &Section); - int PrevWidth = g_Config.m_ClChatWidth; - UI()->DoScrollbarOption(&g_Config.m_ClChatWidth, &g_Config.m_ClChatWidth, &Button, Localize("Chat width"), 120, 400, &CUI::ms_LinearScrollbarScale, CUI::SCROLLBAR_OPTION_MULTILINE); - if(PrevWidth != g_Config.m_ClChatWidth) - { - Chat.EnsureCoherentFontSize(); - Chat.RebuildChat(); - } - - // ***** Messages ***** // - RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView); - UI()->DoLabel(&Label, Localize("Messages"), HeadlineFontSize, TEXTALIGN_ML); - - // Message Colors and extra settings - RightView.HSplitTop(SectionTotalMargin + 6 * ColorPickerLineSize, &Section, &RightView); - Section.Margin(SectionMargin, &Section); - - int i = 0; - static CButtonContainer s_aResetIDs[24]; - - DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("System message"), &g_Config.m_ClMessageSystemColor, ColorRGBA(1.0f, 1.0f, 0.5f), true, &g_Config.m_ClShowChatSystem); - DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Highlighted message"), &g_Config.m_ClMessageHighlightColor, ColorRGBA(1.0f, 0.5f, 0.5f)); - DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Team message"), &g_Config.m_ClMessageTeamColor, ColorRGBA(0.65f, 1.0f, 0.65f)); - DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Friend message"), &g_Config.m_ClMessageFriendColor, ColorRGBA(1.0f, 0.137f, 0.137f), true, &g_Config.m_ClMessageFriend); - DoLine_ColorPicker(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, 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(&s_aResetIDs[i++], ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, aBuf, &g_Config.m_ClMessageClientColor, ColorRGBA(0.5f, 0.78f, 1.0f)); - - // ***** Chat Preview ***** // - PreviewView.HSplitTop(HeadlineAndVMargin, &Label, &PreviewView); - UI()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_ML); - - // Use the rest of the view for preview - Section = PreviewView; - Section.Margin(SectionMargin, &Section); - - Section.Draw(ColorRGBA(1, 1, 1, 0.1f), IGraphics::CORNER_ALL, 8.0f); - - Section.HSplitTop(10.0f, 0x0, &Section); // Margin - - 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); - - const float RealFontSize = Chat.FontSize() * 2; - const float RealMsgPaddingX = (!g_Config.m_ClChatOld ? Chat.MessagePaddingX() : 0) * 2; - const float RealMsgPaddingY = (!g_Config.m_ClChatOld ? Chat.MessagePaddingY() : 0) * 2; - const float RealMsgPaddingTee = (!g_Config.m_ClChatOld ? Chat.MessageTeeSize() + CChat::MESSAGE_TEE_PADDING_RIGHT : 0) * 2; - const float RealOffsetY = RealFontSize + RealMsgPaddingY; - - const float X = 5.0f + RealMsgPaddingX / 2.0f + Section.x; - float Y = Section.y; - float LineWidth = g_Config.m_ClChatWidth * 2 - (RealMsgPaddingX * 1.5f) - RealMsgPaddingTee; - - CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, X, Y, RealFontSize, TEXTFLAG_RENDER); - Cursor.m_LineWidth = LineWidth; - - str_copy(aBuf, Client()->PlayerName()); - - const CAnimState *pIdleState = CAnimState::GetIdle(); - const float RealTeeSize = Chat.MessageTeeSize() * 2; - const float RealTeeSizeHalved = Chat.MessageTeeSize(); - constexpr float TWSkinUnreliableOffset = -0.25f; - const float OffsetTeeY = RealTeeSizeHalved; - const float FullHeightMinusTee = RealOffsetY - RealTeeSize; - - struct SPreviewLine - { - int m_ClientID; - bool m_Team; - char m_aName[64]; - char m_aText[256]; - bool m_Friend; - bool m_Player; - bool m_Client; - bool m_Highlighted; - int m_TimesRepeated; - - CTeeRenderInfo m_RenderInfo; - }; - - static std::vector s_vLines; - - const auto *pDefaultSkin = GameClient()->m_Skins.Find("default"); - enum ELineFlag - { - FLAG_TEAM = 1 << 0, - FLAG_FRIEND = 1 << 1, - FLAG_HIGHLIGHT = 1 << 2, - FLAG_CLIENT = 1 << 3 - }; - enum - { - PREVIEW_SYS, - PREVIEW_HIGHLIGHT, - PREVIEW_TEAM, - PREVIEW_FRIEND, - PREVIEW_SPAMMER, - PREVIEW_CLIENT - }; - auto &&AddPreviewLine = [](int Index, int ClientID, const char *pName, const char *pText, int Flag, int Repeats) { - s_vLines.emplace_back(); - SPreviewLine *pLine = &s_vLines[s_vLines.size() - 1]; - pLine->m_ClientID = ClientID; - pLine->m_Team = Flag & FLAG_TEAM; - pLine->m_Friend = Flag & FLAG_FRIEND; - pLine->m_Player = ClientID >= 0; - pLine->m_Highlighted = Flag & FLAG_HIGHLIGHT; - pLine->m_Client = Flag & FLAG_CLIENT; - pLine->m_TimesRepeated = Repeats; - str_copy(pLine->m_aName, pName); - str_copy(pLine->m_aText, pText); - }; - auto &&SetLineSkin = [RealTeeSize, &pDefaultSkin](int Index, const CSkin *pSkin) { - if(Index >= (int)s_vLines.size()) - return; - s_vLines[Index].m_RenderInfo.m_Size = RealTeeSize; - s_vLines[Index].m_RenderInfo.m_CustomColoredSkin = false; - if(pSkin != nullptr) - s_vLines[Index].m_RenderInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - else if(pDefaultSkin != nullptr) - s_vLines[Index].m_RenderInfo.m_OriginalRenderSkin = pDefaultSkin->m_OriginalSkin; - }; - - auto &&RenderPreview = [&](int LineIndex, int x, int y, bool Render = true) { - if(LineIndex >= (int)s_vLines.size()) - return vec2(0, 0); - CTextCursor LocalCursor; - TextRender()->SetCursor(&LocalCursor, x, y, RealFontSize, Render ? TEXTFLAG_RENDER : 0); - LocalCursor.m_LineWidth = LineWidth; - const auto &Line = s_vLines[LineIndex]; - - char aName[64 + 12] = ""; - - if(g_Config.m_ClShowIDs && Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') - { - if(Line.m_ClientID < 10) - str_format(aName, sizeof(aName), " %d: ", Line.m_ClientID); - else - str_format(aName, sizeof(aName), "%d: ", Line.m_ClientID); - } - - str_append(aName, Line.m_aName); - - char aCount[12]; - if(Line.m_ClientID < 0) - str_format(aCount, sizeof(aCount), "[%d] ", Line.m_TimesRepeated + 1); - else - str_format(aCount, sizeof(aCount), " [%d]", Line.m_TimesRepeated + 1); - - if(Line.m_Player) - { - LocalCursor.m_X += RealMsgPaddingTee; - - if(Line.m_Friend && g_Config.m_ClMessageFriend) - { - if(Render) - TextRender()->TextColor(FriendColor); - TextRender()->TextEx(&LocalCursor, "♥ ", -1); - } - } - - ColorRGBA NameColor; - if(Line.m_Team) - NameColor = CalculateNameColor(color_cast(TeamColor)); - else if(Line.m_Player) - NameColor = DefaultNameColor; - else if(Line.m_Client) - NameColor = ClientColor; - else - NameColor = SystemColor; - - if(Render) - TextRender()->TextColor(NameColor); - - TextRender()->TextEx(&LocalCursor, aName, -1); - - if(Line.m_TimesRepeated > 0) - { - if(Render) - TextRender()->TextColor(1.0f, 1.0f, 1.0f, 0.3f); - TextRender()->TextEx(&LocalCursor, aCount, -1); - } - - if(Line.m_ClientID >= 0 && Line.m_aName[0] != '\0') - { - if(Render) - TextRender()->TextColor(NameColor); - TextRender()->TextEx(&LocalCursor, ": ", -1); - } - - CTextCursor AppendCursor = LocalCursor; - AppendCursor.m_LongestLineWidth = 0.0f; - if(!g_Config.m_ClChatOld) - { - AppendCursor.m_StartX = LocalCursor.m_X; - AppendCursor.m_LineWidth -= LocalCursor.m_LongestLineWidth; - } - - if(Render) - { - if(Line.m_Highlighted) - TextRender()->TextColor(HighlightedColor); - else if(Line.m_Team) - TextRender()->TextColor(TeamColor); - else if(Line.m_Player) - TextRender()->TextColor(NormalColor); - } - - TextRender()->TextEx(&AppendCursor, Line.m_aText, -1); - if(Render) - TextRender()->TextColor(TextRender()->DefaultTextColor()); - - return vec2{LocalCursor.m_LongestLineWidth + AppendCursor.m_LongestLineWidth, AppendCursor.Height() + RealMsgPaddingY}; - }; - - // Init lines - if(s_vLines.empty()) - { - char aLineBuilder[128]; - - str_format(aLineBuilder, sizeof(aLineBuilder), "'%s' entered and joined the game", aBuf); - AddPreviewLine(PREVIEW_SYS, -1, "*** ", aLineBuilder, 0, 0); - - str_format(aLineBuilder, sizeof(aLineBuilder), "Hey, how are you %s?", aBuf); - AddPreviewLine(PREVIEW_HIGHLIGHT, 7, "Random Tee", aLineBuilder, FLAG_HIGHLIGHT, 0); - - AddPreviewLine(PREVIEW_TEAM, 11, "Your Teammate", "Let's speedrun this!", FLAG_TEAM, 0); - AddPreviewLine(PREVIEW_FRIEND, 8, "Friend", "Hello there", FLAG_FRIEND, 0); - AddPreviewLine(PREVIEW_SPAMMER, 9, "Spammer", "Hey fools, I'm spamming here!", 0, 5); - AddPreviewLine(PREVIEW_CLIENT, -1, "— ", "Echo command executed", FLAG_CLIENT, 0); - } - - SetLineSkin(1, GameClient()->m_Skins.FindOrNullptr("pinky")); - SetLineSkin(2, pDefaultSkin); - SetLineSkin(3, GameClient()->m_Skins.FindOrNullptr("cammostripes")); - SetLineSkin(4, GameClient()->m_Skins.FindOrNullptr("beast")); - - // Backgrounds first - if(!g_Config.m_ClChatOld) - { - Graphics()->TextureClear(); - Graphics()->QuadsBegin(); - Graphics()->SetColor(0, 0, 0, 0.12f); - - float TempY = Y; - const float RealBackgroundRounding = Chat.MessageRounding() * 2.0f; - - auto &&RenderMessageBackground = [&](int LineIndex) { - auto Size = RenderPreview(LineIndex, 0, 0, false); - Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Size.x + RealMsgPaddingX * 1.5f, Size.y, RealBackgroundRounding, IGraphics::CORNER_ALL); - return Size.y; - }; - - if(g_Config.m_ClShowChatSystem) - { - TempY += RenderMessageBackground(PREVIEW_SYS); - } - - if(!g_Config.m_ClShowChatFriends) - { - TempY += RenderMessageBackground(PREVIEW_HIGHLIGHT); - TempY += RenderMessageBackground(PREVIEW_TEAM); - } - - TempY += RenderMessageBackground(PREVIEW_FRIEND); - - if(!g_Config.m_ClShowChatFriends) - { - TempY += RenderMessageBackground(PREVIEW_SPAMMER); - } - - TempY += RenderMessageBackground(PREVIEW_CLIENT); - - Graphics()->QuadsEnd(); - } - - // System - if(g_Config.m_ClShowChatSystem) - { - Y += RenderPreview(PREVIEW_SYS, X, Y).y; - } - - if(!g_Config.m_ClShowChatFriends) - { - // Highlighted - if(!g_Config.m_ClChatOld) - RenderTools()->RenderTee(pIdleState, &s_vLines[PREVIEW_HIGHLIGHT].m_RenderInfo, EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); - Y += RenderPreview(PREVIEW_HIGHLIGHT, X, Y).y; - - // Team - if(!g_Config.m_ClChatOld) - RenderTools()->RenderTee(pIdleState, &s_vLines[PREVIEW_TEAM].m_RenderInfo, EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); - Y += RenderPreview(PREVIEW_TEAM, X, Y).y; - } - - // Friend - if(!g_Config.m_ClChatOld) - RenderTools()->RenderTee(pIdleState, &s_vLines[PREVIEW_FRIEND].m_RenderInfo, EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); - Y += RenderPreview(PREVIEW_FRIEND, X, Y).y; - - // Normal - if(!g_Config.m_ClShowChatFriends) - { - if(!g_Config.m_ClChatOld) - RenderTools()->RenderTee(pIdleState, &s_vLines[PREVIEW_SPAMMER].m_RenderInfo, EMOTE_NORMAL, vec2(1, 0.1f), vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset)); - Y += RenderPreview(PREVIEW_SPAMMER, X, Y).y; - } - // Client - RenderPreview(PREVIEW_CLIENT, X, Y); - TextRender()->SetCursorPosition(&Cursor, X, Y); + CUIRect Column; + MainView.VSplitLeft(MainView.w * 0.5, &MainView, &Column); - TextRender()->TextColor(TextRender()->DefaultTextColor()); + MainView.HSplitTop(40.0f, &Section, &MainView); + UI()->DoLabel(&Section, ("GO TO Appearence->Chat "), 40.0f, TEXTALIGN_LEFT); + MainView.VSplitLeft(5.1f, 0x0, &MainView); // i splitted it 5.1, because 5.0 is not perfectly centered for some fckn reason - DDNET FIX YOUR CODE + MainView.HSplitTop(5.1f, 0x0, &MainView); } if(s_CurTab == STA_TAB_PAGE3) { @@ -3858,6 +3517,13 @@ void CMenus::RenderSettingsStA(CUIRect MainView) g_Config.m_ClFrozenHudTeeSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClFrozenHudTeeSize, &Button, (g_Config.m_ClFrozenHudTeeSize - 8) / 19.0f) * 19.0f) + 8; } + CUIRect Rainbow; + MainView.HSplitTop(20.0f, &Rainbow, &MainView); + UI()->DoLabel(&Rainbow, ("Rainbow Tee(s)"), 20.0f, TEXTALIGN_LEFT); + MainView.VSplitLeft(5.1f, 0x0, &MainView); // i splitted it 5.1, because 5.0 is not perfectly centered for some fckn reason - DDNET FIX YOUR CODE + MainView.HSplitTop(20.0f, &Rainbow, &MainView); + + DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClRainbow, ("Rainbow Skin"), &g_Config.m_ClRainbow, &Rainbow, LineMargin); // ***** OUTLINES ***** // @@ -3895,7 +3561,7 @@ void CMenus::RenderSettingsStA(CUIRect MainView) UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); g_Config.m_ClOutlineAlpha = (int)(UI()->DoScrollbarH(&g_Config.m_ClOutlineAlpha, &Button, (g_Config.m_ClOutlineAlpha) / 100.0f) * 100.0f); } - { + { CUIRect Button, Label; MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView); diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index f254dc014..949bd0d7d 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -477,15 +477,6 @@ void CPlayers::RenderPlayer( bool IsRainbowBody = g_Config.m_ClRainbow, IsRainbowFeet = g_Config.m_ClRainbow; - if (g_Config.m_ClRainbowEveryone == 1) - { - g_Config.m_ClRainbow = 1; - } - else - { - g_Config.m_ClRainbow = Local == 1; - } - if(g_Config.m_ClRainbow == 1) { IsRainbowBody = true;