From b495b1681ca5ef62540cf0f1e881a8b142c52d0f Mon Sep 17 00:00:00 2001 From: def Date: Wed, 27 Apr 2016 20:04:31 +0200 Subject: [PATCH] Double click works on votes (and vote window disappears after server setting vote) --- src/game/client/components/menus.h | 4 ++-- src/game/client/components/menus_demo.cpp | 1 + src/game/client/components/menus_ingame.cpp | 24 ++++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 316942fa5..f013beac2 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -251,8 +251,8 @@ class CMenus : public CComponent void RenderPlayers(CUIRect MainView); void RenderServerInfo(CUIRect MainView); void RenderServerControl(CUIRect MainView); - void RenderServerControlKick(CUIRect MainView, bool FilterSpectators); - void RenderServerControlServer(CUIRect MainView); + bool RenderServerControlKick(CUIRect MainView, bool FilterSpectators); + bool RenderServerControlServer(CUIRect MainView); // found in menus_browser.cpp int m_SelectedIndex; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 38efc4c19..5f3daca41 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -589,6 +589,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected) { gs_ListBoxDoneEvents = 1; + if(m_EnterPressed || (UI()->ActiveItem() == pId && Input()->MouseDoubleClick())) { gs_ListBoxItemActivated = true; diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index aefd3c985..f1d7c3a64 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -452,7 +452,7 @@ void CMenus::RenderServerInfo(CUIRect MainView) TextRender()->Text(0, Motd.x+x, Motd.y+y, 16, m_pClient->m_pMotd->m_aServerMotd, (int)Motd.w); } -void CMenus::RenderServerControlServer(CUIRect MainView) +bool CMenus::RenderServerControlServer(CUIRect MainView) { static int s_VoteList = 0; static float s_ScrollValue = 0; @@ -493,12 +493,14 @@ void CMenus::RenderServerControlServer(CUIRect MainView) NumVoteOptions++; } - s_CurVoteOption = UiDoListboxEnd(&s_ScrollValue, 0); + bool Call; + s_CurVoteOption = UiDoListboxEnd(&s_ScrollValue, &Call); if(s_CurVoteOption < Total) m_CallvoteSelectedOption = aIndices[s_CurVoteOption]; + return Call; } -void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) +bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) { int NumOptions = 0; int Selected = -1; @@ -544,8 +546,10 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) } } - Selected = UiDoListboxEnd(&s_ScrollValue, 0); + bool Call; + Selected = UiDoListboxEnd(&s_ScrollValue, &Call); m_CallvoteSelectedPlayer = Selected != -1 ? aPlayerIDs[Selected] : -1; + return Call; } void CMenus::RenderServerControl(CUIRect MainView) @@ -594,12 +598,13 @@ void CMenus::RenderServerControl(CUIRect MainView) MainView.HSplitBottom(ms_ButtonHeight + 5*2, &MainView, &Bottom); Bottom.HMargin(5.0f, &Bottom); + bool Call = false; if(s_ControlPage == 0) - RenderServerControlServer(MainView); + Call = RenderServerControlServer(MainView); else if(s_ControlPage == 1) - RenderServerControlKick(MainView, false); + Call = RenderServerControlKick(MainView, false); else if(s_ControlPage == 2) - RenderServerControlKick(MainView, true); + Call = RenderServerControlKick(MainView, true); // vote menu { @@ -638,10 +643,13 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitRight(120.0f, &Bottom, &Button); static int s_CallVoteButton = 0; - if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button)) + if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call) { if(s_ControlPage == 0) + { m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason); + SetActive(false); + } else if(s_ControlPage == 1) { if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS &&