core/MenuStyle_Radio.h
author David Anderson <dvander@alliedmods.net>
Mon Oct 15 00:38:25 2007 +0000 (2007-10-15)
changeset 1568 ecbaee393b0b
parent 1541 e46ad208b9b4
child 1695 1c59f0a5e596
child 1715 f9ecab642e25
permissions -rw-r--r--
extensions can now be built for multiple engines, and will autoload from auto.X.Y folders
     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 #include <compat_wrappers.h>
    44 
    45 using namespace SourceMod;
    46 
    47 class CRadioDisplay;
    48 class CRadioMenu;
    49 
    50 class CRadioStyle : 
    51 	public BaseMenuStyle,
    52 	public SMGlobalClass,
    53 	public IUserMessageListener
    54 {
    55 public:
    56 	CRadioStyle();
    57 public: //SMGlobalClass
    58 	void OnSourceModAllInitialized();
    59 	void OnSourceModLevelChange(const char *mapName);
    60 	void OnSourceModShutdown();
    61 public: //BaseMenuStyle
    62 	CBaseMenuPlayer *GetMenuPlayer(int client);
    63 	void SendDisplay(int client, IMenuPanel *display);
    64 public: //IMenuStyle
    65 	const char *GetStyleName();
    66 	IMenuPanel *CreatePanel();
    67 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    68 	unsigned int GetMaxPageItems();
    69 public: //IUserMessageListener
    70 	void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter);
    71 	void OnUserMessageSent(int msg_id);
    72 public:
    73 	bool IsSupported();
    74 	bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd);
    75 public:
    76 	CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
    77 	void FreeRadioDisplay(CRadioDisplay *display);
    78 private:
    79 	CBaseMenuPlayer *m_players;
    80 	CStack<CRadioDisplay *> m_FreeDisplays;
    81 };
    82 
    83 class CRadioDisplay : public IMenuPanel
    84 {
    85 	friend class CRadioStyle;
    86 public:
    87 	CRadioDisplay();
    88 	CRadioDisplay(CRadioMenu *menu);
    89 public: //IMenuPanel
    90 	IMenuStyle *GetParentStyle();
    91 	void Reset();
    92 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    93 	unsigned int DrawItem(const ItemDrawInfo &item);
    94 	bool DrawRawLine(const char *rawline);
    95 	bool SetExtOption(MenuOption option, const void *valuePtr);
    96 	bool CanDrawItem(unsigned int drawFlags);
    97 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    98 	void DeleteThis();
    99 	void SendRawDisplay(int client, unsigned int time);
   100 	bool SetSelectableKeys(unsigned int keymap);
   101 	unsigned int GetCurrentKey();
   102 	bool SetCurrentKey(unsigned int key);
   103 	int GetAmountRemaining();
   104 private:
   105 	String m_BufferText;
   106 	String m_Title;
   107 	unsigned int m_NextPos;
   108 	int keys;
   109 };
   110 
   111 class CRadioMenu : public CBaseMenu
   112 {
   113 public:
   114 	CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
   115 public:
   116 	bool SetExtOption(MenuOption option, const void *valuePtr);
   117 	IMenuPanel *CreatePanel();
   118 	bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL);
   119 	bool DisplayAtItem(int client,
   120 		unsigned int time,
   121 		unsigned int start_item,
   122 		IMenuHandler *alt_handler/* =NULL */);
   123 	void Cancel_Finally();
   124 };
   125 
   126 extern CRadioStyle g_RadioMenuStyle;
   127 
   128 #endif //_INCLUDE_MENUSTYLE_RADIO_H