Merge pull request #1230 from cinaera/alignment

UI: Use alignment enums
This commit is contained in:
oy 2014-06-21 12:42:28 +02:00
commit c35b170503
14 changed files with 182 additions and 167 deletions

View file

@ -453,10 +453,10 @@ void CHud::RenderVoting()
const char *pNoKey = m_pClient->m_pBinds->GetKey("vote no");
str_format(aBuf, sizeof(aBuf), "%s - %s", pYesKey, Localize("Vote yes"));
Base.y += Base.h+1;
UI()->DoLabel(&Base, aBuf, 6.0f, -1);
UI()->DoLabel(&Base, aBuf, 6.0f, CUI::ALIGN_LEFT);
str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), pNoKey);
UI()->DoLabel(&Base, aBuf, 6.0f, 1);
UI()->DoLabel(&Base, aBuf, 6.0f, CUI::ALIGN_RIGHT);
}
void CHud::RenderCursor()

View file

@ -141,7 +141,7 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
}
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
if(TextFade)
{
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
@ -188,7 +188,7 @@ int CMenus::DoButton_MenuImage(const void *pID, const char *pText, int Checked,
Text.VSplitLeft(r, 0, &Text);
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Text, pText, Text.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
@ -205,7 +205,7 @@ void CMenus::DoButton_KeySelect(const void *pID, const char *pText, int Checked,
pRect->HMargin(1.0f, &Temp);
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
@ -222,7 +222,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
CUIRect Temp;
pRect->HMargin(pRect->h>=20.0f?2.0f:1.0f, &Temp);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
@ -240,7 +240,7 @@ int CMenus::DoButton_MenuTabTop(const void *pID, const char *pText, int Checked,
Temp.HMargin((Temp.h*FontFactor)/2.0f, &Temp);
TextRender()->TextColor(1.0f-FadeVal, 1.0f-FadeVal, 1.0f-FadeVal, 1.0f);
TextRender()->TextOutlineColor(0.0f+FadeVal, 0.0f+FadeVal, 0.0f+FadeVal, 0.25f);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
@ -259,7 +259,7 @@ int CMenus::DoButton_GridHeader(const void *pID, const char *pText, int Checked,
CUIRect Label;
pRect->VSplitLeft(5.0f, 0, &Label);
Label.y+=2.0f;
UI()->DoLabel(&Label, pText, pRect->h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, pText, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
if(Checked)
{
@ -317,8 +317,8 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
Graphics()->QuadsEnd();
t.y += 2.0f; // lame fix
UI()->DoLabel(&c, pBoxText, pRect->h*ms_FontmodHeight*0.6f, 0);
UI()->DoLabel(&t, pText, pRect->h*ms_FontmodHeight*0.8f, -1);
UI()->DoLabel(&c, pBoxText, pRect->h*ms_FontmodHeight*0.6f, CUI::ALIGN_CENTER);
UI()->DoLabel(&t, pText, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
return UI()->DoButtonLogic(pID, pText, 0, pRect);
}
@ -541,7 +541,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
UI()->ClipEnable(pRect);
Textbox.x -= *pOffset;
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, 0);
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, CUI::ALIGN_CENTER);
// render the cursor
if(UI()->LastActiveItem() == pID && !JustGotActive)
@ -553,7 +553,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
Textbox.x += (w-*pOffset-TextRender()->TextWidth(0, FontSize, "|", -1)/2);
if((2*time_get()/time_freq()) % 2) // make it blink
UI()->DoLabel(&Textbox, "|", FontSize, -1);
UI()->DoLabel(&Textbox, "|", FontSize, CUI::ALIGN_LEFT);
}
UI()->ClipDisable();
@ -570,7 +570,7 @@ void CMenus::DoEditBoxOption(void *pID, char *pOption, int OptionLength, const C
char aBuf[32];
str_format(aBuf, sizeof(aBuf), "%s:", pStr);
Label.y += 2.0f;
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
DoEditBox(pID, &EditBox, pOption, OptionLength, pRect->h*ms_FontmodHeight*0.8f, pOffset, Hidden);
}
@ -589,7 +589,7 @@ void CMenus::DoScrollbarOption(void *pID, int *pOption, const CUIRect *pRect, co
str_format(aBuf, sizeof(aBuf), "%s: \xe2\x88\x9e", pStr);
Label.VSplitLeft(Label.h+5.0f, 0, &Label);
Label.y += 2.0f;
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, -1);
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
ScrollBar.VMargin(4.0f, &ScrollBar);
*pOption = static_cast<int>(DoScrollbarH(pOption, &ScrollBar, (float)(*pOption-Min)/(float)(Max-Min))*(float)(Max-Min)+(float)Min+0.1f);
@ -627,7 +627,7 @@ float CMenus::DoDropdownMenu(void *pID, const CUIRect *pRect, const char *pStr,
// label
Label = Header;
Label.y += 2.0f;
UI()->DoLabel(&Label, pStr, Header.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, pStr, Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
if(UI()->DoButtonLogic(pID, 0, 0, &Header))
{
@ -656,10 +656,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, 0);
UI()->DoLabel(&Label, aBuf, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Value.y += 2.0f;
UI()->DoLabel(&Value, pValue, pRect->h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Value, pValue, pRect->h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current)
@ -784,7 +784,7 @@ void CMenus::UiDoListboxHeader(const CUIRect *pRect, const char *pTitle, float H
// draw header
View.HSplitTop(ms_ListheaderHeight, &Header, &View);
Header.y += 2.0f;
UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
View.HSplitTop(Spacing, &Header, &View);
@ -812,7 +812,7 @@ void CMenus::UiDoListboxStart(const void *pID, float RowHeight, const char *pBot
View.HSplitBottom(ms_ListheaderHeight, &View, &Footer);
Footer.VSplitLeft(10.0f, 0, &Footer);
Footer.y += 2.0f;
UI()->DoLabel(&Footer, pBottomText, Footer.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Footer, pBottomText, Footer.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
// prepare the scroll
@ -1191,7 +1191,7 @@ void CMenus::RenderMenubar(CUIRect r)
Box.HMargin(2.0f, &Box);
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
UI()->DoLabel(&Box, Localize("Demo"), Box.h*ms_FontmodHeight, 0);
UI()->DoLabel(&Box, Localize("Demo"), Box.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
@ -1292,7 +1292,7 @@ void CMenus::RenderLoading()
r.y = y+20;
r.w = w;
r.h = h;
UI()->DoLabel(&r, pCaption, 48.0f, 0, -1);
UI()->DoLabel(&r, pCaption, 48.0f, CUI::ALIGN_CENTER);
Graphics()->TextureClear();
Graphics()->QuadsBegin();
@ -1684,7 +1684,7 @@ int CMenus::Render()
const char *pTitle = "";
const char *pExtraText = "";
const char *pButtonText = "";
int ExtraAlign = 0;
CUI::EAlignment ExtraAlign = CUI::ALIGN_CENTER;
int NumOptions = 4;
if(m_Popup == POPUP_MESSAGE)
@ -1727,7 +1727,7 @@ int CMenus::Render()
pTitle = Localize("Disconnected");
pExtraText = Localize("The server is running a non-standard tuning on a pure game type.");
pButtonText = Localize("Ok");
ExtraAlign = -1;
ExtraAlign = CUI::ALIGN_LEFT;
}
else if(m_Popup == POPUP_DELETE_DEMO)
{
@ -1750,7 +1750,7 @@ int CMenus::Render()
pTitle = Localize("Save skin");
pExtraText = Localize("Are you sure you want to save your skin? If a skin with this name already exists, it will be replaced.");
NumOptions = 6;
ExtraAlign = -1;
ExtraAlign = CUI::ALIGN_LEFT;
}
else if(m_Popup == POPUP_DELETE_SKIN)
{
@ -1762,7 +1762,7 @@ int CMenus::Render()
pTitle = Localize("Sound error");
pExtraText = Localize("The audio device couldn't be initialised.");
pButtonText = Localize("Ok");
ExtraAlign = -1;
ExtraAlign = CUI::ALIGN_LEFT;
}
else if(m_Popup == POPUP_PASSWORD)
{
@ -1780,7 +1780,7 @@ int CMenus::Render()
pExtraText = Localize("As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server.");
pButtonText = Localize("Enter");
NumOptions = 6;
ExtraAlign = -1;
ExtraAlign = CUI::ALIGN_LEFT;
}
CUIRect Box, Part, BottomBar;
@ -1800,7 +1800,7 @@ int CMenus::Render()
// headline
Box.HSplitTop(ButtonHeightBig, &Part, &Box);
Part.y += 3.0f;
UI()->DoLabel(&Part, pTitle, Part.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Part, pTitle, Part.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// inner box
Box.HSplitTop(SpacingH, 0, &Box);
@ -1902,7 +1902,7 @@ int CMenus::Render()
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, ButtonHeight*ms_FontmodHeight*0.8f, 0, -1);
UI()->DoLabel(&Part, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// time left
const char *pTimeLeftString;
@ -1917,7 +1917,7 @@ int CMenus::Render()
Box.HSplitTop(SpacingH, 0, &Box);
Box.HSplitTop(ButtonHeight, &Part, &Box);
str_format(aBuf, sizeof(aBuf), pTimeLeftString, TimeLeft);
UI()->DoLabel(&Part, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, 0, -1);
UI()->DoLabel(&Part, aBuf, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// progress bar
Box.HSplitTop(SpacingH, 0, &Box);
@ -1984,12 +1984,12 @@ int CMenus::Render()
{
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
else
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, CUI::ALIGN_CENTER);
}
}

View file

@ -344,7 +344,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect *pRect, const CServerInfo *p
if(g_Config.m_BrFilterString[0] && (pEntry->m_QuickSearchHit&IServerBrowser::QUICK_PLAYER))
TextRender()->TextColor(0.4f, 0.4f, 1.0f, TextAplpha);
Button.y += 2.0f;
UI()->DoLabel(&Button, aTemp, 12.0f, 0);
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_CENTER);
}
else if(ID == COL_PING)
{
@ -380,7 +380,7 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect *pRect, const CServerInfo *p
str_format(aTemp, sizeof(aTemp), "%d", pEntry->m_Latency);
TextRender()->TextColor(Color.r, Color.g, Color.b, Color.a);
Button.y += 2.0f;
UI()->DoLabel(&Button, aTemp, 12.0f, 0);
UI()->DoLabel(&Button, aTemp, 12.0f, CUI::ALIGN_CENTER);
}
else if(ID == COL_GAMETYPE)
{
@ -443,10 +443,10 @@ bool 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, -1);
UI()->DoLabel(&View, pFilter->Name(), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
/*if(pFilter->Custom() <= CBrowserFilter::FILTER_ALL)
UI()->DoLabel(&View, pFilter->Name(), 12.0f, -1);
UI()->DoLabel(&View, pFilter->Name(), 12.0f, CUI::ALIGN_LEFT);
else
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BROWSEICONS].m_Id);
@ -460,7 +460,7 @@ bool CMenus::RenderFilterHeader(CUIRect View, int FilterIndex)
Graphics()->QuadsEnd();
Label.VSplitLeft(25.0f, 0, &Label);
UI()->DoLabel(&Label, pFilter->Name(), 12.0f, -1);
UI()->DoLabel(&Label, pFilter->Name(), 12.0f, CUI::ALIGN_LEFT);
}*/
EditButtons.VSplitRight(ButtonHeight, &EditButtons, &Button);
@ -553,11 +553,11 @@ void CMenus::RenderServerbrowserOverlay()
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Servers"), pFilter->NumSortedServers());
UI()->DoLabel(&View, aBuf, 12.0f, 0);
UI()->DoLabel(&View, aBuf, 12.0f, CUI::ALIGN_CENTER);
View.HSplitMid(0, &View);
str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Players"), pFilter->NumPlayers());
UI()->DoLabel(&View, aBuf, 12.0f, 0);
UI()->DoLabel(&View, aBuf, 12.0f, CUI::ALIGN_CENTER);
}
else if(Type == CInfoOverlay::OVERLAY_SERVERINFO)
{
@ -707,7 +707,7 @@ void CMenus::RenderServerbrowserOverlay()
RenderTools()->DrawUIRect(&View, vec4(1.0f, 1.0f, 1.0f, 0.75f), CUI::CORNER_ALL, 6.0f);
View.y += 2.0f;
UI()->DoLabel(&View, Localize("no players"), View.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&View, Localize("no players"), View.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
@ -861,11 +861,11 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
MsgBox.y += View.h/3;
if(m_ActivePage == PAGE_INTERNET && ServerBrowser()->IsRefreshingMasters())
UI()->DoLabelScaled(&MsgBox, Localize("Refreshing master servers"), 16.0f, 0);
UI()->DoLabelScaled(&MsgBox, Localize("Refreshing master servers"), 16.0f, CUI::ALIGN_CENTER);
else if(!ServerBrowser()->NumServers())
UI()->DoLabelScaled(&MsgBox, Localize("No servers found"), 16.0f, 0);
UI()->DoLabelScaled(&MsgBox, Localize("No servers found"), 16.0f, CUI::ALIGN_CENTER);
/*else if(ServerBrowser()->NumServers() && !NumServers)
UI()->DoLabelScaled(&MsgBox, Localize("No servers match your filter criteria"), 16.0f, 0);*/
UI()->DoLabelScaled(&MsgBox, Localize("No servers match your filter criteria"), 16.0f, CUI::ALIGN_CENTER);*/
}
// count all the servers
@ -1091,7 +1091,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
Left.HSplitTop(ButtonHeight, &Label, &Left);
Label.VSplitRight(ButtonWidth*2.0f+SpacingH, &Label, &EditBox);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Search:"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Search:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
EditBox.VSplitRight(EditBox.h, &EditBox, &Button);
static float s_ClearOffset = 0.0f;
if(DoEditBox(&g_Config.m_BrFilterString, &EditBox, g_Config.m_BrFilterString, sizeof(g_Config.m_BrFilterString), ButtonHeight*ms_FontmodHeight*0.8f, &s_ClearOffset, false, CUI::CORNER_ALL))
@ -1112,7 +1112,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
Left.HSplitTop(ButtonHeight, &Label, 0);
Label.VSplitRight(ButtonWidth*2.0f+SpacingH, &Label, &EditBox);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Host address:"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Host address:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
static float s_AddressOffset = 0.0f;
DoEditBox(&g_Config.m_UiServerAddress, &EditBox, g_Config.m_UiServerAddress, sizeof(g_Config.m_UiServerAddress), ButtonHeight*ms_FontmodHeight*0.8f, &s_AddressOffset, false, CUI::CORNER_ALL);
@ -1125,7 +1125,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
else
str_format(aBuf, sizeof(aBuf), Localize("%d servers, %d players"), ServerBrowser()->NumServers(), NumPlayers);
Status.y += 2.0f;
UI()->DoLabel(&Status, aBuf, 14.0f, 0);
UI()->DoLabel(&Status, aBuf, 14.0f, CUI::ALIGN_CENTER);
}
void CMenus::RenderServerbrowserFilters(CUIRect View)
@ -1138,7 +1138,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
ServerFilter.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFilter);
RenderTools()->DrawUIRect(&FilterHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
RenderTools()->DrawUIRect(&ServerFilter, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize+2.0f, 0);
UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize+2.0f, CUI::ALIGN_CENTER);
CUIRect Button;
ServerFilter.VSplitLeft(5.0f, 0, &ServerFilter);
@ -1193,7 +1193,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
ServerFilter.HSplitTop(5.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, -1);
UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, CUI::ALIGN_LEFT);
Button.VSplitRight(60.0f, 0, &Button);
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
static float Offset = 0.0f;
@ -1205,7 +1205,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
CUIRect EditBox;
Button.VSplitRight(60.0f, &Button, &EditBox);
UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, -1);
UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, CUI::ALIGN_LEFT);
char aBuf[5];
str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing);
@ -1217,7 +1217,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
// server address
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, -1);
UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, CUI::ALIGN_LEFT);
Button.VSplitRight(60.0f, 0, &Button);
static float OffsetAddr = 0.0f;
if(DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &OffsetAddr))
@ -1285,7 +1285,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View, const CServerInfo *pI
ServerDetails.HSplitTop(ms_ListheaderHeight, &ServerHeader, &ServerDetails);
RenderTools()->DrawUIRect(&ServerHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
RenderTools()->DrawUIRect(&ServerDetails, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
UI()->DoLabelScaled(&ServerHeader, Localize("Server details"), FontSize+2.0f, 0);
UI()->DoLabelScaled(&ServerHeader, Localize("Server details"), FontSize+2.0f, CUI::ALIGN_CENTER);
if(pInfo)
{
@ -1307,7 +1307,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View, const CServerInfo *pI
for (unsigned int i = 0; i < sizeof(s_aLabels) / sizeof(s_aLabels[0]); i++)
{
LeftColumn.HSplitTop(15.0f, &Row, &LeftColumn);
UI()->DoLabelScaled(&Row, s_aLabels[i], FontSize, -1);
UI()->DoLabelScaled(&Row, s_aLabels[i], FontSize, CUI::ALIGN_LEFT);
}
RightColumn.HSplitTop(15.0f, &Row, &RightColumn);
@ -1335,7 +1335,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View, const CServerInfo *pI
ServerScoreBoard.HSplitTop(ms_ListheaderHeight, &ServerHeader, &ServerScoreBoard);
RenderTools()->DrawUIRect(&ServerHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
RenderTools()->DrawUIRect(&ServerScoreBoard, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
UI()->DoLabelScaled(&ServerHeader, Localize("Scoreboard"), FontSize+2.0f, 0);
UI()->DoLabelScaled(&ServerHeader, Localize("Scoreboard"), FontSize+2.0f, CUI::ALIGN_CENTER);
ServerScoreBoard.Margin(3.0f, &ServerScoreBoard);
for (int i = 0; i < pInfo->m_NumClients; i++)
@ -1451,7 +1451,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFriends);
RenderTools()->DrawUIRect(&FilterHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
RenderTools()->DrawUIRect(&ServerFriends, vec4(0,0,0,0.15f), 0, 4.0f);
UI()->DoLabelScaled(&FilterHeader, Localize("Friends"), FontSize+4.0f, 0);
UI()->DoLabelScaled(&FilterHeader, Localize("Friends"), FontSize+4.0f, CUI::ALIGN_CENTER);
CUIRect Button, List;
ServerFriends.Margin(3.0f, &ServerFriends);
@ -1480,15 +1480,15 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
Item.m_Rect.VMargin(2.5f, &Item.m_Rect);
Item.m_Rect.HSplitTop(12.0f, &Item.m_Rect, &Button);
UI()->DoLabelScaled(&Item.m_Rect, m_lFriends[i].m_pFriendInfo->m_aName, FontSize, -1);
UI()->DoLabelScaled(&Button, m_lFriends[i].m_pFriendInfo->m_aClan, FontSize, -1);
UI()->DoLabelScaled(&Item.m_Rect, m_lFriends[i].m_pFriendInfo->m_aName, FontSize, CUI::ALIGN_LEFT);
UI()->DoLabelScaled(&Button, m_lFriends[i].m_pFriendInfo->m_aClan, FontSize, CUI::ALIGN_LEFT);
RenderTools()->DrawUIRect(&OnState, m_lFriends[i].m_NumFound ? vec4(0.0f, 1.0f, 0.0f, 0.25f) : vec4(1.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_R, 4.0f);
OnState.HMargin((OnState.h-FontSize)/3, &OnState);
OnState.VMargin(5.0f, &OnState);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%i", m_lFriends[i].m_NumFound);
UI()->DoLabelScaled(&OnState, aBuf, FontSize+2, 1);
UI()->DoLabelScaled(&OnState, aBuf, FontSize+2, CUI::ALIGN_RIGHT);
}
}
@ -1545,7 +1545,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
UI()->DoLabelScaled(&Button, aBuf, FontSize, -1);
UI()->DoLabelScaled(&Button, aBuf, FontSize, CUI::ALIGN_LEFT);
Button.VSplitLeft(80.0f, 0, &Button);
static char s_aName[MAX_NAME_LENGTH] = {0};
static float s_OffsetName = 0.0f;
@ -1554,7 +1554,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
ServerFriends.HSplitTop(3.0f, 0, &ServerFriends);
ServerFriends.HSplitTop(19.0f, &Button, &ServerFriends);
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
UI()->DoLabelScaled(&Button, aBuf, FontSize, -1);
UI()->DoLabelScaled(&Button, aBuf, FontSize, CUI::ALIGN_LEFT);
Button.VSplitLeft(80.0f, 0, &Button);
static char s_aClan[MAX_CLAN_LENGTH] = {0};
static float s_OffsetClan = 0.0f;

View file

@ -70,7 +70,7 @@ void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View, float ButtonHeigh
str_format(aBuf, sizeof(aBuf), "%s:", (const char *)Key.m_Name);
Label.y += 2.0f;
UI()->DoLabelScaled(&Label, aBuf, 13.0f, 0);
UI()->DoLabelScaled(&Label, aBuf, 13.0f, CUI::ALIGN_CENTER);
int OldId = Key.m_KeyId;
int NewId = DoKeyReader((void *)&gs_aKeys[i].m_Name, &Button, OldId);
if(NewId != OldId)

View file

@ -25,7 +25,7 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, const CUIRec
float *pFade = ButtonFade(pID, Seconds);
RenderTools()->DrawUIRect(pRect, vec4(1,1,1, 0.5f+(*pFade/Seconds)*0.25f), CUI::CORNER_ALL, 5.0f);
UI()->DoLabel(pRect, pText, 14.0f, 0);
UI()->DoLabel(pRect, pText, 14.0f, CUI::ALIGN_CENTER);
return UI()->DoButtonLogic(pID, pText, false, pRect);
}
@ -98,7 +98,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, 0);
UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, CUI::ALIGN_CENTER);
// do the logic
int Inside = UI()->MouseInside(&SeekBar);
@ -194,7 +194,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
str_format(aBuffer, sizeof(aBuffer), "x%.0f", pInfo->m_Speed);
else
str_format(aBuffer, sizeof(aBuffer), "x%.2f", pInfo->m_Speed);
UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, -1);
UI()->DoLabel(&ButtonBar, aBuffer, Button.h*0.7f, CUI::ALIGN_LEFT);
// close button
ButtonBar.VSplitRight(ButtonbarHeight*3, &ButtonBar, &Button);
@ -347,14 +347,14 @@ void CMenus::RenderDemoList(CUIRect MainView)
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
Item.m_Rect.y += 2.0f;
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
else
{
Item.m_Rect.y += 2.0f;
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
}
}
@ -374,7 +374,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
MainView.HSplitTop(ButtonHeight, &Label, &MainView);
Label.y += 2.0f;
UI()->DoLabel(&Label, aFooterLabel, ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, aFooterLabel, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
if(!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid)
{
MainView.HSplitTop(Spacing, 0, &MainView);

View file

@ -81,7 +81,7 @@ void CMenus::RenderGame(CUIRect MainView)
MainView.HSplitTop(45.0f, &Bar, &MainView);
RenderTools()->DrawUIRect(&Bar, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);
Bar.HMargin(15.0f, &Bar);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, 0);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER);
}
// join buttons
@ -196,12 +196,12 @@ void CMenus::RenderPlayers(CUIRect MainView)
RenderTools()->DrawUIRect(&Options, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
Options.Margin(10.0f, &Options);
Options.HSplitTop(50.0f, &Button, &Options);
UI()->DoLabelScaled(&Button, Localize("Player options"), 34.0f, -1);
UI()->DoLabelScaled(&Button, Localize("Player options"), 34.0f, CUI::ALIGN_LEFT);
// headline
Options.HSplitTop(34.0f, &ButtonBar, &Options);
ButtonBar.VSplitRight(220.0f, &Player, &ButtonBar);
UI()->DoLabelScaled(&Player, Localize("Player"), 24.0f, -1);
UI()->DoLabelScaled(&Player, Localize("Player"), 24.0f, CUI::ALIGN_LEFT);
ButtonBar.HMargin(1.0f, &ButtonBar);
float Width = ButtonBar.h*2.0f;
@ -405,7 +405,7 @@ void CMenus::RenderServerControlServer(CUIRect MainView)
CListboxItem Item = UiDoListboxNextItem(pOption);
if(Item.m_Visible)
UI()->DoLabelScaled(&Item.m_Rect, pOption->m_aDescription, 16.0f, -1);
UI()->DoLabelScaled(&Item.m_Rect, pOption->m_aDescription, 16.0f, CUI::ALIGN_LEFT);
}
m_CallvoteSelectedOption = UiDoListboxEnd(&s_ScrollValue, 0);
@ -448,7 +448,7 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators)
Item.m_Rect.HSplitTop(5.0f, 0, &Item.m_Rect); // some margin from the top
RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1,0), vec2(Item.m_Rect.x+Item.m_Rect.h/2, Item.m_Rect.y+Item.m_Rect.h/2));
Item.m_Rect.x +=Info.m_Size;
UI()->DoLabelScaled(&Item.m_Rect, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, -1);
UI()->DoLabelScaled(&Item.m_Rect, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, CUI::ALIGN_LEFT);
}
}
@ -507,7 +507,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
MainView.HSplitTop(45.0f, &Bar, &MainView);
RenderTools()->DrawUIRect(&Bar, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 10.0f);
Bar.HMargin(15.0f, &Bar);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, 0);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER);
return;
}
@ -552,7 +552,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
MainView.HSplitTop(45.0f, &Bar, &MainView);
RenderTools()->DrawUIRect(&Bar, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_B, 10.0f);
Bar.HMargin(15.0f, &Bar);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, 0);
UI()->DoLabelScaled(&Bar, pNotification, 14.0f, CUI::ALIGN_CENTER);
return;
}
@ -583,7 +583,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
Reason.HSplitTop(5.0f, 0, &Reason);
Reason.VSplitRight(Reason.h, &Reason, &ClearButton);
const char *pLabel = Localize("Reason:");
UI()->DoLabelScaled(&Reason, pLabel, 14.0f, -1);
UI()->DoLabelScaled(&Reason, pLabel, 14.0f, CUI::ALIGN_LEFT);
float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1);
Reason.VSplitLeft(w+10.0f, 0, &Reason);
static float s_Offset = 0.0f;
@ -594,7 +594,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
static int s_ClearButton = 0;
float *pClearButtonFade = ButtonFade(&s_ClearButton, 0.6f);
RenderTools()->DrawUIRect(&ClearButton, vec4(1.0f, 1.0f, 1.0f, 0.33f+(*pClearButtonFade/0.6f)*0.165f), CUI::CORNER_R, 3.0f);
UI()->DoLabel(&ClearButton, "x", ClearButton.h*ms_FontmodHeight, 0);
UI()->DoLabel(&ClearButton, "x", ClearButton.h*ms_FontmodHeight, CUI::ALIGN_CENTER);
if(UI()->DoButtonLogic(&s_ClearButton, "x", 0, &ClearButton))
m_aCallvoteReason[0] = 0;
}
@ -609,7 +609,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
else
{
// print notice
UI()->DoLabelScaled(&Bottom, pNotification, 14.0f, -1, Bottom.w);
UI()->DoLabelScaled(&Bottom, pNotification, 14.0f, CUI::ALIGN_LEFT, Bottom.w);
}
// extended features (only available when authed in rcon)
@ -641,10 +641,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
Extended.HSplitTop(20.0f, &Bottom, &Extended);
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &Button, &Bottom);
UI()->DoLabelScaled(&Button, Localize("Vote description:"), 14.0f, -1);
UI()->DoLabelScaled(&Button, Localize("Vote description:"), 14.0f, CUI::ALIGN_LEFT);
Bottom.VSplitLeft(20.0f, 0, &Button);
UI()->DoLabelScaled(&Button, Localize("Vote command:"), 14.0f, -1);
UI()->DoLabelScaled(&Button, Localize("Vote command:"), 14.0f, CUI::ALIGN_LEFT);
static char s_aVoteDescription[64] = {0};
static char s_aVoteCommand[512] = {0};

