6340: Various refactoring of text render r=def- a=Robyt3



## Checklist

- [X] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2023-02-20 22:19:58 +00:00 committed by GitHub
commit 0f37591af7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 496 additions and 521 deletions

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,10 @@
#include "kernel.h"
#include <base/color.h>
#include <engine/graphics.h>
#include <stdint.h>
#include <cstdint>
enum
{
@ -109,24 +111,24 @@ class ITextRender : public IInterface
{
MACRO_INTERFACE("textrender", 0)
public:
virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) = 0;
virtual void MoveCursor(CTextCursor *pCursor, float x, float y) = 0;
virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) = 0;
virtual void SetCursor(CTextCursor *pCursor, float x, float y, float FontSize, int Flags) const = 0;
virtual void MoveCursor(CTextCursor *pCursor, float x, float y) const = 0;
virtual void SetCursorPosition(CTextCursor *pCursor, float x, float y) const = 0;
virtual CFont *LoadFont(const char *pFilename, const unsigned char *pBuf, size_t Size) = 0;
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, const unsigned char *pBuf, size_t Size) = 0;
virtual CFont *GetFont(int FontIndex) = 0;
virtual CFont *LoadFont(const char *pFilename, unsigned char *pBuf, size_t Size) = 0;
virtual bool LoadFallbackFont(CFont *pFont, const char *pFilename, unsigned char *pBuf, size_t Size) const = 0;
virtual CFont *GetFont(size_t FontIndex) = 0;
virtual CFont *GetFont(const char *pFilename) = 0;
virtual void SetDefaultFont(CFont *pFont) = 0;
virtual void SetCurFont(CFont *pFont) = 0;
virtual void SetRenderFlags(unsigned int Flags) = 0;
virtual unsigned int GetRenderFlags() = 0;
virtual void SetRenderFlags(unsigned Flags) = 0;
virtual unsigned GetRenderFlags() const = 0;
ColorRGBA DefaultTextColor() { return ColorRGBA(1, 1, 1, 1); }
ColorRGBA DefaultTextOutlineColor() { return ColorRGBA(0, 0, 0, 0.3f); }
ColorRGBA DefaultSelectionColor() { return ColorRGBA(0, 0, 1.0f, 1.0f); }
ColorRGBA DefaultTextColor() const { return ColorRGBA(1, 1, 1, 1); }
ColorRGBA DefaultTextOutlineColor() const { return ColorRGBA(0, 0, 0, 0.3f); }
ColorRGBA DefaultSelectionColor() const { return ColorRGBA(0, 0, 1.0f, 1.0f); }
//
virtual void TextEx(CTextCursor *pCursor, const char *pText, int Length) = 0;
@ -144,13 +146,14 @@ public:
virtual void RenderTextContainer(int TextContainerIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) = 0;
virtual void RenderTextContainer(int TextContainerIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor, float X, float Y) = 0;
virtual void UploadEntityLayerText(void *pTexBuff, int ImageColorChannelCount, int TexWidth, int TexHeight, int TexSubWidth, int TexSubHeight, const char *pText, int Length, float x, float y, int FontHeight) = 0;
virtual int AdjustFontSize(const char *pText, int TextLength, int MaxSize, int MaxWidth) = 0;
virtual int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontHeight) = 0;
virtual void UploadEntityLayerText(void *pTexBuff, size_t ImageColorChannelCount, int TexWidth, int TexHeight, int TexSubWidth, int TexSubHeight, const char *pText, int Length, float x, float y, int FontHeight) = 0;
virtual int AdjustFontSize(const char *pText, int TextLength, int MaxSize, int MaxWidth) const = 0;
virtual float GetGlyphOffsetX(int FontSize, char TextCharacter) const = 0;
virtual int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontHeight) const = 0;
virtual bool SelectionToUTF8OffSets(const char *pText, int SelStart, int SelEnd, int &OffUTF8Start, int &OffUTF8End) = 0;
virtual bool UTF8OffToDecodedOff(const char *pText, int UTF8Off, int &DecodedOff) = 0;
virtual bool DecodedOffToUTF8Off(const char *pText, int DecodedOff, int &UTF8Off) = 0;
virtual bool SelectionToUTF8OffSets(const char *pText, int SelStart, int SelEnd, int &OffUTF8Start, int &OffUTF8End) const = 0;
virtual bool UTF8OffToDecodedOff(const char *pText, int UTF8Off, int &DecodedOff) const = 0;
virtual bool DecodedOffToUTF8Off(const char *pText, int DecodedOff, int &UTF8Off) const = 0;
// old foolish interface
virtual void TextColor(float r, float g, float b, float a) = 0;
@ -159,17 +162,15 @@ public:
virtual void TextOutlineColor(ColorRGBA rgb) = 0;
virtual void TextSelectionColor(float r, float g, float b, float a) = 0;
virtual void TextSelectionColor(ColorRGBA rgb) = 0;
virtual void Text(void *pFontSetV, float x, float y, float Size, const char *pText, float LineWidth) = 0;
virtual float TextWidth(void *pFontSetV, float Size, const char *pText, int StrLength, float LineWidth, float *pAlignedHeight = nullptr, float *pMaxCharacterHeightInLine = nullptr) = 0;
virtual int TextLineCount(void *pFontSetV, float Size, const char *pText, float LineWidth) = 0;
virtual void Text(float x, float y, float Size, const char *pText, float LineWidth) = 0;
virtual float TextWidth(float Size, const char *pText, int StrLength, float LineWidth, float *pAlignedHeight = nullptr, float *pMaxCharacterHeightInLine = nullptr) = 0;
virtual int TextLineCount(float Size, const char *pText, float LineWidth) = 0;
virtual ColorRGBA GetTextColor() = 0;
virtual ColorRGBA GetTextOutlineColor() = 0;
virtual ColorRGBA GetTextSelectionColor() = 0;
virtual ColorRGBA GetTextColor() const = 0;
virtual ColorRGBA GetTextOutlineColor() const = 0;
virtual ColorRGBA GetTextSelectionColor() const = 0;
virtual void OnWindowResize() = 0;
virtual float GetGlyphOffsetX(int FontSize, char TextCharacter) = 0;
};
class IEngineTextRender : public ITextRender

View file

@ -1220,7 +1220,7 @@ void CChat::OnRender()
}
TextRender()->TextEx(&Cursor, m_Input.GetString(Editing) + m_ChatStringOffset, m_Input.GetCursorOffset(Editing) - m_ChatStringOffset);
static float MarkerOffset = TextRender()->TextWidth(0, 8.0f, "|", -1, -1.0f) / 3;
static float MarkerOffset = TextRender()->TextWidth(8.0f, "|", -1, -1.0f) / 3;
CTextCursor Marker = Cursor;
Marker.m_X -= MarkerOffset;
TextRender()->TextEx(&Marker, "|", -1);

View file

@ -546,7 +546,7 @@ void CGameConsole::PossibleCommandsRenderCallback(int Index, const char *pStr, v
if(Index == pInfo->m_WantedCompletion)
{
float TextWidth = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1, -1.0f);
float TextWidth = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_FontSize, pStr, -1, -1.0f);
const CUIRect Rect = {pInfo->m_Cursor.m_X - 2.5f, pInfo->m_Cursor.m_Y - 4.f / 2.f, TextWidth + 5.f, pInfo->m_Cursor.m_FontSize + 4.f};
Rect.Draw(ColorRGBA(229.0f / 255.0f, 185.0f / 255.0f, 4.0f / 255.0f, 0.85f), IGraphics::CORNER_ALL, pInfo->m_Cursor.m_FontSize / 3.f);
@ -923,12 +923,12 @@ void CGameConsole::OnRender()
char aBuf[128];
TextRender()->TextColor(1, 1, 1, 1);
str_format(aBuf, sizeof(aBuf), Localize("-Page %d-"), pConsole->m_BacklogCurPage + 1);
TextRender()->Text(0, 10.0f, FontSize / 2.f, FontSize, aBuf, -1.0f);
TextRender()->Text(10.0f, FontSize / 2.f, FontSize, aBuf, -1.0f);
// render version
str_copy(aBuf, "v" GAME_VERSION " on " CONF_PLATFORM_STRING " " CONF_ARCH_STRING);
float Width = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, Screen.w - Width - 10.0f, FontSize / 2.f, FontSize, aBuf, -1.0f);
float Width = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(Screen.w - Width - 10.0f, FontSize / 2.f, FontSize, aBuf, -1.0f);
}
}

View file

