Square and center icons before rendering them on button

This commit is contained in:
def 2019-03-19 16:07:32 +01:00
parent 38333b65a1
commit 04d67c02f2

View file

@ -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();