From faa7c0f0739b2561750da52d91572a69628816f6 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Wed, 12 Oct 2011 16:18:14 +0200 Subject: [PATCH] added 0.5 sec image fade --- src/game/client/components/menus.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 0185334dc..2c3e1ba7a 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -137,12 +137,33 @@ int CMenus::DoButton_MenuImage(const void *pID, const char *pText, int Checked, const CMenuImage *pImage = FindMenuImage(pImageName); if(pImage) { - Graphics()->TextureSet(UI()->HotItem() == pID ? pImage->m_OrgTexture : pImage->m_GreyTexture); + float *pFade = (float*)pID; + Graphics()->TextureSet(pImage->m_GreyTexture); Graphics()->QuadsBegin(); - Graphics()->SetColor(1,1,1,1); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); IGraphics::CQuadItem QuadItem(Image.x, Image.y, Image.w, Image.h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); + + float Seconds = 0.5f; // 0.5 seconds for fade + if(UI()->HotItem() == pID) + *pFade = Seconds; + else if(*pFade > 0.0f) + { + *pFade -= Client()->FrameTime(); + if(*pFade < 0.0f) + *pFade = 0.0f; + } + + if(*pFade > 0.0f) + { + Graphics()->TextureSet(pImage->m_OrgTexture); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, *pFade/Seconds); + Graphics()->QuadsDrawTL(&QuadItem, 1); + Graphics()->QuadsEnd(); + } + } pRect->HMargin(pRect->h>=20.0f?2.0f:1.0f, &Text);