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