2 * vim: set ts=4 sw=4 tw=99 noet :
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_MENUSTYLE_BASE_H
33 #define _INCLUDE_MENUSTYLE_BASE_H
35 #include <IMenuManager.h>
36 #include <IPlayerHelpers.h>
37 #include <am-string.h>
38 #include <am-vector.h>
39 #include "sm_fastlink.h"
41 using namespace SourceMod;
53 CItem(ke::Moveable<CItem> other)
54 : info(ke::Move(other->info)),
55 display(ke::Move(other->display))
58 access = other->access;
70 CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false)
77 unsigned int menuHoldTime;
85 public IClientListener
90 bool CancelClientMenu(int client, bool autoIgnore/* =false */);
91 MenuSource GetClientMenu(int client, void **object);
93 public: //IClientListener
94 void OnClientDisconnected(int client);
95 public: //what derived must implement
96 virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
97 virtual void SendDisplay(int client, IMenuPanel *display) =0;
98 public: //what derived may implement
99 virtual bool DoClientMenu(int client,
101 unsigned int first_item,
104 virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
105 virtual void AddClientToWatch(int client);
106 virtual void RemoveClientFromWatch(int client);
107 virtual void ProcessWatchList();
109 void CancelMenu(CBaseMenu *menu);
110 void ClientPressedKey(int client, unsigned int key_press);
112 void _CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore=false);
113 bool RedoClientMenu(int client, ItemOrder order);
115 FastLink<int> m_WatchList;
119 class CBaseMenu : public IBaseMenu
122 CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner);
123 virtual ~CBaseMenu();
125 virtual bool AppendItem(const char *info, const ItemDrawInfo &draw);
126 virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
127 virtual bool RemoveItem(unsigned int position);
128 virtual void RemoveAllItems();
129 virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
130 virtual unsigned int GetItemCount();
131 virtual bool SetPagination(unsigned int itemsPerPage);
132 virtual unsigned int GetPagination();
133 virtual IMenuStyle *GetDrawStyle();
134 virtual void SetDefaultTitle(const char *message);
135 virtual const char *GetDefaultTitle();
136 virtual void Cancel();
137 virtual void Destroy(bool releaseHandle);
138 virtual void Cancel_Finally() =0;
139 virtual Handle_t GetHandle();
140 virtual unsigned int GetMenuOptionFlags();
141 virtual void SetMenuOptionFlags(unsigned int flags);
142 virtual IMenuHandler *GetHandler();
143 unsigned int GetBaseMemUsage();
145 void InternalDelete();
148 IMenuStyle *m_pStyle;
149 unsigned int m_Pagination;
150 ke::Vector<CItem> m_items;
151 bool m_bShouldDelete;
153 IdentityToken_t *m_pOwner;
155 bool m_bWillFreeHandle;
157 IMenuHandler *m_pHandler;
158 unsigned int m_nFlags;
161 #endif //_INCLUDE_MENUSTYLE_BASE_H