plugins/include/clientprefs.inc
author David Anderson <dvander@alliedmods.net>
Sat May 24 06:48:35 2008 +0000 (2008-05-24)
changeset 2072 82d3186b9fa4
parent 2048 2454ff4d6afb
child 2207 3a97a56ded62
permissions -rw-r--r--
added quick tool for fetching dlls of mdmps
pred@2009
     1
/**
pred@2009
     2
 * vim: set ts=4 :
pred@2009
     3
 * =============================================================================
pred@2009
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
pred@2009
     5
 * =============================================================================
pred@2009
     6
 *
pred@2009
     7
 * This file is part of the SourceMod/SourcePawn SDK.
pred@2009
     8
 *
pred@2009
     9
 * This program is free software; you can redistribute it and/or modify it under
pred@2009
    10
 * the terms of the GNU General Public License, version 3.0, as published by the
pred@2009
    11
 * Free Software Foundation.
pred@2009
    12
 * 
pred@2009
    13
 * This program is distributed in the hope that it will be useful, but WITHOUT
pred@2009
    14
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
pred@2009
    15
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
pred@2009
    16
 * details.
pred@2009
    17
 *
pred@2009
    18
 * You should have received a copy of the GNU General Public License along with
pred@2009
    19
 * this program.  If not, see <http://www.gnu.org/licenses/>.
pred@2009
    20
 *
pred@2009
    21
 * As a special exception, AlliedModders LLC gives you permission to link the
pred@2009
    22
 * code of this program (as well as its derivative works) to "Half-Life 2," the
pred@2009
    23
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
pred@2009
    24
 * by the Valve Corporation.  You must obey the GNU General Public License in
pred@2009
    25
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
pred@2009
    26
 * this exception to all derivative works.  AlliedModders LLC defines further
pred@2009
    27
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
pred@2009
    28
 * or <http://www.sourcemod.net/license.php>.
pred@2009
    29
 *
pred@2009
    30
 * Version: $Id$
pred@2009
    31
 */
pred@2009
    32
 
pred@2009
    33
#if defined _clientprefs_included
pred@2009
    34
 #endinput
pred@2009
    35
#endif
pred@2009
    36
#define _clientprefs_included
pred@2009
    37
pred@2009
    38
/**
pred@2048
    39
 * Cookie access types for client viewing
pred@2048
    40
 */
pred@2048
    41
enum CookieAccess
pred@2048
    42
{
pred@2048
    43
	CookieAccess_Public,			/**< Visible and Changeable by users */
pred@2048
    44
	CookieAccess_Protected,			/**< Read only to users */
pred@2048
    45
	CookieAccess_Private,			/**< Completely hidden cookie */
pred@2048
    46
};
pred@2048
    47
pred@2048
    48
/**
pred@2048
    49
 * Cookie Prefab menu types
pred@2048
    50
 */
pred@2048
    51
enum CookieMenu
pred@2048
    52
{
pred@2048
    53
	CookieMenu_YesNo,			/**< Yes/No menu with "yes"/"no" results saved into the cookie */
pred@2048
    54
	CookieMenu_YesNo_Int,		/**< Yes/No menu with 1/0 saved into the cookie */
pred@2048
    55
	CookieMenu_OnOff,			/**< On/Off menu with "on"/"off" results saved into the cookie */
pred@2048
    56
	CookieMenu_OnOff_Int,		/**< On/Off menu with 1/0 saved into the cookie */
pred@2048
    57
};
pred@2048
    58
pred@2048
    59
enum CookieMenuAction
pred@2048
    60
{
pred@2048
    61
	/**
pred@2048
    62
	 * An option is being drawn for a menu.
pred@2048
    63
	 *
pred@2048
    64
	 * INPUT : Client index and data if available.
pred@2048
    65
	 * OUTPUT: Buffer for rendering, maxlength of buffer.
pred@2048
    66
	 */
pred@2048
    67
	CookieMenuAction_DisplayOption = 0,
pred@2048
    68
	
pred@2048
    69
	/**
pred@2048
    70
	 * A menu option has been selected.
pred@2048
    71
	 *
pred@2048
    72
	 * INPUT : Client index and any data if available.
pred@2048
    73
	 */
pred@2048
    74
	CookieMenuAction_SelectOption = 1,
pred@2048
    75
};
pred@2048
    76
