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