mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Stylize it a bit
This commit is contained in:
parent
72a6417400
commit
b285a3d96d
|
@ -869,7 +869,9 @@ void CChat::OnRender()
|
|||
|
||||
if(Line.m_ClientID != -1)
|
||||
{
|
||||
RenderTools()->DrawClientID(TextRender(), &Cursor, Line.m_ClientID);
|
||||
vec4 BgIdColor = TextColor;
|
||||
BgIdColor.a = 0.5f;
|
||||
RenderTools()->DrawClientID(TextRender(), &Cursor, Line.m_ClientID, BgIdColor);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: ", Line.m_aName);
|
||||
TextRender()->TextShadowed(&Cursor, aBuf, -1, ShadowOffset, ShadowColor, TextColor);
|
||||
}
|
||||
|
|
|
@ -48,8 +48,16 @@ void CNamePlates::RenderNameplate(
|
|||
TextRender()->TextColor(0.7f, 0.7f, 1.0f, a);
|
||||
}
|
||||
|
||||
RenderTools()->DrawClientID(TextRender(), &Cursor, ClientID);
|
||||
TextRender()->TextEx(&Cursor, aName, -1);
|
||||
const vec4 IdTextColor(0.1f, 0.1f, 0.1f, a);
|
||||
vec4 BgIdColor(1.0f, 0.5f, 0.5f, a * 0.5f);
|
||||
if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE)
|
||||
BgIdColor = vec4(0.7f, 0.7f, 1.0f, a * 0.5f);
|
||||
|
||||
if(a > 0.001f)
|
||||
{
|
||||
RenderTools()->DrawClientID(TextRender(), &Cursor, ClientID, BgIdColor, IdTextColor);
|
||||
TextRender()->TextEx(&Cursor, aName, -1);
|
||||
}
|
||||
|
||||
TextRender()->TextColor(1,1,1,1);
|
||||
TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
|
|
|
@ -595,25 +595,32 @@ void CRenderTools::RenderTilemapGenerateSkip(class CLayers *pLayers)
|
|||
}
|
||||
}
|
||||
|
||||
void CRenderTools::DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor, int ID)
|
||||
void CRenderTools::DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor, int ID,
|
||||
const vec4& BgColor, const vec4& TextColor)
|
||||
{
|
||||
char aBuff[4];
|
||||
str_format(aBuff, sizeof(aBuff), "%2d ", ID);
|
||||
|
||||
const float LinebaseY = pTextRender->TextGetLineBaseY(pCursor);
|
||||
|
||||
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
|
||||
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
|
||||
float FakeToScreenY = (Graphics()->ScreenHeight()/(ScreenY1-ScreenY0));
|
||||
float FontSize = (int)(pCursor->m_FontSize * FakeToScreenY)/FakeToScreenY;
|
||||
|
||||
CUIRect Rect;
|
||||
Rect.x = pCursor->m_X;
|
||||
Rect.y = LinebaseY - pCursor->m_FontSize + 0.2f;
|
||||
Rect.w = 1.4f * pCursor->m_FontSize;
|
||||
Rect.h = pCursor->m_FontSize;
|
||||
DrawRoundRect(&Rect, vec4(1, 1, 1, 0.5f), 0.25f * pCursor->m_FontSize);
|
||||
Rect.y = LinebaseY - FontSize + 0.025f * FontSize;
|
||||
Rect.w = 1.4f * FontSize;
|
||||
Rect.h = FontSize;
|
||||
DrawRoundRect(&Rect, BgColor, 0.25f * FontSize);
|
||||
|
||||
const float PrevX = pCursor->m_X;
|
||||
pCursor->m_X += (ID < 10 ? 0.04f: 0.0f) * FontSize;
|
||||
|
||||
pTextRender->TextColor(1, 1, 1, 1);
|
||||
pTextRender->TextOutlineColor(0, 0, 0, 0.3f);
|
||||
pTextRender->TextEx(pCursor, aBuff, -1);
|
||||
// TODO: make a simple text one (no shadow)
|
||||
pTextRender->TextShadowed(pCursor, aBuff, -1, vec2(0,0), vec4(0,0,0,0),
|
||||
vec4(0.1f, 0.1f, 0.1f, 1.0f));
|
||||
|
||||
pCursor->m_X = PrevX + Rect.w + 1.0f;
|
||||
pCursor->m_X = PrevX + Rect.w + 0.2f * FontSize;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,8 @@ public:
|
|||
float OffsetX, float OffsetY, float Aspect, float Zoom, float aPoints[4]);
|
||||
void MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom);
|
||||
|
||||
void DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor, int ID);
|
||||
void DrawClientID(ITextRender* pTextRender, CTextCursor* pCursor, int ID,
|
||||
const vec4& BgColor = vec4(1, 1, 1, 0.5f), const vec4& TextColor = vec4(0.1f, 0.1f, 0.1f, 1.0f));
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue