Refactor vertical alignment in UI

Add separate constants `TEXTALIGN_TOP`, `TEXTALIGN_MIDDLE` and `TEXTALIGN_BOTTOM` for vertical alignment.

Add shorthand constants for all possible combinations of horizontal and vertical alignment, e.g. `TEXTALIGN_MC` for `TEXTALIGN_MIDDLE | TEXTALIGN_CENTER`.

Replace usage of `SLabelProperties::m_AlignVertically` with these constants in all menu and editor code for more convenient and versatile alignment of text. Use combined horizontal-vertical alignment constants for all existing labels. Manually adjust layout for some elements which were initially misaligned with the new implementation.

Refactoring:

- Use `CORNER_NONE` instead of `0`.
- Improve some `CUIRect` variables names and usage.
This commit is contained in:
Robert Müller 2023-04-09 21:24:06 +02:00
parent bf1e757581
commit 8507a651d1
19 changed files with 366 additions and 426 deletions

View file

@ -20,9 +20,25 @@ enum
enum ETextAlignment enum ETextAlignment
{ {
TEXTALIGN_LEFT = 1 << 0, TEXTALIGN_LEFT = 0,
TEXTALIGN_CENTER = 1 << 1, TEXTALIGN_CENTER = 1 << 1,
TEXTALIGN_RIGHT = 1 << 2, TEXTALIGN_RIGHT = 1 << 2,
TEXTALIGN_TOP = 0, // this is also 0, so the default alignment is top-left
TEXTALIGN_MIDDLE = 1 << 3,
TEXTALIGN_BOTTOM = 1 << 4,
TEXTALIGN_TL = TEXTALIGN_TOP | TEXTALIGN_LEFT,
TEXTALIGN_TC = TEXTALIGN_TOP | TEXTALIGN_CENTER,
TEXTALIGN_TR = TEXTALIGN_TOP | TEXTALIGN_RIGHT,
TEXTALIGN_ML = TEXTALIGN_MIDDLE | TEXTALIGN_LEFT,
TEXTALIGN_MC = TEXTALIGN_MIDDLE | TEXTALIGN_CENTER,
TEXTALIGN_MR = TEXTALIGN_MIDDLE | TEXTALIGN_RIGHT,
TEXTALIGN_BL = TEXTALIGN_BOTTOM | TEXTALIGN_LEFT,
TEXTALIGN_BC = TEXTALIGN_BOTTOM | TEXTALIGN_CENTER,
TEXTALIGN_BR = TEXTALIGN_BOTTOM | TEXTALIGN_RIGHT,
TEXTALIGN_MASK_HORIZONTAL = TEXTALIGN_LEFT | TEXTALIGN_CENTER | TEXTALIGN_RIGHT,
TEXTALIGN_MASK_VERTICAL = TEXTALIGN_TOP | TEXTALIGN_MIDDLE | TEXTALIGN_BOTTOM,
}; };
enum ETextRenderFlags enum ETextRenderFlags

View file

@ -595,12 +595,12 @@ void CHud::RenderVoting()
str_format(aBuf, sizeof(aBuf), "%s - %s", aKey, Localize("Vote yes")); str_format(aBuf, sizeof(aBuf), "%s - %s", aKey, Localize("Vote yes"));
Base.y += Base.h; Base.y += Base.h;
Base.h = 11.f; Base.h = 12.0f;
UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_ML);
m_pClient->m_Binds.GetKey("vote no", aKey, sizeof(aKey)); m_pClient->m_Binds.GetKey("vote no", aKey, sizeof(aKey));
str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), aKey); str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), aKey);
UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_MR);
} }
void CHud::RenderCursor() void CHud::RenderCursor()

View file

@ -128,7 +128,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect,
return Active ? UI()->DoButtonLogic(pID, Checked, pRect) : 0; return Active ? UI()->DoButtonLogic(pID, Checked, pRect) : 0;
} }
int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, 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) int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, int Corners, float r, float FontFactor, vec4 ColorHot, vec4 Color, bool CheckForActiveColorPicker)
{ {
CUIRect Text = *pRect; CUIRect Text = *pRect;
@ -174,9 +174,7 @@ int CMenus::DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText,
Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text); Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text);
Text.HMargin((Text.h * FontFactor) / 2.0f, &Text); Text.HMargin((Text.h * FontFactor) / 2.0f, &Text);
SLabelProperties Props; UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
Props.m_AlignVertically = AlignVertically;
UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
if(MouseInsideColorPicker) if(MouseInsideColorPicker)
return 0; return 0;
@ -189,10 +187,10 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, const CUIRec
pRect->Draw(ColorRGBA(1, 1, 1, 0.5f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f); pRect->Draw(ColorRGBA(1, 1, 1, 0.5f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f);
CUIRect Temp; CUIRect Temp;
pRect->HMargin(1.0f, &Temp); pRect->HMargin(1.0f, &Temp);
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER); UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
} }
int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding, int AlignVertically) int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator, const ColorRGBA *pDefaultColor, const ColorRGBA *pActiveColor, const ColorRGBA *pHoverColor, float EdgeRounding)
{ {
const bool MouseInside = UI()->MouseInside(pRect); const bool MouseInside = UI()->MouseInside(pRect);
CUIRect Rect = *pRect; CUIRect Rect = *pRect;
@ -267,9 +265,7 @@ int CMenus::DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pTe
CUIRect Temp; CUIRect Temp;
Rect.HMargin(2.0f, &Temp); Rect.HMargin(2.0f, &Temp);
SLabelProperties Props; UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
Props.m_AlignVertically = AlignVertically;
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
return UI()->DoButtonLogic(pButtonContainer, Checked, pRect); return UI()->DoButtonLogic(pButtonContainer, Checked, pRect);
} }
@ -280,38 +276,35 @@ int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked,
pRect->Draw(ColorRGBA(1, 0.98f, 0.5f, 0.55f), IGraphics::CORNER_T, 5.0f); pRect->Draw(ColorRGBA(1, 0.98f, 0.5f, 0.55f), IGraphics::CORNER_T, 5.0f);
else if(Checked) else if(Checked)
pRect->Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_T, 5.0f); pRect->Draw(ColorRGBA(1, 1, 1, 0.5f), IGraphics::CORNER_T, 5.0f);
CUIRect t;
pRect->VSplitLeft(5.0f, 0, &t); CUIRect Temp;
UI()->DoLabel(&t, pText, pRect->h * CUI::ms_FontmodHeight, TEXTALIGN_LEFT); pRect->VSplitLeft(5.0f, nullptr, &Temp);
UI()->DoLabel(&Temp, pText, pRect->h * CUI::ms_FontmodHeight, TEXTALIGN_ML);
return UI()->DoButtonLogic(pID, Checked, pRect); return UI()->DoButtonLogic(pID, Checked, pRect);
} }
int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect) int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect)
{ {
CUIRect c = *pRect; CUIRect Box, Label;
CUIRect t = *pRect; pRect->VSplitLeft(pRect->h, &Box, &Label);
c.w = c.h; Label.VSplitLeft(5.0f, nullptr, &Label);
t.x += c.w;
t.w -= c.w;
t.VSplitLeft(5.0f, 0, &t);
c.Margin(2.0f, &c); Box.Margin(2.0f, &Box);
c.Draw(ColorRGBA(1, 1, 1, 0.25f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 3.0f); Box.Draw(ColorRGBA(1, 1, 1, 0.25f * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 3.0f);
const bool Checkable = *pBoxText == 'X'; const bool Checkable = *pBoxText == 'X';
SLabelProperties Props;
Props.m_AlignVertically = 0;
if(Checkable) if(Checkable)
{ {
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
UI()->DoLabel(&c, FONT_ICON_XMARK, c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props); UI()->DoLabel(&Box, FONT_ICON_XMARK, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(nullptr);
} }
else else
UI()->DoLabel(&c, pBoxText, c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props); UI()->DoLabel(&Box, pBoxText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
UI()->DoLabel(&t, pText, c.h * CUI::ms_FontmodHeight, TEXTALIGN_LEFT); UI()->DoLabel(&Label, pText, Box.h * CUI::ms_FontmodHeight, TEXTALIGN_ML);
return UI()->DoButtonLogic(pID, 0, pRect); return UI()->DoButtonLogic(pID, 0, pRect);
} }
@ -412,12 +405,12 @@ ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float Lin
Section.VSplitRight(8.0f, &Section, nullptr); Section.VSplitRight(8.0f, &Section, nullptr);
Section.VSplitRight(Section.h, &Section, &ColorPickerButton); Section.VSplitRight(Section.h, &Section, &ColorPickerButton);
UI()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_ML);
ColorHSLA PickedColor = RenderHSLColorPicker(&ColorPickerButton, pColorValue, false); ColorHSLA PickedColor = RenderHSLColorPicker(&ColorPickerButton, pColorValue, false);
ResetButton.HMargin(2.0f, &ResetButton); ResetButton.HMargin(2.0f, &ResetButton);
if(DoButton_Menu(pResetID, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 8.0f, 0.0f, vec4(1, 1, 1, 0.5f), vec4(1, 1, 1, 0.25f), 1, true)) if(DoButton_Menu(pResetID, Localize("Reset"), 0, &ResetButton, nullptr, IGraphics::CORNER_ALL, 8.0f, 0.0f, vec4(1, 1, 1, 0.5f), vec4(1, 1, 1, 0.25f), true))
{ {
*pColorValue = color_cast<ColorHSLA>(DefaultColor).Pack(false); *pColorValue = color_cast<ColorHSLA>(DefaultColor).Pack(false);
} }
@ -565,7 +558,7 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
str_format(aBuf, sizeof(aBuf), "%d", Current); str_format(aBuf, sizeof(aBuf), "%d", Current);
} }
pRect->Draw(*pColor, IGraphics::CORNER_ALL, Round); pRect->Draw(*pColor, IGraphics::CORNER_ALL, Round);
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER); UI()->DoLabel(pRect, aBuf, 10.0f, TEXTALIGN_MC);
} }
return Current; return Current;
@ -690,7 +683,7 @@ int CMenus::RenderMenubar(CUIRect r)
pHomeButtonColorHover = &HomeButtonColorAlertHover; pHomeButtonColorHover = &HomeButtonColorAlertHover;
} }
if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_HOME], pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f, 0)) if(DoButton_MenuTab(&s_StartButton, pHomeScreenButtonLabel, false, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_HOME], pHomeButtonColor, pHomeButtonColor, pHomeButtonColorHover, 10.0f))
{ {
m_ShowStart = true; m_ShowStart = true;
} }
@ -823,7 +816,7 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static CButtonContainer s_QuitButton; static CButtonContainer s_QuitButton;
ColorRGBA QuitColor(1, 0, 0, 0.5f); ColorRGBA QuitColor(1, 0, 0, 0.5f);
if(DoButton_MenuTab(&s_QuitButton, FONT_ICON_POWER_OFF, 0, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_QUIT], NULL, NULL, &QuitColor, 10.0f, 0)) if(DoButton_MenuTab(&s_QuitButton, FONT_ICON_POWER_OFF, 0, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_QUIT], nullptr, nullptr, &QuitColor, 10.0f))
{ {
if(m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0)) if(m_pClient->Editor()->HasUnsavedData() || (Client()->GetCurrentRaceTime() / 60 >= g_Config.m_ClConfirmQuitTime && g_Config.m_ClConfirmQuitTime >= 0))
{ {
@ -839,13 +832,13 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static CButtonContainer s_SettingsButton; static CButtonContainer s_SettingsButton;
if(DoButton_MenuTab(&s_SettingsButton, FONT_ICON_GEAR, m_ActivePage == PAGE_SETTINGS, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], NULL, NULL, NULL, 10.0f, 0)) if(DoButton_MenuTab(&s_SettingsButton, FONT_ICON_GEAR, m_ActivePage == PAGE_SETTINGS, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SETTINGS], nullptr, nullptr, nullptr, 10.0f))
NewPage = PAGE_SETTINGS; NewPage = PAGE_SETTINGS;
Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(10.0f, &Box, &Button);
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static CButtonContainer s_EditorButton; static CButtonContainer s_EditorButton;
if(DoButton_MenuTab(&s_EditorButton, FONT_ICON_PEN_TO_SQUARE, 0, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], NULL, NULL, NULL, 10.0f, 0)) if(DoButton_MenuTab(&s_EditorButton, FONT_ICON_PEN_TO_SQUARE, 0, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_EDITOR], nullptr, nullptr, nullptr, 10.0f))
{ {
g_Config.m_ClEditor = 1; g_Config.m_ClEditor = 1;
} }
@ -856,19 +849,19 @@ int CMenus::RenderMenubar(CUIRect r)
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static CButtonContainer s_DemoButton; static CButtonContainer s_DemoButton;
if(DoButton_MenuTab(&s_DemoButton, FONT_ICON_CLAPPERBOARD, m_ActivePage == PAGE_DEMOS, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], NULL, NULL, NULL, 10.0f, 0)) if(DoButton_MenuTab(&s_DemoButton, FONT_ICON_CLAPPERBOARD, m_ActivePage == PAGE_DEMOS, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_DEMOBUTTON], nullptr, nullptr, nullptr, 10.0f))
NewPage = PAGE_DEMOS; NewPage = PAGE_DEMOS;
Box.VSplitRight(10.0f, &Box, &Button); Box.VSplitRight(10.0f, &Box, &Button);
Box.VSplitRight(33.0f, &Box, &Button); Box.VSplitRight(33.0f, &Box, &Button);
static CButtonContainer s_ServerButton; static CButtonContainer s_ServerButton;
if(DoButton_MenuTab(&s_ServerButton, FONT_ICON_EARTH_AMERICAS, m_ActivePage == g_Config.m_UiPage, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], NULL, NULL, NULL, 10.0f, 0)) if(DoButton_MenuTab(&s_ServerButton, FONT_ICON_EARTH_AMERICAS, m_ActivePage == g_Config.m_UiPage, &Button, IGraphics::CORNER_T, &m_aAnimatorsSmallPage[SMALL_TAB_SERVER], nullptr, nullptr, nullptr, 10.0f))
NewPage = g_Config.m_UiPage; NewPage = g_Config.m_UiPage;
} }
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(nullptr);
if(NewPage != -1) if(NewPage != -1)
{ {
@ -925,13 +918,13 @@ void CMenus::RenderLoading(const char *pCaption, const char *pContent, int Incre
Part.VMargin(20.f, &Part); Part.VMargin(20.f, &Part);
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
UI()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, pCaption, 24.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
Part.VMargin(20.f, &Part); Part.VMargin(20.f, &Part);
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, pContent, 20.0f, TEXTALIGN_MC);
if(RenderLoadingBar) if(RenderLoadingBar)
Graphics()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f); Graphics()->DrawRect(Box.x + 40, Box.y + Box.h - 75, (Box.w - 80) * Percent, 25, ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f), IGraphics::CORNER_ALL, 5.0f);
@ -945,8 +938,8 @@ void CMenus::RenderNews(CUIRect MainView)
MainView.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 10.0f); MainView.Draw(ms_ColorTabbarActive, IGraphics::CORNER_B, 10.0f);
MainView.HSplitTop(15.0f, 0, &MainView); MainView.HSplitTop(10.0f, nullptr, &MainView);
MainView.VSplitLeft(15.0f, 0, &MainView); MainView.VSplitLeft(15.0f, nullptr, &MainView);
CUIRect Label; CUIRect Label;
@ -959,12 +952,12 @@ void CMenus::RenderNews(CUIRect MainView)
{ {
MainView.HSplitTop(30.0f, &Label, &MainView); MainView.HSplitTop(30.0f, &Label, &MainView);
aLine[Len - 1] = '\0'; aLine[Len - 1] = '\0';
UI()->DoLabel(&Label, aLine + 1, 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aLine + 1, 20.0f, TEXTALIGN_ML);
} }
else else
{ {
MainView.HSplitTop(20.0f, &Label, &MainView); MainView.HSplitTop(20.0f, &Label, &MainView);
UI()->DoLabel(&Label, aLine, 15.f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aLine, 15.f, TEXTALIGN_ML);
} }
} }
} }
@ -1233,7 +1226,7 @@ void CMenus::RenderColorPicker()
PickerColorHSV = color_cast<ColorHSVA>(ColorRGBA(NewHex)); PickerColorHSV = color_cast<ColorHSVA>(ColorRGBA(NewHex));
// TODO : ALPHA SUPPORT // TODO : ALPHA SUPPORT
UI()->DoLabel(&AlphaRect, "A: 255", 10, TEXTALIGN_CENTER); UI()->DoLabel(&AlphaRect, "A: 255", 10, TEXTALIGN_MC);
AlphaRect.Draw(ColorRGBA(0, 0, 0, 0.65f), IGraphics::CORNER_ALL, 5.0f); AlphaRect.Draw(ColorRGBA(0, 0, 0, 0.65f), IGraphics::CORNER_ALL, 5.0f);
// Logic // Logic
@ -1613,9 +1606,9 @@ int CMenus::Render()
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
if(TextRender()->TextWidth(24.f, pTitle, -1, -1.0f) > Part.w) if(TextRender()->TextWidth(24.f, pTitle, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_LEFT, Props); UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_ML, Props);
else else
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
@ -1625,20 +1618,20 @@ int CMenus::Render()
if(UseIpLabel) if(UseIpLabel)
{ {
UI()->DoLabel(&Part, Client()->ConnectAddressString(), FontSize, TEXTALIGN_CENTER); UI()->DoLabel(&Part, Client()->ConnectAddressString(), FontSize, TEXTALIGN_MC);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
} }
Props.m_MaxWidth = (int)Part.w; Props.m_MaxWidth = (int)Part.w;
if(ExtraAlign == -1) if(ExtraAlign == -1)
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props); UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_ML, Props);
else else
{ {
if(TextRender()->TextWidth(FontSize, pExtraText, -1, -1.0f) > Part.w) if(TextRender()->TextWidth(FontSize, pExtraText, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props); UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_ML, Props);
else else
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_CENTER); UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_MC);
} }
if(m_Popup == POPUP_MESSAGE || m_Popup == POPUP_CONFIRM) if(m_Popup == POPUP_MESSAGE || m_Popup == POPUP_CONFIRM)
@ -1689,7 +1682,7 @@ int CMenus::Render()
{ {
str_format(aBuf, sizeof(aBuf), "%s\n%s", Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), Localize("Quit anyway?")); str_format(aBuf, sizeof(aBuf), "%s\n%s", Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), Localize("Quit anyway?"));
Props.m_MaxWidth = Part.w - 20.0f; Props.m_MaxWidth = Part.w - 20.0f;
UI()->DoLabel(&Box, aBuf, 20.f, TEXTALIGN_LEFT, Props); UI()->DoLabel(&Box, aBuf, 20.f, TEXTALIGN_ML, Props);
} }
// buttons // buttons
@ -1739,7 +1732,7 @@ int CMenus::Render()
Label.VSplitLeft(100.0f, 0, &TextBox); Label.VSplitLeft(100.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("Password"), 18.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Password"), 18.0f, TEXTALIGN_ML);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
UI()->DoEditBox(&g_Config.m_Password, &TextBox, g_Config.m_Password, sizeof(g_Config.m_Password), 12.0f, &s_Offset, true); UI()->DoEditBox(&g_Config.m_Password, &TextBox, g_Config.m_Password, sizeof(g_Config.m_Password), 12.0f, &s_Offset, true);
} }
@ -1784,7 +1777,7 @@ int CMenus::Render()
Box.HSplitTop(64.f, 0, &Box); Box.HSplitTop(64.f, 0, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f); str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f);
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC);
// time left // time left
int TimeLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast<int>((Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed) : 1); int TimeLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast<int>((Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed) : 1);
@ -1799,7 +1792,7 @@ int CMenus::Render()
} }
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_MC);
// progress bar // progress bar
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
@ -1865,9 +1858,7 @@ int CMenus::Render()
ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f);
m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h); m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
SLabelProperties ItemLabelProps; UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_ML);
ItemLabelProps.m_AlignVertically = 0;
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_CENTER, ItemLabelProps);
} }
const int NewSelected = s_ListBox.DoEnd(); const int NewSelected = s_ListBox.DoEnd();
@ -1939,7 +1930,7 @@ int CMenus::Render()
Label.VSplitLeft(120.0f, 0, &TextBox); Label.VSplitLeft(120.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_ML);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset); UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset);
} }
@ -2029,7 +2020,7 @@ int CMenus::Render()
Part.VSplitLeft(8.0f, 0, &Part); Part.VSplitLeft(8.0f, 0, &Part);
char aBuffer[64]; char aBuffer[64];
str_format(aBuffer, sizeof(aBuffer), "%s: ×%g", Localize("Speed"), g_aSpeeds[m_Speed]); str_format(aBuffer, sizeof(aBuffer), "%s: ×%g", Localize("Speed"), g_aSpeeds[m_Speed]);
UI()->DoLabel(&Part, aBuffer, 12.8f, TEXTALIGN_LEFT); UI()->DoLabel(&Part, aBuffer, 12.8f, TEXTALIGN_ML);
if(IncDemoSpeed) if(IncDemoSpeed)
m_Speed = clamp(m_Speed + 1, 0, (int)(g_DemoSpeeds - 1)); m_Speed = clamp(m_Speed + 1, 0, (int)(g_DemoSpeeds - 1));
@ -2051,7 +2042,7 @@ int CMenus::Render()
Label.VSplitLeft(120.0f, 0, &TextBox); Label.VSplitLeft(120.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("Video name:"), 18.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Video name:"), 18.0f, TEXTALIGN_ML);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset); UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset);
} }
@ -2101,7 +2092,7 @@ int CMenus::Render()
Label.VSplitLeft(100.0f, 0, &TextBox); Label.VSplitLeft(100.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("Nickname"), 16.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Nickname"), 16.0f, TEXTALIGN_ML);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
SUIExEditBoxProperties EditProps; SUIExEditBoxProperties EditProps;
EditProps.m_pEmptyText = Client()->PlayerName(); EditProps.m_pEmptyText = Client()->PlayerName();
@ -2236,9 +2227,7 @@ void CMenus::RenderThemeSelection(CUIRect MainView)
else // generic else // generic
str_copy(aName, Theme.m_Name.c_str()); str_copy(aName, Theme.m_Name.c_str());
SLabelProperties Props; UI()->DoLabel(&Label, aName, 16.0f * CUI::ms_FontmodHeight, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Label, aName, 16.0f * CUI::ms_FontmodHeight, TEXTALIGN_LEFT, Props);
} }
SelectedTheme = s_ListBox.DoEnd(); SelectedTheme = s_ListBox.DoEnd();

