// This file is provided under The MIT License as part of Steamworks.NET. // Copyright (c) 2013-2019 Riley Labrecque // Please see the included LICENSE.txt for additional information. // This file is automatically generated. // Changes to this file will be reverted when you update Steamworks.NET #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH #define DISABLESTEAMWORKS #endif #if !DISABLESTEAMWORKS using System.Runtime.InteropServices; using IntPtr = System.IntPtr; namespace Steamworks { public static class SteamHTMLSurface { /// /// Must call init and shutdown when starting/ending use of the interface /// public static bool Init() { InteropHelp.TestIfAvailableClient(); return NativeMethods.ISteamHTMLSurface_Init(CSteamAPIContext.GetSteamHTMLSurface()); } public static bool Shutdown() { InteropHelp.TestIfAvailableClient(); return NativeMethods.ISteamHTMLSurface_Shutdown(CSteamAPIContext.GetSteamHTMLSurface()); } /// /// Create a browser object for display of a html page, when creation is complete the call handle /// will return a HTML_BrowserReady_t callback for the HHTMLBrowser of your new browser. /// The user agent string is a substring to be added to the general user agent string so you can /// identify your client on web servers. /// The userCSS string lets you apply a CSS style sheet to every displayed page, leave null if /// you do not require this functionality. /// YOU MUST HAVE IMPLEMENTED HANDLERS FOR HTML_BrowserReady_t, HTML_StartRequest_t, /// HTML_JSAlert_t, HTML_JSConfirm_t, and HTML_FileOpenDialog_t! See the CALLBACKS /// section of this interface (AllowStartRequest, etc) for more details. If you do /// not implement these callback handlers, the browser may appear to hang instead of /// navigating to new pages or triggering javascript popups. /// public static SteamAPICall_t CreateBrowser(string pchUserAgent, string pchUserCSS) { InteropHelp.TestIfAvailableClient(); using (var pchUserAgent2 = new InteropHelp.UTF8StringHandle(pchUserAgent)) using (var pchUserCSS2 = new InteropHelp.UTF8StringHandle(pchUserCSS)) { return (SteamAPICall_t)NativeMethods.ISteamHTMLSurface_CreateBrowser(CSteamAPIContext.GetSteamHTMLSurface(), pchUserAgent2, pchUserCSS2); } } /// /// Call this when you are done with a html surface, this lets us free the resources being used by it /// public static void RemoveBrowser(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_RemoveBrowser(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// Navigate to this URL, results in a HTML_StartRequest_t as the request commences /// public static void LoadURL(HHTMLBrowser unBrowserHandle, string pchURL, string pchPostData) { InteropHelp.TestIfAvailableClient(); using (var pchURL2 = new InteropHelp.UTF8StringHandle(pchURL)) using (var pchPostData2 = new InteropHelp.UTF8StringHandle(pchPostData)) { NativeMethods.ISteamHTMLSurface_LoadURL(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchURL2, pchPostData2); } } /// /// Tells the surface the size in pixels to display the surface /// public static void SetSize(HHTMLBrowser unBrowserHandle, uint unWidth, uint unHeight) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetSize(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, unWidth, unHeight); } /// /// Stop the load of the current html page /// public static void StopLoad(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_StopLoad(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// Reload (most likely from local cache) the current page /// public static void Reload(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_Reload(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// navigate back in the page history /// public static void GoBack(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_GoBack(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// navigate forward in the page history /// public static void GoForward(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_GoForward(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// add this header to any url requests from this browser /// public static void AddHeader(HHTMLBrowser unBrowserHandle, string pchKey, string pchValue) { InteropHelp.TestIfAvailableClient(); using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue)) { NativeMethods.ISteamHTMLSurface_AddHeader(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchKey2, pchValue2); } } /// /// run this javascript script in the currently loaded page /// public static void ExecuteJavascript(HHTMLBrowser unBrowserHandle, string pchScript) { InteropHelp.TestIfAvailableClient(); using (var pchScript2 = new InteropHelp.UTF8StringHandle(pchScript)) { NativeMethods.ISteamHTMLSurface_ExecuteJavascript(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchScript2); } } /// /// Mouse click and mouse movement commands /// public static void MouseUp(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_MouseUp(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton); } public static void MouseDown(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_MouseDown(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton); } public static void MouseDoubleClick(HHTMLBrowser unBrowserHandle, EHTMLMouseButton eMouseButton) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_MouseDoubleClick(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, eMouseButton); } /// /// x and y are relative to the HTML bounds /// public static void MouseMove(HHTMLBrowser unBrowserHandle, int x, int y) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_MouseMove(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, x, y); } /// /// nDelta is pixels of scroll /// public static void MouseWheel(HHTMLBrowser unBrowserHandle, int nDelta) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_MouseWheel(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nDelta); } /// /// keyboard interactions, native keycode is the virtual key code value from your OS, system key flags the key to not /// be sent as a typed character as well as a key down /// public static void KeyDown(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers, bool bIsSystemKey = false) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_KeyDown(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nNativeKeyCode, eHTMLKeyModifiers, bIsSystemKey); } public static void KeyUp(HHTMLBrowser unBrowserHandle, uint nNativeKeyCode, EHTMLKeyModifiers eHTMLKeyModifiers) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_KeyUp(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nNativeKeyCode, eHTMLKeyModifiers); } /// /// cUnicodeChar is the unicode character point for this keypress (and potentially multiple chars per press) /// public static void KeyChar(HHTMLBrowser unBrowserHandle, uint cUnicodeChar, EHTMLKeyModifiers eHTMLKeyModifiers) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_KeyChar(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, cUnicodeChar, eHTMLKeyModifiers); } /// /// programmatically scroll this many pixels on the page /// public static void SetHorizontalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetHorizontalScroll(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nAbsolutePixelScroll); } public static void SetVerticalScroll(HHTMLBrowser unBrowserHandle, uint nAbsolutePixelScroll) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetVerticalScroll(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, nAbsolutePixelScroll); } /// /// tell the html control if it has key focus currently, controls showing the I-beam cursor in text controls amongst other things /// public static void SetKeyFocus(HHTMLBrowser unBrowserHandle, bool bHasKeyFocus) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetKeyFocus(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bHasKeyFocus); } /// /// open the current pages html code in the local editor of choice, used for debugging /// public static void ViewSource(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_ViewSource(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// copy the currently selected text on the html page to the local clipboard /// public static void CopyToClipboard(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_CopyToClipboard(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// paste from the local clipboard to the current html page /// public static void PasteFromClipboard(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_PasteFromClipboard(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// find this string in the browser, if bCurrentlyInFind is true then instead cycle to the next matching element /// public static void Find(HHTMLBrowser unBrowserHandle, string pchSearchStr, bool bCurrentlyInFind, bool bReverse) { InteropHelp.TestIfAvailableClient(); using (var pchSearchStr2 = new InteropHelp.UTF8StringHandle(pchSearchStr)) { NativeMethods.ISteamHTMLSurface_Find(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchSearchStr2, bCurrentlyInFind, bReverse); } } /// /// cancel a currently running find /// public static void StopFind(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_StopFind(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// return details about the link at position x,y on the current page /// public static void GetLinkAtPosition(HHTMLBrowser unBrowserHandle, int x, int y) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_GetLinkAtPosition(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, x, y); } /// /// set a webcookie for the hostname in question /// public static void SetCookie(string pchHostname, string pchKey, string pchValue, string pchPath = "/", uint nExpires = 0, bool bSecure = false, bool bHTTPOnly = false) { InteropHelp.TestIfAvailableClient(); using (var pchHostname2 = new InteropHelp.UTF8StringHandle(pchHostname)) using (var pchKey2 = new InteropHelp.UTF8StringHandle(pchKey)) using (var pchValue2 = new InteropHelp.UTF8StringHandle(pchValue)) using (var pchPath2 = new InteropHelp.UTF8StringHandle(pchPath)) { NativeMethods.ISteamHTMLSurface_SetCookie(CSteamAPIContext.GetSteamHTMLSurface(), pchHostname2, pchKey2, pchValue2, pchPath2, nExpires, bSecure, bHTTPOnly); } } /// /// 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) /// public static void SetPageScaleFactor(HHTMLBrowser unBrowserHandle, float flZoom, int nPointX, int nPointY) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetPageScaleFactor(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, flZoom, nPointX, nPointY); } /// /// Enable/disable low-resource background mode, where javascript and repaint timers are throttled, resources are /// more aggressively purged from memory, and audio/video elements are paused. When background mode is enabled, /// all HTML5 video and audio objects will execute ".pause()" and gain the property "._steam_background_paused = 1". /// When background mode is disabled, any video or audio objects with that property will resume with ".play()". /// public static void SetBackgroundMode(HHTMLBrowser unBrowserHandle, bool bBackgroundMode) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetBackgroundMode(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bBackgroundMode); } /// /// Scale the output display space by this factor, this is useful when displaying content on high dpi devices. /// Specifies the ratio between physical and logical pixels. /// public static void SetDPIScalingFactor(HHTMLBrowser unBrowserHandle, float flDPIScaling) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_SetDPIScalingFactor(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, flDPIScaling); } /// /// Open HTML/JS developer tools /// public static void OpenDeveloperTools(HHTMLBrowser unBrowserHandle) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_OpenDeveloperTools(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle); } /// /// CALLBACKS /// These set of functions are used as responses to callback requests /// You MUST call this in response to a HTML_StartRequest_t callback /// Set bAllowed to true to allow this navigation, false to cancel it and stay /// on the current page. You can use this feature to limit the valid pages /// allowed in your HTML surface. /// public static void AllowStartRequest(HHTMLBrowser unBrowserHandle, bool bAllowed) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_AllowStartRequest(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bAllowed); } /// /// You MUST call this in response to a HTML_JSAlert_t or HTML_JSConfirm_t callback /// Set bResult to true for the OK option of a confirm, use false otherwise /// public static void JSDialogResponse(HHTMLBrowser unBrowserHandle, bool bResult) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_JSDialogResponse(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, bResult); } /// /// You MUST call this in response to a HTML_FileOpenDialog_t callback /// public static void FileLoadDialogResponse(HHTMLBrowser unBrowserHandle, IntPtr pchSelectedFiles) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamHTMLSurface_FileLoadDialogResponse(CSteamAPIContext.GetSteamHTMLSurface(), unBrowserHandle, pchSelectedFiles); } } } #endif // !DISABLESTEAMWORKS