@ -33,52 +33,52 @@ void CDebugHud::RenderNetCorrections()
float x = Width - 100.0f, y = 50.0f;
for(int i = 0; i < Num; ++i)
TextRender()->Text(0, x, y + i * LineHeight, Fontsize, s_apStrings[i], -1.0f);
TextRender()->Text(x, y + i * LineHeight, Fontsize, s_apStrings[i], -1.0f);
x = Width - 10.0f;
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%.0f Bps", Velspeed / 32);
float w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
float w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
str_format(aBuf, sizeof(aBuf), "%.0f Bps", VelspeedX / 32 * Ramp);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
str_format(aBuf, sizeof(aBuf), "%.0f Bps", VelspeedY / 32);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
str_format(aBuf, sizeof(aBuf), "%.2f", Ramp);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID);
if(pCharacter)
str_format(aBuf, sizeof(aBuf), "%d", pCharacter->m_TeleCheckpoint);
else
str_copy(aBuf, "-1");
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += 2 * LineHeight;
str_format(aBuf, sizeof(aBuf), "%.2f", m_pClient->m_Snap.m_pLocalCharacter->m_X / 32.0f);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
str_format(aBuf, sizeof(aBuf), "%.2f", m_pClient->m_Snap.m_pLocalCharacter->m_Y / 32.0f);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_Snap.m_pLocalCharacter->m_Angle);
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += 2 * LineHeight;
str_format(aBuf, sizeof(aBuf), "%d", m_pClient->NetobjNumCorrections());
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
w = TextRender()->TextWidth(Fontsize, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, aBuf, -1.0f);
y += LineHeight;
w = TextRender()->TextWidth(0, Fontsize, m_pClient->NetobjCorrectedOn(), -1, -1.0f);
TextRender()->Text(0, x - w, y, Fontsize, m_pClient->NetobjCorrectedOn(), -1.0f);
w = TextRender()->TextWidth(Fontsize, m_pClient->NetobjCorrectedOn(), -1, -1.0f);
TextRender()->Text(x - w, y, Fontsize, m_pClient->NetobjCorrectedOn(), -1.0f);
}
void CDebugHud::RenderTuning()
@ -110,16 +110,16 @@ void CDebugHud::RenderTuning()
str_format(aBuf, sizeof(aBuf), "%.2f", Standard);
x += 20.0f;
w = TextRender()->TextWidth(0, 5, aBuf, -1, -1.0f);
TextRender()->Text(0x0, x - w, y + Count * 6, 5, aBuf, -1.0f);
w = TextRender()->TextWidth(5, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y + Count * 6, 5, aBuf, -1.0f);
str_format(aBuf, sizeof(aBuf), "%.2f", Current);
x += 20.0f;
w = TextRender()->TextWidth(0, 5, aBuf, -1, -1.0f);
TextRender()->Text(0x0, x - w, y + Count * 6, 5, aBuf, -1.0f);
w = TextRender()->TextWidth(5, aBuf, -1, -1.0f);
TextRender()->Text(x - w, y + Count * 6, 5, aBuf, -1.0f);
x += 5.0f;
TextRender()->Text(0x0, x, y + Count * 6, 5, CTuningParams::Name(i), -1.0f);
TextRender()->Text(x, y + Count * 6, 5, CTuningParams::Name(i), -1.0f);
Count++;
}
@ -193,7 +193,7 @@ void CDebugHud::RenderTuning()
str_format(aBuf, sizeof(aBuf), "Velspeed.X*Ramp in Bps (Velspeed %d to %d)", StepSizeRampGraph / 32, 128 * StepSizeRampGraph / 32);
m_RampGraph.Render(Graphics(), Client()->GetDebugFont(), GraphX, GraphY - GraphH - sp, GraphW, GraphH, aBuf);
str_format(aBuf, sizeof(aBuf), "Max Velspeed before it ramps off: %.2f Bps", m_SpeedTurningPoint / 32);
TextRender()->Text(0x0, GraphX, GraphY - sp - GraphH - 12, 12, aBuf, -1.0f);
TextRender()->Text(GraphX, GraphY - sp - GraphH - 12, 12, aBuf, -1.0f);
str_format(aBuf, sizeof(aBuf), "Zoomed in on turning point (Velspeed %d to %d)", ((int)MiddleOfZoomedInGraph - 64 * StepSizeZoomedInGraph) / 32, ((int)MiddleOfZoomedInGraph + 64 * StepSizeZoomedInGraph) / 32);
m_ZoomedInGraph.Render(Graphics(), Client()->GetDebugFont(), GraphX, GraphY, GraphW, GraphH, aBuf);
TextRender()->TextColor(1, 1, 1, 1);
@ -207,7 +207,7 @@ void CDebugHud::RenderHint()
float Width = 300 * Graphics()->ScreenAspect();
Graphics()->MapScreen(0, 0, Width, 300);
TextRender()->TextColor(1, 1, 1, 1);
TextRender()->Text(0x0, 5, 290, 5, Localize("Debug mode enabled. Press Ctrl+Shift+D to disable debug mode."), -1.0f);
TextRender()->Text(5, 290, 5, Localize("Debug mode enabled. Press Ctrl+Shift+D to disable debug mode."), -1.0f);
}
void CDebugHud::OnRender()

View file

