|
ds@1952
|
1 |
/** |
|
ds@1952
|
2 |
* vim: set ts=4 : |
|
ds@1952
|
3 |
* ============================================================================= |
|
ds@1952
|
4 |
* SourceMod |
|
ds@1952
|
5 |
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. |
|
ds@1952
|
6 |
* ============================================================================= |
|
ds@1952
|
7 |
* |
|
ds@1952
|
8 |
* This program is free software; you can redistribute it and/or modify it under |
|
ds@1952
|
9 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
ds@1952
|
10 |
* Free Software Foundation. |
|
ds@1952
|
11 |
* |
|
ds@1952
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
ds@1952
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
ds@1952
|
14 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
ds@1952
|
15 |
* details. |
|
ds@1952
|
16 |
* |
|
ds@1952
|
17 |
* You should have received a copy of the GNU General Public License along with |
|
ds@1952
|
18 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
ds@1952
|
19 |
* |
|
ds@1952
|
20 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
ds@1952
|
21 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
ds@1952
|
22 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
ds@1952
|
23 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
ds@1952
|
24 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
ds@1952
|
25 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
ds@1952
|
26 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
ds@1952
|
27 |
* or <http://www.sourcemod.net/license.php>. |
|
ds@1952
|
28 |
* |
|
ds@1952
|
29 |
* Version: $Id$ |
|
ds@1952
|
30 |
*/ |
|
ds@1952
|
31 |
|
|
ds@1952
|
32 |
#ifndef _INCLUDE_SOURCEMOD_MENUVOTING_H_ |
|
ds@1952
|
33 |
#define _INCLUDE_SOURCEMOD_MENUVOTING_H_ |
|
ds@1952
|
34 |
|
|
ds@1952
|
35 |
#include <IMenuManager.h> |
|
ds@1952
|
36 |
#include <IPlayerHelpers.h> |
|
ds@1952
|
37 |
#include <sh_vector.h> |
|
ds@1952
|
38 |
#include "sm_globals.h" |
|
ds@1952
|
39 |
|
|
ds@1952
|
40 |
using namespace SourceHook; |
|
ds@1952
|
41 |
using namespace SourceMod; |
|
ds@1952
|
42 |
|
|
ds@1952
|
43 |
class VoteMenuHandler : |
|
ds@1952
|
44 |
public IMenuHandler, |
|
ds@1952
|
45 |
public SMGlobalClass, |
|
ds@1952
|
46 |
public IClientListener |
|
ds@1952
|
47 |
{ |
|
ds@1952
|
48 |
public: //SMGlobalClass |
|
ds@1952
|
49 |
void OnSourceModAllInitialized(); |
|
ds@1952
|
50 |
void OnSourceModShutdown(); |
|
ds@1952
|
51 |
void OnSourceModLevelChange(const char *mapName); |
|
ds@1952
|
52 |
public: //IClientListener |
|
ds@1952
|
53 |
void OnClientDisconnected(int client); |
|
ds@1952
|
54 |
public: //IMenuHandler |
|
ds@1952
|
55 |
unsigned int GetMenuAPIVersion2(); |
|
ds@1952
|
56 |
void OnMenuStart(IBaseMenu *menu); |
|
ds@1952
|
57 |
void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display); |
|
ds@1952
|
58 |
void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item); |
|
ds@1952
|
59 |
void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page); |
|
ds@1952
|
60 |
void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason); |
|
ds@1952
|
61 |
void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason); |
|
ds@1952
|
62 |
void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style); |
|
ds@1952
|
63 |
unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr); |
|
ds@1952
|
64 |
public: |
|
ds@1952
|
65 |
bool StartVote(IBaseMenu *menu, |
|
ds@1952
|
66 |
unsigned int num_clients, |
|
ds@1952
|
67 |
int clients[], |
|
ds@1952
|
68 |
unsigned int max_time, |
|
ds@1952
|
69 |
unsigned int flags=0); |
|
ds@1952
|
70 |
bool IsVoteInProgress(); |
|
ds@1952
|
71 |
void CancelVoting(); |
|
ds@1952
|
72 |
IBaseMenu *GetCurrentMenu(); |
|
ds@1952
|
73 |
bool IsCancelling(); |
|
ds@1952
|
74 |
unsigned int GetRemainingVoteDelay(); |
|
dvander@2056
|
75 |
bool IsClientInVotePool(int client); |
|
dvander@2056
|
76 |
bool GetClientVoteChoice(int client, unsigned int *pItem); |
|
dvander@2056
|
77 |
bool RedrawToClient(int client); |
|
ds@1952
|
78 |
private: |
|
ds@1952
|
79 |
void Reset(IMenuHandler *mh); |
|
ds@1952
|
80 |
void DecrementPlayerCount(); |
|
ds@1952
|
81 |
void EndVoting(); |
|
ds@1952
|
82 |
void InternalReset(); |
|
ds@1952
|
83 |
bool InitializeVoting(IBaseMenu *menu, |
|
ds@1952
|
84 |
IMenuHandler *handler, |
|
ds@1952
|
85 |
unsigned int time, |
|
ds@1952
|
86 |
unsigned int flags); |
|
ds@1952
|
87 |
void StartVoting(); |
|
ds@1952
|
88 |
private: |
|
ds@1952
|
89 |
IMenuHandler *m_pHandler; |
|
ds@1952
|
90 |
unsigned int m_Clients; |
|
ds@1952
|
91 |
unsigned int m_Items; |
|
ds@1952
|
92 |
CVector<unsigned int> m_Votes; |
|
ds@1952
|
93 |
IBaseMenu *m_pCurMenu; |
|
ds@1952
|
94 |
bool m_bStarted; |
|
ds@1952
|
95 |
bool m_bCancelled; |
|
ds@1952
|
96 |
unsigned int m_NumVotes; |
|
ds@1952
|
97 |
unsigned int m_VoteTime; |
|
ds@1952
|
98 |
unsigned int m_VoteFlags; |
|
dvander@2056
|
99 |
float m_fStartTime; |
|
dvander@2056
|
100 |
unsigned int m_nMenuTime; |
|
ds@1952
|
101 |
int m_ClientVotes[256+1]; |
|
ds@1952
|
102 |
}; |
|
ds@1952
|
103 |
|
|
ds@1952
|
104 |
#endif //_INCLUDE_SOURCEMOD_MENUVOTING_H_ |