pred@2048
    77
/**
pred@2009
    78
 * Creates a new Client preference cookie.
pred@2009
    79
 *
pred@2009
    80
 * @param name			Name of the new preference cookie.
pred@2009
    81
 * @param description	Optional description of the preference cookie.
pred@2048
    82
 * @param access		What CookieAccess level to assign to this cookie.
pred@2009
    83
 * @return				A handle to the newly created cookie. If the cookie already exists, a handle to it will still be returned.
pred@2009
    84
 * @error				Cookie name is blank.
pred@2009
    85
 */
pred@2048
    86
native Handle:RegClientCookie(const String:name[], const String:description[], CookieAccess:access);
pred@2009
    87
pred@2009
    88
/**
pred@2009
    89
 * Searches for a Client preference cookie.
pred@2009
    90
 *
pred@2009
    91
 * @param name			Name of cookie to find.
pred@2009
    92
 * @return				A handle to the cookie if it is found. INVALID_HANDLE otherwise.
pred@2009
    93
 */
pred@2048
    94
native Handle:FindClientCookie(const String:name[]);
pred@2009
    95
pred@2009
    96
/**
pred@2009
    97
 * Set the value of a Client preference cookie.
pred@2009
    98
 *
pred@2009
    99
 * @param client		Client index.
pred@2009
   100
 * @param cookie		Client preference cookie handle.
pred@2009
   101
 * @param value			String value to set.
pred@2009
   102
 * @noreturn			
pred@2009
   103
 * @error				Invalid cookie handle or invalid client index.
pred@2009
   104
 */
pred@2048
   105
native SetClientCookie(client, Handle:cookie, const String:value[]);
pred@2009
   106
pred@2009
   107
/**
pred@2009
   108
 * Retrieve the value of a Client preference cookie.
pred@2009
   109
 *
pred@2009
   110
 * @param client		Client index.
pred@2009
   111
 * @param cookie		Client preference cookie handle.
pred@2009
   112
 * @param buffer		Copyback buffer for value.
pred@2009
   113
 * @param maxlen		Maximum length of the buffer.
pred@2048
   114
 * @noreturn
pred@2009
   115
 * @error				Invalid cookie handle or invalid client index.
pred@2009
   116
 */
pred@2048
   117
native GetClientCookie(client, Handle:cookie, String:buffer[], maxlen);
pred@2009
   118
pred@2009
   119
/**
pred@2009
   120
 * Checks if a clients cookies have been loaded from the database.
pred@2009
   121
 *
pred@2009
   122
 * @param client		Client index.
pred@2009
   123
 * @return 				True if loaded, false otherwise.
pred@2009
   124
 * @error				Invalid client index.
pred@2009
   125
 */
pred@2009
   126
native bool:AreClientCookiesCached(client);
pred@2009
   127
pred@2009
   128
/**
pred@2009
   129
 * Called once a client's saved cookies have been loaded from the database.
pred@2009
   130
 *
pred@2009
   131
 * @param client		Client index.
pred@2009
   132
 */
pred@2048
   133
forward OnClientCookiesCached(client);
pred@2048
   134
pred@2048
   135
/**
pred@2048
   136
 * Cookie Menu Callback prototype
pred@2048
   137
 *
pred@2048
   138
 * @param client		Client index.
pred@2048
   139
 * @param action		CookeMenuAction being performed.
pred@2048
   140
 * @param data			Info data passed.
pred@2048
   141
 * @param buffer		Outbut buffer.
pred@2048
   142
 * @param maxlen		Max length of the output buffer.			
pred@2048
   143
 */
pred@2048
   144
functag CookieMenuHandler public(client, CookieMenuAction:action, any:info, String:buffer[], maxlen);
pred@2048
   145
pred@2048
   146
