ds@1952: /** ds@1952: * vim: set ts=4 : ds@1952: * ============================================================================= ds@1952: * SourceMod ds@1952: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. ds@1952: * ============================================================================= ds@1952: * ds@1952: * This program is free software; you can redistribute it and/or modify it under ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the ds@1952: * Free Software Foundation. ds@1952: * ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1952: * details. ds@1952: * ds@1952: * You should have received a copy of the GNU General Public License along with ds@1952: * this program. If not, see . ds@1952: * ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1952: * this exception to all derivative works. AlliedModders LLC defines further ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1952: * or . ds@1952: * ds@1952: * Version: $Id$ ds@1952: */ ds@1952: ds@1952: #ifndef _INCLUDE_MENUSTYLE_BASE_H ds@1952: #define _INCLUDE_MENUSTYLE_BASE_H ds@1952: ds@1952: #include ds@1952: #include ds@1952: #include ds@1952: #include ds@1952: #include "sm_memtable.h" ds@1952: #include "sm_fastlink.h" ds@1952: ds@1952: using namespace SourceMod; ds@1952: using namespace SourceHook; ds@1952: ds@1952: class CItem ds@1952: { ds@1952: public: ds@1952: CItem() ds@1952: { ds@1952: infoString = -1; ds@1952: displayString = -1; ds@1952: style = 0; ds@1952: access = 0; ds@1952: } ds@1952: public: ds@1952: int infoString; ds@1952: int displayString; ds@1952: unsigned int style; ds@1952: unsigned int access; ds@1952: }; ds@1952: ds@1952: class CBaseMenuPlayer ds@1952: { ds@1952: public: ds@1952: CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false) ds@1952: { ds@1952: } ds@1952: menu_states_t states; ds@1952: bool bInMenu; ds@1952: bool bAutoIgnore; ds@1952: float menuStartTime; ds@1952: unsigned int menuHoldTime; ds@1952: bool bInExternMenu; ds@1952: }; ds@1952: ds@1952: class CBaseMenu; ds@1952: ds@1952: class BaseMenuStyle : ds@1952: public IMenuStyle, ds@1952: public IClientListener ds@1952: { ds@1952: public: ds@1952: BaseMenuStyle(); ds@1952: public: //IMenuStyle ds@1952: bool CancelClientMenu(int client, bool autoIgnore/* =false */); ds@1952: MenuSource GetClientMenu(int client, void **object); ds@1952: Handle_t GetHandle(); ds@1952: public: //IClientListener ds@1952: void OnClientDisconnected(int client); ds@1952: public: //what derived must implement ds@1952: virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0; ds@1952: virtual void SendDisplay(int client, IMenuPanel *display) =0; ds@1952: public: //what derived may implement ds@1952: virtual bool DoClientMenu(int client, ds@1952: CBaseMenu *menu, ds@1952: unsigned int first_item, ds@1952: IMenuHandler *mh, ds@1952: unsigned int time); ds@1952: virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time); ds@1952: virtual void AddClientToWatch(int client); ds@1952: virtual void RemoveClientFromWatch(int client); ds@1952: virtual void ProcessWatchList(); ds@1952: public: //helpers ds@1952: void CancelMenu(CBaseMenu *menu); ds@1952: void ClientPressedKey(int client, unsigned int key_press); ds@1952: protected: ds@1952: void _CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore=false); ds@1952: bool RedoClientMenu(int client, ItemOrder order); ds@1952: protected: ds@1952: FastLink m_WatchList; ds@1952: Handle_t m_hHandle; ds@1952: }; ds@1952: ds@1952: class CBaseMenu : public IBaseMenu ds@1952: { ds@1952: public: ds@1952: CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner); ds@1952: virtual ~CBaseMenu(); ds@1952: public: ds@1952: virtual bool AppendItem(const char *info, const ItemDrawInfo &draw); ds@1952: virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw); ds@1952: virtual bool RemoveItem(unsigned int position); ds@1952: virtual void RemoveAllItems(); ds@1952: virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL); ds@1952: virtual unsigned int GetItemCount(); ds@1952: virtual bool SetPagination(unsigned int itemsPerPage); ds@1952: virtual unsigned int GetPagination(); ds@1952: virtual IMenuStyle *GetDrawStyle(); ds@1952: virtual void SetDefaultTitle(const char *message); ds@1952: virtual const char *GetDefaultTitle(); ds@1952: virtual void Cancel(); ds@1952: virtual void Destroy(bool releaseHandle); ds@1952: virtual void Cancel_Finally() =0; ds@1952: virtual Handle_t GetHandle(); ds@1952: virtual unsigned int GetMenuOptionFlags(); ds@1952: virtual void SetMenuOptionFlags(unsigned int flags); ds@1952: virtual IMenuHandler *GetHandler(); ds@1952: unsigned int GetBaseMemUsage(); ds@1952: private: ds@1952: void InternalDelete(); ds@1952: protected: ds@1952: String m_Title; ds@1952: IMenuStyle *m_pStyle; ds@1952: BaseStringTable m_Strings; ds@1952: unsigned int m_Pagination; ds@1952: CVector m_items; ds@1952: bool m_bShouldDelete; ds@1952: bool m_bCancelling; ds@1952: IdentityToken_t *m_pOwner; ds@1952: bool m_bDeleting; ds@1952: bool m_bWillFreeHandle; ds@1952: Handle_t m_hHandle; ds@1952: IMenuHandler *m_pHandler; ds@1952: unsigned int m_nFlags; ds@1952: }; ds@1952: ds@1952: #endif //_INCLUDE_MENUSTYLE_BASE_H