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