mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Auto font size
This commit is contained in:
parent
fb20961cec
commit
95fe457abb
|
@ -213,7 +213,9 @@ int CMenus::DoButton_Menu(const void *pID, const char *pText, int Checked, const
|
|||
|
||||
Text.HMargin(pRect->h >= 20.0f ? 2.0f : 1.0f, &Text);
|
||||
Text.HMargin((Text.h * FontFactor) / 2.0f, &Text);
|
||||
UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, AlignVertically);
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = AlignVertically;
|
||||
UI()->DoLabel(&Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
|
||||
if(MouseInsideColorPicker)
|
||||
return 0;
|
||||
|
@ -305,7 +307,9 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co
|
|||
}
|
||||
|
||||
Rect.HMargin(2.0f, &Temp);
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, AlignVertically);
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = AlignVertically;
|
||||
UI()->DoLabel(&Temp, pText, Temp.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
|
||||
return UI()->DoButtonLogic(pID, pText, Checked, pRect);
|
||||
}
|
||||
|
@ -335,15 +339,17 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c
|
|||
RenderTools()->DrawUIRect(&c, ColorRGBA(1, 1, 1, 0.25f * UI()->ButtonColorMul(pID)), CUI::CORNER_ALL, 3.0f);
|
||||
|
||||
bool CheckAble = *pBoxText == 'X';
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
if(CheckAble)
|
||||
{
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
UI()->DoLabel(&c, "\xEE\x97\x8D", c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, 0);
|
||||
UI()->DoLabel(&c, "\xEE\x97\x8D", c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
}
|
||||
else
|
||||
UI()->DoLabel(&c, pBoxText, c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, 0);
|
||||
UI()->DoLabel(&c, pBoxText, c.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
UI()->DoLabel(&t, pText, c.h * CUI::ms_FontmodHeight, TEXTALIGN_LEFT);
|
||||
|
||||
|
@ -589,7 +595,7 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
|
|||
str_format(aBuf, sizeof(aBuf), "%d", Current);
|
||||
}
|
||||
RenderTools()->DrawUIRect(pRect, *Color, CUI::CORNER_ALL, Round);
|
||||
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER);
|
||||
}
|
||||
|
||||
return Current;
|
||||
|
@ -964,7 +970,7 @@ void CMenus::RenderLoading()
|
|||
r.y = y + 20;
|
||||
r.w = w;
|
||||
r.h = h - 130;
|
||||
UI()->DoLabel(&r, pCaption, 48.0f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&r, pCaption, 48.0f, TEXTALIGN_CENTER);
|
||||
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
|
@ -1000,7 +1006,7 @@ void CMenus::RenderNews(CUIRect MainView)
|
|||
else
|
||||
{
|
||||
MainView.HSplitTop(20.0f, &Label, &MainView);
|
||||
UI()->DoLabelScaled(&Label, aLine, 15.f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabelScaled(&Label, aLine, 15.f, TEXTALIGN_LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1220,7 +1226,7 @@ void CMenus::RenderColorPicker()
|
|||
|
||||
// TODO : ALPHA SUPPORT
|
||||
//static int ALPHAID = 0;
|
||||
UI()->DoLabel(&ALPHARect, "A: 255", 10, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&ALPHARect, "A: 255", 10, TEXTALIGN_CENTER);
|
||||
RenderTools()->DrawUIRect(&ALPHARect, ColorRGBA(0, 0, 0, 0.65f), CUI::CORNER_ALL, 5.0f);
|
||||
|
||||
// Logic
|
||||
|
@ -1596,8 +1602,10 @@ int CMenus::Render()
|
|||
Box.HSplitTop(20.f / UI()->Scale(), &Part, &Box);
|
||||
Box.HSplitTop(24.f / UI()->Scale(), &Part, &Box);
|
||||
Part.VMargin(20.f / UI()->Scale(), &Part);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = (int)Part.w;
|
||||
if(TextRender()->TextWidth(0, 24.f, pTitle, -1, -1.0f) > Part.w)
|
||||
UI()->DoLabelScaled(&Part, pTitle, 24.f, TEXTALIGN_LEFT, (int)Part.w);
|
||||
UI()->DoLabelScaled(&Part, pTitle, 24.f, TEXTALIGN_LEFT, Props);
|
||||
else
|
||||
UI()->DoLabelScaled(&Part, pTitle, 24.f, TEXTALIGN_CENTER);
|
||||
Box.HSplitTop(20.f / UI()->Scale(), &Part, &Box);
|
||||
|
@ -1606,14 +1614,15 @@ int CMenus::Render()
|
|||
|
||||
float FontSize = m_Popup == POPUP_FIRST_LAUNCH ? 16.0f : 20.f;
|
||||
|
||||
Props.m_MaxWidth = (int)Part.w;
|
||||
if(ExtraAlign == -1)
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, (int)Part.w);
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props);
|
||||
else
|
||||
{
|
||||
if(TextRender()->TextWidth(0, FontSize, pExtraText, -1, -1.0f) > Part.w)
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, (int)Part.w);
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props);
|
||||
else
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabelScaled(&Part, pExtraText, FontSize, TEXTALIGN_CENTER);
|
||||
}
|
||||
|
||||
if(m_Popup == POPUP_QUIT)
|
||||
|
@ -1628,7 +1637,8 @@ int CMenus::Render()
|
|||
{
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "%s\n%s", Localize("There's an unsaved map in the editor, you might want to save it before you quit the game."), Localize("Quit anyway?"));
|
||||
UI()->DoLabelScaled(&Box, aBuf, 20.f, TEXTALIGN_LEFT, Part.w - 20.0f);
|
||||
Props.m_MaxWidth = Part.w - 20.0f;
|
||||
UI()->DoLabelScaled(&Box, aBuf, 20.f, TEXTALIGN_LEFT, Props);
|
||||
}
|
||||
|
||||
// buttons
|
||||
|
@ -1767,7 +1777,7 @@ int CMenus::Render()
|
|||
Box.HSplitTop(64.f, 0, &Box);
|
||||
Box.HSplitTop(24.f, &Part, &Box);
|
||||
str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount() / 1024, Client()->MapDownloadTotalsize() / 1024, m_DownloadSpeed / 1024.0f);
|
||||
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER);
|
||||
|
||||
// time left
|
||||
int TimeLeft = maximum(1, m_DownloadSpeed > 0.0f ? static_cast<int>((Client()->MapDownloadTotalsize() - Client()->MapDownloadAmount()) / m_DownloadSpeed) : 1);
|
||||
|
@ -1782,7 +1792,7 @@ int CMenus::Render()
|
|||
}
|
||||
Box.HSplitTop(20.f, 0, &Box);
|
||||
Box.HSplitTop(24.f, &Part, &Box);
|
||||
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Part, aBuf, 20.f, TEXTALIGN_CENTER);
|
||||
|
||||
// progress bar
|
||||
Box.HSplitTop(20.f, 0, &Box);
|
||||
|
@ -2670,7 +2680,7 @@ void CMenus::RenderUpdating(const char *pCaption, int current, int total)
|
|||
r.y = y + 20;
|
||||
r.w = w;
|
||||
r.h = h;
|
||||
UI()->DoLabel(&r, Localize(pCaption), 32.0f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&r, Localize(pCaption), 32.0f, TEXTALIGN_CENTER);
|
||||
|
||||
if(total > 0)
|
||||
{
|
||||
|
|
|
@ -166,7 +166,9 @@ class CMenus : public CComponent
|
|||
if(pText == NULL)
|
||||
pText = GetTextLambda();
|
||||
NewRect.m_Text = pText;
|
||||
UI()->DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, AlignVertically);
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = AlignVertically;
|
||||
UI()->DoLabel(NewRect, &Text, pText, Text.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
}
|
||||
}
|
||||
Graphics()->SetColor(1, 1, 1, 1);
|
||||
|
|
|
@ -514,7 +514,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
{
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 16.0f, TEXTALIGN_LEFT, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 16.0f, TEXTALIGN_LEFT, Props);
|
||||
SearchIconWidth = TextRender()->TextWidth(0, 16.0f, pSearchLabel, -1, -1.0f);
|
||||
ExcludeIconWidth = TextRender()->TextWidth(0, 16.0f, pExcludeLabel, -1, -1.0f);
|
||||
ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth);
|
||||
|
@ -541,7 +544,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
{
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
||||
UI()->DoLabelScaled(&QuickExclude, pExcludeLabel, 16.0f, TEXTALIGN_LEFT, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabelScaled(&QuickExclude, pExcludeLabel, 16.0f, TEXTALIGN_LEFT, Props);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
QuickExclude.VSplitLeft(ExcludeSearchIconMax, 0, &QuickExclude);
|
||||
|
|
|
@ -676,7 +676,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
|
|||
const char *pSearchLabel = "\xEE\xA2\xB6";
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
|
||||
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
|
|
|
@ -694,7 +694,9 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
|
||||
Item.m_Rect.VSplitLeft(60.0f, 0, &Item.m_Rect);
|
||||
str_format(aBuf, sizeof(aBuf), "%s", s->m_aName);
|
||||
RenderTools()->UI()->DoLabelScaled(&Item.m_Rect, aBuf, 12.0f, TEXTALIGN_LEFT, Item.m_Rect.w);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = Item.m_Rect.w;
|
||||
RenderTools()->UI()->DoLabelScaled(&Item.m_Rect, aBuf, 12.0f, TEXTALIGN_LEFT, Props);
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
ColorRGBA BloodColor = *UseCustomColor ? color_cast<ColorRGBA>(ColorHSLA(*ColorBody)) : s->m_BloodColor;
|
||||
|
@ -723,7 +725,10 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
const char *pSearchLabel = "\xEE\xA2\xB6";
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
|
||||
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
|
|
|
@ -512,7 +512,10 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
|
|||
const char *pSearchLabel = "\xEE\xA2\xB6";
|
||||
TextRender()->SetCurFont(TextRender()->GetFont(TEXT_FONT_ICON_FONT));
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabelScaled(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
|
||||
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
TextRender()->SetCurFont(NULL);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <engine/graphics.h>
|
||||
#include <engine/shared/config.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <limits>
|
||||
|
||||
void CUIElement::Init(CUI *pUI, int RequestedRectCount)
|
||||
{
|
||||
|
@ -451,17 +452,28 @@ int CUI::DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *
|
|||
return 1;
|
||||
}
|
||||
|
||||
float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, bool StopAtEnd, class CTextCursor *pSelCursor)
|
||||
float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, float Size, int Align, const SLabelProperties &LabelProps)
|
||||
{
|
||||
float AlignedSize = 0;
|
||||
float MaxCharacterHeightInLine = 0;
|
||||
float tw = TextRender()->TextWidth(0, Size, pText, -1, MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
float tw = std::numeric_limits<float>::max();
|
||||
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : w;
|
||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
while(tw > MaxTextWidth + 0.001f)
|
||||
{
|
||||
if(!LabelProps.m_EnableWidthCheck)
|
||||
break;
|
||||
if(Size < 4.0f)
|
||||
break;
|
||||
Size -= 1.0f;
|
||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
}
|
||||
|
||||
int Flags = TEXTFLAG_RENDER | (StopAtEnd ? TEXTFLAG_STOP_AT_END : 0);
|
||||
int Flags = TEXTFLAG_RENDER | (LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0);
|
||||
|
||||
float AlignmentVert = y + (h - AlignedSize) / 2.f;
|
||||
float AlignmentHori = 0;
|
||||
if(AlignVertically == 0)
|
||||
if(LabelProps.m_AlignVertically == 0)
|
||||
{
|
||||
AlignmentVert = y + (h - AlignedSize) / 2.f - (AlignedSize - MaxCharacterHeightInLine) / 2.f;
|
||||
}
|
||||
|
@ -483,54 +495,65 @@ float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, fl
|
|||
|
||||
CTextCursor Cursor;
|
||||
TextRender()->SetCursor(&Cursor, AlignmentHori, AlignmentVert, Size, Flags);
|
||||
Cursor.m_LineWidth = (float)MaxWidth;
|
||||
if(pSelCursor)
|
||||
Cursor.m_LineWidth = (float)LabelProps.m_MaxWidth;
|
||||
if(LabelProps.m_pSelCursor)
|
||||
{
|
||||
Cursor.m_CursorMode = pSelCursor->m_CursorMode;
|
||||
Cursor.m_CursorCharacter = pSelCursor->m_CursorCharacter;
|
||||
Cursor.m_CalculateSelectionMode = pSelCursor->m_CalculateSelectionMode;
|
||||
Cursor.m_PressMouseX = pSelCursor->m_PressMouseX;
|
||||
Cursor.m_PressMouseY = pSelCursor->m_PressMouseY;
|
||||
Cursor.m_ReleaseMouseX = pSelCursor->m_ReleaseMouseX;
|
||||
Cursor.m_ReleaseMouseY = pSelCursor->m_ReleaseMouseY;
|
||||
Cursor.m_CursorMode = LabelProps.m_pSelCursor->m_CursorMode;
|
||||
Cursor.m_CursorCharacter = LabelProps.m_pSelCursor->m_CursorCharacter;
|
||||
Cursor.m_CalculateSelectionMode = LabelProps.m_pSelCursor->m_CalculateSelectionMode;
|
||||
Cursor.m_PressMouseX = LabelProps.m_pSelCursor->m_PressMouseX;
|
||||
Cursor.m_PressMouseY = LabelProps.m_pSelCursor->m_PressMouseY;
|
||||
Cursor.m_ReleaseMouseX = LabelProps.m_pSelCursor->m_ReleaseMouseX;
|
||||
Cursor.m_ReleaseMouseY = LabelProps.m_pSelCursor->m_ReleaseMouseY;
|
||||
|
||||
Cursor.m_SelectionStart = pSelCursor->m_SelectionStart;
|
||||
Cursor.m_SelectionEnd = pSelCursor->m_SelectionEnd;
|
||||
Cursor.m_SelectionStart = LabelProps.m_pSelCursor->m_SelectionStart;
|
||||
Cursor.m_SelectionEnd = LabelProps.m_pSelCursor->m_SelectionEnd;
|
||||
}
|
||||
|
||||
TextRender()->TextEx(&Cursor, pText, -1);
|
||||
|
||||
if(pSelCursor)
|
||||
if(LabelProps.m_pSelCursor)
|
||||
{
|
||||
*pSelCursor = Cursor;
|
||||
*LabelProps.m_pSelCursor = Cursor;
|
||||
}
|
||||
|
||||
return tw;
|
||||
}
|
||||
|
||||
void CUI::DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, CTextCursor *pSelCursor)
|
||||
void CUI::DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps)
|
||||
{
|
||||
DoTextLabel(pRect->x, pRect->y, pRect->w, pRect->h, pText, Size, Align, MaxWidth, AlignVertically, false, pSelCursor);
|
||||
DoTextLabel(pRect->x, pRect->y, pRect->w, pRect->h, pText, Size, Align, LabelProps);
|
||||
}
|
||||
|
||||
void CUI::DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically)
|
||||
void CUI::DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps)
|
||||
{
|
||||
DoLabel(pRect, pText, Size * Scale(), Align, MaxWidth, AlignVertically);
|
||||
DoLabel(pRect, pText, Size * Scale(), Align, LabelProps);
|
||||
}
|
||||
|
||||
void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor)
|
||||
void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen, CTextCursor *pReadCursor)
|
||||
{
|
||||
float AlignedSize = 0;
|
||||
float MaxCharacterHeightInLine = 0;
|
||||
float tw = TextRender()->TextWidth(0, Size, pText, -1, MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
float tw = std::numeric_limits<float>::max();
|
||||
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
|
||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
while(tw > MaxTextWidth + 0.001f)
|
||||
{
|
||||
if(!LabelProps.m_EnableWidthCheck)
|
||||
break;
|
||||
if(Size < 4.0f)
|
||||
break;
|
||||
Size -= 1.0f;
|
||||
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
|
||||
}
|
||||
float AlignmentVert = pRect->y + (pRect->h - AlignedSize) / 2.f;
|
||||
float AlignmentHori = 0;
|
||||
|
||||
CTextCursor Cursor;
|
||||
|
||||
int Flags = TEXTFLAG_RENDER | (StopAtEnd ? TEXTFLAG_STOP_AT_END : 0);
|
||||
int Flags = TEXTFLAG_RENDER | (LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0);
|
||||
|
||||
if(AlignVertically == 0)
|
||||
if(LabelProps.m_AlignVertically == 0)
|
||||
{
|
||||
AlignmentVert = pRect->y + (pRect->h - AlignedSize) / 2.f - (AlignedSize - MaxCharacterHeightInLine) / 2.f;
|
||||
}
|
||||
|
@ -558,7 +581,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
|
|||
{
|
||||
TextRender()->SetCursor(&Cursor, AlignmentHori, AlignmentVert, Size, Flags);
|
||||
}
|
||||
Cursor.m_LineWidth = MaxWidth;
|
||||
Cursor.m_LineWidth = LabelProps.m_MaxWidth;
|
||||
|
||||
RectEl.m_TextColor = TextRender()->GetTextColor();
|
||||
RectEl.m_TextOutlineColor = TextRender()->GetTextOutlineColor();
|
||||
|
@ -614,7 +637,12 @@ void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, float x, float y,
|
|||
TmpRect.y = y;
|
||||
TmpRect.w = w;
|
||||
TmpRect.h = h;
|
||||
DoLabel(RectEl, &TmpRect, pText, Size, Align, MaxWidth, AlignVertically, StopAtEnd, StrLen, pReadCursor);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = MaxWidth;
|
||||
Props.m_AlignVertically = AlignVertically;
|
||||
Props.m_StopAtEnd = StopAtEnd;
|
||||
DoLabel(RectEl, &TmpRect, pText, Size, Align, Props, StrLen, pReadCursor);
|
||||
}
|
||||
|
||||
STextRenderColor ColorText(RectEl.m_TextColor);
|
||||
|
|
|
@ -179,6 +179,17 @@ public:
|
|||
void InitRects(int RequestedRectCount);
|
||||
};
|
||||
|
||||
struct SLabelProperties
|
||||
{
|
||||
float m_MaxWidth = -1;
|
||||
int m_AlignVertically = 1;
|
||||
bool m_StopAtEnd = false;
|
||||
class CTextCursor *m_pSelCursor = nullptr;
|
||||
bool m_EnableWidthCheck = true;
|
||||
|
||||
SLabelProperties() {}
|
||||
};
|
||||
|
||||
class CUI
|
||||
{
|
||||
const void *m_pHotItem;
|
||||
|
@ -280,11 +291,11 @@ public:
|
|||
int DoButtonLogic(const void *pID, const char *pText /* TODO: Refactor: Remove */, int Checked, const CUIRect *pRect);
|
||||
int DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *pY);
|
||||
|
||||
float DoTextLabel(float x, float y, float w, float h, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, class CTextCursor *pSelCursor = NULL);
|
||||
void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, class CTextCursor *pSelCursor = NULL);
|
||||
void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1);
|
||||
float DoTextLabel(float x, float y, float w, float h, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {});
|
||||
void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {});
|
||||
void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps = {});
|
||||
|
||||
void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL);
|
||||
void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, const SLabelProperties &LabelProps, int StrLen = -1, class CTextCursor *pReadCursor = NULL);
|
||||
void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, float x, float y, float w, float h, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL);
|
||||
void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL);
|
||||
};
|
||||
|
|
|
@ -586,7 +586,10 @@ bool CUIEx::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigne
|
|||
SelCursor.m_SelectionEnd = m_CurSelEnd;
|
||||
}
|
||||
|
||||
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, TEXTALIGN_LEFT, -1, 1, &SelCursor);
|
||||
SLabelProperties Props;
|
||||
Props.m_pSelCursor = &SelCursor;
|
||||
Props.m_EnableWidthCheck = IsEmptyText;
|
||||
UI()->DoLabel(&Textbox, pDisplayStr, FontSize, TEXTALIGN_LEFT, Props);
|
||||
|
||||
if(UI()->LastActiveItem() == pID)
|
||||
{
|
||||
|
@ -627,7 +630,10 @@ bool CUIEx::DoClearableEditBox(const void *pID, const void *pClearID, const CUIR
|
|||
|
||||
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT);
|
||||
RenderTools()->DrawUIRect(&ClearButton, ColorRGBA(1, 1, 1, 0.33f * UI()->ButtonColorMul(pClearID)), Corners & ~CUI::CORNER_L, 3.0f);
|
||||
UI()->DoLabel(&ClearButton, "×", ClearButton.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, -1, 0);
|
||||
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = 0;
|
||||
UI()->DoLabel(&ClearButton, "×", ClearButton.h * CUI::ms_FontmodHeight, TEXTALIGN_CENTER, Props);
|
||||
TextRender()->SetRenderFlags(0);
|
||||
if(UI()->DoButtonLogic(pClearID, "×", 0, &ClearButton))
|
||||
{
|
||||
|
|
|
@ -375,7 +375,9 @@ int CEditor::DoButton_Editor(const void *pID, const char *pText, int Checked, co
|
|||
{
|
||||
RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_ALL, 3.0f);
|
||||
CUIRect NewRect = *pRect;
|
||||
UI()->DoLabel(&NewRect, pText, 10.f, TEXTALIGN_CENTER, -1, AlignVert);
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = AlignVert;
|
||||
UI()->DoLabel(&NewRect, pText, 10.f, TEXTALIGN_CENTER, Props);
|
||||
Checked %= 2;
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
@ -387,7 +389,7 @@ int CEditor::DoButton_Env(const void *pID, const char *pText, int Checked, const
|
|||
ColorRGBA Color = ColorRGBA(BaseColor.r * Bright, BaseColor.g * Bright, BaseColor.b * Bright, Alpha);
|
||||
|
||||
RenderTools()->DrawUIRect(pRect, Color, CUI::CORNER_ALL, 3.0f);
|
||||
UI()->DoLabel(pRect, pText, 10.f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(pRect, pText, 10.f, TEXTALIGN_CENTER);
|
||||
Checked %= 2;
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, 0, pToolTip);
|
||||
}
|
||||
|
@ -399,7 +401,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, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&t, pText, 10, TEXTALIGN_LEFT);
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
||||
|
@ -410,7 +412,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, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&r, pText, 10, TEXTALIGN_LEFT);
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
||||
|
@ -421,7 +423,7 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked,
|
|||
|
||||
CUIRect t = *pRect;
|
||||
t.VMargin(5.0f, &t);
|
||||
UI()->DoLabel(&t, pText, 10, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&t, pText, 10, TEXTALIGN_LEFT);
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
||||
|
@ -429,7 +431,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;
|
||||
UI()->DoLabel(&NewRect, pText, 10, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&NewRect, pText, 10, TEXTALIGN_CENTER);
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
||||
|
@ -437,21 +439,23 @@ 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;
|
||||
UI()->DoLabel(&NewRect, pText, FontSize, TEXTALIGN_CENTER, -1, AlignVert);
|
||||
SLabelProperties Props;
|
||||
Props.m_AlignVertically = AlignVert;
|
||||
UI()->DoLabel(&NewRect, pText, FontSize, TEXTALIGN_CENTER, Props);
|
||||
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, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(pRect, pText ? pText : "+", 10, TEXTALIGN_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, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(pRect, pText ? pText : "-", 10, TEXTALIGN_CENTER);
|
||||
return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip);
|
||||
}
|
||||
|
||||
|
@ -627,7 +631,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in
|
|||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%d", Current);
|
||||
RenderTools()->DrawUIRect(pRect, Color ? *Color : GetButtonColor(pID, 0), Corners, 5.0f);
|
||||
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(pRect, aBuf, 10, TEXTALIGN_CENTER);
|
||||
}
|
||||
|
||||
return Current;
|
||||
|
@ -2977,7 +2981,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, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Label, pProps[i].m_pName, 10.0f, TEXTALIGN_LEFT);
|
||||
|
||||
if(pProps[i].m_Type == PROPTYPE_INT_STEP)
|
||||
{
|
||||
|
@ -3145,11 +3149,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, ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f);
|
||||
UI()->DoLabel(&Shifter, "X", 10.0f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Shifter, "X", 10.0f, TEXTALIGN_CENTER);
|
||||
Up.VSplitLeft(10.0f, &Up, &Shifter);
|
||||
Shifter.VSplitRight(10.0f, &Shifter, &Down);
|
||||
RenderTools()->DrawUIRect(&Shifter, ColorRGBA(1, 1, 1, 0.5f), 0, 0.0f);
|
||||
UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Shifter, "Y", 10.0f, TEXTALIGN_CENTER);
|
||||
if(DoButton_ButtonDec(&pIDs[i], "-", 0, &Left, 0, "Left"))
|
||||
{
|
||||
*pNewVal = 1;
|
||||
|
@ -3227,7 +3231,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
|
|||
|
||||
float FontSize = ScaleFontSize(aBuf, sizeof(aBuf), 10.0f, Shifter.w);
|
||||
RenderTools()->DrawUIRect(&Shifter, Color, 0, 5.0f);
|
||||
UI()->DoLabel(&Shifter, aBuf, FontSize, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Shifter, aBuf, FontSize, TEXTALIGN_CENTER);
|
||||
|
||||
if(DoButton_ButtonDec((char *)&pIDs[i] + 1, 0, 0, &Dec, 0, "Previous Envelope"))
|
||||
{
|
||||
|
@ -4326,7 +4330,7 @@ void CEditor::RenderFileDialog()
|
|||
// title
|
||||
RenderTools()->DrawUIRect(&Title, ColorRGBA(1, 1, 1, 0.25f), CUI::CORNER_ALL, 4.0f);
|
||||
Title.VMargin(10.0f, &Title);
|
||||
UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Title, m_pFileDialogTitle, 12.0f, TEXTALIGN_LEFT);
|
||||
|
||||
// pathbox
|
||||
char aPath[128], aBuf[128];
|
||||
|
@ -4335,12 +4339,12 @@ void CEditor::RenderFileDialog()
|
|||
else
|
||||
aPath[0] = 0;
|
||||
str_format(aBuf, sizeof(aBuf), "Current path: %s", aPath);
|
||||
UI()->DoLabel(&PathBox, aBuf, 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&PathBox, aBuf, 10.0f, TEXTALIGN_LEFT);
|
||||
|
||||
if(m_FileDialogStorageType == IStorage::TYPE_SAVE)
|
||||
{
|
||||
// filebox
|
||||
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&FileBoxLabel, "Filename:", 10.0f, TEXTALIGN_LEFT);
|
||||
static float s_FileBoxID = 0;
|
||||
if(DoEditBox(&s_FileBoxID, &FileBox, m_aFileDialogFileName, sizeof(m_aFileDialogFileName), 10.0f, &s_FileBoxID))
|
||||
{
|
||||
|
@ -4361,7 +4365,7 @@ void CEditor::RenderFileDialog()
|
|||
CUIRect ClearBox;
|
||||
FileBox.VSplitRight(15, &FileBox, &ClearBox);
|
||||
|
||||
UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&FileBoxLabel, "Search:", 10.0f, TEXTALIGN_LEFT);
|
||||
str_copy(m_aFileDialogPrevSearchText, m_aFileDialogSearchText, sizeof(m_aFileDialogPrevSearchText));
|
||||
static float s_SearchBoxID = 0;
|
||||
DoEditBox(&s_SearchBoxID, &FileBox, m_aFileDialogSearchText, sizeof(m_aFileDialogSearchText), 10.0f, &s_SearchBoxID, false, CUI::CORNER_L);
|
||||
|
@ -4757,7 +4761,9 @@ void CEditor::RenderStatusbar(CUIRect View)
|
|||
str_copy(aBuf, m_pTooltip, sizeof(aBuf));
|
||||
|
||||
float FontSize = ScaleFontSize(aBuf, sizeof(aBuf), 10.0f, View.w);
|
||||
UI()->DoLabel(&View, aBuf, FontSize, TEXTALIGN_LEFT, View.w);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = View.w;
|
||||
UI()->DoLabel(&View, aBuf, FontSize, TEXTALIGN_LEFT, Props);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4896,7 +4902,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
}
|
||||
|
||||
RenderTools()->DrawUIRect(&Shifter, EnvColor, 0, 0.0f);
|
||||
UI()->DoLabel(&Shifter, aBuf, 10.0f, TEXTALIGN_CENTER, -1);
|
||||
UI()->DoLabel(&Shifter, aBuf, 10.0f, TEXTALIGN_CENTER);
|
||||
|
||||
static int s_PrevButton = 0;
|
||||
if(DoButton_ButtonDec(&s_PrevButton, 0, 0, &Dec, 0, "Previous Envelope"))
|
||||
|
@ -4920,7 +4926,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
{
|
||||
ToolBar.VSplitLeft(15.0f, &Button, &ToolBar);
|
||||
ToolBar.VSplitLeft(35.0f, &Button, &ToolBar);
|
||||
UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT);
|
||||
|
||||
ToolBar.VSplitLeft(80.0f, &Button, &ToolBar);
|
||||
|
||||
|
@ -4995,7 +5001,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
|
||||
ToolBar.VSplitLeft(4.0f, &Button, &ToolBar);
|
||||
ToolBar.VSplitLeft(80.0f, &Button, &ToolBar);
|
||||
UI()->DoLabel(&Button, "Synchronized", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Button, "Synchronized", 10.0f, TEXTALIGN_LEFT);
|
||||
}
|
||||
|
||||
float EndTime = pEnvelope->EndTime();
|
||||
|
@ -5315,8 +5321,8 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
ToolBar1.VSplitMid(&Label1, &ToolBar1);
|
||||
ToolBar2.VSplitMid(&Label2, &ToolBar2);
|
||||
|
||||
UI()->DoLabel(&Label1, "Value:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Label2, "Time (in s):", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&Label1, "Value:", 10.0f, TEXTALIGN_LEFT);
|
||||
UI()->DoLabel(&Label2, "Time (in s):", 10.0f, TEXTALIGN_LEFT);
|
||||
}
|
||||
|
||||
static float s_ValNumber = 0;
|
||||
|
@ -5644,13 +5650,13 @@ 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, TEXTALIGN_LEFT, -1);
|
||||
UI()->DoLabel(&MenuBar, aBuf, 10.0f, TEXTALIGN_LEFT);
|
||||
|
||||
char aTimeStr[6];
|
||||
str_timestamp_format(aTimeStr, sizeof(aTimeStr), "%H:%M");
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "X: %i, Y: %i, Z: %i, A: %.1f, G: %i %s", (int)UI()->MouseWorldX() / 32, (int)UI()->MouseWorldY() / 32, m_ZoomLevel, m_AnimateSpeed, m_GridFactor, aTimeStr);
|
||||
UI()->DoLabel(&Info, aBuf, 10.0f, TEXTALIGN_RIGHT, -1);
|
||||
UI()->DoLabel(&Info, aBuf, 10.0f, TEXTALIGN_RIGHT);
|
||||
|
||||
static int s_CloseButton = 0;
|
||||
if(DoButton_Editor(&s_CloseButton, "×", 0, &Close, 0, "Exits from the editor", 0) || (m_Dialog == DIALOG_NONE && !UiPopupOpen() && !m_PopupEventActivated && Input()->KeyPress(KEY_ESCAPE)))
|
||||
|
|
|
@ -1018,7 +1018,9 @@ int CLayerTiles::RenderCommonProperties(SCommonPropState &State, CEditor *pEdito
|
|||
Warning.HMargin(0.5f, &Warning);
|
||||
|
||||
pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f));
|
||||
pEditor->UI()->DoLabel(&Warning, "Editing multiple layers", 9.0f, TEXTALIGN_LEFT, Warning.w);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = Warning.w;
|
||||
pEditor->UI()->DoLabel(&Warning, "Editing multiple layers", 9.0f, TEXTALIGN_LEFT, Props);
|
||||
pEditor->TextRender()->TextColor(ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
pToolbox->HSplitTop(2.0f, 0, pToolbox);
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT);
|
||||
Button.VSplitLeft(40.0f, 0, &Button);
|
||||
static float s_Name = 0;
|
||||
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))
|
||||
|
@ -421,7 +421,7 @@ int CEditor::PopupLayer(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
{
|
||||
View.HSplitBottom(5.0f, &View, &Button);
|
||||
View.HSplitBottom(12.0f, &View, &Button);
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT, -1);
|
||||
pEditor->UI()->DoLabel(&Button, "Name:", 10.0f, TEXTALIGN_LEFT);
|
||||
Button.VSplitLeft(40.0f, 0, &Button);
|
||||
static float s_Name = 0;
|
||||
if(pEditor->DoEditBox(&s_Name, &Button, pEditor->GetSelectedLayer(0)->m_aName, sizeof(pEditor->GetSelectedLayer(0)->m_aName), 10.0f, &s_Name))
|
||||
|
@ -1036,7 +1036,9 @@ int CEditor::PopupNewFolder(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
View.HSplitTop(20.0f, &Label, &View);
|
||||
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, TEXTALIGN_LEFT, View.w);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = View.w;
|
||||
pEditor->UI()->DoLabel(&Label, "Unable to create the folder", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
|
||||
// button
|
||||
ButtonBar.VMargin(ButtonBar.w / 2.0f - 55.0f, &ButtonBar);
|
||||
|
@ -1149,24 +1151,26 @@ int CEditor::PopupEvent(CEditor *pEditor, CUIRect View, void *pContext)
|
|||
View.HSplitTop(30.0f, 0, &View);
|
||||
View.VMargin(40.0f, &View);
|
||||
View.HSplitTop(20.0f, &Label, &View);
|
||||
SLabelProperties Props;
|
||||
Props.m_MaxWidth = Label.w - 10.0f;
|
||||
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, TEXTALIGN_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, Props);
|
||||
else if((pEditor->m_PopupEventType == POPEVENT_LOAD) || (pEditor->m_PopupEventType == POPEVENT_LOADCURRENT))
|
||||
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);
|
||||
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, Props);
|
||||
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, TEXTALIGN_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, Props);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_SAVE)
|
||||
pEditor->UI()->DoLabel(&Label, "The file already exists.\nDo you want to overwrite the map?", 10.0f, TEXTALIGN_LEFT);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_LARGELAYER)
|
||||
pEditor->UI()->DoLabel(&Label, "You are trying to set the height or width of a layer to more than 1000 tiles. This is actually possible, but only rarely necessary. It may cause the editor to work slower, larger file size as well as higher memory usage for client and server.", 10.0f, TEXTALIGN_LEFT, Label.w - 10.0f);
|
||||
pEditor->UI()->DoLabel(&Label, "You are trying to set the height or width of a layer to more than 1000 tiles. This is actually possible, but only rarely necessary. It may cause the editor to work slower, larger file size as well as higher memory usage for client and server.", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_PREVENTUNUSEDTILES)
|
||||
pEditor->UI()->DoLabel(&Label, "Unused tiles can't be placed by default because they could get a use later and then destroy your map.\nActivate the 'Unused' switch to be able to place every tile.", 10.0f, TEXTALIGN_LEFT, Label.w - 10.0f);
|
||||
pEditor->UI()->DoLabel(&Label, "Unused tiles can't be placed by default because they could get a use later and then destroy your map.\nActivate the 'Unused' switch to be able to place every tile.", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_IMAGEDIV16)
|
||||
pEditor->UI()->DoLabel(&Label, "The width or height of this image is not divisible by 16. This is required for images used in tile layers.", 10.0f, TEXTALIGN_LEFT, Label.w - 10.0f);
|
||||
pEditor->UI()->DoLabel(&Label, "The width or height of this image is not divisible by 16. This is required for images used in tile layers.", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_IMAGE_MAX)
|
||||
pEditor->UI()->DoLabel(&Label, "The client only allows a maximum of 64 images.", 10.0f, TEXTALIGN_LEFT, Label.w - 10.0f);
|
||||
pEditor->UI()->DoLabel(&Label, "The client only allows a maximum of 64 images.", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
else if(pEditor->m_PopupEventType == POPEVENT_PLACE_BORDER_TILES)
|
||||
pEditor->UI()->DoLabel(&Label, "This is going to overwrite any existing tiles around the edges of the layer.\nContinue?", 10.0f, TEXTALIGN_LEFT, Label.w - 10.0f);
|
||||
pEditor->UI()->DoLabel(&Label, "This is going to overwrite any existing tiles around the edges of the layer.\nContinue?", 10.0f, TEXTALIGN_LEFT, Props);
|
||||
|
||||
// button bar
|
||||
ButtonBar.VSplitLeft(30.0f, 0, &ButtonBar);
|
||||
|
|
Loading…
Reference in a new issue