mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
fixed some quad rendering. Closes #1333
This commit is contained in:
parent
39f1d3a7e2
commit
2283a3b785
|
@ -271,11 +271,8 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser)
|
|||
if(pInfo->m_EnumCount == pInfo->m_WantedCompletion)
|
||||
{
|
||||
float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1);
|
||||
pInfo->m_pSelf->Graphics()->TextureClear();
|
||||
pInfo->m_pSelf->Graphics()->QuadsBegin();
|
||||
pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f);
|
||||
pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3);
|
||||
pInfo->m_pSelf->Graphics()->QuadsEnd();
|
||||
CUIRect Rect = {pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4};
|
||||
pInfo->m_pSelf->RenderTools()->DrawRoundRect(&Rect, vec4(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f), pInfo->m_Cursor.m_FontSize/3);
|
||||
|
||||
// scroll when out of sight
|
||||
if(pInfo->m_Cursor.m_X < 3.0f)
|
||||
|
|
|
@ -165,15 +165,9 @@ void CHud::RenderScoreHud()
|
|||
for(int t = 0; t < NUM_TEAMS; t++)
|
||||
{
|
||||
// draw box
|
||||
CUIRect Rect = {Whole-ScoreWidthMax-ImageSize-2*Split, StartY+t*20, ScoreWidthMax+ImageSize+2*Split, 18.0f};
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
if(t == 0)
|
||||
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f);
|
||||
else
|
||||
Graphics()->SetColor(0.0f, 0.0f, 1.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRectExt(Whole-ScoreWidthMax-ImageSize-2*Split, StartY+t*20, ScoreWidthMax+ImageSize+2*Split, 18.0f, 5.0f, CUI::CORNER_L);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawUIRect(&Rect, t == 0 ? vec4(1.0f, 0.0f, 0.0f, 0.25f) : vec4(0.0f, 0.0f, 1.0f, 0.25f), CUI::CORNER_L, 5.0f);
|
||||
|
||||
// draw score
|
||||
TextRender()->Text(0, Whole-ScoreWidthMax+(ScoreWidthMax-aScoreTeamWidth[t])/2-Split, StartY+t*20, 14.0f, aScoreTeam[t], -1);
|
||||
|
@ -276,15 +270,9 @@ void CHud::RenderScoreHud()
|
|||
for(int t = 0; t < 2; t++)
|
||||
{
|
||||
// draw box
|
||||
CUIRect Rect = {Whole-ScoreWidthMax-ImageSize-2*Split-PosSize, StartY+t*20, ScoreWidthMax+ImageSize+2*Split+PosSize, 18.0f};
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
if(t == Local)
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
else
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRectExt(Whole-ScoreWidthMax-ImageSize-2*Split-PosSize, StartY+t*20, ScoreWidthMax+ImageSize+2*Split+PosSize, 18.0f, 5.0f, CUI::CORNER_L);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawUIRect(&Rect, t == Local ? vec4(1.0f, 1.0f, 1.0f, 0.25f) : vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_L, 5.0f);
|
||||
|
||||
// draw score
|
||||
TextRender()->Text(0, Whole-ScoreWidthMax+(ScoreWidthMax-aScoreWidth[t])/2-Split, StartY+t*20, 14.0f, aScore[t], -1);
|
||||
|
@ -420,11 +408,8 @@ void CHud::RenderVoting()
|
|||
if(!m_pClient->m_pVoting->IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
||||
return;
|
||||
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.40f);
|
||||
RenderTools()->DrawRoundRect(-10, 60-2, 100+10+4+5, 46, 5.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
CUIRect Rect = {-10.0f, 58.0f, 119.0f, 46.0f};
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.4f), 5.0f);
|
||||
|
||||
TextRender()->TextColor(1,1,1,1);
|
||||
|
||||
|
@ -488,22 +473,22 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
|||
// render ammo
|
||||
if(pCharacter->m_Weapon == WEAPON_NINJA)
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.8f, 0.8f, 0.8f, 0.5f);
|
||||
RenderTools()->DrawRoundRectExt(x,y+24, 118.0f, 10.0f, 0.0f, 0);
|
||||
CUIRect Rect = {x, y+24.0f, 118.0f, 10.0f};
|
||||
RenderTools()->DrawUIRect(&Rect, vec4(0.8f, 0.8f, 0.8f, 0.5f), 0, 0.0f);
|
||||
|
||||
int Max = g_pData->m_Weapons.m_Ninja.m_Duration * Client()->GameTickSpeed() / 1000;
|
||||
float Width = 116.0f * clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / Max;
|
||||
Graphics()->SetColor(0.9f, 0.2f, 0.2f, 0.85f);
|
||||
RenderTools()->DrawRoundRectExt(x+1.0f, y+25.0f, Width, 8.0f, 0.0f, 0);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = x+1.0f;
|
||||
Rect.y = y+25.0f;
|
||||
Rect.w = 116.0f * clamp(pCharacter->m_AmmoCount-Client()->GameTick(), 0, Max) / Max;
|
||||
Rect.h = 8.0f;
|
||||
RenderTools()->DrawUIRect(&Rect, vec4(0.9f, 0.2f, 0.2f, 0.85f), 0, 0.0f);
|
||||
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[WEAPON_NINJA].m_pSpriteBody);
|
||||
RenderTools()->DrawRoundRectExt(x+40.0f,y+25, 32.0f, 8.0f, 0.0f, 0);
|
||||
Array[0] = IGraphics::CQuadItem(x+40.0f,y+25, 32.0f, 8.0f);
|
||||
Graphics()->QuadsDrawTL(Array, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -547,11 +532,8 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter)
|
|||
void CHud::RenderSpectatorHud()
|
||||
{
|
||||
// draw the box
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
RenderTools()->DrawRoundRectExt(m_Width-180.0f, m_Height-15.0f, 180.0f, 15.0f, 5.0f, CUI::CORNER_TL);
|
||||
Graphics()->QuadsEnd();
|
||||
CUIRect Rect = {m_Width-180.0f, m_Height-15.0f, 180.0f, 15.0f};
|
||||
RenderTools()->DrawUIRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.4f), CUI::CORNER_TL, 5.0f);
|
||||
|
||||
// draw the text
|
||||
char aBuf[128];
|
||||
|
|
|
@ -1279,30 +1279,24 @@ void CMenus::RenderLoading()
|
|||
float h = 200;
|
||||
float x = Screen.w/2-w/2;
|
||||
float y = Screen.h/2-h/2;
|
||||
CUIRect Rect = {x, y, w, h};
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.50f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 40.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 40.0f);
|
||||
|
||||
const char *pCaption = Localize("Loading");
|
||||
|
||||
CUIRect r;
|
||||
r.x = x;
|
||||
r.y = y+20;
|
||||
r.w = w;
|
||||
r.h = h;
|
||||
UI()->DoLabel(&r, pCaption, 48.0f, CUI::ALIGN_CENTER);
|
||||
Rect.x = x;
|
||||
Rect.y = y+20;
|
||||
Rect.w = w;
|
||||
Rect.h = h;
|
||||
UI()->DoLabel(&Rect, pCaption, 48.0f, CUI::ALIGN_CENTER);
|
||||
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1,1,1,0.75f);
|
||||
RenderTools()->DrawRoundRect(x+40, y+h-75, (w-80)*Percent, 25, 5.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = x+40.0f;
|
||||
Rect.y = y+h-75.0f;
|
||||
Rect.w = (w-80.0f)*Percent;
|
||||
Rect.h = 25.0f;
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.75f), 5.0f);
|
||||
|
||||
Graphics()->Swap();
|
||||
}
|
||||
|
|
|
@ -41,13 +41,10 @@ void CMotd::OnRender()
|
|||
float w = 650.0f;
|
||||
float x = Width/2 - w/2;
|
||||
float y = 150.0f;
|
||||
CUIRect Rect = {x, y, w, h};
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 40.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 40.0f);
|
||||
|
||||
TextRender()->Text(0, x+40.0f, y+40.0f, 32.0f, m_aServerMotd, (int)(w-80.0f));
|
||||
}
|
||||
|
|
|
@ -46,13 +46,10 @@ void CScoreboard::OnConsoleInit()
|
|||
void CScoreboard::RenderGoals(float x, float y, float w)
|
||||
{
|
||||
float h = 50.0f;
|
||||
CUIRect Rect = {x, y, w, h};
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 10.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 10.0f);
|
||||
|
||||
// render goals
|
||||
y += 10.0f;
|
||||
|
@ -80,14 +77,11 @@ void CScoreboard::RenderGoals(float x, float y, float w)
|
|||
void CScoreboard::RenderSpectators(float x, float y, float w)
|
||||
{
|
||||
float h = 140.0f;
|
||||
CUIRect Rect = {x, y, w, h};
|
||||
|
||||
// background
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0,0,0,0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 10.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 10.0f);
|
||||
|
||||
// Headline
|
||||
y += 10.0f;
|
||||
|
@ -122,14 +116,11 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
return;
|
||||
|
||||
float h = 760.0f;
|
||||
CUIRect Rect = {x, y, w, h};
|
||||
|
||||
// background
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||
RenderTools()->DrawRoundRect(x, y, w, h, 17.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.5f), 17.0f);
|
||||
|
||||
// render title
|
||||
float TitleFontsize = 40.0f;
|
||||
|
@ -228,11 +219,11 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
// background so it's easy to find the local player or the followed one in spectator mode
|
||||
if(m_pClient->m_LocalClientID == pInfo->m_ClientID || (m_pClient->m_Snap.m_SpecInfo.m_Active && pInfo->m_ClientID == m_pClient->m_Snap.m_SpecInfo.m_SpectatorID))
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f*ColorAlpha);
|
||||
RenderTools()->DrawRoundRect(x, y, w-20.0f, LineHeight, 15.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = x;
|
||||
Rect.y = y;
|
||||
Rect.w = w-20.0f;
|
||||
Rect.h = LineHeight;
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.25f*ColorAlpha), 15.0f);
|
||||
}
|
||||
|
||||
// score
|
||||
|
@ -318,18 +309,16 @@ void CScoreboard::RenderRecordingNotification(float x)
|
|||
return;
|
||||
|
||||
//draw the box
|
||||
CUIRect Rect = {x, 0.0f, 180.0f, 50.0f};
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
RenderTools()->DrawRoundRectExt(x, 0.0f, 180.0f, 50.0f, 15.0f, CUI::CORNER_B);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawUIRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.4f), CUI::CORNER_B, 15.0f);
|
||||
|
||||
//draw the red dot
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
RenderTools()->DrawRoundRect(x+20, 15.0f, 20.0f, 20.0f, 10.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = x+20;
|
||||
Rect.y = 15.0f;
|
||||
Rect.w = 20.0f;
|
||||
Rect.h = 20.0f;
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 0.0f, 0.0f, 1.0f), 10.0f);
|
||||
|
||||
//draw the text
|
||||
char aBuf[64];
|
||||
|
|
|
@ -178,12 +178,9 @@ void CSpectator::OnRender()
|
|||
|
||||
Graphics()->MapScreen(0, 0, Width, Height);
|
||||
|
||||
CUIRect Rect = {Width/2.0f-300.0f, Height/2.0f-300.0f, 600.0f, 600.0f};
|
||||
Graphics()->BlendNormal();
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f-300.0f, Height/2.0f-300.0f, 600.0f, 600.0f, 20.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(0.0f, 0.0f, 0.0f, 0.3f), 20.0f);
|
||||
|
||||
// clamp mouse position to selector area
|
||||
m_SelectorMouse.x = clamp(m_SelectorMouse.x, -280.0f, 280.0f);
|
||||
|
@ -199,11 +196,11 @@ void CSpectator::OnRender()
|
|||
{
|
||||
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW)
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f-280.0f, Height/2.0f-280.0f, 270.0f, 60.0f, 20.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = Width/2.0f-280.0f;
|
||||
Rect.y = Height/2.0f-280.0f;
|
||||
Rect.w = 270.0f;
|
||||
Rect.h = 60.0f;
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.25f), 20.0f);
|
||||
}
|
||||
|
||||
if(m_SelectorMouse.x >= -280.0f && m_SelectorMouse.x <= -10.0f &&
|
||||
|
@ -232,11 +229,11 @@ void CSpectator::OnRender()
|
|||
|
||||
if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == i)
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f);
|
||||
RenderTools()->DrawRoundRect(Width/2.0f+x-10.0f, Height/2.0f+y-10.0f, 270.0f, 60.0f, 20.0f);
|
||||
Graphics()->QuadsEnd();
|
||||
Rect.x = Width/2.0f+x-10.0f;
|
||||
Rect.y = Height/2.0f+y-10.0f;
|
||||
Rect.w = 270.0f;
|
||||
Rect.h = 60.0f;
|
||||
RenderTools()->DrawRoundRect(&Rect, vec4(1.0f, 1.0f, 1.0f, 0.25f), 20.0f);
|
||||
}
|
||||
|
||||
Selected = false;
|
||||
|
|
|
@ -302,9 +302,9 @@ void CRenderTools::DrawRoundRectExt4(float x, float y, float w, float h, vec4 Co
|
|||
}
|
||||
}
|
||||
|
||||
void CRenderTools::DrawRoundRect(float x, float y, float w, float h, float r)
|
||||
void CRenderTools::DrawRoundRect(const CUIRect *r, vec4 Color, float Rounding)
|
||||
{
|
||||
DrawRoundRectExt(x,y,w,h,r,0xf);
|
||||
DrawUIRect(r, Color, CUI::CORNER_ALL, Rounding);
|
||||
}
|
||||
|
||||
void CRenderTools::DrawUIRect(const CUIRect *r, vec4 Color, int Corners, float Rounding)
|
||||
|
@ -313,7 +313,7 @@ void CRenderTools::DrawUIRect(const CUIRect *r, vec4 Color, int Corners, float R
|
|||
|
||||
// TODO: FIX US
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(Color.r, Color.g, Color.b, Color.a);
|
||||
Graphics()->SetColor(Color.r*Color.a, Color.g*Color.a, Color.b*Color.a, Color.a);
|
||||
DrawRoundRectExt(r->x,r->y,r->w,r->h,Rounding*UI()->Scale(), Corners);
|
||||
Graphics()->QuadsEnd();
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ typedef void (*ENVELOPE_EVAL)(float TimeOffset, int Env, float *pChannels, void
|
|||
|
||||
class CRenderTools
|
||||
{
|
||||
void DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners);
|
||||
void DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners);
|
||||
|
||||
public:
|
||||
class IGraphics *m_pGraphics;
|
||||
class CUI *m_pUI;
|
||||
|
@ -54,9 +57,7 @@ public:
|
|||
void DrawSprite(float x, float y, float size);
|
||||
|
||||
// rects
|
||||
void DrawRoundRect(float x, float y, float w, float h, float r);
|
||||
void DrawRoundRectExt(float x, float y, float w, float h, float r, int Corners);
|
||||
void DrawRoundRectExt4(float x, float y, float w, float h, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, float r, int Corners);
|
||||
void DrawRoundRect(const CUIRect *r, vec4 Color, float Rounding);
|
||||
|
||||
void DrawUIRect(const CUIRect *pRect, vec4 Color, int Corners, float Rounding);
|
||||
void DrawUIRect4(const CUIRect *pRect, vec4 ColorTopLeft, vec4 ColorTopRight, vec4 ColorBottomLeft, vec4 ColorBottomRight, int Corners, float Rounding);
|
||||
|
|
Loading…
Reference in a new issue