core/MenuStyle_Valve.h
author David Anderson <dvander@alliedmods.net>
Sun Aug 26 18:41:57 2007 +0000 (2007-08-26)
changeset 1371 d207f0e17532
parent 1361 591f6d2fd11d
child 1474 a3b73df84d88
permissions -rw-r--r--
added amb727 (sm_time_adjustment)
     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_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 
    42 using namespace SourceMod;
    43 
    44 class CValveMenuPlayer : public CBaseMenuPlayer
    45 {
    46 public:
    47 	CValveMenuPlayer() : curPrioLevel(1)
    48 	{
    49 	}
    50 	int curPrioLevel;
    51 };
    52 
    53 class CValveMenu;
    54 class CValveMenuDisplay;
    55 
    56 class ValveMenuStyle : 
    57 	public SMGlobalClass,
    58 	public BaseMenuStyle
    59 {
    60 public:
    61 	ValveMenuStyle();
    62 	bool OnClientCommand(int client, const char *cmd);
    63 public: //BaseMenuStyle
    64 	CBaseMenuPlayer *GetMenuPlayer(int client);
    65 	void SendDisplay(int client, IMenuPanel *display);
    66 	bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
    67 	bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
    68 public: //SMGlobalClass
    69 	void OnSourceModAllInitialized();
    70 	void OnSourceModShutdown();
    71 	void OnSourceModVSPReceived(IServerPluginCallbacks *iface);
    72 public: //IMenuStyle
    73 	const char *GetStyleName();
    74 	IMenuPanel *CreatePanel();
    75 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    76 	unsigned int GetMaxPageItems();
    77 private:
    78 	void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin);
    79 private:
    80 	CValveMenuPlayer *m_players;
    81 };
    82 
    83 class CValveMenu;
    84 
    85 class CValveMenuDisplay : public IMenuPanel
    86 {
    87 public:
    88 	CValveMenuDisplay();
    89 	CValveMenuDisplay(CValveMenu *pMenu);
    90 	~CValveMenuDisplay();
    91 public:
    92 	IMenuStyle *GetParentStyle();
    93 	void Reset();
    94 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    95 	unsigned int DrawItem(const ItemDrawInfo &item);
    96 	bool DrawRawLine(const char *rawline);
    97 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    98 	bool SetExtOption(MenuOption option, const void *valuePtr);
    99 	bool CanDrawItem(unsigned int drawFlags);
   100 	void SendRawDisplay(int client, int priority, unsigned int time);
   101 	void DeleteThis();
   102 	bool SetSelectableKeys(unsigned int keymap);
   103 	unsigned int GetCurrentKey();
   104 	bool SetCurrentKey(unsigned int key);
   105 	int GetAmountRemaining();
   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, IMenuHandler *alt_handler=NULL);
   124 	void SetMenuOptionFlags(unsigned int flags);
   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