ddnet/src/game/client/components/voting.h

63 lines
1.7 KiB
C
Raw Normal View History

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
#include <game/client/component.h>
#include <game/client/ui.h>
#include <engine/shared/memheap.h>
class CVoting : public CComponent
{
CHeap m_Heap;
static void ConCallvote(IConsole::IResult *pResult, void *pUserData);
static void ConVote(IConsole::IResult *pResult, void *pUserData);
int64 m_Closetime;
2011-03-25 08:49:21 +00:00
char m_aDescription[64];
char m_aReason[16];
2010-05-29 07:25:38 +00:00
int m_Voted;
int m_Yes, m_No, m_Pass, m_Total;
2010-05-29 07:25:38 +00:00
void ClearOptions();
void Callvote(const char *pType, const char *pValue, const char *pReason);
2010-05-29 07:25:38 +00:00
public:
struct CVoteOption
{
CVoteOption *m_pNext;
CVoteOption *m_pPrev;
2011-03-25 08:49:21 +00:00
char m_aDescription[64];
2010-05-29 07:25:38 +00:00
};
CVoteOption *m_pFirst;
CVoteOption *m_pLast;
2011-03-25 10:49:35 +00:00
CVoteOption *m_pRecycleFirst;
CVoteOption *m_pRecycleLast;
2010-05-29 07:25:38 +00:00
CVoting();
virtual void OnReset();
virtual void OnConsoleInit();
virtual void OnMessage(int Msgtype, void *pRawMsg);
virtual void OnRender();
void RenderBars(CUIRect Bars, bool Text);
void CallvoteKick(int ClientID, const char *pReason);
void CallvoteOption(int Option, const char *pReason);
void ForcevoteKick(int ClientID, const char *pReason);
void ForcevoteOption(int Option, const char *pReason);
2010-05-29 07:25:38 +00:00
void Vote(int v); // -1 = no, 1 = yes
int SecondsLeft() { return (m_Closetime - time_get())/time_freq(); }
bool IsVoting() { return m_Closetime != 0; }
int TakenChoice() const { return m_Voted; }
const char *VoteDescription() const { return m_aDescription; }
const char *VoteReason() const { return m_aReason; }
2010-05-29 07:25:38 +00:00
};
#endif