View file

@ -79,8 +79,8 @@ class CMenus : public CComponent
int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect); int DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled = true); int DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, bool Enabled = true);
int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active);
int DoButton_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = IGraphics::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_Menu(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName = nullptr, int Corners = IGraphics::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), bool CheckForActiveColorPicker = false);
int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10, int AlignVertically = 1); int DoButton_MenuTab(CButtonContainer *pButtonContainer, const char *pText, int Checked, const CUIRect *pRect, int Corners, SUIAnimator *pAnimator = nullptr, const ColorRGBA *pDefaultColor = nullptr, const ColorRGBA *pActiveColor = nullptr, const ColorRGBA *pHoverColor = nullptr, float EdgeRounding = 10);
int DoButton_CheckBox_Common(const void *pID, const char *pText, const char *pBoxText, const CUIRect *pRect); 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_CheckBox(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
@ -109,7 +109,7 @@ class CMenus : public CComponent
// new gui with gui elements // new gui with gui elements
template<typename T> template<typename T>
int DoButtonMenu(CUIElement &UIElement, const void *pID, T &&GetTextLambda, int Checked, const CUIRect *pRect, bool HintRequiresStringCheck, bool HintCanChangePositionOrSize = false, int Corners = IGraphics::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 DoButtonMenu(CUIElement &UIElement, const void *pID, T &&GetTextLambda, int Checked, const CUIRect *pRect, bool HintRequiresStringCheck, bool HintCanChangePositionOrSize = false, int Corners = IGraphics::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))
{ {
CUIRect Text = *pRect; CUIRect Text = *pRect;
Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text); Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text);
@ -172,9 +172,7 @@ class CMenus : public CComponent
if(pText == nullptr) if(pText == nullptr)
pText = GetTextLambda(); pText = GetTextLambda();
NewRect.m_Text = pText; NewRect.m_Text = pText;
SLabelProperties Props; UI()->DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
Props.m_AlignVertically = AlignVertically;
UI()->DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
} }
} }
Graphics()->SetColor(1, 1, 1, 1); Graphics()->SetColor(1, 1, 1, 1);

View file

@ -171,11 +171,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
CUIRect MsgBox = View; CUIRect MsgBox = View;
if(!ServerBrowser()->NumServers() && ServerBrowser()->IsGettingServerlist()) if(!ServerBrowser()->NumServers() && ServerBrowser()->IsGettingServerlist())
UI()->DoLabel(&MsgBox, Localize("Getting server list from master server"), 16.0f, TEXTALIGN_CENTER); UI()->DoLabel(&MsgBox, Localize("Getting server list from master server"), 16.0f, TEXTALIGN_MC);
else if(!ServerBrowser()->NumServers()) else if(!ServerBrowser()->NumServers())
UI()->DoLabel(&MsgBox, Localize("No servers found"), 16.0f, TEXTALIGN_CENTER); UI()->DoLabel(&MsgBox, Localize("No servers found"), 16.0f, TEXTALIGN_MC);
else if(ServerBrowser()->NumServers() && !NumServers) else if(ServerBrowser()->NumServers() && !NumServers)
UI()->DoLabel(&MsgBox, Localize("No servers match your filter criteria"), 16.0f, TEXTALIGN_CENTER); UI()->DoLabel(&MsgBox, Localize("No servers match your filter criteria"), 16.0f, TEXTALIGN_MC);
} }
if(UI()->ConsumeHotkey(CUI::HOTKEY_TAB)) if(UI()->ConsumeHotkey(CUI::HOTKEY_TAB))
@ -200,7 +200,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
for(auto &Friend : m_vFriends) for(auto &Friend : m_vFriends)
Friend.m_NumFound = 0; Friend.m_NumFound = 0;
auto RenderBrowserIcons = [this](CUIElement::SUIElementRect &UIRect, CUIRect *pRect, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor, const char *pText, ETextAlignment TextAlign, bool SmallFont = false) { auto RenderBrowserIcons = [this](CUIElement::SUIElementRect &UIRect, CUIRect *pRect, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor, const char *pText, int TextAlign, bool SmallFont = false) {
float FontSize = 14.0f; float FontSize = 14.0f;
if(SmallFont) if(SmallFont)
FontSize = 6.0f; FontSize = 6.0f;
@ -208,7 +208,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
TextRender()->TextColor(TextColor); TextRender()->TextColor(TextColor);
TextRender()->TextOutlineColor(TextOutlineColor); TextRender()->TextOutlineColor(TextOutlineColor);
UI()->DoLabelStreamed(UIRect, pRect, pText, FontSize, TextAlign, -1, 0); UI()->DoLabelStreamed(UIRect, pRect, pText, FontSize, TextAlign, -1.0f);
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
@ -280,22 +280,22 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
{ {
if(pItem->m_Flags & SERVER_FLAG_PASSWORD) if(pItem->m_Flags & SERVER_FLAG_PASSWORD)
{ {
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFlagLock + 0), &Button, {0.75f, 0.75f, 0.75f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_LOCK, TEXTALIGN_CENTER); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFlagLock + 0), &Button, {0.75f, 0.75f, 0.75f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_LOCK, TEXTALIGN_MC);
} }
} }
else if(ID == COL_FLAG_FAV) else if(ID == COL_FLAG_FAV)
{ {
if(pItem->m_Favorite != TRISTATE::NONE) if(pItem->m_Favorite != TRISTATE::NONE)
{ {
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFav + 0), &Button, {0.94f, 0.4f, 0.4f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_HEART, TEXTALIGN_CENTER); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFav + 0), &Button, {0.94f, 0.4f, 0.4f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_HEART, TEXTALIGN_MC);
} }
} }
else if(ID == COL_FLAG_OFFICIAL) else if(ID == COL_FLAG_OFFICIAL)
{ {
if(pItem->m_Official && g_Config.m_UiPage != PAGE_DDNET && g_Config.m_UiPage != PAGE_KOG) if(pItem->m_Official && g_Config.m_UiPage != PAGE_DDNET && g_Config.m_UiPage != PAGE_KOG)
{ {
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColOff + 0), &Button, {0.4f, 0.7f, 0.94f, 1}, {0.0f, 0.0f, 0.0f, 1.0f}, FONT_ICON_CERTIFICATE, TEXTALIGN_CENTER); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColOff + 0), &Button, {0.4f, 0.7f, 0.94f, 1}, {0.0f, 0.0f, 0.0f, 1.0f}, FONT_ICON_CERTIFICATE, TEXTALIGN_MC);
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColOff + 1), &Button, {0.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, FONT_ICON_CHECK, TEXTALIGN_CENTER, true); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColOff + 1), &Button, {0.0f, 0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 0.0f}, FONT_ICON_CHECK, TEXTALIGN_MC, true);
} }
} }
else if(ID == COL_NAME) else if(ID == COL_NAME)
@ -305,14 +305,14 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_SERVERNAME)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_SERVERNAME))
Printed = PrintHighlighted(pItem->m_aName, [this, pItem, FontSize, &Button](const char *pFilteredStr, const int FilterLen) { Printed = PrintHighlighted(pItem->m_aName, [this, pItem, FontSize, &Button](const char *pFilteredStr, const int FilterLen) {
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 0), &Button, pItem->m_aName, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, (int)(pFilteredStr - pItem->m_aName)); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 0), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Button.w, true, (int)(pFilteredStr - pItem->m_aName));
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1); TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1);
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 1), &Button, pFilteredStr, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, FilterLen, &pItem->m_pUIElement->Rect(gs_OffsetColName + 0)->m_Cursor); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 1), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Button.w, true, FilterLen, &pItem->m_pUIElement->Rect(gs_OffsetColName + 0)->m_Cursor);
TextRender()->TextColor(1, 1, 1, 1); TextRender()->TextColor(1, 1, 1, 1);
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 2), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, -1, &pItem->m_pUIElement->Rect(gs_OffsetColName + 1)->m_Cursor); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName + 2), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Button.w, true, -1, &pItem->m_pUIElement->Rect(gs_OffsetColName + 1)->m_Cursor);
}); });
if(!Printed) if(!Printed)
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName), &Button, pItem->m_aName, FontSize, TEXTALIGN_LEFT, Button.w, 1, true); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColName), &Button, pItem->m_aName, FontSize, TEXTALIGN_ML, Button.w, true);
} }
else if(ID == COL_MAP) else if(ID == COL_MAP)
{ {
@ -325,7 +325,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(g_Config.m_BrIndicateFinished && pItem->m_HasRank == 1) if(g_Config.m_BrIndicateFinished && pItem->m_HasRank == 1)
{ {
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFlagLock + 1), &Icon, TextRender()->DefaultTextColor(), TextRender()->DefaultTextOutlineColor(), FONT_ICON_FLAG_CHECKERED, TEXTALIGN_CENTER); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFlagLock + 1), &Icon, TextRender()->DefaultTextColor(), TextRender()->DefaultTextOutlineColor(), FONT_ICON_FLAG_CHECKERED, TEXTALIGN_MC);
} }
} }
@ -333,14 +333,14 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
bool Printed = false; bool Printed = false;
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_MAPNAME)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_MAPNAME))
Printed = PrintHighlighted(pItem->m_aMap, [this, pItem, FontSize, &Button](const char *pFilteredStr, const int FilterLen) { Printed = PrintHighlighted(pItem->m_aMap, [this, pItem, FontSize, &Button](const char *pFilteredStr, const int FilterLen) {
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 0), &Button, pItem->m_aMap, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, (int)(pFilteredStr - pItem->m_aMap)); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 0), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Button.w, true, (int)(pFilteredStr - pItem->m_aMap));
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1); TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1);
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 1), &Button, pFilteredStr, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, FilterLen, &pItem->m_pUIElement->Rect(gs_OffsetColMap + 0)->m_Cursor); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 1), &Button, pFilteredStr, FontSize, TEXTALIGN_ML, Button.w, true, FilterLen, &pItem->m_pUIElement->Rect(gs_OffsetColMap + 0)->m_Cursor);
TextRender()->TextColor(1, 1, 1, 1); TextRender()->TextColor(1, 1, 1, 1);
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 2), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_LEFT, Button.w, 1, true, -1, &pItem->m_pUIElement->Rect(gs_OffsetColMap + 1)->m_Cursor); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap + 2), &Button, pFilteredStr + FilterLen, FontSize, TEXTALIGN_ML, Button.w, true, -1, &pItem->m_pUIElement->Rect(gs_OffsetColMap + 1)->m_Cursor);
}); });
if(!Printed) if(!Printed)
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap), &Button, pItem->m_aMap, FontSize, TEXTALIGN_LEFT, Button.w, 1, true); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColMap), &Button, pItem->m_aMap, FontSize, TEXTALIGN_ML, Button.w, true);
} }
else if(ID == COL_PLAYERS) else if(ID == COL_PLAYERS)
{ {
@ -351,13 +351,13 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
Button.VSplitRight(50.0f, &Icon, &Button); Button.VSplitRight(50.0f, &Icon, &Button);
Icon.Margin(2.0f, &Icon); Icon.Margin(2.0f, &Icon);
Icon.HSplitBottom(6.0f, 0, &IconText); Icon.HSplitBottom(6.0f, 0, &IconText);
RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFav + 1), &Icon, {0.94f, 0.4f, 0.4f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_HEART, TEXTALIGN_CENTER); RenderBrowserIcons(*pItem->m_pUIElement->Rect(gs_OffsetColFav + 1), &Icon, {0.94f, 0.4f, 0.4f, 1}, TextRender()->DefaultTextOutlineColor(), FONT_ICON_HEART, TEXTALIGN_MC);
if(FriendsOnServer > 1) if(FriendsOnServer > 1)
{ {
char aBufFriendsOnServer[64]; char aBufFriendsOnServer[64];
str_format(aBufFriendsOnServer, sizeof(aBufFriendsOnServer), "%i", FriendsOnServer); str_format(aBufFriendsOnServer, sizeof(aBufFriendsOnServer), "%i", FriendsOnServer);
TextRender()->TextColor(0.94f, 0.8f, 0.8f, 1); TextRender()->TextColor(0.94f, 0.8f, 0.8f, 1);
UI()->DoLabel(&IconText, aBufFriendsOnServer, 10.0f, TEXTALIGN_CENTER); UI()->DoLabel(&IconText, aBufFriendsOnServer, 10.0f, TEXTALIGN_MC);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1);
} }
} }
@ -366,7 +366,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_PLAYER)) if(g_Config.m_BrFilterString[0] && (pItem->m_QuickSearchHit & IServerBrowser::QUICK_PLAYER))
TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1); TextRender()->TextColor(0.4f, 0.4f, 1.0f, 1);
float FontSize = 12.0f; float FontSize = 12.0f;
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColPlayers), &Button, aTemp, FontSize, TEXTALIGN_RIGHT, -1, 1, false); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColPlayers), &Button, aTemp, FontSize, TEXTALIGN_MR, -1.0f, false);
TextRender()->TextColor(1, 1, 1, 1); TextRender()->TextColor(1, 1, 1, 1);
} }
else if(ID == COL_PING) else if(ID == COL_PING)
@ -380,14 +380,14 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
} }
float FontSize = 12.0f; float FontSize = 12.0f;
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColPing), &Button, aTemp, FontSize, TEXTALIGN_RIGHT, -1, 1, false); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColPing), &Button, aTemp, FontSize, TEXTALIGN_MR, -1.0f, false);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
else if(ID == COL_VERSION) else if(ID == COL_VERSION)
{ {
const char *pVersion = pItem->m_aVersion; const char *pVersion = pItem->m_aVersion;
float FontSize = 12.0f; float FontSize = 12.0f;
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColVersion), &Button, pVersion, FontSize, TEXTALIGN_RIGHT, -1, 1, false); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColVersion), &Button, pVersion, FontSize, TEXTALIGN_MR, -1.0f, false);
} }
else if(ID == COL_GAMETYPE) else if(ID == COL_GAMETYPE)
{ {
@ -420,11 +420,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
ColorRGBA rgb = color_cast<ColorRGBA>(hsl); ColorRGBA rgb = color_cast<ColorRGBA>(hsl);
TextRender()->TextColor(rgb); TextRender()->TextColor(rgb);
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_LEFT, Button.w, 1, true); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_ML, Button.w, true);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
else else
UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_LEFT, Button.w, 1, true); UI()->DoLabelStreamed(*pItem->m_pUIElement->Rect(gs_OffsetColGameType), &Button, pItem->m_aGameType, FontSize, TEXTALIGN_ML, Button.w, true);
} }
} }
} }
@ -488,9 +488,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
SLabelProperties Props; UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 16.0f, TEXTALIGN_LEFT, Props);
SearchIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); SearchIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
ExcludeIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_BAN, -1, -1.0f); ExcludeIconWidth = TextRender()->TextWidth(16.0f, FONT_ICON_BAN, -1, -1.0f);
ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth); ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth);
@ -501,7 +499,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
char aBufSearch[64]; char aBufSearch[64];
str_format(aBufSearch, sizeof(aBufSearch), "%s:", Localize("Search")); str_format(aBufSearch, sizeof(aBufSearch), "%s:", Localize("Search"));
UI()->DoLabel(&QuickSearch, aBufSearch, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&QuickSearch, aBufSearch, 14.0f, TEXTALIGN_ML);
QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickSearch); QuickSearch.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickSearch);
QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch); QuickSearch.VSplitLeft(5.0f, 0, &QuickSearch);
@ -523,9 +521,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
SLabelProperties Props; UI()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickExclude, FONT_ICON_BAN, 16.0f, TEXTALIGN_LEFT, Props);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(NULL);
QuickExclude.VSplitLeft(ExcludeSearchIconMax, 0, &QuickExclude); QuickExclude.VSplitLeft(ExcludeSearchIconMax, 0, &QuickExclude);
@ -533,7 +529,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
char aBufExclude[64]; char aBufExclude[64];
str_format(aBufExclude, sizeof(aBufExclude), "%s:", Localize("Exclude")); str_format(aBufExclude, sizeof(aBufExclude), "%s:", Localize("Exclude"));
UI()->DoLabel(&QuickExclude, aBufExclude, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&QuickExclude, aBufExclude, 14.0f, TEXTALIGN_ML);
QuickExclude.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickExclude); QuickExclude.VSplitLeft(SearchExcludeAddrStrMax, 0, &QuickExclude);
QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude); QuickExclude.VSplitLeft(5.0f, 0, &QuickExclude);
@ -560,9 +556,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
CUIRect SvrsOnline, PlysOnline; CUIRect SvrsOnline, PlysOnline;
Status3.HSplitTop(20.f, &PlysOnline, &SvrsOnline); Status3.HSplitTop(20.f, &PlysOnline, &SvrsOnline);
PlysOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufPyr, -1, -1.0f), 0, &PlysOnline); PlysOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufPyr, -1, -1.0f), 0, &PlysOnline);
UI()->DoLabel(&PlysOnline, aBufPyr, 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&PlysOnline, aBufPyr, 12.0f, TEXTALIGN_ML);
SvrsOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufSvr, -1, -1.0f), 0, &SvrsOnline); SvrsOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufSvr, -1, -1.0f), 0, &SvrsOnline);
UI()->DoLabel(&SvrsOnline, aBufSvr, 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&SvrsOnline, aBufSvr, 12.0f, TEXTALIGN_ML);
// status box // status box
{ {
@ -571,7 +567,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
ServerAddr.Margin(2.0f, &ServerAddr); ServerAddr.Margin(2.0f, &ServerAddr);
// address info // address info
UI()->DoLabel(&ServerAddr, Localize("Server address:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&ServerAddr, Localize("Server address:"), 14.0f, TEXTALIGN_ML);
ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, NULL, &ServerAddr); ServerAddr.VSplitLeft(SearchExcludeAddrStrMax + 5.0f + ExcludeSearchIconMax + 5.0f, NULL, &ServerAddr);
static int s_ClearButton = 0; static int s_ClearButton = 0;
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
@ -602,7 +598,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
static int s_JoinButton = 0; static int s_JoinButton = 0;
if(DoButtonMenu( if(DoButtonMenu(
m_ConnectButton, &s_JoinButton, []() -> const char * { return Localize("Connect"); }, 0, &ButtonConnect, false, false, IGraphics::CORNER_ALL, 5, 0, vec4(0.7f, 1, 0.7f, 0.1f), vec4(0.7f, 1, 0.7f, 0.2f)) || m_ConnectButton, &s_JoinButton, []() -> const char * { return Localize("Connect"); }, 0, &ButtonConnect, false, false, IGraphics::CORNER_ALL, 5.0f, 0.0f, vec4(0.7f, 1, 0.7f, 0.1f), vec4(0.7f, 1, 0.7f, 0.2f)) ||
UI()->ConsumeHotkey(CUI::HOTKEY_ENTER)) UI()->ConsumeHotkey(CUI::HOTKEY_ENTER))
{ {
Connect(g_Config.m_UiServerAddress); Connect(g_Config.m_UiServerAddress);
@ -637,7 +633,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
FilterHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f); FilterHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f);
ServerFilter.Draw(ColorRGBA(0, 0, 0, 0.15f), IGraphics::CORNER_B, 4.0f); ServerFilter.Draw(ColorRGBA(0, 0, 0, 0.15f), IGraphics::CORNER_B, 4.0f);
UI()->DoLabel(&FilterHeader, Localize("Server filter"), FontSize + 2.0f, TEXTALIGN_CENTER); UI()->DoLabel(&FilterHeader, Localize("Server filter"), FontSize + 2.0f, TEXTALIGN_MC);
CUIRect Button, Button2; CUIRect Button, Button2;
ServerFilter.VSplitLeft(5.0f, 0, &ServerFilter); ServerFilter.VSplitLeft(5.0f, 0, &ServerFilter);
@ -671,7 +667,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
ServerFilter.HSplitTop(5.0f, 0, &ServerFilter); ServerFilter.HSplitTop(5.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter); ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
UI()->DoLabel(&Button, Localize("Game types:"), FontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Game types:"), FontSize, TEXTALIGN_ML);
Button.VSplitRight(60.0f, 0, &Button); Button.VSplitRight(60.0f, 0, &Button);
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter); ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
static float s_OffsetGametype = 0.0f; static float s_OffsetGametype = 0.0f;
@ -681,7 +677,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
// server address // server address
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter); ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter); ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
UI()->DoLabel(&Button, Localize("Server address:"), FontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Server address:"), FontSize, TEXTALIGN_ML);
Button.VSplitRight(60.0f, 0, &Button); Button.VSplitRight(60.0f, 0, &Button);
static float s_OffsetAddr = 0.0f; static float s_OffsetAddr = 0.0f;
if(UI()->DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &s_OffsetAddr)) if(UI()->DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &s_OffsetAddr))
@ -859,7 +855,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
} }
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Active ? 1.0f : 0.2f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, Active ? 1.0f : 0.2f);
UI()->DoLabel(&Rect, pName, FontSize, TEXTALIGN_CENTER); UI()->DoLabel(&Rect, pName, FontSize, TEXTALIGN_MC);
TextRender()->TextColor(1.0, 1.0, 1.0, 1.0f); TextRender()->TextColor(1.0, 1.0, 1.0, 1.0f);
} }
} }
@ -1002,7 +998,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
ServerDetails.HSplitTop(ms_ListheaderHeight, &ServerHeader, &ServerDetails); ServerDetails.HSplitTop(ms_ListheaderHeight, &ServerHeader, &ServerDetails);
ServerHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f); ServerHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f);
ServerDetails.Draw(ColorRGBA(0, 0, 0, 0.15f), IGraphics::CORNER_B, 4.0f); ServerDetails.Draw(ColorRGBA(0, 0, 0, 0.15f), IGraphics::CORNER_B, 4.0f);
UI()->DoLabel(&ServerHeader, Localize("Server details"), FontSize + 2.0f, TEXTALIGN_CENTER); UI()->DoLabel(&ServerHeader, Localize("Server details"), FontSize + 2.0f, TEXTALIGN_MC);
if(pSelectedServer) if(pSelectedServer)
{ {
@ -1070,7 +1066,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
for(auto &Label : s_aLabels) for(auto &Label : s_aLabels)
{ {
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn); LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
UI()->DoLabel(&Row, Localize(Label), FontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Row, Localize(Label), FontSize, TEXTALIGN_ML);
} }
RightColumn.HSplitTop(15.0f, &Row, &RightColumn); RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
@ -1284,7 +1280,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFriends); ServerFriends.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFriends);
FilterHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f); FilterHeader.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_T, 4.0f);
ServerFriends.Draw(ColorRGBA(0, 0, 0, 0.15f), 0, 4.0f); ServerFriends.Draw(ColorRGBA(0, 0, 0, 0.15f), 0, 4.0f);
UI()->DoLabel(&FilterHeader, Localize("Friends"), FontSize + 4.0f, TEXTALIGN_CENTER); UI()->DoLabel(&FilterHeader, Localize("Friends"), FontSize + 4.0f, TEXTALIGN_MC);
CUIRect List; CUIRect List;
ServerFriends.Margin(3.0f, &ServerFriends); ServerFriends.Margin(3.0f, &ServerFriends);
@ -1312,15 +1308,15 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
NameClanLabels.VMargin(2.5f, &NameClanLabels); NameClanLabels.VMargin(2.5f, &NameClanLabels);
NameClanLabels.HSplitTop(12.0f, &NameLabel, &ClanLabel); NameClanLabels.HSplitTop(12.0f, &NameLabel, &ClanLabel);
UI()->DoLabel(&NameLabel, Friend.m_pFriendInfo->m_aName, FontSize, TEXTALIGN_LEFT); UI()->DoLabel(&NameLabel, Friend.m_pFriendInfo->m_aName, FontSize, TEXTALIGN_ML);
UI()->DoLabel(&ClanLabel, Friend.m_pFriendInfo->m_aClan, FontSize, TEXTALIGN_LEFT); UI()->DoLabel(&ClanLabel, Friend.m_pFriendInfo->m_aClan, FontSize, TEXTALIGN_ML);
OnState.Draw(Friend.m_NumFound ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.25f) : ColorRGBA(1.0f, 0.0f, 0.0f, 0.25f), IGraphics::CORNER_R, 4.0f); OnState.Draw(Friend.m_NumFound ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.25f) : ColorRGBA(1.0f, 0.0f, 0.0f, 0.25f), IGraphics::CORNER_R, 4.0f);
OnState.HMargin((OnState.h - FontSize) / 3, &OnState); OnState.HMargin((OnState.h - FontSize) / 3, &OnState);
OnState.VMargin(5.0f, &OnState); OnState.VMargin(5.0f, &OnState);
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%i", Friend.m_NumFound); str_format(aBuf, sizeof(aBuf), "%i", Friend.m_NumFound);
UI()->DoLabel(&OnState, aBuf, FontSize + 2, TEXTALIGN_RIGHT); UI()->DoLabel(&OnState, aBuf, FontSize + 2, TEXTALIGN_ML);
} }
m_FriendlistSelectedIndex = s_ListBox.DoEnd(); m_FriendlistSelectedIndex = s_ListBox.DoEnd();
@ -1377,7 +1373,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends); ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
UI()->DoLabel(&Button, aBuf, FontSize + 2, TEXTALIGN_LEFT); UI()->DoLabel(&Button, aBuf, FontSize + 2, TEXTALIGN_ML);
Button.VSplitLeft(80.0f, 0, &Button); Button.VSplitLeft(80.0f, 0, &Button);
static char s_aName[MAX_NAME_LENGTH] = {0}; static char s_aName[MAX_NAME_LENGTH] = {0};
static float s_OffsetName = 0.0f; static float s_OffsetName = 0.0f;
@ -1386,7 +1382,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends); ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends); ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
UI()->DoLabel(&Button, aBuf, FontSize + 2, TEXTALIGN_LEFT); UI()->DoLabel(&Button, aBuf, FontSize + 2, TEXTALIGN_ML);
Button.VSplitLeft(80.0f, 0, &Button); Button.VSplitLeft(80.0f, 0, &Button);
static char s_aClan[MAX_CLAN_LENGTH] = {0}; static char s_aClan[MAX_CLAN_LENGTH] = {0};
static float s_OffsetClan = 0.0f; static float s_OffsetClan = 0.0f;

