isteamfriends.cs (32830B)
1 // This file is provided under The MIT License as part of Steamworks.NET. 2 // Copyright (c) 2013-2019 Riley Labrecque 3 // Please see the included LICENSE.txt for additional information. 4 5 // This file is automatically generated. 6 // Changes to this file will be reverted when you update Steamworks.NET 7 8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH 9 #define DISABLESTEAMWORKS 10 #endif 11 12 #if !DISABLESTEAMWORKS 13 14 using System.Runtime.InteropServices; 15 using IntPtr = System.IntPtr; 16 17 namespace Steamworks { 18 public static class SteamFriends { 19 /// <summary> 20 /// <para> returns the local players name - guaranteed to not be NULL.</para> 21 /// <para> this is the same name as on the users community profile page</para> 22 /// <para> this is stored in UTF-8 format</para> 23 /// <para> like all the other interface functions that return a char *, it's important that this pointer is not saved</para> 24 /// <para> off; it will eventually be free'd or re-allocated</para> 25 /// </summary> 26 public static string GetPersonaName() { 27 InteropHelp.TestIfAvailableClient(); 28 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetPersonaName(CSteamAPIContext.GetSteamFriends())); 29 } 30 31 /// <summary> 32 /// <para> Sets the player name, stores it on the server and publishes the changes to all friends who are online.</para> 33 /// <para> Changes take place locally immediately, and a PersonaStateChange_t is posted, presuming success.</para> 34 /// <para> The final results are available through the return value SteamAPICall_t, using SetPersonaNameResponse_t.</para> 35 /// <para> If the name change fails to happen on the server, then an additional global PersonaStateChange_t will be posted</para> 36 /// <para> to change the name back, in addition to the SetPersonaNameResponse_t callback.</para> 37 /// </summary> 38 public static SteamAPICall_t SetPersonaName(string pchPersonaName) { 39 InteropHelp.TestIfAvailableClient(); 40 using (var pchPersonaName2 = new InteropHelp.UTF8StringHandle(pchPersonaName)) { 41 return (SteamAPICall_t)NativeMethods.ISteamFriends_SetPersonaName(CSteamAPIContext.GetSteamFriends(), pchPersonaName2); 42 } 43 } 44 45 /// <summary> 46 /// <para> gets the status of the current user</para> 47 /// </summary> 48 public static EPersonaState GetPersonaState() { 49 InteropHelp.TestIfAvailableClient(); 50 return NativeMethods.ISteamFriends_GetPersonaState(CSteamAPIContext.GetSteamFriends()); 51 } 52 53 /// <summary> 54 /// <para> friend iteration</para> 55 /// <para> takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria</para> 56 /// <para> then GetFriendByIndex() can then be used to return the id's of each of those users</para> 57 /// </summary> 58 public static int GetFriendCount(EFriendFlags iFriendFlags) { 59 InteropHelp.TestIfAvailableClient(); 60 return NativeMethods.ISteamFriends_GetFriendCount(CSteamAPIContext.GetSteamFriends(), iFriendFlags); 61 } 62 63 /// <summary> 64 /// <para> returns the steamID of a user</para> 65 /// <para> iFriend is a index of range [0, GetFriendCount())</para> 66 /// <para> iFriendsFlags must be the same value as used in GetFriendCount()</para> 67 /// <para> the returned CSteamID can then be used by all the functions below to access details about the user</para> 68 /// </summary> 69 public static CSteamID GetFriendByIndex(int iFriend, EFriendFlags iFriendFlags) { 70 InteropHelp.TestIfAvailableClient(); 71 return (CSteamID)NativeMethods.ISteamFriends_GetFriendByIndex(CSteamAPIContext.GetSteamFriends(), iFriend, iFriendFlags); 72 } 73 74 /// <summary> 75 /// <para> returns a relationship to a user</para> 76 /// </summary> 77 public static EFriendRelationship GetFriendRelationship(CSteamID steamIDFriend) { 78 InteropHelp.TestIfAvailableClient(); 79 return NativeMethods.ISteamFriends_GetFriendRelationship(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 80 } 81 82 /// <summary> 83 /// <para> returns the current status of the specified user</para> 84 /// <para> this will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user</para> 85 /// </summary> 86 public static EPersonaState GetFriendPersonaState(CSteamID steamIDFriend) { 87 InteropHelp.TestIfAvailableClient(); 88 return NativeMethods.ISteamFriends_GetFriendPersonaState(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 89 } 90 91 /// <summary> 92 /// <para> returns the name another user - guaranteed to not be NULL.</para> 93 /// <para> same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user</para> 94 /// <para> note that on first joining a lobby, chat room or game server the local user will not known the name of the other users automatically; that information will arrive asyncronously</para> 95 /// </summary> 96 public static string GetFriendPersonaName(CSteamID steamIDFriend) { 97 InteropHelp.TestIfAvailableClient(); 98 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendPersonaName(CSteamAPIContext.GetSteamFriends(), steamIDFriend)); 99 } 100 101 /// <summary> 102 /// <para> returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details</para> 103 /// </summary> 104 public static bool GetFriendGamePlayed(CSteamID steamIDFriend, out FriendGameInfo_t pFriendGameInfo) { 105 InteropHelp.TestIfAvailableClient(); 106 return NativeMethods.ISteamFriends_GetFriendGamePlayed(CSteamAPIContext.GetSteamFriends(), steamIDFriend, out pFriendGameInfo); 107 } 108 109 /// <summary> 110 /// <para> accesses old friends names - returns an empty string when their are no more items in the history</para> 111 /// </summary> 112 public static string GetFriendPersonaNameHistory(CSteamID steamIDFriend, int iPersonaName) { 113 InteropHelp.TestIfAvailableClient(); 114 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendPersonaNameHistory(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iPersonaName)); 115 } 116 117 /// <summary> 118 /// <para> friends steam level</para> 119 /// </summary> 120 public static int GetFriendSteamLevel(CSteamID steamIDFriend) { 121 InteropHelp.TestIfAvailableClient(); 122 return NativeMethods.ISteamFriends_GetFriendSteamLevel(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 123 } 124 125 /// <summary> 126 /// <para> Returns nickname the current user has set for the specified player. Returns NULL if the no nickname has been set for that player.</para> 127 /// <para> DEPRECATED: GetPersonaName follows the Steam nickname preferences, so apps shouldn't need to care about nicknames explicitly.</para> 128 /// </summary> 129 public static string GetPlayerNickname(CSteamID steamIDPlayer) { 130 InteropHelp.TestIfAvailableClient(); 131 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetPlayerNickname(CSteamAPIContext.GetSteamFriends(), steamIDPlayer)); 132 } 133 134 /// <summary> 135 /// <para> friend grouping (tag) apis</para> 136 /// <para> returns the number of friends groups</para> 137 /// </summary> 138 public static int GetFriendsGroupCount() { 139 InteropHelp.TestIfAvailableClient(); 140 return NativeMethods.ISteamFriends_GetFriendsGroupCount(CSteamAPIContext.GetSteamFriends()); 141 } 142 143 /// <summary> 144 /// <para> returns the friends group ID for the given index (invalid indices return k_FriendsGroupID_Invalid)</para> 145 /// </summary> 146 public static FriendsGroupID_t GetFriendsGroupIDByIndex(int iFG) { 147 InteropHelp.TestIfAvailableClient(); 148 return (FriendsGroupID_t)NativeMethods.ISteamFriends_GetFriendsGroupIDByIndex(CSteamAPIContext.GetSteamFriends(), iFG); 149 } 150 151 /// <summary> 152 /// <para> returns the name for the given friends group (NULL in the case of invalid friends group IDs)</para> 153 /// </summary> 154 public static string GetFriendsGroupName(FriendsGroupID_t friendsGroupID) { 155 InteropHelp.TestIfAvailableClient(); 156 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendsGroupName(CSteamAPIContext.GetSteamFriends(), friendsGroupID)); 157 } 158 159 /// <summary> 160 /// <para> returns the number of members in a given friends group</para> 161 /// </summary> 162 public static int GetFriendsGroupMembersCount(FriendsGroupID_t friendsGroupID) { 163 InteropHelp.TestIfAvailableClient(); 164 return NativeMethods.ISteamFriends_GetFriendsGroupMembersCount(CSteamAPIContext.GetSteamFriends(), friendsGroupID); 165 } 166 167 /// <summary> 168 /// <para> gets up to nMembersCount members of the given friends group, if fewer exist than requested those positions' SteamIDs will be invalid</para> 169 /// </summary> 170 public static void GetFriendsGroupMembersList(FriendsGroupID_t friendsGroupID, CSteamID[] pOutSteamIDMembers, int nMembersCount) { 171 InteropHelp.TestIfAvailableClient(); 172 NativeMethods.ISteamFriends_GetFriendsGroupMembersList(CSteamAPIContext.GetSteamFriends(), friendsGroupID, pOutSteamIDMembers, nMembersCount); 173 } 174 175 /// <summary> 176 /// <para> returns true if the specified user meets any of the criteria specified in iFriendFlags</para> 177 /// <para> iFriendFlags can be the union (binary or, |) of one or more k_EFriendFlags values</para> 178 /// </summary> 179 public static bool HasFriend(CSteamID steamIDFriend, EFriendFlags iFriendFlags) { 180 InteropHelp.TestIfAvailableClient(); 181 return NativeMethods.ISteamFriends_HasFriend(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iFriendFlags); 182 } 183 184 /// <summary> 185 /// <para> clan (group) iteration and access functions</para> 186 /// </summary> 187 public static int GetClanCount() { 188 InteropHelp.TestIfAvailableClient(); 189 return NativeMethods.ISteamFriends_GetClanCount(CSteamAPIContext.GetSteamFriends()); 190 } 191 192 public static CSteamID GetClanByIndex(int iClan) { 193 InteropHelp.TestIfAvailableClient(); 194 return (CSteamID)NativeMethods.ISteamFriends_GetClanByIndex(CSteamAPIContext.GetSteamFriends(), iClan); 195 } 196 197 public static string GetClanName(CSteamID steamIDClan) { 198 InteropHelp.TestIfAvailableClient(); 199 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetClanName(CSteamAPIContext.GetSteamFriends(), steamIDClan)); 200 } 201 202 public static string GetClanTag(CSteamID steamIDClan) { 203 InteropHelp.TestIfAvailableClient(); 204 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetClanTag(CSteamAPIContext.GetSteamFriends(), steamIDClan)); 205 } 206 207 /// <summary> 208 /// <para> returns the most recent information we have about what's happening in a clan</para> 209 /// </summary> 210 public static bool GetClanActivityCounts(CSteamID steamIDClan, out int pnOnline, out int pnInGame, out int pnChatting) { 211 InteropHelp.TestIfAvailableClient(); 212 return NativeMethods.ISteamFriends_GetClanActivityCounts(CSteamAPIContext.GetSteamFriends(), steamIDClan, out pnOnline, out pnInGame, out pnChatting); 213 } 214 215 /// <summary> 216 /// <para> for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest</para> 217 /// </summary> 218 public static SteamAPICall_t DownloadClanActivityCounts(CSteamID[] psteamIDClans, int cClansToRequest) { 219 InteropHelp.TestIfAvailableClient(); 220 return (SteamAPICall_t)NativeMethods.ISteamFriends_DownloadClanActivityCounts(CSteamAPIContext.GetSteamFriends(), psteamIDClans, cClansToRequest); 221 } 222 223 /// <summary> 224 /// <para> iterators for getting users in a chat room, lobby, game server or clan</para> 225 /// <para> note that large clans that cannot be iterated by the local user</para> 226 /// <para> note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby</para> 227 /// <para> steamIDSource can be the steamID of a group, game server, lobby or chat room</para> 228 /// </summary> 229 public static int GetFriendCountFromSource(CSteamID steamIDSource) { 230 InteropHelp.TestIfAvailableClient(); 231 return NativeMethods.ISteamFriends_GetFriendCountFromSource(CSteamAPIContext.GetSteamFriends(), steamIDSource); 232 } 233 234 public static CSteamID GetFriendFromSourceByIndex(CSteamID steamIDSource, int iFriend) { 235 InteropHelp.TestIfAvailableClient(); 236 return (CSteamID)NativeMethods.ISteamFriends_GetFriendFromSourceByIndex(CSteamAPIContext.GetSteamFriends(), steamIDSource, iFriend); 237 } 238 239 /// <summary> 240 /// <para> returns true if the local user can see that steamIDUser is a member or in steamIDSource</para> 241 /// </summary> 242 public static bool IsUserInSource(CSteamID steamIDUser, CSteamID steamIDSource) { 243 InteropHelp.TestIfAvailableClient(); 244 return NativeMethods.ISteamFriends_IsUserInSource(CSteamAPIContext.GetSteamFriends(), steamIDUser, steamIDSource); 245 } 246 247 /// <summary> 248 /// <para> User is in a game pressing the talk button (will suppress the microphone for all voice comms from the Steam friends UI)</para> 249 /// </summary> 250 public static void SetInGameVoiceSpeaking(CSteamID steamIDUser, bool bSpeaking) { 251 InteropHelp.TestIfAvailableClient(); 252 NativeMethods.ISteamFriends_SetInGameVoiceSpeaking(CSteamAPIContext.GetSteamFriends(), steamIDUser, bSpeaking); 253 } 254 255 /// <summary> 256 /// <para> activates the game overlay, with an optional dialog to open</para> 257 /// <para> valid options include "Friends", "Community", "Players", "Settings", "OfficialGameGroup", "Stats", "Achievements",</para> 258 /// <para> "chatroomgroup/nnnn"</para> 259 /// </summary> 260 public static void ActivateGameOverlay(string pchDialog) { 261 InteropHelp.TestIfAvailableClient(); 262 using (var pchDialog2 = new InteropHelp.UTF8StringHandle(pchDialog)) { 263 NativeMethods.ISteamFriends_ActivateGameOverlay(CSteamAPIContext.GetSteamFriends(), pchDialog2); 264 } 265 } 266 267 /// <summary> 268 /// <para> activates game overlay to a specific place</para> 269 /// <para> valid options are</para> 270 /// <para> "steamid" - opens the overlay web browser to the specified user or groups profile</para> 271 /// <para> "chat" - opens a chat window to the specified user, or joins the group chat</para> 272 /// <para> "jointrade" - opens a window to a Steam Trading session that was started with the ISteamEconomy/StartTrade Web API</para> 273 /// <para> "stats" - opens the overlay web browser to the specified user's stats</para> 274 /// <para> "achievements" - opens the overlay web browser to the specified user's achievements</para> 275 /// <para> "friendadd" - opens the overlay in minimal mode prompting the user to add the target user as a friend</para> 276 /// <para> "friendremove" - opens the overlay in minimal mode prompting the user to remove the target friend</para> 277 /// <para> "friendrequestaccept" - opens the overlay in minimal mode prompting the user to accept an incoming friend invite</para> 278 /// <para> "friendrequestignore" - opens the overlay in minimal mode prompting the user to ignore an incoming friend invite</para> 279 /// </summary> 280 public static void ActivateGameOverlayToUser(string pchDialog, CSteamID steamID) { 281 InteropHelp.TestIfAvailableClient(); 282 using (var pchDialog2 = new InteropHelp.UTF8StringHandle(pchDialog)) { 283 NativeMethods.ISteamFriends_ActivateGameOverlayToUser(CSteamAPIContext.GetSteamFriends(), pchDialog2, steamID); 284 } 285 } 286 287 /// <summary> 288 /// <para> activates game overlay web browser directly to the specified URL</para> 289 /// <para> full address with protocol type is required, e.g. http://www.steamgames.com/</para> 290 /// </summary> 291 public static void ActivateGameOverlayToWebPage(string pchURL, EActivateGameOverlayToWebPageMode eMode = EActivateGameOverlayToWebPageMode.k_EActivateGameOverlayToWebPageMode_Default) { 292 InteropHelp.TestIfAvailableClient(); 293 using (var pchURL2 = new InteropHelp.UTF8StringHandle(pchURL)) { 294 NativeMethods.ISteamFriends_ActivateGameOverlayToWebPage(CSteamAPIContext.GetSteamFriends(), pchURL2, eMode); 295 } 296 } 297 298 /// <summary> 299 /// <para> activates game overlay to store page for app</para> 300 /// </summary> 301 public static void ActivateGameOverlayToStore(AppId_t nAppID, EOverlayToStoreFlag eFlag) { 302 InteropHelp.TestIfAvailableClient(); 303 NativeMethods.ISteamFriends_ActivateGameOverlayToStore(CSteamAPIContext.GetSteamFriends(), nAppID, eFlag); 304 } 305 306 /// <summary> 307 /// <para> Mark a target user as 'played with'. This is a client-side only feature that requires that the calling user is</para> 308 /// <para> in game</para> 309 /// </summary> 310 public static void SetPlayedWith(CSteamID steamIDUserPlayedWith) { 311 InteropHelp.TestIfAvailableClient(); 312 NativeMethods.ISteamFriends_SetPlayedWith(CSteamAPIContext.GetSteamFriends(), steamIDUserPlayedWith); 313 } 314 315 /// <summary> 316 /// <para> activates game overlay to open the invite dialog. Invitations will be sent for the provided lobby.</para> 317 /// </summary> 318 public static void ActivateGameOverlayInviteDialog(CSteamID steamIDLobby) { 319 InteropHelp.TestIfAvailableClient(); 320 NativeMethods.ISteamFriends_ActivateGameOverlayInviteDialog(CSteamAPIContext.GetSteamFriends(), steamIDLobby); 321 } 322 323 /// <summary> 324 /// <para> gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set</para> 325 /// </summary> 326 public static int GetSmallFriendAvatar(CSteamID steamIDFriend) { 327 InteropHelp.TestIfAvailableClient(); 328 return NativeMethods.ISteamFriends_GetSmallFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 329 } 330 331 /// <summary> 332 /// <para> gets the medium (64x64) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set</para> 333 /// </summary> 334 public static int GetMediumFriendAvatar(CSteamID steamIDFriend) { 335 InteropHelp.TestIfAvailableClient(); 336 return NativeMethods.ISteamFriends_GetMediumFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 337 } 338 339 /// <summary> 340 /// <para> gets the large (184x184) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set</para> 341 /// <para> returns -1 if this image has yet to be loaded, in this case wait for a AvatarImageLoaded_t callback and then call this again</para> 342 /// </summary> 343 public static int GetLargeFriendAvatar(CSteamID steamIDFriend) { 344 InteropHelp.TestIfAvailableClient(); 345 return NativeMethods.ISteamFriends_GetLargeFriendAvatar(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 346 } 347 348 /// <summary> 349 /// <para> requests information about a user - persona name & avatar</para> 350 /// <para> if bRequireNameOnly is set, then the avatar of a user isn't downloaded</para> 351 /// <para> - it's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them</para> 352 /// <para> if returns true, it means that data is being requested, and a PersonaStateChanged_t callback will be posted when it's retrieved</para> 353 /// <para> if returns false, it means that we already have all the details about that user, and functions can be called immediately</para> 354 /// </summary> 355 public static bool RequestUserInformation(CSteamID steamIDUser, bool bRequireNameOnly) { 356 InteropHelp.TestIfAvailableClient(); 357 return NativeMethods.ISteamFriends_RequestUserInformation(CSteamAPIContext.GetSteamFriends(), steamIDUser, bRequireNameOnly); 358 } 359 360 /// <summary> 361 /// <para> requests information about a clan officer list</para> 362 /// <para> when complete, data is returned in ClanOfficerListResponse_t call result</para> 363 /// <para> this makes available the calls below</para> 364 /// <para> you can only ask about clans that a user is a member of</para> 365 /// <para> note that this won't download avatars automatically; if you get an officer,</para> 366 /// <para> and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar</para> 367 /// </summary> 368 public static SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) { 369 InteropHelp.TestIfAvailableClient(); 370 return (SteamAPICall_t)NativeMethods.ISteamFriends_RequestClanOfficerList(CSteamAPIContext.GetSteamFriends(), steamIDClan); 371 } 372 373 /// <summary> 374 /// <para> iteration of clan officers - can only be done when a RequestClanOfficerList() call has completed</para> 375 /// <para> returns the steamID of the clan owner</para> 376 /// </summary> 377 public static CSteamID GetClanOwner(CSteamID steamIDClan) { 378 InteropHelp.TestIfAvailableClient(); 379 return (CSteamID)NativeMethods.ISteamFriends_GetClanOwner(CSteamAPIContext.GetSteamFriends(), steamIDClan); 380 } 381 382 /// <summary> 383 /// <para> returns the number of officers in a clan (including the owner)</para> 384 /// </summary> 385 public static int GetClanOfficerCount(CSteamID steamIDClan) { 386 InteropHelp.TestIfAvailableClient(); 387 return NativeMethods.ISteamFriends_GetClanOfficerCount(CSteamAPIContext.GetSteamFriends(), steamIDClan); 388 } 389 390 /// <summary> 391 /// <para> returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount)</para> 392 /// </summary> 393 public static CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer) { 394 InteropHelp.TestIfAvailableClient(); 395 return (CSteamID)NativeMethods.ISteamFriends_GetClanOfficerByIndex(CSteamAPIContext.GetSteamFriends(), steamIDClan, iOfficer); 396 } 397 398 /// <summary> 399 /// <para> if current user is chat restricted, he can't send or receive any text/voice chat messages.</para> 400 /// <para> the user can't see custom avatars. But the user can be online and send/recv game invites.</para> 401 /// <para> a chat restricted user can't add friends or join any groups.</para> 402 /// </summary> 403 public static uint GetUserRestrictions() { 404 InteropHelp.TestIfAvailableClient(); 405 return NativeMethods.ISteamFriends_GetUserRestrictions(CSteamAPIContext.GetSteamFriends()); 406 } 407 408 /// <summary> 409 /// <para> Rich Presence data is automatically shared between friends who are in the same game</para> 410 /// <para> Each user has a set of Key/Value pairs</para> 411 /// <para> Note the following limits: k_cchMaxRichPresenceKeys, k_cchMaxRichPresenceKeyLength, k_cchMaxRichPresenceValueLength</para> 412 /// <para> There are two magic keys:</para> 413 /// <para> "status" - a UTF-8 string that will show up in the 'view game info' dialog in the Steam friends list</para> 414 /// <para> "connect" - a UTF-8 string that contains the command-line for how a friend can connect to a game</para> 415 /// <para> GetFriendRichPresence() returns an empty string "" if no value is set</para> 416 /// <para> SetRichPresence() to a NULL or an empty string deletes the key</para> 417 /// <para> You can iterate the current set of keys for a friend with GetFriendRichPresenceKeyCount()</para> 418 /// <para> and GetFriendRichPresenceKeyByIndex() (typically only used for debugging)</para> 419 /// </summary> 420 public static bool SetRichPresence(string pchKey, string pchValue) { 421 InteropHelp.TestIfAvailableClient(); 422 using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) 423 using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue)) { 424 return NativeMethods.ISteamFriends_SetRichPresence(CSteamAPIContext.GetSteamFriends(), pchKey2, pchValue2); 425 } 426 } 427 428 public static void ClearRichPresence() { 429 InteropHelp.TestIfAvailableClient(); 430 NativeMethods.ISteamFriends_ClearRichPresence(CSteamAPIContext.GetSteamFriends()); 431 } 432 433 public static string GetFriendRichPresence(CSteamID steamIDFriend, string pchKey) { 434 InteropHelp.TestIfAvailableClient(); 435 using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) { 436 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendRichPresence(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchKey2)); 437 } 438 } 439 440 public static int GetFriendRichPresenceKeyCount(CSteamID steamIDFriend) { 441 InteropHelp.TestIfAvailableClient(); 442 return NativeMethods.ISteamFriends_GetFriendRichPresenceKeyCount(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 443 } 444 445 public static string GetFriendRichPresenceKeyByIndex(CSteamID steamIDFriend, int iKey) { 446 InteropHelp.TestIfAvailableClient(); 447 return InteropHelp.PtrToStringUTF8(NativeMethods.ISteamFriends_GetFriendRichPresenceKeyByIndex(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iKey)); 448 } 449 450 /// <summary> 451 /// <para> Requests rich presence for a specific user.</para> 452 /// </summary> 453 public static void RequestFriendRichPresence(CSteamID steamIDFriend) { 454 InteropHelp.TestIfAvailableClient(); 455 NativeMethods.ISteamFriends_RequestFriendRichPresence(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 456 } 457 458 /// <summary> 459 /// <para> Rich invite support.</para> 460 /// <para> If the target accepts the invite, a GameRichPresenceJoinRequested_t callback is posted containing the connect string.</para> 461 /// <para> (Or you can configure yout game so that it is passed on the command line instead. This is a deprecated path; ask us if you really need this.)</para> 462 /// <para> Invites can only be sent to friends.</para> 463 /// </summary> 464 public static bool InviteUserToGame(CSteamID steamIDFriend, string pchConnectString) { 465 InteropHelp.TestIfAvailableClient(); 466 using (var pchConnectString2 = new InteropHelp.UTF8StringHandle(pchConnectString)) { 467 return NativeMethods.ISteamFriends_InviteUserToGame(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchConnectString2); 468 } 469 } 470 471 /// <summary> 472 /// <para> recently-played-with friends iteration</para> 473 /// <para> this iterates the entire list of users recently played with, across games</para> 474 /// <para> GetFriendCoplayTime() returns as a unix time</para> 475 /// </summary> 476 public static int GetCoplayFriendCount() { 477 InteropHelp.TestIfAvailableClient(); 478 return NativeMethods.ISteamFriends_GetCoplayFriendCount(CSteamAPIContext.GetSteamFriends()); 479 } 480 481 public static CSteamID GetCoplayFriend(int iCoplayFriend) { 482 InteropHelp.TestIfAvailableClient(); 483 return (CSteamID)NativeMethods.ISteamFriends_GetCoplayFriend(CSteamAPIContext.GetSteamFriends(), iCoplayFriend); 484 } 485 486 public static int GetFriendCoplayTime(CSteamID steamIDFriend) { 487 InteropHelp.TestIfAvailableClient(); 488 return NativeMethods.ISteamFriends_GetFriendCoplayTime(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 489 } 490 491 public static AppId_t GetFriendCoplayGame(CSteamID steamIDFriend) { 492 InteropHelp.TestIfAvailableClient(); 493 return (AppId_t)NativeMethods.ISteamFriends_GetFriendCoplayGame(CSteamAPIContext.GetSteamFriends(), steamIDFriend); 494 } 495 496 /// <summary> 497 /// <para> chat interface for games</para> 498 /// <para> this allows in-game access to group (clan) chats from in the game</para> 499 /// <para> the behavior is somewhat sophisticated, because the user may or may not be already in the group chat from outside the game or in the overlay</para> 500 /// <para> use ActivateGameOverlayToUser( "chat", steamIDClan ) to open the in-game overlay version of the chat</para> 501 /// </summary> 502 public static SteamAPICall_t JoinClanChatRoom(CSteamID steamIDClan) { 503 InteropHelp.TestIfAvailableClient(); 504 return (SteamAPICall_t)NativeMethods.ISteamFriends_JoinClanChatRoom(CSteamAPIContext.GetSteamFriends(), steamIDClan); 505 } 506 507 public static bool LeaveClanChatRoom(CSteamID steamIDClan) { 508 InteropHelp.TestIfAvailableClient(); 509 return NativeMethods.ISteamFriends_LeaveClanChatRoom(CSteamAPIContext.GetSteamFriends(), steamIDClan); 510 } 511 512 public static int GetClanChatMemberCount(CSteamID steamIDClan) { 513 InteropHelp.TestIfAvailableClient(); 514 return NativeMethods.ISteamFriends_GetClanChatMemberCount(CSteamAPIContext.GetSteamFriends(), steamIDClan); 515 } 516 517 public static CSteamID GetChatMemberByIndex(CSteamID steamIDClan, int iUser) { 518 InteropHelp.TestIfAvailableClient(); 519 return (CSteamID)NativeMethods.ISteamFriends_GetChatMemberByIndex(CSteamAPIContext.GetSteamFriends(), steamIDClan, iUser); 520 } 521 522 public static bool SendClanChatMessage(CSteamID steamIDClanChat, string pchText) { 523 InteropHelp.TestIfAvailableClient(); 524 using (var pchText2 = new InteropHelp.UTF8StringHandle(pchText)) { 525 return NativeMethods.ISteamFriends_SendClanChatMessage(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, pchText2); 526 } 527 } 528 529 public static int GetClanChatMessage(CSteamID steamIDClanChat, int iMessage, out string prgchText, int cchTextMax, out EChatEntryType peChatEntryType, out CSteamID psteamidChatter) { 530 InteropHelp.TestIfAvailableClient(); 531 IntPtr prgchText2 = Marshal.AllocHGlobal(cchTextMax); 532 int ret = NativeMethods.ISteamFriends_GetClanChatMessage(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, iMessage, prgchText2, cchTextMax, out peChatEntryType, out psteamidChatter); 533 prgchText = ret != 0 ? InteropHelp.PtrToStringUTF8(prgchText2) : null; 534 Marshal.FreeHGlobal(prgchText2); 535 return ret; 536 } 537 538 public static bool IsClanChatAdmin(CSteamID steamIDClanChat, CSteamID steamIDUser) { 539 InteropHelp.TestIfAvailableClient(); 540 return NativeMethods.ISteamFriends_IsClanChatAdmin(CSteamAPIContext.GetSteamFriends(), steamIDClanChat, steamIDUser); 541 } 542 543 /// <summary> 544 /// <para> interact with the Steam (game overlay / desktop)</para> 545 /// </summary> 546 public static bool IsClanChatWindowOpenInSteam(CSteamID steamIDClanChat) { 547 InteropHelp.TestIfAvailableClient(); 548 return NativeMethods.ISteamFriends_IsClanChatWindowOpenInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat); 549 } 550 551 public static bool OpenClanChatWindowInSteam(CSteamID steamIDClanChat) { 552 InteropHelp.TestIfAvailableClient(); 553 return NativeMethods.ISteamFriends_OpenClanChatWindowInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat); 554 } 555 556 public static bool CloseClanChatWindowInSteam(CSteamID steamIDClanChat) { 557 InteropHelp.TestIfAvailableClient(); 558 return NativeMethods.ISteamFriends_CloseClanChatWindowInSteam(CSteamAPIContext.GetSteamFriends(), steamIDClanChat); 559 } 560 561 /// <summary> 562 /// <para> peer-to-peer chat interception</para> 563 /// <para> this is so you can show P2P chats inline in the game</para> 564 /// </summary> 565 public static bool SetListenForFriendsMessages(bool bInterceptEnabled) { 566 InteropHelp.TestIfAvailableClient(); 567 return NativeMethods.ISteamFriends_SetListenForFriendsMessages(CSteamAPIContext.GetSteamFriends(), bInterceptEnabled); 568 } 569 570 public static bool ReplyToFriendMessage(CSteamID steamIDFriend, string pchMsgToSend) { 571 InteropHelp.TestIfAvailableClient(); 572 using (var pchMsgToSend2 = new InteropHelp.UTF8StringHandle(pchMsgToSend)) { 573 return NativeMethods.ISteamFriends_ReplyToFriendMessage(CSteamAPIContext.GetSteamFriends(), steamIDFriend, pchMsgToSend2); 574 } 575 } 576 577 public static int GetFriendMessage(CSteamID steamIDFriend, int iMessageID, out string pvData, int cubData, out EChatEntryType peChatEntryType) { 578 InteropHelp.TestIfAvailableClient(); 579 IntPtr pvData2 = Marshal.AllocHGlobal(cubData); 580 int ret = NativeMethods.ISteamFriends_GetFriendMessage(CSteamAPIContext.GetSteamFriends(), steamIDFriend, iMessageID, pvData2, cubData, out peChatEntryType); 581 pvData = ret != 0 ? InteropHelp.PtrToStringUTF8(pvData2) : null; 582 Marshal.FreeHGlobal(pvData2); 583 return ret; 584 } 585 586 /// <summary> 587 /// <para> following apis</para> 588 /// </summary> 589 public static SteamAPICall_t GetFollowerCount(CSteamID steamID) { 590 InteropHelp.TestIfAvailableClient(); 591 return (SteamAPICall_t)NativeMethods.ISteamFriends_GetFollowerCount(CSteamAPIContext.GetSteamFriends(), steamID); 592 } 593 594 public static SteamAPICall_t IsFollowing(CSteamID steamID) { 595 InteropHelp.TestIfAvailableClient(); 596 return (SteamAPICall_t)NativeMethods.ISteamFriends_IsFollowing(CSteamAPIContext.GetSteamFriends(), steamID); 597 } 598 599 public static SteamAPICall_t EnumerateFollowingList(uint unStartIndex) { 600 InteropHelp.TestIfAvailableClient(); 601 return (SteamAPICall_t)NativeMethods.ISteamFriends_EnumerateFollowingList(CSteamAPIContext.GetSteamFriends(), unStartIndex); 602 } 603 604 public static bool IsClanPublic(CSteamID steamIDClan) { 605 InteropHelp.TestIfAvailableClient(); 606 return NativeMethods.ISteamFriends_IsClanPublic(CSteamAPIContext.GetSteamFriends(), steamIDClan); 607 } 608 609 public static bool IsClanOfficialGameGroup(CSteamID steamIDClan) { 610 InteropHelp.TestIfAvailableClient(); 611 return NativeMethods.ISteamFriends_IsClanOfficialGameGroup(CSteamAPIContext.GetSteamFriends(), steamIDClan); 612 } 613 614 /// <summary> 615 /// <para>/ Return the number of chats (friends or chat rooms) with unread messages.</para> 616 /// <para>/ A "priority" message is one that would generate some sort of toast or</para> 617 /// <para>/ notification, and depends on user settings.</para> 618 /// <para>/</para> 619 /// <para>/ You can register for UnreadChatMessagesChanged_t callbacks to know when this</para> 620 /// <para>/ has potentially changed.</para> 621 /// </summary> 622 public static int GetNumChatsWithUnreadPriorityMessages() { 623 InteropHelp.TestIfAvailableClient(); 624 return NativeMethods.ISteamFriends_GetNumChatsWithUnreadPriorityMessages(CSteamAPIContext.GetSteamFriends()); 625 } 626 } 627 } 628 629 #endif // !DISABLESTEAMWORKS