core/MenuStyle_Radio.h
author David Anderson <dvander@alliedmods.net>
Wed Aug 15 17:14:48 2007 +0000 (2007-08-15)
changeset 1335 2047dc42d800
parent 1330 ab94316bb52b
child 1361 591f6d2fd11d
permissions -rw-r--r--
fixed bug amb571 (FakeClientCommand having weird side effects)
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod
     5  * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_MENUSTYLE_RADIO_H
    33 #define _INCLUDE_MENUSTYLE_RADIO_H
    34 
    35 #include "sm_globals.h"
    36 #include "MenuManager.h"
    37 #include "MenuStyle_Base.h"
    38 #include "sourcemm_api.h"
    39 #include <IPlayerHelpers.h>
    40 #include <IUserMessages.h>
    41 #include "sm_fastlink.h"
    42 #include <sh_stack.h>
    43 
    44 using namespace SourceMod;
    45 
    46 class CRadioDisplay;
    47 class CRadioMenu;
    48 
    49 class CRadioStyle : 
    50 	public BaseMenuStyle,
    51 	public SMGlobalClass,
    52 	public IUserMessageListener
    53 {
    54 public:
    55 	CRadioStyle();
    56 public: //SMGlobalClass
    57 	void OnSourceModAllInitialized();
    58 	void OnSourceModLevelChange(const char *mapName);
    59 	void OnSourceModShutdown();
    60 public: //BaseMenuStyle
    61 	CBaseMenuPlayer *GetMenuPlayer(int client);
    62 	void SendDisplay(int client, IMenuPanel *display);
    63 public: //IMenuStyle
    64 	const char *GetStyleName();
    65 	IMenuPanel *CreatePanel();
    66 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    67 	unsigned int GetMaxPageItems();
    68 public: //IUserMessageListener
    69 	void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter);
    70 	void OnUserMessageSent(int msg_id);
    71 public:
    72 	bool IsSupported();
    73 	bool OnClientCommand(int client, const char *cmd);
    74 public:
    75 	CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
    76 	void FreeRadioDisplay(CRadioDisplay *display);
    77 private:
    78 	CBaseMenuPlayer *m_players;
    79 	CStack<CRadioDisplay *> m_FreeDisplays;
    80 };
    81 
    82 class CRadioDisplay : public IMenuPanel
    83 {
    84 	friend class CRadioStyle;
    85 public:
    86 	CRadioDisplay();
    87 	CRadioDisplay(CRadioMenu *menu);
    88 public: //IMenuPanel
    89 	IMenuStyle *GetParentStyle();
    90 	void Reset();
    91 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    92 	unsigned int DrawItem(const ItemDrawInfo &item);
    93 	bool DrawRawLine(const char *rawline);
    94 	bool SetExtOption(MenuOption option, const void *valuePtr);
    95 	bool CanDrawItem(unsigned int drawFlags);
    96 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    97 	void DeleteThis();
    98 	void SendRawDisplay(int client, unsigned int time);
    99 	bool SetSelectableKeys(unsigned int keymap);
   100 	unsigned int GetCurrentKey();
   101 	bool SetCurrentKey(unsigned int key);
   102 private:
   103 	String m_BufferText;
   104 	String m_Title;
   105 	unsigned int m_NextPos;
   106 	int keys;
   107 };
   108 
   109 class CRadioMenu : public CBaseMenu
   110 {
   111 public:
   112 	CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
   113 public:
   114 	bool SetExtOption(MenuOption option, const void *valuePtr);
   115 	IMenuPanel *CreatePanel();
   116 	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
   117 	void Cancel_Finally();
   118 };
   119 
   120 extern CRadioStyle g_RadioMenuStyle;
   121 
   122 #endif //_INCLUDE_MENUSTYLE_RADIO_H