3 * ================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ================================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License,
10 * version 3.0, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to
21 * link the code of this program (as well as its derivative works) to
22 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
23 * Game MODs that run on software by the Valve Corporation. You must
24 * obey the GNU General Public License in all respects for all other
25 * code used. Additionally, AlliedModders LLC grants this exception
26 * to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version
28 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
33 #ifndef _INCLUDE_MENUSTYLE_BASE_H
34 #define _INCLUDE_MENUSTYLE_BASE_H
36 #include <IMenuManager.h>
37 #include <IPlayerHelpers.h>
38 #include <sh_string.h>
39 #include <sh_vector.h>
40 #include "sm_memtable.h"
41 #include "sm_fastlink.h"
43 using namespace SourceMod;
44 using namespace SourceHook;
66 CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false)
73 unsigned int menuHoldTime;
81 public IClientListener
86 bool CancelClientMenu(int client, bool autoIgnore/* =false */);
87 MenuSource GetClientMenu(int client, void **object);
89 public: //IClientListener
90 void OnClientDisconnected(int client);
91 public: //what derived must implement
92 virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
93 virtual void SendDisplay(int client, IMenuPanel *display) =0;
94 public: //what derived may implement
95 virtual bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
96 virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
97 virtual void AddClientToWatch(int client);
98 virtual void RemoveClientFromWatch(int client);
99 virtual void ProcessWatchList();
101 void CancelMenu(CBaseMenu *menu);
102 void ClientPressedKey(int client, unsigned int key_press);
104 void _CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore=false);
105 bool RedoClientMenu(int client, ItemOrder order);
107 FastLink<int> m_WatchList;
111 class CBaseMenu : public IBaseMenu
114 CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner);
115 virtual ~CBaseMenu();
117 virtual bool AppendItem(const char *info, const ItemDrawInfo &draw);
118 virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
119 virtual bool RemoveItem(unsigned int position);
120 virtual void RemoveAllItems();
121 virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
122 virtual unsigned int GetItemCount();
123 virtual bool SetPagination(unsigned int itemsPerPage);
124 virtual unsigned int GetPagination();
125 virtual IMenuStyle *GetDrawStyle();
126 virtual void SetDefaultTitle(const char *message);
127 virtual const char *GetDefaultTitle();
128 virtual bool GetExitButton();
129 virtual bool SetExitButton(bool set);
130 virtual void Cancel();
131 virtual void Destroy(bool releaseHandle);
132 virtual void Cancel_Finally() =0;
133 virtual Handle_t GetHandle();
134 virtual bool BroadcastVote(int clients[],
135 unsigned int numClients,
136 unsigned int maxTime,
137 unsigned int flags=0);
138 virtual bool IsVoteInProgress();
139 virtual bool GetExitBackButton();
140 virtual void SetExitBackButton(bool set);
142 virtual void VoteDisplay(int client, unsigned int maxTime) =0;
144 void InternalDelete();
147 IMenuStyle *m_pStyle;
148 BaseStringTable m_Strings;
149 unsigned int m_Pagination;
150 CVector<CItem> m_items;
152 bool m_bShouldDelete;
154 IdentityToken_t *m_pOwner;
156 bool m_bWillFreeHandle;
158 IMenuHandler *m_pHandler;
159 IVoteMenuHandler *m_pVoteHandler;
160 bool m_ExitBackButton;
163 #endif //_INCLUDE_MENUSTYLE_BASE_H