core/MenuStyle_Base.h
changeset 775 9c537df13ec8
parent 769 d7dc79f1f93e
child 778 07e49a8cf046
     1.1 --- a/core/MenuStyle_Base.h	Sun May 13 00:42:39 2007 +0000
     1.2 +++ b/core/MenuStyle_Base.h	Sun May 13 03:38:36 2007 +0000
     1.3 @@ -16,9 +16,11 @@
     1.4  #define _INCLUDE_MENUSTYLE_BASE_H
     1.5  
     1.6  #include <IMenuManager.h>
     1.7 +#include <IPlayerHelpers.h>
     1.8  #include <sh_string.h>
     1.9  #include <sh_vector.h>
    1.10  #include "sm_memtable.h"
    1.11 +#include "sm_fastlink.h"
    1.12  
    1.13  using namespace SourceMod;
    1.14  using namespace SourceHook;
    1.15 @@ -38,6 +40,52 @@
    1.16  	unsigned int style;
    1.17  };
    1.18  
    1.19 +class CBaseMenuPlayer
    1.20 +{
    1.21 +public:
    1.22 +	CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false)
    1.23 +	{
    1.24 +	}
    1.25 +	menu_states_t states;
    1.26 +	bool bInMenu;
    1.27 +	bool bAutoIgnore;
    1.28 +	float menuStartTime;
    1.29 +	unsigned int menuHoldTime;
    1.30 +};
    1.31 +
    1.32 +class CBaseMenu;
    1.33 +
    1.34 +class BaseMenuStyle : 
    1.35 +	public IMenuStyle,
    1.36 +	public IClientListener
    1.37 +{
    1.38 +public:
    1.39 +	BaseMenuStyle();
    1.40 +public: //IMenuStyle
    1.41 +	bool CancelClientMenu(int client, bool autoIgnore/* =false */);
    1.42 +	MenuSource GetClientMenu(int client, void **object);
    1.43 +public: //IClientListener
    1.44 +	void OnClientDisconnected(int client);
    1.45 +public: //what derived must implement
    1.46 +	virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
    1.47 +	virtual void SendDisplay(int client, IMenuDisplay *display) =0;
    1.48 +public: //what derived may implement 
    1.49 +	virtual bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
    1.50 +	virtual bool DoClientMenu(int client, IMenuDisplay *menu, IMenuHandler *mh, unsigned int time);
    1.51 +	virtual void AddClientToWatch(int client);
    1.52 +	virtual void RemoveClientFromWatch(int client);
    1.53 +	virtual void ProcessWatchList();
    1.54 +	virtual MenuSource GetClientExternMenu(int client, void **object);
    1.55 +public: //helpers
    1.56 +	void CancelMenu(CBaseMenu *menu);
    1.57 +	void ClientPressedKey(int client, unsigned int key_press);
    1.58 +protected:
    1.59 +	void _CancelClientMenu(int client, bool bAutoIgnore=false, MenuCancelReason reason=MenuCancel_Interrupt);
    1.60 +	bool RedoClientMenu(int client, ItemOrder order);
    1.61 +protected:
    1.62 +	FastLink<int> m_WatchList;
    1.63 +};
    1.64 +
    1.65  class CBaseMenu : public IBaseMenu
    1.66  {
    1.67  public:
    1.68 @@ -57,6 +105,9 @@
    1.69  	virtual const char *GetDefaultTitle();
    1.70  	virtual bool GetExitButton();
    1.71  	virtual bool SetExitButton(bool set);
    1.72 +	virtual void Cancel();
    1.73 +	virtual void Destroy();
    1.74 +	virtual void Cancel_Finally() =0;
    1.75  protected:
    1.76  	String m_Title;
    1.77  	IMenuStyle *m_pStyle;
    1.78 @@ -64,6 +115,8 @@
    1.79  	CVector<CItem> m_items;
    1.80  	BaseStringTable m_Strings;
    1.81  	bool m_ExitButton;
    1.82 +	bool m_bCancelling;
    1.83 +	bool m_bShouldDelete;
    1.84  };
    1.85  
    1.86  #endif //_INCLUDE_MENUSTYLE_BASE_H