core/MenuStyle_Valve.h
author Phong Dang <teame06@gmail.com>
Wed Aug 01 07:29:40 2007 +0000 (2007-08-01)
changeset 1241 2e8046793bc9
parent 1231 17badaf66ce4
child 1259 472c5e61cdc8
permissions -rw-r--r--
Added check to make sure player are alive to perform sm_slap, sm_burn, sm_slay.
     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 
     9  * modify it under the terms of the GNU General Public License, 
    10  * version 3.0, as published by the Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to 
    21  * link the code of this program (as well as its derivative works) to 
    22  * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any 
    23  * Game MODs that run on software by the Valve Corporation.  You must 
    24  * obey the GNU General Public License in all respects for all other 
    25  * code used. Additionally, AlliedModders LLC grants this exception 
    26  * to all derivative works. AlliedModders LLC defines further 
    27  * exceptions, found in LICENSE.txt (as of this writing, version 
    28  * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #ifndef _INCLUDE_MENUSTYLE_VALVE_H
    34 #define _INCLUDE_MENUSTYLE_VALVE_H
    35 
    36 #include "sm_globals.h"
    37 #include "MenuManager.h"
    38 #include "MenuStyle_Base.h"
    39 #include "sourcemm_api.h"
    40 #include "KeyValues.h"
    41 #include "sm_fastlink.h"
    42 
    43 using namespace SourceMod;
    44 
    45 class CValveMenuPlayer : public CBaseMenuPlayer
    46 {
    47 public:
    48 	CValveMenuPlayer() : curPrioLevel(1)
    49 	{
    50 	}
    51 	int curPrioLevel;
    52 };
    53 
    54 class CValveMenu;
    55 class CValveMenuDisplay;
    56 
    57 class ValveMenuStyle : 
    58 	public SMGlobalClass,
    59 	public BaseMenuStyle
    60 {
    61 public:
    62 	ValveMenuStyle();
    63 	bool OnClientCommand(int client);
    64 public: //BaseMenuStyle
    65 	CBaseMenuPlayer *GetMenuPlayer(int client);
    66 	void SendDisplay(int client, IMenuPanel *display);
    67 	bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
    68 	bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
    69 public: //SMGlobalClass
    70 	void OnSourceModAllInitialized();
    71 	void OnSourceModShutdown();
    72 	void OnSourceModVSPReceived(IServerPluginCallbacks *iface);
    73 public: //IMenuStyle
    74 	const char *GetStyleName();
    75 	IMenuPanel *CreatePanel();
    76 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    77 	unsigned int GetMaxPageItems();
    78 private:
    79 	void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin);
    80 private:
    81 	CValveMenuPlayer *m_players;
    82 };
    83 
    84 class CValveMenu;
    85 
    86 class CValveMenuDisplay : public IMenuPanel
    87 {
    88 public:
    89 	CValveMenuDisplay();
    90 	CValveMenuDisplay(CValveMenu *pMenu);
    91 	~CValveMenuDisplay();
    92 public:
    93 	IMenuStyle *GetParentStyle();
    94 	void Reset();
    95 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    96 	unsigned int DrawItem(const ItemDrawInfo &item);
    97 	bool DrawRawLine(const char *rawline);
    98 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    99 	bool SetExtOption(MenuOption option, const void *valuePtr);
   100 	bool CanDrawItem(unsigned int drawFlags);
   101 	void SendRawDisplay(int client, int priority, unsigned int time);
   102 	void DeleteThis();
   103 	bool SetSelectableKeys(unsigned int keymap);
   104 	unsigned int GetCurrentKey();
   105 	bool SetCurrentKey(unsigned int key);
   106 private:
   107 	KeyValues *m_pKv;
   108 	unsigned int m_NextPos;
   109 	bool m_TitleDrawn;
   110 };
   111 
   112 class CValveMenu : public CBaseMenu
   113 {
   114 	friend class CValveMenuDisplay;
   115 public:
   116 	CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
   117 public: //IBaseMenu
   118 	bool SetExtOption(MenuOption option, const void *valuePtr);
   119 	IMenuPanel *CreatePanel();
   120 	bool GetExitButton();
   121 	bool SetExitButton(bool set);
   122 	bool SetPagination(unsigned int itemsPerPage);
   123 	bool Display(int client, unsigned int time);
   124 	void VoteDisplay(int client, unsigned int maxTime);
   125 public: //CBaseMenu
   126 	void Cancel_Finally();
   127 private:
   128 	Color m_IntroColor;
   129 	char m_IntroMsg[128];
   130 };
   131 
   132 extern ValveMenuStyle g_ValveMenuStyle;
   133 
   134 #endif //_INCLUDE_MENUSTYLE_VALVE_H