core/MenuStyle_Radio.h
author David Anderson <dvander@alliedmods.net>
Sun Aug 26 17:41:02 2007 +0000 (2007-08-26)
changeset 1369 bd9ccced1b1a
parent 1361 591f6d2fd11d
child 1474 a3b73df84d88
permissions -rw-r--r--
fixed amb834 - command callbacks could potentially occur on invalid clients in very rare cases
dvander@780
     1
/**
dvander@780
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
dvander@1231
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
dvander@780
     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@780
    28
 *
dvander@780
    29
 * Version: $Id$
dvander@780
    30
 */
dvander@780
    31
dvander@780
    32
#ifndef _INCLUDE_MENUSTYLE_RADIO_H
dvander@780
    33
#define _INCLUDE_MENUSTYLE_RADIO_H
dvander@780
    34
dvander@780
    35
#include "sm_globals.h"
dvander@780
    36
#include "MenuManager.h"
dvander@780
    37
#include "MenuStyle_Base.h"
dvander@780
    38
#include "sourcemm_api.h"
dvander@780
    39
#include <IPlayerHelpers.h>
dvander@780
    40
#include <IUserMessages.h>
dvander@780
    41
#include "sm_fastlink.h"
dvander@790
    42
#include <sh_stack.h>
dvander@780
    43
dvander@780
    44
using namespace SourceMod;
dvander@780
    45
dvander@790
    46
class CRadioDisplay;
dvander@790
    47
class CRadioMenu;
dvander@790
    48
dvander@780
    49
class CRadioStyle : 
dvander@780
    50
	public BaseMenuStyle,
dvander@780
    51
	public SMGlobalClass,
dvander@780
    52
	public IUserMessageListener
dvander@780
    53
{
dvander@780
    54
public:
dvander@780
    55
	CRadioStyle();
dvander@780
    56
public: //SMGlobalClass
dvander@846
    57
	void OnSourceModAllInitialized();
dvander@785
    58
	void OnSourceModLevelChange(const char *mapName);
dvander@780
    59
	void OnSourceModShutdown();
dvander@780
    60
public: //BaseMenuStyle
dvander@780
    61
	CBaseMenuPlayer *GetMenuPlayer(int client);
dvander@787
    62
	void SendDisplay(int client, IMenuPanel *display);
dvander@780
    63
public: //IMenuStyle
dvander@780
    64
	const char *GetStyleName();
dvander@787
    65
	IMenuPanel *CreatePanel();
dvander@790
    66
	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@780
    67
	unsigned int GetMaxPageItems();
dvander@780
    68
public: //IUserMessageListener
dvander@780
    69
	void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter);
dvander@780
    70
	void OnUserMessageSent(int msg_id);
dvander@780
    71
public:
dvander@780
    72
	bool IsSupported();
dvander@1335
    73
	bool OnClientCommand(int client, const char *cmd);
dvander@790
    74
public:
dvander@790
    75
	CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
dvander@790
    76
	void FreeRadioDisplay(CRadioDisplay *display);
dvander@780
    77
private:
dvander@780
    78
	CBaseMenuPlayer *m_players;
dvander@790
    79
	CStack<CRadioDisplay *> m_FreeDisplays;
dvander@780
    80
};
dvander@780
    81
dvander@787
    82
class CRadioDisplay : public IMenuPanel
dvander@780
    83
{
dvander@790
    84
	friend class CRadioStyle;
dvander@780
    85
public:
dvander@780
    86
	CRadioDisplay();
dvander@780
    87
	CRadioDisplay(CRadioMenu *menu);
dvander@787
    88
public: //IMenuPanel
dvander@780
    89
	IMenuStyle *GetParentStyle();
dvander@780
    90
	void Reset();
dvander@780
    91
	void DrawTitle(const char *text, bool onlyIfEmpty=false);
dvander@780
    92
	unsigned int DrawItem(const ItemDrawInfo &item);
dvander@780
    93
	bool DrawRawLine(const char *rawline);
dvander@780
    94
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@780
    95
	bool CanDrawItem(unsigned int drawFlags);
dvander@780
    96
	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
dvander@780
    97
	void DeleteThis();
dvander@780
    98
	void SendRawDisplay(int client, unsigned int time);
dvander@819
    99
	bool SetSelectableKeys(unsigned int keymap);
dvander@840
   100
	unsigned int GetCurrentKey();
dvander@840
   101
	bool SetCurrentKey(unsigned int key);
dvander@1361
   102
	int GetAmountRemaining();
dvander@780
   103
private:
dvander@780
   104
	String m_BufferText;
dvander@780
   105
	String m_Title;
dvander@780
   106
	unsigned int m_NextPos;
dvander@780
   107
	int keys;
dvander@780
   108
};
dvander@780
   109
dvander@780
   110
class CRadioMenu : public CBaseMenu
dvander@780
   111
{
dvander@780
   112
public:
dvander@790
   113
	CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@780
   114
public:
dvander@780
   115
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@787
   116
	IMenuPanel *CreatePanel();
dvander@1269
   117
	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
dvander@780
   118
	void Cancel_Finally();
dvander@780
   119
};
dvander@780
   120
dvander@780
   121
extern CRadioStyle g_RadioMenuStyle;
dvander@780
   122
dvander@780
   123
#endif //_INCLUDE_MENUSTYLE_RADIO_H