core/MenuManager.h
author David Anderson <dvander@alliedmods.net>
Tue Dec 04 15:58:07 2007 +0000 (2007-12-04)
changeset 1764 e4f24e9789fd
parent 1330 ab94316bb52b
child 1766 d30c252089be
permissions -rw-r--r--
- removed ancient bcompat shim for translations/core.cfg file
- fixed msvc8 whining about BfReadString
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2007 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_memtable.h"
    41 #include "sm_globals.h"
    42 
    43 using namespace SourceMod;
    44 using namespace SourceHook;
    45 
    46 class MenuManager : 
    47 	public IMenuManager,
    48 	public SMGlobalClass,
    49 	public IHandleTypeDispatch
    50 {
    51 	friend class BroadcastHandler;
    52 	friend class VoteHandler;
    53 	friend class CBaseMenu;
    54 	friend class BaseMenuStyle;
    55 public:
    56 	MenuManager();
    57 public: //SMGlobalClass
    58 	void OnSourceModAllInitialized();
    59 	void OnSourceModAllShutdown();
    60 	ConfigResult OnSourceModConfigChanged(const char *key,
    61 		const char *value,
    62 		ConfigSource source,
    63 		char *error,
    64 		size_t maxlength);
    65 	void OnSourceModLevelChange(const char *mapName);
    66 public: //IMenuManager
    67 	virtual const char *GetInterfaceName()
    68 	{
    69 		return SMINTERFACE_MENUMANAGER_NAME;
    70 	}
    71 	virtual unsigned int GetInterfaceVersion()
    72 	{
    73 		return SMINTERFACE_MENUMANAGER_VERSION;
    74 	}
    75 public:
    76 	unsigned int GetStyleCount();
    77 	IMenuStyle *GetStyle(unsigned int index);
    78 	IMenuStyle *FindStyleByName(const char *name);
    79 	IMenuStyle *GetDefaultStyle();
    80 	void AddStyle(IMenuStyle *style);
    81 	bool SetDefaultStyle(IMenuStyle *style);
    82 	IMenuPanel *RenderMenu(int client, menu_states_t &states, ItemOrder order);
    83 	void CancelMenu(IBaseMenu *menu);
    84 	bool StartVote(IBaseMenu *menu,
    85 		unsigned int num_clients,
    86 		int clients[],
    87 		unsigned int max_time,
    88 		unsigned int flags=0);
    89 	bool IsVoteInProgress();
    90 	void CancelVoting();
    91 	unsigned int GetRemainingVoteDelay();
    92 public: //IHandleTypeDispatch
    93 	void OnHandleDestroy(HandleType_t type, void *object);
    94 public:
    95 	HandleError ReadMenuHandle(Handle_t handle, IBaseMenu **menu);
    96 	HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
    97 public:
    98 	bool MenuSoundsEnabled();
    99 	const char *GetMenuSound(ItemSelection sel);
   100 protected:
   101 	Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
   102 	Handle_t CreateStyleHandle(IMenuStyle *style);
   103 private:
   104 	int m_ShowMenu;
   105 	IMenuStyle *m_pDefaultStyle;
   106 	CVector<IMenuStyle *> m_Styles;
   107 	HandleType_t m_StyleType;
   108 	HandleType_t m_MenuType;
   109 	String m_SelectSound;
   110 	String m_ExitBackSound;
   111 	String m_ExitSound;
   112 };
   113 
   114 extern MenuManager g_Menus;
   115 
   116 #endif //_INCLUDE_SOURCEMOD_MENUMANAGER_H_