View file

@ -103,7 +103,7 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View)
ServerFilter.HSplitTop(ms_ListheaderHeight, &FilterHeader, &ServerFilter);
pMenus->RenderTools()->DrawUIRect(&FilterHeader, vec4(1,1,1,0.25f), CUI::CORNER_T, 4.0f);
pMenus->RenderTools()->DrawUIRect(&ServerFilter, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f);
pMenus->UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize+2.0f, 0);
pMenus->UI()->DoLabelScaled(&FilterHeader, Localize("Server filter"), FontSize+2.0f, CUI::ALIGN_CENTER);
CUIRect Button;
ServerFilter.VSplitLeft(5.0f, 0, &ServerFilter);
@ -158,7 +158,7 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View)
ServerFilter.HSplitTop(5.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
pMenus->UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, -1);
pMenus->UI()->DoLabelScaled(&Button, Localize("Game types:"), FontSize, CUI::ALIGN_LEFT);
Button.VSplitRight(60.0f, 0, &Button);
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
static float Offset = 0.0f;
@ -171,7 +171,7 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View)
CUIRect EditBox;
Button.VSplitRight(60.0f, &Button, &EditBox);
pMenus->UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, -1);
pMenus->UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, CUI::ALIGN_LEFT);
char aBuf[5];
str_format(aBuf, sizeof(aBuf), "%d", Ping);
@ -186,7 +186,7 @@ int CMenus::PopupFilter(CMenus *pMenus, CUIRect View)
// server address
ServerFilter.HSplitTop(3.0f, 0, &ServerFilter);
ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter);
pMenus->UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, -1);
pMenus->UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, CUI::ALIGN_LEFT);
Button.VSplitRight(60.0f, 0, &Button);
static float OffsetAddr = 0.0f;
static int s_BrFilterServerAddress = 0;

