From 89a453329556e635405c08425d79c4b57bf3125c Mon Sep 17 00:00:00 2001 From: Robert Müller Date: Mon, 7 Jun 2021 14:09:28 +0200 Subject: use textrender alignment constants, support vertical alignment in CUI, fix editor buttons --- src/game/client/components/hud.cpp | 4 +- src/game/client/components/menus.cpp | 52 +++++++-------- src/game/client/components/menus.h | 4 +- src/game/client/components/menus_browser.cpp | 78 +++++++++++----------- src/game/client/components/menus_callback.cpp | 12 ++-- src/game/client/components/menus_demo.cpp | 16 ++--- src/game/client/components/menus_ingame.cpp | 60 ++++++++--------- src/game/client/components/menus_listbox.cpp | 6 +- src/game/client/components/menus_settings.cpp | 60 ++++++++--------- src/game/client/components/menus_start.cpp | 4 +- src/game/client/ui.cpp | 40 ++++++------ src/game/client/ui.h | 11 +--- src/game/editor/editor.cpp | 94 ++++++++++----------------- src/game/editor/popups.cpp | 44 ++++++------- 14 files changed, 226 insertions(+), 259 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index fe45c20d8..437dd0c79 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -612,10 +612,10 @@ void CHud::RenderVoting() m_pClient->m_pBinds->GetKey("vote no", aBufNo, sizeof(aBufNo)); str_format(aBuf, sizeof(aBuf), "%s - %s", aBufYes, Localize("Vote yes")); Base.y += Base.h+1; - UI()->DoLabel(&Base, aBuf, 6.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_LEFT); str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), aBufNo); - UI()->DoLabel(&Base, aBuf, 6.0f, CUI::ALIGN_RIGHT); + UI()->DoLabel(&Base, aBuf, 6.0f, TEXTALIGN_RIGHT); } void CHud::RenderCursor() diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 5490455ed..4765981ca 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -184,7 +184,7 @@ bool CMenus::DoButton_Menu(CButtonContainer *pBC, const char *pText, bool Checke TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f); TextRender()->TextSecondaryColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f); } - UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, CUI::ALIGN_CENTER); + UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, TEXTALIGN_CENTER); if(TextFade) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -203,7 +203,7 @@ void CMenus::DoButton_KeySelect(CButtonContainer *pBC, const char *pText, const pRect->HMargin(1.0f, &Label); TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f); TextRender()->TextSecondaryColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f); - UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight, TEXTALIGN_CENTER); TextRender()->TextColor(CUI::ms_DefaultTextColor); TextRender()->TextSecondaryColor(CUI::ms_DefaultTextOutlineColor); } @@ -220,13 +220,13 @@ bool CMenus::DoButton_MenuTabTop(CButtonContainer *pBC, const char *pText, bool Label.HMargin((Label.h*FontFactor)/2.0f, &Label); TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, FontAlpha); TextRender()->TextSecondaryColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f*FontAlpha); - UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight, TEXTALIGN_CENTER); TextRender()->TextColor(CUI::ms_DefaultTextColor); TextRender()->TextSecondaryColor(CUI::ms_DefaultTextOutlineColor); return UI()->DoButtonLogic(pBC, pRect); } -bool CMenus::DoButton_GridHeader(const void *pID, const char *pText, bool Checked, CUI::EAlignment Align, const CUIRect *pRect, int Corners) +bool CMenus::DoButton_GridHeader(const void *pID, const char *pText, bool Checked, int Align, const CUIRect *pRect, int Corners) { if(Checked) { @@ -285,7 +285,7 @@ bool CMenus::DoButton_CheckBox(const void *pID, const char *pText, bool Checked, Graphics()->QuadsEnd(); Label.y += 1.0f; // lame fix - UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, pText, Label.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); if(Locked) { @@ -355,7 +355,7 @@ float CMenus::DoIndependentDropdownMenu(void *pID, const CUIRect *pRect, const c // label Label = Header; Label.y += 2.0f; - UI()->DoLabel(&Label, pStr, Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pStr, Header.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); if(UI()->DoButtonLogic(pID, &Header)) *pActive ^= 1; @@ -379,10 +379,10 @@ void CMenus::DoInfoBox(const CUIRect *pRect, const char *pLabel, const char *pVa char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%s:", pLabel); Label.y += 2.0f; - UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Value.y += 2.0f; - UI()->DoLabel(&Value, pValue, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Value, pValue, pRect->h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); } void CMenus::DoJoystickBar(const CUIRect *pRect, float Current, float Tolerance, bool Active) @@ -701,7 +701,7 @@ void CMenus::RenderMenubar(CUIRect Rect) Box.HMargin(2.0f, &Box); TextRender()->TextColor(CUI::ms_HighlightTextColor); TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); - UI()->DoLabel(&Box, Localize("Demos"), Box.h*ms_FontmodHeight, CUI::ALIGN_CENTER); + UI()->DoLabel(&Box, Localize("Demos"), Box.h*ms_FontmodHeight, TEXTALIGN_CENTER); TextRender()->TextColor(CUI::ms_DefaultTextColor); TextRender()->TextSecondaryColor(CUI::ms_DefaultTextOutlineColor); } @@ -765,7 +765,7 @@ void CMenus::RenderLoading(int WorkedAmount) Rect.y += 20; TextRender()->TextColor(CUI::ms_DefaultTextColor); TextRender()->TextSecondaryColor(CUI::ms_DefaultTextOutlineColor); - UI()->DoLabel(&Rect, "Teeworlds", 48.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Rect, "Teeworlds", 48.0f, TEXTALIGN_CENTER); const float Percent = m_LoadCurrent/(float)m_LoadTotal; const float Spacing = 40.0f; @@ -785,7 +785,7 @@ void CMenus::RenderLoading(int WorkedAmount) } char aBuf[8]; str_format(aBuf, sizeof(aBuf), "%d%%", (int)(100*Percent)); - UI()->DoLabel(&FullBar, aBuf, 20.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&FullBar, aBuf, 20.0f, TEXTALIGN_CENTER); if(Percent > 0.5f) { @@ -1110,7 +1110,7 @@ void CMenus::RenderMenu(CUIRect Screen) Button.Draw(Color, 5.0f, CUIRect::CORNER_BL); // draw non-blending X - UI()->DoLabel(&Button, "\xE2\x9C\x95", Button.h*ms_FontmodHeight, CUI::ALIGN_CENTER); + UI()->DoLabel(&Button, "\xE2\x9C\x95", Button.h*ms_FontmodHeight, TEXTALIGN_CENTER); if(UI()->DoButtonLogic(&s_QuitButton, &Button)) m_Popup = POPUP_QUIT; @@ -1254,7 +1254,7 @@ void CMenus::RenderMenu(CUIRect Screen) CUIRect Part; Box.HSplitTop(ButtonHeight+5.0f, &Part, &Box); Part.y += 3.0f; - UI()->DoLabel(&Part, pTitle, Part.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Part, pTitle, Part.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // inner box CUIRect BottomBar; @@ -1269,15 +1269,15 @@ void CMenus::RenderMenu(CUIRect Screen) if(m_pClient->Editor()->HasUnsavedData()) { Box.HSplitTop(12.0f, 0, &Part); - UI()->DoLabel(&Part, pExtraText, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_CENTER); Part.HSplitTop(20.0f, 0, &Part); Part.VMargin(5.0f, &Part); - UI()->DoLabel(&Part, Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), FontSize, CUI::ALIGN_LEFT, Part.w); + UI()->DoLabel(&Part, Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), FontSize, TEXTALIGN_LEFT, Part.w); } else { Box.HSplitTop(27.0f, 0, &Box); - UI()->DoLabel(&Box, pExtraText, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Box, pExtraText, FontSize, TEXTALIGN_CENTER); } // buttons @@ -1298,7 +1298,7 @@ void CMenus::RenderMenu(CUIRect Screen) CUIRect Label; Box.HSplitTop(20.0f, &Label, &Box); - UI()->DoLabel(&Label, pExtraText, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pExtraText, FontSize, TEXTALIGN_CENTER); CUIRect EditBox; Box.HSplitTop(20.0f, &EditBox, &Box); @@ -1371,7 +1371,7 @@ void CMenus::RenderMenu(CUIRect Screen) Box.HSplitTop(15.f, 0, &Box); Box.HSplitTop(ButtonHeight, &Part, &Box); 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, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Part, aBuf, FontSize, TEXTALIGN_CENTER); // time left int SecondsLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast((Client()->MapDownloadTotalsize()-Client()->MapDownloadAmount())/m_DownloadSpeed) : 1); @@ -1386,7 +1386,7 @@ void CMenus::RenderMenu(CUIRect Screen) } Box.HSplitTop(SpacingH, 0, &Box); Box.HSplitTop(ButtonHeight, &Part, &Box); - UI()->DoLabel(&Part, aBuf, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Part, aBuf, FontSize, TEXTALIGN_CENTER); // progress bar Box.HSplitTop(SpacingH, 0, &Box); @@ -1399,7 +1399,7 @@ void CMenus::RenderMenu(CUIRect Screen) else { Box.HSplitTop(27.0f, 0, &Box); - UI()->DoLabel(&Box, Client()->ServerAddress(), FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Box, Client()->ServerAddress(), FontSize, TEXTALIGN_CENTER); } } else if(m_Popup == POPUP_LOADING_DEMO) @@ -1416,7 +1416,7 @@ void CMenus::RenderMenu(CUIRect Screen) else { Box.HSplitTop(27.0f, 0, &Box); - UI()->DoLabel(&Box, m_aDemoLoadingFile, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Box, m_aDemoLoadingFile, FontSize, TEXTALIGN_CENTER); // wait until next frame to load the demo m_DemoLoadingPopupRendered = true; } @@ -1466,7 +1466,7 @@ void CMenus::RenderMenu(CUIRect Screen) TextRender()->TextColor(CUI::ms_HighlightTextColor); TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } - UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, TEXTALIGN_CENTER); if(i == OldSelected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -1500,7 +1500,7 @@ void CMenus::RenderMenu(CUIRect Screen) { Box.HSplitTop(27.0f, 0, &Box); Box.VMargin(10.0f, &Box); - UI()->DoLabel(&Box, pExtraText, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Box, pExtraText, FontSize, TEXTALIGN_LEFT); CUIRect EditBox; Box.HSplitBottom(Box.h/2.0f, 0, &Box); @@ -1549,7 +1549,7 @@ void CMenus::RenderMenu(CUIRect Screen) { Box.HSplitTop(24.0f, 0, &Box); Box.VMargin(10.0f, &Part); - UI()->DoLabel(&Part, pExtraText, FontSize, CUI::ALIGN_LEFT, Box.w-20.0f); + UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Box.w-20.0f); CUIRect EditBox; Box.HSplitBottom(Box.h/2.0f, 0, &Box); @@ -1581,7 +1581,7 @@ void CMenus::RenderMenu(CUIRect Screen) { Box.HSplitTop(20.0f, 0, &Box); Box.VMargin(10.0f, &Part); - UI()->DoLabel(&Part, pExtraText, FontSize, CUI::ALIGN_LEFT, Box.w-20.0f); + UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Box.w-20.0f); CUIRect EditBox; Box.HSplitBottom(ButtonHeight*2.0f, 0, &Box); @@ -1605,7 +1605,7 @@ void CMenus::RenderMenu(CUIRect Screen) // message Box.HSplitTop(27.0f, 0, &Box); Box.VMargin(5.0f, &Part); - UI()->DoLabel(&Part, pExtraText, FontSize, CUI::ALIGN_LEFT, Part.w); + UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Part.w); if(m_Popup == POPUP_MESSAGE) { diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 3a82bec73..c40091acb 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -69,7 +69,7 @@ private: bool DoButton_CheckBox(const void *pID, const char *pText, bool Checked, const CUIRect *pRect, bool Locked = false); void DoIcon(int ImageId, int SpriteId, const CUIRect *pRect, const vec4 *pColor = 0); - bool DoButton_GridHeader(const void *pID, const char *pText, bool Checked, CUI::EAlignment Align, const CUIRect *pRect, int Corners = CUIRect::CORNER_ALL); + bool DoButton_GridHeader(const void *pID, const char *pText, bool Checked, int Align, const CUIRect *pRect, int Corners = CUIRect::CORNER_ALL); float DoIndependentDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr, float HeaderHeight, FDropdownCallback pfnCallback, bool *pActive); void DoInfoBox(const CUIRect *pRect, const char *pLable, const char *pValue); @@ -592,7 +592,7 @@ private: int m_Flags; CUIRect m_Rect; CUIRect m_Spacer; - CUI::EAlignment m_Align; + int m_Align; }; enum diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 8231ef856..dc3034339 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -25,12 +25,12 @@ #include "menus.h" CMenus::CColumn CMenus::ms_aBrowserCols[] = { // Localize("Server"); Localize("Type"); Localize("Map"); Localize("Players"); Localize("Ping"); - these strings are localized within CLocConstString - {COL_BROWSER_FLAG, -1, " ", -1, 4*16.0f+3*2.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_BROWSER_NAME, IServerBrowser::SORT_NAME, "Server", 0, 310.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_BROWSER_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 70.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_BROWSER_MAP, IServerBrowser::SORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_BROWSER_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 50.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_BROWSER_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, + {COL_BROWSER_FLAG, -1, " ", -1, 4*16.0f+3*2.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_BROWSER_NAME, IServerBrowser::SORT_NAME, "Server", 0, 310.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_BROWSER_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 70.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_BROWSER_MAP, IServerBrowser::SORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_BROWSER_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 50.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_BROWSER_PING, IServerBrowser::SORT_PING, "Ping", 1, 40.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, }; CServerFilterInfo CMenus::CBrowserFilter::ms_FilterStandard = {IServerBrowser::FILTER_COMPAT_VERSION|IServerBrowser::FILTER_PURE|IServerBrowser::FILTER_PURE_MAP, 999, -1, 0, {{0}}, {0}}; @@ -565,7 +565,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn Button.x += s_RenderOffset; if(!Num) TextRender()->TextColor(CUI::ms_TransparentTextColor); - UI()->DoLabel(&Button, aTemp, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, aTemp, FontSize, TEXTALIGN_LEFT); Button.x += TextRender()->TextWidth(FontSize, aTemp, -1); } else if(ID == COL_BROWSER_PING) @@ -604,7 +604,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect View, const CServerInfo *pEn TextRender()->TextSecondaryColor(TextBaseOutlineColor); Button.y += (Button.h - FontSize/ms_FontmodHeight)/2.0f; Button.w -= 4.0f; - UI()->DoLabel(&Button, aTemp, FontSize, CUI::ALIGN_RIGHT); + UI()->DoLabel(&Button, aTemp, FontSize, TEXTALIGN_RIGHT); } else if(ID == COL_BROWSER_GAMETYPE) { @@ -668,12 +668,12 @@ void CMenus::RenderFilterHeader(CUIRect View, int FilterIndex) View.VSplitLeft(20.0f, 0, &View); // little space View.y += 2.0f; - UI()->DoLabel(&View, pFilter->Name(), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&View, pFilter->Name(), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); View.VSplitRight(20.0f, &View, 0); // little space char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("%d servers, %d players"), pFilter->NumSortedServers(), pFilter->NumPlayers()); - UI()->DoLabel(&View, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_RIGHT); + UI()->DoLabel(&View, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_RIGHT); EditButtons.VSplitRight(ButtonHeight, &EditButtons, &Button); Button.Margin(2.0f, &Button); @@ -1116,7 +1116,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) if(pImportantMessage) { MsgBox.y += MsgBox.h/3.0f; - UI()->DoLabel(&MsgBox, pImportantMessage, 16.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&MsgBox, pImportantMessage, 16.0f, TEXTALIGN_CENTER); } } } @@ -1138,7 +1138,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) Label.VSplitLeft(2.0f, 0, &Label); Label.VSplitRight(ButtonWidth*2.0f+SpacingH, &Label, &EditBox); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Search:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("Search:"), FontSize, TEXTALIGN_LEFT); EditBox.VSplitRight(EditBox.h, &EditBox, &Button); static CLineInput s_FilterInput(Config()->m_BrFilterString, sizeof(Config()->m_BrFilterString)); if(UI()->DoEditBox(&s_FilterInput, &EditBox, FontSize, false, CUIRect::CORNER_L)) @@ -1163,7 +1163,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) Label.VSplitLeft(2.0f, 0, &Label); Label.VSplitRight(ButtonWidth*2.0f+SpacingH, &Label, &EditBox); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Host address:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("Host address:"), FontSize, TEXTALIGN_LEFT); if(BrowserType == IServerBrowser::TYPE_INTERNET) { @@ -1189,7 +1189,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) Status.HSplitTop(ButtonHeight + SpacingH, 0, &Status); str_format(aBuf, sizeof(aBuf), Localize("%d%% loaded"), ServerBrowser()->LoadingProgression()); Status.y += 2.0f; - UI()->DoLabel(&Status, aBuf, 14.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Status, aBuf, 14.0f, TEXTALIGN_CENTER); } else { @@ -1221,14 +1221,14 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) str_format(aBuf, sizeof(aBuf), Localize("%d servers"), ServerBrowser()->NumServers()); Label.y += 2.0f; Label.x += OffsetServer; - UI()->DoLabel(&Label, aBuf, 14.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); Status.HSplitTop(SpacingH, 0, &Status); Status.HSplitTop(ButtonHeight, &Label, 0); str_format(aBuf, sizeof(aBuf), Localize("%d players"), NumPlayers); Label.y += 2.0f; Label.x += OffsetPlayer; - UI()->DoLabel(&Label, aBuf, 14.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, 14.0f, TEXTALIGN_LEFT); } } @@ -1395,11 +1395,11 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) // name Rect.HSplitTop(10.0f, &Button, &Rect); Button.VSplitLeft(2.0f, 0, &Button); - UI()->DoLabel(&Button, m_lFriendList[i][f].m_aName, FontSize - 2, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, m_lFriendList[i][f].m_aName, FontSize - 2, TEXTALIGN_LEFT); // clan Rect.HSplitTop(10.0f, &Button, &Rect); Button.VSplitLeft(2.0f, 0, &Button); - UI()->DoLabel(&Button, m_lFriendList[i][f].m_aClan, FontSize - 2, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, m_lFriendList[i][f].m_aClan, FontSize - 2, TEXTALIGN_LEFT); // info if(m_lFriendList[i][f].m_pServerInfo) { @@ -1410,7 +1410,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) else str_format(aBuf, sizeof(aBuf), Localize("Watching '%s' on '%s'", "Watching '(gametype)' on '(map)'"), m_lFriendList[i][f].m_pServerInfo->m_aGameType, m_lFriendList[i][f].m_pServerInfo->m_aMap); Button.HMargin(2.0f, &Button); - UI()->DoLabel(&Button, aBuf, FontSize - 2, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, aBuf, FontSize - 2, TEXTALIGN_LEFT); } // delete button Icon.HSplitTop(14.0f, &Rect, 0); @@ -1454,7 +1454,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) case 2: str_format(aBuf, sizeof(aBuf), Localize("Offline (%d)", "friends (server browser)"), ListSize); break; } Label.HMargin(2.0f, &Label); - UI()->DoLabel(&Label, aBuf, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, FontSize, TEXTALIGN_LEFT); static int s_HeaderButton[NUM_FRIEND_TYPES] = { 0 }; if(UI()->DoButtonLogic(&s_HeaderButton[i], &Header)) { @@ -1467,7 +1467,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) BottomArea.HSplitTop(HeaderHeight, &Button, &BottomArea); BottomArea.HSplitTop(SpacingH, 0, &BottomArea); Button.VSplitLeft(50.0f, &Label, &Button); - UI()->DoLabel(&Label, Localize("Name"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("Name"), FontSize, TEXTALIGN_LEFT); static char s_aName[MAX_NAME_ARRAY_SIZE] = { 0 }; static CLineInput s_NameInput(s_aName, sizeof(s_aName), MAX_NAME_LENGTH); UI()->DoEditBox(&s_NameInput, &Button, Button.h*ms_FontmodHeight*0.8f); @@ -1475,7 +1475,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) BottomArea.HSplitTop(HeaderHeight, &Button, &BottomArea); BottomArea.HSplitTop(SpacingH, 0, &BottomArea); Button.VSplitLeft(50.0f, &Label, &Button); - UI()->DoLabel(&Label, Localize("Clan"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("Clan"), FontSize, TEXTALIGN_LEFT); static char s_aClan[MAX_CLAN_ARRAY_SIZE] = { 0 }; static CLineInput s_ClanInput(s_aClan, sizeof(s_aClan), MAX_CLAN_LENGTH); UI()->DoEditBox(&s_ClanInput, &Button, Button.h*ms_FontmodHeight*0.8f); @@ -1488,7 +1488,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) Label = Button; Label.HMargin(2.0f, &Label); const char *pButtonText = (!s_aName[0] && !s_aClan[0]) ? Localize("Add friend/clan") : s_aName[0] ? Localize("Add friend") : Localize("Add clan"); - UI()->DoLabel(&Label, pButtonText, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, pButtonText, FontSize, TEXTALIGN_CENTER); if(s_aName[0] || s_aClan[0]) DoIcon(IMAGE_FRIENDICONS, UI()->MouseHovered(&Button) ? SPRITE_FRIEND_PLUS_A : SPRITE_FRIEND_PLUS_B, &Icon); static CButtonContainer s_AddFriend; @@ -1536,7 +1536,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) Button.Draw(vec4(1.0f, 1.0f, 1.0f, 0.25f), 5.0f, CUIRect::CORNER_R); Button.VSplitLeft(Button.h, &Icon, &Label); Label.HMargin(2.0f, &Label); - UI()->DoLabel(&Label, Localize("New filter"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("New filter"), FontSize, TEXTALIGN_LEFT); if(s_aFilterName[0]) { DoIcon(IMAGE_FRIENDICONS, UI()->MouseHovered(&Button) ? SPRITE_FRIEND_PLUS_A : SPRITE_FRIEND_PLUS_B, &Icon); @@ -1562,7 +1562,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) FilterHeader.Draw(vec4(1, 1, 1, 0.25f), 4.0f, CUIRect::CORNER_T); ServerFilter.Draw(vec4(0, 0, 0, 0.15f), 4.0f, CUIRect::CORNER_B); FilterHeader.HMargin(2.0f, &FilterHeader); - UI()->DoLabel(&FilterHeader, Localize("Server filter"), FontSize + 2.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&FilterHeader, Localize("Server filter"), FontSize + 2.0f, TEXTALIGN_CENTER); int NewSortHash = FilterInfo.m_SortHash; ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); @@ -1622,7 +1622,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) { ServerFilter.HSplitTop(5.0f, 0, &ServerFilter); ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); - UI()->DoLabel(&Button, Localize("Game types:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Game types:"), FontSize, TEXTALIGN_LEFT); ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); Button.Draw(vec4(0.0, 0.0, 0.0, 0.25f), 2.0f); @@ -1651,7 +1651,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) Button.VSplitLeft(ItemLength, &FilterItem, &Button); FilterItem.Draw(FilterInfo.m_aGametypeExclusive[i] ? vec4(0.75f, 0.25f, 0.25f, 0.25f) : vec4(0.25f, 0.75f, 0.25f, 0.25f), 3.0f); FilterItem.VSplitLeft(Spacing, 0, &FilterItem); - UI()->DoLabel(&FilterItem, FilterInfo.m_aGametype[i], FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&FilterItem, FilterInfo.m_aGametype[i], FontSize, TEXTALIGN_LEFT); FilterItem.VSplitRight(IconWidth, 0, &FilterItem); DoIcon(IMAGE_TOOLICONS, UI()->MouseHovered(&FilterItem) ? SPRITE_TOOL_X_A : SPRITE_TOOL_X_B, &FilterItem); if(UI()->DoButtonLogic(&FilterInfo.m_aGametype[i], &FilterItem)) @@ -1754,7 +1754,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s %d", Localize("Maximum ping:"), Value); - UI()->DoLabel(&Button, aBuf, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, aBuf, FontSize, TEXTALIGN_LEFT); ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); @@ -1772,7 +1772,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) // server address ServerFilter.HSplitTop(3.0f, 0, &ServerFilter); ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); - UI()->DoLabel(&Button, Localize("Server address:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Server address:"), FontSize, TEXTALIGN_LEFT); Button.VSplitRight(60.0f, 0, &Button); static char s_aAddressFilter[sizeof(FilterInfo.m_aAddress)]; static CLineInput s_AddressInput(s_aAddressFilter, sizeof(s_aAddressFilter)); @@ -1787,7 +1787,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) CUIRect Rect; ServerFilter.HSplitTop(3.0f, 0, &ServerFilter); ServerFilter.HSplitTop(LineSize, &Button, &ServerFilter); - UI()->DoLabel(&Button, Localize("Flag:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Flag:"), FontSize, TEXTALIGN_LEFT); Button.VSplitRight(60.0f, 0, &Rect); Rect.VSplitLeft(16.0f, &Button, &Rect); static int s_BrFilterCountry = 0; @@ -1808,7 +1808,7 @@ void CMenus::RenderServerbrowserFilterTab(CUIRect View) // level ServerFilter.HSplitTop(5.0f, 0, &ServerFilter); ServerFilter.HSplitTop(LineSize + 2, &Button, &ServerFilter); - UI()->DoLabel(&Button, Localize("Difficulty:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Difficulty:"), FontSize, TEXTALIGN_LEFT); Button.VSplitRight(60.0f, 0, &Button); Button.y -= 2.0f; Button.VSplitLeft(Button.h, &Icon, &Button); @@ -1877,7 +1877,7 @@ void CMenus::RenderDetailInfo(CUIRect View, const CServerInfo *pInfo, const vec4 ServerHeader.Draw(vec4(1, 1, 1, 0.25f), 5.0f, CUIRect::CORNER_T); View.Draw(vec4(0, 0, 0, 0.15f), 5.0f, CUIRect::CORNER_B); ServerHeader.HMargin(2.0f, &ServerHeader); - UI()->DoLabel(&ServerHeader, Localize("Server details"), FontSize + 2.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&ServerHeader, Localize("Server details"), FontSize + 2.0f, TEXTALIGN_CENTER); if(!pInfo) return; @@ -1905,12 +1905,12 @@ void CMenus::RenderDetailInfo(CUIRect View, const CServerInfo *pInfo, const vec4 for(unsigned int i = 0; i < sizeof(s_aLabels) / sizeof(s_aLabels[0]); i++) { LeftColumn.HSplitTop(RowHeight, &Row, &LeftColumn); - UI()->DoLabel(&Row, s_aLabels[i], FontSize, CUI::ALIGN_LEFT, Row.w, false); + UI()->DoLabel(&Row, s_aLabels[i], FontSize, TEXTALIGN_LEFT, Row.w, false); } // map RightColumn.HSplitTop(RowHeight, &Row, &RightColumn); - UI()->DoLabel(&Row, pInfo->m_aMap, FontSize, CUI::ALIGN_LEFT, Row.w, false); + UI()->DoLabel(&Row, pInfo->m_aMap, FontSize, TEXTALIGN_LEFT, Row.w, false); // game type RightColumn.HSplitTop(RowHeight, &Row, &RightColumn); @@ -1918,18 +1918,18 @@ void CMenus::RenderDetailInfo(CUIRect View, const CServerInfo *pInfo, const vec4 Row.VSplitLeft(Row.h, &Icon, &Row); Icon.y -= 2.0f; DoGameIcon(pInfo->m_aGameType, &Icon); - UI()->DoLabel(&Row, pInfo->m_aGameType, FontSize, CUI::ALIGN_LEFT, Row.w, false); + UI()->DoLabel(&Row, pInfo->m_aGameType, FontSize, TEXTALIGN_LEFT, Row.w, false); // version RightColumn.HSplitTop(RowHeight, &Row, &RightColumn); - UI()->DoLabel(&Row, pInfo->m_aVersion, FontSize, CUI::ALIGN_LEFT, Row.w, false); + UI()->DoLabel(&Row, pInfo->m_aVersion, FontSize, TEXTALIGN_LEFT, Row.w, false); // difficulty RightColumn.HSplitTop(RowHeight, &Row, &RightColumn); Row.VSplitLeft(Row.h, &Icon, &Row); Icon.y -= 2.0f; DoIcon(IMAGE_LEVELICONS, s_aDifficultySpriteIds[pInfo->m_ServerLevel], &Icon); - UI()->DoLabel(&Row, s_aDifficultyLabels[pInfo->m_ServerLevel], FontSize, CUI::ALIGN_LEFT, Row.w, false); + UI()->DoLabel(&Row, s_aDifficultyLabels[pInfo->m_ServerLevel], FontSize, TEXTALIGN_LEFT, Row.w, false); } void CMenus::RenderDetailScoreboard(CUIRect View, const CServerInfo *pInfo, int RowCount, const vec4 &TextColor, const vec4 &TextOutlineColor) @@ -2036,7 +2036,7 @@ void CMenus::RenderDetailScoreboard(CUIRect View, const CServerInfo *pInfo, int Score.y += (Score.h - FontSize/ms_FontmodHeight)/2.0f; char aTemp[16]; FormatScore(aTemp, sizeof(aTemp), pInfo->m_Flags&IServerBrowser::FLAG_TIMESCORE, &pInfo->m_aClients[i]); - UI()->DoLabel(&Score, aTemp, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Score, aTemp, FontSize, TEXTALIGN_LEFT); } // name @@ -2069,7 +2069,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View, const CServerInfo *pI ServerScoreboard.HSplitTop(GetListHeaderHeight(), &ServerHeader, &ServerScoreboard); ServerHeader.Draw(vec4(1, 1, 1, 0.25f), 4.0f, CUIRect::CORNER_T); ServerHeader.HMargin(2.0f, &ServerHeader); - UI()->DoLabel(&ServerHeader, Localize("Scoreboard"), 12.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&ServerHeader, Localize("Scoreboard"), 12.0f, TEXTALIGN_CENTER); RenderDetailScoreboard(ServerScoreboard, pInfo, 0, CUI::ms_DefaultTextColor, CUI::ms_DefaultTextOutlineColor); } diff --git a/src/game/client/components/menus_callback.cpp b/src/game/client/components/menus_callback.cpp index 0897cfa8f..6522afd58 100644 --- a/src/game/client/components/menus_callback.cpp +++ b/src/game/client/components/menus_callback.cpp @@ -82,7 +82,7 @@ void CMenus::DoSettingsControlsButtons(int Start, int Stop, CUIRect View, float str_format(aBuf, sizeof(aBuf), "%s:", (const char *)Key.m_Name); Label.y += 2.0f; - UI()->DoLabel(&Label, aBuf, 13.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, aBuf, 13.0f, TEXTALIGN_CENTER); int OldId = Key.m_KeyId, OldModifier = Key.m_Modifier, NewModifier; int NewId = DoKeyReader(&gs_aKeys[i].m_BC, &Button, OldId, OldModifier, &NewModifier); if(NewId != OldId || NewModifier != OldModifier) @@ -242,7 +242,7 @@ float CMenus::RenderSettingsControlsJoystick(CUIRect View) { View.HSplitTop((View.h-ButtonHeight)/2.0f, 0, &View); View.HSplitTop(ButtonHeight, &Button, &View); - m_pClient->UI()->DoLabel(&Button, Localize("No joysticks found. Plug in a joystick and restart the game."), 13.0f, CUI::ALIGN_CENTER); + m_pClient->UI()->DoLabel(&Button, Localize("No joysticks found. Plug in a joystick and restart the game."), 13.0f, TEXTALIGN_CENTER); } } @@ -396,13 +396,13 @@ void CMenus::DoJoystickAxisPicker(CUIRect View) View.HSplitTop(Spacing, 0, &View); View.HSplitTop(ButtonHeight, &Row, &View); Row.VSplitLeft(StatusWidth, &Button, &Row); - m_pClient->UI()->DoLabel(&Button, Localize("Device"), 13.0f, CUI::ALIGN_CENTER); + m_pClient->UI()->DoLabel(&Button, Localize("Device"), 13.0f, TEXTALIGN_CENTER); Row.VSplitLeft(StatusMargin, 0, &Row); Row.VSplitLeft(StatusWidth, &Button, &Row); - m_pClient->UI()->DoLabel(&Button, Localize("Status"), 13.0f, CUI::ALIGN_CENTER); + m_pClient->UI()->DoLabel(&Button, Localize("Status"), 13.0f, TEXTALIGN_CENTER); Row.VSplitLeft(2*StatusMargin, 0, &Row); Row.VSplitLeft(2*BindWidth, &Button, &Row); - m_pClient->UI()->DoLabel(&Button, Localize("Aim bind"), 13.0f, CUI::ALIGN_CENTER); + m_pClient->UI()->DoLabel(&Button, Localize("Aim bind"), 13.0f, TEXTALIGN_CENTER); static int s_aActive[g_MaxJoystickAxes][2]; for(int i = 0; i < minimum(m_pClient->Input()->GetJoystickNumAxes(), g_MaxJoystickAxes); i++) @@ -421,7 +421,7 @@ void CMenus::DoJoystickAxisPicker(CUIRect View) m_pClient->TextRender()->TextColor(0.7f, 0.7f, 0.7f, 1.0f); else m_pClient->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); - m_pClient->UI()->DoLabel(&Button, aBuf, 13.0f, CUI::ALIGN_CENTER); + m_pClient->UI()->DoLabel(&Button, aBuf, 13.0f, TEXTALIGN_CENTER); // Device status Row.VSplitLeft(StatusMargin, 0, &Row); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index e4d88bf77..83c7e3b43 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -21,9 +21,9 @@ #include "menus.h" CMenus::CColumn CMenus::ms_aDemoCols[] = { // Localize("Name"); Localize("Length"); Localize("Date"); - these strings are localized within CLocConstString - {COL_DEMO_NAME, CMenus::SORT_DEMONAME, "Name", 0, 100.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_DEMO_LENGTH, CMenus::SORT_LENGTH, "Length", 1, 80.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, - {COL_DEMO_DATE, CMenus::SORT_DATE, "Date", 1, 170.0f, 0, {0}, {0}, CUI::ALIGN_CENTER}, + {COL_DEMO_NAME, CMenus::SORT_DEMONAME, "Name", 0, 100.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_DEMO_LENGTH, CMenus::SORT_LENGTH, "Length", 1, 80.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, + {COL_DEMO_DATE, CMenus::SORT_DATE, "Date", 1, 170.0f, 0, {0}, {0}, TEXTALIGN_CENTER}, }; void CMenus::RenderDemoPlayer(CUIRect MainView) @@ -121,7 +121,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) str_format(aBuffer, sizeof(aBuffer), "%d:%02d / %d:%02d", CurrentTick/SERVER_TICK_SPEED/60, (CurrentTick/SERVER_TICK_SPEED)%60, TotalTicks/SERVER_TICK_SPEED/60, (TotalTicks/SERVER_TICK_SPEED)%60); - UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, CUI::ALIGN_CENTER); + UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, TEXTALIGN_CENTER); // do the logic if(UI()->CheckActiveItem(&s_PrevAmount)) @@ -314,7 +314,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins*3, 0, &ButtonBar); char aBuffer[64]; str_format(aBuffer, sizeof(aBuffer), pInfo->m_Speed >= 1.0f ? "x%.0f" : "x%.2f", pInfo->m_Speed); - UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, CUI::ALIGN_LEFT); + UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, TEXTALIGN_LEFT); // close button ButtonBar.VSplitRight(ButtonbarHeight*3, &ButtonBar, &Button); @@ -587,7 +587,7 @@ void CMenus::RenderDemoList(CUIRect MainView) if(ID == COL_DEMO_NAME) { Button.x += FileIcon.w + 10.0f; - UI()->DoLabel(&Button, DemoItem.m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, DemoItem.m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); } else if(ID == COL_DEMO_LENGTH && !DemoItem.m_IsDir && DemoItem.m_InfosLoaded && DemoItem.m_Valid) { @@ -597,7 +597,7 @@ void CMenus::RenderDemoList(CUIRect MainView) Button.VMargin(4.0f, &Button); if(!Item.m_Selected) TextRender()->TextColor(CUI::ms_TransparentTextColor); - UI()->DoLabel(&Button, aLength, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_RIGHT); + UI()->DoLabel(&Button, aLength, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_RIGHT); } else if(ID == COL_DEMO_DATE && !DemoItem.m_IsDir) { @@ -605,7 +605,7 @@ void CMenus::RenderDemoList(CUIRect MainView) str_timestamp_ex(DemoItem.m_Date, aDate, sizeof(aDate), FORMAT_SPACE); if(!Item.m_Selected) TextRender()->TextColor(CUI::ms_TransparentTextColor); - UI()->DoLabel(&Button, aDate, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Button, aDate, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); } TextRender()->TextColor(CUI::ms_DefaultTextColor); if(Item.m_Selected) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index e6b19fc35..9966bd5e3 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -70,7 +70,7 @@ void CMenus::RenderGame(CUIRect MainView) // game options MainView.HSplitTop(20.0f, &Label, &MainView); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Game options"), 20.0f*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Game options"), 20.0f*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); MainView.Draw(vec4(0.0, 0.0, 0.0, 0.25f)); if(Info.m_aNotification[0] != 0) @@ -79,7 +79,7 @@ void CMenus::RenderGame(CUIRect MainView) CUIRect Bar; MainView.HSplitBottom(NoteHeight, &MainView, &Bar); Bar.HMargin(15.0f, &Bar); - UI()->DoLabel(&Bar, Info.m_aNotification, 14.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Bar, Info.m_aNotification, 14.0f, TEXTALIGN_CENTER); } // buttons @@ -220,7 +220,7 @@ void CMenus::RenderPlayers(CUIRect MainView) // player options MainView.HSplitTop(ButtonHeight, &Label, &MainView); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Player options"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Player options"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); MainView.Draw(vec4(0.0, 0.0, 0.0, 0.25f)); // prepare headline @@ -244,7 +244,7 @@ void CMenus::RenderPlayers(CUIRect MainView) Row.VSplitLeft(ButtonHeight+Spacing, 0, &Row); Row.VSplitLeft(NameWidth, &Label, &Row); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Player"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, Localize("Player"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); Row.VSplitRight(2*ButtonHeight, &Row, &Label); Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIICONS].m_Id); @@ -306,12 +306,12 @@ void CMenus::RenderPlayers(CUIRect MainView) } char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s", Config()->m_ClShowsocial ? m_pClient->m_aClients[i].m_aName : ""); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); Row.VSplitLeft(Spacing, 0, &Row); Row.VSplitLeft(ClanWidth, &Label, &Row); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s", Config()->m_ClShowsocial ? m_pClient->m_aClients[i].m_aClan : ""); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); // ignore button Row.VSplitRight(ButtonHeight/2, &Row, 0); @@ -372,33 +372,33 @@ void CMenus::RenderServerInfo(CUIRect MainView) ServerInfo.HSplitTop(ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Server info"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Server info"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); ServerInfo.Draw(vec4(0.0, 0.0, 0.0, 0.25f)); ServerInfo.Margin(5.0f, &ServerInfo); ServerInfo.HSplitTop(2*ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; - UI()->DoLabel(&Label, CurrentServerInfo.m_aName, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT, Label.w); + UI()->DoLabel(&Label, CurrentServerInfo.m_aName, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT, Label.w); ServerInfo.HSplitTop(ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Address"), CurrentServerInfo.m_aHostname); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); ServerInfo.HSplitTop(ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Ping"), m_pClient->m_Snap.m_pLocalInfo->m_Latency); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); ServerInfo.HSplitTop(ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Version"), CurrentServerInfo.m_aVersion); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); ServerInfo.HSplitTop(ButtonHeight, &Label, &ServerInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Password"), CurrentServerInfo.m_Flags&IServerBrowser::FLAG_PASSWORD ? Localize("Yes", "With") : Localize("No", "Without/None")); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); const bool IsFavorite = CurrentServerInfo.m_Favorite; ServerInfo.HSplitBottom(ButtonHeight, &ServerInfo, &Label); @@ -426,19 +426,19 @@ void CMenus::RenderServerInfo(CUIRect MainView) GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Game info"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Game info"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); GameInfo.Draw(vec4(0.0, 0.0, 0.0, 0.25f)); GameInfo.Margin(5.0f, &GameInfo); GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Game type"), CurrentServerInfo.m_aGameType); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Map"), CurrentServerInfo.m_aMap); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; @@ -456,22 +456,22 @@ void CMenus::RenderServerInfo(CUIRect MainView) break; } str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Difficulty"), pLevelName); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_GameInfo.m_ScoreLimit); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); GameInfo.HSplitTop(ButtonHeight, &Label, &GameInfo); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Time limit"), m_pClient->m_GameInfo.m_TimeLimit); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); GameInfo.HSplitBottom(ButtonHeight, &GameInfo, &Label); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s: %d/%d", Localize("Players"), m_pClient->m_GameInfo.m_NumPlayers, CurrentServerInfo.m_MaxClients); - UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); // motd Motd.HSplitTop(2.0f, 0, &Motd); @@ -479,7 +479,7 @@ void CMenus::RenderServerInfo(CUIRect MainView) Motd.HSplitTop(ButtonHeight, &Label, &Motd); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("MOTD"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("MOTD"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Motd.Draw(vec4(0.0, 0.0, 0.0, 0.25f)); Motd.Margin(5.0f, &Motd); @@ -533,7 +533,7 @@ bool CMenus::RenderServerControlServer(CUIRect MainView) for(int i = pOption->m_IsSubheader ? 1 : 0; i < pOption->m_Depth; i++) Item.m_Rect.VSplitLeft(10.0f, 0, &Item.m_Rect); - UI()->DoLabel(&Item.m_Rect, pOption->m_aDescription, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Item.m_Rect, pOption->m_aDescription, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); } } @@ -598,12 +598,12 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) Label.y += 2.0f; char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s", Config()->m_ClShowsocial ? m_pClient->m_aClients[s_aPlayerIDs[i]].m_aName : ""); - UI()->DoLabel(&Label, aBuf, Label.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, Label.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); Row.VSplitLeft(Spacing, 0, &Row); Row.VSplitLeft(ClanWidth, &Label, &Row); Label.y += 2.0f; str_format(aBuf, sizeof(aBuf), "%s", Config()->m_ClShowsocial ? m_pClient->m_aClients[s_aPlayerIDs[i]].m_aClan : ""); - UI()->DoLabel(&Label, aBuf, Label.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, aBuf, Label.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); } } @@ -681,7 +681,7 @@ void CMenus::RenderServerControl(CUIRect MainView) MainView.HSplitTop(45.0f, &Bar, &MainView); Bar.Draw(vec4(0.0f, 0.0f, 0.0f, 0.25f+Config()->m_ClMenuAlpha/100.0f)); Bar.HMargin(15.0f, &Bar); - UI()->DoLabel(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Bar, pNotification, 14.0f, TEXTALIGN_CENTER); return; } @@ -726,7 +726,7 @@ void CMenus::RenderServerControl(CUIRect MainView) MainView.HSplitTop(45.0f, &MainView, 0); MainView.Draw(vec4(0.0f, 0.0f, 0.0f, Config()->m_ClMenuAlpha/100.0f), 5.0f, CUIRect::CORNER_B); MainView.HMargin(15.0f, &MainView); - UI()->DoLabel(&MainView, pNotification, 14.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&MainView, pNotification, 14.0f, TEXTALIGN_CENTER); return; } @@ -764,7 +764,7 @@ void CMenus::RenderServerControl(CUIRect MainView) CUIRect Label; Search.VSplitLeft(TextRender()->TextWidth(FontSize, pSearchLabel, -1) + 10.0f, &Label, &Search); Label.y += 2.0f; - UI()->DoLabel(&Label, pSearchLabel, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, pSearchLabel, FontSize, TEXTALIGN_LEFT); static CLineInput s_FilterInput(m_aFilterString, sizeof(m_aFilterString)); if(UI()->DoEditBox(&s_FilterInput, &Search, FontSize)) m_CallvoteSelectedOption = 0; @@ -773,7 +773,7 @@ void CMenus::RenderServerControl(CUIRect MainView) if(pNotification) { Bottom.y += 2.0f; - UI()->DoLabel(&Bottom, pNotification, Bottom.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Bottom, pNotification, Bottom.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); } else { @@ -788,7 +788,7 @@ void CMenus::RenderServerControl(CUIRect MainView) const float FontSize = Reason.h*ms_FontmodHeight*0.8f; Reason.VSplitLeft(TextRender()->TextWidth(FontSize, pReasonLabel, -1) + 10.0f, &Label, &Reason); Label.y += 2.0f; - UI()->DoLabel(&Label, pReasonLabel, FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, pReasonLabel, FontSize, TEXTALIGN_LEFT); static CLineInput s_ReasonInput(m_aCallvoteReason, sizeof(m_aCallvoteReason)); UI()->DoEditBox(&s_ReasonInput, &Reason, FontSize, false, CUIRect::CORNER_L); @@ -837,10 +837,10 @@ void CMenus::RenderServerControl(CUIRect MainView) // add vote Extended.HSplitTop(LineHeight, &Bottom, &Extended); Bottom.VSplitLeft(2*ColumnWidth+Spacing, &Button, &Bottom); - UI()->DoLabel(&Button, Localize("Vote description:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Vote description:"), FontSize, TEXTALIGN_LEFT); Bottom.VSplitLeft(2*Spacing, 0, &Button); - UI()->DoLabel(&Button, Localize("Vote command:"), FontSize, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, Localize("Vote command:"), FontSize, TEXTALIGN_LEFT); static char s_aVoteDescription[VOTE_DESC_LENGTH] = {0}; static char s_aVoteCommand[VOTE_CMD_LENGTH] = {0}; diff --git a/src/game/client/components/menus_listbox.cpp b/src/game/client/components/menus_listbox.cpp index f089babb7..be0f2fc06 100644 --- a/src/game/client/components/menus_listbox.cpp +++ b/src/game/client/components/menus_listbox.cpp @@ -37,7 +37,7 @@ void CMenus::CListBox::DoHeader(const CUIRect *pRect, const char *pTitle, // draw header View.HSplitTop(HeaderHeight, &Header, &View); Header.y += 2.0f; - m_pUI->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + m_pUI->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); View.HSplitTop(Spacing, &Header, &View); @@ -70,7 +70,7 @@ bool CMenus::CListBox::DoFilter(float FilterHeight, float Spacing) CUIRect Label, EditBox; Filter.VSplitLeft(Filter.w/5.0f, &Label, &EditBox); Label.y += Spacing; - m_pUI->DoLabel(&Label, Localize("Search:"), FontSize, CUI::ALIGN_CENTER); + m_pUI->DoLabel(&Label, Localize("Search:"), FontSize, TEXTALIGN_CENTER); bool Changed = m_pUI->DoEditBox(&m_FilterInput, &EditBox, FontSize); View.HSplitTop(Spacing, &Filter, &View); @@ -107,7 +107,7 @@ void CMenus::CListBox::DoStart(float RowHeight, int NumItems, int ItemsPerRow, i View.HSplitBottom(m_FooterHeight, &View, &Footer); Footer.VSplitLeft(10.0f, 0, &Footer); Footer.y += 2.0f; - m_pUI->DoLabel(&Footer, m_pBottomText, Footer.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + m_pUI->DoLabel(&Footer, m_pBottomText, Footer.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); } // setup the variables diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index ef4c8716f..e48cd214e 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -180,13 +180,13 @@ void CMenus::RenderHSLPicker(CUIRect MainView) // label Label.VSplitMid(&Label, &Button, 0.0f); Label.y += 4.0f; - UI()->DoLabel(&Label, apNames[i], SliderHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, apNames[i], SliderHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // value label char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", *apVars[i]); Button.y += 4.0f; - UI()->DoLabel(&Button, aBuf, SliderHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Button, aBuf, SliderHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // button < Section.VSplitLeft(SliderHeight, &Button, &Bar); @@ -380,7 +380,7 @@ void CMenus::RenderSkinSelection(CUIRect MainView) TextRender()->TextColor(CUI::ms_HighlightTextColor); TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } - UI()->DoLabel(&Label, s->m_aName, 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, s->m_aName, 10.0f, TEXTALIGN_CENTER); if(Item.m_Selected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -492,7 +492,7 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView) TextRender()->TextColor(CUI::ms_HighlightTextColor); TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } - UI()->DoLabel(&Label, s->m_aName, 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, s->m_aName, 10.0f, TEXTALIGN_CENTER); if(Item.m_Selected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -752,7 +752,7 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header) TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } Item.m_Rect.y += 2.0f; - UI()->DoLabel(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); if(Item.m_Selected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -847,7 +847,7 @@ void CMenus::RenderThemeSelection(CUIRect MainView, bool Header) TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } Item.m_Rect.y += 2.0f; - UI()->DoLabel(&Item.m_Rect, aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Item.m_Rect, aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); if(Item.m_Selected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -903,7 +903,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) // render game menu Game.HSplitTop(ButtonHeight, &Label, &Game); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Game"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Game"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Game.VSplitMid(&GameLeft, &GameRight, Spacing); @@ -1015,7 +1015,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) // render client menu Client.HSplitTop(ButtonHeight, &Label, &Client); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Client"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Client"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Client.HSplitTop(Spacing, 0, &Client); Client.HSplitTop(ButtonHeight, &Button, &Client); @@ -1095,7 +1095,7 @@ void CMenus::RenderSettingsTeeCustom(CUIRect MainView) MainView.HSplitTop(ButtonHeight, &Label, &MainView); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Customize"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Customize"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // skin part selection MainView.HSplitTop(SpacingH, 0, &MainView); @@ -1183,7 +1183,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Left.HSplitTop(ButtonHeight, &Label, &Left); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Tee"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Tee"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // Preview { @@ -1235,7 +1235,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Top.VSplitLeft(Top.w/3.0f+SpacingW/2.0f, &Label, &Top); Label.y += 17.0f; - UI()->DoLabel(&Label, Localize("Normal:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Normal:"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Top.Draw(vec4(0.0f, 0.0f, 0.0f, 0.25f)); @@ -1287,7 +1287,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Bottom.VSplitLeft(Bottom.w/3.0f+SpacingW/2.0f, &Label, &Bottom); Label.y += 17.0f; - UI()->DoLabel(&Label, Localize("Team:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Team:"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Bottom.VSplitMid(&TeeLeft, &TeeRight, SpacingW); @@ -1312,7 +1312,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Right.HSplitTop(ButtonHeight, &Label, &Right); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Personal"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Personal"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // Personal { @@ -1336,7 +1336,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Bottom.VSplitLeft(100.0f, &Label, &Button); Label.y += 17.0f; - UI()->DoLabel(&Label, Localize("Flag:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Flag:"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Button.w = (SkinHeight - 20.0f) * 2 + 20.0f; Button.Draw(vec4(0.0f, 0.0f, 0.0f, 0.25f)); @@ -1613,7 +1613,7 @@ bool CMenus::DoResolutionList(CUIRect* pRect, CListBox* pListBox, TextRender()->TextSecondaryColor(CUI::ms_HighlightTextOutlineColor); } Item.m_Rect.y += 2.0f; - UI()->DoLabel(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); if(Item.m_Selected) { TextRender()->TextColor(CUI::ms_DefaultTextColor); @@ -1680,7 +1680,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) // render screen menu ScreenLeft.HSplitTop(ButtonHeight, &Label, &ScreenLeft); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Screen"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Screen"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); ScreenLeft.VSplitMid(&ScreenLeft, &ScreenRight, Spacing); @@ -1709,7 +1709,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) Button.VSplitLeft(100.0f-25.0f, &Text, &Button); // make button appear centered with FSAA str_format(aBuf, sizeof(aBuf), Localize("Screen:")); Text.y += 2.0f; - UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); Button.VSplitLeft(120.0f, &Button, 0); str_format(aBuf, sizeof(aBuf), "#%d (%dx%d)", Config()->m_GfxScreen+1, Graphics()->DesktopWidth(), Graphics()->DesktopHeight()); @@ -1732,7 +1732,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%s:", Localize("Anti Aliasing")); Text.y += 2.0f; - UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, TEXTALIGN_LEFT); Button.VSplitLeft(70.0f, &Button, 0); str_format(aBuf, sizeof(aBuf), "%dx", Config()->m_GfxFsaaSamples); @@ -1775,7 +1775,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) // render texture menu Texture.HSplitTop(ButtonHeight, &Label, &Texture); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Texture"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Texture"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Texture.HSplitTop(Spacing, 0, &Texture); Texture.HSplitTop(ButtonHeight, &Button, &Texture); @@ -1813,7 +1813,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) // draw header MainView.HSplitTop(ButtonHeight, &Header, &MainView); Header.y += 2.0f; - UI()->DoLabel(&Header, Localize("Resolution"), Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Header, Localize("Resolution"), Header.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); MainView.HSplitTop(Spacing, 0, &MainView); MainView.HSplitTop(ButtonHeight, &Button, &MainView); @@ -1826,11 +1826,11 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s", Localize("Recommended")); HeaderLeft.y += 2; - UI()->DoLabel(&HeaderLeft, aBuf, HeaderLeft.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&HeaderLeft, aBuf, HeaderLeft.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); str_format(aBuf, sizeof(aBuf), "%s", Localize("Other")); HeaderRight.y += 2; - UI()->DoLabel(&HeaderRight, aBuf, HeaderRight.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&HeaderRight, aBuf, HeaderRight.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); MainView.HSplitTop(Spacing, 0, &MainView); @@ -1844,7 +1844,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) const float HiDPIScale = Graphics()->ScreenHiDPIScale(); str_format(aBuf, sizeof(aBuf), Localize("Current: %dx%d (%d:%d)"), (int)(s_GfxScreenWidth*HiDPIScale), (int)(s_GfxScreenHeight*HiDPIScale), s_GfxScreenWidth/g, s_GfxScreenHeight/g); Button.y += 2; - UI()->DoLabel(&Button, aBuf, Button.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Button, aBuf, Button.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); static int s_LastScreen = Config()->m_GfxScreen; if(s_LastScreen != Config()->m_GfxScreen) @@ -1927,7 +1927,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView) // render sound menu Sound.HSplitTop(ButtonHeight, &Label, &Sound); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Sound"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Sound"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Sound.HSplitTop(Spacing, 0, &Sound); CUIRect UseSoundButton; @@ -1953,7 +1953,7 @@ void CMenus::RenderSettingsSound(CUIRect MainView) // render detail menu Detail.HSplitTop(ButtonHeight, &Label, &Detail); Label.y += 2.0f; - UI()->DoLabel(&Label, Localize("Detail"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Label, Localize("Detail"), ButtonHeight*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); // split menu CUIRect Left, Right; @@ -1972,10 +1972,10 @@ void CMenus::RenderSettingsSound(CUIRect MainView) char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%s:", Localize("Sample rate")); Text.y += 2.0f; - UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); Unit.y += 2.0f; - UI()->DoLabel(&Unit, "kHz", Unit.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Unit, "kHz", Unit.h*ms_FontmodHeight*0.8f, TEXTALIGN_CENTER); if(Config()->m_SndRate != 48000 && Config()->m_SndRate != 44100) Config()->m_SndRate = 48000; @@ -2143,16 +2143,16 @@ void CMenus::RenderSettings(CUIRect MainView) TextRender()->TextColor(0.973f, 0.863f, 0.207f, 1.0f); RestartWarning.y += 2.0f; if(m_NeedRestartGraphics || m_NeedRestartSound) - UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), RestartWarning.h*ms_FontmodHeight*0.75f, CUI::ALIGN_CENTER); + UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), RestartWarning.h*ms_FontmodHeight*0.75f, TEXTALIGN_CENTER); else if(Client()->State() == IClient::STATE_ONLINE) { if(m_NeedRestartPlayer || NeedRestartTee) - UI()->DoLabel(&RestartWarning, Localize("You must reconnect to change identity."), RestartWarning.h*ms_FontmodHeight*0.75f, CUI::ALIGN_CENTER); + UI()->DoLabel(&RestartWarning, Localize("You must reconnect to change identity."), RestartWarning.h*ms_FontmodHeight*0.75f, TEXTALIGN_CENTER); else if(m_SkinModified) { char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("You have to wait %1.0f seconds to change identity."), m_pClient->m_LastSkinChangeTime+6.5f - Client()->LocalTime()); - UI()->DoLabel(&RestartWarning, aBuf, RestartWarning.h*ms_FontmodHeight*0.75f, CUI::ALIGN_CENTER); + UI()->DoLabel(&RestartWarning, aBuf, RestartWarning.h*ms_FontmodHeight*0.75f, TEXTALIGN_CENTER); } } TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index 2019db24b..7f41bea2e 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -108,10 +108,10 @@ void CMenus::RenderStartMenu(CUIRect MainView) { str_format(aBuf, sizeof(aBuf), Localize("Teeworlds %s is out! Download it at www.teeworlds.com!"), Client()->LatestVersion()); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); - UI()->DoLabel(&Version, aBuf, 14.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Version, aBuf, 14.0f, TEXTALIGN_CENTER); TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } - UI()->DoLabel(&Version, GAME_RELEASE_VERSION, 14.0f, CUI::ALIGN_RIGHT); + UI()->DoLabel(&Version, GAME_RELEASE_VERSION, 14.0f, TEXTALIGN_RIGHT); if(NewPage != -1) SetMenuPage(NewPage); diff --git a/src/game/client/ui.cpp b/src/game/client/ui.cpp index ea8d981ac..975cba877 100644 --- a/src/game/client/ui.cpp +++ b/src/game/client/ui.cpp @@ -267,7 +267,7 @@ bool CUI::DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float return true; } -void CUI::DoLabel(const CUIRect *pRect, const char *pText, float FontSize, EAlignment Align, float LineWidth, bool MultiLine) +void CUI::DoLabel(const CUIRect *pRect, const char *pText, float FontSize, int Align, float LineWidth, bool MultiLine) { // TODO: FIX ME!!!! // Graphics()->BlendNormal(); @@ -279,21 +279,19 @@ void CUI::DoLabel(const CUIRect *pRect, const char *pText, float FontSize, EAlig s_Cursor.m_MaxWidth = LineWidth; s_Cursor.m_Align = Align; - switch(Align) - { - case CUI::ALIGN_LEFT: - s_Cursor.m_Align = TEXTALIGN_LEFT; - s_Cursor.MoveTo(pRect->x, pRect->y); - break; - case CUI::ALIGN_CENTER: - s_Cursor.m_Align = TEXTALIGN_CENTER; - s_Cursor.MoveTo(pRect->x + pRect->w / 2.0f, pRect->y); - break; - case CUI::ALIGN_RIGHT: - s_Cursor.m_Align = TEXTALIGN_RIGHT; - s_Cursor.MoveTo(pRect->x + pRect->w, pRect->y); - break; - } + float x = pRect->x; + if(Align&TEXTALIGN_CENTER) + x += pRect->w / 2.0f; + else if(Align&TEXTALIGN_RIGHT) + x += pRect->w; + + float y = pRect->y; + if(Align&TEXTALIGN_MIDDLE) + y += pRect->h / 2.0f; + else if(Align&TEXTALIGN_BOTTOM) + y += pRect->h; + + s_Cursor.MoveTo(x, y); TextRender()->TextOutlined(&s_Cursor, pText, -1); } @@ -452,7 +450,7 @@ bool CUI::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize ClipEnable(pRect); Textbox.x -= ScrollOffset; - DoLabel(&Textbox, pDisplayStr, FontSize, CUI::ALIGN_LEFT); + DoLabel(&Textbox, pDisplayStr, FontSize, TEXTALIGN_LEFT); // render the cursor if(LastActiveItem() == pLineInput && !JustGotActive) @@ -463,7 +461,7 @@ bool CUI::DoEditBox(CLineInput *pLineInput, const CUIRect *pRect, float FontSize Textbox = *pRect; Textbox.VSplitLeft(Spacing, 0, &Textbox); Textbox.x += TextWidth - ScrollOffset - TextRender()->TextWidth(FontSize, "|", -1)/2; - DoLabel(&Textbox, "|", FontSize, CUI::ALIGN_LEFT); + DoLabel(&Textbox, "|", FontSize, TEXTALIGN_LEFT); } } ClipDisable(); @@ -484,7 +482,7 @@ void CUI::DoEditBoxOption(CLineInput *pLineInput, const CUIRect *pRect, const ch char aBuf[32]; str_format(aBuf, sizeof(aBuf), "%s:", pStr); Label.y += 2.0f; - DoLabel(&Label, aBuf, FontSize, CUI::ALIGN_CENTER); + DoLabel(&Label, aBuf, FontSize, TEXTALIGN_CENTER); DoEditBox(pLineInput, &EditBox, FontSize, Hidden); } @@ -655,7 +653,7 @@ void CUI::DoScrollbarOption(const void *pID, int *pOption, const CUIRect *pRect, pRect->VSplitLeft(pRect->h+10.0f+VSplitVal, &Label, &ScrollBar); Label.VSplitLeft(Label.h+5.0f, 0, &Label); Label.y += 2.0f; - DoLabel(&Label, aBuf, FontSize, CUI::ALIGN_LEFT); + DoLabel(&Label, aBuf, FontSize, TEXTALIGN_LEFT); ScrollBar.VMargin(4.0f, &ScrollBar); Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, Min, Max)), Min, Max); @@ -681,7 +679,7 @@ void CUI::DoScrollbarOptionLabeled(const void *pID, int *pOption, const CUIRect pRect->VSplitLeft(pRect->h+5.0f, 0, &Label); Label.VSplitRight(60.0f, &Label, &ScrollBar); Label.y += 2.0f; - DoLabel(&Label, aBuf, FontSize, CUI::ALIGN_LEFT); + DoLabel(&Label, aBuf, FontSize, TEXTALIGN_LEFT); ScrollBar.VMargin(4.0f, &ScrollBar); Value = pScale->ToAbsolute(DoScrollbarH(pID, &ScrollBar, pScale->ToRelative(Value, 0, Max)), 0, Max); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 2f6800ad5..a1b2371dc 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -3,7 +3,7 @@ #ifndef GAME_CLIENT_UI_H #define GAME_CLIENT_UI_H -#include +#include #include "lineinput.h" #include "ui_rect.h" @@ -142,13 +142,6 @@ public: CUI(); - enum EAlignment - { - ALIGN_LEFT, - ALIGN_CENTER, - ALIGN_RIGHT, - }; - enum { HOTKEY_ENTER = 1, @@ -208,7 +201,7 @@ public: bool DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *pY); // labels - void DoLabel(const CUIRect *pRect, const char *pText, float FontSize, EAlignment Align, float LineWidth = -1.0f, bool MultiLine = true); + void DoLabel(const CUIRect *pRect, const char *pText, float FontSize, int Align = TEXTALIGN_LEFT|TEXTALIGN_TOP, float LineWidth = -1.0f, bool MultiLine = true); void DoLabelHighlighted(const CUIRect *pRect, const char *pText, const char *pHighlighted, float FontSize, const vec4 &TextColor, const vec4 &HighlightColor); // editboxes diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index adb09ddca..9d265d5a2 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -319,18 +319,10 @@ int CEditor::DoButton_Editor_Common(const void *pID, const char *pText, int Chec return 0; } - 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), 3.0f); - - static CTextCursor s_Cursor(10.0f); - s_Cursor.MoveTo(pRect->x + pRect->w/2, pRect->y + pRect->h/2); - s_Cursor.Reset(); - s_Cursor.m_MaxWidth = pRect->w; - s_Cursor.m_MaxLines = 1; - s_Cursor.m_Align = TEXTALIGN_MC; - TextRender()->TextOutlined(&s_Cursor, pText, -1); + UI()->DoLabel(pRect, pText, 10.0f, TEXTALIGN_MC); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -341,16 +333,9 @@ int CEditor::DoButton_Image(const void *pID, const char *pText, int Checked, con if(!Used) ButtonColor *= vec4(0.5f, 0.5f, 0.5f, 1.0f); + const float FontSize = clamp(8.0f * pRect->w / TextRender()->TextWidth(10.0f, pText, -1), 6.0f, 10.0f); pRect->Draw(ButtonColor, 3.0f); - - static CTextCursor s_Cursor; - s_Cursor.MoveTo(pRect->x + pRect->w/2, pRect->y + pRect->h/2); - s_Cursor.Reset(); - s_Cursor.m_FontSize = clamp(8.0f * pRect->w / TextRender()->TextWidth(10.0f, pText, -1), 6.0f, 10.0f); - s_Cursor.m_MaxWidth = pRect->w; - s_Cursor.m_MaxLines = 1; - s_Cursor.m_Align = TEXTALIGN_MC; - TextRender()->TextOutlined(&s_Cursor, pText, -1); + UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -361,20 +346,19 @@ int CEditor::DoButton_File(const void *pID, const char *pText, int Checked, cons else if(UI()->HotItem() == pID) pRect->Draw(vec4(1,1,1,0.33f), 3.0f); - CUIRect t = *pRect; - t.VMargin(5.0f, &t); - UI()->DoLabel(&t, pText, 10, CUI::ALIGN_LEFT); + CUIRect Label = *pRect; + Label.VMargin(5.0f, &Label); + UI()->DoLabel(&Label, pText, 10.0f, TEXTALIGN_ML); 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) { - CUIRect r = *pRect; - r.Draw(vec4(0.5f, 0.5f, 0.5f, 1.0f), 3.0f, CUIRect::CORNER_T); + pRect->Draw(vec4(0.5f, 0.5f, 0.5f, 1.0f), 3.0f, CUIRect::CORNER_T); - r = *pRect; - r.VMargin(5.0f, &r); - UI()->DoLabel(&r, pText, 10, CUI::ALIGN_LEFT); + CUIRect Label = *pRect; + Label.VMargin(5.0f, &Label); + UI()->DoLabel(&Label, pText, 10.0f, TEXTALIGN_ML); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -383,45 +367,37 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked, if(UI()->HotItem() == pID || Checked) pRect->Draw(GetButtonColor(pID, Checked), 3.0f); - CUIRect t = *pRect; - t.VMargin(5.0f, &t); - static CTextCursor s_Cursor(10.0f); - s_Cursor.Reset(); - s_Cursor.MoveTo(t.x, t.y - 1.0f); - s_Cursor.m_MaxWidth = t.w; - TextRender()->TextOutlined(&s_Cursor, pText, -1); + CUIRect Label = *pRect; + Label.VMargin(5.0f, &Label); + UI()->DoLabel(&Label, pText, 10.0f, TEXTALIGN_ML); 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) { pRect->Draw(GetButtonColor(pID, Checked), 5.0f, CUIRect::CORNER_T); - CUIRect NewRect = *pRect; - NewRect.y += NewRect.h/2.0f-7.0f; - UI()->DoLabel(&NewRect, pText, 10, CUI::ALIGN_CENTER); + UI()->DoLabel(pRect, pText, 10.0f, TEXTALIGN_MC); 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) { pRect->Draw(GetButtonColor(pID, Checked), 3.0f, Corners); - CUIRect NewRect = *pRect; - NewRect.HMargin(NewRect.h/2.0f-FontSize/2.0f-1.0f, &NewRect); - UI()->DoLabel(&NewRect, pText, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(pRect, pText, FontSize, TEXTALIGN_MC); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, 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), 3.0f, CUIRect::CORNER_R); - UI()->DoLabel(pRect, pText?pText:"+", 10, CUI::ALIGN_CENTER); + UI()->DoLabel(pRect, pText?pText:"+", 10.0f, TEXTALIGN_MC); 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) { pRect->Draw(GetButtonColor(pID, Checked), 3.0f, CUIRect::CORNER_L); - UI()->DoLabel(pRect, pText?pText:"-", 10, CUI::ALIGN_CENTER); + UI()->DoLabel(pRect, pText?pText:"-", 10.0f, TEXTALIGN_MC); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -537,7 +513,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in str_format(aBuf, sizeof(aBuf),"%s %d", pLabel, Current); pRect->Draw(GetButtonColor(pID, 0)); pRect->y += pRect->h/2.0f-7.0f; - UI()->DoLabel(pRect, aBuf, 10, CUI::ALIGN_CENTER); + UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER); return Current; } @@ -2177,7 +2153,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * CUIRect Label, Shifter; Slot.VSplitMid(&Label, &Shifter); Shifter.HMargin(1.0f, &Shifter); - UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, TEXTALIGN_LEFT); if(pProps[i].m_Type == PROPTYPE_INT_STEP) { @@ -2188,7 +2164,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * Shifter.VSplitLeft(10.0f, &Dec, &Shifter); str_format(aBuf, sizeof(aBuf),"%d", pProps[i].m_Value); Shifter.Draw(vec4(1,1,1,0.5f), 0.0f, CUIRect::CORNER_NONE); - UI()->DoLabel(&Shifter, aBuf, 10.0f,CUI::ALIGN_CENTER); + UI()->DoLabel(&Shifter, aBuf, 10.0f,TEXTALIGN_CENTER); if(DoButton_ButtonDec(&pIDs[i], 0, 0, &Dec, 0, "Decrease")) { @@ -2306,11 +2282,11 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int * Left.VSplitLeft(10.0f, &Left, &Shifter); Shifter.VSplitRight(10.0f, &Shifter, &Right); Shifter.Draw(vec4(1,1,1,0.5f), 0.0f, CUIRect::CORNER_NONE); - UI()->DoLabel(&Shifter, "X", 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Shifter, "X", 10.0f, TEXTALIGN_CENTER); Up.VSplitLeft(10.0f, &Up, &Shifter); Shifter.VSplitRight(10.0f, &Shifter, &Down); Shifter.Draw(vec4(1,1,1,0.5f), 0.0f, CUIRect::CORNER_NONE); - UI()->DoLabel(&Shifter, "Y", 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_CENTER); if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left")) { *pNewVal = 1; @@ -2671,7 +2647,7 @@ void CEditor::RenderImagesList(CUIRect ToolBox) if(ImageCur >= ImageStartAt) { ToolBox.HSplitTop(HeaderHeight, &Slot, &ToolBox); - UI()->DoLabel(&Slot, e == 0 ? "Embedded" : "External", 12.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Slot, e == 0 ? "Embedded" : "External", 12.0f, TEXTALIGN_CENTER); } ImageCur += HeaderHeight; @@ -2869,7 +2845,7 @@ void CEditor::RenderFileDialog() // title Title.Draw(vec4(1, 1, 1, 0.25f), 4.0f); Title.VMargin(10.0f, &Title); - UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, TEXTALIGN_LEFT); // pathbox char aPath[128], aBuf[128]; @@ -2878,12 +2854,12 @@ void CEditor::RenderFileDialog() else aPath[0] = 0; str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath); - UI()->DoLabel(&PathBox, aBuf, 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&PathBox, aBuf, 10.0f, TEXTALIGN_LEFT); // filebox if(m_FileDialogStorageType == IStorage::TYPE_SAVE) { - UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, TEXTALIGN_LEFT); static CLineInput s_FileNameInput(m_aFileDialogFileName, sizeof(m_aFileDialogFileName)); if(DoEditBox(&s_FileNameInput, &FileBox, 10.0f)) { @@ -2897,7 +2873,7 @@ void CEditor::RenderFileDialog() else { // render search bar - UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, TEXTALIGN_LEFT); if(DoEditBox(&m_FileDialogFilterInput, &FileBox, 10.0f)) { // reset scrolling @@ -3218,10 +3194,10 @@ void CEditor::RenderStatusbar(CUIRect View) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s Right click for context menu.", m_pTooltip); - UI()->DoLabel(&View, aBuf, 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&View, aBuf, 10.0f, TEXTALIGN_LEFT); } else - UI()->DoLabel(&View, m_pTooltip, 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&View, m_pTooltip, 10.0f, TEXTALIGN_LEFT); } } @@ -3299,7 +3275,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) char aBuf[IO_MAX_PATH_LENGTH]; str_format(aBuf, sizeof(aBuf),"%d/%d", m_SelectedEnvelope+1, m_Map.m_lEnvelopes.size()); Shifter.Draw(vec4(1,1,1,0.5f), 0.0f, CUIRect::CORNER_NONE); - UI()->DoLabel(&Shifter, aBuf, 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&Shifter, aBuf, 10.0f, TEXTALIGN_CENTER); static int s_PrevButton = 0; if(DoButton_ButtonDec(&s_PrevButton, 0, 0, &Dec, 0, "Previous Envelope")) @@ -3313,7 +3289,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) { ToolBar.VSplitLeft(15.0f, &Button, &ToolBar); ToolBar.VSplitLeft(35.0f, &Button, &ToolBar); - UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT); ToolBar.VSplitLeft(80.0f, &Button, &ToolBar); @@ -3376,7 +3352,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) ToolBar.VSplitLeft(4.0f, &Button, &ToolBar); ToolBar.VSplitLeft(80.0f, &Button, &ToolBar); - UI()->DoLabel(&Button, "Synchronized", 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&Button, "Synchronized", 10.0f, TEXTALIGN_LEFT); } float EndTime = pEnvelope->EndTime(); @@ -3862,7 +3838,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View) char aBuf[512]; str_format(aBuf, sizeof(aBuf),"%.3f %.3f", CurrentTime/1000.0f, fx2f(CurrentValue)); - UI()->DoLabel(&ToolBar, aBuf, 10.0f, CUI::ALIGN_CENTER); + UI()->DoLabel(&ToolBar, aBuf, 10.0f, TEXTALIGN_CENTER); } } } @@ -3884,10 +3860,10 @@ void CEditor::RenderMenubar(CUIRect MenuBar) char aBuf[128]; str_format(aBuf, sizeof(aBuf), "File: %s", m_aFileName); - UI()->DoLabel(&MenuBar, aBuf, 10.0f, CUI::ALIGN_LEFT); + UI()->DoLabel(&MenuBar, aBuf, 10.0f, TEXTALIGN_LEFT); str_format(aBuf, sizeof(aBuf), "Z: %i, A: %.1f, G: %i", m_ZoomLevel, m_AnimateSpeed, m_GridFactor); - UI()->DoLabel(&Info, aBuf, 10.0f, CUI::ALIGN_RIGHT); + UI()->DoLabel(&Info, aBuf, 10.0f, TEXTALIGN_RIGHT); // Exit editor button static int s_ExitButton; diff --git a/src/game/editor/popups.cpp b/src/game/editor/popups.cpp index a0ecd36a4..98934886a 100644 --- a/src/game/editor/popups.cpp +++ b/src/game/editor/popups.cpp @@ -181,7 +181,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) { View.HSplitBottom(5.0f, &View, &Button); View.HSplitBottom(16.0f, &View, &Button); - pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT); Button.VSplitLeft(40.0f, 0, &Button); static CLineInput s_NameInput; s_NameInput.SetBuffer(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName, sizeof(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName)); @@ -272,7 +272,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View) { View.HSplitBottom(5.0f, &View, &Button); View.HSplitBottom(16.0f, &View, &Button); - pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT); Button.VSplitLeft(40.0f, 0, &Button); static CLineInput s_NameInput; s_NameInput.SetBuffer(pCurrentLayer->m_aName, sizeof(pCurrentLayer->m_aName)); @@ -625,7 +625,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View) // title View.HSplitTop(10.0f, 0, &View); View.HSplitTop(30.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, TEXTALIGN_CENTER); View.HSplitBottom(10.0f, &View, 0); View.HSplitBottom(20.0f, &View, &ButtonBar); @@ -639,7 +639,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View) static CLineInput s_FolderInput(pEditor->m_aFileDialogNewFolderName, sizeof(pEditor->m_aFileDialogNewFolderName)); pEditor->DoEditBox(&s_FolderInput, &Label, 15.0f); View.HSplitBottom(20.0f, &View, &Label); - pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, TEXTALIGN_LEFT); // button bar ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar); @@ -673,9 +673,9 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View) View.HSplitTop(30.0f, 0, &View); View.VMargin(40.0f, &View); View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Error:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Error:", 10.0f, TEXTALIGN_LEFT); View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Unable to create the folder", 10.0f, CUI::ALIGN_LEFT, View.w); + pEditor->UI()->DoLabel(&Label, "Unable to create the folder", 10.0f, TEXTALIGN_LEFT, View.w); // button ButtonBar.VMargin(ButtonBar.w/2.0f-55.0f, &ButtonBar); @@ -694,7 +694,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) // title View.HSplitTop(10.0f, 0, &View); View.HSplitTop(30.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, TEXTALIGN_CENTER); View.HSplitBottom(10.0f, &View, 0); View.HSplitBottom(20.0f, &View, &ButtonBar); @@ -703,7 +703,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) // author box View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, TEXTALIGN_LEFT); Label.VSplitLeft(40.0f, 0, &Button); Button.HSplitTop(16.0f, &Button, 0); static CLineInput s_AuthorInput; @@ -712,7 +712,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) // version box View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, TEXTALIGN_LEFT); Label.VSplitLeft(40.0f, 0, &Button); Button.HSplitTop(16.0f, &Button, 0); static CLineInput s_VersionInput; @@ -721,7 +721,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) // credits box View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, TEXTALIGN_LEFT); Label.VSplitLeft(40.0f, 0, &Button); Button.HSplitTop(16.0f, &Button, 0); static CLineInput s_CreditsInput; @@ -730,7 +730,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View) // license box View.HSplitTop(20.0f, &Label, &View); - pEditor->UI()->DoLabel(&Label, "License:", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "License:", 10.0f, TEXTALIGN_LEFT); Label.VSplitLeft(40.0f, 0, &Button); Button.HSplitTop(16.0f, &Button, 0); static CLineInput s_LicenseInput; @@ -767,15 +767,15 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View) View.HSplitTop(10.0f, 0, &View); View.HSplitTop(30.0f, &Label, &View); if(pEditor->m_PopupEventType == POPEVENT_EXIT) - pEditor->UI()->DoLabel(&Label, "Exit the editor", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Exit the editor", 20.0f, TEXTALIGN_CENTER); else if(pEditor->m_PopupEventType == POPEVENT_LOAD) - pEditor->UI()->DoLabel(&Label, "Load map", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Load map", 20.0f, TEXTALIGN_CENTER); else if(pEditor->m_PopupEventType == POPEVENT_LOAD_CURRENT) - pEditor->UI()->DoLabel(&Label, "Load current map", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Load current map", 20.0f, TEXTALIGN_CENTER); else if(pEditor->m_PopupEventType == POPEVENT_NEW) - pEditor->UI()->DoLabel(&Label, "New map", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "New map", 20.0f, TEXTALIGN_CENTER); else if(pEditor->m_PopupEventType == POPEVENT_SAVE) - pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, CUI::ALIGN_CENTER); + pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, TEXTALIGN_CENTER); View.HSplitBottom(10.0f, &View, 0); View.HSplitBottom(20.0f, &View, &ButtonBar); @@ -785,15 +785,15 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View) View.VMargin(40.0f, &View); View.HSplitTop(20.0f, &Label, &View); if(pEditor->m_PopupEventType == POPEVENT_EXIT) - pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you exit the editor.\nContinue anyway?", 10.0f, CUI::ALIGN_LEFT, Label.w-10.0f); + pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you exit the editor.\nContinue anyway?", 10.0f, TEXTALIGN_LEFT, Label.w-10.0f); else if(pEditor->m_PopupEventType == POPEVENT_LOAD) - pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you load a new map.\nContinue anyway?", 10.0f, CUI::ALIGN_LEFT, Label.w-10.0f); + pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you load a new map.\nContinue anyway?", 10.0f, TEXTALIGN_LEFT, Label.w-10.0f); else if(pEditor->m_PopupEventType == POPEVENT_LOAD_CURRENT) - pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you load the current map.\nContinue anyway?", 10.0f, CUI::ALIGN_LEFT, Label.w-10.0f); + pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you load the current map.\nContinue anyway?", 10.0f, TEXTALIGN_LEFT, Label.w-10.0f); else if(pEditor->m_PopupEventType == POPEVENT_NEW) - pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you create a new map.\nContinue anyway?", 10.0f, CUI::ALIGN_LEFT, Label.w-10.0f); + pEditor->UI()->DoLabel(&Label, "The map contains unsaved data, you might want to save it before you create a new map.\nContinue anyway?", 10.0f, TEXTALIGN_LEFT, Label.w-10.0f); else if(pEditor->m_PopupEventType == POPEVENT_SAVE) - pEditor->UI()->DoLabel(&Label, "The file already exists.\nDo you want to overwrite the map?", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "The file already exists.\nDo you want to overwrite the map?", 10.0f, TEXTALIGN_LEFT); // button bar ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar); @@ -1022,7 +1022,7 @@ int CEditor::PopupSelectConfigAutoMap(CEditor *pEditor, CUIRect View) CUIRect Label, Full, Live; View.VSplitMid(&Label, &View); - pEditor->UI()->DoLabel(&Label, "Type", 10.0f, CUI::ALIGN_LEFT); + pEditor->UI()->DoLabel(&Label, "Type", 10.0f, TEXTALIGN_LEFT); View.VSplitMid(&Full, &Live); if(pEditor->DoButton_ButtonDec(&s_aIds[0], "Full", !pLayer->m_LiveAutoMap, &Full, 0, "")) -- cgit v1.2.3