3410: Color picker r=def- a=Banana090

Kinda lost track of all the updates this PR contains, so... It's just huge.
For in-game changes it changes HUD settings tab and adds Color Picker UI feature with preview, editboxes on RMB and so on...

https://cdn.discordapp.com/attachments/295908390956433410/787843848810135582/unknown.png

(Github does not want to upload my image here...)

## Checklist

- [x] Tested the change ingame
- [x] Provided screenshots if it is a visual change
- [x] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Дядя Женя <spy090@yandex.ru>
Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2020-12-18 22:07:56 +00:00 committed by GitHub
commit 5fa2e04c97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 889 additions and 486 deletions

View file

@ -780,6 +780,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;

View file

@ -91,6 +91,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;

View file

@ -11,13 +11,9 @@ class CChat : public CComponent
{
CLineInput m_Input;
static constexpr float MESSAGE_PADDING_X = 5.0f;
static constexpr float MESSAGE_TEE_SIZE = 7.0f;
static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f;
static constexpr float FONT_SIZE = 6.0f;
static constexpr float MESSAGE_PADDING_Y = 1.0f;
static constexpr float MESSAGE_ROUNDING = 3.0f;
static_assert(FONT_SIZE + MESSAGE_PADDING_Y >= MESSAGE_ROUNDING * 2.0f, "Corners for background chat are too huge for this combination of font size and message padding.");
static constexpr float CHAT_WIDTH = 200.0f;
static constexpr float CHAT_HEIGHT_FULL = 200.0f;
static constexpr float CHAT_HEIGHT_MIN = 50.0f;
enum
{
@ -121,6 +117,14 @@ class CChat : public CComponent
public:
CChat();
static constexpr float MESSAGE_PADDING_X = 5.0f;
static constexpr float MESSAGE_TEE_SIZE = 7.0f;
static constexpr float MESSAGE_TEE_PADDING_RIGHT = 0.5f;
static constexpr float FONT_SIZE = 6.0f;
static constexpr float MESSAGE_PADDING_Y = 1.0f;
static constexpr float MESSAGE_ROUNDING = 3.0f;
static_assert(FONT_SIZE + MESSAGE_PADDING_Y >= MESSAGE_ROUNDING * 2.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);

View file

@ -55,6 +55,9 @@ ColorRGBA CMenus::ms_ColorTabbarInactiveIngame;
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;
float CMenus::ms_FontmodHeight = 0.8f;
@ -177,11 +180,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)
@ -207,6 +227,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);
}
@ -339,6 +363,118 @@ 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);
Graphics()->BlendNormal();
Graphics()->TextureClear();
Graphics()->QuadsBegin();
LaserRGB = color_cast<ColorRGBA, ColorHSLA>(LaserOutlineColor);
ColorRGBA OuterColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f);
Graphics()->SetColor(LaserRGB.r, LaserRGB.g, LaserRGB.b, 1.0f);
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);
LaserRGB = color_cast<ColorRGBA, ColorHSLA>(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<ColorHSLA>(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);
@ -351,6 +487,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);
@ -1214,6 +1471,196 @@ 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;
ms_ValueSelectorTextMode = false;
UI()->SetActiveItem(0);
return;
}
// Render
ColorRGBA BackgroundColor(0.1f, 0.1f, 0.1f, 1.0f);
RenderTools()->DrawUIRect(&PickerRect, BackgroundColor, 0, 0);
CUIRect ColorsArea, HueArea, ValuesHitbox, BottomArea, HSVHRect, HSVSRect, HSVVRect, HEXRect, ALPHARect;
PickerRect.Margin(3, &ColorsArea);
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.HSplitTop(20, &HSVHRect, &BottomArea);
BottomArea.HSplitTop(3, 0x0, &BottomArea);
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, BlackColor, 0, 0);
ColorsArea.Margin(1, &ColorsArea);
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<ColorRGBA, ColorHSVA>(ColorHSVA(PickerColorHSV.x, 0.0f, 1.0f));
vec4 TL(rgb.r, rgb.g, rgb.b, 1.0f);
rgb = color_cast<ColorRGBA, ColorHSVA>(ColorHSVA(PickerColorHSV.x, 1.0f, 1.0f));
vec4 TR(rgb.r, rgb.g, rgb.b, 1.0f);
rgb = color_cast<ColorRGBA, ColorHSVA>(ColorHSVA(PickerColorHSV.x, 0.0f, 1.0f));
vec4 BL(rgb.r, rgb.g, rgb.b, 1.0f);
rgb = color_cast<ColorRGBA, ColorHSVA>(ColorHSVA(PickerColorHSV.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);
}
//Editboxes Area
ColorRGBA EditboxBackground(0, 0, 0, 0.4f);
static int RGBRID = 0;
static int RGBGID = 0;
static int RGBBID = 0;
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<ColorRGBA, ColorHSVA>(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<ColorHSVA, ColorRGBA>(NEWHEX);
// 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);
// Logic
float 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(&HuePickerID, &HueArea, &PickerX, &PickerY))
PickerColorHSV.x = 1.0f - PickerY / HueArea.h;
// Marker Color Area
float MarkerX = ColorsArea.x + ColorsArea.w * PickerColorHSV.y;
float MarkerY = ColorsArea.y + ColorsArea.h * (1.0f - PickerColorHSV.z);
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, 4.5f, 32);
Graphics()->SetColor(color_cast<ColorRGBA, ColorHSVA>(PickerColorHSV));
RenderTools()->DrawCircle(MarkerX, MarkerY, 3.5f, 32);
Graphics()->QuadsEnd();
// Marker Hue Area
CUIRect HueMarker;
HueArea.Margin(-2.5f, &HueMarker);
HueMarker.h = 6.5f;
HueMarker.y = (HueArea.y + HueArea.h * (1.0f - PickerColorHSV.x)) - HueMarker.h / 2.0f;
ColorRGBA HueMarkerColor = color_cast<ColorRGBA, ColorHSVA>(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, CUI::CORNER_ALL, 1.2f);
HueMarker.Margin(1.2f, &HueMarker);
RenderTools()->DrawUIRect(&HueMarker, HueMarkerColor, CUI::CORNER_ALL, 1.2f);
ms_ColorPicker.m_HSVColor = PickerColorHSV.Pack(false);
*ms_ColorPicker.m_pColor = color_cast<ColorHSLA, ColorHSVA>(PickerColorHSV).Pack(false);
}
int CMenus::Render()
{
if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_Popup == POPUP_NONE)
@ -1357,9 +1804,7 @@ int CMenus::Render()
RenderServerbrowser(MainView);
}
else if(m_MenuPage == PAGE_SETTINGS)
{
RenderSettings(MainView);
}
// do tab bar
RenderMenubar(TabBar);
@ -2258,7 +2703,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)
{

View file

@ -24,6 +24,22 @@ struct CServerProcess
CLineReader LineReader;
};
struct SColorPicker
{
public:
const float ms_Width = 160.0f;
const float ms_Height = 186.0f;
float m_X;
float m_Y;
bool m_Active;
CUIRect m_AttachedRect;
unsigned int *m_pColor;
unsigned int m_HSVColor;
};
// compnent to fetch keypresses, override all other input
class CMenusKeyBinder : public CComponent
{
@ -49,6 +65,9 @@ class CMenus : public CComponent
static ColorRGBA ms_ColorTabbarActive;
static ColorRGBA ms_ColorTabbarHover;
static SColorPicker ms_ColorPicker;
static bool ms_ValueSelectorTextMode;
char m_aLocalStringHelper[1024];
float ButtonColorMulActive() { return 0.5f; }
@ -59,19 +78,21 @@ 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, 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);
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);
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);
@ -94,6 +115,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<typename T>
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)
@ -663,6 +686,7 @@ private:
// found in menus_settings.cpp
void RenderSettingsDDNet(CUIRect MainView);
void RenderSettingsHUD(CUIRect MainView);
ColorHSLA RenderHSLColorPicker(const CUIRect *pRect, unsigned int *pColor, bool Alpha);
ColorHSLA RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha = false);
CServerProcess m_ServerProcess;

