1.1 --- a/core/MenuStyle_Base.h Fri Jul 11 06:51:21 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,157 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#ifndef _INCLUDE_MENUSTYLE_BASE_H
1.36 -#define _INCLUDE_MENUSTYLE_BASE_H
1.37 -
1.38 -#include <IMenuManager.h>
1.39 -#include <IPlayerHelpers.h>
1.40 -#include <sh_string.h>
1.41 -#include <sh_vector.h>
1.42 -#include "sm_memtable.h"
1.43 -#include "sm_fastlink.h"
1.44 -
1.45 -using namespace SourceMod;
1.46 -using namespace SourceHook;
1.47 -
1.48 -class CItem
1.49 -{
1.50 -public:
1.51 - CItem()
1.52 - {
1.53 - infoString = -1;
1.54 - displayString = -1;
1.55 - style = 0;
1.56 - access = 0;
1.57 - }
1.58 -public:
1.59 - int infoString;
1.60 - int displayString;
1.61 - unsigned int style;
1.62 - unsigned int access;
1.63 -};
1.64 -
1.65 -class CBaseMenuPlayer
1.66 -{
1.67 -public:
1.68 - CBaseMenuPlayer() : bInMenu(false), bAutoIgnore(false), bInExternMenu(false)
1.69 - {
1.70 - }
1.71 - menu_states_t states;
1.72 - bool bInMenu;
1.73 - bool bAutoIgnore;
1.74 - float menuStartTime;
1.75 - unsigned int menuHoldTime;
1.76 - bool bInExternMenu;
1.77 -};
1.78 -
1.79 -class CBaseMenu;
1.80 -
1.81 -class BaseMenuStyle :
1.82 - public IMenuStyle,
1.83 - public IClientListener
1.84 -{
1.85 -public:
1.86 - BaseMenuStyle();
1.87 -public: //IMenuStyle
1.88 - bool CancelClientMenu(int client, bool autoIgnore/* =false */);
1.89 - MenuSource GetClientMenu(int client, void **object);
1.90 - Handle_t GetHandle();
1.91 -public: //IClientListener
1.92 - void OnClientDisconnected(int client);
1.93 -public: //what derived must implement
1.94 - virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
1.95 - virtual void SendDisplay(int client, IMenuPanel *display) =0;
1.96 -public: //what derived may implement
1.97 - virtual bool DoClientMenu(int client,
1.98 - CBaseMenu *menu,
1.99 - unsigned int first_item,
1.100 - IMenuHandler *mh,
1.101 - unsigned int time);
1.102 - virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
1.103 - virtual void AddClientToWatch(int client);
1.104 - virtual void RemoveClientFromWatch(int client);
1.105 - virtual void ProcessWatchList();
1.106 -public: //helpers
1.107 - void CancelMenu(CBaseMenu *menu);
1.108 - void ClientPressedKey(int client, unsigned int key_press);
1.109 -protected:
1.110 - void _CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore=false);
1.111 - bool RedoClientMenu(int client, ItemOrder order);
1.112 -protected:
1.113 - FastLink<int> m_WatchList;
1.114 - Handle_t m_hHandle;
1.115 -};
1.116 -
1.117 -class CBaseMenu : public IBaseMenu
1.118 -{
1.119 -public:
1.120 - CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner);
1.121 - virtual ~CBaseMenu();
1.122 -public:
1.123 - virtual bool AppendItem(const char *info, const ItemDrawInfo &draw);
1.124 - virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
1.125 - virtual bool RemoveItem(unsigned int position);
1.126 - virtual void RemoveAllItems();
1.127 - virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
1.128 - virtual unsigned int GetItemCount();
1.129 - virtual bool SetPagination(unsigned int itemsPerPage);
1.130 - virtual unsigned int GetPagination();
1.131 - virtual IMenuStyle *GetDrawStyle();
1.132 - virtual void SetDefaultTitle(const char *message);
1.133 - virtual const char *GetDefaultTitle();
1.134 - virtual void Cancel();
1.135 - virtual void Destroy(bool releaseHandle);
1.136 - virtual void Cancel_Finally() =0;
1.137 - virtual Handle_t GetHandle();
1.138 - virtual unsigned int GetMenuOptionFlags();
1.139 - virtual void SetMenuOptionFlags(unsigned int flags);
1.140 - virtual IMenuHandler *GetHandler();
1.141 - unsigned int GetBaseMemUsage();
1.142 -private:
1.143 - void InternalDelete();
1.144 -protected:
1.145 - String m_Title;
1.146 - IMenuStyle *m_pStyle;
1.147 - BaseStringTable m_Strings;
1.148 - unsigned int m_Pagination;
1.149 - CVector<CItem> m_items;
1.150 - bool m_bShouldDelete;
1.151 - bool m_bCancelling;
1.152 - IdentityToken_t *m_pOwner;
1.153 - bool m_bDeleting;
1.154 - bool m_bWillFreeHandle;
1.155 - Handle_t m_hHandle;
1.156 - IMenuHandler *m_pHandler;
1.157 - unsigned int m_nFlags;
1.158 -};
1.159 -
1.160 -#endif //_INCLUDE_MENUSTYLE_BASE_H