View file

@ -30,7 +30,7 @@ using namespace std::chrono_literals;
int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect) int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect)
{ {
pRect->Draw(ColorRGBA(1, 1, 1, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f); pRect->Draw(ColorRGBA(1, 1, 1, (Checked ? 0.10f : 0.5f) * UI()->ButtonColorMul(pID)), IGraphics::CORNER_ALL, 5.0f);
UI()->DoLabel(pRect, pText, 14.0f, TEXTALIGN_CENTER); UI()->DoLabel(pRect, pText, 14.0f, TEXTALIGN_MC);
return UI()->DoButtonLogic(pID, Checked, pRect); return UI()->DoButtonLogic(pID, Checked, pRect);
} }
@ -41,17 +41,15 @@ int CMenus::DoButton_FontIcon(CButtonContainer *pButtonContainer, const char *pT
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
CUIRect Rect = *pRect;
CUIRect Temp; CUIRect Temp;
Rect.HMargin(2.0f, &Temp); pRect->HMargin(2.0f, &Temp);
SLabelProperties Props; UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
if(!Enabled) if(!Enabled)
{ {
TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f)); TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
TextRender()->TextOutlineColor(ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f)); TextRender()->TextOutlineColor(ColorRGBA(0.0f, 0.0f, 0.0f, 0.0f));
UI()->DoLabel(&Temp, FONT_ICON_SLASH, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props); UI()->DoLabel(&Temp, FONT_ICON_SLASH, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_MC);
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
} }
@ -133,11 +131,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
Box.HSplitTop(24.f, &Part, &Box); Box.HSplitTop(24.f, &Part, &Box);
UI()->DoLabel(&Part, Localize("Select a name"), 24.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, Localize("Select a name"), 24.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
Box.HSplitTop(20.f, &Part, &Box); Box.HSplitTop(20.f, &Part, &Box);
Part.VMargin(20.f, &Part); Part.VMargin(20.f, &Part);
UI()->DoLabel(&Part, m_aDemoPlayerPopupHint, 20.f, TEXTALIGN_CENTER); UI()->DoLabel(&Part, m_aDemoPlayerPopupHint, 20.f, TEXTALIGN_MC);
Box.HSplitTop(20.f, 0, &Box); Box.HSplitTop(20.f, 0, &Box);
CUIRect Label, TextBox, Ok, Abort; CUIRect Label, TextBox, Ok, Abort;
@ -207,7 +205,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
Label.VSplitLeft(120.0f, 0, &TextBox); Label.VSplitLeft(120.0f, 0, &TextBox);
TextBox.VSplitLeft(20.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox);
TextBox.VSplitRight(60.0f, &TextBox, 0); TextBox.VSplitRight(60.0f, &TextBox, 0);
UI()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("New name:"), 18.0f, TEXTALIGN_ML);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
if(UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset)) if(UI()->DoEditBox(&s_Offset, &TextBox, m_aCurrentDemoFile, sizeof(m_aCurrentDemoFile), 12.0f, &s_Offset))
{ {
@ -412,7 +410,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
char aTotalTime[32]; char aTotalTime[32];
str_time((int64_t)TotalTicks / SERVER_TICK_SPEED * 100, TIME_HOURS, aTotalTime, sizeof(aTotalTime)); str_time((int64_t)TotalTicks / SERVER_TICK_SPEED * 100, TIME_HOURS, aTotalTime, sizeof(aTotalTime));
str_format(aBuffer, sizeof(aBuffer), "%s / %s", aCurrentTime, aTotalTime); str_format(aBuffer, sizeof(aBuffer), "%s / %s", aCurrentTime, aTotalTime);
UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h * 0.70f, TEXTALIGN_CENTER); UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h * 0.70f, TEXTALIGN_MC);
// do the logic // do the logic
const bool Inside = UI()->MouseInside(&SeekBar); const bool Inside = UI()->MouseInside(&SeekBar);
@ -531,7 +529,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
ButtonBar.VSplitLeft(Margins * 12, &SpeedBar, &ButtonBar); ButtonBar.VSplitLeft(Margins * 12, &SpeedBar, &ButtonBar);
char aBuffer[64]; char aBuffer[64];
str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed); str_format(aBuffer, sizeof(aBuffer), "×%g", pInfo->m_Speed);
UI()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_CENTER); UI()->DoLabel(&SpeedBar, aBuffer, Button.h * 0.7f, TEXTALIGN_MC);
// slice begin button // slice begin button
ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar);
@ -816,76 +814,76 @@ void CMenus::RenderDemoList(CUIRect MainView)
// left side // left side
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Created:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Created:"), 14.0f, TEXTALIGN_ML);
char aTimestamp[256]; char aTimestamp[256];
str_timestamp_ex(m_vDemos[m_DemolistSelectedIndex].m_Date, aTimestamp, sizeof(aTimestamp), FORMAT_SPACE); str_timestamp_ex(m_vDemos[m_DemolistSelectedIndex].m_Date, aTimestamp, sizeof(aTimestamp), FORMAT_SPACE);
UI()->DoLabel(&Right, aTimestamp, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aTimestamp, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Type:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Type:"), 14.0f, TEXTALIGN_ML);
UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aType, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aType, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Length:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Length:"), 14.0f, TEXTALIGN_ML);
int Length = m_vDemos[m_DemolistSelectedIndex].Length(); int Length = m_vDemos[m_DemolistSelectedIndex].Length();
char aBuf[64]; char aBuf[64];
str_time((int64_t)Length * 100, TIME_HOURS, aBuf, sizeof(aBuf)); str_time((int64_t)Length * 100, TIME_HOURS, aBuf, sizeof(aBuf));
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Version:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Version:"), 14.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].m_Info.m_Version); str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].m_Info.m_Version);
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Markers:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Markers:"), 14.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].NumMarkers()); str_format(aBuf, sizeof(aBuf), "%d", m_vDemos[m_DemolistSelectedIndex].NumMarkers());
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
// right side // right side
Labels = MainView; Labels = MainView;
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Map:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Map:"), 14.0f, TEXTALIGN_ML);
UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aMapName, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aMapName, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Size:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Size:"), 14.0f, TEXTALIGN_ML);
const float Size = m_vDemos[m_DemolistSelectedIndex].Size() / 1024.0f; const float Size = m_vDemos[m_DemolistSelectedIndex].Size() / 1024.0f;
if(Size > 1024) if(Size > 1024)
str_format(aBuf, sizeof(aBuf), Localize("%.2f MiB"), Size / 1024.0f); str_format(aBuf, sizeof(aBuf), Localize("%.2f MiB"), Size / 1024.0f);
else else
str_format(aBuf, sizeof(aBuf), Localize("%.2f KiB"), Size); str_format(aBuf, sizeof(aBuf), Localize("%.2f KiB"), Size);
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
if(m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Sha256 != SHA256_ZEROED) if(m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Sha256 != SHA256_ZEROED)
{ {
UI()->DoLabel(&Left, "SHA256:", 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, "SHA256:", 14.0f, TEXTALIGN_ML);
char aSha[SHA256_MAXSTRSIZE]; char aSha[SHA256_MAXSTRSIZE];
sha256_str(m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Sha256, aSha, sizeof(aSha) / 2); sha256_str(m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Sha256, aSha, sizeof(aSha) / 2);
UI()->DoLabel(&Right, aSha, Right.w > 235 ? 14.0f : 11.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aSha, Right.w > 235 ? 14.0f : 11.0f, TEXTALIGN_ML);
} }
else else
{ {
UI()->DoLabel(&Left, Localize("Crc:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Crc:"), 14.0f, TEXTALIGN_ML);
str_format(aBuf, sizeof(aBuf), "%08x", m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Crc); str_format(aBuf, sizeof(aBuf), "%08x", m_vDemos[m_DemolistSelectedIndex].m_MapInfo.m_Crc);
UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, aBuf, 14.0f, TEXTALIGN_ML);
} }
Labels.HSplitTop(5.0f, 0, &Labels); Labels.HSplitTop(5.0f, 0, &Labels);
Labels.HSplitTop(20.0f, &Left, &Labels); Labels.HSplitTop(20.0f, &Left, &Labels);
Left.VSplitLeft(150.0f, &Left, &Right); Left.VSplitLeft(150.0f, &Left, &Right);
UI()->DoLabel(&Left, Localize("Netversion:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Left, Localize("Netversion:"), 14.0f, TEXTALIGN_ML);
UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Right, m_vDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, TEXTALIGN_ML);
} }
// demo list // demo list
@ -1010,7 +1008,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->TextColor(IconColor); TextRender()->TextColor(IconColor);
UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_ML);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetCurFont(nullptr); TextRender()->SetCurFont(nullptr);
@ -1037,7 +1035,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
char aBuf[3]; char aBuf[3];
str_format(aBuf, sizeof(aBuf), "%d", Item.NumMarkers()); str_format(aBuf, sizeof(aBuf), "%d", Item.NumMarkers());
Button.VMargin(4.0f, &Button); Button.VMargin(4.0f, &Button);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
} }
else if(ID == COL_LENGTH && !Item.m_IsDir && Item.m_InfosLoaded) else if(ID == COL_LENGTH && !Item.m_IsDir && Item.m_InfosLoaded)
{ {
@ -1045,14 +1043,14 @@ void CMenus::RenderDemoList(CUIRect MainView)
char aBuf[32]; char aBuf[32];
str_time((int64_t)Length * 100, TIME_HOURS, aBuf, sizeof(aBuf)); str_time((int64_t)Length * 100, TIME_HOURS, aBuf, sizeof(aBuf));
Button.VMargin(4.0f, &Button); Button.VMargin(4.0f, &Button);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
} }
else if(ID == COL_DATE && !Item.m_IsDir) else if(ID == COL_DATE && !Item.m_IsDir)
{ {
char aBuf[64]; char aBuf[64];
str_timestamp_ex(Item.m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE); str_timestamp_ex(Item.m_Date, aBuf, sizeof(aBuf), FORMAT_SPACE);
Button.VSplitRight(24.0f, &Button, 0); Button.VSplitRight(24.0f, &Button, 0);
UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Button, aBuf, 12.0f, TEXTALIGN_MR);
} }
} }
} }
@ -1168,7 +1166,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
#endif #endif
} }
UI()->DoLabel(&LabelRect, aFooterLabel, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&LabelRect, aFooterLabel, 14.0f, TEXTALIGN_ML);
} }
void CMenus::PopupConfirmDeleteDemo() void CMenus::PopupConfirmDeleteDemo()