@ -112,11 +112,11 @@ void CHud::RenderGameTimer()
str_time((int64_t)Time * 100, TIME_DAYS, aBuf, sizeof(aBuf));
float FontSize = 10.0f;
static float s_TextWidthM = TextRender()->TextWidth(0, FontSize, "00:00", -1, -1.0f);
static float s_TextWidthH = TextRender()->TextWidth(0, FontSize, "00:00:00", -1, -1.0f);
static float s_TextWidth0D = TextRender()->TextWidth(0, FontSize, "0d 00:00:00", -1, -1.0f);
static float s_TextWidth00D = TextRender()->TextWidth(0, FontSize, "00d 00:00:00", -1, -1.0f);
static float s_TextWidth000D = TextRender()->TextWidth(0, FontSize, "000d 00:00:00", -1, -1.0f);
static float s_TextWidthM = TextRender()->TextWidth(FontSize, "00:00", -1, -1.0f);
static float s_TextWidthH = TextRender()->TextWidth(FontSize, "00:00:00", -1, -1.0f);
static float s_TextWidth0D = TextRender()->TextWidth(FontSize, "0d 00:00:00", -1, -1.0f);
static float s_TextWidth00D = TextRender()->TextWidth(FontSize, "00d 00:00:00", -1, -1.0f);
static float s_TextWidth000D = TextRender()->TextWidth(FontSize, "000d 00:00:00", -1, -1.0f);
float w = Time >= 3600 * 24 * 100 ? s_TextWidth000D : Time >= 3600 * 24 * 10 ? s_TextWidth00D : Time >= 3600 * 24 ? s_TextWidth0D : Time >= 3600 ? s_TextWidthH : s_TextWidthM;
// last 60 sec red, last 10 sec blink
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && Time <= 60 && (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer <= 0))
@ -124,7 +124,7 @@ void CHud::RenderGameTimer()
float Alpha = Time <= 10 && (2 * time() / time_freq()) % 2 ? 0.5f : 1.0f;
TextRender()->TextColor(1.0f, 0.25f, 0.25f, Alpha);
}
TextRender()->Text(0, Half - w / 2, 2, FontSize, aBuf, -1.0f);
TextRender()->Text(Half - w / 2, 2, FontSize, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -136,8 +136,8 @@ void CHud::RenderPauseNotification()
{
const char *pText = Localize("Game paused");
float FontSize = 20.0f;
float w = TextRender()->TextWidth(0, FontSize, pText, -1, -1.0f);
TextRender()->Text(0, 150.0f * Graphics()->ScreenAspect() + -w / 2.0f, 50.0f, FontSize, pText, -1.0f);
float w = TextRender()->TextWidth(FontSize, pText, -1, -1.0f);
TextRender()->Text(150.0f * Graphics()->ScreenAspect() + -w / 2.0f, 50.0f, FontSize, pText, -1.0f);
}
}
@ -148,8 +148,8 @@ void CHud::RenderSuddenDeath()
float Half = m_Width / 2.0f;
const char *pText = Localize("Sudden Death");
float FontSize = 12.0f;
float w = TextRender()->TextWidth(0, FontSize, pText, -1, -1.0f);
TextRender()->Text(0, Half - w / 2, 2, FontSize, pText, -1.0f);
float w = TextRender()->TextWidth(FontSize, pText, -1, -1.0f);
TextRender()->Text(Half - w / 2, 2, FontSize, pText, -1.0f);
}
}
@ -183,13 +183,13 @@ void CHud::RenderScoreHud()
{
if(aRecreateTeamScore[t])
{
m_aScoreInfo[t].m_ScoreTextWidth = TextRender()->TextWidth(0, 14.0f, aScoreTeam[t == 0 ? TEAM_RED : TEAM_BLUE], -1, -1.0f);
m_aScoreInfo[t].m_ScoreTextWidth = TextRender()->TextWidth(14.0f, aScoreTeam[t == 0 ? TEAM_RED : TEAM_BLUE], -1, -1.0f);
mem_copy(m_aScoreInfo[t].m_aScoreText, aScoreTeam[t == 0 ? TEAM_RED : TEAM_BLUE], sizeof(m_aScoreInfo[t].m_aScoreText));
RecreateRect = true;
}
}
static float s_TextWidth100 = TextRender()->TextWidth(0, 14.0f, "100", -1, -1.0f);
static float s_TextWidth100 = TextRender()->TextWidth(14.0f, "100", -1, -1.0f);
float ScoreWidthMax = maximum(maximum(m_aScoreInfo[0].m_ScoreTextWidth, m_aScoreInfo[1].m_ScoreTextWidth), s_TextWidth100);
float Split = 3.0f;
float ImageSize = (GameFlags & GAMEFLAG_FLAGS) ? 16.0f : Split;
@ -252,7 +252,7 @@ void CHud::RenderScoreHud()
TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_OptionalNameTextContainerIndex);
float w = TextRender()->TextWidth(0, 8.0f, pName, -1, -1.0f);
float w = TextRender()->TextWidth(8.0f, pName, -1, -1.0f);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, minimum(m_Width - w - 1.0f, m_Width - ScoreWidthMax - ImageSize - 2 * Split), StartY + (t + 1) * 20.0f - 2.0f, 8.0f, TEXTFLAG_RENDER);
@ -341,7 +341,7 @@ void CHud::RenderScoreHud()
{
if(RecreateScores)
{
m_aScoreInfo[t].m_ScoreTextWidth = TextRender()->TextWidth(0, 14.0f, aScore[t], -1, -1.0f);
m_aScoreInfo[t].m_ScoreTextWidth = TextRender()->TextWidth(14.0f, aScore[t], -1, -1.0f);
mem_copy(m_aScoreInfo[t].m_aScoreText, aScore[t], sizeof(m_aScoreInfo[t].m_aScoreText));
RecreateRect = true;
}
@ -368,7 +368,7 @@ void CHud::RenderScoreHud()
RecreateRect = true;
}
static float s_TextWidth10 = TextRender()->TextWidth(0, 14.0f, "10", -1, -1.0f);
static float s_TextWidth10 = TextRender()->TextWidth(14.0f, "10", -1, -1.0f);
float ScoreWidthMax = maximum(maximum(m_aScoreInfo[0].m_ScoreTextWidth, m_aScoreInfo[1].m_ScoreTextWidth), s_TextWidth10);
float Split = 3.0f, ImageSize = 16.0f, PosSize = 16.0f;
@ -421,7 +421,7 @@ void CHud::RenderScoreHud()
TextRender()->DeleteTextContainer(m_aScoreInfo[t].m_OptionalNameTextContainerIndex);
CTextCursor Cursor;
float w = TextRender()->TextWidth(0, 8.0f, pName, -1, -1.0f);
float w = TextRender()->TextWidth(8.0f, pName, -1, -1.0f);
TextRender()->SetCursor(&Cursor, minimum(m_Width - w - 1.0f, m_Width - ScoreWidthMax - ImageSize - 2 * Split - PosSize), StartY + (t + 1) * 20.0f - 2.0f, 8.0f, TEXTFLAG_RENDER);
Cursor.m_LineWidth = -1;
TextRender()->CreateTextContainer(m_aScoreInfo[t].m_OptionalNameTextContainerIndex, &Cursor, pName);
@ -485,16 +485,16 @@ void CHud::RenderWarmupTimer()
{
char aBuf[256];
float FontSize = 20.0f;
float w = TextRender()->TextWidth(0, FontSize, Localize("Warmup"), -1, -1.0f);
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 50, FontSize, Localize("Warmup"), -1.0f);
float w = TextRender()->TextWidth(FontSize, Localize("Warmup"), -1, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() + -w / 2, 50, FontSize, Localize("Warmup"), -1.0f);
int Seconds = m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer / SERVER_TICK_SPEED;
if(Seconds < 5)
str_format(aBuf, sizeof(aBuf), "%d.%d", Seconds, (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer * 10 / SERVER_TICK_SPEED) % 10);
else
str_format(aBuf, sizeof(aBuf), "%d", Seconds);
w = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() + -w / 2, 75, FontSize, aBuf, -1.0f);
w = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() + -w / 2, 75, FontSize, aBuf, -1.0f);
}
}
@ -508,15 +508,15 @@ void CHud::RenderTextInfo()
int FrameTime = (int)(1.0f / m_FrameTimeAvg + 0.5f);
str_format(aBuf, sizeof(aBuf), "%d", FrameTime);
static float s_TextWidth0 = TextRender()->TextWidth(0, 12.f, "0", -1, -1.0f);
static float s_TextWidth00 = TextRender()->TextWidth(0, 12.f, "00", -1, -1.0f);
static float s_TextWidth000 = TextRender()->TextWidth(0, 12.f, "000", -1, -1.0f);
static float s_TextWidth0000 = TextRender()->TextWidth(0, 12.f, "0000", -1, -1.0f);
static float s_TextWidth00000 = TextRender()->TextWidth(0, 12.f, "00000", -1, -1.0f);
static float s_TextWidth0 = TextRender()->TextWidth(12.f, "0", -1, -1.0f);
static float s_TextWidth00 = TextRender()->TextWidth(12.f, "00", -1, -1.0f);
static float s_TextWidth000 = TextRender()->TextWidth(12.f, "000", -1, -1.0f);
static float s_TextWidth0000 = TextRender()->TextWidth(12.f, "0000", -1, -1.0f);
static float s_TextWidth00000 = TextRender()->TextWidth(12.f, "00000", -1, -1.0f);
static const float s_aTextWidth[5] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000};
int DigitIndex = GetDigitsIndex(FrameTime, 4);
//TextRender()->Text(0, m_Width-10-TextRender()->TextWidth(0,12,Buf,-1,-1.0f), 5, 12, Buf, -1.0f);
//TextRender()->Text(m_Width-10-TextRender()->TextWidth(0,12,Buf,-1,-1.0f), 5, 12, Buf, -1.0f);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, m_Width - 10 - s_aTextWidth[DigitIndex], 5, 12, TEXTFLAG_RENDER);
@ -536,7 +536,7 @@ void CHud::RenderTextInfo()
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%d", Client()->GetPredictionTime());
TextRender()->Text(0, m_Width - 10 - TextRender()->TextWidth(0, 12, aBuf, -1, -1.0f), g_Config.m_ClShowfps ? 20 : 5, 12, aBuf, -1.0f);
TextRender()->Text(m_Width - 10 - TextRender()->TextWidth(12, aBuf, -1, -1.0f), g_Config.m_ClShowfps ? 20 : 5, 12, aBuf, -1.0f);
}
}
@ -545,8 +545,8 @@ void CHud::RenderConnectionWarning()
if(Client()->ConnectionProblems())
{
const char *pText = Localize("Connection Problems...");
float w = TextRender()->TextWidth(0, 24, pText, -1, -1.0f);
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - w / 2, 50, 24, pText, -1.0f);
float w = TextRender()->TextWidth(24, pText, -1, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() - w / 2, 50, 24, pText, -1.0f);
}
}
@ -564,7 +564,7 @@ void CHud::RenderTeambalanceWarning()
TextRender()->TextColor(1, 1, 0.5f, 1);
else
TextRender()->TextColor(0.7f, 0.7f, 0.2f, 1.0f);
TextRender()->Text(0x0, 5, 50, 6, pText, -1.0f);
TextRender()->Text(5, 50, 6, pText, -1.0f);
TextRender()->TextColor(1, 1, 1, 1);
}
}
@ -582,7 +582,7 @@ void CHud::RenderVoting()
CTextCursor Cursor;
char aBuf[512];
str_format(aBuf, sizeof(aBuf), Localize("%ds left"), m_pClient->m_Voting.SecondsLeft());
float tw = TextRender()->TextWidth(0x0, 6, aBuf, -1, -1.0f);
float tw = TextRender()->TextWidth(6, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, 5.0f + 100.0f - tw, 60.0f, 6.0f, TEXTFLAG_RENDER);
TextRender()->TextEx(&Cursor, aBuf, -1);
@ -1409,69 +1409,69 @@ void CHud::RenderMovementInformation(const int ClientID)
float xr = m_Width - 2;
int DigitsIndex;
static float s_TextWidth0 = TextRender()->TextWidth(0, Fontsize, "0.00", -1, -1.0f);
static float s_TextWidth00 = TextRender()->TextWidth(0, Fontsize, "00.00", -1, -1.0f);
static float s_TextWidth000 = TextRender()->TextWidth(0, Fontsize, "000.00", -1, -1.0f);
static float s_TextWidth0000 = TextRender()->TextWidth(0, Fontsize, "0000.00", -1, -1.0f);
static float s_TextWidth00000 = TextRender()->TextWidth(0, Fontsize, "00000.00", -1, -1.0f);
static float s_TextWidth000000 = TextRender()->TextWidth(0, Fontsize, "000000.00", -1, -1.0f);
static float s_TextWidth0 = TextRender()->TextWidth(Fontsize, "0.00", -1, -1.0f);
static float s_TextWidth00 = TextRender()->TextWidth(Fontsize, "00.00", -1, -1.0f);
static float s_TextWidth000 = TextRender()->TextWidth(Fontsize, "000.00", -1, -1.0f);
static float s_TextWidth0000 = TextRender()->TextWidth(Fontsize, "0000.00", -1, -1.0f);
static float s_TextWidth00000 = TextRender()->TextWidth(Fontsize, "00000.00", -1, -1.0f);
static float s_TextWidth000000 = TextRender()->TextWidth(Fontsize, "000000.00", -1, -1.0f);
static float s_aTextWidth[6] = {s_TextWidth0, s_TextWidth00, s_TextWidth000, s_TextWidth0000, s_TextWidth00000, s_TextWidth000000};
static float s_TextWidthMinus0 = TextRender()->TextWidth(0, Fontsize, "-0.00", -1, -1.0f);
static float s_TextWidthMinus00 = TextRender()->TextWidth(0, Fontsize, "-00.00", -1, -1.0f);
static float s_TextWidthMinus000 = TextRender()->TextWidth(0, Fontsize, "-000.00", -1, -1.0f);
static float s_TextWidthMinus0000 = TextRender()->TextWidth(0, Fontsize, "-0000.00", -1, -1.0f);
static float s_TextWidthMinus00000 = TextRender()->TextWidth(0, Fontsize, "-00000.00", -1, -1.0f);
static float s_TextWidthMinus000000 = TextRender()->TextWidth(0, Fontsize, "-000000.00", -1, -1.0f);
static float s_TextWidthMinus0 = TextRender()->TextWidth(Fontsize, "-0.00", -1, -1.0f);
static float s_TextWidthMinus00 = TextRender()->TextWidth(Fontsize, "-00.00", -1, -1.0f);
static float s_TextWidthMinus000 = TextRender()->TextWidth(Fontsize, "-000.00", -1, -1.0f);
static float s_TextWidthMinus0000 = TextRender()->TextWidth(Fontsize, "-0000.00", -1, -1.0f);
static float s_TextWidthMinus00000 = TextRender()->TextWidth(Fontsize, "-00000.00", -1, -1.0f);
static float s_TextWidthMinus000000 = TextRender()->TextWidth(Fontsize, "-000000.00", -1, -1.0f);
static float s_aTextWidthMinus[6] = {s_TextWidthMinus0, s_TextWidthMinus00, s_TextWidthMinus000, s_TextWidthMinus0000, s_TextWidthMinus00000, s_TextWidthMinus000000};
if(g_Config.m_ClShowhudPlayerPosition)
{
TextRender()->Text(0, xl, y, Fontsize, Localize("Position:"), -1.0f);
TextRender()->Text(xl, y, Fontsize, Localize("Position:"), -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
TextRender()->Text(0, xl, y, Fontsize, "X:", -1.0f);
TextRender()->Text(xl, y, Fontsize, "X:", -1.0f);
str_format(aBuf, sizeof(aBuf), "%.2f", PosX);
DigitsIndex = GetDigitsIndex(PosX, 5);
w = (PosX < 0) ? s_aTextWidthMinus[DigitsIndex] : s_aTextWidth[DigitsIndex];
TextRender()->Text(0, xr - w, y, Fontsize, aBuf, -1.0f);
TextRender()->Text(xr - w, y, Fontsize, aBuf, -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
TextRender()->Text(0, xl, y, Fontsize, "Y:", -1.0f);
TextRender()->Text(xl, y, Fontsize, "Y:", -1.0f);
str_format(aBuf, sizeof(aBuf), "%.2f", PosY);
DigitsIndex = GetDigitsIndex(PosY, 5);
w = (PosY < 0) ? s_aTextWidthMinus[DigitsIndex] : s_aTextWidth[DigitsIndex];
TextRender()->Text(0, xr - w, y, Fontsize, aBuf, -1.0f);
TextRender()->Text(xr - w, y, Fontsize, aBuf, -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
}
if(g_Config.m_ClShowhudPlayerSpeed)
{
TextRender()->Text(0, xl, y, Fontsize, Localize("Speed:"), -1.0f);
TextRender()->Text(xl, y, Fontsize, Localize("Speed:"), -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
TextRender()->Text(0, xl, y, Fontsize, "X:", -1.0f);
TextRender()->Text(xl, y, Fontsize, "X:", -1.0f);
str_format(aBuf, sizeof(aBuf), "%.2f", DisplaySpeedX);
DigitsIndex = GetDigitsIndex(DisplaySpeedX, 5);
w = (DisplaySpeedX < 0) ? s_aTextWidthMinus[DigitsIndex] : s_aTextWidth[DigitsIndex];
TextRender()->Text(0, xr - w, y, Fontsize, aBuf, -1.0f);
TextRender()->Text(xr - w, y, Fontsize, aBuf, -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
TextRender()->Text(0, xl, y, Fontsize, "Y:", -1.0f);
TextRender()->Text(xl, y, Fontsize, "Y:", -1.0f);
str_format(aBuf, sizeof(aBuf), "%.2f", DisplaySpeedY);
DigitsIndex = GetDigitsIndex(DisplaySpeedY, 5);
w = (DisplaySpeedY < 0) ? s_aTextWidthMinus[DigitsIndex] : s_aTextWidth[DigitsIndex];
TextRender()->Text(0, xr - w, y, Fontsize, aBuf, -1.0f);
TextRender()->Text(xr - w, y, Fontsize, aBuf, -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
}
if(g_Config.m_ClShowhudPlayerAngle)
{
TextRender()->Text(0, xl, y, Fontsize, Localize("Angle:"), -1.0f);
TextRender()->Text(xl, y, Fontsize, Localize("Angle:"), -1.0f);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
str_format(aBuf, sizeof(aBuf), "%.2f", DisplayAngle);
DigitsIndex = GetDigitsIndex(DisplayAngle, 5);
w = (DisplayAngle < 0) ? s_aTextWidthMinus[DigitsIndex] : s_aTextWidth[DigitsIndex];
TextRender()->Text(0, xr - w, y, Fontsize, aBuf, -1.0f);
TextRender()->Text(xr - w, y, Fontsize, aBuf, -1.0f);
}
}
@ -1483,7 +1483,7 @@ void CHud::RenderSpectatorHud()
// draw the text
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Spectate"), m_pClient->m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW ? m_pClient->m_aClients[m_pClient->m_Snap.m_SpecInfo.m_SpectatorID].m_aName : Localize("Free-View"));
TextRender()->Text(0, m_Width - 174.0f, m_Height - 15.0f + (15.f - 8.f) / 2.f, 8.0f, aBuf, -1.0f);
TextRender()->Text(m_Width - 174.0f, m_Height - 15.0f + (15.f - 8.f) / 2.f, 8.0f, aBuf, -1.0f);
}
void CHud::RenderLocalTime(float x)
@ -1497,7 +1497,7 @@ void CHud::RenderLocalTime(float x)
// draw the text
char aTimeStr[6];
str_timestamp_format(aTimeStr, sizeof(aTimeStr), "%H:%M");
TextRender()->Text(0, x - 25.0f, (12.5f - 5.f) / 2.f, 5.0f, aTimeStr, -1.0f);
TextRender()->Text(x - 25.0f, (12.5f - 5.f) / 2.f, 5.0f, aTimeStr, -1.0f);
}
void CHud::OnRender()
@ -1632,7 +1632,7 @@ void CHud::RenderDDRaceEffects()
}
TextRender()->TextColor(1, 1, 1, alpha);
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 12, aBuf, -1, -1.0f) / 2, 20, 12, aBuf, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(12, aBuf, -1, -1.0f) / 2, 20, 12, aBuf, -1.0f);
if(m_FinishTimeDiff != 0.0f)
{
if(m_FinishTimeDiff < 0)
@ -1647,7 +1647,7 @@ void CHud::RenderDDRaceEffects()
str_format(aBuf, sizeof(aBuf), "+%s", aTime);
TextRender()->TextColor(1.0f, 0.5f, 0.5f, alpha); // red
}
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 34, 10, aBuf, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(10, aBuf, -1, -1.0f) / 2, 34, 10, aBuf, -1.0f);
}
TextRender()->TextColor(1, 1, 1, 1);
}
@ -1678,7 +1678,7 @@ void CHud::RenderDDRaceEffects()
TextRender()->TextColor(0.5f, 1.0f, 0.5f, alpha); // green
else if(!m_TimeCpDiff)
TextRender()->TextColor(1, 1, 1, alpha); // white
TextRender()->Text(0, 150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(0, 10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);
TextRender()->Text(150 * Graphics()->ScreenAspect() - TextRender()->TextWidth(10, aBuf, -1, -1.0f) / 2, 20, 10, aBuf, -1.0f);
TextRender()->TextColor(1, 1, 1, 1);
}
@ -1691,11 +1691,11 @@ void CHud::RenderRecord()
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("Server best:"));
TextRender()->Text(0, 5, 75, 6, aBuf, -1.0f);
TextRender()->Text(5, 75, 6, aBuf, -1.0f);
char aTime[32];
str_time_float(m_ServerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
str_format(aBuf, sizeof(aBuf), "%s%s", m_ServerRecord > 3600 ? "" : " ", aTime);
TextRender()->Text(0, 53, 75, 6, aBuf, -1.0f);
TextRender()->Text(53, 75, 6, aBuf, -1.0f);
}
const float PlayerRecord = m_aPlayerRecord[g_Config.m_ClDummy];
@ -1703,10 +1703,10 @@ void CHud::RenderRecord()
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("Personal best:"));
TextRender()->Text(0, 5, 82, 6, aBuf, -1.0f);
TextRender()->Text(5, 82, 6, aBuf, -1.0f);
char aTime[32];
str_time_float(PlayerRecord, TIME_HOURS_CENTISECS, aTime, sizeof(aTime));
str_format(aBuf, sizeof(aBuf), "%s%s", PlayerRecord > 3600 ? "" : " ", aTime);
TextRender()->Text(0, 53, 82, 6, aBuf, -1.0f);
TextRender()->Text(53, 82, 6, aBuf, -1.0f);
}
}

