core/MenuStyle_Valve.h
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 2289 44045ead61cd
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_MENUSTYLE_VALVE_H
    33 #define _INCLUDE_MENUSTYLE_VALVE_H
    34 
    35 #include "sm_globals.h"
    36 #include "MenuManager.h"
    37 #include "MenuStyle_Base.h"
    38 #include "sourcemm_api.h"
    39 #include "KeyValues.h"
    40 #include "sm_fastlink.h"
    41 #include <compat_wrappers.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, const char *cmdname, const CCommand &cmd);
    64 public: //BaseMenuStyle
    65 	CBaseMenuPlayer *GetMenuPlayer(int client);
    66 	void SendDisplay(int client, IMenuPanel *display);
    67 	bool DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, 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 public: //IMenuStyle
    73 	const char *GetStyleName();
    74 	IMenuPanel *CreatePanel();
    75 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    76 	unsigned int GetMaxPageItems();
    77 	unsigned int GetApproxMemUsage();
    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 	int GetAmountRemaining();
   107 	unsigned int GetApproxMemUsage();
   108 private:
   109 	KeyValues *m_pKv;
   110 	unsigned int m_NextPos;
   111 	bool m_TitleDrawn;
   112 };
   113 
   114 class CValveMenu : public CBaseMenu
   115 {
   116 	friend class CValveMenuDisplay;
   117 public:
   118 	CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
   119 public: //IBaseMenu
   120 	bool SetExtOption(MenuOption option, const void *valuePtr);
   121 	IMenuPanel *CreatePanel();
   122 	bool GetExitButton();
   123 	bool SetExitButton(bool set);
   124 	bool SetPagination(unsigned int itemsPerPage);
   125 	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
   126 	bool DisplayAtItem(int client,
   127 		unsigned int time,
   128 		unsigned int start_item,
   129 		IMenuHandler *alt_handler/* =NULL */);
   130 	void SetMenuOptionFlags(unsigned int flags);
   131 	unsigned int GetApproxMemUsage();
   132 public: //CBaseMenu
   133 	void Cancel_Finally();
   134 private:
   135 	Color m_IntroColor;
   136 	char m_IntroMsg[128];
   137 };
   138 
   139 extern ValveMenuStyle g_ValveMenuStyle;
   140 
   141 #endif //_INCLUDE_MENUSTYLE_VALVE_H