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_MENUMANAGER_H_
33 #define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
35 #include <IMenuManager.h>
36 #include <sh_vector.h>
39 #include <sh_string.h>
40 #include "sm_memtable.h"
41 #include "sm_globals.h"
43 using namespace SourceMod;
44 using namespace SourceHook;
49 public IHandleTypeDispatch
51 friend class BroadcastHandler;
52 friend class VoteHandler;
53 friend class CBaseMenu;
54 friend class BaseMenuStyle;
57 public: //SMGlobalClass
58 void OnSourceModAllInitialized();
59 void OnSourceModAllShutdown();
60 ConfigResult OnSourceModConfigChanged(const char *key,
65 void OnSourceModLevelChange(const char *mapName);
66 public: //IMenuManager
67 virtual const char *GetInterfaceName()
69 return SMINTERFACE_MENUMANAGER_NAME;
71 virtual unsigned int GetInterfaceVersion()
73 return SMINTERFACE_MENUMANAGER_VERSION;
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,
87 unsigned int max_time,
88 unsigned int flags=0);
89 bool IsVoteInProgress();
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);
99 HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
100 HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
102 bool MenuSoundsEnabled();
103 const char *GetMenuSound(ItemSelection sel);
105 Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
106 Handle_t CreateStyleHandle(IMenuStyle *style);
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;
118 extern MenuManager g_Menus;
120 #endif //_INCLUDE_SOURCEMOD_MENUMANAGER_H_