View file

@ -62,7 +62,7 @@ void CKillMessages::CreateKillmessageNamesIfNotCreated(CKillMsg &Kill)
const float FontSize = 36.0f;
if(Kill.m_VictimTextContainerIndex == -1 && Kill.m_aVictimName[0] != 0)
{
Kill.m_VitctimTextWidth = TextRender()->TextWidth(0, FontSize, Kill.m_aVictimName, -1, -1.0f);
Kill.m_VitctimTextWidth = TextRender()->TextWidth(FontSize, Kill.m_aVictimName, -1, -1.0f);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);
@ -80,7 +80,7 @@ void CKillMessages::CreateKillmessageNamesIfNotCreated(CKillMsg &Kill)
if(Kill.m_KillerTextContainerIndex == -1 && Kill.m_aKillerName[0] != 0)
{
Kill.m_KillerTextWidth = TextRender()->TextWidth(0, FontSize, Kill.m_aKillerName, -1, -1.0f);
Kill.m_KillerTextWidth = TextRender()->TextWidth(FontSize, Kill.m_aKillerName, -1, -1.0f);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSize, TEXTFLAG_RENDER);

View file

@ -409,7 +409,7 @@ ColorHSLA CMenus::DoLine_ColorPicker(CButtonContainer *pResetID, const float Lin
}
Section.VSplitLeft(5.0f, 0x0, &Section);
float LabelWidth = TextRender()->TextWidth(0, 14.0f, pText, -1, -1.0f);
float LabelWidth = TextRender()->TextWidth(14.0f, pText, -1, -1.0f);
Section.VSplitLeft(LabelWidth, &Label, &Section);
UI()->DoLabel(&Label, pText, LabelSize, TEXTALIGN_LEFT);
@ -1627,7 +1627,7 @@ int CMenus::Render()
SLabelProperties Props;
Props.m_MaxWidth = (int)Part.w;
if(TextRender()->TextWidth(0, 24.f, pTitle, -1, -1.0f) > Part.w)
if(TextRender()->TextWidth(24.f, pTitle, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_LEFT, Props);
else
UI()->DoLabel(&Part, pTitle, 24.f, TEXTALIGN_CENTER);
@ -1650,7 +1650,7 @@ int CMenus::Render()
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props);
else
{
if(TextRender()->TextWidth(0, FontSize, pExtraText, -1, -1.0f) > Part.w)
if(TextRender()->TextWidth(FontSize, pExtraText, -1, -1.0f) > Part.w)
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_LEFT, Props);
else
UI()->DoLabel(&Part, pExtraText, FontSize, TEXTALIGN_CENTER);

View file

@ -491,8 +491,8 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
SLabelProperties Props;
Props.m_AlignVertically = 0;
UI()->DoLabel(&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);
SearchIconWidth = TextRender()->TextWidth(16.0f, pSearchLabel, -1, -1.0f);
ExcludeIconWidth = TextRender()->TextWidth(16.0f, pExcludeLabel, -1, -1.0f);
ExcludeSearchIconMax = maximum(SearchIconWidth, ExcludeIconWidth);
TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL);
@ -559,9 +559,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
CUIRect SvrsOnline, PlysOnline;
Status3.HSplitTop(20.f, &PlysOnline, &SvrsOnline);
PlysOnline.VSplitRight(TextRender()->TextWidth(0, 12.0f, aBufPyr, -1, -1.0f), 0, &PlysOnline);
PlysOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufPyr, -1, -1.0f), 0, &PlysOnline);
UI()->DoLabel(&PlysOnline, aBufPyr, 12.0f, TEXTALIGN_LEFT);
SvrsOnline.VSplitRight(TextRender()->TextWidth(0, 12.0f, aBufSvr, -1, -1.0f), 0, &SvrsOnline);
SvrsOnline.VSplitRight(TextRender()->TextWidth(12.0f, aBufSvr, -1, -1.0f), 0, &SvrsOnline);
UI()->DoLabel(&SvrsOnline, aBufSvr, 12.0f, TEXTALIGN_LEFT);
// status box
@ -1140,7 +1140,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
str_format(aTemp, sizeof(aTemp), "%d", CurrentClient.m_Score);
float ScoreFontSize = 12.0f;
while(ScoreFontSize >= 4.0f && TextRender()->TextWidth(0, ScoreFontSize, aTemp, -1, -1.0f) > Score.w)
while(ScoreFontSize >= 4.0f && TextRender()->TextWidth(ScoreFontSize, aTemp, -1, -1.0f) > Score.w)
ScoreFontSize--;
TextRender()->SetCursor(&Cursor, Score.x, Score.y + (Score.h - ScoreFontSize) / 2.0f, ScoreFontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);

View file

