From 9fd796162ad5f3bbb5fb91c541be27688d912d85 Mon Sep 17 00:00:00 2001 From: SushiTee Date: Wed, 7 Nov 2012 17:15:03 +0100 Subject: [PATCH] gave info button a function --- src/game/client/components/menus.cpp | 11 +++++++---- src/game/client/components/menus.h | 3 ++- src/game/client/components/menus_browser.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 16b8bdec3..441a76c08 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -55,6 +55,8 @@ CMenus::CMenus() m_MenuPage = PAGE_START; + m_InfoMode = false; + m_EscapePressed = false; m_EnterPressed = false; m_DeletePressed = false; @@ -373,13 +375,13 @@ int CMenus::DoButton_SpriteClean(int ImageID, int SpriteID, const CUIRect *pRect return ReturnValue; } -int CMenus::DoButton_SpriteCleanID(const void *pID, int ImageID, int SpriteID, const CUIRect *pRect) +int CMenus::DoButton_SpriteCleanID(const void *pID, int ImageID, int SpriteID, const CUIRect *pRect, bool Blend) { int Inside = UI()->MouseInside(pRect); Graphics()->TextureSet(g_pData->m_aImages[ImageID].m_Id); Graphics()->QuadsBegin(); - Graphics()->SetColor(1.0f, 1.0f, 1.0f, Inside ? 1.0f : 0.6f); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, !Blend || Inside ? 1.0f : 0.6f); RenderTools()->SelectSprite(SpriteID); IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); Graphics()->QuadsDrawTL(&QuadItem, 1); @@ -410,12 +412,13 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS bool UpdateOffset = false; static int s_AtIndex = 0; static bool s_DoScroll = false; - static float s_ScrollStart = 0.0f; FontSize *= UI()->Scale(); if(UI()->LastActiveItem() == pID) { + static float s_ScrollStart = 0.0f; + int Len = str_length(pStr); if(Len == 0) s_AtIndex = 0; @@ -1667,7 +1670,6 @@ int CMenus::Render() // make sure that other windows doesn't do anything funnay! //UI()->SetHotItem(0); //UI()->SetActiveItem(0); - char aBuf[128]; const char *pTitle = ""; const char *pExtraText = ""; const char *pButtonText = ""; @@ -1860,6 +1862,7 @@ int CMenus::Render() if(Client()->MapDownloadTotalsize() > 0) { + char aBuf[128]; int64 Now = time_get(); if(Now-m_DownloadLastCheckTime >= time_freq()) { diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index ce5ff8573..5023a1ef7 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -37,7 +37,7 @@ class CMenus : public CComponent int DoButton_DemoPlayer(const void *pID, const char *pText, const CUIRect *pRect); int DoButton_SpriteID(const void *pID, int ImageID, int SpriteID, const CUIRect *pRect, int Corners=CUI::CORNER_ALL, float r=5.0f, bool Fade=true); int DoButton_SpriteClean(int ImageID, int SpriteID, const CUIRect *pRect); - int DoButton_SpriteCleanID(const void *pID, int ImageID, int SpriteID, const CUIRect *pRect); + int DoButton_SpriteCleanID(const void *pID, int ImageID, int SpriteID, const CUIRect *pRect, bool Blend=true); int DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active); int DoButton_Menu(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Corners=CUI::CORNER_ALL, float r=5.0f, float FontFactor=0.0f, vec4 ColorHot=vec4(1.0f, 1.0f, 1.0f, 0.75f), bool TextFade=true); int DoButton_MenuImage(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pImageName, float r=5.0f, float FontFactor=0.0f); @@ -150,6 +150,7 @@ class CMenus : public CComponent bool m_MenuActive; bool m_UseMouseButtons; vec2 m_MousePos; + bool m_InfoMode; // images struct CMenuImage diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 42d77eb7e..ea94157ce 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -322,13 +322,13 @@ int CMenus::DoBrowserEntry(const void *pID, CUIRect *pRect, const CServerInfo *p else if(ID == COL_PLAYERS) { // handle mouse over - if(UI()->MouseInside(&Button)) + if(m_InfoMode && UI()->MouseInside(&Button)) { // overlay SetOverlay(CInfoOverlay::OVERLAY_PLAYERSINFO, UI()->MouseX(), UI()->MouseY(), pEntry); // rect - RenderTools()->DrawUIRect(&Button, vec4(0.973f, 0.863f, 0.207, 1.0f), CUI::CORNER_ALL, 5.0f); + RenderTools()->DrawUIRect(&Button, vec4(0.973f, 0.863f, 0.207, 0.75f), CUI::CORNER_ALL, 5.0f); } TextRender()->TextColor(TextBaseColor.r, TextBaseColor.g, TextBaseColor.b, TextAplpha); @@ -788,9 +788,9 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) { InfoButton.Margin(2.0f, &InfoButton); static int s_InfoButton = 0; - if(DoButton_SpriteCleanID(&s_InfoButton, IMAGE_INFOICONS, SPRITE_INFO_A, &InfoButton)) + if(DoButton_SpriteCleanID(&s_InfoButton, IMAGE_INFOICONS, ((m_InfoMode && !UI()->MouseInside(&InfoButton)) || (!m_InfoMode && UI()->MouseInside(&InfoButton))) ? SPRITE_INFO_B : SPRITE_INFO_A, &InfoButton, false)) { - + m_InfoMode ^= 1; } }