core/MenuStyle_Valve.h
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/MenuStyle_Valve.h	Sun Mar 30 07:00:22 2008 +0000
     1.3 @@ -0,0 +1,141 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * =============================================================================
     1.7 + * SourceMod
     1.8 + * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 + * =============================================================================
    1.10 + *
    1.11 + * This program is free software; you can redistribute it and/or modify it under
    1.12 + * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 + * Free Software Foundation.
    1.14 + * 
    1.15 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 + * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 + * details.
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License along with
    1.21 + * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 + *
    1.23 + * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 + * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 + * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 + * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 + * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 + * or <http://www.sourcemod.net/license.php>.
    1.31 + *
    1.32 + * Version: $Id$
    1.33 + */
    1.34 +
    1.35 +#ifndef _INCLUDE_MENUSTYLE_VALVE_H
    1.36 +#define _INCLUDE_MENUSTYLE_VALVE_H
    1.37 +
    1.38 +#include "sm_globals.h"
    1.39 +#include "MenuManager.h"
    1.40 +#include "MenuStyle_Base.h"
    1.41 +#include "sourcemm_api.h"
    1.42 +#include "KeyValues.h"
    1.43 +#include "sm_fastlink.h"
    1.44 +#include <compat_wrappers.h>
    1.45 +
    1.46 +using namespace SourceMod;
    1.47 +
    1.48 +class CValveMenuPlayer : public CBaseMenuPlayer
    1.49 +{
    1.50 +public:
    1.51 +	CValveMenuPlayer() : curPrioLevel(1)
    1.52 +	{
    1.53 +	}
    1.54 +	int curPrioLevel;
    1.55 +};
    1.56 +
    1.57 +class CValveMenu;
    1.58 +class CValveMenuDisplay;
    1.59 +
    1.60 +class ValveMenuStyle : 
    1.61 +	public SMGlobalClass,
    1.62 +	public BaseMenuStyle
    1.63 +{
    1.64 +public:
    1.65 +	ValveMenuStyle();
    1.66 +	bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd);
    1.67 +public: //BaseMenuStyle
    1.68 +	CBaseMenuPlayer *GetMenuPlayer(int client);
    1.69 +	void SendDisplay(int client, IMenuPanel *display);
    1.70 +	bool DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, IMenuHandler *mh, unsigned int time);
    1.71 +	bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
    1.72 +public: //SMGlobalClass
    1.73 +	void OnSourceModAllInitialized();
    1.74 +	void OnSourceModShutdown();
    1.75 +public: //IMenuStyle
    1.76 +	const char *GetStyleName();
    1.77 +	IMenuPanel *CreatePanel();
    1.78 +	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    1.79 +	unsigned int GetMaxPageItems();
    1.80 +	unsigned int GetApproxMemUsage();
    1.81 +private:
    1.82 +	void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin);
    1.83 +private:
    1.84 +	CValveMenuPlayer *m_players;
    1.85 +};
    1.86 +
    1.87 +class CValveMenu;
    1.88 +
    1.89 +class CValveMenuDisplay : public IMenuPanel
    1.90 +{
    1.91 +public:
    1.92 +	CValveMenuDisplay();
    1.93 +	CValveMenuDisplay(CValveMenu *pMenu);
    1.94 +	~CValveMenuDisplay();
    1.95 +public:
    1.96 +	IMenuStyle *GetParentStyle();
    1.97 +	void Reset();
    1.98 +	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    1.99 +	unsigned int DrawItem(const ItemDrawInfo &item);
   1.100 +	bool DrawRawLine(const char *rawline);
   1.101 +	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
   1.102 +	bool SetExtOption(MenuOption option, const void *valuePtr);
   1.103 +	bool CanDrawItem(unsigned int drawFlags);
   1.104 +	void SendRawDisplay(int client, int priority, unsigned int time);
   1.105 +	void DeleteThis();
   1.106 +	bool SetSelectableKeys(unsigned int keymap);
   1.107 +	unsigned int GetCurrentKey();
   1.108 +	bool SetCurrentKey(unsigned int key);
   1.109 +	int GetAmountRemaining();
   1.110 +	unsigned int GetApproxMemUsage();
   1.111 +private:
   1.112 +	KeyValues *m_pKv;
   1.113 +	unsigned int m_NextPos;
   1.114 +	bool m_TitleDrawn;
   1.115 +};
   1.116 +
   1.117 +class CValveMenu : public CBaseMenu
   1.118 +{
   1.119 +	friend class CValveMenuDisplay;
   1.120 +public:
   1.121 +	CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
   1.122 +public: //IBaseMenu
   1.123 +	bool SetExtOption(MenuOption option, const void *valuePtr);
   1.124 +	IMenuPanel *CreatePanel();
   1.125 +	bool GetExitButton();
   1.126 +	bool SetExitButton(bool set);
   1.127 +	bool SetPagination(unsigned int itemsPerPage);
   1.128 +	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
   1.129 +	bool DisplayAtItem(int client,
   1.130 +		unsigned int time,
   1.131 +		unsigned int start_item,
   1.132 +		IMenuHandler *alt_handler/* =NULL */);
   1.133 +	void SetMenuOptionFlags(unsigned int flags);
   1.134 +	unsigned int GetApproxMemUsage();
   1.135 +public: //CBaseMenu
   1.136 +	void Cancel_Finally();
   1.137 +private:
   1.138 +	Color m_IntroColor;
   1.139 +	char m_IntroMsg[128];
   1.140 +};
   1.141 +
   1.142 +extern ValveMenuStyle g_ValveMenuStyle;
   1.143 +
   1.144 +#endif //_INCLUDE_MENUSTYLE_VALVE_H