@ -304,7 +304,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
char aSpeedBuf[256];
str_format(aSpeedBuf, sizeof(aSpeedBuf), "×%.2f", pInfo->m_Speed);
TextRender()->Text(0, 120.0f, Screen.y + Screen.h - 120.0f - TotalHeight, 60.0f, aSpeedBuf, -1.0f);
TextRender()->Text(120.0f, Screen.y + Screen.h - 120.0f - TotalHeight, 60.0f, aSpeedBuf, -1.0f);
}
const int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick;

View file

@ -392,7 +392,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
x = 5.0f;
y = 0.0f;
TextRender()->Text(0, ServerInfo.x + x, ServerInfo.y + y, 32, Localize("Server info"), 250.0f);
TextRender()->Text(ServerInfo.x + x, ServerInfo.y + y, 32, Localize("Server info"), 250.0f);
y += 32.0f + 5.0f;
mem_zero(aBuf, sizeof(aBuf));
@ -410,7 +410,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
Localize("Version"), CurrentServerInfo.m_aVersion,
Localize("Password"), CurrentServerInfo.m_Flags & 1 ? Localize("Yes") : Localize("No"));
TextRender()->Text(0, ServerInfo.x + x, ServerInfo.y + y, 20, aBuf, 250.0f);
TextRender()->Text(ServerInfo.x + x, ServerInfo.y + y, 20, aBuf, 250.0f);
// copy info button
{
@ -451,7 +451,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
x = 5.0f;
y = 0.0f;
TextRender()->Text(0, GameInfo.x + x, GameInfo.y + y, 32, Localize("Game info"), 250.0f);
TextRender()->Text(GameInfo.x + x, GameInfo.y + y, 32, Localize("Game info"), 250.0f);
y += 32.0f + 5.0f;
if(m_pClient->m_Snap.m_pGameInfoObj)
@ -472,7 +472,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
Localize("Score limit"), m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit,
Localize("Time limit"), m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit,
Localize("Players"), m_pClient->m_Snap.m_NumPlayers, CurrentServerInfo.m_MaxClients);
TextRender()->Text(0, GameInfo.x + x, GameInfo.y + y, 20, aBuf, 250.0f);
TextRender()->Text(GameInfo.x + x, GameInfo.y + y, 20, aBuf, 250.0f);
}
// motd
@ -485,7 +485,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
CUIRect MotdHeader;
Motd.HSplitTop(2.0f * MotdFontSize, &MotdHeader, &Motd);
Motd.HSplitTop(5.0f, nullptr, &Motd);
TextRender()->Text(nullptr, MotdHeader.x, MotdHeader.y, 2.0f * MotdFontSize, Localize("MOTD"), -1.0f);
TextRender()->Text(MotdHeader.x, MotdHeader.y, 2.0f * MotdFontSize, Localize("MOTD"), -1.0f);
static CScrollRegion s_ScrollRegion;
vec2 ScrollOffset(0.0f, 0.0f);
@ -497,7 +497,7 @@ void CMenus::RenderServerInfo(CUIRect MainView)
CUIRect MotdTextArea;
Motd.HSplitTop((str_countchr(m_pClient->m_Motd.m_aServerMotd, '\n') + 1) * MotdFontSize, &MotdTextArea, &Motd);
s_ScrollRegion.AddRect(MotdTextArea);
TextRender()->Text(nullptr, MotdTextArea.x, MotdTextArea.y, MotdFontSize, m_pClient->m_Motd.m_aServerMotd, MotdTextArea.w);
TextRender()->Text(MotdTextArea.x, MotdTextArea.y, MotdFontSize, m_pClient->m_Motd.m_aServerMotd, MotdTextArea.w);
s_ScrollRegion.End();
}
@ -660,7 +660,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
SLabelProperties Props;
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
float wSearch = TextRender()->TextWidth(14.0f, pSearchLabel, -1, -1.0f);
TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
@ -718,7 +718,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
Reason.HSplitTop(5.0f, 0, &Reason);
const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_LEFT);
float w = TextRender()->TextWidth(0, 14.0f, pLabel, -1, -1.0f);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
Reason.VSplitLeft(w + 10.0f, 0, &Reason);
static float s_Offset = 0.0f;
if(Input()->KeyPress(KEY_R) && Input()->ModifierIsPressed())
@ -1154,6 +1154,6 @@ void CMenus::RenderIngameHint()
float Width = 300 * Graphics()->ScreenAspect();
Graphics()->MapScreen(0, 0, Width, 300);
TextRender()->TextColor(1, 1, 1, 1);
TextRender()->Text(0x0, 5, 280, 5, Localize("Menu opened. Press Esc key again to close menu."), -1.0f);
TextRender()->Text(5, 280, 5, Localize("Menu opened. Press Esc key again to close menu."), -1.0f);
UI()->MapScreen();
}

View file