View file

@ -232,12 +232,12 @@ void CMenus::RenderPlayers(CUIRect MainView)
Options.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 10.0f); Options.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.25f), IGraphics::CORNER_ALL, 10.0f);
Options.Margin(10.0f, &Options); Options.Margin(10.0f, &Options);
Options.HSplitTop(50.0f, &Button, &Options); Options.HSplitTop(50.0f, &Button, &Options);
UI()->DoLabel(&Button, Localize("Player options"), 34.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Player options"), 34.0f, TEXTALIGN_ML);
// headline // headline
Options.HSplitTop(34.0f, &ButtonBar, &Options); Options.HSplitTop(34.0f, &ButtonBar, &Options);
ButtonBar.VSplitRight(231.0f, &Player, &ButtonBar); ButtonBar.VSplitRight(231.0f, &Player, &ButtonBar);
UI()->DoLabel(&Player, Localize("Player"), 24.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Player, Localize("Player"), 24.0f, TEXTALIGN_ML);
ButtonBar.HMargin(1.0f, &ButtonBar); ButtonBar.HMargin(1.0f, &ButtonBar);
float Width = ButtonBar.h * 2.0f; float Width = ButtonBar.h * 2.0f;
@ -558,9 +558,7 @@ bool CMenus::RenderServerControlServer(CUIRect MainView)
if(!Item.m_Visible) if(!Item.m_Visible)
continue; continue;
SLabelProperties Props; UI()->DoLabel(&Item.m_Rect, pOption->m_aDescription, 13.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Item.m_Rect, pOption->m_aDescription, 13.0f, TEXTALIGN_LEFT, Props);
} }
s_CurVoteOption = s_ListBox.DoEnd(); s_CurVoteOption = s_ListBox.DoEnd();
@ -613,9 +611,7 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos);
SLabelProperties Props; UI()->DoLabel(&Label, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Label, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, TEXTALIGN_LEFT, Props);
} }
Selected = s_ListBox.DoEnd(); Selected = s_ListBox.DoEnd();
@ -678,9 +674,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
SLabelProperties Props; UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(NULL);
@ -738,7 +732,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
Bottom.VSplitRight(160.0f, &Bottom, &Reason); Bottom.VSplitRight(160.0f, &Bottom, &Reason);
Reason.HSplitTop(5.0f, 0, &Reason); Reason.HSplitTop(5.0f, 0, &Reason);
const char *pLabel = Localize("Reason:"); const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f); float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason); Reason.VSplitLeft(w + 10.0f, 0, &Reason);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
@ -797,10 +791,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension); RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension);
Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom); Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Vote description:"), 14.0f, TEXTALIGN_ML);
Bottom.VSplitLeft(20.0f, 0, &Button); Bottom.VSplitLeft(20.0f, 0, &Button);
UI()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Vote command:"), 14.0f, TEXTALIGN_ML);
static char s_aVoteDescription[64] = {0}; static char s_aVoteDescription[64] = {0};
static char s_aVoteCommand[512] = {0}; static char s_aVoteCommand[512] = {0};

View file