View file

@ -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,57 @@ 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)
{
ColorHSLA HSLColor(*pColor, false);
ColorRGBA RGBColor = color_cast<ColorRGBA>(HSLColor);
ColorRGBA Outline(1, 1, 1, 0.25f);
const float OutlineSize = 3.0f;
Outline.a *= ButtonColorMul(pColor);
CUIRect Rect;
pRect->Margin(OutlineSize, &Rect);
RenderTools()->DrawUIRect(pRect, Outline, CUI::CORNER_ALL, 4.0f);
RenderTools()->DrawUIRect(&Rect, RGBColor, CUI::CORNER_ALL, 4.0f);
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;
ms_ColorPicker.m_HSVColor = color_cast<ColorHSVA, ColorHSLA>(HSLColor).Pack(false);
}
}
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;
ms_ColorPicker.m_HSVColor = color_cast<ColorHSVA, ColorHSLA>(HSLColor).Pack(false);
}
}
return HSLColor;
}
ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool Alpha)
@ -1587,430 +1642,285 @@ 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, Messages, Button, Label, Weapon, Laser, Page1Tab, Page2Tab, Enable, Heart;
CUIRect HUD, Chat, Section, SectionTwo;
MainView.HSplitTop(150.0f, &HUD, &MainView);
MainView.VSplitMid(&HUD, &Chat);
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);
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);
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;
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);
HUD.Margin(5.0f, &HUD);
HUD.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0);
Right.VMargin(5.0f, &Right);
const float LineMargin = 20.0f;
if(Page == 1)
// ***** HUD ***** //
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_ClChatOld, Localize("Use old chat style"), &g_Config.m_ClChatOld, &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(1, 1, 1, 0.1f), CUI::CORNER_ALL, 8.0f);
Chat.HSplitTop(10.0f, 0x0, &Chat);
ColorRGBA SystemColor = color_cast<ColorRGBA, ColorHSLA>(ColorHSLA(g_Config.m_ClMessageSystemColor));
ColorRGBA HighlightedColor = color_cast<ColorRGBA, ColorHSLA>(ColorHSLA(g_Config.m_ClMessageHighlightColor));
ColorRGBA TeamColor = color_cast<ColorRGBA, ColorHSLA>(ColorHSLA(g_Config.m_ClMessageTeamColor));
ColorRGBA FriendColor = color_cast<ColorRGBA, ColorHSLA>(ColorHSLA(g_Config.m_ClMessageFriendColor));
ColorRGBA NormalColor = color_cast<ColorRGBA, ColorHSLA>(ColorHSLA(g_Config.m_ClMessageColor));
ColorRGBA ClientColor = color_cast<ColorRGBA, ColorHSLA>(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_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;
float Y = Chat.y;
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, X, Y, RealFontSize, TEXTFLAG_RENDER);
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_ClChatOld)
{
// 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;
}
Right.HSplitTop(20.0f, &Button, &Right);
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);
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_ClChatOld, Localize("Use old chat style"), g_Config.m_ClChatOld, &Button))
{
g_Config.m_ClChatOld ^= 1;
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);
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<ColorHSLA>(ColorRGBA(1.0f, 1.0f, 0.5f));
g_Config.m_ClMessageSystemColor = HSL.Pack(false);
}
}
ColorHSLA SMColor = RenderHSLScrollbars(&Left, &g_Config.m_ClMessageSystemColor);
Left.HSplitTop(10.0f, &Label, &Left);
ColorRGBA rgb = color_cast<ColorRGBA>(SMColor);
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<ColorHSLA>(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<ColorRGBA>(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<ColorHSLA>(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<ColorRGBA>(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<ColorRGBA>(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<ColorRGBA>(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<ColorHSLA>(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<ColorRGBA>(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<ColorHSLA>(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<ColorRGBA>(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<ColorHSLA>(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<ColorHSLA>(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;
Graphics()->BlendNormal();
Graphics()->TextureClear();
Graphics()->QuadsBegin();
Graphics()->SetColor(0, 0, 0, 0.12f);
// do outline
RGB = color_cast<ColorRGBA>(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;
constexpr float RealBackgroundRounding = CChat::MESSAGE_ROUNDING * 2.0f;
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<ColorRGBA>(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();
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;
}
// 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: Evgesha: Hey, how are you ", sizeof(LineBuilder));
else
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);
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, RealBackgroundRounding, 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, RealBackgroundRounding, 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, 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, RealBackgroundRounding, CUI::CORNER_ALL);
Graphics()->QuadsEnd();
// Load skins
int DefaultInd = GameClient()->m_pSkins->Find("default");
for(auto &i : RenderInfo)
{
i.m_Size = RealTeeSize;
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("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;
}
/*
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)
// System
if(g_Config.m_ClShowChatSystem)
{
str_format(aBuf, sizeof(aBuf), "%s %i %s", Localize("Wait before try for"), g_Config.m_ClReconnectTimeout, Localize("second"));
TextRender()->TextColor(SystemColor);
TextRender()->TextEx(&Cursor, "*** '", -1);
TextRender()->TextEx(&Cursor, aBuf, -1);
TextRender()->TextEx(&Cursor, "' 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: Evgesha: ", -1);
else
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_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
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_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
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<int>(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_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);
// 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_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);
// Client
TextRender()->TextColor(ClientColor);
TextRender()->TextEx(&Cursor, "*** Echo command executed", -1);
TextRender()->SetCursorPosition(&Cursor, X, Y);
TextRender()->TextColor(1, 1, 1, 1);
}
void CMenus::RenderSettingsDDNet(CUIRect MainView)
@ -2214,69 +2124,70 @@ 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;
Left.HSplitTop(25.0f, &TempLabel, &Left);
Left.HSplitTop(5.0f, 0x0, &Left);
unsigned *paColors[2] = {&g_Config.m_ClBackgroundColor, &g_Config.m_ClBackgroundEntitiesColor};
const char *paParts[2] = {Localize("Background (regular)"), Localize("Background (entities)")};
UI()->DoLabelScaled(&TempLabel, Localize("Background"), 20.0f, -1);
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]);
Right.HSplitTop(25.0f, 0x0, &Right);
Right.HSplitTop(25.0f, &TempLabel, &Right);
Right.HSplitTop(5.0f, 0x0, &Miscellaneous);
RenderHSLScrollbars(&aRects[i], paColors[i]);
}
UI()->DoLabelScaled(&TempLabel, Localize("Miscellaneous"), 20.0f, -1);
{
static float s_Map = 0.0f;
aRects[1].HSplitTop(25.0f, &Background, &aRects[1]);
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);
static int ResetID1 = 0;
static int ResetID2 = 0;
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);
aRects[1].HSplitTop(20.0f, &Button, &aRects[1]);
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));
}
aRects[1].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;
}
}
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);
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);
if(DoButton_CheckBox(&g_Config.m_ClHttpMapDownload, Localize("Try fast HTTP map download first"), g_Config.m_ClHttpMapDownload, &Button))
bool UseCurrentMap = str_comp(g_Config.m_ClBackgroundEntities, CURRENT_MAP) == 0;
if(DoButton_CheckBox(&UseCurrentMap, Localize("Use current map as background"), UseCurrentMap, &Button))
{
g_Config.m_ClHttpMapDownload ^= 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))
{
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();
@ -2289,7 +2200,9 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Button.VSplitLeft(100.0f, &Button, 0);
static int s_ButtonUpdate = 0;
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..."));
@ -2313,13 +2226,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();
}
}
}

View file

@ -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];

View file

@ -96,6 +96,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);

View file

@ -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)

View file

@ -183,6 +183,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;
@ -233,12 +234,15 @@ 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; }
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)