Render loading message/indicator when receiving vote options

Render a progress spinner and message on the "Change settings" tab while receiving vote options.
This commit is contained in:
Robert Müller 2024-01-10 22:08:47 +01:00
parent e041c0a870
commit 1d0bb0dfcf
3 changed files with 25 additions and 4 deletions

View file

@ -657,6 +657,7 @@ void CMenus::RenderServerControl(CUIRect MainView)
// render page
MainView.HSplitBottom(ms_ButtonHeight + 5 * 2, &MainView, &Bottom);
Bottom.HMargin(5.0f, &Bottom);
Bottom.HSplitTop(5.0f, nullptr, &Bottom);
bool Call = false;
if(s_ControlPage == EServerControlTab::SETTINGS)
@ -667,12 +668,11 @@ void CMenus::RenderServerControl(CUIRect MainView)
Call = RenderServerControlKick(MainView, true);
// vote menu
CUIRect QuickSearch;
// render quick search
CUIRect QuickSearch;
Bottom.VSplitLeft(5.0f, 0, &Bottom);
Bottom.VSplitLeft(250.0f, &QuickSearch, &Bottom);
QuickSearch.HSplitTop(5.0f, 0, &QuickSearch);
TextRender()->SetFontPreset(EFontPreset::ICON_FONT);
TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags::TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags::TEXT_RENDER_FLAG_NO_OVERSIZE);
@ -695,7 +695,6 @@ void CMenus::RenderServerControl(CUIRect MainView)
// call vote
Bottom.VSplitRight(10.0f, &Bottom, 0);
Bottom.VSplitRight(120.0f, &Bottom, &Button);
Button.HSplitTop(5.0f, 0, &Button);
static CButtonContainer s_CallVoteButton;
if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button) || Call)
@ -731,7 +730,6 @@ void CMenus::RenderServerControl(CUIRect MainView)
CUIRect Reason;
Bottom.VSplitRight(20.0f, &Bottom, 0);
Bottom.VSplitRight(200.0f, &Bottom, &Reason);
Reason.HSplitTop(5.0f, 0, &Reason);
const char *pLabel = Localize("Reason:");
UI()->DoLabel(&Reason, pLabel, 14.0f, TEXTALIGN_ML);
float w = TextRender()->TextWidth(14.0f, pLabel, -1, -1.0f);
@ -743,6 +741,18 @@ void CMenus::RenderServerControl(CUIRect MainView)
}
UI()->DoEditBox(&m_CallvoteReasonInput, &Reason, 14.0f);
// vote option loading indicator
if(s_ControlPage == EServerControlTab::SETTINGS && m_pClient->m_Voting.IsReceivingOptions())
{
CUIRect Spinner, LoadingLabel;
Bottom.VSplitLeft(20.0f, nullptr, &Bottom);
Bottom.VSplitLeft(16.0f, &Spinner, &Bottom);
Bottom.VSplitLeft(5.0f, nullptr, &Bottom);
Bottom.VSplitRight(10.0f, &LoadingLabel, nullptr);
UI()->RenderProgressSpinner(Spinner.Center(), 8.0f);
UI()->DoLabel(&LoadingLabel, Localize("Loading…"), 14.0f, TEXTALIGN_ML);
}
// extended features (only available when authed in rcon)
if(Client()->RconAuthed())
{

View file

@ -225,6 +225,7 @@ void CVoting::OnReset()
m_aReason[0] = 0;
m_Yes = m_No = m_Pass = m_Total = 0;
m_Voted = 0;
m_ReceivingOptions = false;
}
void CVoting::OnConsoleInit()
@ -308,6 +309,14 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg)
CNetMsg_Sv_YourVote *pMsg = (CNetMsg_Sv_YourVote *)pRawMsg;
m_Voted = pMsg->m_Voted;
}
else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONGROUPSTART)
{
m_ReceivingOptions = true;
}
else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONGROUPEND)
{
m_ReceivingOptions = false;
}
}
void CVoting::Render()

View file

@ -24,6 +24,7 @@ class CVoting : public CComponent
char m_aReason[VOTE_REASON_LENGTH];
int m_Voted;
int m_Yes, m_No, m_Pass, m_Total;
bool m_ReceivingOptions;
void AddOption(const char *pDescription);
void RemoveOption(const char *pDescription);
@ -61,6 +62,7 @@ public:
int TakenChoice() const { return m_Voted; }
const char *VoteDescription() const { return m_aDescription; }
const char *VoteReason() const { return m_aReason; }
bool IsReceivingOptions() const { return m_ReceivingOptions; }
};
#endif