isteamhtmlsurface.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 SteamHTMLSurface {
  14. /// <summary>
  15. /// <para> Must call init and shutdown when starting/ending use of the interface</para>
  16. /// </summary>
  17. public static bool Init() {
  18. InteropHelp.TestIfAvailableClient();
  19. return NativeMethods.ISteamHTMLSurface_Init(CSteamAPIContext.GetSteamHTMLSurface());
  20. }
  21. public static bool Shutdown() {
  22. InteropHelp.TestIfAvailableClient();
  23. return NativeMethods.ISteamHTMLSurface_Shutdown(CSteamAPIContext.GetSteamHTMLSurface());
  24. }
  25. /// <summary>
  26. /// <para> Create a browser object for display of a html page, when creation is complete the call handle</para>
  27. /// <para> will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser.</para>
  28. /// <para> The user agent string is a substring to be added to the general user agent string so you can</para>
  29. /// <para> identify your client on web servers.</para>
  30. /// <para> The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if</para>
  31. /// <para> you do not require this functionality.</para>
  32. /// <para> YOU MUST HAVE IMPLEMENTED HANDLERS FOR HTML_BrowserReady_t, HTML_StartRequest_t,</para>
  33. /// <para> HTML_JSAlert_t, HTML_JSConfirm_t, and HTML_FileOpenDialog_t! See the CALLBACKS</para>
  34. /// <para> section of this interface (AllowStartRequest, etc) for more details. If you do</para>
  35. /// <para> not implement these callback handlers, the browser may appear to hang instead of</para>
  36. /// <para> navigating to new pages or triggering javascript popups.</para>
  37. /// </summary>
  38. public static SteamAPICall_t CreateBrowser(string pchUserAgent, string pchUserCSS) {
  39. InteropHelp.TestIfAvailableClient();
  40. using (var pchUserAgent2 = new InteropHelp.UTF8StringHandle(pchUserAgent))
  41. using (var pchUserCSS2 = new InteropHelp.UTF8StringHandle(pchUserCSS)) {
  42. return (SteamAPICall_t)NativeMethods.ISteamHTMLSurface_CreateBrowser(CSteamAPIContext.GetSteamHTMLSurface(), pchUserAgent2, pchUserCSS2);
  43. }
  44. }
  45. /// <summary>
  46. /// <para> Call this when you are done with a html surface, this lets us free the resources being used by it</para>
  47. /// </summary>
  48. public static void RemoveBrowser(HHTMLBrowser unBrowserHandle) {
  49. InteropHelp.TestIfAvailableClient();
  50. NativeMethods.ISteamHTMLSurface_RemoveBrowser(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  51. }
  52. /// <summary>
  53. /// <para> Navigate to this URL, results in a HTML_StartRequest_t as the request commences</para>
  54. /// </summary>
  55. public static void LoadURL(HHTMLBrowser unBrowserHandle, string pchURL, string pchPostData) {
  56. InteropHelp.TestIfAvailableClient();
  57. using (var pchURL2 = new InteropHelp.UTF8StringHandle(pchURL))
  58. using (var pchPostData2 = new InteropHelp.UTF8StringHandle(pchPostData)) {
  59. NativeMethods.ISteamHTMLSurface_LoadURL(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchURL2, pchPostData2);
  60. }
  61. }
  62. /// <summary>
  63. /// <para> Tells the surface the size in pixels to display the surface</para>
  64. /// </summary>
  65. public static void SetSize(HHTMLBrowser unBrowserHandle, uint unWidth, uint unHeight) {
  66. InteropHelp.TestIfAvailableClient();
  67. NativeMethods.ISteamHTMLSurface_SetSize(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, unWidth, unHeight);
  68. }
  69. /// <summary>
  70. /// <para> Stop the load of the current html page</para>
  71. /// </summary>
  72. public static void StopLoad(HHTMLBrowser unBrowserHandle) {
  73. InteropHelp.TestIfAvailableClient();
  74. NativeMethods.ISteamHTMLSurface_StopLoad(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  75. }
  76. /// <summary>
  77. /// <para> Reload (most likely from local cache) the current page</para>
  78. /// </summary>
  79. public static void Reload(HHTMLBrowser unBrowserHandle) {
  80. InteropHelp.TestIfAvailableClient();
  81. NativeMethods.ISteamHTMLSurface_Reload(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  82. }
  83. /// <summary>
  84. /// <para> navigate back in the page history</para>
  85. /// </summary>
  86. public static void GoBack(HHTMLBrowser unBrowserHandle) {
  87. InteropHelp.TestIfAvailableClient();
  88. NativeMethods.ISteamHTMLSurface_GoBack(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  89. }
  90. /// <summary>
  91. /// <para> navigate forward in the page history</para>
  92. /// </summary>
  93. public static void GoForward(HHTMLBrowser unBrowserHandle) {
  94. InteropHelp.TestIfAvailableClient();
  95. NativeMethods.ISteamHTMLSurface_GoForward(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  96. }
  97. /// <summary>
  98. /// <para> add this header to any url requests from this browser</para>
  99. /// </summary>
  100. public static void AddHeader(HHTMLBrowser unBrowserHandle, string pchKey, string pchValue) {
  101. InteropHelp.TestIfAvailableClient();
  102. using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey))
  103. using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue)) {
  104. NativeMethods.ISteamHTMLSurface_AddHeader(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchKey2, pchValue2);
  105. }
  106. }
  107. /// <summary>
  108. /// <para> run this javascript script in the currently loaded page</para>
  109. /// </summary>
  110. public static void ExecuteJavascript(HHTMLBrowser unBrowserHandle, string pchScript) {
  111. InteropHelp.TestIfAvailableClient();
  112. using (var pchScript2 = new InteropHelp.UTF8StringHandle(pchScript)) {
  113. NativeMethods.ISteamHTMLSurface_ExecuteJavascript(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchScript2);
  114. }
  115. }
  116. /// <summary>
  117. /// <para> Mouse click and mouse movement commands</para>
  118. /// </summary>
  119. public static void MouseUp(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) {
  120. InteropHelp.TestIfAvailableClient();
  121. NativeMethods.ISteamHTMLSurface_MouseUp(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton);
  122. }
  123. public static void MouseDown(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) {
  124. InteropHelp.TestIfAvailableClient();
  125. NativeMethods.ISteamHTMLSurface_MouseDown(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton);
  126. }
  127. public static void MouseDoubleClick(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) {
  128. InteropHelp.TestIfAvailableClient();
  129. NativeMethods.ISteamHTMLSurface_MouseDoubleClick(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton);
  130. }
  131. /// <summary>
  132. /// <para> x and y are relative to the HTML bounds</para>
  133. /// </summary>
  134. public static void MouseMove(HHTMLBrowser unBrowserHandle, int x, int y) {
  135. InteropHelp.TestIfAvailableClient();
  136. NativeMethods.ISteamHTMLSurface_MouseMove(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, x, y);
  137. }
  138. /// <summary>
  139. /// <para> nDelta is pixels of scroll</para>
  140. /// </summary>
  141. public static void MouseWheel(HHTMLBrowser unBrowserHandle, int nDelta) {
  142. InteropHelp.TestIfAvailableClient();
  143. NativeMethods.ISteamHTMLSurface_MouseWheel(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nDelta);
  144. }
  145. /// <summary>
  146. /// <para> keyboard interactions, native keycode is the virtual key code value from your OS, system key flags the key to not</para>
  147. /// <para> be sent as a typed character as well as a key down</para>
  148. /// </summary>
  149. public static void KeyDown(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers, bool bIsSystemKey = false) {
  150. InteropHelp.TestIfAvailableClient();
  151. NativeMethods.ISteamHTMLSurface_KeyDown(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nNativeKeyCode, eHTMLKeyModifiers, bIsSystemKey);
  152. }
  153. public static void KeyUp(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers) {
  154. InteropHelp.TestIfAvailableClient();
  155. NativeMethods.ISteamHTMLSurface_KeyUp(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nNativeKeyCode, eHTMLKeyModifiers);
  156. }
  157. /// <summary>
  158. /// <para> cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press)</para>
  159. /// </summary>
  160. public static void KeyChar(HHTMLBrowser unBrowserHandle, uint cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers) {
  161. InteropHelp.TestIfAvailableClient();
  162. NativeMethods.ISteamHTMLSurface_KeyChar(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, cUnicodeChar, eHTMLKeyModifiers);
  163. }
  164. /// <summary>
  165. /// <para> programmatically scroll this many pixels on the page</para>
  166. /// </summary>
  167. public static void SetHorizontalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll) {
  168. InteropHelp.TestIfAvailableClient();
  169. NativeMethods.ISteamHTMLSurface_SetHorizontalScroll(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nAbsolutePixelScroll);
  170. }
  171. public static void SetVerticalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll) {
  172. InteropHelp.TestIfAvailableClient();
  173. NativeMethods.ISteamHTMLSurface_SetVerticalScroll(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nAbsolutePixelScroll);
  174. }
  175. /// <summary>
  176. /// <para> tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things</para>
  177. /// </summary>
  178. public static void SetKeyFocus(HHTMLBrowser unBrowserHandle, bool bHasKeyFocus) {
  179. InteropHelp.TestIfAvailableClient();
  180. NativeMethods.ISteamHTMLSurface_SetKeyFocus(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bHasKeyFocus);
  181. }
  182. /// <summary>
  183. /// <para> open the current pages html code in the local editor of choice, used for debugging</para>
  184. /// </summary>
  185. public static void ViewSource(HHTMLBrowser unBrowserHandle) {
  186. InteropHelp.TestIfAvailableClient();
  187. NativeMethods.ISteamHTMLSurface_ViewSource(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  188. }
  189. /// <summary>
  190. /// <para> copy the currently selected text on the html page to the local clipboard</para>
  191. /// </summary>
  192. public static void CopyToClipboard(HHTMLBrowser unBrowserHandle) {
  193. InteropHelp.TestIfAvailableClient();
  194. NativeMethods.ISteamHTMLSurface_CopyToClipboard(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  195. }
  196. /// <summary>
  197. /// <para> paste from the local clipboard to the current html page</para>
  198. /// </summary>
  199. public static void PasteFromClipboard(HHTMLBrowser unBrowserHandle) {
  200. InteropHelp.TestIfAvailableClient();
  201. NativeMethods.ISteamHTMLSurface_PasteFromClipboard(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  202. }
  203. /// <summary>
  204. /// <para> find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element</para>
  205. /// </summary>
  206. public static void Find(HHTMLBrowser unBrowserHandle, string pchSearchStr, bool bCurrentlyInFind, bool bReverse) {
  207. InteropHelp.TestIfAvailableClient();
  208. using (var pchSearchStr2 = new InteropHelp.UTF8StringHandle(pchSearchStr)) {
  209. NativeMethods.ISteamHTMLSurface_Find(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchSearchStr2, bCurrentlyInFind, bReverse);
  210. }
  211. }
  212. /// <summary>
  213. /// <para> cancel a currently running find</para>
  214. /// </summary>
  215. public static void StopFind(HHTMLBrowser unBrowserHandle) {
  216. InteropHelp.TestIfAvailableClient();
  217. NativeMethods.ISteamHTMLSurface_StopFind(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  218. }
  219. /// <summary>
  220. /// <para> return details about the link at position x,y on the current page</para>
  221. /// </summary>
  222. public static void GetLinkAtPosition(HHTMLBrowser unBrowserHandle, int x, int y) {
  223. InteropHelp.TestIfAvailableClient();
  224. NativeMethods.ISteamHTMLSurface_GetLinkAtPosition(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, x, y);
  225. }
  226. /// <summary>
  227. /// <para> set a webcookie for the hostname in question</para>
  228. /// </summary>
  229. public static void SetCookie(string pchHostname, string pchKey, string pchValue, string pchPath = "/", uint nExpires = 0, bool bSecure = false, bool bHTTPOnly = false) {
  230. InteropHelp.TestIfAvailableClient();
  231. using (var pchHostname2 = new InteropHelp.UTF8StringHandle(pchHostname))
  232. using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey))
  233. using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue))
  234. using (var pchPath2 = new InteropHelp.UTF8StringHandle(pchPath)) {
  235. NativeMethods.ISteamHTMLSurface_SetCookie(CSteamAPIContext.GetSteamHTMLSurface(), pchHostname2, pchKey2, pchValue2, pchPath2, nExpires, bSecure, bHTTPOnly);
  236. }
  237. }
  238. /// <summary>
  239. /// <para> Zoom the current page by flZoom ( from 0.0 to 2.0, so to zoom to 120% use 1.2 ), zooming around point X,Y in the page (use 0,0 if you don't care)</para>
  240. /// </summary>
  241. public static void SetPageScaleFactor(HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY) {
  242. InteropHelp.TestIfAvailableClient();
  243. NativeMethods.ISteamHTMLSurface_SetPageScaleFactor(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, flZoom, nPointX, nPointY);
  244. }
  245. /// <summary>
  246. /// <para> Enable/disable low-resource background mode, where javascript and repaint timers are throttled, resources are</para>
  247. /// <para> more aggressively purged from memory, and audio/video elements are paused. When background mode is enabled,</para>
  248. /// <para> all HTML5 video and audio objects will execute ".pause()" and gain the property "._steam_background_paused = 1".</para>
  249. /// <para> When background mode is disabled, any video or audio objects with that property will resume with ".play()".</para>
  250. /// </summary>
  251. public static void SetBackgroundMode(HHTMLBrowser unBrowserHandle, bool bBackgroundMode) {
  252. InteropHelp.TestIfAvailableClient();
  253. NativeMethods.ISteamHTMLSurface_SetBackgroundMode(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bBackgroundMode);
  254. }
  255. /// <summary>
  256. /// <para> Scale the output display space by this factor, this is useful when displaying content on high dpi devices.</para>
  257. /// <para> Specifies the ratio between physical and logical pixels.</para>
  258. /// </summary>
  259. public static void SetDPIScalingFactor(HHTMLBrowser unBrowserHandle, float flDPIScaling) {
  260. InteropHelp.TestIfAvailableClient();
  261. NativeMethods.ISteamHTMLSurface_SetDPIScalingFactor(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, flDPIScaling);
  262. }
  263. /// <summary>
  264. /// <para> Open HTML/JS developer tools</para>
  265. /// </summary>
  266. public static void OpenDeveloperTools(HHTMLBrowser unBrowserHandle) {
  267. InteropHelp.TestIfAvailableClient();
  268. NativeMethods.ISteamHTMLSurface_OpenDeveloperTools(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle);
  269. }
  270. /// <summary>
  271. /// <para> CALLBACKS</para>
  272. /// <para> These set of functions are used as responses to callback requests</para>
  273. /// <para> You MUST call this in response to a HTML_StartRequest_t callback</para>
  274. /// <para> Set bAllowed to true to allow this navigation, false to cancel it and stay</para>
  275. /// <para> on the current page. You can use this feature to limit the valid pages</para>
  276. /// <para> allowed in your HTML surface.</para>
  277. /// </summary>
  278. public static void AllowStartRequest(HHTMLBrowser unBrowserHandle, bool bAllowed) {
  279. InteropHelp.TestIfAvailableClient();
  280. NativeMethods.ISteamHTMLSurface_AllowStartRequest(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bAllowed);
  281. }
  282. /// <summary>
  283. /// <para> You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback</para>
  284. /// <para> Set bResult to true for the OK option of a confirm, use false otherwise</para>
  285. /// </summary>
  286. public static void JSDialogResponse(HHTMLBrowser unBrowserHandle, bool bResult) {
  287. InteropHelp.TestIfAvailableClient();
  288. NativeMethods.ISteamHTMLSurface_JSDialogResponse(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bResult);
  289. }
  290. /// <summary>
  291. /// <para> You MUST call this in response to a HTML_FileOpenDialog_t callback</para>
  292. /// </summary>
  293. public static void FileLoadDialogResponse(HHTMLBrowser unBrowserHandle, IntPtr pchSelectedFiles) {
  294. InteropHelp.TestIfAvailableClient();
  295. NativeMethods.ISteamHTMLSurface_FileLoadDialogResponse(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchSelectedFiles);
  296. }
  297. }
  298. }
  299. #endif // !DISABLESTEAMWORKS