1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/MenuVoting.h Wed Aug 08 02:27:10 2007 +0000
1.3 @@ -0,0 +1,97 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * ================================================================
1.7 + * SourceMod
1.8 + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
1.9 + * ================================================================
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or
1.12 + * modify it under the terms of the GNU General Public License,
1.13 + * version 3.0, as published by the Free Software Foundation.
1.14 + *
1.15 + * This program is distributed in the hope that it will be useful,
1.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 + * GNU General Public License for more details.
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License
1.21 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.22 + *
1.23 + * As a special exception, AlliedModders LLC gives you permission to
1.24 + * link the code of this program (as well as its derivative works) to
1.25 + * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
1.26 + * Game MODs that run on software by the Valve Corporation. You must
1.27 + * obey the GNU General Public License in all respects for all other
1.28 + * code used. Additionally, AlliedModders LLC grants this exception
1.29 + * to all derivative works. AlliedModders LLC defines further
1.30 + * exceptions, found in LICENSE.txt (as of this writing, version
1.31 + * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
1.32 + *
1.33 + * Version: $Id$
1.34 + */
1.35 +
1.36 +#ifndef _INCLUDE_SOURCEMOD_MENUVOTING_H_
1.37 +#define _INCLUDE_SOURCEMOD_MENUVOTING_H_
1.38 +
1.39 +#include <IMenuManager.h>
1.40 +#include <IPlayerHelpers.h>
1.41 +#include <sh_vector.h>
1.42 +#include "sm_globals.h"
1.43 +
1.44 +using namespace SourceHook;
1.45 +using namespace SourceMod;
1.46 +
1.47 +class VoteMenuHandler :
1.48 + public IMenuHandler,
1.49 + public SMGlobalClass,
1.50 + public IClientListener
1.51 +{
1.52 +public: //SMGlobalClass
1.53 + void OnSourceModAllInitialized();
1.54 + void OnSourceModShutdown();
1.55 +public: //IClientListener
1.56 + void OnClientDisconnected(int client);
1.57 +public: //IMenuHandler
1.58 + unsigned int GetMenuAPIVersion2();
1.59 + void OnMenuStart(IBaseMenu *menu);
1.60 + void OnMenuDisplay(IBaseMenu *menu, int client, IMenuPanel *display);
1.61 + void OnMenuSelect(IBaseMenu *menu, int client, unsigned int item);
1.62 + void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
1.63 + void OnMenuEnd(IBaseMenu *menu, MenuEndReason reason);
1.64 + void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
1.65 + unsigned int OnMenuDisplayItem(IBaseMenu *menu, int client, IMenuPanel *panel, unsigned int item, const ItemDrawInfo &dr);
1.66 +public:
1.67 + bool StartVote(IBaseMenu *menu,
1.68 + unsigned int num_clients,
1.69 + int clients[],
1.70 + unsigned int max_time,
1.71 + unsigned int flags=0);
1.72 + bool IsVoteInProgress();
1.73 + void CancelVoting();
1.74 + IBaseMenu *GetCurrentMenu();
1.75 + bool IsCancelling();
1.76 +private:
1.77 + void Reset(IMenuHandler *mh);
1.78 + void DecrementPlayerCount();
1.79 + void EndVoting();
1.80 + void InternalReset();
1.81 + bool InitializeVoting(IBaseMenu *menu,
1.82 + IMenuHandler *handler,
1.83 + unsigned int time,
1.84 + unsigned int flags);
1.85 + void StartVoting();
1.86 +private:
1.87 + IMenuHandler *m_pHandler;
1.88 + unsigned int m_Clients;
1.89 + unsigned int m_Items;
1.90 + CVector<unsigned int> m_Votes;
1.91 + IBaseMenu *m_pCurMenu;
1.92 + bool m_bStarted;
1.93 + bool m_bCancelled;
1.94 + unsigned int m_NumVotes;
1.95 + unsigned int m_VoteTime;
1.96 + unsigned int m_VoteFlags;
1.97 + int m_ClientVotes[256+1];
1.98 +};
1.99 +
1.100 +#endif //_INCLUDE_SOURCEMOD_MENUVOTING_H_