core/MenuStyle_Valve.h
author Nicholas Hastings <skamonkey@gmail.com>
Sat Aug 03 19:03:12 2013 -0400 (2013-08-03)
changeset 3969 fe179ff9a57a
parent 2289 44045ead61cd
permissions -rw-r--r--
Triggering build.
dvander@769
     1
/**
dvander@769
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
dvander@769
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1231
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1231
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1231
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
dvander@769
    28
 *
dvander@769
    29
 * Version: $Id$
dvander@769
    30
 */
dvander@769
    31
dvander@769
    32
#ifndef _INCLUDE_MENUSTYLE_VALVE_H
dvander@769
    33
#define _INCLUDE_MENUSTYLE_VALVE_H
dvander@769
    34
dvander@769
    35
#include "sm_globals.h"
dvander@769
    36
#include "MenuManager.h"
dvander@769
    37
#include "MenuStyle_Base.h"
dvander@769
    38
#include "sourcemm_api.h"
dvander@769
    39
#include "KeyValues.h"
dvander@769
    40
#include "sm_fastlink.h"
faluco@1541
    41
#include <compat_wrappers.h>
dvander@769
    42
dvander@769
    43
using namespace SourceMod;
dvander@769
    44
dvander@775
    45
class CValveMenuPlayer : public CBaseMenuPlayer
dvander@769
    46
{
dvander@769
    47
public:
dvander@775
    48
	CValveMenuPlayer() : curPrioLevel(1)
dvander@769
    49
	{
dvander@769
    50
	}
dvander@769
    51
	int curPrioLevel;
dvander@769
    52
};
dvander@769
    53
dvander@769
    54
class CValveMenu;
dvander@769
    55
class CValveMenuDisplay;
dvander@769
    56
dvander@769
    57
class ValveMenuStyle : 
dvander@769
    58
	public SMGlobalClass,
dvander@775
    59
	public BaseMenuStyle
dvander@769
    60
{
dvander@769
    61
public:
dvander@769
    62
	ValveMenuStyle();
faluco@1541
    63
	bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd);
dvander@775
    64
public: //BaseMenuStyle
dvander@775
    65
	CBaseMenuPlayer *GetMenuPlayer(int client);
dvander@787
    66
	void SendDisplay(int client, IMenuPanel *display);
dvander@1474
    67
	bool DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, IMenuHandler *mh, unsigned int time);
dvander@787
    68
	bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
dvander@769
    69
public: //SMGlobalClass
dvander@769
    70
	void OnSourceModAllInitialized();
dvander@769
    71
	void OnSourceModShutdown();
dvander@769
    72
public: //IMenuStyle
dvander@769
    73
	const char *GetStyleName();
dvander@787
    74
	IMenuPanel *CreatePanel();
dvander@790
    75
	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@769
    76
	unsigned int GetMaxPageItems();
dvander@1766
    77
	unsigned int GetApproxMemUsage();
dvander@769
    78
private:
dvander@769
    79
	void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin);
dvander@769
    80
private:
dvander@769
    81
	CValveMenuPlayer *m_players;
dvander@769
    82
};
dvander@769
    83
dvander@769
    84
class CValveMenu;
dvander@769
    85
dvander@787
    86
class CValveMenuDisplay : public IMenuPanel
dvander@769
    87
{
dvander@769
    88
public:
dvander@769
    89
	CValveMenuDisplay();
dvander@769
    90
	CValveMenuDisplay(CValveMenu *pMenu);
dvander@769
    91
	~CValveMenuDisplay();
dvander@769
    92
public:
dvander@769
    93
	IMenuStyle *GetParentStyle();
dvander@769
    94
	void Reset();
dvander@769
    95
	void DrawTitle(const char *text, bool onlyIfEmpty=false);
dvander@769
    96
	unsigned int DrawItem(const ItemDrawInfo &item);
dvander@769
    97
	bool DrawRawLine(const char *rawline);
dvander@769
    98
	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
dvander@769
    99
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@769
   100
	bool CanDrawItem(unsigned int drawFlags);
dvander@769
   101
	void SendRawDisplay(int client, int priority, unsigned int time);
dvander@776
   102
	void DeleteThis();
dvander@819
   103
	bool SetSelectableKeys(unsigned int keymap);
dvander@840
   104
	unsigned int GetCurrentKey();
dvander@840
   105
	bool SetCurrentKey(unsigned int key);
dvander@1361
   106
	int GetAmountRemaining();
dvander@1766
   107
	unsigned int GetApproxMemUsage();
dvander@769
   108
private:
dvander@769
   109
	KeyValues *m_pKv;
dvander@769
   110
	unsigned int m_NextPos;
dvander@769
   111
	bool m_TitleDrawn;
dvander@769
   112
};
dvander@769
   113
dvander@769
   114
class CValveMenu : public CBaseMenu
dvander@769
   115
{
dvander@769
   116
	friend class CValveMenuDisplay;
dvander@769
   117
public:
dvander@790
   118
	CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@776
   119
public: //IBaseMenu
dvander@769
   120
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@787
   121
	IMenuPanel *CreatePanel();
dvander@769
   122
	bool GetExitButton();
dvander@769
   123
	bool SetExitButton(bool set);
dvander@769
   124
	bool SetPagination(unsigned int itemsPerPage);
dvander@1269
   125
	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
dvander@1474
   126
	bool DisplayAtItem(int client,
dvander@1474
   127
		unsigned int time,
dvander@1474
   128
		unsigned int start_item,
dvander@1474
   129
		IMenuHandler *alt_handler/* =NULL */);
dvander@1259
   130
	void SetMenuOptionFlags(unsigned int flags);
dvander@1766
   131
	unsigned int GetApproxMemUsage();
dvander@776
   132
public: //CBaseMenu
dvander@775
   133
	void Cancel_Finally();
dvander@769
   134
private:
dvander@769
   135
	Color m_IntroColor;
dvander@769
   136
	char m_IntroMsg[128];
dvander@769
   137
};
dvander@769
   138
dvander@769
   139
extern ValveMenuStyle g_ValveMenuStyle;
dvander@769
   140
dvander@769
   141
#endif //_INCLUDE_MENUSTYLE_VALVE_H