isteamscreenshots.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 SteamScreenshots {
  14. /// <summary>
  15. /// <para> Writes a screenshot to the user's screenshot library given the raw image data, which must be in RGB format.</para>
  16. /// <para> The return value is a handle that is valid for the duration of the game process and can be used to apply tags.</para>
  17. /// </summary>
  18. public static ScreenshotHandle WriteScreenshot(byte[] pubRGB, uint cubRGB, int nWidth, int nHeight) {
  19. InteropHelp.TestIfAvailableClient();
  20. return (ScreenshotHandle)NativeMethods.ISteamScreenshots_WriteScreenshot(CSteamAPIContext.GetSteamScreenshots(), pubRGB, cubRGB, nWidth, nHeight);
  21. }
  22. /// <summary>
  23. /// <para> Adds a screenshot to the user's screenshot library from disk. If a thumbnail is provided, it must be 200 pixels wide and the same aspect ratio</para>
  24. /// <para> as the screenshot, otherwise a thumbnail will be generated if the user uploads the screenshot. The screenshots must be in either JPEG or TGA format.</para>
  25. /// <para> The return value is a handle that is valid for the duration of the game process and can be used to apply tags.</para>
  26. /// <para> JPEG, TGA, and PNG formats are supported.</para>
  27. /// </summary>
  28. public static ScreenshotHandle AddScreenshotToLibrary(string pchFilename, string pchThumbnailFilename, int nWidth, int nHeight) {
  29. InteropHelp.TestIfAvailableClient();
  30. using (var pchFilename2 = new InteropHelp.UTF8StringHandle(pchFilename))
  31. using (var pchThumbnailFilename2 = new InteropHelp.UTF8StringHandle(pchThumbnailFilename)) {
  32. return (ScreenshotHandle)NativeMethods.ISteamScreenshots_AddScreenshotToLibrary(CSteamAPIContext.GetSteamScreenshots(), pchFilename2, pchThumbnailFilename2, nWidth, nHeight);
  33. }
  34. }
  35. /// <summary>
  36. /// <para> Causes the Steam overlay to take a screenshot. If screenshots are being hooked by the game then a ScreenshotRequested_t callback is sent back to the game instead.</para>
  37. /// </summary>
  38. public static void TriggerScreenshot() {
  39. InteropHelp.TestIfAvailableClient();
  40. NativeMethods.ISteamScreenshots_TriggerScreenshot(CSteamAPIContext.GetSteamScreenshots());
  41. }
  42. /// <summary>
  43. /// <para> Toggles whether the overlay handles screenshots when the user presses the screenshot hotkey, or the game handles them. If the game is hooking screenshots,</para>
  44. /// <para> then the ScreenshotRequested_t callback will be sent if the user presses the hotkey, and the game is expected to call WriteScreenshot or AddScreenshotToLibrary</para>
  45. /// <para> in response.</para>
  46. /// </summary>
  47. public static void HookScreenshots(bool bHook) {
  48. InteropHelp.TestIfAvailableClient();
  49. NativeMethods.ISteamScreenshots_HookScreenshots(CSteamAPIContext.GetSteamScreenshots(), bHook);
  50. }
  51. /// <summary>
  52. /// <para> Sets metadata about a screenshot's location (for example, the name of the map)</para>
  53. /// </summary>
  54. public static bool SetLocation(ScreenshotHandle hScreenshot, string pchLocation) {
  55. InteropHelp.TestIfAvailableClient();
  56. using (var pchLocation2 = new InteropHelp.UTF8StringHandle(pchLocation)) {
  57. return NativeMethods.ISteamScreenshots_SetLocation(CSteamAPIContext.GetSteamScreenshots(), hScreenshot, pchLocation2);
  58. }
  59. }
  60. /// <summary>
  61. /// <para> Tags a user as being visible in the screenshot</para>
  62. /// </summary>
  63. public static bool TagUser(ScreenshotHandle hScreenshot, CSteamID steamID) {
  64. InteropHelp.TestIfAvailableClient();
  65. return NativeMethods.ISteamScreenshots_TagUser(CSteamAPIContext.GetSteamScreenshots(), hScreenshot, steamID);
  66. }
  67. /// <summary>
  68. /// <para> Tags a published file as being visible in the screenshot</para>
  69. /// </summary>
  70. public static bool TagPublishedFile(ScreenshotHandle hScreenshot, PublishedFileId_t unPublishedFileID) {
  71. InteropHelp.TestIfAvailableClient();
  72. return NativeMethods.ISteamScreenshots_TagPublishedFile(CSteamAPIContext.GetSteamScreenshots(), hScreenshot, unPublishedFileID);
  73. }
  74. /// <summary>
  75. /// <para> Returns true if the app has hooked the screenshot</para>
  76. /// </summary>
  77. public static bool IsScreenshotsHooked() {
  78. InteropHelp.TestIfAvailableClient();
  79. return NativeMethods.ISteamScreenshots_IsScreenshotsHooked(CSteamAPIContext.GetSteamScreenshots());
  80. }
  81. /// <summary>
  82. /// <para> Adds a VR screenshot to the user's screenshot library from disk in the supported type.</para>
  83. /// <para> pchFilename should be the normal 2D image used in the library view</para>
  84. /// <para> pchVRFilename should contain the image that matches the correct type</para>
  85. /// <para> The return value is a handle that is valid for the duration of the game process and can be used to apply tags.</para>
  86. /// <para> JPEG, TGA, and PNG formats are supported.</para>
  87. /// </summary>
  88. public static ScreenshotHandle AddVRScreenshotToLibrary(EVRScreenshotType eType, string pchFilename, string pchVRFilename) {
  89. InteropHelp.TestIfAvailableClient();
  90. using (var pchFilename2 = new InteropHelp.UTF8StringHandle(pchFilename))
  91. using (var pchVRFilename2 = new InteropHelp.UTF8StringHandle(pchVRFilename)) {
  92. return (ScreenshotHandle)NativeMethods.ISteamScreenshots_AddVRScreenshotToLibrary(CSteamAPIContext.GetSteamScreenshots(), eType, pchFilename2, pchVRFilename2);
  93. }
  94. }
  95. }
  96. }
  97. #endif // !DISABLESTEAMWORKS