@ -81,7 +81,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
{ {
// headline // headline
Game.HSplitTop(20.0f, &Label, &Game); Game.HSplitTop(20.0f, &Label, &Game);
UI()->DoLabel(&Label, Localize("Game"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Game"), 20.0f, TEXTALIGN_ML);
Game.Margin(5.0f, &Game); Game.Margin(5.0f, &Game);
Game.VSplitMid(&Left, &Right); Game.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0); Left.VSplitRight(5.0f, &Left, 0);
@ -139,7 +139,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
{ {
// headline // headline
Client.HSplitTop(20.0f, &Label, &Client); Client.HSplitTop(20.0f, &Label, &Client);
UI()->DoLabel(&Label, Localize("Client"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Client"), 20.0f, TEXTALIGN_ML);
Client.Margin(5.0f, &Client); Client.Margin(5.0f, &Client);
Client.VSplitMid(&Left, &Right); Client.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0); Left.VSplitRight(5.0f, &Left, 0);
@ -165,7 +165,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max demos"), g_Config.m_ClAutoDemoMax); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max demos"), g_Config.m_ClAutoDemoMax);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max demos"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max demos"), "");
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
g_Config.m_ClAutoDemoMax = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoDemoMax, &Button, g_Config.m_ClAutoDemoMax / 1000.0f) * 1000.0f + 0.1f); g_Config.m_ClAutoDemoMax = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoDemoMax, &Button, g_Config.m_ClAutoDemoMax / 1000.0f) * 1000.0f + 0.1f);
@ -179,7 +179,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max Screenshots"), g_Config.m_ClAutoScreenshotMax); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max Screenshots"), g_Config.m_ClAutoScreenshotMax);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), "");
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
g_Config.m_ClAutoScreenshotMax = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoScreenshotMax, &Button, g_Config.m_ClAutoScreenshotMax / 1000.0f) * 1000.0f + 0.1f); g_Config.m_ClAutoScreenshotMax = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoScreenshotMax, &Button, g_Config.m_ClAutoScreenshotMax / 1000.0f) * 1000.0f + 0.1f);
} }
@ -190,7 +190,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_ClRefreshRate); str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_ClRefreshRate);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), "");
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
Left.HSplitTop(20.0f, &Button, &Left); Left.HSplitTop(20.0f, &Button, &Left);
g_Config.m_ClRefreshRate = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClRefreshRate, &Button, g_Config.m_ClRefreshRate / 10000.0f) * 10000.0f + 0.1f); g_Config.m_ClRefreshRate = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClRefreshRate, &Button, g_Config.m_ClRefreshRate / 10000.0f) * 10000.0f + 0.1f);
Left.HSplitTop(5.0f, 0, &Left); Left.HSplitTop(5.0f, 0, &Left);
@ -264,7 +264,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max Screenshots"), g_Config.m_ClAutoStatboardScreenshotMax); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max Screenshots"), g_Config.m_ClAutoStatboardScreenshotMax);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), "");
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
g_Config.m_ClAutoStatboardScreenshotMax = g_Config.m_ClAutoStatboardScreenshotMax =
static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoStatboardScreenshotMax, static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoStatboardScreenshotMax,
@ -290,7 +290,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max CSVs"), g_Config.m_ClAutoCSVMax); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max CSVs"), g_Config.m_ClAutoCSVMax);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max CSVs"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max CSVs"), "");
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
g_Config.m_ClAutoCSVMax = g_Config.m_ClAutoCSVMax =
static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoCSVMax, static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClAutoCSVMax,
@ -334,7 +334,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
Button.VSplitLeft(150.0f, &Button, 0); Button.VSplitLeft(150.0f, &Button, 0);
char aBuf[128]; char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
static float s_OffsetName = 0.0f; static float s_OffsetName = 0.0f;
SUIExEditBoxProperties EditProps; SUIExEditBoxProperties EditProps;
EditProps.m_pEmptyText = pNameFallback; EditProps.m_pEmptyText = pNameFallback;
@ -350,7 +350,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
Button.VSplitLeft(200.0f, &Button, &Dummy); Button.VSplitLeft(200.0f, &Button, &Dummy);
Button.VSplitLeft(150.0f, &Button, 0); Button.VSplitLeft(150.0f, &Button, 0);
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
static float s_OffsetClan = 0.0f; static float s_OffsetClan = 0.0f;
if(UI()->DoEditBox(pClan, &Button, pClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan)) if(UI()->DoEditBox(pClan, &Button, pClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan))
{ {
@ -394,9 +394,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
if(pEntry->m_Texture.IsValid()) if(pEntry->m_Texture.IsValid())
{ {
SLabelProperties ItemLabelProps; UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_MC);
ItemLabelProps.m_AlignVertically = 0;
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_CENTER);
} }
} }
@ -539,7 +537,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
SkinPrefix.VSplitLeft(120.0f, &SkinPrefix, &EyesRight); SkinPrefix.VSplitLeft(120.0f, &SkinPrefix, &EyesRight);
char aBuf[128 + IO_MAX_PATH_LENGTH]; char aBuf[128 + IO_MAX_PATH_LENGTH];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin")); str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy); Dummy.HSplitTop(20.0f, &DummyLabel, &Dummy);
@ -584,7 +582,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
} }
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix); SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
UI()->DoLabel(&SkinPrefixLabel, Localize("Skin prefix"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&SkinPrefixLabel, Localize("Skin prefix"), 14.0f, TEXTALIGN_ML);
SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix); SkinPrefix.HSplitTop(20.0f, &SkinPrefixLabel, &SkinPrefix);
{ {
@ -743,7 +741,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
for(int i = 0; i < 2; i++) for(int i = 0; i < 2; i++)
{ {
aRects[i].HSplitTop(20.0f, &Label, &aRects[i]); aRects[i].HSplitTop(20.0f, &Label, &aRects[i]);
UI()->DoLabel(&Label, apParts[i], 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, apParts[i], 14.0f, TEXTALIGN_ML);
aRects[i].VSplitLeft(10.0f, 0, &aRects[i]); aRects[i].VSplitLeft(10.0f, 0, &aRects[i]);
aRects[i].HSplitTop(2.5f, 0, &aRects[i]); aRects[i].HSplitTop(2.5f, 0, &aRects[i]);
@ -827,7 +825,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor()); TextRender()->TextOutlineColor(TextRender()->DefaultTextOutlineColor());
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = FavIcon.w; Props.m_MaxWidth = FavIcon.w;
UI()->DoLabel(&FavIcon, FONT_ICON_STAR, 12.0f, TEXTALIGN_RIGHT, Props); UI()->DoLabel(&FavIcon, FONT_ICON_STAR, 12.0f, TEXTALIGN_MR, Props);
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(nullptr); TextRender()->SetCurFont(nullptr);
@ -863,7 +861,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
{ {
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Label.w - 5.0f; Props.m_MaxWidth = Label.w - 5.0f;
UI()->DoLabel(&Label, pSkinToBeDraw->GetName(), 12.0f, TEXTALIGN_LEFT, Props); UI()->DoLabel(&Label, pSkinToBeDraw->GetName(), 12.0f, TEXTALIGN_ML, Props);
} }
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {
@ -924,9 +922,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
SLabelProperties Props; UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(NULL);
@ -978,7 +974,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
static CButtonContainer s_SkinRefreshButtonID; static CButtonContainer s_SkinRefreshButtonID;
if(DoButton_Menu(&s_SkinRefreshButtonID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &RefreshButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) if(DoButton_Menu(&s_SkinRefreshButtonID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &RefreshButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f)))
{ {
// reset render flags for possible loading screen // reset render flags for possible loading screen
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
@ -1076,7 +1072,7 @@ void CMenus::DoSettingsControlsButtons(int Start, int Stop, CUIRect View)
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s:", Localize((const char *)Key.m_Name)); str_format(aBuf, sizeof(aBuf), "%s:", Localize((const char *)Key.m_Name));
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
int OldId = Key.m_KeyId, OldModifierCombination = Key.m_ModifierCombination, NewModifierCombination; int OldId = Key.m_KeyId, OldModifierCombination = Key.m_ModifierCombination, NewModifierCombination;
int NewId = DoKeyReader((void *)&Key.m_Name, &Button, OldId, OldModifierCombination, &NewModifierCombination); int NewId = DoKeyReader((void *)&Key.m_Name, &Button, OldId, OldModifierCombination, &NewModifierCombination);
if(NewId != OldId || NewModifierCombination != OldModifierCombination) if(NewId != OldId || NewModifierCombination != OldModifierCombination)
@ -1170,9 +1166,9 @@ float CMenus::RenderSettingsControlsJoystick(CUIRect View)
} }
else else
{ {
View.HSplitTop((View.h - ButtonHeight) / 2.0f, 0, &View); View.HSplitTop(View.h - ButtonHeight, 0, &View);
View.HSplitTop(ButtonHeight, &Button, &View); View.HSplitTop(ButtonHeight, &Button, &View);
UI()->DoLabel(&Button, Localize("No controller found. Plug in a controller."), 13.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Button, Localize("No controller found. Plug in a controller."), 13.0f, TEXTALIGN_MC);
} }
} }
@ -1192,13 +1188,13 @@ void CMenus::DoJoystickAxisPicker(CUIRect View)
View.HSplitTop(Spacing, 0, &View); View.HSplitTop(Spacing, 0, &View);
View.HSplitTop(ButtonHeight, &Row, &View); View.HSplitTop(ButtonHeight, &Row, &View);
Row.VSplitLeft(StatusWidth, &Button, &Row); Row.VSplitLeft(StatusWidth, &Button, &Row);
UI()->DoLabel(&Button, Localize("Device"), 13.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Button, Localize("Device"), 13.0f, TEXTALIGN_MC);
Row.VSplitLeft(StatusMargin, 0, &Row); Row.VSplitLeft(StatusMargin, 0, &Row);
Row.VSplitLeft(StatusWidth, &Button, &Row); Row.VSplitLeft(StatusWidth, &Button, &Row);
UI()->DoLabel(&Button, Localize("Status"), 13.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Button, Localize("Status"), 13.0f, TEXTALIGN_MC);
Row.VSplitLeft(2 * StatusMargin, 0, &Row); Row.VSplitLeft(2 * StatusMargin, 0, &Row);
Row.VSplitLeft(2 * BindWidth, &Button, &Row); Row.VSplitLeft(2 * BindWidth, &Button, &Row);
UI()->DoLabel(&Button, Localize("Aim bind"), 13.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Button, Localize("Aim bind"), 13.0f, TEXTALIGN_MC);
IInput::IJoystick *pJoystick = Input()->GetActiveJoystick(); IInput::IJoystick *pJoystick = Input()->GetActiveJoystick();
static int s_aActive[NUM_JOYSTICK_AXES][2]; static int s_aActive[NUM_JOYSTICK_AXES][2];
@ -1218,7 +1214,7 @@ void CMenus::DoJoystickAxisPicker(CUIRect View)
TextRender()->TextColor(0.7f, 0.7f, 0.7f, 1.0f); TextRender()->TextColor(0.7f, 0.7f, 0.7f, 1.0f);
else else
TextRender()->TextColor(TextRender()->DefaultTextColor()); TextRender()->TextColor(TextRender()->DefaultTextColor());
UI()->DoLabel(&Button, aBuf, 13.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Button, aBuf, 13.0f, TEXTALIGN_MC);
// Device status // Device status
Row.VSplitLeft(StatusMargin, 0, &Row); Row.VSplitLeft(StatusMargin, 0, &Row);
@ -1501,9 +1497,7 @@ int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelecti
if(!Item.m_Visible) if(!Item.m_Visible)
continue; continue;
SLabelProperties Props; UI()->DoLabel(&Item.m_Rect, pStr[i], 16.0f, TEXTALIGN_MC);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Item.m_Rect, pStr[i], 16.0f, TEXTALIGN_CENTER, Props);
} }
int NewIndex = s_ListBox.DoEnd(); int NewIndex = s_ListBox.DoEnd();
if(s_ListBox.WasItemSelected() || s_ListBox.WasItemActivated()) if(s_ListBox.WasItemSelected() || s_ListBox.WasItemActivated())
@ -1526,7 +1520,7 @@ int CMenus::RenderDropDown(int &CurDropDownState, CUIRect *pRect, int CurSelecti
DropDownIcon.VSplitRight(5.0f, &DropDownIcon, nullptr); DropDownIcon.VSplitRight(5.0f, &DropDownIcon, nullptr);
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
UI()->DoLabel(&DropDownIcon, FONT_ICON_CIRCLE_CHEVRON_DOWN, DropDownIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_RIGHT); UI()->DoLabel(&DropDownIcon, FONT_ICON_CIRCLE_CHEVRON_DOWN, DropDownIcon.h * CUI::ms_FontmodHeight, TEXTALIGN_MR);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(NULL);
return CurSelection; return CurSelection;
@ -1583,7 +1577,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %dx%d @%dhz %d bit (%d:%d)", Localize("Current"), (int)(g_Config.m_GfxScreenWidth * Graphics()->ScreenHiDPIScale()), (int)(g_Config.m_GfxScreenHeight * Graphics()->ScreenHiDPIScale()), g_Config.m_GfxScreenRefreshRate, g_Config.m_GfxColorDepth, g_Config.m_GfxScreenWidth / G, g_Config.m_GfxScreenHeight / G); str_format(aBuf, sizeof(aBuf), "%s: %dx%d @%dhz %d bit (%d:%d)", Localize("Current"), (int)(g_Config.m_GfxScreenWidth * Graphics()->ScreenHiDPIScale()), (int)(g_Config.m_GfxScreenHeight * Graphics()->ScreenHiDPIScale()), g_Config.m_GfxScreenRefreshRate, g_Config.m_GfxColorDepth, g_Config.m_GfxScreenWidth / G, g_Config.m_GfxScreenHeight / G);
} }
UI()->DoLabel(&ModeLabel, aBuf, sc_FontSizeResListHeader, TEXTALIGN_CENTER); UI()->DoLabel(&ModeLabel, aBuf, sc_FontSizeResListHeader, TEXTALIGN_MC);
s_ListBox.DoStart(sc_RowHeightResList, s_NumNodes, 1, 3, OldSelected, &ModeList); s_ListBox.DoStart(sc_RowHeightResList, s_NumNodes, 1, 3, OldSelected, &ModeList);
for(int i = 0; i < s_NumNodes; ++i) for(int i = 0; i < s_NumNodes; ++i)
@ -1603,9 +1597,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
int G = std::gcd(s_aModes[i].m_CanvasWidth, s_aModes[i].m_CanvasHeight); int G = std::gcd(s_aModes[i].m_CanvasWidth, s_aModes[i].m_CanvasHeight);
str_format(aBuf, sizeof(aBuf), " %dx%d @%dhz %d bit (%d:%d)", s_aModes[i].m_CanvasWidth, s_aModes[i].m_CanvasHeight, s_aModes[i].m_RefreshRate, Depth, s_aModes[i].m_CanvasWidth / G, s_aModes[i].m_CanvasHeight / G); str_format(aBuf, sizeof(aBuf), " %dx%d @%dhz %d bit (%d:%d)", s_aModes[i].m_CanvasWidth, s_aModes[i].m_CanvasHeight, s_aModes[i].m_RefreshRate, Depth, s_aModes[i].m_CanvasWidth / G, s_aModes[i].m_CanvasHeight / G);
SLabelProperties Props; UI()->DoLabel(&Item.m_Rect, aBuf, sc_FontSizeResList, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Item.m_Rect, aBuf, sc_FontSizeResList, TEXTALIGN_LEFT, Props);
} }
const int NewSelected = s_ListBox.DoEnd(); const int NewSelected = s_ListBox.DoEnd();
@ -1732,7 +1724,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_GfxRefreshRate); str_format(aBuf, sizeof(aBuf), "%s: %i Hz", Localize("Refresh Rate"), g_Config.m_GfxRefreshRate);
else else
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), ""); str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Refresh Rate"), "");
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
int NewRefreshRate = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_GfxRefreshRate, &Button, (minimum(g_Config.m_GfxRefreshRate, 1000)) / 1000.0f) * 1000.0f + 0.1f); int NewRefreshRate = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_GfxRefreshRate, &Button, (minimum(g_Config.m_GfxRefreshRate, 1000)) / 1000.0f) * 1000.0f + 0.1f);
if(g_Config.m_GfxRefreshRate <= 1000 || NewRefreshRate < 1000) if(g_Config.m_GfxRefreshRate <= 1000 || NewRefreshRate < 1000)
g_Config.m_GfxRefreshRate = NewRefreshRate; g_Config.m_GfxRefreshRate = NewRefreshRate;
@ -1741,7 +1733,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
MainView.HSplitTop(20.0f, 0, &MainView); MainView.HSplitTop(20.0f, 0, &MainView);
MainView.HSplitTop(20.0f, &Text, &MainView); MainView.HSplitTop(20.0f, &Text, &MainView);
// text.VSplitLeft(15.0f, 0, &text); // text.VSplitLeft(15.0f, 0, &text);
UI()->DoLabel(&Text, Localize("UI Color"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Text, Localize("UI Color"), 14.0f, TEXTALIGN_ML);
CUIRect HSLBar = MainView; CUIRect HSLBar = MainView;
RenderHSLScrollbars(&HSLBar, &g_Config.m_UiColor, true); RenderHSLScrollbars(&HSLBar, &g_Config.m_UiColor, true);
MainView.y = HSLBar.y; MainView.y = HSLBar.y;
@ -1781,7 +1773,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
{ {
MainView.HSplitTop(10.0f, nullptr, &MainView); MainView.HSplitTop(10.0f, nullptr, &MainView);
MainView.HSplitTop(20.0f, &Text, &MainView); MainView.HSplitTop(20.0f, &Text, &MainView);
UI()->DoLabel(&Text, Localize("Renderer"), 16.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Text, Localize("Renderer"), 16.0f, TEXTALIGN_MC);
static float s_ScrollValueDropBackend = 0; static float s_ScrollValueDropBackend = 0;
static int s_BackendDropDownState = 0; static int s_BackendDropDownState = 0;
@ -1884,7 +1876,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
{ {
MainView.HSplitTop(10.0f, nullptr, &MainView); MainView.HSplitTop(10.0f, nullptr, &MainView);
MainView.HSplitTop(20.0f, &Text, &MainView); MainView.HSplitTop(20.0f, &Text, &MainView);
UI()->DoLabel(&Text, Localize("Graphics cards"), 16.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Text, Localize("Graphics cards"), 16.0f, TEXTALIGN_MC);
static float s_ScrollValueDropGPU = 0; static float s_ScrollValueDropGPU = 0;
static int s_GPUDropDownState = 0; static int s_GPUDropDownState = 0;
@ -2019,7 +2011,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_SndRate); str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_SndRate);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
UI()->DoLabel(&Button, Localize("Sample rate"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, Localize("Sample rate"), 14.0f, TEXTALIGN_ML);
Button.VSplitLeft(190.0f, 0, &Button); Button.VSplitLeft(190.0f, 0, &Button);
static float s_Offset = 0.0f; static float s_Offset = 0.0f;
UI()->DoEditBox(&g_Config.m_SndRate, &Button, aBuf, sizeof(aBuf), 14.0f, &s_Offset); UI()->DoEditBox(&g_Config.m_SndRate, &Button, aBuf, sizeof(aBuf), 14.0f, &s_Offset);
@ -2032,7 +2024,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(190.0f, &Label, &Button); Button.VSplitLeft(190.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Sound volume"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Sound volume"), 14.0f, TEXTALIGN_ML);
g_Config.m_SndVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f); g_Config.m_SndVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume / 100.0f) * 100.0f);
} }
@ -2041,7 +2033,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(190.0f, &Label, &Button); Button.VSplitLeft(190.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Game sound volume"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Game sound volume"), 14.0f, TEXTALIGN_ML);
g_Config.m_SndGameSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndGameSoundVolume, &Button, g_Config.m_SndGameSoundVolume / 100.0f) * 100.0f); g_Config.m_SndGameSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndGameSoundVolume, &Button, g_Config.m_SndGameSoundVolume / 100.0f) * 100.0f);
} }
@ -2050,7 +2042,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(190.0f, &Label, &Button); Button.VSplitLeft(190.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Chat sound volume"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Chat sound volume"), 14.0f, TEXTALIGN_ML);
g_Config.m_SndChatSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndChatSoundVolume, &Button, g_Config.m_SndChatSoundVolume / 100.0f) * 100.0f); g_Config.m_SndChatSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndChatSoundVolume, &Button, g_Config.m_SndChatSoundVolume / 100.0f) * 100.0f);
} }
@ -2059,7 +2051,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(190.0f, &Label, &Button); Button.VSplitLeft(190.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Map sound volume"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Map sound volume"), 14.0f, TEXTALIGN_ML);
g_Config.m_SndMapSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f); g_Config.m_SndMapSoundVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndMapSoundVolume, &Button, g_Config.m_SndMapSoundVolume / 100.0f) * 100.0f);
} }
@ -2068,7 +2060,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
MainView.HSplitTop(5.0f, &Button, &MainView); MainView.HSplitTop(5.0f, &Button, &MainView);
MainView.HSplitTop(20.0f, &Button, &MainView); MainView.HSplitTop(20.0f, &Button, &MainView);
Button.VSplitLeft(190.0f, &Label, &Button); Button.VSplitLeft(190.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Background music volume"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Background music volume"), 14.0f, TEXTALIGN_ML);
g_Config.m_SndBackgroundMusicVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f); g_Config.m_SndBackgroundMusicVolume = (int)(UI()->DoScrollbarH(&g_Config.m_SndBackgroundMusicVolume, &Button, g_Config.m_SndBackgroundMusicVolume / 100.0f) * 100.0f);
} }
} }
@ -2109,9 +2101,7 @@ bool CMenus::RenderLanguageSelection(CUIRect MainView)
ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f);
m_pClient->m_CountryFlags.Render(Language.m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h); m_pClient->m_CountryFlags.Render(Language.m_CountryCode, &Color, FlagRect.x, FlagRect.y, FlagRect.w, FlagRect.h);
SLabelProperties Props; UI()->DoLabel(&Label, Language.m_Name.c_str(), 16.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Label, Language.m_Name.c_str(), 16.0f, TEXTALIGN_LEFT, Props);
} }
s_SelectedLanguage = s_ListBox.DoEnd(); s_SelectedLanguage = s_ListBox.DoEnd();
@ -2224,11 +2214,11 @@ void CMenus::RenderSettings(CUIRect MainView)
if(m_NeedRestartUpdate) if(m_NeedRestartUpdate)
{ {
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
UI()->DoLabel(&RestartWarning, Localize("DDNet Client needs to be restarted to complete update!"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&RestartWarning, Localize("DDNet Client needs to be restarted to complete update!"), 14.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
else if(m_NeedRestartGeneral || m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound || m_NeedRestartDDNet) else if(m_NeedRestartGeneral || m_NeedRestartSkins || m_NeedRestartGraphics || m_NeedRestartSound || m_NeedRestartDDNet)
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 14.0f, TEXTALIGN_ML);
RenderColorPicker(); RenderColorPicker();
} }
@ -2571,7 +2561,7 @@ ColorHSLA CMenus::RenderHSLScrollbars(CUIRect *pRect, unsigned int *pColor, bool
Button.Margin(2.0f, &Rail); Button.Margin(2.0f, &Rail);
str_format(aBuf, sizeof(aBuf), "%s: %03d", apLabels[i], (int)(*apComponent[i] * 255)); str_format(aBuf, sizeof(aBuf), "%s: %03d", apLabels[i], (int)(*apComponent[i] * 255));
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
ColorHSLA CurColorPureHSLA(RenderColorHSLA.r, 1, 0.5f, 1); ColorHSLA CurColorPureHSLA(RenderColorHSLA.r, 1, 0.5f, 1);
ColorRGBA CurColorPure = color_cast<ColorRGBA>(CurColorPureHSLA); ColorRGBA CurColorPure = color_cast<ColorRGBA>(CurColorPureHSLA);
@ -2673,7 +2663,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** HUD ***** // // ***** HUD ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("HUD"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("HUD"), HeadlineFontSize, TEXTALIGN_ML);
// Switch of the entire HUD // Switch of the entire HUD
LeftView.HSplitTop(SectionTotalMargin + LineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + LineSize, &Section, &LeftView);
@ -2699,7 +2689,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** DDRace HUD ***** // // ***** DDRace HUD ***** //
RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView); RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView);
UI()->DoLabel(&Label, Localize("DDRace HUD"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("DDRace HUD"), HeadlineFontSize, TEXTALIGN_ML);
// Switches of various DDRace HUD elements // Switches of various DDRace HUD elements
RightView.HSplitTop(SectionTotalMargin + 4 * LineSize, &Section, &RightView); RightView.HSplitTop(SectionTotalMargin + 4 * LineSize, &Section, &RightView);
@ -2742,7 +2732,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
Section.HSplitTop(LineSize, &Button, &Section); Section.HSplitTop(LineSize, &Button, &Section);
str_format(aBuf, sizeof(aBuf), "%s: %i%%", Localize("Opacity of freeze bars inside freeze"), g_Config.m_ClFreezeBarsAlphaInsideFreeze); str_format(aBuf, sizeof(aBuf), "%s: %i%%", Localize("Opacity of freeze bars inside freeze"), g_Config.m_ClFreezeBarsAlphaInsideFreeze);
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
g_Config.m_ClFreezeBarsAlphaInsideFreeze = (int)(UI()->DoScrollbarH(&g_Config.m_ClFreezeBarsAlphaInsideFreeze, &Button, g_Config.m_ClFreezeBarsAlphaInsideFreeze / 100.0f) * 100.0f); g_Config.m_ClFreezeBarsAlphaInsideFreeze = (int)(UI()->DoScrollbarH(&g_Config.m_ClFreezeBarsAlphaInsideFreeze, &Button, g_Config.m_ClFreezeBarsAlphaInsideFreeze / 100.0f) * 100.0f);
} }
else else
@ -2757,7 +2747,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Chat ***** // // ***** Chat ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Chat"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Chat"), HeadlineFontSize, TEXTALIGN_ML);
// General chat settings // General chat settings
LeftView.HSplitTop(SectionTotalMargin + 3 * LineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 3 * LineSize, &Section, &LeftView);
@ -2772,7 +2762,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Messages ***** // // ***** Messages ***** //
LeftView.HSplitTop(MarginToNextSection, 0x0, &LeftView); LeftView.HSplitTop(MarginToNextSection, 0x0, &LeftView);
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Messages"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Messages"), HeadlineFontSize, TEXTALIGN_ML);
// Message Colors and extra settings // Message Colors and extra settings
LeftView.HSplitTop(SectionTotalMargin + 6 * ColorPickerLineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 6 * ColorPickerLineSize, &Section, &LeftView);
@ -2792,7 +2782,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Chat Preview ***** // // ***** Chat Preview ***** //
RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView); RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView);
UI()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_ML);
// Use the rest of the view for preview // Use the rest of the view for preview
Section = RightView; Section = RightView;
@ -2976,7 +2966,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Name Plate ***** // // ***** Name Plate ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Name Plate"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Name Plate"), HeadlineFontSize, TEXTALIGN_ML);
// General chat settings // General chat settings
LeftView.HSplitTop(SectionTotalMargin + 9 * LineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 9 * LineSize, &Section, &LeftView);
@ -2986,7 +2976,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
Section.HSplitTop(LineSize, &Button, &Section); Section.HSplitTop(LineSize, &Button, &Section);
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Name plates size"), g_Config.m_ClNameplatesSize); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Name plates size"), g_Config.m_ClNameplatesSize);
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
g_Config.m_ClNameplatesSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize / 100.0f) * 100.0f + 0.1f); g_Config.m_ClNameplatesSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize / 100.0f) * 100.0f + 0.1f);
} }
@ -2996,7 +2986,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
Section.HSplitTop(LineSize, &Button, &Section); Section.HSplitTop(LineSize, &Button, &Section);
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Clan plates size"), g_Config.m_ClNameplatesClanSize); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Clan plates size"), g_Config.m_ClNameplatesClanSize);
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
g_Config.m_ClNameplatesClanSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClNameplatesClanSize, &Button, g_Config.m_ClNameplatesClanSize / 100.0f) * 100.0f + 0.1f); g_Config.m_ClNameplatesClanSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClNameplatesClanSize, &Button, g_Config.m_ClNameplatesClanSize / 100.0f) * 100.0f + 0.1f);
} }
else else
@ -3026,7 +3016,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Hookline ***** // // ***** Hookline ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Hook collision line"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Hook collision line"), HeadlineFontSize, TEXTALIGN_ML);
// General hookline settings // General hookline settings
LeftView.HSplitTop(SectionTotalMargin + 6 * LineSize + 3 * ColorPickerLineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 6 * LineSize + 3 * ColorPickerLineSize, &Section, &LeftView);
@ -3042,7 +3032,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
Section.HSplitTop(LineSize, &Button, &Section); Section.HSplitTop(LineSize, &Button, &Section);
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Hook collision line width"), g_Config.m_ClHookCollSize); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Hook collision line width"), g_Config.m_ClHookCollSize);
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
g_Config.m_ClHookCollSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClHookCollSize, &Button, g_Config.m_ClHookCollSize / 20.0f) * 20.0f); g_Config.m_ClHookCollSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClHookCollSize, &Button, g_Config.m_ClHookCollSize / 20.0f) * 20.0f);
} }
@ -3050,7 +3040,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
Section.HSplitTop(LineSize, &Button, &Section); Section.HSplitTop(LineSize, &Button, &Section);
str_format(aBuf, sizeof(aBuf), "%s: %i%%", Localize("Hook collision line opacity"), g_Config.m_ClHookCollAlpha); str_format(aBuf, sizeof(aBuf), "%s: %i%%", Localize("Hook collision line opacity"), g_Config.m_ClHookCollAlpha);
UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_ML);
g_Config.m_ClHookCollAlpha = (int)(UI()->DoScrollbarH(&g_Config.m_ClHookCollAlpha, &Button, g_Config.m_ClHookCollAlpha / 100.0f) * 100.0f); g_Config.m_ClHookCollAlpha = (int)(UI()->DoScrollbarH(&g_Config.m_ClHookCollAlpha, &Button, g_Config.m_ClHookCollAlpha / 100.0f) * 100.0f);
} }
@ -3058,7 +3048,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
static int s_HookCollToolTip; static int s_HookCollToolTip;
Section.HSplitTop(LineSize, &Label, &Section); Section.HSplitTop(LineSize, &Label, &Section);
UI()->DoLabel(&Label, Localize("Colors of the hook collision line, in case of a possible collision with:"), 13.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Colors of the hook collision line, in case of a possible collision with:"), 13.0f, TEXTALIGN_ML);
GameClient()->m_Tooltips.DoToolTip(&s_HookCollToolTip, &Label, Localize("Your movements are not taken into account when calculating the line colors")); GameClient()->m_Tooltips.DoToolTip(&s_HookCollToolTip, &Label, Localize("Your movements are not taken into account when calculating the line colors"));
DoLine_ColorPicker(&s_HookCollNoCollResetID, ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Nothing hookable"), &g_Config.m_ClHookCollColorNoColl, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), false); DoLine_ColorPicker(&s_HookCollNoCollResetID, ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Nothing hookable"), &g_Config.m_ClHookCollColorNoColl, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), false);
DoLine_ColorPicker(&s_HookCollHookableCollResetID, ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Something hookable"), &g_Config.m_ClHookCollColorHookableColl, ColorRGBA(130.0f / 255.0f, 232.0f / 255.0f, 160.0f / 255.0f, 1.0f), false); DoLine_ColorPicker(&s_HookCollHookableCollResetID, ColorPickerLineSize, ColorPickerLabelSize, ColorPickerLineSpacing, &Section, Localize("Something hookable"), &g_Config.m_ClHookCollColorHookableColl, ColorRGBA(130.0f / 255.0f, 232.0f / 255.0f, 160.0f / 255.0f, 1.0f), false);
@ -3070,7 +3060,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Kill Messages ***** // // ***** Kill Messages ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Kill Messages"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Kill Messages"), HeadlineFontSize, TEXTALIGN_ML);
// General kill messages settings // General kill messages settings
LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 2 * ColorPickerLineSize, &Section, &LeftView);
@ -3087,7 +3077,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Weapons ***** // // ***** Weapons ***** //
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Weapons"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Weapons"), HeadlineFontSize, TEXTALIGN_ML);
// General weapon laser settings // General weapon laser settings
LeftView.HSplitTop(SectionTotalMargin + 4 * ColorPickerLineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 4 * ColorPickerLineSize, &Section, &LeftView);
@ -3103,7 +3093,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Entities ***** // // ***** Entities ***** //
LeftView.HSplitTop(MarginToNextSection * 2.0f, 0x0, &LeftView); LeftView.HSplitTop(MarginToNextSection * 2.0f, 0x0, &LeftView);
LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView); LeftView.HSplitTop(HeadlineAndVMargin, &Label, &LeftView);
UI()->DoLabel(&Label, Localize("Entities"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Entities"), HeadlineFontSize, TEXTALIGN_ML);
// General entity laser settings // General entity laser settings
LeftView.HSplitTop(SectionTotalMargin + 4 * ColorPickerLineSize, &Section, &LeftView); LeftView.HSplitTop(SectionTotalMargin + 4 * ColorPickerLineSize, &Section, &LeftView);
@ -3147,7 +3137,7 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
// ***** Laser Preview ***** // // ***** Laser Preview ***** //
RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView); RightView.HSplitTop(HeadlineAndVMargin, &Label, &RightView);
UI()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Preview"), HeadlineFontSize, TEXTALIGN_ML);
RightView.HSplitTop(SectionTotalMargin + 50.0f, &Section, &RightView); RightView.HSplitTop(SectionTotalMargin + 50.0f, &Section, &RightView);
Section.Margin(SectionMargin, &Section); Section.Margin(SectionMargin, &Section);
@ -3177,7 +3167,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
MainView.HSplitTop(100.0f, &Demo, &MainView); MainView.HSplitTop(100.0f, &Demo, &MainView);
Demo.HSplitTop(30.0f, &Label, &Demo); Demo.HSplitTop(30.0f, &Label, &Demo);
UI()->DoLabel(&Label, Localize("Demo"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Demo"), 20.0f, TEXTALIGN_ML);
Demo.Margin(5.0f, &Demo); Demo.Margin(5.0f, &Demo);
Demo.VSplitMid(&Left, &Right); Demo.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0); Left.VSplitRight(5.0f, &Left, 0);
@ -3211,7 +3201,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Button.VSplitLeft(140.0f, &Label, &Button); Button.VSplitLeft(140.0f, &Label, &Button);
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), Localize("Default length: %d"), g_Config.m_ClReplayLength); str_format(aBuf, sizeof(aBuf), Localize("Default length: %d"), g_Config.m_ClReplayLength);
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
int NewValue = (int)(UI()->DoScrollbarH(&g_Config.m_ClReplayLength, &Button, (minimum(g_Config.m_ClReplayLength, 600) - 10) / 590.0f) * 590.0f) + 10; int NewValue = (int)(UI()->DoScrollbarH(&g_Config.m_ClReplayLength, &Button, (minimum(g_Config.m_ClReplayLength, 600) - 10) / 590.0f) * 590.0f) + 10;
if(g_Config.m_ClReplayLength < 600 || NewValue < 600) if(g_Config.m_ClReplayLength < 600 || NewValue < 600)
@ -3243,7 +3233,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
MainView.HSplitTop(330.0f, &Gameplay, &MainView); MainView.HSplitTop(330.0f, &Gameplay, &MainView);
Gameplay.HSplitTop(30.0f, &Label, &Gameplay); Gameplay.HSplitTop(30.0f, &Label, &Gameplay);
UI()->DoLabel(&Label, Localize("Gameplay"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Gameplay"), 20.0f, TEXTALIGN_ML);
Gameplay.Margin(5.0f, &Gameplay); Gameplay.Margin(5.0f, &Gameplay);
Gameplay.VSplitMid(&Left, &Right); Gameplay.VSplitMid(&Left, &Right);
Left.VSplitRight(5.0f, &Left, 0); Left.VSplitRight(5.0f, &Left, 0);
@ -3252,7 +3242,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
{ {
Left.HSplitTop(20.0f, &Button, &Left); Left.HSplitTop(20.0f, &Button, &Left);
Button.VSplitLeft(120.0f, &Label, &Button); Button.VSplitLeft(120.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Overlay entities"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Overlay entities"), 14.0f, TEXTALIGN_ML);
g_Config.m_ClOverlayEntities = (int)(UI()->DoScrollbarH(&g_Config.m_ClOverlayEntities, &Button, g_Config.m_ClOverlayEntities / 100.0f) * 100.0f); g_Config.m_ClOverlayEntities = (int)(UI()->DoScrollbarH(&g_Config.m_ClOverlayEntities, &Button, g_Config.m_ClOverlayEntities / 100.0f) * 100.0f);
} }
@ -3261,7 +3251,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Button.VSplitMid(&LeftLeft, &Button); Button.VSplitMid(&LeftLeft, &Button);
Button.VSplitLeft(50.0f, &Label, &Button); Button.VSplitLeft(50.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Size"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Size"), 14.0f, TEXTALIGN_ML);
g_Config.m_ClTextEntitiesSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClTextEntitiesSize, &Button, g_Config.m_ClTextEntitiesSize / 100.0f) * 100.0f); g_Config.m_ClTextEntitiesSize = (int)(UI()->DoScrollbarH(&g_Config.m_ClTextEntitiesSize, &Button, g_Config.m_ClTextEntitiesSize / 100.0f) * 100.0f);
if(DoButton_CheckBox(&g_Config.m_ClTextEntities, Localize("Show text entities"), g_Config.m_ClTextEntities, &LeftLeft)) if(DoButton_CheckBox(&g_Config.m_ClTextEntities, Localize("Show text entities"), g_Config.m_ClTextEntities, &LeftLeft))
@ -3275,7 +3265,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Button.VSplitMid(&LeftLeft, &Button); Button.VSplitMid(&LeftLeft, &Button);
Button.VSplitLeft(50.0f, &Label, &Button); Button.VSplitLeft(50.0f, &Label, &Button);
UI()->DoLabel(&Label, Localize("Opacity"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Opacity"), 14.0f, TEXTALIGN_ML);
g_Config.m_ClShowOthersAlpha = (int)(UI()->DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha / 100.0f) * 100.0f); g_Config.m_ClShowOthersAlpha = (int)(UI()->DoScrollbarH(&g_Config.m_ClShowOthersAlpha, &Button, g_Config.m_ClShowOthersAlpha / 100.0f) * 100.0f);
if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == SHOW_OTHERS_ON, &LeftLeft)) if(DoButton_CheckBox(&g_Config.m_ClShowOthers, Localize("Show others"), g_Config.m_ClShowOthers == SHOW_OTHERS_ON, &LeftLeft))
@ -3304,7 +3294,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Label.VSplitLeft(130.0f, &Label, &Button); Label.VSplitLeft(130.0f, &Label, &Button);
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Default zoom"), g_Config.m_ClDefaultZoom); str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Default zoom"), g_Config.m_ClDefaultZoom);
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
g_Config.m_ClDefaultZoom = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClDefaultZoom, &Button, g_Config.m_ClDefaultZoom / 20.0f) * 20.0f + 0.1f); g_Config.m_ClDefaultZoom = static_cast<int>(UI()->DoScrollbarH(&g_Config.m_ClDefaultZoom, &Button, g_Config.m_ClDefaultZoom / 20.0f) * 20.0f + 0.1f);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
@ -3359,12 +3349,12 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Left.HSplitTop(25.0f, &TempLabel, &Left); Left.HSplitTop(25.0f, &TempLabel, &Left);
Left.HSplitTop(5.0f, 0x0, &Left); Left.HSplitTop(5.0f, 0x0, &Left);
UI()->DoLabel(&TempLabel, Localize("Background"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&TempLabel, Localize("Background"), 20.0f, TEXTALIGN_ML);
Right.HSplitTop(25.0f, &TempLabel, &Right); Right.HSplitTop(25.0f, &TempLabel, &Right);
Right.HSplitTop(5.0f, 0x0, &Miscellaneous); Right.HSplitTop(5.0f, 0x0, &Miscellaneous);
UI()->DoLabel(&TempLabel, Localize("Miscellaneous"), 20.0f, TEXTALIGN_LEFT); UI()->DoLabel(&TempLabel, Localize("Miscellaneous"), 20.0f, TEXTALIGN_ML);
static CButtonContainer s_ResetID2; static CButtonContainer s_ResetID2;
ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1); ColorRGBA GreyDefault(0.5f, 0.5f, 0.5f, 1);
@ -3374,7 +3364,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Left.HSplitTop(25.0f, &Background, &Left); Left.HSplitTop(25.0f, &Background, &Left);
Background.HSplitTop(20.0f, &Background, 0); Background.HSplitTop(20.0f, &Background, 0);
Background.VSplitLeft(100.0f, &Label, &TempLabel); Background.VSplitLeft(100.0f, &Label, &TempLabel);
UI()->DoLabel(&Label, Localize("Map"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Map"), 14.0f, TEXTALIGN_ML);
static float s_Map = 0.0f; static float s_Map = 0.0f;
UI()->DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map); UI()->DoEditBox(g_Config.m_ClBackgroundEntities, &TempLabel, g_Config.m_ClBackgroundEntities, sizeof(g_Config.m_ClBackgroundEntities), 14.0f, &s_Map);
@ -3409,7 +3399,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Right.HSplitTop(5.0f, 0, &Right); Right.HSplitTop(5.0f, 0, &Right);
Right.HSplitTop(20.0f, &Label, &Right); Right.HSplitTop(20.0f, &Label, &Right);
Label.VSplitLeft(5.0f, 0, &Label); Label.VSplitLeft(5.0f, 0, &Label);
UI()->DoLabel(&Label, Localize("Run on join"), 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, Localize("Run on join"), 14.0f, TEXTALIGN_ML);
Right.HSplitTop(20.0f, &Button, &Right); Right.HSplitTop(20.0f, &Button, &Right);
Button.VSplitLeft(5.0f, 0, &Button); Button.VSplitLeft(5.0f, 0, &Button);
SUIExEditBoxProperties EditProps; SUIExEditBoxProperties EditProps;
@ -3465,7 +3455,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
Client()->RequestDDNetInfo(); Client()->RequestDDNetInfo();
} }
} }
UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
#endif #endif

