Update CS:GO team score gamedata.
2 * vim: set ts=4 sw=4 tw=99 noet :
3 * =============================================================================
4 * SourceMod TopMenus Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
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.
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
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/>.
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>.
32 #ifndef _INCLUDE_SOURCEMOD_TOP_MENU_H_
33 #define _INCLUDE_SOURCEMOD_TOP_MENU_H_
36 #include <sh_vector.h>
37 #include <ITopMenus.h>
38 #include "smsdk_ext.h"
39 #include "sm_memtable.h"
40 #include <sm_namehashset.h>
42 using namespace SourceHook;
43 using namespace SourceMod;
45 struct config_category_t
48 CVector<int> commands;
53 config_root_t() : strings(1024)
56 BaseStringTable strings;
57 CVector<config_category_t *> cats;
60 struct topmenu_object_t
62 char name[64]; /** Name */
63 char cmdname[64]; /** Command name */
64 FlagBits flags; /** Admin flags */
65 ITopMenuObjectCallbacks *callbacks; /** Callbacks */
66 IdentityToken_t *owner; /** Owner */
67 unsigned int object_id; /** Object ID */
68 topmenu_object_t *parent; /** Parent, if any */
69 TopMenuObjectType type; /** Object Type */
70 bool is_free; /** Free or not? */
71 char info[255]; /** Info string */
72 unsigned int cat_id; /** Set if a category */
74 static inline bool matches(const char *name, const topmenu_object_t *topmenu)
76 return strcmp(name, topmenu->name) == 0;
80 struct topmenu_category_t
82 CVector<topmenu_object_t *> obj_list; /** Full object list */
83 CVector<topmenu_object_t *> sorted; /** Sorted items */
84 CVector<topmenu_object_t *> unsorted; /** Unsorted items */
85 topmenu_object_t *obj; /** Bound object */
86 unsigned int serial; /** Serial number */
87 bool reorder; /** Whether ordering needs updating */
90 struct topmenu_player_category_t
92 IBaseMenu *menu; /** menu pointer */
93 unsigned int serial; /** last known serial */
96 struct topmenu_player_t
98 int user_id; /** userid on server */
99 unsigned int menu_serial; /** menu serial no */
100 IBaseMenu *root; /** root menu display */
101 topmenu_player_category_t *cats; /** category display */
102 unsigned int cat_count; /** number of categories */
103 unsigned int last_category; /** last category they selected */
104 unsigned int last_position; /** last position in that category */
105 unsigned int last_root_pos; /** last page in the root menu */
111 public ITextListener_SMC
113 friend class TopMenuManager;
115 TopMenu(ITopMenuObjectCallbacks *callbacks);
118 virtual unsigned int AddToMenu(const char *name,
119 TopMenuObjectType type,
120 ITopMenuObjectCallbacks *callbacks,
121 IdentityToken_t *owner,
124 unsigned int parent);
125 unsigned int AddToMenu2(const char *name,
126 TopMenuObjectType type,
127 ITopMenuObjectCallbacks *callbacks,
128 IdentityToken_t *owner,
132 const char *info_string);
133 virtual void RemoveFromMenu(unsigned int object_id);
134 virtual bool DisplayMenu(int client,
135 unsigned int hold_time,
136 TopMenuPosition position);
137 virtual bool LoadConfiguration(const char *file, char *error, size_t maxlength);
138 virtual unsigned int FindCategory(const char *name);
139 const char *GetObjectInfoString(unsigned int object_id);
140 const char *GetObjectName(unsigned int object_id);
141 public: //IMenuHandler
142 virtual void OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page);
143 virtual void OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style);
144 virtual unsigned int OnMenuDisplayItem(IBaseMenu *menu,
148 const ItemDrawInfo &dr);
149 virtual void OnMenuCancel(IBaseMenu *menu, int client, MenuCancelReason reason);
150 public: //ITextListener_SMC
151 void ReadSMC_ParseStart();
152 SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
153 SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
154 SMCResult ReadSMC_LeavingSection(const SMCStates *states);
156 unsigned int CalcMemUsage();
157 void SetTitleCaching(bool cache_titles);
158 bool DisplayMenuAtCategory(int client, unsigned int object_id);
160 void SortCategoriesIfNeeded();
161 void SortCategoryIfNeeded(unsigned int category);
163 bool DisplayCategory(int client, unsigned int category, unsigned int hold_time, bool last_position);
164 void CreatePlayers(int max_clients);
165 void UpdateClientRoot(int client, IGamePlayer *pGamePlayer=NULL);
166 void UpdateClientCategory(int client, unsigned int category, bool bSkipRootCheck=false);
167 void TearDownClient(topmenu_player_t *player);
168 bool FindCategoryByObject(unsigned int obj_id, size_t *index);
170 void OnClientConnected(int client);
171 void OnClientDisconnected(int client);
172 void OnServerActivated(int max_clients);
173 bool OnIdentityRemoval(IdentityToken_t *owner);
174 void OnMaxPlayersChanged(int newvalue);
176 config_root_t m_Config; /* Configuration from file */
177 topmenu_player_t *m_clients; /* Client array */
178 CVector<unsigned int> m_SortedCats; /* Sorted categories */
179 CVector<unsigned int> m_UnsortedCats; /* Un-sorted categories */
180 CVector<topmenu_category_t *> m_Categories; /* Category array */
181 CVector<topmenu_object_t *> m_Objects; /* Object array */
182 NameHashSet<topmenu_object_t *> m_ObjLookup; /* Object lookup trie */
183 unsigned int m_SerialNo; /* Serial number for updating */
184 ITopMenuObjectCallbacks *m_pTitle; /* Title callbacks */
185 int m_max_clients; /* Maximum number of clients */
186 bool m_bCatsNeedResort; /* True if categories need a resort */
187 bool m_bCacheTitles; /* True if the categorie titles should be cached */
190 unsigned int strncopy(char *dest, const char *src, size_t count);
192 #endif //_INCLUDE_SOURCEMOD_TOP_MENU_H_