mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Square and center icons before rendering them on button
This commit is contained in:
parent
38333b65a1
commit
04d67c02f2
|
@ -101,11 +101,28 @@ vec4 CMenus::ButtonColorMul(const void *pID)
|
|||
|
||||
int CMenus::DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect)
|
||||
{
|
||||
int x = pRect->x;
|
||||
int y = pRect->y;
|
||||
int w = pRect->w;
|
||||
int h = pRect->h;
|
||||
|
||||
// Square and center
|
||||
if(w > h)
|
||||
{
|
||||
x += (w-h) / 2;
|
||||
w = h;
|
||||
}
|
||||
else if(h > w)
|
||||
{
|
||||
y += (h-w) / 2;
|
||||
h = w;
|
||||
}
|
||||
|
||||
Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id);
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
RenderTools()->SelectSprite(SpriteId);
|
||||
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
|
||||
IGraphics::CQuadItem QuadItem(x, y, w, h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
|
|
Loading…
Reference in a new issue