/**
pred@2048
   147
 * Add a new prefab item to the client cookie settings menu.
pred@2048
   148
 *
pred@2048
   149
 * Note: This handles everything automatically and does not require a callback
pred@2048
   150
 *
pred@2048
   151
 * @param cookie		Client preference cookie handle.
pred@2048
   152
 * @param type			A CookieMenu prefab menu type.
pred@2048
   153
 * @param display		Text to show on the menu.
pred@2048
   154
 * @param handler		Optional handler callback for translations and output on selection
pred@2048
   155
 * @param info			Info data to pass to the callback.
pred@2048
   156
 * @noreturn
pred@2048
   157
 * @error				Invalid cookie handle.
pred@2048
   158
 */
pred@2048
   159
native SetCookiePrefabMenu(Handle:cookie, CookieMenu:type, const String:display[], CookieMenuHandler:handler=CookieMenuHandler:-1, info=0);
pred@2048
   160
pred@2048
   161
/**
pred@2048
   162
 * Adds a new item to the client cookie settings menu.
pred@2048
   163
 *
pred@2048
   164
 * Note: This only adds the top level menu item. You need to handle any submenus from the callback.
pred@2048
   165
 *
pred@2048
   166
 * @param handler		A MenuHandler callback function.
pred@2048
   167
 * @param info			Data to pass to the callback.
pred@2048
   168
 * @param display		Text to show on the menu.
pred@2048
   169
 * @noreturn
pred@2048
   170
 * @error				Invalid cookie handle.
pred@2048
   171
 */
pred@2048
   172
native SetCookieMenuItem(CookieMenuHandler:handler, any:info, const String:display[]);
pred@2009
   173
pred@2048
   174
/**
pred@2048
   175
 * Displays the settings menu to a client.
pred@2048
   176
 *
pred@2048
   177
 * @param client		Client index.
pred@2048
   178
 * @noreturn
pred@2048
   179
 */
pred@2048
   180
native ShowCookieMenu(client);
pred@2048
   181
pred@2048
   182
/**
pred@2048
   183
 * Gets a cookie iterator.  Must be freed with CloseHandle().
pred@2048
   184
 *
pred@2048
   185
 * @return				A new cookie iterator.
pred@2048
   186
 */
pred@2048
   187
native Handle:GetCookieIterator();
pred@2048
   188
pred@2048
   189
/**
pred@2048
   190
 * Reads a cookie iterator, then advances to the next cookie if any.
pred@2048
   191
 *
pred@2048
   192
 * @param iter			Cookie iterator Handle.
pred@2048
   193
 * @param name			Name buffer.
pred@2048
   194
 * @param nameLen		Name buffer size.
pred@2048
   195
 * @param access		Access level of the cookie.
pred@2048
   196
 * @param desc			Cookie description buffer.
pred@2048
   197
 * @param descLen		Cookie description buffer size.
pred@2048
   198
 * @param 
pred@2048
   199
 * @return				True on success, false if there are no more commands.
pred@2048
   200
 */
pred@2048
   201
native bool:ReadCookieIterator(Handle:iter, 
pred@2048
   202
								String:name[], 
pred@2048
   203
								nameLen,
pred@2048
   204
								&CookieAccess:access, 
pred@2048
   205
								String:desc[]="", 
pred@2048
   206
								descLen=0);
pred@2048
   207
								
pred@2048
   208
/**
pred@2048
   209
 * Returns the access level of a cookie
pred@2048
   210
 *
pred@2048
   211
 * @param cookie		Client preference cookie handle.
pred@2048
   212
 * @return				CookieAccess access level.
pred@2048
   213
 * @error				Invalid cookie handle.	
pred@2048
   214
 */
pred@2048
   215
native CookieAccess:GetCookieAccess(Handle:cookie);
pred@2009
   216
pred@2009
   217
/**
pred@2009
   218
 * Do not edit below this line!
pred@2009
   219
 */
pred@2009
   220
public Extension:__ext_clientprefs = 
pred@2009
   221
{
pred@2009
   222
	name = "Client Preferences",
pred@2009
   223
	file = "clientprefs.ext",
pred@2009
   224
	autoload = 1,
pred@2009
   225
#if defined REQUIRE_EXTENSIONS
pred@2009
   226
	required = 1,
pred@2009
   227
#else
pred@2009
   228
	required = 0,
pred@2009
   229
#endif
pred@2009
   230
};