View file

@ -583,7 +583,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
CUIRect TextureRect; CUIRect TextureRect;
ItemRect.HSplitTop(15, &ItemRect, &TextureRect); ItemRect.HSplitTop(15, &ItemRect, &TextureRect);
TextureRect.HSplitTop(10, NULL, &TextureRect); TextureRect.HSplitTop(10, NULL, &TextureRect);
UI()->DoLabel(&ItemRect, pItem->m_aName, ItemRect.h - 2, TEXTALIGN_CENTER); UI()->DoLabel(&ItemRect, pItem->m_aName, ItemRect.h - 2, TEXTALIGN_MC);
if(pItem->m_RenderTexture.IsValid()) if(pItem->m_RenderTexture.IsValid())
{ {
Graphics()->WrapClamp(); Graphics()->WrapClamp();
@ -643,9 +643,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
SLabelProperties Props; UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, FONT_ICON_MAGNIFYING_GLASS, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f); float wSearch = TextRender()->TextWidth(14.0f, FONT_ICON_MAGNIFYING_GLASS, -1, -1.0f);
TextRender()->SetRenderFlags(0); TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL); TextRender()->SetCurFont(NULL);
@ -699,7 +697,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE); TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
static CButtonContainer s_AssetsReloadBtnID; static CButtonContainer s_AssetsReloadBtnID;
if(DoButton_Menu(&s_AssetsReloadBtnID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) if(DoButton_Menu(&s_AssetsReloadBtnID, FONT_ICON_ARROW_ROTATE_RIGHT, 0, &ReloadButton, nullptr, IGraphics::CORNER_ALL, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f)))
{ {
ClearCustomItems(s_CurCustomTab); ClearCustomItems(s_CurCustomTab);
} }

View file

@ -232,7 +232,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!")); str_format(aBuf, sizeof(aBuf), Localize("DDNet Client updated!"));
TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f);
} }
UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_ML);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
VersionUpdate.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part); VersionUpdate.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part);
@ -275,12 +275,12 @@ void CMenus::RenderStartMenu(CUIRect MainView)
char aBuf[64]; char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion()); str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is out!"), Client()->LatestVersion());
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_CENTER); UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_MC);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
} }
#endif #endif
UI()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&CurVersion, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_MR);
if(NewPage != -1) if(NewPage != -1)
{ {

View file

@ -109,7 +109,7 @@ void CTooltips::OnRender()
Rect.Draw(ColorRGBA(0.2, 0.2, 0.2, 0.80f), IGraphics::CORNER_ALL, 5.0f); Rect.Draw(ColorRGBA(0.2, 0.2, 0.2, 0.80f), IGraphics::CORNER_ALL, 5.0f);
Rect.Margin(2.0f, &Rect); Rect.Margin(2.0f, &Rect);
UI()->DoLabel(&Rect, Tooltip.m_pText, 14.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Rect, Tooltip.m_pText, 14.0f, TEXTALIGN_ML);
Tooltip.m_OnScreen = false; Tooltip.m_OnScreen = false;
} }
} }

View file

@ -325,7 +325,7 @@ void CVoting::RenderBars(CUIRect Bars, bool Text)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%d", m_Yes); str_format(aBuf, sizeof(aBuf), "%d", m_Yes);
UI()->DoLabel(&YesArea, aBuf, Bars.h * 0.75f, TEXTALIGN_CENTER); UI()->DoLabel(&YesArea, aBuf, Bars.h * 0.75f, TEXTALIGN_MC);
} }
PassArea.x += YesArea.w; PassArea.x += YesArea.w;
@ -343,7 +343,7 @@ void CVoting::RenderBars(CUIRect Bars, bool Text)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%d", m_No); str_format(aBuf, sizeof(aBuf), "%d", m_No);
UI()->DoLabel(&NoArea, aBuf, Bars.h * 0.75f, TEXTALIGN_CENTER); UI()->DoLabel(&NoArea, aBuf, Bars.h * 0.75f, TEXTALIGN_MC);
} }
PassArea.w -= NoArea.w; PassArea.w -= NoArea.w;
@ -353,7 +353,7 @@ void CVoting::RenderBars(CUIRect Bars, bool Text)
{ {
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "%d", m_Pass); str_format(aBuf, sizeof(aBuf), "%d", m_Pass);
UI()->DoLabel(&PassArea, aBuf, Bars.h * 0.75f, TEXTALIGN_CENTER); UI()->DoLabel(&PassArea, aBuf, Bars.h * 0.75f, TEXTALIGN_MC);
} }
} }
} }

View file

@ -517,14 +517,39 @@ void CUI::DoSmoothScrollLogic(float *pScrollOffset, float *pScrollOffsetChange,
} }
} }
static vec2 CalcAlignedCursorPos(const CUIRect *pRect, vec2 TextSize, int Align)
{
vec2 Cursor(pRect->x, pRect->y);
const int HorizontalAlign = Align & TEXTALIGN_MASK_HORIZONTAL;
if(HorizontalAlign == TEXTALIGN_CENTER)
{
Cursor.x += (pRect->w - TextSize.x) / 2.0f;
}
else if(HorizontalAlign == TEXTALIGN_RIGHT)
{
Cursor.x += pRect->w - TextSize.x;
}
const int VerticalAlign = Align & TEXTALIGN_MASK_VERTICAL;
if(VerticalAlign == TEXTALIGN_MIDDLE)
{
Cursor.y += (pRect->h - TextSize.y) / 2.0f;
}
else if(VerticalAlign == TEXTALIGN_BOTTOM)
{
Cursor.y += pRect->h - TextSize.y;
}
return Cursor;
}
void CUI::DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps) void CUI::DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps)
{ {
int Flags = LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0; int Flags = LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0;
float TextHeight = 0.0f; float TextHeight = 0.0f;
float AlignedFontSize = 0.0f;
float MaxCharacterHeightInLine = 0.0f;
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w; float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
float TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight, &AlignedFontSize, &MaxCharacterHeightInLine); float TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight);
while(TextWidth > MaxTextWidth + 0.001f) while(TextWidth > MaxTextWidth + 0.001f)
{ {
if(!LabelProps.m_EnableWidthCheck) if(!LabelProps.m_EnableWidthCheck)
@ -532,31 +557,13 @@ void CUI::DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align
if(Size < 4.0f) if(Size < 4.0f)
break; break;
Size -= 1.0f; Size -= 1.0f;
TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight, &AlignedFontSize, &MaxCharacterHeightInLine); TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight);
} }
float CursorX = 0.0f; const vec2 CursorPos = CalcAlignedCursorPos(pRect, vec2(TextWidth, TextHeight), Align);
if(Align & TEXTALIGN_CENTER)
{
CursorX = pRect->x + (pRect->w - TextWidth) / 2.f;
}
else if(Align & TEXTALIGN_LEFT)
{
CursorX = pRect->x;
}
else if(Align & TEXTALIGN_RIGHT)
{
CursorX = pRect->x + pRect->w - TextWidth;
}
float CursorY = pRect->y + (pRect->h - TextHeight) / 2.f;
if(LabelProps.m_AlignVertically == 0)
{
CursorY = pRect->y + (pRect->h - AlignedFontSize) / 2.f - (AlignedFontSize - MaxCharacterHeightInLine) / 2.f;
}
CTextCursor Cursor; CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, CursorX, CursorY, Size, TEXTFLAG_RENDER | Flags); TextRender()->SetCursor(&Cursor, CursorPos.x, CursorPos.y, Size, TEXTFLAG_RENDER | Flags);
Cursor.m_LineWidth = (float)LabelProps.m_MaxWidth; Cursor.m_LineWidth = (float)LabelProps.m_MaxWidth;
if(LabelProps.m_pSelCursor) if(LabelProps.m_pSelCursor)
{ {
@ -584,10 +591,8 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
{ {
int Flags = pReadCursor ? (pReadCursor->m_Flags & ~TEXTFLAG_RENDER) : LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0; int Flags = pReadCursor ? (pReadCursor->m_Flags & ~TEXTFLAG_RENDER) : LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0;
float TextHeight = 0.0f; float TextHeight = 0.0f;
float AlignedFontSize = 0.0f;
float MaxCharacterHeightInLine = 0.0f;
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w; float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
float TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight, &AlignedFontSize, &MaxCharacterHeightInLine); float TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight);
while(TextWidth > MaxTextWidth + 0.001f) while(TextWidth > MaxTextWidth + 0.001f)
{ {
if(!LabelProps.m_EnableWidthCheck) if(!LabelProps.m_EnableWidthCheck)
@ -595,27 +600,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
if(Size < 4.0f) if(Size < 4.0f)
break; break;
Size -= 1.0f; Size -= 1.0f;
TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight, &AlignedFontSize, &MaxCharacterHeightInLine); TextWidth = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, Flags, &TextHeight);
}
float CursorX = 0;
if(Align & TEXTALIGN_CENTER)
{
CursorX = pRect->x + (pRect->w - TextWidth) / 2.f;
}
else if(Align & TEXTALIGN_LEFT)
{
CursorX = pRect->x;
}
else if(Align & TEXTALIGN_RIGHT)
{
CursorX = pRect->x + pRect->w - TextWidth;
}
float CursorY = pRect->y + (pRect->h - TextHeight) / 2.f;
if(LabelProps.m_AlignVertically == 0)
{
CursorY = pRect->y + (pRect->h - AlignedFontSize) / 2.f - (AlignedFontSize - MaxCharacterHeightInLine) / 2.f;
} }
CTextCursor Cursor; CTextCursor Cursor;
@ -625,7 +610,8 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
} }
else else
{ {
TextRender()->SetCursor(&Cursor, CursorX, CursorY, Size, TEXTFLAG_RENDER | Flags); const vec2 CursorPos = CalcAlignedCursorPos(pRect, vec2(TextWidth, TextHeight), Align);
TextRender()->SetCursor(&Cursor, CursorPos.x, CursorPos.y, Size, TEXTFLAG_RENDER | Flags);
} }
Cursor.m_LineWidth = LabelProps.m_MaxWidth; Cursor.m_LineWidth = LabelProps.m_MaxWidth;
@ -639,7 +625,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
RectEl.m_Cursor = Cursor; RectEl.m_Cursor = Cursor;
} }
void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, const CTextCursor *pReadCursor) void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, bool StopAtEnd, int StrLen, const CTextCursor *pReadCursor)
{ {
bool NeedsRecreate = false; bool NeedsRecreate = false;
bool ColorChanged = RectEl.m_TextColor != TextRender()->GetTextColor() || RectEl.m_TextOutlineColor != TextRender()->GetTextOutlineColor(); bool ColorChanged = RectEl.m_TextColor != TextRender()->GetTextColor() || RectEl.m_TextOutlineColor != TextRender()->GetTextOutlineColor();
@ -684,16 +670,16 @@ void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRe
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = MaxWidth; Props.m_MaxWidth = MaxWidth;
Props.m_AlignVertically = AlignVertically;
Props.m_StopAtEnd = StopAtEnd; Props.m_StopAtEnd = StopAtEnd;
DoLabel(RectEl, &TmpRect, pText, Size, Align, Props, StrLen, pReadCursor); DoLabel(RectEl, &TmpRect, pText, Size, TEXTALIGN_TL, Props, StrLen, pReadCursor);
} }
ColorRGBA ColorText(RectEl.m_TextColor); ColorRGBA ColorText(RectEl.m_TextColor);
ColorRGBA ColorTextOutline(RectEl.m_TextOutlineColor); ColorRGBA ColorTextOutline(RectEl.m_TextOutlineColor);
if(RectEl.m_UITextContainer != -1) if(RectEl.m_UITextContainer != -1)
{ {
TextRender()->RenderTextContainer(RectEl.m_UITextContainer, ColorText, ColorTextOutline, pRect->x, pRect->y); const vec2 CursorPos = CalcAlignedCursorPos(pRect, vec2(RectEl.m_Cursor.m_LongestLineWidth, RectEl.m_Cursor.Height()), Align);
TextRender()->RenderTextContainer(RectEl.m_UITextContainer, ColorText, ColorTextOutline, CursorPos.x, CursorPos.y);
} }
} }
@ -1076,7 +1062,7 @@ bool CUI::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned
SLabelProperties Props; SLabelProperties Props;
Props.m_pSelCursor = &SelCursor; Props.m_pSelCursor = &SelCursor;
Props.m_EnableWidthCheck = IsEmptyText; Props.m_EnableWidthCheck = IsEmptyText;
DoLabel(&Textbox, pDisplayStr, FontSize, TEXTALIGN_LEFT, Props); DoLabel(&Textbox, pDisplayStr, FontSize, TEXTALIGN_ML, Props);
if(LastActiveItem() == pID) if(LastActiveItem() == pID)
{ {
@ -1112,22 +1098,19 @@ bool CUI::DoClearableEditBox(const void *pID, const void *pClearID, const CUIRec
{ {
CUIRect EditBox; CUIRect EditBox;
CUIRect ClearButton; CUIRect ClearButton;
pRect->VSplitRight(15.0f, &EditBox, &ClearButton); pRect->VSplitRight(pRect->h, &EditBox, &ClearButton);
bool ReturnValue = DoEditBox(pID, &EditBox, pStr, StrSize, FontSize, pOffset, Hidden, Corners & ~IGraphics::CORNER_R, Properties); bool ReturnValue = DoEditBox(pID, &EditBox, pStr, StrSize, FontSize, pOffset, Hidden, Corners & ~IGraphics::CORNER_R, Properties);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT); ClearButton.Draw(ColorRGBA(1.0f, 1.0f, 1.0f, 0.33f * ButtonColorMul(pClearID)), Corners & ~IGraphics::CORNER_L, 3.0f);
ClearButton.Draw(ColorRGBA(1, 1, 1, 0.33f * ButtonColorMul(pClearID)), Corners & ~IGraphics::CORNER_L, 3.0f); DoLabel(&ClearButton, "×", ClearButton.h * CUI::ms_FontmodHeight * 0.8f, TEXTALIGN_MC);
SLabelProperties Props;
Props.m_AlignVertically = 0;
DoLabel(&ClearButton, "×", ClearButton.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
TextRender()->SetRenderFlags(0);
if(DoButtonLogic(pClearID, 0, &ClearButton)) if(DoButtonLogic(pClearID, 0, &ClearButton))
{ {
pStr[0] = 0; pStr[0] = 0;
SetActiveItem(pID); SetActiveItem(pID);
ReturnValue = true; ReturnValue = true;
} }
return ReturnValue; return ReturnValue;
} }
@ -1137,9 +1120,7 @@ int CUI::DoButton_PopupMenu(CButtonContainer *pButtonContainer, const char *pTex
CUIRect Label; CUIRect Label;
pRect->VMargin(2.0f, &Label); pRect->VMargin(2.0f, &Label);
SLabelProperties Props; DoLabel(&Label, pText, 10.0f, Align);
Props.m_AlignVertically = 0;
DoLabel(&Label, pText, 10.0f, Align, Props);
return DoButtonLogic(pButtonContainer, 0, pRect); return DoButtonLogic(pButtonContainer, 0, pRect);
} }
@ -1347,7 +1328,7 @@ void CUI::DoScrollbarOption(const void *pID, int *pOption, const CUIRect *pRect,
CUIRect Label, ScrollBar; CUIRect Label, ScrollBar;
pRect->VSplitLeft(VSplitVal, &Label, &ScrollBar); pRect->VSplitLeft(VSplitVal, &Label, &ScrollBar);
DoLabel(&Label, aBuf, FontSize, TEXTALIGN_LEFT); DoLabel(&Label, aBuf, FontSize, TEXTALIGN_ML);
Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, Min, Max)), Min, Max); Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, Min, Max)), Min, Max);
if(Infinite) if(Infinite)
@ -1377,7 +1358,7 @@ void CUI::DoScrollbarOptionLabeled(const void *pID, int *pOption, const CUIRect
CUIRect Label, ScrollBar; CUIRect Label, ScrollBar;
pRect->VSplitRight(60.0f, &Label, &ScrollBar); pRect->VSplitRight(60.0f, &Label, &ScrollBar);
Label.VSplitRight(10.0f, &Label, 0); Label.VSplitRight(10.0f, &Label, 0);
DoLabel(&Label, aBuf, FontSize, TEXTALIGN_LEFT); DoLabel(&Label, aBuf, FontSize, TEXTALIGN_MC);
Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, 0, Max)), 0, Max); Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, 0, Max)), 0, Max);
@ -1563,14 +1544,14 @@ CUI::EPopupMenuFunctionResult CUI::PopupConfirm(void *pContext, CUIRect View, bo
pUI->TextRender()->Text(Label.x, Label.y, SConfirmPopupContext::POPUP_FONT_SIZE, pConfirmPopup->m_aMessage, Label.w); pUI->TextRender()->Text(Label.x, Label.y, SConfirmPopupContext::POPUP_FONT_SIZE, pConfirmPopup->m_aMessage, Label.w);
static CButtonContainer s_CancelButton; static CButtonContainer s_CancelButton;
if(pUI->DoButton_PopupMenu(&s_CancelButton, pConfirmPopup->m_aNegativeButtonLabel, &CancelButton, TEXTALIGN_CENTER)) if(pUI->DoButton_PopupMenu(&s_CancelButton, pConfirmPopup->m_aNegativeButtonLabel, &CancelButton, TEXTALIGN_MC))
{ {
pConfirmPopup->m_Result = SConfirmPopupContext::CANCELED; pConfirmPopup->m_Result = SConfirmPopupContext::CANCELED;
return CUI::POPUP_CLOSE_CURRENT; return CUI::POPUP_CLOSE_CURRENT;
} }
static CButtonContainer s_ConfirmButton; static CButtonContainer s_ConfirmButton;
if(pUI->DoButton_PopupMenu(&s_ConfirmButton, pConfirmPopup->m_aPositiveButtonLabel, &ConfirmButton, TEXTALIGN_CENTER) || (Active && pUI->ConsumeHotkey(HOTKEY_ENTER))) if(pUI->DoButton_PopupMenu(&s_ConfirmButton, pConfirmPopup->m_aPositiveButtonLabel, &ConfirmButton, TEXTALIGN_MC) || (Active && pUI->ConsumeHotkey(HOTKEY_ENTER)))
{ {
pConfirmPopup->m_Result = SConfirmPopupContext::CONFIRMED; pConfirmPopup->m_Result = SConfirmPopupContext::CONFIRMED;
return CUI::POPUP_CLOSE_CURRENT; return CUI::POPUP_CLOSE_CURRENT;
@ -1609,7 +1590,7 @@ CUI::EPopupMenuFunctionResult CUI::PopupSelection(void *pContext, CUIRect View,
{ {
View.HSplitTop(SSelectionPopupContext::POPUP_ENTRY_SPACING, nullptr, &View); View.HSplitTop(SSelectionPopupContext::POPUP_ENTRY_SPACING, nullptr, &View);
View.HSplitTop(SSelectionPopupContext::POPUP_ENTRY_HEIGHT, &Slot, &View); View.HSplitTop(SSelectionPopupContext::POPUP_ENTRY_HEIGHT, &Slot, &View);
if(pUI->DoButton_PopupMenu(&pSelectionPopup->m_vButtonContainers[Index], Entry.c_str(), &Slot, TEXTALIGN_LEFT)) if(pUI->DoButton_PopupMenu(&pSelectionPopup->m_vButtonContainers[Index], Entry.c_str(), &Slot, TEXTALIGN_ML))
pSelectionPopup->m_pSelection = &Entry; pSelectionPopup->m_pSelection = &Entry;
++Index; ++Index;
} }

View file

@ -153,7 +153,6 @@ public:
struct SLabelProperties struct SLabelProperties
{ {
float m_MaxWidth = -1; float m_MaxWidth = -1;
int m_AlignVertically = 1;
bool m_StopAtEnd = false; bool m_StopAtEnd = false;
class CTextCursor *m_pSelCursor = nullptr; class CTextCursor *m_pSelCursor = nullptr;
bool m_EnableWidthCheck = true; bool m_EnableWidthCheck = true;
@ -413,8 +412,8 @@ public:
void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {}); void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {});
void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen = -1, const CTextCursor *pReadCursor = nullptr); void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {}, int StrLen = -1, const CTextCursor *pReadCursor = nullptr);
void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, const CTextCursor *pReadCursor = nullptr); void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, bool StopAtEnd = false, int StrLen = -1, const CTextCursor *pReadCursor = nullptr);
bool DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const SUIExEditBoxProperties &Properties = {}); bool DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const SUIExEditBoxProperties &Properties = {});
bool DoClearableEditBox(const void *pID, const void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const SUIExEditBoxProperties &Properties = {}); bool DoClearableEditBox(const void *pID, const void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const SUIExEditBoxProperties &Properties = {});

