isteamfriends.cs 32 KB

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