core/MenuStyle_Radio.h
author David Anderson <dvander@alliedmods.net>
Sun Jun 17 18:48:46 2007 +0000 (2007-06-17)
changeset 972 63d848bccec5
parent 877 898c39fbfde9
child 1231 17badaf66ce4
permissions -rw-r--r--
fixed bug amb401
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_MENUSTYLE_RADIO_H
    16 #define _INCLUDE_MENUSTYLE_RADIO_H
    17 
    18 #include "sm_globals.h"
    19 #include "MenuManager.h"
    20 #include "MenuStyle_Base.h"
    21 #include "sourcemm_api.h"
    22 #include <IPlayerHelpers.h>
    23 #include <IUserMessages.h>
    24 #include "sm_fastlink.h"
    25 #include <sh_stack.h>
    26 
    27 using namespace SourceMod;
    28 
    29 class CRadioDisplay;
    30 class CRadioMenu;
    31 
    32 class CRadioStyle : 
    33 	public BaseMenuStyle,
    34 	public SMGlobalClass,
    35 	public IUserMessageListener
    36 {
    37 public:
    38 	CRadioStyle();
    39 public: //SMGlobalClass
    40 	void OnSourceModAllInitialized();
    41 	void OnSourceModLevelChange(const char *mapName);
    42 	void OnSourceModShutdown();
    43 public: //BaseMenuStyle
    44 	CBaseMenuPlayer *GetMenuPlayer(int client);
    45 	void SendDisplay(int client, IMenuPanel *display);
    46 public: //IMenuStyle
    47 	const char *GetStyleName();
    48 	IMenuPanel *CreatePanel();
    49 	IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    50 	unsigned int GetMaxPageItems();
    51 public: //IUserMessageListener
    52 	void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter);
    53 	void OnUserMessageSent(int msg_id);
    54 public:
    55 	bool IsSupported();
    56 	bool OnClientCommand(int client);
    57 public:
    58 	CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL);
    59 	void FreeRadioDisplay(CRadioDisplay *display);
    60 private:
    61 	CBaseMenuPlayer *m_players;
    62 	CStack<CRadioDisplay *> m_FreeDisplays;
    63 };
    64 
    65 class CRadioDisplay : public IMenuPanel
    66 {
    67 	friend class CRadioStyle;
    68 public:
    69 	CRadioDisplay();
    70 	CRadioDisplay(CRadioMenu *menu);
    71 public: //IMenuPanel
    72 	IMenuStyle *GetParentStyle();
    73 	void Reset();
    74 	void DrawTitle(const char *text, bool onlyIfEmpty=false);
    75 	unsigned int DrawItem(const ItemDrawInfo &item);
    76 	bool DrawRawLine(const char *rawline);
    77 	bool SetExtOption(MenuOption option, const void *valuePtr);
    78 	bool CanDrawItem(unsigned int drawFlags);
    79 	bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
    80 	void DeleteThis();
    81 	void SendRawDisplay(int client, unsigned int time);
    82 	bool SetSelectableKeys(unsigned int keymap);
    83 	unsigned int GetCurrentKey();
    84 	bool SetCurrentKey(unsigned int key);
    85 private:
    86 	String m_BufferText;
    87 	String m_Title;
    88 	unsigned int m_NextPos;
    89 	int keys;
    90 };
    91 
    92 class CRadioMenu : public CBaseMenu
    93 {
    94 public:
    95 	CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner);
    96 public:
    97 	bool SetExtOption(MenuOption option, const void *valuePtr);
    98 	IMenuPanel *CreatePanel();
    99 	bool Display(int client, unsigned int time);
   100 	void Cancel_Finally();
   101 	void VoteDisplay(int client, unsigned int maxTime);
   102 };
   103 
   104 extern CRadioStyle g_RadioMenuStyle;
   105 
   106 #endif //_INCLUDE_MENUSTYLE_RADIO_H