View file

@ -38,9 +38,7 @@ void CListBox::DoHeader(const CUIRect *pRect, const char *pTitle, float HeaderHe
// draw header // draw header
View.HSplitTop(HeaderHeight, &Header, &View); View.HSplitTop(HeaderHeight, &Header, &View);
SLabelProperties Props; UI()->DoLabel(&Header, pTitle, Header.h * CUI::ms_FontmodHeight * 0.8f, TEXTALIGN_MC);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Header, pTitle, Header.h * CUI::ms_FontmodHeight * 0.8f, TEXTALIGN_CENTER, Props);
View.HSplitTop(Spacing, &Header, &View); View.HSplitTop(Spacing, &Header, &View);
@ -81,9 +79,7 @@ void CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, int RowsP
CUIRect Footer; CUIRect Footer;
View.HSplitBottom(m_FooterHeight, &View, &Footer); View.HSplitBottom(m_FooterHeight, &View, &Footer);
Footer.VSplitLeft(10.0f, 0, &Footer); Footer.VSplitLeft(10.0f, 0, &Footer);
SLabelProperties Props; UI()->DoLabel(&Footer, m_pBottomText, Footer.h * CUI::ms_FontmodHeight * 0.8f, TEXTALIGN_MC);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Footer, m_pBottomText, Footer.h * CUI::ms_FontmodHeight * 0.8f, TEXTALIGN_CENTER, Props);
} }
// setup the variables // setup the variables

View file