View file

@ -148,7 +148,7 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
float HeaderHeight = 20.0f;
MainView.HSplitTop(HeaderHeight, &Label, &MainView);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Color"), HeaderHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Color"), HeaderHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
MainView.HSplitTop(Spacing, 0, &MainView);
// use custom color checkbox
@ -267,7 +267,7 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
RenderTools()->DrawUIRect(&Label, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
Label.VSplitLeft((Label.w-160.0f)/2.0f, &Label, &Button);
Label.y += 2.0f;
UI()->DoLabelScaled(&Label, apNames[i], SliderHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Label, apNames[i], SliderHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// button <
Button.VSplitLeft(Button.h, &Button, &Bar);
@ -368,7 +368,7 @@ void CMenus::RenderHSLPicker(CUIRect MainView)
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", *apVars[i]);
Label.y += 2.0f;
UI()->DoLabelScaled(&Label, aBuf, SliderHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Label, aBuf, SliderHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// logic
float X;
@ -645,12 +645,12 @@ void CMenus::RenderLanguageSelection(CUIRect MainView, bool Header)
{
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, -1);
UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
else
UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, -1);
UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
}
}
@ -694,7 +694,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, 0);
UI()->DoLabel(&Label, Localize("Game"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Game.HSplitTop(Spacing, 0, &Game);
Game.HSplitTop(ButtonHeight, &Button, &Game);
@ -764,7 +764,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, 0);
UI()->DoLabel(&Label, Localize("Client"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Client.HSplitTop(Spacing, 0, &Client);
Client.HSplitTop(ButtonHeight, &Button, &Client);
@ -845,7 +845,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
// render game menu
TopView.HSplitTop(ButtonHeight, &Label, &TopView);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Personal"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Personal"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// split menu
TopView.HSplitTop(Spacing, 0, &TopView);
@ -895,12 +895,12 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
{
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
else
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0);
UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, CUI::ALIGN_CENTER);
}
}
@ -932,7 +932,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, 0);
UI()->DoLabel(&Label, Localize("Customize"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// skin part selection
MainView.HSplitTop(SpacingH, 0, &MainView);
@ -989,7 +989,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Preview.HSplitTop(ButtonHeight, &Label, &Preview);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Skin"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Skin"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// Preview
{
@ -1007,7 +1007,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Left.VSplitMid(&Label, &Left);
Label.y += 17.0f;
UI()->DoLabelScaled(&Label, Localize("Normal:"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Label, Localize("Normal:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
RenderTools()->DrawUIRect(&Left, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
@ -1035,7 +1035,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
Right.VSplitLeft(Right.w/3.0f+SpacingW/2.0f, &Label, &Right);
Label.y += 17.0f;
UI()->DoLabelScaled(&Label, Localize("Team:"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Label, Localize("Team:"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Right.VSplitMid(&Left, &Right);
Left.VSplitRight(SpacingW/2.0f, &Left, 0);
@ -1066,7 +1066,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
RenderTools()->DrawUIRect(&Preview, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
Preview.y += 2.0f;
UI()->DoLabel(&Preview, g_Config.m_PlayerSkin, ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Preview, g_Config.m_PlayerSkin, ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
MainView.HSplitTop(10.0f, 0, &MainView);
@ -1199,7 +1199,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
// render screen menu
Screen.HSplitTop(ButtonHeight, &Label, &Screen);
Label.y += 2.0f;
UI()->DoLabel(&Label, Localize("Screen"), ButtonHeight*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Label, Localize("Screen"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Screen.HSplitTop(Spacing, 0, &Screen);
Screen.HSplitTop(ButtonHeight, &Button, &Screen);
@ -1248,7 +1248,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, -1);
UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
Button.VSplitLeft(70.0f, &Button, 0);
str_format(aBuf, sizeof(aBuf), "%dx", g_Config.m_GfxFsaaSamples);
@ -1268,7 +1268,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, 0);
UI()->DoLabel(&Label, Localize("Texture"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Texture.HSplitTop(Spacing, 0, &Texture);
Texture.HSplitTop(ButtonHeight, &Button, &Texture);
@ -1309,7 +1309,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
// draw header
MainView.HSplitTop(ButtonHeight, &Header, &MainView);
Header.y += 2.0f;
UI()->DoLabel(&Header, Localize("Resolutions"), Header.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Header, Localize("Resolutions"), Header.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// supported modes button
MainView.HSplitTop(Spacing, 0, &MainView);
@ -1352,13 +1352,13 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
char aBuf[32];
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Format"));
Text.y += 2.0f;
UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Unit.y += 2.0f;
if((float)m_aVideoFormats[m_CurrentVideoFormat].m_WidthValue/(float)m_aVideoFormats[m_CurrentVideoFormat].m_HeightValue >= 1.55f)
UI()->DoLabel(&Unit, Localize("Wide"), Unit.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Unit, Localize("Wide"), Unit.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
else
UI()->DoLabel(&Unit, Localize("Letterbox"), Unit.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Unit, Localize("Letterbox"), Unit.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
str_format(aBuf, sizeof(aBuf), "%d:%d", m_aVideoFormats[m_CurrentVideoFormat].m_WidthValue, m_aVideoFormats[m_CurrentVideoFormat].m_HeightValue);
static int s_VideoFormatButton = 0;
@ -1398,14 +1398,14 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
TextRender()->TextOutlineColor(1.0f, 1.0f, 1.0f, 0.25f);
Item.m_Rect.y += 2.0f;
UI()->DoLabelScaled(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
}
else
{
Item.m_Rect.y += 2.0f;
UI()->DoLabelScaled(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabelScaled(&Item.m_Rect, aBuf, Item.m_Rect.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
}
}
}
@ -1516,7 +1516,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, 0);
UI()->DoLabel(&Label, Localize("Sound"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Sound.HSplitTop(Spacing, 0, &Sound);
Sound.HSplitTop(ButtonHeight, &Button, &Sound);
@ -1556,7 +1556,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, 0);
UI()->DoLabel(&Label, Localize("Detail"), ButtonHeight*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
// split menu
CUIRect Left, Right;
@ -1577,10 +1577,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, 0);
UI()->DoLabel(&Text, aBuf, Text.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
Unit.y += 2.0f;
UI()->DoLabel(&Unit, "kHz", Unit.h*ms_FontmodHeight*0.8f, 0);
UI()->DoLabel(&Unit, "kHz", Unit.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
if(g_Config.m_SndRate != 48000 && g_Config.m_SndRate != 44100)
g_Config.m_SndRate = 48000;
@ -1660,7 +1660,7 @@ void CMenus::RenderSettings(CUIRect MainView)
// text
TextRender()->TextColor(0.973f, 0.863f, 0.207, 1.0f);
RestartWarning.y += 2.0f;
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), RestartWarning.h*ms_FontmodHeight*0.75f, 0);
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), RestartWarning.h*ms_FontmodHeight*0.75f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}

View file

@ -131,10 +131,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()->DoLabelScaled(&Version, aBuf, 14.0f, 0);
UI()->DoLabelScaled(&Version, aBuf, 14.0f, CUI::ALIGN_CENTER);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
UI()->DoLabelScaled(&Version, GAME_VERSION, 14.0f, 1);
UI()->DoLabelScaled(&Version, GAME_VERSION, 14.0f, CUI::ALIGN_RIGHT);
}
void CMenus::RenderLogo(CUIRect MainView)

View file

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

View file

@ -381,25 +381,33 @@ int CUI::DoButton(const void *id, const char *text, int checked, const CUIRect *
return ret;
}*/
void CUI::DoLabel(const CUIRect *r, const char *pText, float Size, int Align, int MaxWidth)
void CUI::DoLabel(const CUIRect *r, const char *pText, float Size, EAlignment Align, int MaxWidth)
{
// TODO: FIX ME!!!!
//Graphics()->BlendNormal();
if(Align == 0)
switch(Align)
{
case ALIGN_CENTER:
{
float tw = TextRender()->TextWidth(0, Size, pText, MaxWidth);
TextRender()->Text(0, r->x + r->w/2-tw/2, r->y - Size/10, Size, pText, MaxWidth);
break;
}
else if(Align < 0)
case ALIGN_LEFT:
{
TextRender()->Text(0, r->x, r->y - Size/10, Size, pText, MaxWidth);
else if(Align > 0)
break;
}
case ALIGN_RIGHT:
{
float tw = TextRender()->TextWidth(0, Size, pText, MaxWidth);
TextRender()->Text(0, r->x + r->w-tw, r->y - Size/10, Size, pText, MaxWidth);
break;
}
}
}
void CUI::DoLabelScaled(const CUIRect *r, const char *pText, float Size, int Align, int MaxWidth)
void CUI::DoLabelScaled(const CUIRect *r, const char *pText, float Size, EAlignment Align, int MaxWidth)
{
DoLabel(r, pText, Size*Scale(), Align, MaxWidth);
}

View file

@ -71,6 +71,13 @@ public:
CORNER_INV_ALL=CORNER_IT|CORNER_IB
};
enum EAlignment
{
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT,
};
int Update(float mx, float my, float Mwx, float Mwy, int m_Buttons);
float MouseX() const { return m_MouseX; }
@ -104,8 +111,8 @@ public:
int DoColorSelectionLogic(const CUIRect *pRect, const CUIRect *pButton);
// TODO: Refactor: Remove this?
void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1);
void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1);
void DoLabel(const CUIRect *pRect, const char *pText, float Size, EAlignment Align, int MaxWidth = -1);
void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, EAlignment Align, int MaxWidth = -1);
};

View file

@ -415,7 +415,7 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str
UI()->ClipEnable(pRect);
Textbox.x -= *Offset;
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1);
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, CUI::ALIGN_LEFT);
// render the cursor
if(UI()->LastActiveItem() == pID && !JustGotActive)
@ -426,7 +426,7 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str
Textbox.x += (w-*Offset-TextRender()->TextWidth(0, FontSize, "|", -1)/2);
if((2*time_get()/time_freq()) % 2) // make it blink
UI()->DoLabel(&Textbox, "|", FontSize, -1);
UI()->DoLabel(&Textbox, "|", FontSize, CUI::ALIGN_LEFT);
}
UI()->ClipDisable();
@ -553,7 +553,7 @@ int CEditor::DoButton_File(const void *pID, const char *pText, int Checked, cons
CUIRect t = *pRect;
t.VMargin(5.0f, &t);
UI()->DoLabel(&t, pText, 10, -1, -1);
UI()->DoLabel(&t, pText, 10, CUI::ALIGN_LEFT);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
}
@ -564,7 +564,7 @@ int CEditor::DoButton_Menu(const void *pID, const char *pText, int Checked, cons
r = *pRect;
r.VMargin(5.0f, &r);
UI()->DoLabel(&r, pText, 10, -1, -1);
UI()->DoLabel(&r, pText, 10, CUI::ALIGN_LEFT);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
}
@ -587,7 +587,7 @@ int CEditor::DoButton_Tab(const void *pID, const char *pText, int Checked, const
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_T, 5.0f);
CUIRect NewRect = *pRect;
NewRect.y += NewRect.h/2.0f-7.0f;
UI()->DoLabel(&NewRect, pText, 10, 0, -1);
UI()->DoLabel(&NewRect, pText, 10, CUI::ALIGN_CENTER);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
}
@ -596,21 +596,21 @@ int CEditor::DoButton_Ex(const void *pID, const char *pText, int Checked, const
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), Corners, 3.0f);
CUIRect NewRect = *pRect;
NewRect.HMargin(NewRect.h/2.0f-FontSize/2.0f-1.0f, &NewRect);
UI()->DoLabel(&NewRect, pText, FontSize, 0, -1);
UI()->DoLabel(&NewRect, pText, FontSize, CUI::ALIGN_CENTER);
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)
{
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_R, 3.0f);
UI()->DoLabel(pRect, pText?pText:"+", 10, 0, -1);
UI()->DoLabel(pRect, pText?pText:"+", 10, CUI::ALIGN_CENTER);
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)
{
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_L, 3.0f);
UI()->DoLabel(pRect, pText?pText:"-", 10, 0, -1);
UI()->DoLabel(pRect, pText?pText:"-", 10, CUI::ALIGN_CENTER);
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
}
@ -723,7 +723,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in
str_format(aBuf, sizeof(aBuf),"%s %d", pLabel, Current);
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, 0), CUI::CORNER_ALL, 5.0f);
pRect->y += pRect->h/2.0f-7.0f;
UI()->DoLabel(pRect, aBuf, 10, 0, -1);
UI()->DoLabel(pRect, aBuf, 10, CUI::ALIGN_CENTER);
return Current;
}
@ -2221,7 +2221,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, -1, -1);
UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, CUI::ALIGN_LEFT);
if(pProps[i].m_Type == PROPTYPE_INT_STEP)
{
@ -2232,7 +2232,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);
RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, aBuf, 10.0f, 0, -1);
UI()->DoLabel(&Shifter, aBuf, 10.0f,CUI::ALIGN_CENTER);
if(DoButton_ButtonDec(&pIDs[i], 0, 0, &Dec, 0, "Decrease"))
{
@ -2321,11 +2321,11 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
Left.VSplitLeft(10.0f, &Left, &Shifter);
Shifter.VSplitRight(10.0f, &Shifter, &Right);
RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, "X", 10.0f, 0, -1);
UI()->DoLabel(&Shifter, "X", 10.0f, CUI::ALIGN_CENTER);
Up.VSplitLeft(10.0f, &Up, &Shifter);
Shifter.VSplitRight(10.0f, &Shifter, &Down);
RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, "Y", 10.0f, 0, -1);
UI()->DoLabel(&Shifter, "Y", 10.0f, CUI::ALIGN_CENTER);
if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left"))
{
*pNewVal = 1;
@ -2743,9 +2743,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
ToolBox.HSplitTop(15.0f, &Slot, &ToolBox);
if(e == 0)
UI()->DoLabel(&Slot, "Embedded", 12.0f, 0);
UI()->DoLabel(&Slot, "Embedded", 12.0f, CUI::ALIGN_CENTER);
else
UI()->DoLabel(&Slot, "External", 12.0f, 0);
UI()->DoLabel(&Slot, "External", 12.0f, CUI::ALIGN_CENTER);
}
ImageCur += 15.0f;
@ -2913,7 +2913,7 @@ void CEditor::RenderFileDialog()
// title
RenderTools()->DrawUIRect(&Title, vec4(1, 1, 1, 0.25f), CUI::CORNER_ALL, 4.0f);
Title.VMargin(10.0f, &Title);
UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, -1, -1);
UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, CUI::ALIGN_LEFT);
// pathbox
char aPath[128], aBuf[128];
@ -2922,13 +2922,13 @@ void CEditor::RenderFileDialog()
else
aPath[0] = 0;
str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath);
UI()->DoLabel(&PathBox, aBuf, 10.0f, -1, -1);
UI()->DoLabel(&PathBox, aBuf, 10.0f, CUI::ALIGN_LEFT);
// filebox
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
{
static float s_FileBoxID = 0;
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, -1, -1);
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, CUI::ALIGN_LEFT);
if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID))
{
// remove '/' and '\'
@ -3195,10 +3195,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, -1, -1);
UI()->DoLabel(&View, aBuf, 10.0f, CUI::ALIGN_LEFT);
}
else
UI()->DoLabel(&View, m_pTooltip, 10.0f, -1, -1);
UI()->DoLabel(&View, m_pTooltip, 10.0f, CUI::ALIGN_LEFT);
}
}
@ -3276,7 +3276,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
char aBuf[512];
str_format(aBuf, sizeof(aBuf),"%d/%d", m_SelectedEnvelope+1, m_Map.m_lEnvelopes.size());
RenderTools()->DrawUIRect(&Shifter, vec4(1,1,1,0.5f), 0, 0.0f);
UI()->DoLabel(&Shifter, aBuf, 10.0f, 0, -1);
UI()->DoLabel(&Shifter, aBuf, 10.0f, CUI::ALIGN_CENTER);
static int s_PrevButton = 0;
if(DoButton_ButtonDec(&s_PrevButton, 0, 0, &Dec, 0, "Previous Envelope"))
@ -3290,7 +3290,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
{
ToolBar.VSplitLeft(15.0f, &Button, &ToolBar);
ToolBar.VSplitLeft(35.0f, &Button, &ToolBar);
UI()->DoLabel(&Button, "Name:", 10.0f, -1, -1);
UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT);
ToolBar.VSplitLeft(80.0f, &Button, &ToolBar);
@ -3358,7 +3358,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
ToolBar.VSplitLeft(4.0f, &Button, &ToolBar);
ToolBar.VSplitLeft(80.0f, &Button, &ToolBar);
UI()->DoLabel(&Button, "Synchronized", 10.0f, -1, -1);
UI()->DoLabel(&Button, "Synchronized", 10.0f, CUI::ALIGN_LEFT);
}
float EndTime = pEnvelope->EndTime();
@ -3850,7 +3850,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, 0, -1);
UI()->DoLabel(&ToolBar, aBuf, 10.0f, CUI::ALIGN_CENTER);
}
}
}
@ -3969,10 +3969,10 @@ void CEditor::RenderMenubar(CUIRect MenuBar)
MenuBar.VSplitLeft(MenuBar.w*0.75f, &MenuBar, &Info);
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "File: %s", m_aFileName);
UI()->DoLabel(&MenuBar, aBuf, 10.0f, -1, -1);
UI()->DoLabel(&MenuBar, aBuf, 10.0f, CUI::ALIGN_LEFT);
str_format(aBuf, sizeof(aBuf), "Z: %i, A: %.1f, G: %i", m_ZoomLevel, m_AnimateSpeed, m_GridFactor);
UI()->DoLabel(&Info, aBuf, 10.0f, 1, -1);
UI()->DoLabel(&Info, aBuf, 10.0f, CUI::ALIGN_RIGHT);
}
void CEditor::Render()

