core/MenuStyle_Valve.h
author David Anderson <dvander@alliedmods.net>
Sun May 13 18:55:59 2007 +0000 (2007-05-13)
changeset 787 52283fe61d42
parent 776 c031ed44193c
child 790 9b1474d03470
permissions -rw-r--r--
changed IMenuDisplay/CreateDisplay to IMenuPanel/CreatePanel
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_MENUSTYLE_VALVE_H
    16 #define _INCLUDE_MENUSTYLE_VALVE_H
    17 
    18 #include "sm_globals.h"
    19 #include "MenuManager.h"
    20 #include "MenuStyle_Base.h"
    21 #include "sourcemm_api.h"
    22 #include "KeyValues.h"
    23 #include "sm_fastlink.h"
    24 
    25 using namespace SourceMod;
    26 
    27 class CValveMenuPlayer : public CBaseMenuPlayer
    28 {
    29 public:
    30 	CValveMenuPlayer() : curPrioLevel(1)
    31 	{
    32 	}
    33 	int curPrioLevel;
    34 };
    35 
    36 class CValveMenu;
    37 class CValveMenuDisplay;
    38 
    39 class ValveMenuStyle : 
    40 	public SMGlobalClass,
    41 	public BaseMenuStyle
    42 {
    43 public:
    44 	ValveMenuStyle();
    45 	bool OnClientCommand(int client);
    46 public: //BaseMenuStyle
    47 	CBaseMenuPlayer *GetMenuPlayer(int client);
    48 	void SendDisplay(int client, IMenuPanel *display);
    49 	bool DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, unsigned int time);
    50 	bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
    51 public: //SMGlobalClass
    52 	void OnSourceModAllInitialized();
    53 	void OnSourceModShutdown();
    54 	void OnSourceModVSPReceived(IServerPluginCallbacks *iface);
    55 public: //IMenuStyle
    56 	const char *GetStyleName();
    57 	IMenuPanel *CreatePanel();
    58 	IBaseMenu *CreateMenu();
    59 	unsigned int GetMaxPageItems();
    60 private:
    61 	void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin);
    62 private:
    63 	CValveMenuPlayer *m_players;
    64 };
    65 
    66 class CValveMenu;
    67 
    68 class CValveMenuDisplay : public IMenuPanel
    69 {
    70 public:
    71 	CValveMenuDisplay();
    72 	CValveMenuDisplay(CValveMenu *pMenu);
    73 	~CValveMenuDisplay();
    74 public:
    75 	IMenuStyle *GetParentStyle();
    76 	void Reset();
    77 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    78 	unsigned int DrawItem(const ItemDrawInfo &item);
    79 	bool DrawRawLine(const char *rawline);
    80 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    81 	bool SetExtOption(MenuOption option, const void *valuePtr);
    82 	bool CanDrawItem(unsigned int drawFlags);
    83 	void SendRawDisplay(int client, int priority, unsigned int time);
    84 	void DeleteThis();
    85 private:
    86 	KeyValues *m_pKv;
    87 	unsigned int m_NextPos;
    88 	bool m_TitleDrawn;
    89 };
    90 
    91 class CValveMenu : public CBaseMenu
    92 {
    93 	friend class CValveMenuDisplay;
    94 public:
    95 	CValveMenu();
    96 public: //IBaseMenu
    97 	bool SetExtOption(MenuOption option, const void *valuePtr);
    98 	IMenuPanel *CreatePanel();
    99 	bool GetExitButton();
   100 	bool SetExitButton(bool set);
   101 	bool SetPagination(unsigned int itemsPerPage);
   102 	bool Display(int client, IMenuHandler *handler, unsigned int time);
   103 public: //CBaseMenu
   104 	void Cancel_Finally();
   105 private:
   106 	Color m_IntroColor;
   107 	char m_IntroMsg[128];
   108 };
   109 
   110 extern ValveMenuStyle g_ValveMenuStyle;
   111 
   112 #endif //_INCLUDE_MENUSTYLE_VALVE_H