dvander@1269: /**
dvander@1269: * vim: set ts=4 :
ds@1330: * =============================================================================
dvander@1269: * SourceMod
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
dvander@1269: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1269: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1269: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1269: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@1269: *
dvander@1269: * Version: $Id$
dvander@1269: */
dvander@1269:
dvander@1269: #ifndef _INCLUDE_SOURCEMOD_MENUVOTING_H_
dvander@1269: #define _INCLUDE_SOURCEMOD_MENUVOTING_H_
dvander@1269:
dvander@1269: #include
dvander@1269: #include
dvander@1269: #include
dvander@1269: #include "sm_globals.h"
dvander@1269:
dvander@1269: using namespace SourceHook;
dvander@1269: using namespace SourceMod;
dvander@1269:
dvander@1269: class VoteMenuHandler :
dvander@1269: public IMenuHandler,
dvander@1269: public SMGlobalClass,
dvander@1269: public IClientListener
dvander@1269: {
dvander@1269: public: //SMGlobalClass
dvander@1269: void OnSourceModAllInitialized();
dvander@1269: void OnSourceModShutdown();
dvander@1291: void OnSourceModLevelChange(const char *mapName);
dvander@1269: public: //IClientListener
dvander@1269: void OnClientDisconnected(int client);
dvander@1269: public: //IMenuHandler
dvander@1269: unsigned int GetMenuAPIVersion2();
dvander@1269: void OnMenuStart(IBaseMenu *menu);
dvander@1269: void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display);
dvander@1269: void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item);
dvander@1474: void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page);
dvander@1269: void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
dvander@1269: void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason);
dvander@1269: void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
dvander@1269: unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr);
dvander@1269: public:
dvander@1269: bool StartVote(IBaseMenu *menu,
dvander@1269: unsigned int num_clients,
dvander@1269: int clients[],
dvander@1269: unsigned int max_time,
dvander@1269: unsigned int flags=0);
dvander@1269: bool IsVoteInProgress();
dvander@1269: void CancelVoting();
dvander@1269: IBaseMenu *GetCurrentMenu();
dvander@1269: bool IsCancelling();
dvander@1291: unsigned int GetRemainingVoteDelay();
dvander@2056: bool IsClientInVotePool(int client);
dvander@2056: bool GetClientVoteChoice(int client, unsigned int *pItem);
dvander@2056: bool RedrawToClient(int client);
dvander@1269: private:
dvander@1269: void Reset(IMenuHandler *mh);
dvander@1269: void DecrementPlayerCount();
dvander@1269: void EndVoting();
dvander@1269: void InternalReset();
dvander@1269: bool InitializeVoting(IBaseMenu *menu,
dvander@1269: IMenuHandler *handler,
dvander@1269: unsigned int time,
dvander@1269: unsigned int flags);
dvander@1269: void StartVoting();
dvander@1269: private:
dvander@1269: IMenuHandler *m_pHandler;
dvander@1269: unsigned int m_Clients;
dvander@1269: unsigned int m_Items;
dvander@1269: CVector m_Votes;
dvander@1269: IBaseMenu *m_pCurMenu;
dvander@1269: bool m_bStarted;
dvander@1269: bool m_bCancelled;
dvander@1269: unsigned int m_NumVotes;
dvander@1269: unsigned int m_VoteTime;
dvander@1269: unsigned int m_VoteFlags;
dvander@2056: float m_fStartTime;
dvander@2056: unsigned int m_nMenuTime;
dvander@1269: int m_ClientVotes[256+1];
dvander@1269: };
dvander@1269:
dvander@1269: #endif //_INCLUDE_SOURCEMOD_MENUVOTING_H_