View file

@ -175,7 +175,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View)
View.HSplitBottom(5.0f, &View, &Button);
View.HSplitBottom(12.0f, &View, &Button);
static float s_Name = 0;
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, -1, -1);
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT);
Button.VSplitLeft(40.0f, 0, &Button);
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName, sizeof(pEditor->m_Map.m_lGroups[pEditor->m_SelectedGroup]->m_aName), 10.0f, &s_Name))
pEditor->m_Map.m_Modified = true;
@ -263,7 +263,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View)
View.HSplitBottom(5.0f, &View, &Button);
View.HSplitBottom(12.0f, &View, &Button);
static float s_Name = 0;
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, -1, -1);
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, CUI::ALIGN_LEFT);
Button.VSplitLeft(40.0f, 0, &Button);
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->GetSelectedLayer(0)->m_aName, sizeof(pEditor->GetSelectedLayer(0)->m_aName), 10.0f, &s_Name))
pEditor->m_Map.m_Modified = true;
@ -596,7 +596,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, 0);
pEditor->UI()->DoLabel(&Label, "Create new folder", 20.0f, CUI::ALIGN_CENTER);
View.HSplitBottom(10.0f, &View, 0);
View.HSplitBottom(20.0f, &View, &ButtonBar);
@ -610,7 +610,7 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View)
static float s_FolderBox = 0;
pEditor->DoEditBox(&s_FolderBox, &Label, pEditor->m_FileDialogNewFolderName, sizeof(pEditor->m_FileDialogNewFolderName), 15.0f, &s_FolderBox);
View.HSplitBottom(20.0f, &View, &Label);
pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, -1);
pEditor->UI()->DoLabel(&Label, "Name:", 10.0f, CUI::ALIGN_LEFT);
// button bar
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
@ -644,9 +644,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, -1);
pEditor->UI()->DoLabel(&Label, "Error:", 10.0f, CUI::ALIGN_LEFT);
View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Unable to create the folder", 10.0f, -1, View.w);
pEditor->UI()->DoLabel(&Label, "Unable to create the folder", 10.0f, CUI::ALIGN_LEFT, View.w);
// button
ButtonBar.VMargin(ButtonBar.w/2.0f-55.0f, &ButtonBar);
@ -665,7 +665,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, 0);
pEditor->UI()->DoLabel(&Label, "Map details", 20.0f, CUI::ALIGN_CENTER);
View.HSplitBottom(10.0f, &View, 0);
View.HSplitBottom(20.0f, &View, &ButtonBar);
@ -674,7 +674,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View)
// author box
View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, -1);
pEditor->UI()->DoLabel(&Label, "Author:", 10.0f, CUI::ALIGN_LEFT);
Label.VSplitLeft(40.0f, 0, &Button);
Button.HSplitTop(12.0f, &Button, 0);
static float s_AuthorBox = 0;
@ -682,7 +682,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View)
// version box
View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, -1);
pEditor->UI()->DoLabel(&Label, "Version:", 10.0f, CUI::ALIGN_LEFT);
Label.VSplitLeft(40.0f, 0, &Button);
Button.HSplitTop(12.0f, &Button, 0);
static float s_VersionBox = 0;
@ -690,7 +690,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View)
// credits box
View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, -1);
pEditor->UI()->DoLabel(&Label, "Credits:", 10.0f, CUI::ALIGN_LEFT);
Label.VSplitLeft(40.0f, 0, &Button);
Button.HSplitTop(12.0f, &Button, 0);
static float s_CreditsBox = 0;
@ -698,7 +698,7 @@ int CEditor::PopupMapInfo(CEditor *pEditor, CUIRect View)
// license box
View.HSplitTop(20.0f, &Label, &View);
pEditor->UI()->DoLabel(&Label, "License:", 10.0f, -1);
pEditor->UI()->DoLabel(&Label, "License:", 10.0f, CUI::ALIGN_LEFT);
Label.VSplitLeft(40.0f, 0, &Button);
Button.HSplitTop(12.0f, &Button, 0);
static float s_LicenseBox = 0;
@ -734,13 +734,13 @@ 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, 0);
pEditor->UI()->DoLabel(&Label, "Exit the editor", 20.0f, CUI::ALIGN_CENTER);
else if(pEditor->m_PopupEventType == POPEVENT_LOAD)
pEditor->UI()->DoLabel(&Label, "Load map", 20.0f, 0);
pEditor->UI()->DoLabel(&Label, "Load map", 20.0f, CUI::ALIGN_CENTER);
else if(pEditor->m_PopupEventType == POPEVENT_NEW)
pEditor->UI()->DoLabel(&Label, "New map", 20.0f, 0);
pEditor->UI()->DoLabel(&Label, "New map", 20.0f, CUI::ALIGN_CENTER);
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, 0);
pEditor->UI()->DoLabel(&Label, "Save map", 20.0f, CUI::ALIGN_CENTER);
View.HSplitBottom(10.0f, &View, 0);
View.HSplitBottom(20.0f, &View, &ButtonBar);
@ -750,13 +750,13 @@ 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, -1, 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, CUI::ALIGN_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, -1, 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, CUI::ALIGN_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, -1, 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, CUI::ALIGN_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, -1);
pEditor->UI()->DoLabel(&Label, "The file already exists.\nDo you want to overwrite the map?", 10.0f, CUI::ALIGN_LEFT);
// button bar
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);