core/MenuManager.h
author Nicholas Hastings <skamonkey@gmail.com>
Sat Sep 10 12:08:38 2011 -0400 (2011-09-10)
changeset 3389 68d3e56f4bb7
parent 2737 eb7713d87fa1
child 4111 34b8688e3bec
permissions -rw-r--r--
Added CheckAccess native to check cmd/override access of AdminId (bug 5083, r=fyren).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     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.
    11  * 
    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
    15  * details.
    16  *
    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/>.
    19  *
    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>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_SOURCEMOD_MENUMANAGER_H_
    33 #define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
    34 
    35 #include <IMenuManager.h>
    36 #include <sh_vector.h>
    37 #include <sh_stack.h>
    38 #include <sh_list.h>
    39 #include <sh_string.h>
    40 #include "sm_memtable.h"
    41 #include "sm_globals.h"
    42 
    43 using namespace SourceMod;
    44 using namespace SourceHook;
    45 
    46 class MenuManager : 
    47 	public IMenuManager,
    48 	public SMGlobalClass,
    49 	public IHandleTypeDispatch
    50 {
    51 	friend class BroadcastHandler;
    52 	friend class VoteHandler;
    53 	friend class CBaseMenu;
    54 	friend class BaseMenuStyle;
    55 public:
    56 	MenuManager();
    57 public: //SMGlobalClass
    58 	void OnSourceModAllInitialized();
    59 	void OnSourceModAllShutdown();
    60 	ConfigResult OnSourceModConfigChanged(const char *key,
    61 		const char *value,
    62 		ConfigSource source,
    63 		char *error,
    64 		size_t maxlength);
    65 	void OnSourceModLevelChange(const char *mapName);
    66 public: //IMenuManager
    67 	virtual const char *GetInterfaceName()
    68 	{
    69 		return SMINTERFACE_MENUMANAGER_NAME;
    70 	}
    71 	virtual unsigned int GetInterfaceVersion()
    72 	{
    73 		return SMINTERFACE_MENUMANAGER_VERSION;
    74 	}
    75 public:
    76 	unsigned int GetStyleCount();
    77 	IMenuStyle *GetStyle(unsigned int index);
    78 	IMenuStyle *FindStyleByName(const char *name);
    79 	IMenuStyle *GetDefaultStyle();
    80 	void AddStyle(IMenuStyle *style);
    81 	bool SetDefaultStyle(IMenuStyle *style);
    82 	IMenuPanel *RenderMenu(int client, menu_states_t &states, ItemOrder order);
    83 	void CancelMenu(IBaseMenu *menu);
    84 	bool StartVote(IBaseMenu *menu,
    85 		unsigned int num_clients,
    86 		int clients[],
    87 		unsigned int max_time,
    88 		unsigned int flags=0);
    89 	bool IsVoteInProgress();
    90 	void CancelVoting();
    91 	unsigned int GetRemainingVoteDelay();
    92 	bool IsClientInVotePool(int client);
    93 	bool RedrawClientVoteMenu(int client);
    94 	bool RedrawClientVoteMenu2(int client, bool revote);
    95 public: //IHandleTypeDispatch
    96 	void OnHandleDestroy(HandleType_t type, void *object);
    97 	bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
    98 public:
    99 	HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
   100 	HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
   101 public:
   102 	bool MenuSoundsEnabled();
   103 	const char *GetMenuSound(ItemSelection sel);
   104 protected:
   105 	Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
   106 	Handle_t CreateStyleHandle(IMenuStyle *style);
   107 private:
   108 	int m_ShowMenu;
   109 	IMenuStyle *m_pDefaultStyle;
   110 	CVector<IMenuStyle *> m_Styles;
   111 	HandleType_t m_StyleType;
   112 	HandleType_t m_MenuType;
   113 	String m_SelectSound;
   114 	String m_ExitBackSound;
   115 	String m_ExitSound;
   116 };
   117 
   118 extern MenuManager g_Menus;
   119 
   120 #endif //_INCLUDE_SOURCEMOD_MENUMANAGER_H_