core/MenuStyle_Radio.h
author David Anderson <dvander@alliedmods.net>
Tue Oct 16 01:17:08 2007 +0000 (2007-10-16)
changeset 1582 6f18465dd9f9
parent 1541 e46ad208b9b4
child 1695 1c59f0a5e596
child 1715 f9ecab642e25
permissions -rw-r--r--
- added new system for detecting convar/concmd removals in one nice place
- convar code overhaul - reorganized handle contents to make removal easier
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>
faluco@1541
    43
#include <compat_wrappers.h>
dvander@780
    44
dvander@780
    45
using namespace SourceMod;
dvander@780
    46
dvander@790
    47
class CRadioDisplay;
dvander@790
    48
class CRadioMenu;
dvander@790
    49
dvander@780
    50
class CRadioStyle : 
dvander@780
    51
	public BaseMenuStyle,
dvander@780
    52
	public SMGlobalClass,
dvander@780
    53
	public IUserMessageListener
dvander@780
    54
{
dvander@780
    55
public:
dvander@780
    56
	CRadioStyle();
dvander@780
    57
public: //SMGlobalClass
dvander@846
    58
	void OnSourceModAllInitialized();
dvander@785
    59
	void OnSourceModLevelChange(const char *mapName);
dvander@780
    60
	void OnSourceModShutdown();
dvander@780
    61
public: //BaseMenuStyle
dvander@780
    62
	CBaseMenuPlayer *GetMenuPlayer(int client);
dvander@787
    63
	void SendDisplay(int client, IMenuPanel *display);
dvander@780
    64
public: //IMenuStyle
dvander@780
    65
	const char *GetStyleName();
dvander@787
    66
	IMenuPanel *CreatePanel();
dvander@790
    67
	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@780
    68
	unsigned int GetMaxPageItems();
dvander@780
    69
public: //IUserMessageListener
dvander@780
    70
	void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter);
dvander@780
    71
	void OnUserMessageSent(int msg_id);
dvander@780
    72
public:
dvander@780
    73
	bool IsSupported();
faluco@1541
    74
	bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd);
dvander@790
    75
public:
dvander@790
    76
	CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
dvander@790
    77
	void FreeRadioDisplay(CRadioDisplay *display);
dvander@780
    78
private:
dvander@780
    79
	CBaseMenuPlayer *m_players;
dvander@790
    80
	CStack<CRadioDisplay *> m_FreeDisplays;
dvander@780
    81
};
dvander@780
    82
dvander@787
    83
class CRadioDisplay : public IMenuPanel
dvander@780
    84
{
dvander@790
    85
	friend class CRadioStyle;
dvander@780
    86
public:
dvander@780
    87
	CRadioDisplay();
dvander@780
    88
	CRadioDisplay(CRadioMenu *menu);
dvander@787
    89
public: //IMenuPanel
dvander@780
    90
	IMenuStyle *GetParentStyle();
dvander@780
    91
	void Reset();
dvander@780
    92
	void DrawTitle(const char *text, bool onlyIfEmpty=false);
dvander@780
    93
	unsigned int DrawItem(const ItemDrawInfo &item);
dvander@780
    94
	bool DrawRawLine(const char *rawline);
dvander@780
    95
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@780
    96
	bool CanDrawItem(unsigned int drawFlags);
dvander@780
    97
	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
dvander@780
    98
	void DeleteThis();
dvander@780
    99
	void SendRawDisplay(int client, unsigned int time);
dvander@819
   100
	bool SetSelectableKeys(unsigned int keymap);
dvander@840
   101
	unsigned int GetCurrentKey();
dvander@840
   102
	bool SetCurrentKey(unsigned int key);
dvander@1361
   103
	int GetAmountRemaining();
dvander@780
   104
private:
dvander@780
   105
	String m_BufferText;
dvander@780
   106
	String m_Title;
dvander@780
   107
	unsigned int m_NextPos;
dvander@780
   108
	int keys;
dvander@780
   109
};
dvander@780
   110
dvander@780
   111
class CRadioMenu : public CBaseMenu
dvander@780
   112
{
dvander@780
   113
public:
dvander@790
   114
	CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
dvander@780
   115
public:
dvander@780
   116
	bool SetExtOption(MenuOption option, const void *valuePtr);
dvander@787
   117
	IMenuPanel *CreatePanel();
dvander@1269
   118
	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
dvander@1474
   119
	bool DisplayAtItem(int client,
dvander@1474
   120
		unsigned int time,
dvander@1474
   121
		unsigned int start_item,
dvander@1474
   122
		IMenuHandler *alt_handler/* =NULL */);
dvander@780
   123
	void Cancel_Finally();
dvander@780
   124
};
dvander@780
   125
dvander@780
   126
extern CRadioStyle g_RadioMenuStyle;
dvander@780
   127
dvander@780
   128
#endif //_INCLUDE_MENUSTYLE_RADIO_H