3 * =============================================================================
5 * Copyright (C) 2004-2007 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_MENUSTYLE_BASE_H
33 #define _INCLUDE_MENUSTYLE_BASE_H
35 #include <IMenuManager.h>
36 #include <IPlayerHelpers.h>
37 #include <sh_string.h>
38 #include <sh_vector.h>
39 #include "sm_memtable.h"
40 #include "sm_fastlink.h"
42 using namespace SourceMod;
43 using namespace SourceHook;
65 CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false)
72 unsigned int menuHoldTime;
80 public IClientListener
85 bool CancelClientMenu(int client, bool autoIgnore/* =false */);
86 MenuSource GetClientMenu(int client, void **object);
88 public: //IClientListener
89 void OnClientDisconnected(int client);
90 public: //what derived must implement
91 virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
92 virtual void SendDisplay(int client, IMenuPanel *display) =0;
93 public: //what derived may implement
94 virtual bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
95 virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
96 virtual void AddClientToWatch(int client);
97 virtual void RemoveClientFromWatch(int client);
98 virtual void ProcessWatchList();
100 void CancelMenu(CBaseMenu *menu);
101 void ClientPressedKey(int client, unsigned int key_press);
103 void _CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore=false);
104 bool RedoClientMenu(int client, ItemOrder order);
106 FastLink<int> m_WatchList;
110 class CBaseMenu : public IBaseMenu
113 CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner);
114 virtual ~CBaseMenu();
116 virtual bool AppendItem(const char *info, const ItemDrawInfo &draw);
117 virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
118 virtual bool RemoveItem(unsigned int position);
119 virtual void RemoveAllItems();
120 virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
121 virtual unsigned int GetItemCount();
122 virtual bool SetPagination(unsigned int itemsPerPage);
123 virtual unsigned int GetPagination();
124 virtual IMenuStyle *GetDrawStyle();
125 virtual void SetDefaultTitle(const char *message);
126 virtual const char *GetDefaultTitle();
127 virtual void Cancel();
128 virtual void Destroy(bool releaseHandle);
129 virtual void Cancel_Finally() =0;
130 virtual Handle_t GetHandle();
131 virtual unsigned int GetMenuOptionFlags();
132 virtual void SetMenuOptionFlags(unsigned int flags);
133 virtual IMenuHandler *GetHandler();
135 void InternalDelete();
138 IMenuStyle *m_pStyle;
139 BaseStringTable m_Strings;
140 unsigned int m_Pagination;
141 CVector<CItem> m_items;
142 bool m_bShouldDelete;
144 IdentityToken_t *m_pOwner;
146 bool m_bWillFreeHandle;
148 IMenuHandler *m_pHandler;
149 unsigned int m_nFlags;
152 #endif //_INCLUDE_MENUSTYLE_BASE_H