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