dvander@780: /** dvander@780: * vim: set ts=4 : ds@1330: * ============================================================================= dvander@1231: * SourceMod ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. ds@1330: * ============================================================================= dvander@780: * ds@1330: * This program is free software; you can redistribute it and/or modify it under ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the ds@1330: * Free Software Foundation. dvander@1231: * ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1330: * details. dvander@1231: * ds@1330: * You should have received a copy of the GNU General Public License along with ds@1330: * this program. If not, see . dvander@1231: * ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1330: * this exception to all derivative works. AlliedModders LLC defines further ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1330: * or . dvander@780: * dvander@780: * Version: $Id$ dvander@780: */ dvander@780: dvander@780: #ifndef _INCLUDE_MENUSTYLE_RADIO_H dvander@780: #define _INCLUDE_MENUSTYLE_RADIO_H dvander@780: dvander@780: #include "sm_globals.h" dvander@780: #include "MenuManager.h" dvander@780: #include "MenuStyle_Base.h" dvander@780: #include "sourcemm_api.h" dvander@780: #include dvander@780: #include dvander@780: #include "sm_fastlink.h" dvander@790: #include faluco@1541: #include dvander@780: dvander@780: using namespace SourceMod; dvander@780: dvander@790: class CRadioDisplay; dvander@790: class CRadioMenu; dvander@790: dvander@1695: class CRadioMenuPlayer : public CBaseMenuPlayer dvander@1695: { dvander@1695: public: dvander@1695: void Radio_Init(int keys, const char *title, const char *buffer); dvander@1695: bool Radio_NeedsRefresh(); dvander@1695: void Radio_Refresh(); dvander@1695: void Radio_SetIndex(unsigned int index); dvander@1695: private: dvander@1695: unsigned int m_index; dvander@1695: size_t display_len; dvander@1695: char display_pkt[512]; dvander@1695: int display_keys; dvander@1695: float display_last_refresh; dvander@1695: }; dvander@1695: dvander@780: class CRadioStyle : dvander@780: public BaseMenuStyle, dvander@780: public SMGlobalClass, dvander@780: public IUserMessageListener dvander@780: { dvander@780: public: dvander@780: CRadioStyle(); dvander@780: public: //SMGlobalClass dvander@846: void OnSourceModAllInitialized(); dvander@785: void OnSourceModLevelChange(const char *mapName); dvander@780: void OnSourceModShutdown(); dvander@780: public: //BaseMenuStyle dvander@780: CBaseMenuPlayer *GetMenuPlayer(int client); dvander@787: void SendDisplay(int client, IMenuPanel *display); dvander@1695: void ProcessWatchList(); dvander@780: public: //IMenuStyle dvander@780: const char *GetStyleName(); dvander@787: IMenuPanel *CreatePanel(); dvander@790: IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); dvander@780: unsigned int GetMaxPageItems(); dvander@1766: unsigned int GetApproxMemUsage(); dvander@780: public: //IUserMessageListener dvander@780: void OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter); dvander@780: void OnUserMessageSent(int msg_id); dvander@780: public: dvander@780: bool IsSupported(); faluco@1541: bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd); dvander@790: public: dvander@790: CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL); dvander@790: void FreeRadioDisplay(CRadioDisplay *display); dvander@1695: CRadioMenuPlayer *GetRadioMenuPlayer(int client); dvander@1705: IMenuPanel *MakeRadioDisplay(const char *str, int keys); dvander@780: private: dvander@1695: CRadioMenuPlayer *m_players; dvander@790: CStack m_FreeDisplays; dvander@780: }; dvander@780: dvander@787: class CRadioDisplay : public IMenuPanel dvander@780: { dvander@790: friend class CRadioStyle; dvander@780: public: dvander@780: CRadioDisplay(); dvander@780: CRadioDisplay(CRadioMenu *menu); dvander@787: public: //IMenuPanel dvander@780: IMenuStyle *GetParentStyle(); dvander@780: void Reset(); dvander@780: void DrawTitle(const char *text, bool onlyIfEmpty=false); dvander@780: unsigned int DrawItem(const ItemDrawInfo &item); dvander@780: bool DrawRawLine(const char *rawline); dvander@780: bool SetExtOption(MenuOption option, const void *valuePtr); dvander@780: bool CanDrawItem(unsigned int drawFlags); dvander@780: bool SendDisplay(int client, IMenuHandler *handler, unsigned int time); dvander@780: void DeleteThis(); dvander@780: void SendRawDisplay(int client, unsigned int time); dvander@819: bool SetSelectableKeys(unsigned int keymap); dvander@840: unsigned int GetCurrentKey(); dvander@840: bool SetCurrentKey(unsigned int key); dvander@1361: int GetAmountRemaining(); dvander@1766: unsigned int GetApproxMemUsage(); dvander@1705: public: dvander@1705: void DirectSet(const char *str, int keymap); dvander@780: private: dvander@780: String m_BufferText; dvander@780: String m_Title; dvander@780: unsigned int m_NextPos; dvander@780: int keys; dvander@780: }; dvander@780: dvander@780: class CRadioMenu : public CBaseMenu dvander@780: { dvander@780: public: dvander@790: CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); dvander@780: public: dvander@780: bool SetExtOption(MenuOption option, const void *valuePtr); dvander@787: IMenuPanel *CreatePanel(); dvander@1269: bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL); dvander@1474: bool DisplayAtItem(int client, dvander@1474: unsigned int time, dvander@1474: unsigned int start_item, dvander@1474: IMenuHandler *alt_handler/* =NULL */); dvander@780: void Cancel_Finally(); dvander@1766: unsigned int GetApproxMemUsage(); dvander@780: }; dvander@780: dvander@780: extern CRadioStyle g_RadioMenuStyle; dvander@780: dvander@780: #endif //_INCLUDE_MENUSTYLE_RADIO_H