@ -880,7 +880,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
SLabelProperties Props;
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
float wSearch = TextRender()->TextWidth(14.0f, pSearchLabel, -1, -1.0f);
TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);
@ -1272,7 +1272,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
MouseSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
MouseSettings.VMargin(10.0f, &MouseSettings);
TextRender()->Text(0, MouseSettings.x, MouseSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Mouse"), -1.0f);
TextRender()->Text(MouseSettings.x, MouseSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Mouse"), -1.0f);
MouseSettings.HSplitTop(HeaderHeight, 0, &MouseSettings);
@ -1296,7 +1296,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
JoystickSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
JoystickSettings.VMargin(Margin, &JoystickSettings);
TextRender()->Text(0, JoystickSettings.x, JoystickSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Controller"), -1.0f);
TextRender()->Text(JoystickSettings.x, JoystickSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Controller"), -1.0f);
JoystickSettings.HSplitTop(HeaderHeight, 0, &JoystickSettings);
s_JoystickSettingsHeight = RenderSettingsControlsJoystick(JoystickSettings);
@ -1312,7 +1312,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
MovementSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
MovementSettings.VMargin(Margin, &MovementSettings);
TextRender()->Text(0, MovementSettings.x, MovementSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Movement"), -1.0f);
TextRender()->Text(MovementSettings.x, MovementSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Movement"), -1.0f);
MovementSettings.HSplitTop(HeaderHeight, 0, &MovementSettings);
DoSettingsControlsButtons(0, 15, MovementSettings);
@ -1328,7 +1328,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
WeaponSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
WeaponSettings.VMargin(Margin, &WeaponSettings);
TextRender()->Text(0, WeaponSettings.x, WeaponSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Weapon"), -1.0f);
TextRender()->Text(WeaponSettings.x, WeaponSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Weapon"), -1.0f);
WeaponSettings.HSplitTop(HeaderHeight, 0, &WeaponSettings);
DoSettingsControlsButtons(15, 22, WeaponSettings);
@ -1362,7 +1362,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
VotingSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
VotingSettings.VMargin(Margin, &VotingSettings);
TextRender()->Text(0, VotingSettings.x, VotingSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Voting"), -1.0f);
TextRender()->Text(VotingSettings.x, VotingSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Voting"), -1.0f);
VotingSettings.HSplitTop(HeaderHeight, 0, &VotingSettings);
DoSettingsControlsButtons(22, 24, VotingSettings);
@ -1378,7 +1378,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
ChatSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
ChatSettings.VMargin(Margin, &ChatSettings);
TextRender()->Text(0, ChatSettings.x, ChatSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Chat"), -1.0f);
TextRender()->Text(ChatSettings.x, ChatSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Chat"), -1.0f);
ChatSettings.HSplitTop(HeaderHeight, 0, &ChatSettings);
DoSettingsControlsButtons(24, 29, ChatSettings);
@ -1394,7 +1394,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
DummySettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
DummySettings.VMargin(Margin, &DummySettings);
TextRender()->Text(0, DummySettings.x, DummySettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Dummy"), -1.0f);
TextRender()->Text(DummySettings.x, DummySettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Dummy"), -1.0f);
DummySettings.HSplitTop(HeaderHeight, 0, &DummySettings);
DoSettingsControlsButtons(29, 32, DummySettings);
@ -1410,7 +1410,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView)
MiscSettings.Draw(ColorRGBA(1, 1, 1, 0.25f), IGraphics::CORNER_ALL, 10.0f);
MiscSettings.VMargin(Margin, &MiscSettings);
TextRender()->Text(0, MiscSettings.x, MiscSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Miscellaneous"), -1.0f);
TextRender()->Text(MiscSettings.x, MiscSettings.y + (HeaderHeight - FontSize) / 2.f, FontSize, Localize("Miscellaneous"), -1.0f);
MiscSettings.HSplitTop(HeaderHeight, 0, &MiscSettings);
DoSettingsControlsButtons(32, 44, MiscSettings);
@ -2881,32 +2881,32 @@ void CMenus::RenderSettingsAppearance(CUIRect MainView)
if(g_Config.m_ClShowChatSystem)
{
str_format(aLineBuilder, sizeof(aLineBuilder), "*** '%s' entered and joined the game", aBuf);
Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1);
Width = TextRender()->TextWidth(RealFontSize, aLineBuilder, -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
TempY += RealOffsetY;
}
str_format(aLineBuilder, sizeof(aLineBuilder), "%sRandom Tee: Hey, how are you %s?", g_Config.m_ClShowIDs ? "7: " : "", aBuf);
Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1);
Width = TextRender()->TextWidth(RealFontSize, aLineBuilder, -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
TempY += RealOffsetY;
str_format(aLineBuilder, sizeof(aLineBuilder), "%sYour Teammate: Let's speedrun this!", g_Config.m_ClShowIDs ? "11: " : "");
Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1);
Width = TextRender()->TextWidth(RealFontSize, aLineBuilder, -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
TempY += RealOffsetY;
str_format(aLineBuilder, sizeof(aLineBuilder), "%s%sFriend: Hello there", g_Config.m_ClMessageFriend ? "" : "", g_Config.m_ClShowIDs ? "8: " : "");
Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1);
Width = TextRender()->TextWidth(RealFontSize, aLineBuilder, -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
TempY += RealOffsetY;
str_format(aLineBuilder, sizeof(aLineBuilder), "%sSpammer [6]: Hey fools, I'm spamming here!", g_Config.m_ClShowIDs ? "9: " : "");
Width = TextRender()->TextWidth(0, RealFontSize, aLineBuilder, -1, -1);
Width = TextRender()->TextWidth(RealFontSize, aLineBuilder, -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX + RealMsgPaddingTee, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
TempY += RealOffsetY;
Width = TextRender()->TextWidth(0, RealFontSize, "*** Echo command executed", -1, -1);
Width = TextRender()->TextWidth(RealFontSize, "*** Echo command executed", -1, -1);
Graphics()->DrawRectExt(X - RealMsgPaddingX / 2.0f, TempY - RealMsgPaddingY / 2.0f, Width + RealMsgPaddingX, RealFontSize + RealMsgPaddingY, RealBackgroundRounding, IGraphics::CORNER_ALL);
Graphics()->QuadsEnd();
@ -3471,7 +3471,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
if(NeedUpdate && State <= IUpdater::CLEAN)
{
str_format(aBuf, sizeof(aBuf), Localize("DDNet %s is available:"), Client()->LatestVersion());
Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button);
Label.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button);
Button.VSplitLeft(100.0f, &Button, 0);
static CButtonContainer s_ButtonUpdate;
if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Button))
@ -3489,7 +3489,7 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
else
{
str_format(aBuf, sizeof(aBuf), Localize("No updates available"));
Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button);
Label.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, &Label, &Button);
Button.VSplitLeft(100.0f, &Button, 0);
static CButtonContainer s_ButtonUpdate;
if(DoButton_Menu(&s_ButtonUpdate, Localize("Check now"), 0, &Button))

View file

@ -646,7 +646,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView)
SLabelProperties Props;
Props.m_AlignVertically = 0;
UI()->DoLabel(&QuickSearch, pSearchLabel, 14.0f, TEXTALIGN_LEFT, Props);
float wSearch = TextRender()->TextWidth(0, 14.0f, pSearchLabel, -1, -1.0f);
float wSearch = TextRender()->TextWidth(14.0f, pSearchLabel, -1, -1.0f);
TextRender()->SetRenderFlags(0);
TextRender()->SetCurFont(NULL);
QuickSearch.VSplitLeft(wSearch, 0, &QuickSearch);

View file

@ -235,7 +235,7 @@ void CMenus::RenderStartMenu(CUIRect MainView)
UI()->DoLabel(&VersionUpdate, aBuf, 14.0f, TEXTALIGN_LEFT);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
VersionUpdate.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part);
VersionUpdate.VSplitLeft(TextRender()->TextWidth(14.0f, aBuf, -1, -1.0f) + 10.0f, 0, &Part);
if(State == IUpdater::CLEAN && NeedUpdate)
{

View file

@ -43,7 +43,7 @@ void CMotd::OnRender()
Graphics()->DrawRect(x, y, w, h, ColorRGBA(0.0f, 0.0f, 0.0f, 0.5f), IGraphics::CORNER_ALL, 40.0f);
TextRender()->Text(0, x + 40.0f, y + 40.0f, 32.0f, m_aServerMotd, w - 80.0f);
TextRender()->Text(x + 40.0f, y + 40.0f, 32.0f, m_aServerMotd, w - 80.0f);
}
void CMotd::OnMessage(int MsgType, void *pRawMsg)

View file

@ -103,7 +103,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1, -1.0f);
m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(FontSize, pName, -1, -1.0f);
TextRender()->CreateTextContainer(m_aNamePlates[ClientID].m_NameTextContainerIndex, &Cursor, pName);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
@ -128,7 +128,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1, -1.0f);
m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(FontSizeClan, pClan, -1, -1.0f);
TextRender()->CreateTextContainer(m_aNamePlates[ClientID].m_ClanNameTextContainerIndex, &Cursor, pClan);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
@ -181,8 +181,8 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
YOffset -= FontSize;
char aFriendMark[] = "";
TextRender()->TextColor(ColorRGBA(1.0f, 0.0f, 0.0f));
float XOffSet = TextRender()->TextWidth(0, FontSize, aFriendMark, -1, -1.0f) / 2.0f;
TextRender()->Text(0, Position.x - XOffSet, YOffset, FontSize, aFriendMark, -1.0f);
float XOffSet = TextRender()->TextWidth(FontSize, aFriendMark, -1, -1.0f) / 2.0f;
TextRender()->Text(Position.x - XOffSet, YOffset, FontSize, aFriendMark, -1.0f);
}
if(g_Config.m_Debug || g_Config.m_ClNameplatesIDs) // render client id when in debug as well
@ -190,9 +190,9 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
YOffset -= FontSize;
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%d", pPlayerInfo->m_ClientID);
float XOffset = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) / 2.0f;
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->TextColor(rgb);
TextRender()->Text(0, Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
}
}
@ -239,8 +239,8 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
YOffset -= FontSize;
char aBuf[12];
str_format(aBuf, sizeof(aBuf), "%d", pCharacter->GetStrongWeakID());
float XOffset = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->Text(0, Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
}
}
}

View file

@ -66,20 +66,20 @@ void CScoreboard::RenderGoals(float x, float y, float w)
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit);
TextRender()->Text(0, x + 10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
TextRender()->Text(x + 10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
}
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit)
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit);
TextRender()->Text(0, x + 230.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
TextRender()->Text(x + 230.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
}
if(m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum && m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent)
{
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent, m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum);
float tw = TextRender()->TextWidth(0, 20.0f, aBuf, -1, -1.0f);
TextRender()->Text(0, x + w - tw - 10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
float tw = TextRender()->TextWidth(20.0f, aBuf, -1, -1.0f);
TextRender()->Text(x + w - tw - 10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
}
}
}
@ -91,7 +91,7 @@ void CScoreboard::RenderSpectators(float x, float y, float w, float h)
// Headline
y += 10.0f;
TextRender()->Text(0, x + 10.0f, y + (30.f - 28.f) / 2.f, 28.0f, Localize("Spectators"), w - 20.0f);
TextRender()->Text(x + 10.0f, y + (30.f - 28.f) / 2.f, 28.0f, Localize("Spectators"), w - 20.0f);
// spectator names
y += 30.0f;
@ -188,14 +188,14 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
else
{
str_copy(aBuf, Client()->GetCurrentMap());
while(TextRender()->TextWidth(0, TitleFontsize, aBuf, -1, -1.0f) > TitleWidth)
while(TextRender()->TextWidth(TitleFontsize, aBuf, -1, -1.0f) > TitleWidth)
aBuf[str_length(aBuf) - 1] = '\0';
if(str_comp(aBuf, Client()->GetCurrentMap()))
str_append(aBuf, "", sizeof(aBuf));
pTitle = aBuf;
}
}
TextRender()->Text(0, x + 20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, pTitle, -1.0f);
TextRender()->Text(x + 20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, pTitle, -1.0f);
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS)
{
@ -232,8 +232,8 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
if(!lower16 && !lower32 && !lower24)
{
tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1, -1.0f);
TextRender()->Text(0, x + w - tw - 20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, aBuf, -1.0f);
tw = TextRender()->TextWidth(TitleFontsize, aBuf, -1, -1.0f);
TextRender()->Text(x + w - tw - 20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, aBuf, -1.0f);
}
// calculate measurements
@ -273,9 +273,9 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
RoundRadius = 15.0f;
}
float ScoreOffset = x + 10.0f + 10.0f, ScoreLength = TextRender()->TextWidth(0, FontSize, "00:00:00", -1, -1.0f);
float ScoreOffset = x + 10.0f + 10.0f, ScoreLength = TextRender()->TextWidth(FontSize, "00:00:00", -1, -1.0f);
if(IsTeamplayTeam)
ScoreLength = TextRender()->TextWidth(0, FontSize, "99999", -1, -1.0f);
ScoreLength = TextRender()->TextWidth(FontSize, "99999", -1, -1.0f);
float TeeOffset = ScoreOffset + ScoreLength + 15.0f, TeeLength = 60 * TeeSizeMod;
float NameOffset = TeeOffset + TeeLength, NameLength = 300.0f - TeeLength;
float CountryLength = (LineHeight - Spacing - TeeSizeMod * 5.0f) * 2.0f;
@ -290,16 +290,16 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
y += 50.0f;
float HeadlineFontsize = 22.0f;
const char *pScore = (m_pClient->m_GameInfo.m_TimeScore && g_Config.m_ClDDRaceScoreBoard) ? Localize("Time") : Localize("Score");
tw = TextRender()->TextWidth(0, HeadlineFontsize, pScore, -1, -1.0f);
TextRender()->Text(0, ScoreOffset + ScoreLength - tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, pScore, -1.0f);
tw = TextRender()->TextWidth(HeadlineFontsize, pScore, -1, -1.0f);
TextRender()->Text(ScoreOffset + ScoreLength - tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, pScore, -1.0f);
TextRender()->Text(0, NameOffset, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Name"), -1.0f);
TextRender()->Text(NameOffset, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Name"), -1.0f);
tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Clan"), -1, -1.0f);
TextRender()->Text(0, ClanOffset + (ClanLength - tw) / 2, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Clan"), -1.0f);
tw = TextRender()->TextWidth(HeadlineFontsize, Localize("Clan"), -1, -1.0f);
TextRender()->Text(ClanOffset + (ClanLength - tw) / 2, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Clan"), -1.0f);
tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Ping"), -1, -1.0f);
TextRender()->Text(0, PingOffset + PingLength - tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Ping"), -1.0f);
tw = TextRender()->TextWidth(HeadlineFontsize, Localize("Ping"), -1, -1.0f);
TextRender()->Text(PingOffset + PingLength - tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Ping"), -1.0f);
// render player entries
y += HeadlineFontsize * 2.0f;
@ -380,7 +380,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
str_copy(aBuf, Localize("Super"));
else
str_format(aBuf, sizeof(aBuf), Localize("Team %d"), DDTeam);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, ScoreOffset + w / 2.0f - tw / 2.0f, y + LineHeight, FontSize / 1.5f, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = NameLength + 3;
}
@ -406,7 +406,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
}
else
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 99999));
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, ScoreOffset + ScoreLength - tw, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER);
TextRender()->TextEx(&Cursor, aBuf, -1);
@ -477,7 +477,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
else
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
tw = minimum(TextRender()->TextWidth(nullptr, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1, -1.0f), ClanLength);
tw = minimum(TextRender()->TextWidth(FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1, -1.0f), ClanLength);
TextRender()->SetCursor(&Cursor, ClanOffset + (ClanLength - tw) / 2, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_ELLIPSIS_AT_END);
Cursor.m_LineWidth = ClanLength;
TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aClan, -1);
@ -496,7 +496,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
TextRender()->TextColor(rgb);
}
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 999));
tw = TextRender()->TextWidth(nullptr, FontSize, aBuf, -1, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->SetCursor(&Cursor, PingOffset + PingLength - tw, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
Cursor.m_LineWidth = PingLength;
TextRender()->TextEx(&Cursor, aBuf, -1);
@ -556,7 +556,7 @@ void CScoreboard::RenderRecordingNotification(float x)
if(!aBuf[0])
return;
float w = TextRender()->TextWidth(0, 20.0f, aBuf, -1, -1.0f);
float w = TextRender()->TextWidth(20.0f, aBuf, -1, -1.0f);
// draw the box
Graphics()->DrawRect(x, 0.0f, w + 60.0f, 50.0f, ColorRGBA(0.0f, 0.0f, 0.0f, 0.4f), IGraphics::CORNER_B, 15.0f);
@ -564,7 +564,7 @@ void CScoreboard::RenderRecordingNotification(float x)
// draw the red dot
Graphics()->DrawRect(x + 20, 15.0f, 20.0f, 20.0f, ColorRGBA(1.0f, 0.0f, 0.0f, 1.0f), IGraphics::CORNER_ALL, 10.0f);
TextRender()->Text(0, x + 50.0f, (50.f - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
TextRender()->Text(x + 50.0f, (50.f - 20.f) / 2.f, 20.0f, aBuf, -1.0f);
}
void CScoreboard::OnRender()
@ -634,8 +634,8 @@ void CScoreboard::OnRender()
str_copy(aText, Localize("Blue team wins!"));
}
float TextWidth = TextRender()->TextWidth(0, 86.0f, aText, -1, -1.0f);
TextRender()->Text(0, Width / 2 - TextWidth / 2, 39, 86.0f, aText, -1.0f);
float TextWidth = TextRender()->TextWidth(86.0f, aText, -1, -1.0f);
TextRender()->Text(Width / 2 - TextWidth / 2, 39, 86.0f, aText, -1.0f);
}
//decrease width, because team games use additional offsets

View file

@ -268,7 +268,7 @@ void CSpectator::OnRender()
Selected = true;
}
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected ? 1.0f : 0.5f);
TextRender()->Text(0, Width / 2.0f - (ObjWidth - 60.0f), Height / 2.0f - 280.f + (60.f - BigFontSize) / 2.f, BigFontSize, Localize("Free-View"), -1.0f);
TextRender()->Text(Width / 2.0f - (ObjWidth - 60.0f), Height / 2.0f - 280.f + (60.f - BigFontSize) / 2.f, BigFontSize, Localize("Free-View"), -1.0f);
if(Client()->State() == IClient::STATE_DEMOPLAYBACK && m_pClient->m_Snap.m_LocalClientID >= 0)
{
@ -280,7 +280,7 @@ void CSpectator::OnRender()
Selected = true;
}
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected ? 1.0f : 0.5f);
TextRender()->Text(0, Width / 2.0f - (ObjWidth - 350.0f), Height / 2.0f - 280.0f + (60.f - BigFontSize) / 2.f, BigFontSize, Localize("Follow"), -1.0f);
TextRender()->Text(Width / 2.0f - (ObjWidth - 350.0f), Height / 2.0f - 280.0f + (60.f - BigFontSize) / 2.f, BigFontSize, Localize("Follow"), -1.0f);
}
float x = -(ObjWidth - 35.0f), y = StartY;
@ -366,7 +366,7 @@ void CSpectator::OnRender()
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Selected ? 1.0f : 0.5f);
TeeAlpha = 1.0f;
}
TextRender()->Text(0, Width / 2.0f + x + 50.0f, Height / 2.0f + y + BoxMove + (LineHeight - FontSize) / 2.f, FontSize, m_pClient->m_aClients[m_pClient->m_Snap.m_apInfoByDDTeamName[i]->m_ClientID].m_aName, 220.0f);
TextRender()->Text(Width / 2.0f + x + 50.0f, Height / 2.0f + y + BoxMove + (LineHeight - FontSize) / 2.f, FontSize, m_pClient->m_aClients[m_pClient->m_Snap.m_apInfoByDDTeamName[i]->m_ClientID].m_aName, 220.0f);
// flag
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS &&
@ -401,7 +401,7 @@ void CSpectator::OnRender()
{
ColorRGBA rgb = color_cast<ColorRGBA>(ColorHSLA(g_Config.m_ClMessageFriendColor));
TextRender()->TextColor(rgb.WithAlpha(1.f));
TextRender()->Text(0, Width / 2.0f + x - TeeInfo.m_Size / 2.0f, Height / 2.0f + y + BoxMove + (LineHeight - FontSize) / 2.f, FontSize, "", 220.0f);
TextRender()->Text(Width / 2.0f + x - TeeInfo.m_Size / 2.0f, Height / 2.0f + y + BoxMove + (LineHeight - FontSize) / 2.f, FontSize, "", 220.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}

View file

@ -197,7 +197,7 @@ void CStatboard::RenderGlobalStats()
float tw;
int px = 325;
TextRender()->Text(0, x + 10, y - 5, 22.0f, Localize("Name"), -1.0f);
TextRender()->Text(x + 10, y - 5, 22.0f, Localize("Name"), -1.0f);
const char *apHeaders[] = {
Localize("Frags"), Localize("Deaths"), Localize("Suicides"),
Localize("Ratio"), Localize("Net"), Localize("FPM"),
@ -208,8 +208,8 @@ void CStatboard::RenderGlobalStats()
px += 10.0f; // Suicides
if(i == 8 && !GameWithFlags) // Don't draw "Grabs" in game with no flag
continue;
tw = TextRender()->TextWidth(0, 22.0f, apHeaders[i], -1, -1.0f);
TextRender()->Text(0, x + px - tw, y - 5, 22.0f, apHeaders[i], -1.0f);
tw = TextRender()->TextWidth(22.0f, apHeaders[i], -1, -1.0f);
TextRender()->Text(x + px - tw, y - 5, 22.0f, apHeaders[i], -1.0f);
px += 85;
}
@ -294,23 +294,23 @@ void CStatboard::RenderGlobalStats()
// FRAGS
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Frags);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// DEATHS
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Deaths);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// SUICIDES
{
px += 10;
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Suicides);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// RATIO
@ -319,45 +319,45 @@ void CStatboard::RenderGlobalStats()
str_copy(aBuf, "--");
else
str_format(aBuf, sizeof(aBuf), "%.2f", (float)(pStats->m_Frags) / pStats->m_Deaths);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// NET
{
str_format(aBuf, sizeof(aBuf), "%+d", pStats->m_Frags - pStats->m_Deaths);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// FPM
{
float Fpm = pStats->GetFPM(Client()->GameTick(g_Config.m_ClDummy), Client()->GameTickSpeed());
str_format(aBuf, sizeof(aBuf), "%.1f", Fpm);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// SPREE
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_CurrentSpree);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// BEST SPREE
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_BestSpree);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// GRABS
if(GameWithFlags)
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagGrabs);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 85;
}
// WEAPONS
@ -368,16 +368,16 @@ void CStatboard::RenderGlobalStats()
continue;
str_format(aBuf, sizeof(aBuf), "%d/%d", pStats->m_aFragsWith[i], pStats->m_aDeathsFrom[i]);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x + px - tw / 2, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x + px - tw / 2, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
px += 80;
}
// FLAGS
if(GameWithFlags)
{
str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagCaptures);
tw = TextRender()->TextWidth(0, FontSize, aBuf, -1, -1.0f);
TextRender()->Text(0, x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
tw = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f);
TextRender()->Text(x - tw + px, y + (LineHeight * 0.95f - FontSize) / 2.f, FontSize, aBuf, -1.0f);
}
y += LineHeight;
}

