2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_CLIENT_COMPONENTS_VOTING_H
|
|
|
|
#define GAME_CLIENT_COMPONENTS_VOTING_H
|
2011-03-26 16:44:34 +00:00
|
|
|
|
|
|
|
#include <engine/shared/memheap.h>
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/component.h>
|
|
|
|
#include <game/client/ui.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/voting.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
class CVoting : public CComponent
|
|
|
|
{
|
|
|
|
CHeap m_Heap;
|
|
|
|
|
2011-08-13 00:11:06 +00:00
|
|
|
static void ConCallvote(IConsole::IResult *pResult, void *pUserData);
|
|
|
|
static void ConVote(IConsole::IResult *pResult, void *pUserData);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2021-06-23 05:05:49 +00:00
|
|
|
int64_t m_Closetime;
|
2011-03-26 16:44:34 +00:00
|
|
|
char m_aDescription[VOTE_DESC_LENGTH];
|
|
|
|
char m_aReason[VOTE_REASON_LENGTH];
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Voted;
|
2011-03-25 09:26:59 +00:00
|
|
|
int m_Yes, m_No, m_Pass, m_Total;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-26 21:06:29 +00:00
|
|
|
void AddOption(const char *pDescription);
|
2010-05-29 07:25:38 +00:00
|
|
|
void ClearOptions();
|
2011-03-25 09:26:59 +00:00
|
|
|
void Callvote(const char *pType, const char *pValue, const char *pReason);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
2011-04-13 18:37:12 +00:00
|
|
|
int m_NumVoteOptions;
|
2011-03-26 16:44:34 +00:00
|
|
|
CVoteOptionClient *m_pFirst;
|
|
|
|
CVoteOptionClient *m_pLast;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-03-26 16:44:34 +00:00
|
|
|
CVoteOptionClient *m_pRecycleFirst;
|
|
|
|
CVoteOptionClient *m_pRecycleLast;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
CVoting();
|
2022-01-30 23:43:56 +00:00
|
|
|
virtual void OnReset() override;
|
|
|
|
virtual void OnConsoleInit() override;
|
|
|
|
virtual void OnMessage(int Msgtype, void *pRawMsg) override;
|
|
|
|
virtual void OnRender() override;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void RenderBars(CUIRect Bars, bool Text);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-26 15:56:59 +00:00
|
|
|
void CallvoteSpectate(int ClientID, const char *pReason, bool ForceVote = false);
|
2011-03-25 11:06:45 +00:00
|
|
|
void CallvoteKick(int ClientID, const char *pReason, bool ForceVote = false);
|
2011-03-26 17:43:43 +00:00
|
|
|
void CallvoteOption(int OptionID, const char *pReason, bool ForceVote = false);
|
|
|
|
void RemovevoteOption(int OptionID);
|
|
|
|
void AddvoteOption(const char *pDescription, const char *pCommand);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void Vote(int v); // -1 = no, 1 = yes
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
int SecondsLeft() { return (m_Closetime - time()) / time_freq(); }
|
2010-05-29 07:25:38 +00:00
|
|
|
bool IsVoting() { return m_Closetime != 0; }
|
|
|
|
int TakenChoice() const { return m_Voted; }
|
|
|
|
const char *VoteDescription() const { return m_aDescription; }
|
2011-03-25 09:26:59 +00:00
|
|
|
const char *VoteReason() const { return m_aReason; }
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|