From 513249c24be41f0e944f9d4c2682f5c91d6a6cba Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Fri, 18 Jan 2019 11:52:27 +0100 Subject: [PATCH 1/2] Add fade effect to join friend button --- src/game/client/components/menus_browser.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 2550ba4d8..779b03f57 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -1410,6 +1410,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) if(s_ListExtended[i]) { // entries + static CButtonContainer s_JoinButtons[20]; // max of ~10 buttons displayed at once for(int f = 0; f < m_lFriendList[i].size(); ++f) { View.HSplitTop(20.0f + ms_ListheaderHeight, &Rect, &View); @@ -1454,10 +1455,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) if(m_lFriendList[i][f].m_pServerInfo) { Button.Margin((Button.h - ms_ListheaderHeight + 2.0f) / 2, &Button); - RenderTools()->DrawUIRect(&Button, vec4(1.0f, 1.0f, 1.0f, 0.15f), CUI::CORNER_ALL, 4.0f); - Label.HMargin(2.0f, &Label); - UI()->DoLabelScaled(&Button, Localize("Join", "Join a server"), FontSize, CUI::ALIGN_CENTER); - if(UI()->MouseInside(&Button) && Input()->KeyPress(KEY_MOUSE_1)) // todo: fix me + if(DoButton_Menu(&(s_JoinButtons[f%20]), Localize("Join", "Join a server"), 0, &Button) ) { str_copy(g_Config.m_UiServerAddress, m_lFriendList[i][f].m_pServerInfo->m_aAddress, sizeof(g_Config.m_UiServerAddress)); Client()->Connect(g_Config.m_UiServerAddress); From ff22c4106a5236c398937af8effbd0641dc62cce Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Fri, 25 Jan 2019 12:03:34 +0100 Subject: [PATCH 2/2] Browser: make the sliding window of join friend button IDs global to all friend lists --- src/game/client/components/menus_browser.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 779b03f57..d770bbd2d 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -1402,6 +1402,9 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) } // show lists + // only ~10 buttons will be displayed at once, a sliding window of 20 buttons ought to be enough + static CButtonContainer s_FriendJoinButtons[20]; + int ButtonId = 0; for(int i = 0; i < NUM_FRIEND_TYPES; ++i) { CUIRect Header; @@ -1410,8 +1413,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) if(s_ListExtended[i]) { // entries - static CButtonContainer s_JoinButtons[20]; // max of ~10 buttons displayed at once - for(int f = 0; f < m_lFriendList[i].size(); ++f) + for(int f = 0; f < m_lFriendList[i].size(); ++f, ++ButtonId) { View.HSplitTop(20.0f + ms_ListheaderHeight, &Rect, &View); RenderTools()->DrawUIRect(&Rect, vec4(0.5f, 0.5f, 0.5f, 0.5f), CUI::CORNER_ALL, 5.0f); @@ -1455,7 +1457,7 @@ void CMenus::RenderServerbrowserFriendTab(CUIRect View) if(m_lFriendList[i][f].m_pServerInfo) { Button.Margin((Button.h - ms_ListheaderHeight + 2.0f) / 2, &Button); - if(DoButton_Menu(&(s_JoinButtons[f%20]), Localize("Join", "Join a server"), 0, &Button) ) + if(DoButton_Menu(&(s_FriendJoinButtons[ButtonId%20]), Localize("Join", "Join a server"), 0, &Button) ) { str_copy(g_Config.m_UiServerAddress, m_lFriendList[i][f].m_pServerInfo->m_aAddress, sizeof(g_Config.m_UiServerAddress)); Client()->Connect(g_Config.m_UiServerAddress);