ds@1952: /** ds@1952: * vim: set ts=4 : ds@1952: * ============================================================================= ds@1952: * SourceMod ds@1952: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. ds@1952: * ============================================================================= ds@1952: * ds@1952: * This program is free software; you can redistribute it and/or modify it under ds@1952: * the terms of the GNU General Public License, version 3.0, as published by the ds@1952: * Free Software Foundation. ds@1952: * ds@1952: * This program is distributed in the hope that it will be useful, but WITHOUT ds@1952: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ds@1952: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more ds@1952: * details. ds@1952: * ds@1952: * You should have received a copy of the GNU General Public License along with ds@1952: * this program. If not, see . ds@1952: * ds@1952: * As a special exception, AlliedModders LLC gives you permission to link the ds@1952: * code of this program (as well as its derivative works) to "Half-Life 2," the ds@1952: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software ds@1952: * by the Valve Corporation. You must obey the GNU General Public License in ds@1952: * all respects for all other code used. Additionally, AlliedModders LLC grants ds@1952: * this exception to all derivative works. AlliedModders LLC defines further ds@1952: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), ds@1952: * or . ds@1952: * ds@1952: * Version: $Id$ ds@1952: */ ds@1952: ds@1952: #ifndef _INCLUDE_MENUSTYLE_VALVE_H ds@1952: #define _INCLUDE_MENUSTYLE_VALVE_H ds@1952: ds@1952: #include "sm_globals.h" ds@1952: #include "MenuManager.h" ds@1952: #include "MenuStyle_Base.h" ds@1952: #include "sourcemm_api.h" ds@1952: #include "KeyValues.h" ds@1952: #include "sm_fastlink.h" ds@1952: #include ds@1952: ds@1952: using namespace SourceMod; ds@1952: ds@1952: class CValveMenuPlayer : public CBaseMenuPlayer ds@1952: { ds@1952: public: ds@1952: CValveMenuPlayer() : curPrioLevel(1) ds@1952: { ds@1952: } ds@1952: int curPrioLevel; ds@1952: }; ds@1952: ds@1952: class CValveMenu; ds@1952: class CValveMenuDisplay; ds@1952: ds@1952: class ValveMenuStyle : ds@1952: public SMGlobalClass, ds@1952: public BaseMenuStyle ds@1952: { ds@1952: public: ds@1952: ValveMenuStyle(); ds@1952: bool OnClientCommand(int client, const char *cmdname, const CCommand &cmd); ds@1952: public: //BaseMenuStyle ds@1952: CBaseMenuPlayer *GetMenuPlayer(int client); ds@1952: void SendDisplay(int client, IMenuPanel *display); ds@1952: bool DoClientMenu(int client, CBaseMenu *menu, unsigned int first_item, IMenuHandler *mh, unsigned int time); ds@1952: bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time); ds@1952: public: //SMGlobalClass ds@1952: void OnSourceModAllInitialized(); ds@1952: void OnSourceModShutdown(); ds@1952: public: //IMenuStyle ds@1952: const char *GetStyleName(); ds@1952: IMenuPanel *CreatePanel(); ds@1952: IBaseMenu *CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); ds@1952: unsigned int GetMaxPageItems(); ds@1952: unsigned int GetApproxMemUsage(); ds@1952: private: ds@1952: void HookCreateMessage(edict_t *pEdict, DIALOG_TYPE type, KeyValues *kv, IServerPluginCallbacks *plugin); ds@1952: private: ds@1952: CValveMenuPlayer *m_players; ds@1952: }; ds@1952: ds@1952: class CValveMenu; ds@1952: ds@1952: class CValveMenuDisplay : public IMenuPanel ds@1952: { ds@1952: public: ds@1952: CValveMenuDisplay(); ds@1952: CValveMenuDisplay(CValveMenu *pMenu); ds@1952: ~CValveMenuDisplay(); ds@1952: public: ds@1952: IMenuStyle *GetParentStyle(); ds@1952: void Reset(); ds@1952: void DrawTitle(const char *text, bool onlyIfEmpty=false); ds@1952: unsigned int DrawItem(const ItemDrawInfo &item); ds@1952: bool DrawRawLine(const char *rawline); ds@1952: bool SendDisplay(int client, IMenuHandler *handler, unsigned int time); ds@1952: bool SetExtOption(MenuOption option, const void *valuePtr); ds@1952: bool CanDrawItem(unsigned int drawFlags); ds@1952: void SendRawDisplay(int client, int priority, unsigned int time); ds@1952: void DeleteThis(); ds@1952: bool SetSelectableKeys(unsigned int keymap); ds@1952: unsigned int GetCurrentKey(); ds@1952: bool SetCurrentKey(unsigned int key); ds@1952: int GetAmountRemaining(); ds@1952: unsigned int GetApproxMemUsage(); ds@1952: private: ds@1952: KeyValues *m_pKv; ds@1952: unsigned int m_NextPos; ds@1952: bool m_TitleDrawn; ds@1952: }; ds@1952: ds@1952: class CValveMenu : public CBaseMenu ds@1952: { ds@1952: friend class CValveMenuDisplay; ds@1952: public: ds@1952: CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner); ds@1952: public: //IBaseMenu ds@1952: bool SetExtOption(MenuOption option, const void *valuePtr); ds@1952: IMenuPanel *CreatePanel(); ds@1952: bool GetExitButton(); ds@1952: bool SetExitButton(bool set); ds@1952: bool SetPagination(unsigned int itemsPerPage); ds@1952: bool Display(int client, unsigned int time, IMenuHandler *alt_handler=NULL); ds@1952: bool DisplayAtItem(int client, ds@1952: unsigned int time, ds@1952: unsigned int start_item, ds@1952: IMenuHandler *alt_handler/* =NULL */); ds@1952: void SetMenuOptionFlags(unsigned int flags); ds@1952: unsigned int GetApproxMemUsage(); ds@1952: public: //CBaseMenu ds@1952: void Cancel_Finally(); ds@1952: private: ds@1952: Color m_IntroColor; ds@1952: char m_IntroMsg[128]; ds@1952: }; ds@1952: ds@1952: extern ValveMenuStyle g_ValveMenuStyle; ds@1952: ds@1952: #endif //_INCLUDE_MENUSTYLE_VALVE_H