core/MenuManager.h
author Matt Woodrow <pred@alliedmods.net>
Fri Aug 08 00:17:37 2008 +0000 (2008-08-08)
changeset 2224 676c3b826f13
parent 2056 f1fcde46ac7c
child 2289 44045ead61cd
permissions -rw-r--r--
Initial Import of beta structs extension.
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod
ds@1952
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     6
 * =============================================================================
ds@1952
     7
 *
ds@1952
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    10
 * Free Software Foundation.
ds@1952
    11
 * 
ds@1952
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    15
 * details.
ds@1952
    16
 *
ds@1952
    17
 * You should have received a copy of the GNU General Public License along with
ds@1952
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    19
 *
ds@1952
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    27
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    28
 *
ds@1952
    29
 * Version: $Id$
ds@1952
    30
 */
ds@1952
    31
ds@1952
    32
#ifndef _INCLUDE_SOURCEMOD_MENUMANAGER_H_
ds@1952
    33
#define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
ds@1952
    34
ds@1952
    35
#include <IMenuManager.h>
ds@1952
    36
#include <sh_vector.h>
ds@1952
    37
#include <sh_stack.h>
ds@1952
    38
#include <sh_list.h>
ds@1952
    39
#include <sh_string.h>
ds@1952
    40
#include "sm_memtable.h"
ds@1952
    41
#include "sm_globals.h"
ds@1952
    42
ds@1952
    43
using namespace SourceMod;
ds@1952
    44
using namespace SourceHook;
ds@1952
    45
ds@1952
    46
class MenuManager : 
ds@1952
    47
	public IMenuManager,
ds@1952
    48
	public SMGlobalClass,
ds@1952
    49
	public IHandleTypeDispatch
ds@1952
    50
{
ds@1952
    51
	friend class BroadcastHandler;
ds@1952
    52
	friend class VoteHandler;
ds@1952
    53
	friend class CBaseMenu;
ds@1952
    54
	friend class BaseMenuStyle;
ds@1952
    55
public:
ds@1952
    56
	MenuManager();
ds@1952
    57
public: //SMGlobalClass
ds@1952
    58
	void OnSourceModAllInitialized();
ds@1952
    59
	void OnSourceModAllShutdown();
ds@1952
    60
	ConfigResult OnSourceModConfigChanged(const char *key,
ds@1952
    61
		const char *value,
ds@1952
    62
		ConfigSource source,
ds@1952
    63
		char *error,
ds@1952
    64
		size_t maxlength);
ds@1952
    65
	void OnSourceModLevelChange(const char *mapName);
ds@1952
    66
public: //IMenuManager
ds@1952
    67
	virtual const char *GetInterfaceName()
ds@1952
    68
	{
ds@1952
    69
		return SMINTERFACE_MENUMANAGER_NAME;
ds@1952
    70
	}
ds@1952
    71
	virtual unsigned int GetInterfaceVersion()
ds@1952
    72
	{
ds@1952
    73
		return SMINTERFACE_MENUMANAGER_VERSION;
ds@1952
    74
	}
ds@1952
    75
public:
ds@1952
    76
	unsigned int GetStyleCount();
ds@1952
    77
	IMenuStyle *GetStyle(unsigned int index);
ds@1952
    78
	IMenuStyle *FindStyleByName(const char *name);
ds@1952
    79
	IMenuStyle *GetDefaultStyle();
ds@1952
    80
	void AddStyle(IMenuStyle *style);
ds@1952
    81
	bool SetDefaultStyle(IMenuStyle *style);
ds@1952
    82
	IMenuPanel *RenderMenu(int client, menu_states_t &states, ItemOrder order);
ds@1952
    83
	void CancelMenu(IBaseMenu *menu);
ds@1952
    84
	bool StartVote(IBaseMenu *menu,
ds@1952
    85
		unsigned int num_clients,
ds@1952
    86
		int clients[],
ds@1952
    87
		unsigned int max_time,
ds@1952
    88
		unsigned int flags=0);
ds@1952
    89
	bool IsVoteInProgress();
ds@1952
    90
	void CancelVoting();
ds@1952
    91
	unsigned int GetRemainingVoteDelay();
dvander@2056
    92
	bool IsClientInVotePool(int client);
dvander@2056
    93
	bool RedrawClientVoteMenu(int client);
ds@1952
    94
public: //IHandleTypeDispatch
ds@1952
    95
	void OnHandleDestroy(HandleType_t type, void *object);
ds@1952
    96
	bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
ds@1952
    97
public:
ds@1952
    98
	HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
ds@1952
    99
	HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
ds@1952
   100
public:
ds@1952
   101
	bool MenuSoundsEnabled();
ds@1952
   102
	const char *GetMenuSound(ItemSelection sel);
ds@1952
   103
protected:
ds@1952
   104
	Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
ds@1952
   105
	Handle_t CreateStyleHandle(IMenuStyle *style);
ds@1952
   106
private:
ds@1952
   107
	int m_ShowMenu;
ds@1952
   108
	IMenuStyle *m_pDefaultStyle;
ds@1952
   109
	CVector<IMenuStyle *> m_Styles;
ds@1952
   110
	HandleType_t m_StyleType;
ds@1952
   111
	HandleType_t m_MenuType;
ds@1952
   112
	String m_SelectSound;
ds@1952
   113
	String m_ExitBackSound;
ds@1952
   114
	String m_ExitSound;
ds@1952
   115
};
ds@1952
   116
ds@1952
   117
extern MenuManager g_Menus;
ds@1952
   118
ds@1952
   119
#endif //_INCLUDE_SOURCEMOD_MENUMANAGER_H_