DDraceNetwork Docs
voting.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef GAME_CLIENT_COMPONENTS_VOTING_H
4#define GAME_CLIENT_COMPONENTS_VOTING_H
5
6#include <engine/console.h>
8
10#include <game/voting.h>
11
12class CUIRect;
13
14class CVoting : public CComponent
15{
17
18 static void ConCallvote(IConsole::IResult *pResult, void *pUserData);
19 static void ConVote(IConsole::IResult *pResult, void *pUserData);
20
21 int64_t m_Opentime;
22 int64_t m_Closetime;
28
29 void RemoveOption(const char *pDescription);
30 void ClearOptions();
31 void Callvote(const char *pType, const char *pValue, const char *pReason);
32
33 void RenderBars(CUIRect Bars) const;
34
35public:
39
42
43 CVoting();
44 virtual int Sizeof() const override { return sizeof(*this); }
45 virtual void OnReset() override;
46 virtual void OnConsoleInit() override;
47 virtual void OnMessage(int Msgtype, void *pRawMsg) override;
48
49 void Render();
50
51 void CallvoteSpectate(int ClientId, const char *pReason, bool ForceVote = false);
52 void CallvoteKick(int ClientId, const char *pReason, bool ForceVote = false);
53 void CallvoteOption(int OptionId, const char *pReason, bool ForceVote = false);
54 void RemovevoteOption(int OptionId);
55 void AddvoteOption(const char *pDescription, const char *pCommand);
56 void AddOption(const char *pDescription);
57
58 void Vote(int v); // -1 = no, 1 = yes
59
60 int SecondsLeft() const;
61 bool IsVoting() const { return m_Closetime != 0; }
62 int TakenChoice() const { return m_Voted; }
63 const char *VoteDescription() const { return m_aDescription; }
64 const char *VoteReason() const { return m_aReason; }
65 bool IsReceivingOptions() const { return m_ReceivingOptions; }
66};
67
68#endif
Definition: component.h:20
Definition: memheap.h:11
Definition: ui_rect.h:11
Definition: voting.h:15
const char * VoteDescription() const
Definition: voting.h:63
int m_Total
Definition: voting.h:26
void Callvote(const char *pType, const char *pValue, const char *pReason)
Definition: voting.cpp:32
virtual int Sizeof() const override
Definition: voting.h:44
CVoteOptionClient * m_pRecycleFirst
Definition: voting.h:40
virtual void OnConsoleInit() override
Definition: voting.cpp:248
void ClearOptions()
Definition: voting.cpp:226
CVoteOptionClient * m_pRecycleLast
Definition: voting.h:41
void Vote(int v)
Definition: voting.cpp:146
int m_Pass
Definition: voting.h:26
void CallvoteKick(int ClientId, const char *pReason, bool ForceVote=false)
Definition: voting.cpp:67
void RemovevoteOption(int OptionId)
Definition: voting.cpp:112
void AddOption(const char *pDescription)
Definition: voting.cpp:165
bool IsVoting() const
Definition: voting.h:61
virtual void OnReset() override
Definition: voting.cpp:238
const char * VoteReason() const
Definition: voting.h:64
bool IsReceivingOptions() const
Definition: voting.h:65
int TakenChoice() const
Definition: voting.h:62
char m_aReason[VOTE_REASON_LENGTH]
Definition: voting.h:24
CHeap m_Heap
Definition: voting.h:16
int64_t m_Closetime
Definition: voting.h:22
int64_t m_Opentime
Definition: voting.h:21
void CallvoteSpectate(int ClientId, const char *pReason, bool ForceVote=false)
Definition: voting.cpp:51
void RenderBars(CUIRect Bars) const
Definition: voting.cpp:404
void Render()
Definition: voting.cpp:339
void RemoveOption(const char *pDescription)
Definition: voting.cpp:195
CVoting()
Definition: voting.cpp:159
static void ConCallvote(IConsole::IResult *pResult, void *pUserData)
Definition: voting.cpp:17
void CallvoteOption(int OptionId, const char *pReason, bool ForceVote=false)
Definition: voting.cpp:83
static void ConVote(IConsole::IResult *pResult, void *pUserData)
Definition: voting.cpp:23
char m_aDescription[VOTE_DESC_LENGTH]
Definition: voting.h:23
CVoteOptionClient * m_pLast
Definition: voting.h:38
CVoteOptionClient * m_pFirst
Definition: voting.h:37
void AddvoteOption(const char *pDescription, const char *pCommand)
Definition: voting.cpp:133
bool m_ReceivingOptions
Definition: voting.h:27
int m_No
Definition: voting.h:26
int m_Yes
Definition: voting.h:26
int m_NumVoteOptions
Definition: voting.h:36
int m_Voted
Definition: voting.h:25
int SecondsLeft() const
Definition: voting.cpp:154
virtual void OnMessage(int Msgtype, void *pRawMsg) override
Definition: voting.cpp:254
Definition: console.h:45
Definition: voting.h:16
@ VOTE_DESC_LENGTH
Definition: voting.h:8
@ VOTE_REASON_LENGTH
Definition: voting.h:10