Merge pull request #2023 from Fudgyking/show-spec-votes

Show votes in spec with a message indicating that you cannot vote
This commit is contained in:
oy 2019-02-07 17:06:27 +01:00 committed by GitHub
commit 6e8133fe79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -605,9 +605,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
const char *pNotification = 0; const char *pNotification = 0;
char aBuf[64]; char aBuf[64];
if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS) if(m_pClient->m_pVoting->IsVoting())
pNotification = Localize("Spectators aren't allowed to start a vote.");
else if(m_pClient->m_pVoting->IsVoting())
pNotification = Localize("Wait for current vote to end before calling a new one."); pNotification = Localize("Wait for current vote to end before calling a new one.");
else if(m_pClient->m_pVoting->CallvoteBlockTime() != 0) else if(m_pClient->m_pVoting->CallvoteBlockTime() != 0)
{ {
@ -679,6 +677,9 @@ void CMenus::RenderServerControl(CUIRect MainView)
return; return;
} }
if(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team == TEAM_SPECTATORS)
pNotification = Localize("Spectators aren't allowed to start a vote.");
// render background // render background
MainView.HSplitBottom(90.0f+2*20.0f, &MainView, &Extended); MainView.HSplitBottom(90.0f+2*20.0f, &MainView, &Extended);
RenderTools()->DrawUIRect(&Extended, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f); RenderTools()->DrawUIRect(&Extended, vec4(0.0f, 0.0f, 0.0f, 0.25f), CUI::CORNER_ALL, 5.0f);
@ -686,7 +687,8 @@ void CMenus::RenderServerControl(CUIRect MainView)
bool doCallVote = false; bool doCallVote = false;
// render page // render page
if(s_ControlPage == 0) if(s_ControlPage == 0)
doCallVote = RenderServerControlServer(MainView); // double click triggers vote // double click triggers vote if not spectating
doCallVote = RenderServerControlServer(MainView) && m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team != TEAM_SPECTATORS;
else if(s_ControlPage == 1) else if(s_ControlPage == 1)
RenderServerControlKick(MainView, false); RenderServerControlKick(MainView, false);
else if(s_ControlPage == 2) else if(s_ControlPage == 2)
@ -697,33 +699,35 @@ void CMenus::RenderServerControl(CUIRect MainView)
Extended.HSplitTop(20.0f, &Note, &Extended); Extended.HSplitTop(20.0f, &Note, &Extended);
Extended.HSplitTop(20.0f, &Bottom, &Extended); Extended.HSplitTop(20.0f, &Bottom, &Extended);
{ {
Bottom.VSplitRight(120.0f, &Bottom, &Button); if(Authed || m_pClient->m_aClients[m_pClient->m_LocalClientID].m_Team != TEAM_SPECTATORS){
Bottom.VSplitRight(120.0f, &Bottom, &Button);
// render kick reason
CUIRect Reason, ClearButton, Label; // render kick reason
Bottom.VSplitRight(40.0f, &Bottom, 0); CUIRect Reason, ClearButton, Label;
Bottom.VSplitRight(160.0f, &Bottom, &Reason); Bottom.VSplitRight(40.0f, &Bottom, 0);
Reason.VSplitRight(Reason.h, &Reason, &ClearButton); Bottom.VSplitRight(160.0f, &Bottom, &Reason);
const char *pLabel = Localize("Reason:"); Reason.VSplitRight(Reason.h, &Reason, &ClearButton);
float w = TextRender()->TextWidth(0, Reason.h*ms_FontmodHeight*0.8f, pLabel, -1); const char *pLabel = Localize("Reason:");
Reason.VSplitLeft(w + 10.0f, &Label, &Reason); float w = TextRender()->TextWidth(0, Reason.h*ms_FontmodHeight*0.8f, pLabel, -1);
Label.y += 2.0f; Reason.VSplitLeft(w + 10.0f, &Label, &Reason);
UI()->DoLabel(&Label, pLabel, Reason.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
static float s_Offset = 0.0f;
DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), Reason.h*ms_FontmodHeight*0.8f, &s_Offset, false, CUI::CORNER_L);
// clear button
{
static CButtonContainer s_ClearButton;
float Fade = ButtonFade(&s_ClearButton, 0.6f);
RenderTools()->DrawUIRect(&ClearButton, vec4(1.0f, 1.0f, 1.0f, 0.33f+(Fade/0.6f)*0.165f), CUI::CORNER_R, 3.0f);
Label = ClearButton;
Label.y += 2.0f; Label.y += 2.0f;
UI()->DoLabel(&Label, "x", Label.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER); UI()->DoLabel(&Label, pLabel, Reason.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT);
if(UI()->DoButtonLogic(s_ClearButton.GetID(), "x", 0, &ClearButton)) static float s_Offset = 0.0f;
m_aCallvoteReason[0] = 0; DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), Reason.h*ms_FontmodHeight*0.8f, &s_Offset, false, CUI::CORNER_L);
}
// clear button
{
static CButtonContainer s_ClearButton;
float Fade = ButtonFade(&s_ClearButton, 0.6f);
RenderTools()->DrawUIRect(&ClearButton, vec4(1.0f, 1.0f, 1.0f, 0.33f+(Fade/0.6f)*0.165f), CUI::CORNER_R, 3.0f);
Label = ClearButton;
Label.y += 2.0f;
UI()->DoLabel(&Label, "x", Label.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
if(UI()->DoButtonLogic(s_ClearButton.GetID(), "x", 0, &ClearButton))
m_aCallvoteReason[0] = 0;
}
}
if(pNotification == 0) if(pNotification == 0)
{ {
// call vote // call vote
@ -731,10 +735,10 @@ void CMenus::RenderServerControl(CUIRect MainView)
if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || doCallVote) if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || doCallVote)
HandleCallvote(s_ControlPage, false); HandleCallvote(s_ControlPage, false);
} }
else else if (!Authed)
{ {
// print notice // print notice
UI()->DoLabel(&Note, pNotification, Note.h*ms_FontmodHeight*0.8f, CUI::ALIGN_LEFT, Note.w); UI()->DoLabel(&Note, pNotification, Note.h*ms_FontmodHeight*0.8f, CUI::ALIGN_CENTER);
} }
// extended features (only available when authed in rcon) // extended features (only available when authed in rcon)