mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Improve text rendering inside tele tiles in editor
This commit is contained in:
parent
8ce103f04f
commit
fcc095b675
|
@ -724,7 +724,6 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale
|
|||
return; // its useless to render text at this distance
|
||||
|
||||
float Size = g_Config.m_ClTextEntitiesSize / 100.f;
|
||||
float ToCenterOffset = (1 - Size) / 2.f;
|
||||
|
||||
for(int y = StartY; y < EndY; y++)
|
||||
for(int x = StartX; x < EndX; x++)
|
||||
|
@ -749,7 +748,14 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale
|
|||
char aBuf[16];
|
||||
str_from_int(Index, aBuf);
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
|
||||
TextRender()->Text(mx * Scale - 3.f, (my + ToCenterOffset) * Scale, Size * Scale, aBuf, -1.0f);
|
||||
|
||||
// Auto-resize text to fit inside the tile
|
||||
float ScaledWidth = TextRender()->TextWidth(Size * Scale, aBuf, -1);
|
||||
float Factor = clamp(Scale / ScaledWidth, 0.0f, 1.0f);
|
||||
float LocalSize = Size * Factor;
|
||||
float ToCenterOffset = (1 - LocalSize) / 2.f;
|
||||
TextRender()->Text((mx + 0.5f) * Scale - (ScaledWidth * Factor) / 2.0f, (my + ToCenterOffset) * Scale, LocalSize * Scale, aBuf, -1.0f);
|
||||
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue