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