1.1 --- a/plugins/include/clientprefs.inc Mon May 12 02:05:57 2008 +0000
1.2 +++ b/plugins/include/clientprefs.inc Mon May 12 08:06:47 2008 +0000
1.3 @@ -36,14 +36,54 @@
1.4 #define _clientprefs_included
1.5
1.6 /**
1.7 + * Cookie access types for client viewing
1.8 + */
1.9 +enum CookieAccess
1.10 +{
1.11 + CookieAccess_Public, /**< Visible and Changeable by users */
1.12 + CookieAccess_Protected, /**< Read only to users */
1.13 + CookieAccess_Private, /**< Completely hidden cookie */
1.14 +};
1.15 +
1.16 +/**
1.17 + * Cookie Prefab menu types
1.18 + */
1.19 +enum CookieMenu
1.20 +{
1.21 + CookieMenu_YesNo, /**< Yes/No menu with "yes"/"no" results saved into the cookie */
1.22 + CookieMenu_YesNo_Int, /**< Yes/No menu with 1/0 saved into the cookie */
1.23 + CookieMenu_OnOff, /**< On/Off menu with "on"/"off" results saved into the cookie */
1.24 + CookieMenu_OnOff_Int, /**< On/Off menu with 1/0 saved into the cookie */
1.25 +};
1.26 +
1.27 +enum CookieMenuAction
1.28 +{
1.29 + /**
1.30 + * An option is being drawn for a menu.
1.31 + *
1.32 + * INPUT : Client index and data if available.
1.33 + * OUTPUT: Buffer for rendering, maxlength of buffer.
1.34 + */
1.35 + CookieMenuAction_DisplayOption = 0,
1.36 +
1.37 + /**
1.38 + * A menu option has been selected.
1.39 + *
1.40 + * INPUT : Client index and any data if available.
1.41 + */
1.42 + CookieMenuAction_SelectOption = 1,
1.43 +};
1.44 +
1.45 +/**
1.46 * Creates a new Client preference cookie.
1.47 *
1.48 * @param name Name of the new preference cookie.
1.49 * @param description Optional description of the preference cookie.
1.50 + * @param access What CookieAccess level to assign to this cookie.
1.51 * @return A handle to the newly created cookie. If the cookie already exists, a handle to it will still be returned.
1.52 * @error Cookie name is blank.
1.53 */
1.54 -native Handle:RegClientPrefCookie(const String:name[], const String:description[]);
1.55 +native Handle:RegClientCookie(const String:name[], const String:description[], CookieAccess:access);
1.56
1.57 /**
1.58 * Searches for a Client preference cookie.
1.59 @@ -51,7 +91,7 @@
1.60 * @param name Name of cookie to find.
1.61 * @return A handle to the cookie if it is found. INVALID_HANDLE otherwise.
1.62 */
1.63 -native Handle:FindClientPrefCookie(const String:name[]);
1.64 +native Handle:FindClientCookie(const String:name[]);
1.65
1.66 /**
1.67 * Set the value of a Client preference cookie.
1.68 @@ -62,7 +102,7 @@
1.69 * @noreturn
1.70 * @error Invalid cookie handle or invalid client index.
1.71 */
1.72 -native SetClientPrefCookie(client, Handle:cookie, const String:value[]);
1.73 +native SetClientCookie(client, Handle:cookie, const String:value[]);
1.74
1.75 /**
1.76 * Retrieve the value of a Client preference cookie.
1.77 @@ -71,9 +111,10 @@
1.78 * @param cookie Client preference cookie handle.
1.79 * @param buffer Copyback buffer for value.
1.80 * @param maxlen Maximum length of the buffer.
1.81 + * @noreturn
1.82 * @error Invalid cookie handle or invalid client index.
1.83 */
1.84 -native GetClientPrefCookie(client, Handle:cookie, String:buffer[], maxlen);
1.85 +native GetClientCookie(client, Handle:cookie, String:buffer[], maxlen);
1.86
1.87 /**
1.88 * Checks if a clients cookies have been loaded from the database.
1.89 @@ -89,8 +130,89 @@
1.90 *
1.91 * @param client Client index.
1.92 */
1.93 -forward OnClientCookiesLoaded(client);
1.94 +forward OnClientCookiesCached(client);
1.95 +
1.96 +/**
1.97 + * Cookie Menu Callback prototype
1.98 + *
1.99 + * @param client Client index.
1.100 + * @param action CookeMenuAction being performed.
1.101 + * @param data Info data passed.
1.102 + * @param buffer Outbut buffer.
1.103 + * @param maxlen Max length of the output buffer.
1.104 + */
1.105 +functag CookieMenuHandler public(client, CookieMenuAction:action, any:info, String:buffer[], maxlen);
1.106 +
1.107 +/**
1.108 + * Add a new prefab item to the client cookie settings menu.
1.109 + *
1.110 + * Note: This handles everything automatically and does not require a callback
1.111 + *
1.112 + * @param cookie Client preference cookie handle.
1.113 + * @param type A CookieMenu prefab menu type.
1.114 + * @param display Text to show on the menu.
1.115 + * @param handler Optional handler callback for translations and output on selection
1.116 + * @param info Info data to pass to the callback.
1.117 + * @noreturn
1.118 + * @error Invalid cookie handle.
1.119 + */
1.120 +native SetCookiePrefabMenu(Handle:cookie, CookieMenu:type, const String:display[], CookieMenuHandler:handler=CookieMenuHandler:-1, info=0);
1.121 +
1.122 +/**
1.123 + * Adds a new item to the client cookie settings menu.
1.124 + *
1.125 + * Note: This only adds the top level menu item. You need to handle any submenus from the callback.
1.126 + *
1.127 + * @param handler A MenuHandler callback function.
1.128 + * @param info Data to pass to the callback.
1.129 + * @param display Text to show on the menu.
1.130 + * @noreturn
1.131 + * @error Invalid cookie handle.
1.132 + */
1.133 +native SetCookieMenuItem(CookieMenuHandler:handler, any:info, const String:display[]);
1.134
1.135 +/**
1.136 + * Displays the settings menu to a client.
1.137 + *
1.138 + * @param client Client index.
1.139 + * @noreturn
1.140 + */
1.141 +native ShowCookieMenu(client);
1.142 +
1.143 +/**
1.144 + * Gets a cookie iterator. Must be freed with CloseHandle().
1.145 + *
1.146 + * @return A new cookie iterator.
1.147 + */
1.148 +native Handle:GetCookieIterator();
1.149 +
1.150 +/**
1.151 + * Reads a cookie iterator, then advances to the next cookie if any.
1.152 + *
1.153 + * @param iter Cookie iterator Handle.
1.154 + * @param name Name buffer.
1.155 + * @param nameLen Name buffer size.
1.156 + * @param access Access level of the cookie.
1.157 + * @param desc Cookie description buffer.
1.158 + * @param descLen Cookie description buffer size.
1.159 + * @param
1.160 + * @return True on success, false if there are no more commands.
1.161 + */
1.162 +native bool:ReadCookieIterator(Handle:iter,
1.163 + String:name[],
1.164 + nameLen,
1.165 + &CookieAccess:access,
1.166 + String:desc[]="",
1.167 + descLen=0);
1.168 +
1.169 +/**
1.170 + * Returns the access level of a cookie
1.171 + *
1.172 + * @param cookie Client preference cookie handle.
1.173 + * @return CookieAccess access level.
1.174 + * @error Invalid cookie handle.
1.175 + */
1.176 +native CookieAccess:GetCookieAccess(Handle:cookie);
1.177
1.178 /**
1.179 * Do not edit below this line!