View file

@ -77,7 +77,7 @@ void CTooltips::OnRender()
CUIRect Rect;
Rect.w = Tooltip.m_WidthHint;
if(Tooltip.m_WidthHint < 0.0f)
Rect.w = TextRender()->TextWidth(0, 14.0f, Tooltip.m_pText, -1, -1.0f) + 4.0f;
Rect.w = TextRender()->TextWidth(14.0f, Tooltip.m_pText, -1, -1.0f) + 4.0f;
Rect.h = 30.0f;
CUIRect *pScreen = UI()->Screen();

View file

@ -461,7 +461,7 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale - 3.f, (my + ToCenterOffset) * Scale, Size * Scale, aBuf, -1.0f);
TextRender()->Text(mx * Scale - 3.f, (my + ToCenterOffset) * Scale, Size * Scale, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -523,13 +523,13 @@ void CRenderTools::RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, fl
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Force);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->Text(mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
if(MaxSpeed)
{
str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->Text(mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -580,7 +580,7 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->Text(mx * Scale, (my + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
@ -590,7 +590,7 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Delay);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->Text(mx * Scale, (my + 0.5f + ToCenterOffset / 2) * Scale, Size * Scale / 2.f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}
@ -639,7 +639,7 @@ void CRenderTools::RenderTuneOverlay(CTuneTile *pTune, int w, int h, float Scale
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d", Index);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha);
TextRender()->Text(0, mx * Scale + 11.f, my * Scale + 6.f, Size * Scale / 1.5f - 5.f, aBuf, -1.0f); // numbers shouldn't be too big and in the center of the tile
TextRender()->Text(mx * Scale + 11.f, my * Scale + 6.f, Size * Scale / 1.5f - 5.f, aBuf, -1.0f); // numbers shouldn't be too big and in the center of the tile
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}
}

View file

@ -457,7 +457,7 @@ float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, fl
float AlignedSize = 0;
float MaxCharacterHeightInLine = 0;
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : w;
float tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
float tw = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
while(tw > MaxTextWidth + 0.001f)
{
if(!LabelProps.m_EnableWidthCheck)
@ -465,7 +465,7 @@ float CUI::DoTextLabel(float x, float y, float w, float h, const char *pText, fl
if(Size < 4.0f)
break;
Size -= 1.0f;
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
tw = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
}
int Flags = TEXTFLAG_RENDER | (LabelProps.m_StopAtEnd ? TEXTFLAG_STOP_AT_END : 0);
@ -529,7 +529,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
float AlignedSize = 0;
float MaxCharacterHeightInLine = 0;
float MaxTextWidth = LabelProps.m_MaxWidth != -1 ? LabelProps.m_MaxWidth : pRect->w;
float tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
float tw = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
while(tw > MaxTextWidth + 0.001f)
{
if(!LabelProps.m_EnableWidthCheck)
@ -537,7 +537,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons
if(Size < 4.0f)
break;
Size -= 1.0f;
tw = TextRender()->TextWidth(0, Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
tw = TextRender()->TextWidth(Size, pText, -1, LabelProps.m_MaxWidth, &AlignedSize, &MaxCharacterHeightInLine);
}
float AlignmentVert = pRect->y + (pRect->h - AlignedSize) / 2.f;
float AlignmentHori = 0;
@ -963,11 +963,11 @@ bool CUI::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned
// check if the text has to be moved
if(LastActiveItem() == pID && !JustGotActive && (UpdateOffset || *m_pInputEventCount))
{
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, std::numeric_limits<float>::max());
float w = TextRender()->TextWidth(FontSize, pDisplayStr, DispCursorPos, std::numeric_limits<float>::max());
if(w - *pOffset > Textbox.w)
{
// move to the left
float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, std::numeric_limits<float>::max());
float wt = TextRender()->TextWidth(FontSize, pDisplayStr, -1, std::numeric_limits<float>::max());
do
{
*pOffset += minimum(wt - *pOffset - Textbox.w, Textbox.w / 3);
@ -1051,7 +1051,7 @@ bool CUI::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned
// set the ime cursor
if(LastActiveItem() == pID && !JustGotActive)
{
float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, std::numeric_limits<float>::max());
float w = TextRender()->TextWidth(FontSize, pDisplayStr, DispCursorPos, std::numeric_limits<float>::max());
Textbox.x += w;
Input()->SetEditingPosition(Textbox.x, Textbox.y + FontSize);
}
@ -1283,7 +1283,7 @@ void CUI::DoScrollbarOption(const void *pID, int *pOption, const CUIRect *pRect,
}
float FontSize = pRect->h * CUI::ms_FontmodHeight * 0.8f;
float VSplitVal = 10.0f + maximum(TextRender()->TextWidth(0, FontSize, aBuf, -1, std::numeric_limits<float>::max()), TextRender()->TextWidth(0, FontSize, aBufMax, -1, std::numeric_limits<float>::max()));
float VSplitVal = 10.0f + maximum(TextRender()->TextWidth(FontSize, aBuf, -1, std::numeric_limits<float>::max()), TextRender()->TextWidth(FontSize, aBufMax, -1, std::numeric_limits<float>::max()));
CUIRect Label, ScrollBar;
pRect->VSplitLeft(VSplitVal, &Label, &ScrollBar);

View file

@ -2945,7 +2945,7 @@ void CEditor::DoMapEditor(CUIRect View)
float CEditor::ScaleFontSize(char *pText, int TextSize, float FontSize, int Width)
{
while(TextRender()->TextWidth(nullptr, FontSize, pText, -1, -1.0f) > Width)
while(TextRender()->TextWidth(FontSize, pText, -1, -1.0f) > Width)
{
if(FontSize > 6.0f)
{
@ -3268,7 +3268,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
str_format(aBuf, sizeof(aBuf), "#%d %s", g, m_Map.m_vpGroups[g]->m_aName);
float FontSize = 10.0f;
while(TextRender()->TextWidth(nullptr, FontSize, aBuf, -1, -1.0f) > Slot.w && FontSize >= 7.0f)
while(TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) > Slot.w && FontSize >= 7.0f)
FontSize--;
if(int Result = DoButton_Ex(&m_Map.m_vpGroups[g], aBuf, g == m_SelectedGroup, &Slot,
BUTTON_CONTEXT, m_Map.m_vpGroups[g]->m_Collapse ? "Select group. Shift click to select all layers. Double click to expand." : "Select group. Shift click to select all layers. Double click to collapse.", IGraphics::CORNER_R, FontSize))
@ -3351,7 +3351,7 @@ void CEditor::RenderLayers(CUIRect LayersBox)
}
float FontSize = 10.0f;
while(TextRender()->TextWidth(nullptr, FontSize, aBuf, -1, -1.0f) > Button.w && FontSize >= 7.0f)
while(TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) > Button.w && FontSize >= 7.0f)
FontSize--;
int Checked = IsLayerSelected ? 1 : 0;
@ -4056,7 +4056,7 @@ void CEditor::RenderImagesList(CUIRect ToolBox)
}
float FontSize = 10.0f;
while(TextRender()->TextWidth(nullptr, FontSize, m_Map.m_vpImages[i]->m_aName, -1, -1.0f) > Slot.w)
while(TextRender()->TextWidth(FontSize, m_Map.m_vpImages[i]->m_aName, -1, -1.0f) > Slot.w)
FontSize--;
if(int Result = DoButton_Ex(&m_Map.m_vpImages[i], m_Map.m_vpImages[i]->m_aName, Selected, &Slot,
@ -4180,7 +4180,7 @@ void CEditor::RenderSounds(CUIRect ToolBox)
Selected += 2; // Sound is unused
float FontSize = 10.0f;
while(TextRender()->TextWidth(nullptr, FontSize, m_Map.m_vpSounds[i]->m_aName, -1, -1.0f) > Slot.w)
while(TextRender()->TextWidth(FontSize, m_Map.m_vpSounds[i]->m_aName, -1, -1.0f) > Slot.w)
FontSize--;
if(int Result = DoButton_Ex(&m_Map.m_vpSounds[i], m_Map.m_vpSounds[i]->m_aName, Selected, &Slot,
@ -5810,7 +5810,7 @@ void CEditor::Render()
}
TextRender()->TextColor(1.0f, 0.0f, 0.0f, 1.0f);
TextRender()->Text(nullptr, 5.0f, 27.0f, 10.0f, aBuf, -1.0f);
TextRender()->Text(5.0f, 27.0f, 10.0f, aBuf, -1.0f);
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
}

View file

@ -219,7 +219,7 @@ void CLayerTiles::BrushSelecting(CUIRect Rect)
m_pEditor->Graphics()->QuadsEnd();
char aBuf[16];
str_format(aBuf, sizeof(aBuf), "%d,%d", ConvertX(Rect.w), ConvertY(Rect.h));
TextRender()->Text(nullptr, Rect.x + 3.0f, Rect.y + 3.0f, m_pEditor->m_ShowPicker ? 15.0f : 15.0f * m_pEditor->m_WorldZoom, aBuf, -1.0f);
TextRender()->Text(Rect.x + 3.0f, Rect.y + 3.0f, m_pEditor->m_ShowPicker ? 15.0f : 15.0f * m_pEditor->m_WorldZoom, aBuf, -1.0f);
}
int CLayerTiles::BrushGrab(CLayerGroup *pBrush, CUIRect Rect)

View file

@ -1907,8 +1907,8 @@ void CEditor::SConfirmPopupContext::Reset()
void CEditor::ShowPopupConfirm(float X, float Y, SConfirmPopupContext *pContext)
{
const float TextWidth = minimum(TextRender()->TextWidth(nullptr, SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SConfirmPopupContext::POPUP_MAX_WIDTH);
const int LineCount = TextRender()->TextLineCount(nullptr, SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, TextWidth);
const float TextWidth = minimum(TextRender()->TextWidth(SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SConfirmPopupContext::POPUP_MAX_WIDTH);
const int LineCount = TextRender()->TextLineCount(SConfirmPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, TextWidth);
const float PopupHeight = LineCount * SConfirmPopupContext::POPUP_FONT_SIZE + SConfirmPopupContext::POPUP_BUTTON_HEIGHT + SConfirmPopupContext::POPUP_BUTTON_SPACING + 10.0f;
pContext->m_Result = SConfirmPopupContext::UNSET;
UiInvokePopupMenu(pContext, 0, X, Y, TextWidth + 10.0f, PopupHeight, PopupConfirm, pContext);
@ -1946,8 +1946,8 @@ int CEditor::PopupConfirm(CEditor *pEditor, CUIRect View, void *pContext)
void CEditor::ShowPopupMessage(float X, float Y, SMessagePopupContext *pContext)
{
const float TextWidth = minimum(TextRender()->TextWidth(nullptr, SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SMessagePopupContext::POPUP_MAX_WIDTH);
const int LineCount = TextRender()->TextLineCount(nullptr, SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, TextWidth);
const float TextWidth = minimum(TextRender()->TextWidth(SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, -1, -1.0f), SMessagePopupContext::POPUP_MAX_WIDTH);
const int LineCount = TextRender()->TextLineCount(SMessagePopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, TextWidth);
UiInvokePopupMenu(pContext, 0, X, Y, TextWidth + 10.0f, LineCount * SMessagePopupContext::POPUP_FONT_SIZE + 10.0f, PopupMessage, pContext);
}
@ -1967,7 +1967,7 @@ int CEditor::PopupSelection(CEditor *pEditor, CUIRect View, void *pContext)
SSelectionPopupContext *pSelectionPopup = static_cast<SSelectionPopupContext *>(pContext);
CUIRect Slot;
const int LineCount = pEditor->TextRender()->TextLineCount(nullptr, SSelectionPopupContext::POPUP_FONT_SIZE, pSelectionPopup->m_aMessage, SSelectionPopupContext::POPUP_MAX_WIDTH);
const int LineCount = pEditor->TextRender()->TextLineCount(SSelectionPopupContext::POPUP_FONT_SIZE, pSelectionPopup->m_aMessage, SSelectionPopupContext::POPUP_MAX_WIDTH);
View.HSplitTop(LineCount * SSelectionPopupContext::POPUP_FONT_SIZE, &Slot, &View);
CTextCursor Cursor;
@ -1988,7 +1988,7 @@ int CEditor::PopupSelection(CEditor *pEditor, CUIRect View, void *pContext)
void CEditor::ShowPopupSelection(float X, float Y, SSelectionPopupContext *pContext)
{
const int LineCount = TextRender()->TextLineCount(nullptr, SSelectionPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, SSelectionPopupContext::POPUP_MAX_WIDTH);
const int LineCount = TextRender()->TextLineCount(SSelectionPopupContext::POPUP_FONT_SIZE, pContext->m_aMessage, SSelectionPopupContext::POPUP_MAX_WIDTH);
const float PopupHeight = LineCount * SSelectionPopupContext::POPUP_FONT_SIZE + pContext->m_Entries.size() * (SSelectionPopupContext::POPUP_ENTRY_HEIGHT + SSelectionPopupContext::POPUP_ENTRY_SPACING) + 10.0f;
pContext->m_pSelection = nullptr;
UiInvokePopupMenu(pContext, 0, X, Y, SSelectionPopupContext::POPUP_MAX_WIDTH + 10.0f, PopupHeight, PopupSelection, pContext);