From 04d67c02f2937cbbd298c158b82d9a77f1a09a9e Mon Sep 17 00:00:00 2001 From: def Date: Tue, 19 Mar 2019 16:07:32 +0100 Subject: [PATCH] Square and center icons before rendering them on button --- src/game/client/components/menus.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 4ac5eb75e..d1d106926 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -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();