3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_MENUSTYLE_BASE_H
16 #define _INCLUDE_MENUSTYLE_BASE_H
18 #include <IMenuManager.h>
19 #include <IPlayerHelpers.h>
20 #include <sh_string.h>
21 #include <sh_vector.h>
22 #include "sm_memtable.h"
23 #include "sm_fastlink.h"
25 using namespace SourceMod;
26 using namespace SourceHook;
46 CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false)
53 unsigned int menuHoldTime;
61 public IClientListener
66 bool CancelClientMenu(int client, bool autoIgnore/* =false */);
67 MenuSource GetClientMenu(int client, void **object);
69 public: //IClientListener
70 void OnClientDisconnected(int client);
71 public: //what derived must implement
72 virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
73 virtual void SendDisplay(int client, IMenuPanel *display) =0;
74 public: //what derived may implement
75 virtual bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
76 virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
77 virtual void AddClientToWatch(int client);
78 virtual void RemoveClientFromWatch(int client);
79 virtual void ProcessWatchList();
81 void CancelMenu(CBaseMenu *menu);
82 void ClientPressedKey(int client, unsigned int key_press);
84 void _CancelClientMenu(int client, bool bAutoIgnore=false, MenuCancelReason reason=MenuCancel_Interrupt);
85 bool RedoClientMenu(int client, ItemOrder order);
87 FastLink<int> m_WatchList;
91 class CBaseMenu : public IBaseMenu
94 CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner);
97 virtual bool AppendItem(const char *info, const ItemDrawInfo &draw);
98 virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
99 virtual bool RemoveItem(unsigned int position);
100 virtual void RemoveAllItems();
101 virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
102 virtual unsigned int GetItemCount();
103 virtual bool SetPagination(unsigned int itemsPerPage);
104 virtual unsigned int GetPagination();
105 virtual IMenuStyle *GetDrawStyle();
106 virtual void SetDefaultTitle(const char *message);
107 virtual const char *GetDefaultTitle();
108 virtual bool GetExitButton();
109 virtual bool SetExitButton(bool set);
110 virtual void Cancel();
111 virtual void Destroy(bool releaseHandle);
112 virtual void Cancel_Finally() =0;
113 virtual Handle_t GetHandle();
114 bool BroadcastVote(int clients[],
115 unsigned int numClients,
116 unsigned int maxTime,
117 unsigned int flags=0);
118 bool IsVoteInProgress();
120 virtual void VoteDisplay(int client, unsigned int maxTime) =0;
122 void InternalDelete();
125 IMenuStyle *m_pStyle;
126 BaseStringTable m_Strings;
127 unsigned int m_Pagination;
128 CVector<CItem> m_items;
130 bool m_bShouldDelete;
132 IdentityToken_t *m_pOwner;
134 bool m_bWillFreeHandle;
136 IMenuHandler *m_pHandler;
137 IVoteMenuHandler *m_pVoteHandler;
140 #endif //_INCLUDE_MENUSTYLE_BASE_H