core/MenuManager.h
changeset 1952 b7aa2b626807
child 2056 f1fcde46ac7c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/MenuManager.h	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,117 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod
     1.8 + * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 + * =============================================================================
    1.10 + *
    1.11 + * This program is free software; you can redistribute it and/or modify it under
    1.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 + * Free Software Foundation.
    1.14 + * 
    1.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 + * details.
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License along with
    1.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 + *
    1.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 + * or <http://www.sourcemod.net/license.php>.
    1.31 + *
    1.32 + * Version: $Id$
    1.33 + */
    1.34 +
    1.35 +#ifndef _INCLUDE_SOURCEMOD_MENUMANAGER_H_
    1.36 +#define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
    1.37 +
    1.38 +#include <IMenuManager.h>
    1.39 +#include <sh_vector.h>
    1.40 +#include <sh_stack.h>
    1.41 +#include <sh_list.h>
    1.42 +#include <sh_string.h>
    1.43 +#include "sm_memtable.h"
    1.44 +#include "sm_globals.h"
    1.45 +
    1.46 +using namespace SourceMod;
    1.47 +using namespace SourceHook;
    1.48 +
    1.49 +class MenuManager : 
    1.50 +	public IMenuManager,
    1.51 +	public SMGlobalClass,
    1.52 +	public IHandleTypeDispatch
    1.53 +{
    1.54 +	friend class BroadcastHandler;
    1.55 +	friend class VoteHandler;
    1.56 +	friend class CBaseMenu;
    1.57 +	friend class BaseMenuStyle;
    1.58 +public:
    1.59 +	MenuManager();
    1.60 +public: //SMGlobalClass
    1.61 +	void OnSourceModAllInitialized();
    1.62 +	void OnSourceModAllShutdown();
    1.63 +	ConfigResult OnSourceModConfigChanged(const char *key,
    1.64 +		const char *value,
    1.65 +		ConfigSource source,
    1.66 +		char *error,
    1.67 +		size_t maxlength);
    1.68 +	void OnSourceModLevelChange(const char *mapName);
    1.69 +public: //IMenuManager
    1.70 +	virtual const char *GetInterfaceName()
    1.71 +	{
    1.72 +		return SMINTERFACE_MENUMANAGER_NAME;
    1.73 +	}
    1.74 +	virtual unsigned int GetInterfaceVersion()
    1.75 +	{
    1.76 +		return SMINTERFACE_MENUMANAGER_VERSION;
    1.77 +	}
    1.78 +public:
    1.79 +	unsigned int GetStyleCount();
    1.80 +	IMenuStyle *GetStyle(unsigned int index);
    1.81 +	IMenuStyle *FindStyleByName(const char *name);
    1.82 +	IMenuStyle *GetDefaultStyle();
    1.83 +	void AddStyle(IMenuStyle *style);
    1.84 +	bool SetDefaultStyle(IMenuStyle *style);
    1.85 +	IMenuPanel *RenderMenu(int client, menu_states_t &states, ItemOrder order);
    1.86 +	void CancelMenu(IBaseMenu *menu);
    1.87 +	bool StartVote(IBaseMenu *menu,
    1.88 +		unsigned int num_clients,
    1.89 +		int clients[],
    1.90 +		unsigned int max_time,
    1.91 +		unsigned int flags=0);
    1.92 +	bool IsVoteInProgress();
    1.93 +	void CancelVoting();
    1.94 +	unsigned int GetRemainingVoteDelay();
    1.95 +public: //IHandleTypeDispatch
    1.96 +	void OnHandleDestroy(HandleType_t type, void *object);
    1.97 +	bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
    1.98 +public:
    1.99 +	HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
   1.100 +	HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
   1.101 +public:
   1.102 +	bool MenuSoundsEnabled();
   1.103 +	const char *GetMenuSound(ItemSelection sel);
   1.104 +protected:
   1.105 +	Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
   1.106 +	Handle_t CreateStyleHandle(IMenuStyle *style);
   1.107 +private:
   1.108 +	int m_ShowMenu;
   1.109 +	IMenuStyle *m_pDefaultStyle;
   1.110 +	CVector<IMenuStyle *> m_Styles;
   1.111 +	HandleType_t m_StyleType;
   1.112 +	HandleType_t m_MenuType;
   1.113 +	String m_SelectSound;
   1.114 +	String m_ExitBackSound;
   1.115 +	String m_ExitSound;
   1.116 +};
   1.117 +
   1.118 +extern MenuManager g_Menus;
   1.119 +
   1.120 +#endif //_INCLUDE_SOURCEMOD_MENUMANAGER_H_