@ -395,13 +395,11 @@ int CEditor::DoButton_Editor_Common(const void *pID, const char *pText, int Chec
return UI()->DoButtonLogic(pID, Checked, pRect); return UI()->DoButtonLogic(pID, Checked, pRect);
} }
int CEditor::DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int AlignVert) int CEditor::DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
{ {
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f);
CUIRect NewRect = *pRect; CUIRect NewRect = *pRect;
SLabelProperties Props; UI()->DoLabel(&NewRect, pText, 10.0f, TEXTALIGN_MC);
Props.m_AlignVertically = AlignVert;
UI()->DoLabel(&NewRect, pText, 10.f, TEXTALIGN_CENTER, Props);
Checked %= 2; Checked %= 2;
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
@ -413,7 +411,7 @@ int CEditor::DoButton_Env(const void *pID, const char *pText, int Checked, const
ColorRGBA Color = ColorRGBA(BaseColor.r * Bright, BaseColor.g * Bright, BaseColor.b * Bright, Alpha); ColorRGBA Color = ColorRGBA(BaseColor.r * Bright, BaseColor.g * Bright, BaseColor.b * Bright, Alpha);
pRect->Draw(Color, IGraphics::CORNER_ALL, 3.0f); pRect->Draw(Color, IGraphics::CORNER_ALL, 3.0f);
UI()->DoLabel(pRect, pText, 10.f, TEXTALIGN_CENTER); UI()->DoLabel(pRect, pText, 10.0f, TEXTALIGN_MC);
Checked %= 2; Checked %= 2;
return DoButton_Editor_Common(pID, pText, Checked, pRect, 0, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, 0, pToolTip);
} }
@ -423,20 +421,19 @@ int CEditor::DoButton_File(const void *pID, const char *pText, int Checked, cons
if(Checked) if(Checked)
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f);
CUIRect t = *pRect; CUIRect Rect;
t.VMargin(5.0f, &t); pRect->VMargin(5.0f, &Rect);
UI()->DoLabel(&t, pText, 10, TEXTALIGN_LEFT); UI()->DoLabel(&Rect, pText, 10.0f, TEXTALIGN_ML);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
int CEditor::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) int CEditor::DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
{ {
CUIRect r = *pRect; pRect->Draw(ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f), IGraphics::CORNER_T, 3.0f);
r.Draw(ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f), IGraphics::CORNER_T, 3.0f);
r = *pRect; CUIRect Rect;
r.VMargin(5.0f, &r); pRect->VMargin(5.0f, &Rect);
UI()->DoLabel(&r, pText, 10, TEXTALIGN_LEFT); UI()->DoLabel(&Rect, pText, 10.0f, TEXTALIGN_ML);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
@ -445,38 +442,31 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked,
if(UI()->HotItem() == pID || Checked) if(UI()->HotItem() == pID || Checked)
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_ALL, 3.0f);
CUIRect t = *pRect; CUIRect Rect;
t.VMargin(5.0f, &t); pRect->VMargin(5.0f, &Rect);
UI()->DoLabel(&t, pText, 10, TEXTALIGN_LEFT); UI()->DoLabel(&Rect, pText, 10.0f, TEXTALIGN_ML);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
int CEditor::DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) int CEditor::DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
{ {
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_T, 5.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_T, 5.0f);
CUIRect NewRect = *pRect; UI()->DoLabel(pRect, pText, 10.0f, TEXTALIGN_MC);
UI()->DoLabel(&NewRect, pText, 10, TEXTALIGN_CENTER);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize, int AlignVert) int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize)
{ {
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
CUIRect NewRect = *pRect; UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC);
SLabelProperties Props;
Props.m_AlignVertically = AlignVert;
UI()->DoLabel(&NewRect, pText, FontSize, TEXTALIGN_CENTER, Props);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
int CEditor::DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize, int AlignVert) int CEditor::DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize)
{ {
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
CUIRect NewRect = *pRect;
SLabelProperties Props;
Props.m_AlignVertically = AlignVert;
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
UI()->DoLabel(&NewRect, pText, FontSize, TEXTALIGN_CENTER, Props); UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC);
TextRender()->SetCurFont(nullptr); TextRender()->SetCurFont(nullptr);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
@ -484,14 +474,14 @@ int CEditor::DoButton_FontIcon(const void *pID, const char *pText, int Checked,
int CEditor::DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) int CEditor::DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
{ {
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_R, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_R, 3.0f);
UI()->DoLabel(pRect, pText ? pText : "+", 10, TEXTALIGN_CENTER); UI()->DoLabel(pRect, pText ? pText : "+", 10.0f, TEXTALIGN_MC);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
int CEditor::DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) int CEditor::DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
{ {
pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_L, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), IGraphics::CORNER_L, 3.0f);
UI()->DoLabel(pRect, pText ? pText : "-", 10, TEXTALIGN_CENTER); UI()->DoLabel(pRect, pText ? pText : "-", 10.0f, TEXTALIGN_MC);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
} }
@ -501,12 +491,11 @@ int CEditor::DoButton_ColorPicker(const void *pID, const CUIRect *pRect, ColorRG
return DoButton_Editor_Common(pID, nullptr, 0, pRect, 0, pToolTip); return DoButton_Editor_Common(pID, nullptr, 0, pRect, 0, pToolTip);
} }
int CEditor::DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip, int Corners, float FontSize, int AlignVert) int CEditor::DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip, int Corners, float FontSize)
{ {
pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f); pRect->Draw(GetButtonColor(pID, Checked), Corners, 3.0f);
SLabelProperties Props;
Props.m_AlignVertically = AlignVert; UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC);
UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_CENTER, Props);
if(UI()->MouseInside(pRect)) if(UI()->MouseInside(pRect))
{ {
@ -697,7 +686,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in
else else
str_format(aBuf, sizeof(aBuf), "%d", Current); str_format(aBuf, sizeof(aBuf), "%d", Current);
pRect->Draw(pColor ? *pColor : GetButtonColor(pID, 0), Corners, 5.0f); pRect->Draw(pColor ? *pColor : GetButtonColor(pID, 0), Corners, 5.0f);
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER); UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_MC);
} }
return Current; return Current;
@ -1037,7 +1026,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(25.0f, &Button, &TB_Top); TB_Top.VSplitLeft(25.0f, &Button, &TB_Top);
static int s_ZoomNormalButton = 0; static int s_ZoomNormalButton = 0;
if(DoButton_FontIcon(&s_ZoomNormalButton, FONT_ICON_MAGNIFYING_GLASS, 0, &Button, 0, "[NumPad*] Zoom to normal and remove editor offset", 0)) if(DoButton_FontIcon(&s_ZoomNormalButton, FONT_ICON_MAGNIFYING_GLASS, 0, &Button, 0, "[NumPad*] Zoom to normal and remove editor offset", IGraphics::CORNER_NONE))
{ {
m_EditorOffsetX = 0; m_EditorOffsetX = 0;
m_EditorOffsetY = 0; m_EditorOffsetY = 0;
@ -1146,7 +1135,7 @@ void CEditor::DoToolbar(CUIRect ToolBar)
TB_Top.VSplitLeft(25.0f, &Button, &TB_Top); TB_Top.VSplitLeft(25.0f, &Button, &TB_Top);
static int s_GridNormalButton = 0; static int s_GridNormalButton = 0;
if(DoButton_FontIcon(&s_GridNormalButton, FONT_ICON_BORDER_ALL, 0, &Button, 0, "Normal grid", 0)) if(DoButton_FontIcon(&s_GridNormalButton, FONT_ICON_BORDER_ALL, 0, &Button, 0, "Normal grid", IGraphics::CORNER_NONE))
m_GridFactor = 1; m_GridFactor = 1;
TB_Top.VSplitLeft(20.0f, &Button, &TB_Top); TB_Top.VSplitLeft(20.0f, &Button, &TB_Top);
@ -3151,7 +3140,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
CUIRect Label, Shifter; CUIRect Label, Shifter;
Slot.VSplitMid(&Label, &Shifter); Slot.VSplitMid(&Label, &Shifter);
Shifter.HMargin(1.0f, &Shifter); Shifter.HMargin(1.0f, &Shifter);
UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, TEXTALIGN_ML);
if(pProps[i].m_Type == PROPTYPE_INT_STEP) if(pProps[i].m_Type == PROPTYPE_INT_STEP)
{ {
@ -3320,11 +3309,11 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
Left.VSplitLeft(10.0f, &Left, &Shifter); Left.VSplitLeft(10.0f, &Left, &Shifter);
Shifter.VSplitRight(10.0f, &Shifter, &Right); Shifter.VSplitRight(10.0f, &Shifter, &Right);
Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f); Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, "X", 10.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Shifter, "X", 10.0f, TEXTALIGN_MC);
Up.VSplitLeft(10.0f, &Up, &Shifter); Up.VSplitLeft(10.0f, &Up, &Shifter);
Shifter.VSplitRight(10.0f, &Shifter, &Down); Shifter.VSplitRight(10.0f, &Shifter, &Down);
Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f); Shifter.Draw(ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_MC);
if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left")) if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left"))
{ {
*pNewVal = DIRECTION_LEFT; *pNewVal = DIRECTION_LEFT;
@ -3555,7 +3544,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
if(s_ScrollRegion.AddRect(Slot)) if(s_ScrollRegion.AddRect(Slot))
{ {
Slot.VSplitLeft(15.0f, &VisibleToggle, &Slot); Slot.VSplitLeft(15.0f, &VisibleToggle, &Slot);
if(DoButton_FontIcon(&m_Map.m_vpGroups[g]->m_Visible, m_Map.m_vpGroups[g]->m_Visible ? FONT_ICON_EYE : FONT_ICON_EYE_SLASH, m_Map.m_vpGroups[g]->m_Collapse ? 1 : 0, &VisibleToggle, 0, "Toggle group visibility", IGraphics::CORNER_L, 8.0f, 0)) if(DoButton_FontIcon(&m_Map.m_vpGroups[g]->m_Visible, m_Map.m_vpGroups[g]->m_Visible ? FONT_ICON_EYE : FONT_ICON_EYE_SLASH, m_Map.m_vpGroups[g]->m_Collapse ? 1 : 0, &VisibleToggle, 0, "Toggle group visibility", IGraphics::CORNER_L, 8.0f))
m_Map.m_vpGroups[g]->m_Visible = !m_Map.m_vpGroups[g]->m_Visible; m_Map.m_vpGroups[g]->m_Visible = !m_Map.m_vpGroups[g]->m_Visible;
str_format(aBuf, sizeof(aBuf), "#%d %s", g, m_Map.m_vpGroups[g]->m_aName); str_format(aBuf, sizeof(aBuf), "#%d %s", g, m_Map.m_vpGroups[g]->m_aName);
@ -3679,7 +3668,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
Slot.VSplitLeft(12.0f, nullptr, &Slot); Slot.VSplitLeft(12.0f, nullptr, &Slot);
Slot.VSplitLeft(15.0f, &VisibleToggle, &Button); Slot.VSplitLeft(15.0f, &VisibleToggle, &Button);
if(DoButton_FontIcon(&m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible, m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible ? FONT_ICON_EYE : FONT_ICON_EYE_SLASH, 0, &VisibleToggle, 0, "Toggle layer visibility", IGraphics::CORNER_L, 8.0f, 0)) if(DoButton_FontIcon(&m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible, m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible ? FONT_ICON_EYE : FONT_ICON_EYE_SLASH, 0, &VisibleToggle, 0, "Toggle layer visibility", IGraphics::CORNER_L, 8.0f))
m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible = !m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible; m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible = !m_Map.m_vpGroups[g]->m_vpLayers[i]->m_Visible;
if(m_Map.m_vpGroups[g]->m_vpLayers[i]->m_aName[0]) if(m_Map.m_vpGroups[g]->m_vpLayers[i]->m_aName[0])
@ -4411,7 +4400,7 @@ void CEditor::RenderImagesList(CUIRect ToolBox)
CUIRect Slot; CUIRect Slot;
ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox); ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox);
if(s_ScrollRegion.AddRect(Slot)) if(s_ScrollRegion.AddRect(Slot))
UI()->DoLabel(&Slot, e == 0 ? "Embedded" : "External", 12.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Slot, e == 0 ? "Embedded" : "External", 12.0f, TEXTALIGN_MC);
for(int i = 0; i < (int)m_Map.m_vpImages.size(); i++) for(int i = 0; i < (int)m_Map.m_vpImages.size(); i++)
{ {
@ -4547,7 +4536,7 @@ void CEditor::RenderSounds(CUIRect ToolBox)
CUIRect Slot; CUIRect Slot;
ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox); ToolBox.HSplitTop(RowHeight + 3.0f, &Slot, &ToolBox);
if(s_ScrollRegion.AddRect(Slot)) if(s_ScrollRegion.AddRect(Slot))
UI()->DoLabel(&Slot, "Embedded", 12.0f, TEXTALIGN_CENTER); UI()->DoLabel(&Slot, "Embedded", 12.0f, TEXTALIGN_MC);
for(int i = 0; i < (int)m_Map.m_vpSounds.size(); i++) for(int i = 0; i < (int)m_Map.m_vpSounds.size(); i++)
{ {
@ -4738,7 +4727,7 @@ void CEditor::RenderFileDialog()
Title.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 4.0f); Title.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 4.0f);
Title.VMargin(10.0f, &Title); Title.VMargin(10.0f, &Title);
UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, TEXTALIGN_ML);
// pathbox // pathbox
char aPath[IO_MAX_PATH_LENGTH], aBuf[128 + IO_MAX_PATH_LENGTH]; char aPath[IO_MAX_PATH_LENGTH], aBuf[128 + IO_MAX_PATH_LENGTH];
@ -4747,7 +4736,7 @@ void CEditor::RenderFileDialog()
else else
aPath[0] = 0; aPath[0] = 0;
str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath); str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath);
UI()->DoLabel(&PathBox, aBuf, 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&PathBox, aBuf, 10.0f, TEXTALIGN_ML);
// filebox // filebox
static CListBox s_ListBox; static CListBox s_ListBox;
@ -4756,7 +4745,7 @@ void CEditor::RenderFileDialog()
if(m_FileDialogStorageType == IStorage::TYPE_SAVE) if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
{ {
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, TEXTALIGN_ML);
static float s_FileBoxID = 0; static float s_FileBoxID = 0;
if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID)) if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID))
{ {
@ -4795,7 +4784,7 @@ void CEditor::RenderFileDialog()
CUIRect ClearBox; CUIRect ClearBox;
FileBox.VSplitRight(15, &FileBox, &ClearBox); FileBox.VSplitRight(15, &FileBox, &ClearBox);
UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, TEXTALIGN_ML);
static float s_SearchBoxID = 0; static float s_SearchBoxID = 0;
bool SearchUpdated = DoEditBox(&s_SearchBoxID, &FileBox, m_aFileDialogFilterString, sizeof(m_aFileDialogFilterString), 10.0f, &s_SearchBoxID, false, IGraphics::CORNER_L); bool SearchUpdated = DoEditBox(&s_SearchBoxID, &FileBox, m_aFileDialogFilterString, sizeof(m_aFileDialogFilterString), 10.0f, &s_SearchBoxID, false, IGraphics::CORNER_L);
if(m_FileDialogOpening) if(m_FileDialogOpening)
@ -4805,7 +4794,7 @@ void CEditor::RenderFileDialog()
{ {
static int s_ClearButton = 0; static int s_ClearButton = 0;
ClearBox.Draw(ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(&s_ClearButton)), IGraphics::CORNER_R, 3.0f); ClearBox.Draw(ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(&s_ClearButton)), IGraphics::CORNER_R, 3.0f);
UI()->DoLabel(&ClearBox, "×", 10.0f, TEXTALIGN_CENTER); UI()->DoLabel(&ClearBox, "×", 10.0f, TEXTALIGN_MC);
if(UI()->DoButtonLogic(&s_ClearButton, 0, &ClearBox)) if(UI()->DoButtonLogic(&s_ClearButton, 0, &ClearBox))
{ {
SearchUpdated = true; SearchUpdated = true;
@ -4939,17 +4928,15 @@ void CEditor::RenderFileDialog()
} }
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT)); TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&FileIcon, pIconType, 12.0f, TEXTALIGN_ML);
TextRender()->SetCurFont(nullptr); TextRender()->SetCurFont(nullptr);
char aBufTimeModified[64]; char aBufTimeModified[64];
str_timestamp_ex(m_vpFilteredFileList[i]->m_TimeModified, aBufTimeModified, sizeof(aBufTimeModified), "%d.%m.%Y %H:%M"); str_timestamp_ex(m_vpFilteredFileList[i]->m_TimeModified, aBufTimeModified, sizeof(aBufTimeModified), "%d.%m.%Y %H:%M");
SLabelProperties Props; UI()->DoLabel(&Button, m_vpFilteredFileList[i]->m_aName, 10.0f, TEXTALIGN_ML);
Props.m_AlignVertically = 0;
UI()->DoLabel(&Button, m_vpFilteredFileList[i]->m_aName, 10.0f, TEXTALIGN_LEFT, Props);
if(!m_vpFilteredFileList[i]->m_IsLink && str_comp(m_vpFilteredFileList[i]->m_aFilename, "..") != 0) if(!m_vpFilteredFileList[i]->m_IsLink && str_comp(m_vpFilteredFileList[i]->m_aFilename, "..") != 0)
UI()->DoLabel(&TimeModified, aBufTimeModified, 10.0f, TEXTALIGN_RIGHT, Props); UI()->DoLabel(&TimeModified, aBufTimeModified, 10.0f, TEXTALIGN_MR);
} }
const int NewSelection = s_ListBox.DoEnd(); const int NewSelection = s_ListBox.DoEnd();
@ -5280,7 +5267,7 @@ void CEditor::RenderStatusbar(CUIRect View)
float FontSize = ScaleFontSize(aBuf, sizeof(aBuf), 10.0f, View.w); float FontSize = ScaleFontSize(aBuf, sizeof(aBuf), 10.0f, View.w);
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = View.w; Props.m_MaxWidth = View.w;
UI()->DoLabel(&View, aBuf, FontSize, TEXTALIGN_LEFT, Props); UI()->DoLabel(&View, aBuf, FontSize, TEXTALIGN_ML, Props);
} }
} }
@ -5486,7 +5473,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
{ {
ToolBar.VSplitLeft(15.0f, nullptr, &ToolBar); ToolBar.VSplitLeft(15.0f, nullptr, &ToolBar);
ToolBar.VSplitLeft(40.0f, &Button, &ToolBar); ToolBar.VSplitLeft(40.0f, &Button, &ToolBar);
UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_MR);
ToolBar.VSplitLeft(3.0f, nullptr, &ToolBar); ToolBar.VSplitLeft(3.0f, nullptr, &ToolBar);
ToolBar.VSplitLeft(ToolBar.w > ToolBar.h * 40 ? 80.0f : 60.0f, &Button, &ToolBar); ToolBar.VSplitLeft(ToolBar.w > ToolBar.h * 40 ? 80.0f : 60.0f, &Button, &ToolBar);
@ -5558,7 +5545,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
ToolBar.VSplitLeft(4.0f, nullptr, &ToolBar); ToolBar.VSplitLeft(4.0f, nullptr, &ToolBar);
ToolBar.VSplitLeft(40.0f, &Button, &ToolBar); ToolBar.VSplitLeft(40.0f, &Button, &ToolBar);
UI()->DoLabel(&Button, "Sync.", 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, "Sync.", 10.0f, TEXTALIGN_ML);
float EndTime = pEnvelope->EndTime(); float EndTime = pEnvelope->EndTime();
if(EndTime < 1) if(EndTime < 1)
@ -5864,8 +5851,8 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
Label1.VSplitRight(3.0f, &Label1, nullptr); Label1.VSplitRight(3.0f, &Label1, nullptr);
Label2.VSplitRight(3.0f, &Label2, nullptr); Label2.VSplitRight(3.0f, &Label2, nullptr);
UI()->DoLabel(&Label1, "Value:", 10.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Label1, "Value:", 10.0f, TEXTALIGN_MR);
UI()->DoLabel(&Label2, "Time (in s):", 10.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Label2, "Time (in s):", 10.0f, TEXTALIGN_MR);
} }
static float s_ValNumber = 0; static float s_ValNumber = 0;
@ -5890,7 +5877,7 @@ void CEditor::RenderServerSettingsEditor(CUIRect View, bool ShowServerSettingsEd
// command line // command line
ToolBar.VSplitLeft(5.0f, nullptr, &Button); ToolBar.VSplitLeft(5.0f, nullptr, &Button);
UI()->DoLabel(&Button, "Command:", 12.0f, TEXTALIGN_LEFT); UI()->DoLabel(&Button, "Command:", 12.0f, TEXTALIGN_ML);
Button.VSplitLeft(70.0f, nullptr, &Button); Button.VSplitLeft(70.0f, nullptr, &Button);
Button.VSplitLeft(180.0f, &Button, nullptr); Button.VSplitLeft(180.0f, &Button, nullptr);
@ -6054,16 +6041,16 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
MenuBar.VSplitLeft(MenuBar.w * 0.75f, &MenuBar, &Info); MenuBar.VSplitLeft(MenuBar.w * 0.75f, &MenuBar, &Info);
char aBuf[128]; char aBuf[128];
str_format(aBuf, sizeof(aBuf), "File: %s", m_aFileName); str_format(aBuf, sizeof(aBuf), "File: %s", m_aFileName);
UI()->DoLabel(&MenuBar, aBuf, 10.0f, TEXTALIGN_LEFT); UI()->DoLabel(&MenuBar, aBuf, 10.0f, TEXTALIGN_ML);
char aTimeStr[6]; char aTimeStr[6];
str_timestamp_format(aTimeStr, sizeof(aTimeStr), "%H:%M"); str_timestamp_format(aTimeStr, sizeof(aTimeStr), "%H:%M");
str_format(aBuf, sizeof(aBuf), "X: %i, Y: %i, Z: %.1f, A: %.1f, G: %i %s", (int)UI()->MouseWorldX() / 32, (int)UI()->MouseWorldY() / 32, m_Zoom, m_AnimateSpeed, m_GridFactor, aTimeStr); str_format(aBuf, sizeof(aBuf), "X: %i, Y: %i, Z: %.1f, A: %.1f, G: %i %s", (int)UI()->MouseWorldX() / 32, (int)UI()->MouseWorldY() / 32, m_Zoom, m_AnimateSpeed, m_GridFactor, aTimeStr);
UI()->DoLabel(&Info, aBuf, 10.0f, TEXTALIGN_RIGHT); UI()->DoLabel(&Info, aBuf, 10.0f, TEXTALIGN_MR);
static int s_CloseButton = 0; static int s_CloseButton = 0;
if(DoButton_Editor(&s_CloseButton, "×", 0, &Close, 0, "Exits from the editor", 0) || (m_Dialog == DIALOG_NONE && !UI()->IsPopupOpen() && !m_PopupEventActivated && Input()->KeyPress(KEY_ESCAPE))) if(DoButton_Editor(&s_CloseButton, "×", 0, &Close, 0, "Exits from the editor") || (m_Dialog == DIALOG_NONE && !UI()->IsPopupOpen() && !m_PopupEventActivated && Input()->KeyPress(KEY_ESCAPE)))
g_Config.m_ClEditor = 0; g_Config.m_ClEditor = 0;
} }

View file

@ -1154,12 +1154,12 @@ public:
void UpdateTooltip(const void *pID, const CUIRect *pRect, const char *pToolTip); void UpdateTooltip(const void *pID, const CUIRect *pRect, const char *pToolTip);
int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip); int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int AlignVert = 1); int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color); int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color);
int DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip); int DoButton_Tab(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f, int AlignVert = 1); int DoButton_Ex(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f);
int DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f, int AlignVert = 1); int DoButton_FontIcon(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int Corners, float FontSize = 10.0f);
int DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip); int DoButton_ButtonDec(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
int DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip); int DoButton_ButtonInc(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
@ -1170,7 +1170,7 @@ public:
int DoButton_ColorPicker(const void *pID, const CUIRect *pRect, ColorRGBA *pColor, const char *pToolTip = nullptr); int DoButton_ColorPicker(const void *pID, const CUIRect *pRect, ColorRGBA *pColor, const char *pToolTip = nullptr);
int DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip = nullptr, int Corners = IGraphics::CORNER_ALL, float FontSize = 10.0f, int AlignVert = 1); int DoButton_DraggableEx(const void *pID, const char *pText, int Checked, const CUIRect *pRect, bool *pClicked, bool *pAbrupted, int Flags, const char *pToolTip = nullptr, int Corners = IGraphics::CORNER_ALL, float FontSize = 10.0f);
bool DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr); bool DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr);
bool DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr); bool DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr);

View file

@ -1021,7 +1021,7 @@ CUI::EPopupMenuFunctionResult CLayerTiles::RenderCommonProperties(SCommonPropSta
pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f)); pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Warning.w; Props.m_MaxWidth = Warning.w;
pEditor->UI()->DoLabel(&Warning, "Editing multiple layers", 9.0f, TEXTALIGN_LEFT, Props); pEditor->UI()->DoLabel(&Warning, "Editing multiple layers", 9.0f, TEXTALIGN_ML, Props);
pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f)); pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
pToolbox->HSplitTop(2.0f, nullptr, pToolbox); pToolbox->HSplitTop(2.0f, nullptr, pToolbox);
} }

View file

@ -369,7 +369,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupGroup(void *pContext, CUIRect View,
{ {
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Button); View.HSplitBottom(12.0f, &View, &Button);
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_ML);
Button.VSplitLeft(40.0f, nullptr, &Button); Button.VSplitLeft(40.0f, nullptr, &Button);
static float s_Name = 0; static float s_Name = 0;
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_aName, sizeof(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_aName), 10.0f, &s_Name)) if(pEditor->DoEditBox(&s_Name, &Button, pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_aName, sizeof(pEditor->m_Map.m_vpGroups[pEditor->m_SelectedGroup]->m_aName), 10.0f, &s_Name))
@ -540,7 +540,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupLayer(void *pContext, CUIRect View,
View.HSplitBottom(5.0f, &View, nullptr); View.HSplitBottom(5.0f, &View, nullptr);
View.HSplitBottom(12.0f, &View, &Label); View.HSplitBottom(12.0f, &View, &Label);
Label.VSplitLeft(40.0f, &Label, &EditBox); Label.VSplitLeft(40.0f, &Label, &EditBox);
pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, TEXTALIGN_ML);
static float s_Name = 0; static float s_Name = 0;
if(pEditor->DoEditBox(&s_Name, &EditBox, pCurrentLayer->m_aName, sizeof(pCurrentLayer->m_aName), 10.0f, &s_Name)) if(pEditor->DoEditBox(&s_Name, &EditBox, pCurrentLayer->m_aName, sizeof(pCurrentLayer->m_aName), 10.0f, &s_Name))
pEditor->m_Map.m_Modified = true; pEditor->m_Map.m_Modified = true;
@ -1311,12 +1311,12 @@ CUI::EPopupMenuFunctionResult CEditor::PopupNewFolder(void *pContext, CUIRect Vi
// title // title
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, TEXTALIGN_CENTER); pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, TEXTALIGN_MC);
View.HSplitTop(10.0f, nullptr, &View); View.HSplitTop(10.0f, nullptr, &View);
// folder name // folder name
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, TEXTALIGN_ML);
Label.VSplitLeft(50.0f, nullptr, &Button); Label.VSplitLeft(50.0f, nullptr, &Button);
Button.HMargin(2.0f, &Button); Button.HMargin(2.0f, &Button);
static float s_FolderBox = 0; static float s_FolderBox = 0;
@ -1363,12 +1363,12 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMapInfo(void *pContext, CUIRect View
// title // title
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, TEXTALIGN_CENTER); pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, TEXTALIGN_MC);
View.HSplitTop(10.0f, nullptr, &View); View.HSplitTop(10.0f, nullptr, &View);
// author box // author box
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, TEXTALIGN_ML);
Label.VSplitLeft(60.0f, nullptr, &Button); Label.VSplitLeft(60.0f, nullptr, &Button);
Button.HMargin(3.0f, &Button); Button.HMargin(3.0f, &Button);
static float s_AuthorBox = 0; static float s_AuthorBox = 0;
@ -1376,7 +1376,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMapInfo(void *pContext, CUIRect View
// version box // version box
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, TEXTALIGN_ML);
Label.VSplitLeft(60.0f, nullptr, &Button); Label.VSplitLeft(60.0f, nullptr, &Button);
Button.HMargin(3.0f, &Button); Button.HMargin(3.0f, &Button);
static float s_VersionBox = 0; static float s_VersionBox = 0;
@ -1384,7 +1384,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMapInfo(void *pContext, CUIRect View
// credits box // credits box
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, TEXTALIGN_ML);
Label.VSplitLeft(60.0f, nullptr, &Button); Label.VSplitLeft(60.0f, nullptr, &Button);
Button.HMargin(3.0f, &Button); Button.HMargin(3.0f, &Button);
static float s_CreditsBox = 0; static float s_CreditsBox = 0;
@ -1392,7 +1392,7 @@ CUI::EPopupMenuFunctionResult CEditor::PopupMapInfo(void *pContext, CUIRect View
// license box // license box
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "License:", 10.0f, TEXTALIGN_LEFT); pEditor->UI()->DoLabel(&Label, "License:", 10.0f, TEXTALIGN_ML);
Label.VSplitLeft(60.0f, nullptr, &Button); Label.VSplitLeft(60.0f, nullptr, &Button);
Button.HMargin(3.0f, &Button); Button.HMargin(3.0f, &Button);
static float s_LicenseBox = 0; static float s_LicenseBox = 0;
@ -1482,14 +1482,12 @@ CUI::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View,
// title // title
View.HSplitTop(20.0f, &Label, &View); View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, pTitle, 20.0f, TEXTALIGN_CENTER); pEditor->UI()->DoLabel(&Label, pTitle, 20.0f, TEXTALIGN_MC);
View.HSplitTop(10.0f, nullptr, &View);
// message // message
View.HSplitTop(20.0f, &Label, &View);
SLabelProperties Props; SLabelProperties Props;
Props.m_MaxWidth = Label.w; Props.m_MaxWidth = View.w;
pEditor->UI()->DoLabel(&Label, pMessage, 10.0f, TEXTALIGN_LEFT, Props); pEditor->UI()->DoLabel(&View, pMessage, 10.0f, TEXTALIGN_ML, Props);
// button bar // button bar
ButtonBar.VSplitLeft(110.0f, &Button, &ButtonBar); ButtonBar.VSplitLeft(110.0f, &Button, &ButtonBar);