1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#include "menus.h"
4
5#include <base/str.h>
6
7#include <engine/graphics.h>
8#include <engine/shared/config.h>
9#include <engine/textrender.h>
10
11#include <generated/client_data.h>
12
13#include <game/client/animstate.h>
14#include <game/client/components/chat.h>
15#include <game/client/components/items.h>
16#include <game/client/components/mapimages.h>
17#include <game/client/components/nameplates.h>
18#include <game/client/components/skins.h>
19#include <game/client/gameclient.h>
20#include <game/client/skin.h>
21#include <game/client/ui.h>
22#include <game/client/ui_listbox.h>
23#include <game/client/ui_scrollregion.h>
24#include <game/localization.h>
25
26enum
27{
28 APPEARANCE_TAB_HUD = 0,
29 APPEARANCE_TAB_CHAT = 1,
30 APPEARANCE_TAB_NAME_PLATE = 2,
31 APPEARANCE_TAB_HOOK_COLLISION = 3,
32 APPEARANCE_TAB_INFO_MESSAGES = 4,
33 APPEARANCE_TAB_LASER = 5,
34 NUMBER_OF_APPEARANCE_TABS = 6,
35};
36
37void CMenus::RenderSettingsAppearance(CUIRect MainView)
38{
39 char aBuf[128];
40 static int s_CurTab = 0;
41
42 CUIRect TabBar, LeftView, RightView, Button;
43
44 MainView.HSplitTop(Cut: 20.0f, pTop: &TabBar, pBottom: &MainView);
45 const float TabWidth = TabBar.w / (float)NUMBER_OF_APPEARANCE_TABS;
46 static CButtonContainer s_aPageTabs[NUMBER_OF_APPEARANCE_TABS] = {};
47 const char *apTabNames[NUMBER_OF_APPEARANCE_TABS] = {
48 Localize(pStr: "HUD"),
49 Localize(pStr: "Chat"),
50 Localize(pStr: "Name Plate"),
51 Localize(pStr: "Hook Collisions"),
52 Localize(pStr: "Info Messages"),
53 Localize(pStr: "Laser")};
54
55 for(int Tab = APPEARANCE_TAB_HUD; Tab < NUMBER_OF_APPEARANCE_TABS; ++Tab)
56 {
57 TabBar.VSplitLeft(Cut: TabWidth, pLeft: &Button, pRight: &TabBar);
58 const int Corners = Tab == APPEARANCE_TAB_HUD ? IGraphics::CORNER_L : (Tab == NUMBER_OF_APPEARANCE_TABS - 1 ? IGraphics::CORNER_R : IGraphics::CORNER_NONE);
59 if(DoButton_MenuTab(pButtonContainer: &s_aPageTabs[Tab], pText: apTabNames[Tab], Checked: s_CurTab == Tab, pRect: &Button, Corners, pAnimator: nullptr, pDefaultColor: nullptr, pActiveColor: nullptr, pHoverColor: nullptr, EdgeRounding: 4.0f))
60 {
61 s_CurTab = Tab;
62 }
63 }
64
65 MainView.HSplitTop(Cut: 10.0f, pTop: nullptr, pBottom: &MainView);
66
67 const float LineSize = 20.0f;
68 const float ColorPickerLineSize = 25.0f;
69 const float HeadlineFontSize = 20.0f;
70 const float HeadlineHeight = 30.0f;
71 const float MarginSmall = 5.0f;
72 const float MarginBetweenViews = 20.0f;
73
74 const float ColorPickerLabelSize = 13.0f;
75 const float ColorPickerLineSpacing = 5.0f;
76
77 if(s_CurTab == APPEARANCE_TAB_HUD)
78 {
79 MainView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
80
81 // ***** HUD ***** //
82 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "HUD"), FontSize: HeadlineFontSize,
83 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
84 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
85
86 // Switch of the entire HUD
87 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhud, pText: Localize(pStr: "Show ingame HUD"), pValue: &g_Config.m_ClShowhud, pRect: &LeftView, VMargin: LineSize);
88
89 // Switches of the various normal HUD elements
90 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudHealthAmmo, pText: Localize(pStr: "Show health, shields and ammo"), pValue: &g_Config.m_ClShowhudHealthAmmo, pRect: &LeftView, VMargin: LineSize);
91 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudScore, pText: Localize(pStr: "Show score"), pValue: &g_Config.m_ClShowhudScore, pRect: &LeftView, VMargin: LineSize);
92 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowLocalTimeAlways, pText: Localize(pStr: "Show local time always"), pValue: &g_Config.m_ClShowLocalTimeAlways, pRect: &LeftView, VMargin: LineSize);
93 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClSpecCursor, pText: Localize(pStr: "Show spectator cursor"), pValue: &g_Config.m_ClSpecCursor, pRect: &LeftView, VMargin: LineSize);
94
95 // Settings of the HUD element for votes
96 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowVotesAfterVoting, pText: Localize(pStr: "Show votes window after voting"), pValue: &g_Config.m_ClShowVotesAfterVoting, pRect: &LeftView, VMargin: LineSize);
97
98 // ***** Scoreboard ***** //
99 LeftView.HSplitTop(Cut: MarginBetweenViews, pTop: nullptr, pBottom: &LeftView);
100 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Scoreboard"), FontSize: HeadlineFontSize,
101 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
102 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
103
104 ColorRGBA GreenDefault(0.78f, 1.0f, 0.8f, 1.0f);
105 static CButtonContainer s_AuthedColor, s_SameClanColor;
106 DoLine_ColorPicker(pResetId: &s_AuthedColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Authed name color in scoreboard"), pColorValue: &g_Config.m_ClAuthedPlayerColor, DefaultColor: GreenDefault, CheckBoxSpacing: false);
107 DoLine_ColorPicker(pResetId: &s_SameClanColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Same clan color in scoreboard"), pColorValue: &g_Config.m_ClSameClanColor, DefaultColor: GreenDefault, CheckBoxSpacing: false);
108
109 // ***** DDRace HUD ***** //
110 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "DDRace HUD"), FontSize: HeadlineFontSize,
111 Align: TEXTALIGN_ML, pRect: &RightView, LineSize: HeadlineHeight);
112 RightView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &RightView);
113
114 // Switches of various DDRace HUD elements
115 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowIds, pText: Localize(pStr: "Show client IDs (scoreboard, chat, spectator)"), pValue: &g_Config.m_ClShowIds, pRect: &RightView, VMargin: LineSize);
116 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudDDRace, pText: Localize(pStr: "Show DDRace HUD"), pValue: &g_Config.m_ClShowhudDDRace, pRect: &RightView, VMargin: LineSize);
117 if(g_Config.m_ClShowhudDDRace)
118 {
119 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudJumpsIndicator, pText: Localize(pStr: "Show jumps indicator"), pValue: &g_Config.m_ClShowhudJumpsIndicator, pRect: &RightView, VMargin: LineSize);
120 }
121 else
122 {
123 RightView.HSplitTop(Cut: LineSize, pTop: nullptr, pBottom: &RightView); // Create empty space for hidden option
124 }
125
126 // Eye with a number of spectators
127 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudSpectatorCount, pText: Localize(pStr: "Show number of spectators"), pValue: &g_Config.m_ClShowhudSpectatorCount, pRect: &RightView, VMargin: LineSize);
128
129 // Switch for dummy actions display
130 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudDummyActions, pText: Localize(pStr: "Show dummy actions"), pValue: &g_Config.m_ClShowhudDummyActions, pRect: &RightView, VMargin: LineSize);
131
132 // Player movement information display settings
133 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudPlayerPosition, pText: Localize(pStr: "Show player position"), pValue: &g_Config.m_ClShowhudPlayerPosition, pRect: &RightView, VMargin: LineSize);
134 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudPlayerSpeed, pText: Localize(pStr: "Show player speed"), pValue: &g_Config.m_ClShowhudPlayerSpeed, pRect: &RightView, VMargin: LineSize);
135 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowhudPlayerAngle, pText: Localize(pStr: "Show player target angle"), pValue: &g_Config.m_ClShowhudPlayerAngle, pRect: &RightView, VMargin: LineSize);
136
137 // Freeze bar settings
138 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowFreezeBars, pText: Localize(pStr: "Show freeze bars"), pValue: &g_Config.m_ClShowFreezeBars, pRect: &RightView, VMargin: LineSize);
139 RightView.HSplitTop(Cut: LineSize * 2.0f, pTop: &Button, pBottom: &RightView);
140 if(g_Config.m_ClShowFreezeBars)
141 {
142 Ui()->DoScrollbarOption(pId: &g_Config.m_ClFreezeBarsAlphaInsideFreeze, pOption: &g_Config.m_ClFreezeBarsAlphaInsideFreeze, pRect: &Button, pStr: Localize(pStr: "Opacity of freeze bars inside freeze"), Min: 0, Max: 100, pScale: &CUi::ms_LinearScrollbarScale, Flags: CUi::SCROLLBAR_OPTION_MULTILINE, pSuffix: "%");
143 }
144 }
145 else if(s_CurTab == APPEARANCE_TAB_CHAT)
146 {
147 CChat &Chat = GameClient()->m_Chat;
148 CUIRect TopView, PreviewView;
149 MainView.HSplitBottom(Cut: 220.0f, pTop: &TopView, pBottom: &PreviewView);
150 TopView.HSplitBottom(Cut: MarginBetweenViews, pTop: &TopView, pBottom: nullptr);
151 TopView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
152
153 // ***** Chat ***** //
154 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Chat"), FontSize: HeadlineFontSize,
155 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
156 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
157
158 // General chat settings
159 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
160 if(DoButton_CheckBox(pId: &g_Config.m_ClShowChat, pText: Localize(pStr: "Show chat"), Checked: g_Config.m_ClShowChat, pRect: &Button))
161 {
162 g_Config.m_ClShowChat = g_Config.m_ClShowChat ? 0 : 1;
163 }
164 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
165 if(g_Config.m_ClShowChat)
166 {
167 static int s_ShowChat = 0;
168 if(DoButton_CheckBox(pId: &s_ShowChat, pText: Localize(pStr: "Always show chat"), Checked: g_Config.m_ClShowChat == 2, pRect: &Button))
169 g_Config.m_ClShowChat = g_Config.m_ClShowChat != 2 ? 2 : 1;
170 }
171
172 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClChatTeamColors, pText: Localize(pStr: "Show names in chat in team colors"), pValue: &g_Config.m_ClChatTeamColors, pRect: &LeftView, VMargin: LineSize);
173 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowChatFriends, pText: Localize(pStr: "Show only chat messages from friends"), pValue: &g_Config.m_ClShowChatFriends, pRect: &LeftView, VMargin: LineSize);
174 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClShowChatTeamMembersOnly, pText: Localize(pStr: "Show only chat messages from team members"), pValue: &g_Config.m_ClShowChatTeamMembersOnly, pRect: &LeftView, VMargin: LineSize);
175
176 if(DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClChatOld, pText: Localize(pStr: "Use old chat style"), pValue: &g_Config.m_ClChatOld, pRect: &LeftView, VMargin: LineSize))
177 GameClient()->m_Chat.RebuildChat();
178
179 // DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClCensorChat, Localize("Censor profanity"), &g_Config.m_ClCensorChat, &LeftView, LineSize);
180
181 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
182 if(Ui()->DoScrollbarOption(pId: &g_Config.m_ClChatFontSize, pOption: &g_Config.m_ClChatFontSize, pRect: &Button, pStr: Localize(pStr: "Chat font size"), Min: 10, Max: 100))
183 {
184 Chat.EnsureCoherentWidth();
185 Chat.RebuildChat();
186 }
187
188 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
189 if(Ui()->DoScrollbarOption(pId: &g_Config.m_ClChatWidth, pOption: &g_Config.m_ClChatWidth, pRect: &Button, pStr: Localize(pStr: "Chat width"), Min: 120, Max: 400))
190 {
191 Chat.EnsureCoherentFontSize();
192 Chat.RebuildChat();
193 }
194
195 static CButtonContainer s_BackgroundColor;
196 DoLine_ColorPicker(pResetId: &s_BackgroundColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Chat background color"), pColorValue: &g_Config.m_ClChatBackgroundColor, DefaultColor: color_cast<ColorRGBA>(hsl: ColorHSLA(DefaultConfig::ClChatBackgroundColor, true)), CheckBoxSpacing: false, pCheckBoxValue: nullptr, Alpha: true);
197
198 // ***** Messages ***** //
199 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Messages"), FontSize: HeadlineFontSize,
200 Align: TEXTALIGN_ML, pRect: &RightView, LineSize: HeadlineHeight);
201 RightView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &RightView);
202
203 // Message Colors and extra settings
204 static CButtonContainer s_SystemMessageColor;
205 DoLine_ColorPicker(pResetId: &s_SystemMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: Localize(pStr: "System message"), pColorValue: &g_Config.m_ClMessageSystemColor, DefaultColor: ColorRGBA(1.0f, 1.0f, 0.5f), CheckBoxSpacing: true, pCheckBoxValue: &g_Config.m_ClShowChatSystem);
206 static CButtonContainer s_HighlightedMessageColor;
207 DoLine_ColorPicker(pResetId: &s_HighlightedMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: Localize(pStr: "Highlighted message"), pColorValue: &g_Config.m_ClMessageHighlightColor, DefaultColor: ColorRGBA(1.0f, 0.5f, 0.5f));
208 static CButtonContainer s_TeamMessageColor;
209 DoLine_ColorPicker(pResetId: &s_TeamMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: Localize(pStr: "Team message"), pColorValue: &g_Config.m_ClMessageTeamColor, DefaultColor: ColorRGBA(0.65f, 1.0f, 0.65f));
210 static CButtonContainer s_FriendMessageColor;
211 DoLine_ColorPicker(pResetId: &s_FriendMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: Localize(pStr: "Friend message"), pColorValue: &g_Config.m_ClMessageFriendColor, DefaultColor: ColorRGBA(1.0f, 0.137f, 0.137f), CheckBoxSpacing: true, pCheckBoxValue: &g_Config.m_ClMessageFriend);
212 static CButtonContainer s_NormalMessageColor;
213 DoLine_ColorPicker(pResetId: &s_NormalMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: Localize(pStr: "Normal message"), pColorValue: &g_Config.m_ClMessageColor, DefaultColor: ColorRGBA(1.0f, 1.0f, 1.0f));
214
215 str_format(buffer: aBuf, buffer_size: sizeof(aBuf), format: "%s (echo)", Localize(pStr: "Client message"));
216 static CButtonContainer s_ClientMessageColor;
217 DoLine_ColorPicker(pResetId: &s_ClientMessageColor, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &RightView, pText: aBuf, pColorValue: &g_Config.m_ClMessageClientColor, DefaultColor: ColorRGBA(0.5f, 0.78f, 1.0f));
218
219 // ***** Chat Preview ***** //
220 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Preview"), FontSize: HeadlineFontSize,
221 Align: TEXTALIGN_ML, pRect: &PreviewView, LineSize: HeadlineHeight);
222 PreviewView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &PreviewView);
223
224 // Use the rest of the view for preview
225 PreviewView.Draw(Color: ColorRGBA(1, 1, 1, 0.1f), Corners: IGraphics::CORNER_ALL, Rounding: 5.0f);
226 PreviewView.Margin(Cut: MarginSmall, pOtherRect: &PreviewView);
227
228 ColorRGBA SystemColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageSystemColor));
229 ColorRGBA HighlightedColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageHighlightColor));
230 ColorRGBA TeamColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageTeamColor));
231 ColorRGBA FriendColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageFriendColor));
232 ColorRGBA NormalColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageColor));
233 ColorRGBA ClientColor = color_cast<ColorRGBA, ColorHSLA>(hsl: ColorHSLA(g_Config.m_ClMessageClientColor));
234 ColorRGBA DefaultNameColor(0.8f, 0.8f, 0.8f, 1.0f);
235
236 const float RealFontSize = Chat.FontSize() * 2;
237 const float RealMsgPaddingX = (!g_Config.m_ClChatOld ? Chat.MessagePaddingX() : 0) * 2;
238 const float RealMsgPaddingY = (!g_Config.m_ClChatOld ? Chat.MessagePaddingY() : 0) * 2;
239 const float RealMsgPaddingTee = (!g_Config.m_ClChatOld ? Chat.MessageTeeSize() + CChat::MESSAGE_TEE_PADDING_RIGHT : 0) * 2;
240 const float RealOffsetY = RealFontSize + RealMsgPaddingY;
241
242 const float X = RealMsgPaddingX / 2.0f + PreviewView.x;
243 float Y = PreviewView.y;
244 float LineWidth = g_Config.m_ClChatWidth * 2 - (RealMsgPaddingX * 1.5f) - RealMsgPaddingTee;
245
246 str_copy(dst&: aBuf, src: Client()->PlayerName());
247
248 const CAnimState *pIdleState = CAnimState::GetIdle();
249 const float RealTeeSize = Chat.MessageTeeSize() * 2;
250 const float RealTeeSizeHalved = Chat.MessageTeeSize();
251 constexpr float TWSkinUnreliableOffset = -0.25f;
252 const float OffsetTeeY = RealTeeSizeHalved;
253 const float FullHeightMinusTee = RealOffsetY - RealTeeSize;
254
255 struct SPreviewLine
256 {
257 int m_ClientId;
258 bool m_Team;
259 char m_aName[64];
260 char m_aText[256];
261 bool m_Friend;
262 bool m_Player;
263 bool m_Client;
264 bool m_Highlighted;
265 int m_TimesRepeated;
266
267 CTeeRenderInfo m_RenderInfo;
268 };
269
270 static std::vector<SPreviewLine> s_vLines;
271
272 enum ELineFlag
273 {
274 FLAG_TEAM = 1 << 0,
275 FLAG_FRIEND = 1 << 1,
276 FLAG_HIGHLIGHT = 1 << 2,
277 FLAG_CLIENT = 1 << 3
278 };
279 enum
280 {
281 PREVIEW_SYS,
282 PREVIEW_HIGHLIGHT,
283 PREVIEW_TEAM,
284 PREVIEW_FRIEND,
285 PREVIEW_SPAMMER,
286 PREVIEW_CLIENT
287 };
288 auto &&SetPreviewLine = [](int Index, int ClientId, const char *pName, const char *pText, int Flag, int Repeats) {
289 SPreviewLine *pLine;
290 if((int)s_vLines.size() <= Index)
291 {
292 s_vLines.emplace_back();
293 pLine = &s_vLines.back();
294 }
295 else
296 {
297 pLine = &s_vLines[Index];
298 }
299 pLine->m_ClientId = ClientId;
300 pLine->m_Team = Flag & FLAG_TEAM;
301 pLine->m_Friend = Flag & FLAG_FRIEND;
302 pLine->m_Player = ClientId >= 0;
303 pLine->m_Highlighted = Flag & FLAG_HIGHLIGHT;
304 pLine->m_Client = Flag & FLAG_CLIENT;
305 pLine->m_TimesRepeated = Repeats;
306 str_copy(dst&: pLine->m_aName, src: pName);
307 str_copy(dst&: pLine->m_aText, src: pText);
308 };
309 auto &&SetLineSkin = [RealTeeSize](int Index, const CSkin *pSkin) {
310 if(Index >= (int)s_vLines.size())
311 return;
312 s_vLines[Index].m_RenderInfo.m_Size = RealTeeSize;
313 s_vLines[Index].m_RenderInfo.Apply(pSkin);
314 };
315
316 auto &&RenderPreview = [&](int LineIndex, int x, int y, bool Render = true) {
317 if(LineIndex >= (int)s_vLines.size())
318 return vec2(0, 0);
319 CTextCursor LocalCursor;
320 LocalCursor.SetPosition(vec2(x, y));
321 LocalCursor.m_FontSize = RealFontSize;
322 LocalCursor.m_Flags = Render ? TEXTFLAG_RENDER : 0;
323 LocalCursor.m_LineWidth = LineWidth;
324 const auto &Line = s_vLines[LineIndex];
325
326 char aClientId[16] = "";
327 if(g_Config.m_ClShowIds && Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
328 {
329 GameClient()->FormatClientId(ClientId: Line.m_ClientId, aClientId, Format: EClientIdFormat::INDENT_FORCE);
330 }
331
332 char aCount[12];
333 if(Line.m_ClientId < 0)
334 str_format(buffer: aCount, buffer_size: sizeof(aCount), format: "[%d] ", Line.m_TimesRepeated + 1);
335 else
336 str_format(buffer: aCount, buffer_size: sizeof(aCount), format: " [%d]", Line.m_TimesRepeated + 1);
337
338 if(Line.m_Player)
339 {
340 LocalCursor.m_X += RealMsgPaddingTee;
341
342 if(Line.m_Friend && g_Config.m_ClMessageFriend)
343 {
344 if(Render)
345 TextRender()->TextColor(Color: FriendColor);
346 TextRender()->TextEx(pCursor: &LocalCursor, pText: "♥ ", Length: -1);
347 }
348 }
349
350 ColorRGBA NameColor;
351 if(Line.m_Team)
352 NameColor = CalculateNameColor(TextColorHSL: color_cast<ColorHSLA>(rgb: TeamColor));
353 else if(Line.m_Player)
354 NameColor = DefaultNameColor;
355 else if(Line.m_Client)
356 NameColor = ClientColor;
357 else
358 NameColor = SystemColor;
359
360 if(Render)
361 TextRender()->TextColor(Color: NameColor);
362
363 TextRender()->TextEx(pCursor: &LocalCursor, pText: aClientId);
364 TextRender()->TextEx(pCursor: &LocalCursor, pText: Line.m_aName);
365
366 if(Line.m_TimesRepeated > 0)
367 {
368 if(Render)
369 TextRender()->TextColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 0.3f);
370 TextRender()->TextEx(pCursor: &LocalCursor, pText: aCount, Length: -1);
371 }
372
373 if(Line.m_ClientId >= 0 && Line.m_aName[0] != '\0')
374 {
375 if(Render)
376 TextRender()->TextColor(Color: NameColor);
377 TextRender()->TextEx(pCursor: &LocalCursor, pText: ": ", Length: -1);
378 }
379
380 CTextCursor AppendCursor = LocalCursor;
381 AppendCursor.m_LongestLineWidth = 0.0f;
382 if(!g_Config.m_ClChatOld)
383 {
384 AppendCursor.m_StartX = LocalCursor.m_X;
385 AppendCursor.m_LineWidth -= LocalCursor.m_LongestLineWidth;
386 }
387
388 if(Render)
389 {
390 if(Line.m_Highlighted)
391 TextRender()->TextColor(Color: HighlightedColor);
392 else if(Line.m_Team)
393 TextRender()->TextColor(Color: TeamColor);
394 else if(Line.m_Player)
395 TextRender()->TextColor(Color: NormalColor);
396 }
397
398 TextRender()->TextEx(pCursor: &AppendCursor, pText: Line.m_aText, Length: -1);
399 if(Render)
400 TextRender()->TextColor(Color: TextRender()->DefaultTextColor());
401
402 return vec2{LocalCursor.m_LongestLineWidth + AppendCursor.m_LongestLineWidth, AppendCursor.Height() + RealMsgPaddingY};
403 };
404
405 // Set preview lines
406 {
407 char aLineBuilder[128];
408
409 str_format(buffer: aLineBuilder, buffer_size: sizeof(aLineBuilder), format: "'%s' entered and joined the game", aBuf);
410 SetPreviewLine(PREVIEW_SYS, -1, "*** ", aLineBuilder, 0, 0);
411
412 str_format(buffer: aLineBuilder, buffer_size: sizeof(aLineBuilder), format: "Hey, how are you %s?", aBuf);
413 SetPreviewLine(PREVIEW_HIGHLIGHT, 7, "Random Tee", aLineBuilder, FLAG_HIGHLIGHT, 0);
414
415 SetPreviewLine(PREVIEW_TEAM, 11, "Your Teammate", "Let's speedrun this!", FLAG_TEAM, 0);
416 SetPreviewLine(PREVIEW_FRIEND, 8, "Friend", "Hello there", FLAG_FRIEND, 0);
417 SetPreviewLine(PREVIEW_SPAMMER, 9, "Spammer", "Hey fools, I'm spamming here!", 0, 5);
418 SetPreviewLine(PREVIEW_CLIENT, -1, "— ", "Echo command executed", FLAG_CLIENT, 0);
419 }
420
421 SetLineSkin(1, GameClient()->m_Skins.Find(pName: "pinky"));
422 SetLineSkin(2, GameClient()->m_Skins.Find(pName: "default"));
423 SetLineSkin(3, GameClient()->m_Skins.Find(pName: "cammostripes"));
424 SetLineSkin(4, GameClient()->m_Skins.Find(pName: "beast"));
425
426 // Backgrounds first
427 if(!g_Config.m_ClChatOld)
428 {
429 Graphics()->TextureClear();
430 Graphics()->QuadsBegin();
431 Graphics()->SetColor(color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClChatBackgroundColor, true)));
432
433 float TempY = Y;
434 const float RealBackgroundRounding = Chat.MessageRounding() * 2.0f;
435
436 auto &&RenderMessageBackground = [&](int LineIndex) {
437 auto Size = RenderPreview(LineIndex, 0, 0, false);
438 Graphics()->DrawRectExt(x: X - RealMsgPaddingX / 2.0f, y: TempY - RealMsgPaddingY / 2.0f, w: Size.x + RealMsgPaddingX * 1.5f, h: Size.y, r: RealBackgroundRounding, Corners: IGraphics::CORNER_ALL);
439 return Size.y;
440 };
441
442 if(g_Config.m_ClShowChatSystem)
443 {
444 TempY += RenderMessageBackground(PREVIEW_SYS);
445 }
446
447 if(!g_Config.m_ClShowChatFriends)
448 {
449 if(!g_Config.m_ClShowChatTeamMembersOnly)
450 TempY += RenderMessageBackground(PREVIEW_HIGHLIGHT);
451 TempY += RenderMessageBackground(PREVIEW_TEAM);
452 }
453
454 if(!g_Config.m_ClShowChatTeamMembersOnly)
455 TempY += RenderMessageBackground(PREVIEW_FRIEND);
456
457 if(!g_Config.m_ClShowChatFriends && !g_Config.m_ClShowChatTeamMembersOnly)
458 {
459 TempY += RenderMessageBackground(PREVIEW_SPAMMER);
460 }
461
462 TempY += RenderMessageBackground(PREVIEW_CLIENT);
463
464 Graphics()->QuadsEnd();
465 }
466
467 // System
468 if(g_Config.m_ClShowChatSystem)
469 {
470 Y += RenderPreview(PREVIEW_SYS, X, Y).y;
471 }
472
473 if(!g_Config.m_ClShowChatFriends)
474 {
475 // Highlighted
476 if(!g_Config.m_ClChatOld && !g_Config.m_ClShowChatTeamMembersOnly)
477 RenderTools()->RenderTee(pAnim: pIdleState, pInfo: &s_vLines[PREVIEW_HIGHLIGHT].m_RenderInfo, Emote: EMOTE_NORMAL, Dir: vec2(1, 0.1f), Pos: vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset));
478 if(!g_Config.m_ClShowChatTeamMembersOnly)
479 Y += RenderPreview(PREVIEW_HIGHLIGHT, X, Y).y;
480
481 // Team
482 if(!g_Config.m_ClChatOld)
483 RenderTools()->RenderTee(pAnim: pIdleState, pInfo: &s_vLines[PREVIEW_TEAM].m_RenderInfo, Emote: EMOTE_NORMAL, Dir: vec2(1, 0.1f), Pos: vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset));
484 Y += RenderPreview(PREVIEW_TEAM, X, Y).y;
485 }
486
487 // Friend
488 if(!g_Config.m_ClChatOld && !g_Config.m_ClShowChatTeamMembersOnly)
489 RenderTools()->RenderTee(pAnim: pIdleState, pInfo: &s_vLines[PREVIEW_FRIEND].m_RenderInfo, Emote: EMOTE_NORMAL, Dir: vec2(1, 0.1f), Pos: vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset));
490 if(!g_Config.m_ClShowChatTeamMembersOnly)
491 Y += RenderPreview(PREVIEW_FRIEND, X, Y).y;
492
493 // Normal
494 if(!g_Config.m_ClShowChatFriends && !g_Config.m_ClShowChatTeamMembersOnly)
495 {
496 if(!g_Config.m_ClChatOld)
497 RenderTools()->RenderTee(pAnim: pIdleState, pInfo: &s_vLines[PREVIEW_SPAMMER].m_RenderInfo, Emote: EMOTE_NORMAL, Dir: vec2(1, 0.1f), Pos: vec2(X + RealTeeSizeHalved, Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset));
498 Y += RenderPreview(PREVIEW_SPAMMER, X, Y).y;
499 }
500 // Client
501 RenderPreview(PREVIEW_CLIENT, X, Y);
502
503 TextRender()->TextColor(Color: TextRender()->DefaultTextColor());
504 }
505 else if(s_CurTab == APPEARANCE_TAB_NAME_PLATE)
506 {
507 MainView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
508
509 // ***** Name Plate ***** //
510 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Name Plate"), FontSize: HeadlineFontSize,
511 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
512 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
513
514 // General name plate settings
515 {
516 int Pressed = (g_Config.m_ClNamePlates ? 2 : 0) + (g_Config.m_ClNamePlatesOwn ? 1 : 0);
517 if(DoLine_RadioMenu(View&: LeftView, pLabel: Localize(pStr: "Show name plates"),
518 vButtonContainers&: m_vButtonContainersNamePlateShow,
519 vLabels: {Localize(pStr: "None", pContext: "Show name plates"), Localize(pStr: "Own", pContext: "Show name plates"), Localize(pStr: "Others", pContext: "Show name plates"), Localize(pStr: "All", pContext: "Show name plates")},
520 vValues: {0, 1, 2, 3},
521 Value&: Pressed))
522 {
523 g_Config.m_ClNamePlates = Pressed & 2 ? 1 : 0;
524 g_Config.m_ClNamePlatesOwn = Pressed & 1 ? 1 : 0;
525 }
526 }
527 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
528 Ui()->DoScrollbarOption(pId: &g_Config.m_ClNamePlatesSize, pOption: &g_Config.m_ClNamePlatesSize, pRect: &Button, pStr: Localize(pStr: "Name plates size"), Min: -50, Max: 100);
529 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
530 Ui()->DoScrollbarOption(pId: &g_Config.m_ClNamePlatesOffset, pOption: &g_Config.m_ClNamePlatesOffset, pRect: &Button, pStr: Localize(pStr: "Name plates offset"), Min: 10, Max: 50);
531
532 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClNamePlatesClan, pText: Localize(pStr: "Show clan above name plates"), pValue: &g_Config.m_ClNamePlatesClan, pRect: &LeftView, VMargin: LineSize);
533 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
534 if(g_Config.m_ClNamePlatesClan)
535 Ui()->DoScrollbarOption(pId: &g_Config.m_ClNamePlatesClanSize, pOption: &g_Config.m_ClNamePlatesClanSize, pRect: &Button, pStr: Localize(pStr: "Clan plates size"), Min: -50, Max: 100);
536
537 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClNamePlatesTeamcolors, pText: Localize(pStr: "Use team colors for name plates"), pValue: &g_Config.m_ClNamePlatesTeamcolors, pRect: &LeftView, VMargin: LineSize);
538 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClNamePlatesFriendMark, pText: Localize(pStr: "Show friend icon in name plates"), pValue: &g_Config.m_ClNamePlatesFriendMark, pRect: &LeftView, VMargin: LineSize);
539
540 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClNamePlatesIds, pText: Localize(pStr: "Show client IDs in name plates"), pValue: &g_Config.m_ClNamePlatesIds, pRect: &LeftView, VMargin: LineSize);
541 if(g_Config.m_ClNamePlatesIds > 0)
542 DoButton_CheckBoxAutoVMarginAndSet(pId: &g_Config.m_ClNamePlatesIdsSeparateLine, pText: Localize(pStr: "Show client IDs on a separate line"), pValue: &g_Config.m_ClNamePlatesIdsSeparateLine, pRect: &LeftView, VMargin: LineSize);
543 else
544 LeftView.HSplitTop(Cut: LineSize, pTop: nullptr, pBottom: &LeftView);
545 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
546 if(g_Config.m_ClNamePlatesIds > 0 && g_Config.m_ClNamePlatesIdsSeparateLine > 0)
547 Ui()->DoScrollbarOption(pId: &g_Config.m_ClNamePlatesIdsSize, pOption: &g_Config.m_ClNamePlatesIdsSize, pRect: &Button, pStr: Localize(pStr: "Client IDs size"), Min: ConfigLimits::ClNamePlatesIdsSize.m_Min, Max: ConfigLimits::ClNamePlatesIdsSize.m_Max);
548
549 // ***** Hook Strength ***** //
550 LeftView.HSplitTop(Cut: MarginBetweenViews, pTop: nullptr, pBottom: &LeftView);
551 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Hook Strength"), FontSize: HeadlineFontSize,
552 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
553 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
554
555 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
556 if(DoButton_CheckBox(pId: &g_Config.m_ClNamePlatesStrong, pText: Localize(pStr: "Show hook strength icon indicator"), Checked: g_Config.m_ClNamePlatesStrong, pRect: &Button))
557 {
558 g_Config.m_ClNamePlatesStrong = g_Config.m_ClNamePlatesStrong ? 0 : 1;
559 }
560 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
561 if(g_Config.m_ClNamePlatesStrong)
562 {
563 static int s_NamePlatesStrong = 0;
564 if(DoButton_CheckBox(pId: &s_NamePlatesStrong, pText: Localize(pStr: "Show hook strength number indicator"), Checked: g_Config.m_ClNamePlatesStrong == 2, pRect: &Button))
565 g_Config.m_ClNamePlatesStrong = g_Config.m_ClNamePlatesStrong != 2 ? 2 : 1;
566 }
567
568 LeftView.HSplitTop(Cut: LineSize * 2.0f, pTop: &Button, pBottom: &LeftView);
569 if(g_Config.m_ClNamePlatesStrong)
570 {
571 Ui()->DoScrollbarOption(pId: &g_Config.m_ClNamePlatesStrongSize, pOption: &g_Config.m_ClNamePlatesStrongSize, pRect: &Button, pStr: Localize(pStr: "Size of hook strength icon and number indicator"), Min: -50, Max: 100, pScale: &CUi::ms_LinearScrollbarScale, Flags: CUi::SCROLLBAR_OPTION_MULTILINE);
572 }
573
574 // ***** Key Presses ***** //
575 LeftView.HSplitTop(Cut: MarginBetweenViews, pTop: nullptr, pBottom: &LeftView);
576 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Key Presses"), FontSize: HeadlineFontSize,
577 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
578 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
579
580 DoLine_RadioMenu(View&: LeftView, pLabel: Localize(pStr: "Show players' key presses"),
581 vButtonContainers&: m_vButtonContainersNamePlateKeyPresses,
582 vLabels: {Localize(pStr: "None", pContext: "Show players' key presses"), Localize(pStr: "Own", pContext: "Show players' key presses"), Localize(pStr: "Others", pContext: "Show players' key presses"), Localize(pStr: "All", pContext: "Show players' key presses")},
583 vValues: {0, 3, 1, 2},
584 Value&: g_Config.m_ClShowDirection);
585
586 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
587 if(g_Config.m_ClShowDirection > 0)
588 Ui()->DoScrollbarOption(pId: &g_Config.m_ClDirectionSize, pOption: &g_Config.m_ClDirectionSize, pRect: &Button, pStr: Localize(pStr: "Size of key press icons"), Min: -50, Max: 100);
589
590 // ***** Name Plate Preview ***** //
591 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Preview"), FontSize: HeadlineFontSize,
592 Align: TEXTALIGN_ML, pRect: &RightView, LineSize: HeadlineHeight);
593 RightView.HSplitTop(Cut: 2.0f * MarginSmall, pTop: nullptr, pBottom: &RightView);
594
595 // ***** Name Plate Dummy Preview ***** //
596 RightView.HSplitBottom(Cut: LineSize, pTop: &RightView, pBottom: &Button);
597 if(DoButton_CheckBox(pId: &m_DummyNamePlatePreview, pText: g_Config.m_ClDummy ? Localize(pStr: "Preview player's name plate") : Localize(pStr: "Preview dummy's name plate"), Checked: m_DummyNamePlatePreview, pRect: &Button))
598 m_DummyNamePlatePreview = !m_DummyNamePlatePreview;
599
600 int Dummy = g_Config.m_ClDummy != (m_DummyNamePlatePreview ? 1 : 0);
601
602 const vec2 Position = RightView.Center();
603
604 GameClient()->m_NamePlates.RenderNamePlatePreview(Position, Dummy);
605 }
606 else if(s_CurTab == APPEARANCE_TAB_HOOK_COLLISION)
607 {
608 MainView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
609
610 // ***** Hookline ***** //
611 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Hook collision line"), FontSize: HeadlineFontSize,
612 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
613 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
614
615 // General hookline settings
616 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
617 if(DoButton_CheckBox(pId: &g_Config.m_ClShowHookCollOwn, pText: Localize(pStr: "Show own player's hook collision line"), Checked: g_Config.m_ClShowHookCollOwn, pRect: &Button))
618 {
619 g_Config.m_ClShowHookCollOwn = g_Config.m_ClShowHookCollOwn ? 0 : 1;
620 }
621 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
622 if(g_Config.m_ClShowHookCollOwn)
623 {
624 static int s_ShowHookCollOwn = 0;
625 if(DoButton_CheckBox(pId: &s_ShowHookCollOwn, pText: Localize(pStr: "Always show own player's hook collision line"), Checked: g_Config.m_ClShowHookCollOwn == 2, pRect: &Button))
626 g_Config.m_ClShowHookCollOwn = g_Config.m_ClShowHookCollOwn != 2 ? 2 : 1;
627 }
628
629 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
630 if(DoButton_CheckBox(pId: &g_Config.m_ClShowHookCollOther, pText: Localize(pStr: "Show other players' hook collision lines"), Checked: g_Config.m_ClShowHookCollOther, pRect: &Button))
631 {
632 g_Config.m_ClShowHookCollOther = g_Config.m_ClShowHookCollOther >= 1 ? 0 : 1;
633 }
634 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
635 if(g_Config.m_ClShowHookCollOther)
636 {
637 static int s_ShowHookCollOther = 0;
638 if(DoButton_CheckBox(pId: &s_ShowHookCollOther, pText: Localize(pStr: "Always show other players' hook collision lines"), Checked: g_Config.m_ClShowHookCollOther == 2, pRect: &Button))
639 g_Config.m_ClShowHookCollOther = g_Config.m_ClShowHookCollOther != 2 ? 2 : 1;
640 }
641
642 LeftView.HSplitTop(Cut: LineSize * 2.0f, pTop: &Button, pBottom: &LeftView);
643 Ui()->DoScrollbarOption(pId: &g_Config.m_ClHookCollSize, pOption: &g_Config.m_ClHookCollSize, pRect: &Button, pStr: Localize(pStr: "Width of your own hook collision line"), Min: 0, Max: 20, pScale: &CUi::ms_LinearScrollbarScale, Flags: CUi::SCROLLBAR_OPTION_MULTILINE);
644
645 LeftView.HSplitTop(Cut: LineSize * 2.0f, pTop: &Button, pBottom: &LeftView);
646 Ui()->DoScrollbarOption(pId: &g_Config.m_ClHookCollSizeOther, pOption: &g_Config.m_ClHookCollSizeOther, pRect: &Button, pStr: Localize(pStr: "Width of others' hook collision line"), Min: 0, Max: 20, pScale: &CUi::ms_LinearScrollbarScale, Flags: CUi::SCROLLBAR_OPTION_MULTILINE);
647
648 LeftView.HSplitTop(Cut: LineSize * 2.0f, pTop: &Button, pBottom: &LeftView);
649 Ui()->DoScrollbarOption(pId: &g_Config.m_ClHookCollAlpha, pOption: &g_Config.m_ClHookCollAlpha, pRect: &Button, pStr: Localize(pStr: "Hook collision line opacity"), Min: 0, Max: 100, pScale: &CUi::ms_LinearScrollbarScale, Flags: CUi::SCROLLBAR_OPTION_MULTILINE, pSuffix: "%");
650
651 static CButtonContainer s_HookCollNoCollResetId, s_HookCollHookableCollResetId, s_HookCollTeeCollResetId, s_HookCollTipColorResetId;
652 static int s_HookCollToolTip;
653
654 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Colors of the hook collision line:"), FontSize: 13.0f,
655 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
656
657 Ui()->DoButtonLogic(pId: &s_HookCollToolTip, Checked: 0, pRect: &LeftView, Flags: BUTTONFLAG_NONE); // Just for the tooltip, result ignored
658 Ui()->DoToolTip(pId: &s_HookCollToolTip, pNearRect: &LeftView, pText: Localize(pStr: "Your movements are not taken into account when calculating the line colors"));
659 DoLine_ColorPicker(pResetId: &s_HookCollNoCollResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "When nothing is hookable", pContext: "Hook collision line color"), pColorValue: &g_Config.m_ClHookCollColorNoColl, DefaultColor: ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), CheckBoxSpacing: false);
660 DoLine_ColorPicker(pResetId: &s_HookCollHookableCollResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "When something is hookable", pContext: "Hook collision line color"), pColorValue: &g_Config.m_ClHookCollColorHookableColl, DefaultColor: ColorRGBA(130.0f / 255.0f, 232.0f / 255.0f, 160.0f / 255.0f, 1.0f), CheckBoxSpacing: false);
661 DoLine_ColorPicker(pResetId: &s_HookCollTeeCollResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "When a Tee is hookable", pContext: "Hook collision line color"), pColorValue: &g_Config.m_ClHookCollColorTeeColl, DefaultColor: ColorRGBA(1.0f, 1.0f, 0.0f, 1.0f), CheckBoxSpacing: false);
662 DoLine_ColorPicker(pResetId: &s_HookCollTipColorResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Hook collision line tip", pContext: "Hook collision line color"), pColorValue: &g_Config.m_ClHookCollTipColor, DefaultColor: ColorRGBA(1.0f, 1.0f, 0.0f, 0.5f), CheckBoxSpacing: false, pCheckBoxValue: nullptr, Alpha: true);
663
664 // ***** Hook collisions preview ***** //
665 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Preview"), FontSize: HeadlineFontSize,
666 Align: TEXTALIGN_ML, pRect: &RightView, LineSize: HeadlineHeight);
667 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
668
669 auto DoHookCollision = [this](const vec2 &Pos, const float &Length, const int &Size, const ColorRGBA &Color, const ColorRGBA &TipColor, const bool &Invert) {
670 ColorRGBA ColorModified = Color;
671 ColorRGBA TipColorModified = TipColor;
672 if(Invert)
673 ColorModified = color_invert(col: ColorModified);
674 ColorModified = ColorModified.WithAlpha(alpha: (float)g_Config.m_ClHookCollAlpha / 100);
675 TipColorModified = TipColor.WithMultipliedAlpha(alpha: (float)g_Config.m_ClHookCollAlpha / 100);
676 Graphics()->TextureClear();
677 if(Size > 0)
678 {
679 Graphics()->QuadsBegin();
680 Graphics()->SetColor(ColorModified);
681 float LineWidth = 0.5f + (float)(Size - 1) * 0.25f;
682 IGraphics::CQuadItem QuadItem(Pos.x, Pos.y - LineWidth, Length, LineWidth * 2.f);
683 Graphics()->QuadsDrawTL(pArray: &QuadItem, Num: 1);
684 if(TipColor.a > 0.0f)
685 {
686 Graphics()->SetColor(TipColorModified);
687 IGraphics::CQuadItem TipQuadItem(Pos.x + Length, Pos.y - LineWidth, 15.f, LineWidth * 2.f);
688 Graphics()->QuadsDrawTL(pArray: &TipQuadItem, Num: 1);
689 }
690 Graphics()->QuadsEnd();
691 }
692 else
693 {
694 Graphics()->LinesBegin();
695 Graphics()->SetColor(ColorModified);
696 IGraphics::CLineItem LineItem(Pos.x, Pos.y, Pos.x + Length, Pos.y);
697 Graphics()->LinesDraw(pArray: &LineItem, Num: 1);
698 if(TipColor.a > 0.0f)
699 {
700 Graphics()->SetColor(TipColorModified);
701 IGraphics::CLineItem TipLineItem(Pos.x + Length, Pos.y, Pos.x + Length + 15.f, Pos.y);
702 Graphics()->LinesDraw(pArray: &TipLineItem, Num: 1);
703 }
704 Graphics()->LinesEnd();
705 }
706 };
707
708 CTeeRenderInfo OwnSkinInfo;
709 OwnSkinInfo.Apply(pSkin: GameClient()->m_Skins.Find(pName: g_Config.m_ClPlayerSkin));
710 OwnSkinInfo.ApplyColors(CustomColoredSkin: g_Config.m_ClPlayerUseCustomColor, ColorBody: g_Config.m_ClPlayerColorBody, ColorFeet: g_Config.m_ClPlayerColorFeet);
711 OwnSkinInfo.m_Size = 50.0f;
712
713 CTeeRenderInfo DummySkinInfo;
714 DummySkinInfo.Apply(pSkin: GameClient()->m_Skins.Find(pName: g_Config.m_ClDummySkin));
715 DummySkinInfo.ApplyColors(CustomColoredSkin: g_Config.m_ClDummyUseCustomColor, ColorBody: g_Config.m_ClDummyColorBody, ColorFeet: g_Config.m_ClDummyColorFeet);
716 DummySkinInfo.m_Size = 50.0f;
717
718 vec2 TeeRenderPos, DummyRenderPos;
719
720 const float LineLength = 150.f;
721 const float LeftMargin = 30.f;
722
723 const int TileScale = 32.0f;
724
725 // Toggled via checkbox later, inverts some previews
726 static bool s_HookCollPressed = false;
727
728 CUIRect PreviewColl;
729
730 // ***** Unhookable Tile Preview *****
731 CUIRect PreviewNoColl;
732 RightView.HSplitTop(Cut: 50.0f, pTop: &PreviewNoColl, pBottom: &RightView);
733 RightView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &RightView);
734 TeeRenderPos = vec2(PreviewNoColl.x + LeftMargin, PreviewNoColl.y + PreviewNoColl.h / 2.0f);
735 DoHookCollision(TeeRenderPos, PreviewNoColl.w - LineLength, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorNoColl)), ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f), s_HookCollPressed);
736 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &OwnSkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: TeeRenderPos);
737
738 CUIRect NoHookTileRect;
739 PreviewNoColl.VSplitRight(Cut: LineLength, pLeft: &PreviewNoColl, pRight: &NoHookTileRect);
740 NoHookTileRect.VSplitLeft(Cut: 50.0f, pLeft: &NoHookTileRect, pRight: nullptr);
741 NoHookTileRect.Margin(Cut: 10.0f, pOtherRect: &NoHookTileRect);
742
743 // Render unhookable tile
744 Graphics()->TextureClear();
745 Graphics()->TextureSet(Texture: GameClient()->m_MapImages.GetEntities(EntityLayerType: MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH));
746 Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f);
747 RenderMap()->RenderTile(x: NoHookTileRect.x, y: NoHookTileRect.y, Index: TILE_NOHOOK, Scale: TileScale, Color: ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
748
749 // ***** Hookable Tile Preview *****
750 RightView.HSplitTop(Cut: 50.0f, pTop: &PreviewColl, pBottom: &RightView);
751 RightView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &RightView);
752 TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
753 DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorHookableColl)), ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f), s_HookCollPressed);
754 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &OwnSkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: TeeRenderPos);
755
756 CUIRect HookTileRect;
757 PreviewColl.VSplitRight(Cut: LineLength, pLeft: &PreviewColl, pRight: &HookTileRect);
758 HookTileRect.VSplitLeft(Cut: 50.0f, pLeft: &HookTileRect, pRight: nullptr);
759 HookTileRect.Margin(Cut: 10.0f, pOtherRect: &HookTileRect);
760
761 // Render hookable tile
762 Graphics()->TextureClear();
763 Graphics()->TextureSet(Texture: GameClient()->m_MapImages.GetEntities(EntityLayerType: MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH));
764 Graphics()->SetColor(r: 1.0f, g: 1.0f, b: 1.0f, a: 1.0f);
765 RenderMap()->RenderTile(x: HookTileRect.x, y: HookTileRect.y, Index: TILE_SOLID, Scale: TileScale, Color: ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
766
767 // ***** Hook Dummy Preview *****
768 RightView.HSplitTop(Cut: 50.0f, pTop: &PreviewColl, pBottom: &RightView);
769 RightView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &RightView);
770 TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
771 DummyRenderPos = vec2(PreviewColl.x + PreviewColl.w - LineLength - 5.f + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
772 DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength - 15.f, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorTeeColl)), ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f), s_HookCollPressed);
773 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &DummySkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: DummyRenderPos);
774 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &OwnSkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: TeeRenderPos);
775
776 // ***** Hook Dummy Reverse Preview *****
777 RightView.HSplitTop(Cut: 50.0f, pTop: &PreviewColl, pBottom: &RightView);
778 RightView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &RightView);
779 TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
780 DummyRenderPos = vec2(PreviewColl.x + PreviewColl.w - LineLength - 5.f + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
781 DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength - 15.f, g_Config.m_ClHookCollSizeOther, color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorTeeColl)), ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f), false);
782 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &OwnSkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: DummyRenderPos);
783 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &DummySkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: TeeRenderPos);
784
785 // ***** Hook Line Tip Preview *****
786 RightView.HSplitTop(Cut: 50.0f, pTop: &PreviewColl, pBottom: &RightView);
787 RightView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &RightView);
788 TeeRenderPos = vec2(PreviewColl.x + LeftMargin, PreviewColl.y + PreviewColl.h / 2.0f);
789 DoHookCollision(TeeRenderPos, PreviewColl.w - LineLength - 15.f, g_Config.m_ClHookCollSize, color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollColorNoColl)), color_cast<ColorRGBA>(hsl: ColorHSLA(g_Config.m_ClHookCollTipColor, true)), s_HookCollPressed);
790 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &OwnSkinInfo, Emote: 0, Dir: vec2(1.0f, 0.0f), Pos: TeeRenderPos);
791
792 // ***** Preview +hookcoll pressed toggle *****
793 RightView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &RightView);
794 if(DoButton_CheckBox(pId: &s_HookCollPressed, pText: Localize(pStr: "Preview 'Hook collisions' being pressed"), Checked: s_HookCollPressed, pRect: &Button))
795 s_HookCollPressed = !s_HookCollPressed;
796 }
797 else if(s_CurTab == APPEARANCE_TAB_INFO_MESSAGES)
798 {
799 MainView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
800
801 // ***** Info Messages ***** //
802 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Info Messages"), FontSize: HeadlineFontSize,
803 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
804 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
805
806 // General info messages settings
807 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
808 if(DoButton_CheckBox(pId: &g_Config.m_ClShowKillMessages, pText: Localize(pStr: "Show kill messages"), Checked: g_Config.m_ClShowKillMessages, pRect: &Button))
809 {
810 g_Config.m_ClShowKillMessages ^= 1;
811 }
812
813 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
814 if(DoButton_CheckBox(pId: &g_Config.m_ClShowFinishMessages, pText: Localize(pStr: "Show finish messages"), Checked: g_Config.m_ClShowFinishMessages, pRect: &Button))
815 {
816 g_Config.m_ClShowFinishMessages ^= 1;
817 }
818
819 static CButtonContainer s_KillMessageNormalColorId, s_KillMessageHighlightColorId;
820 DoLine_ColorPicker(pResetId: &s_KillMessageNormalColorId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Normal Color"), pColorValue: &g_Config.m_ClKillMessageNormalColor, DefaultColor: ColorRGBA(1.0f, 1.0f, 1.0f), CheckBoxSpacing: false);
821 DoLine_ColorPicker(pResetId: &s_KillMessageHighlightColorId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Highlight Color"), pColorValue: &g_Config.m_ClKillMessageHighlightColor, DefaultColor: ColorRGBA(1.0f, 1.0f, 1.0f), CheckBoxSpacing: false);
822 }
823 else if(s_CurTab == APPEARANCE_TAB_LASER)
824 {
825 MainView.VSplitMid(pLeft: &LeftView, pRight: &RightView, Spacing: MarginBetweenViews);
826
827 // ***** Weapons ***** //
828 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Weapons"), FontSize: HeadlineFontSize,
829 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
830 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
831
832 // General weapon laser settings
833 static CButtonContainer s_LaserRifleOutResetId, s_LaserRifleInResetId, s_LaserShotgunOutResetId, s_LaserShotgunInResetId;
834
835 ColorHSLA LaserRifleOutlineColor = DoLine_ColorPicker(pResetId: &s_LaserRifleOutResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Rifle Laser Outline Color"), pColorValue: &g_Config.m_ClLaserRifleOutlineColor, DefaultColor: ColorRGBA(0.074402f, 0.074402f, 0.247166f, 1.0f), CheckBoxSpacing: false);
836 ColorHSLA LaserRifleInnerColor = DoLine_ColorPicker(pResetId: &s_LaserRifleInResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Rifle Laser Inner Color"), pColorValue: &g_Config.m_ClLaserRifleInnerColor, DefaultColor: ColorRGBA(0.498039f, 0.498039f, 1.0f, 1.0f), CheckBoxSpacing: false);
837 ColorHSLA LaserShotgunOutlineColor = DoLine_ColorPicker(pResetId: &s_LaserShotgunOutResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Shotgun Laser Outline Color"), pColorValue: &g_Config.m_ClLaserShotgunOutlineColor, DefaultColor: ColorRGBA(0.125490f, 0.098039f, 0.043137f, 1.0f), CheckBoxSpacing: false);
838 ColorHSLA LaserShotgunInnerColor = DoLine_ColorPicker(pResetId: &s_LaserShotgunInResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Shotgun Laser Inner Color"), pColorValue: &g_Config.m_ClLaserShotgunInnerColor, DefaultColor: ColorRGBA(0.570588f, 0.417647f, 0.252941f, 1.0f), CheckBoxSpacing: false);
839
840 // ***** Entities ***** //
841 LeftView.HSplitTop(Cut: 10.0f, pTop: nullptr, pBottom: &LeftView);
842 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Entities"), FontSize: HeadlineFontSize,
843 Align: TEXTALIGN_ML, pRect: &LeftView, LineSize: HeadlineHeight);
844 LeftView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &LeftView);
845
846 // General entity laser settings
847 static CButtonContainer s_LaserDoorOutResetId, s_LaserDoorInResetId, s_LaserFreezeOutResetId, s_LaserFreezeInResetId, s_LaserDraggerOutResetId, s_LaserDraggerInResetId;
848
849 ColorHSLA LaserDoorOutlineColor = DoLine_ColorPicker(pResetId: &s_LaserDoorOutResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Door Laser Outline Color"), pColorValue: &g_Config.m_ClLaserDoorOutlineColor, DefaultColor: ColorRGBA(0.0f, 0.131372f, 0.096078f, 1.0f), CheckBoxSpacing: false);
850 ColorHSLA LaserDoorInnerColor = DoLine_ColorPicker(pResetId: &s_LaserDoorInResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Door Laser Inner Color"), pColorValue: &g_Config.m_ClLaserDoorInnerColor, DefaultColor: ColorRGBA(0.262745f, 0.760784f, 0.639215f, 1.0f), CheckBoxSpacing: false);
851 ColorHSLA LaserFreezeOutlineColor = DoLine_ColorPicker(pResetId: &s_LaserFreezeOutResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Freeze Laser Outline Color"), pColorValue: &g_Config.m_ClLaserFreezeOutlineColor, DefaultColor: ColorRGBA(0.131372f, 0.123529f, 0.182352f, 1.0f), CheckBoxSpacing: false);
852 ColorHSLA LaserFreezeInnerColor = DoLine_ColorPicker(pResetId: &s_LaserFreezeInResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Freeze Laser Inner Color"), pColorValue: &g_Config.m_ClLaserFreezeInnerColor, DefaultColor: ColorRGBA(0.482352f, 0.443137f, 0.564705f, 1.0f), CheckBoxSpacing: false);
853 ColorHSLA LaserDraggerOutlineColor = DoLine_ColorPicker(pResetId: &s_LaserDraggerOutResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Dragger Outline Color"), pColorValue: &g_Config.m_ClLaserDraggerOutlineColor, DefaultColor: ColorRGBA(0.1640625f, 0.015625f, 0.015625f, 1.0f), CheckBoxSpacing: false);
854 ColorHSLA LaserDraggerInnerColor = DoLine_ColorPicker(pResetId: &s_LaserDraggerInResetId, LineSize: ColorPickerLineSize, LabelSize: ColorPickerLabelSize, BottomMargin: ColorPickerLineSpacing, pMainRect: &LeftView, pText: Localize(pStr: "Dragger Inner Color"), pColorValue: &g_Config.m_ClLaserDraggerInnerColor, DefaultColor: ColorRGBA(.8666666f, .3725490f, .3725490f, 1.0f), CheckBoxSpacing: false);
855
856 static CButtonContainer s_AllToRifleResetId, s_AllToDefaultResetId;
857
858 LeftView.HSplitTop(Cut: 4 * MarginSmall, pTop: nullptr, pBottom: &LeftView);
859 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
860 if(DoButton_Menu(pButtonContainer: &s_AllToRifleResetId, pText: Localize(pStr: "Set all to Rifle"), Checked: 0, pRect: &Button))
861 {
862 g_Config.m_ClLaserShotgunOutlineColor = g_Config.m_ClLaserRifleOutlineColor;
863 g_Config.m_ClLaserShotgunInnerColor = g_Config.m_ClLaserRifleInnerColor;
864 g_Config.m_ClLaserDoorOutlineColor = g_Config.m_ClLaserRifleOutlineColor;
865 g_Config.m_ClLaserDoorInnerColor = g_Config.m_ClLaserRifleInnerColor;
866 g_Config.m_ClLaserFreezeOutlineColor = g_Config.m_ClLaserRifleOutlineColor;
867 g_Config.m_ClLaserFreezeInnerColor = g_Config.m_ClLaserRifleInnerColor;
868 g_Config.m_ClLaserDraggerOutlineColor = g_Config.m_ClLaserRifleOutlineColor;
869 g_Config.m_ClLaserDraggerInnerColor = g_Config.m_ClLaserRifleInnerColor;
870 }
871
872 // values taken from the CL commands
873 LeftView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &LeftView);
874 LeftView.HSplitTop(Cut: LineSize, pTop: &Button, pBottom: &LeftView);
875 if(DoButton_Menu(pButtonContainer: &s_AllToDefaultResetId, pText: Localize(pStr: "Reset to defaults"), Checked: 0, pRect: &Button))
876 {
877 g_Config.m_ClLaserRifleOutlineColor = 11176233;
878 g_Config.m_ClLaserRifleInnerColor = 11206591;
879 g_Config.m_ClLaserShotgunOutlineColor = 1866773;
880 g_Config.m_ClLaserShotgunInnerColor = 1467241;
881 g_Config.m_ClLaserDoorOutlineColor = 7667473;
882 g_Config.m_ClLaserDoorInnerColor = 7701379;
883 g_Config.m_ClLaserFreezeOutlineColor = 11613223;
884 g_Config.m_ClLaserFreezeInnerColor = 12001153;
885 g_Config.m_ClLaserDraggerOutlineColor = 57618;
886 g_Config.m_ClLaserDraggerInnerColor = 42398;
887 }
888
889 // ***** Laser Preview ***** //
890 Ui()->DoLabel_AutoLineSize(pText: Localize(pStr: "Preview"), FontSize: HeadlineFontSize,
891 Align: TEXTALIGN_ML, pRect: &RightView, LineSize: HeadlineHeight);
892 RightView.HSplitTop(Cut: MarginSmall, pTop: nullptr, pBottom: &RightView);
893
894 const float LaserPreviewHeight = 60.0f;
895 CUIRect LaserPreview;
896 RightView.HSplitTop(Cut: LaserPreviewHeight, pTop: &LaserPreview, pBottom: &RightView);
897 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
898 DoLaserPreview(pRect: &LaserPreview, OutlineColor: LaserRifleOutlineColor, InnerColor: LaserRifleInnerColor, LaserType: LASERTYPE_RIFLE);
899
900 RightView.HSplitTop(Cut: LaserPreviewHeight, pTop: &LaserPreview, pBottom: &RightView);
901 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
902 DoLaserPreview(pRect: &LaserPreview, OutlineColor: LaserShotgunOutlineColor, InnerColor: LaserShotgunInnerColor, LaserType: LASERTYPE_SHOTGUN);
903
904 RightView.HSplitTop(Cut: LaserPreviewHeight, pTop: &LaserPreview, pBottom: &RightView);
905 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
906 DoLaserPreview(pRect: &LaserPreview, OutlineColor: LaserDoorOutlineColor, InnerColor: LaserDoorInnerColor, LaserType: LASERTYPE_DOOR);
907
908 RightView.HSplitTop(Cut: LaserPreviewHeight, pTop: &LaserPreview, pBottom: &RightView);
909 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
910 DoLaserPreview(pRect: &LaserPreview, OutlineColor: LaserFreezeOutlineColor, InnerColor: LaserFreezeInnerColor, LaserType: LASERTYPE_FREEZE);
911
912 RightView.HSplitTop(Cut: LaserPreviewHeight, pTop: &LaserPreview, pBottom: &RightView);
913 RightView.HSplitTop(Cut: 2 * MarginSmall, pTop: nullptr, pBottom: &RightView);
914 DoLaserPreview(pRect: &LaserPreview, OutlineColor: LaserDraggerOutlineColor, InnerColor: LaserDraggerInnerColor, LaserType: LASERTYPE_DRAGGER);
915 }
916}
917
918void CMenus::DoLaserPreview(const CUIRect *pRect, const ColorHSLA LaserOutlineColor, const ColorHSLA LaserInnerColor, const int LaserType)
919{
920 CUIRect Section = *pRect;
921 vec2 From = vec2(Section.x + 30.0f, Section.y + Section.h / 2.0f);
922 vec2 Pos = vec2(Section.x + Section.w - 20.0f, Section.y + Section.h / 2.0f);
923
924 const ColorRGBA OuterColor = color_cast<ColorRGBA>(hsl: ColorHSLA(LaserOutlineColor));
925 const ColorRGBA InnerColor = color_cast<ColorRGBA>(hsl: ColorHSLA(LaserInnerColor));
926 const float TicksHead = Client()->GlobalTime() * Client()->GameTickSpeed();
927
928 // TicksBody = 4.0 for less laser width for weapon alignment
929 GameClient()->m_Items.RenderLaser(From, Pos, OuterColor, InnerColor, TicksBody: 4.0f, TicksHead, Type: LaserType);
930
931 switch(LaserType)
932 {
933 case LASERTYPE_RIFLE:
934 Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_SpriteWeaponLaser);
935 Graphics()->SelectSprite(Id: SPRITE_WEAPON_LASER_BODY);
936 Graphics()->QuadsBegin();
937 Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1);
938 Graphics()->DrawSprite(x: Section.x + 30.0f, y: Section.y + Section.h / 2.0f, Size: 60.0f);
939 Graphics()->QuadsEnd();
940 break;
941 case LASERTYPE_SHOTGUN:
942 Graphics()->TextureSet(Texture: GameClient()->m_GameSkin.m_SpriteWeaponShotgun);
943 Graphics()->SelectSprite(Id: SPRITE_WEAPON_SHOTGUN_BODY);
944 Graphics()->QuadsBegin();
945 Graphics()->QuadsSetSubset(TopLeftU: 0, TopLeftV: 0, BottomRightU: 1, BottomRightV: 1);
946 Graphics()->DrawSprite(x: Section.x + 30.0f, y: Section.y + Section.h / 2.0f, Size: 60.0f);
947 Graphics()->QuadsEnd();
948 break;
949 case LASERTYPE_DRAGGER:
950 {
951 CTeeRenderInfo TeeRenderInfo;
952 TeeRenderInfo.Apply(pSkin: GameClient()->m_Skins.Find(pName: g_Config.m_ClPlayerSkin));
953 TeeRenderInfo.ApplyColors(CustomColoredSkin: g_Config.m_ClPlayerUseCustomColor, ColorBody: g_Config.m_ClPlayerColorBody, ColorFeet: g_Config.m_ClPlayerColorFeet);
954 TeeRenderInfo.m_Size = 64.0f;
955 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &TeeRenderInfo, Emote: EMOTE_NORMAL, Dir: vec2(-1, 0), Pos);
956 break;
957 }
958 case LASERTYPE_FREEZE:
959 {
960 CTeeRenderInfo TeeRenderInfo;
961 if(g_Config.m_ClShowNinja)
962 TeeRenderInfo.Apply(pSkin: GameClient()->m_Skins.Find(pName: "x_ninja"));
963 else
964 TeeRenderInfo.Apply(pSkin: GameClient()->m_Skins.Find(pName: g_Config.m_ClPlayerSkin));
965 TeeRenderInfo.m_TeeRenderFlags = TEE_EFFECT_FROZEN;
966 TeeRenderInfo.m_Size = 64.0f;
967 TeeRenderInfo.m_ColorBody = ColorRGBA(1, 1, 1);
968 TeeRenderInfo.m_ColorFeet = ColorRGBA(1, 1, 1);
969 RenderTools()->RenderTee(pAnim: CAnimState::GetIdle(), pInfo: &TeeRenderInfo, Emote: EMOTE_PAIN, Dir: vec2(1, 0), Pos: From);
970 break;
971 }
972 default:
973 GameClient()->m_Items.RenderLaser(From, Pos: From, OuterColor, InnerColor, TicksBody: 4.0f, TicksHead, Type: LaserType);
974 }
975}
976