User:Jusonex: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 64: | Line 64: | ||
onClientBrowserRequestResult | onClientBrowserRequestResult | ||
Parameters: bool wasAllowed | Parameters: bool wasAllowed | ||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
onClientBrowserCursorChange | |||
Parameters: int cursor | |||
Source: The webbrowser element | |||
</syntaxhighlight> | |||
''Cursor IDs:'' | |||
[code] | |||
enum Cursor { | |||
kCursor_Pointer, // ID: 0 | |||
kCursor_Cross, // ID: 1 | |||
kCursor_Hand, // ID: 2 | |||
kCursor_IBeam, // ID: 3 | |||
kCursor_Wait, // ID: 4 | |||
kCursor_Help, // ID: ... | |||
kCursor_EastResize, | |||
kCursor_NorthResize, | |||
kCursor_NorthEastResize, | |||
kCursor_NorthWestResize, | |||
kCursor_SouthResize, | |||
kCursor_SouthEastResize, | |||
kCursor_SouthWestResize, | |||
kCursor_WestResize, | |||
kCursor_NorthSouthResize, | |||
kCursor_EastWestResize, | |||
kCursor_NorthEastSouthWestResize, | |||
kCursor_NorthWestSouthEastResize, | |||
kCursor_ColumnResize, | |||
kCursor_RowResize, | |||
kCursor_MiddlePanning, | |||
kCursor_EastPanning, | |||
kCursor_NorthPanning, | |||
kCursor_NorthEastPanning, | |||
kCursor_NorthWestPanning, | |||
kCursor_SouthPanning, | |||
kCursor_SouthEastPanning, | |||
kCursor_SouthWestPanning, | |||
kCursor_WestPanning, | |||
kCursor_Move, | |||
kCursor_VerticalText, | |||
kCursor_Cell, | |||
kCursor_ContextMenu, | |||
kCursor_Alias, | |||
kCursor_Progress, | |||
kCursor_NoDrop, | |||
kCursor_Copy, | |||
kCursor_None, | |||
kCursor_NotAllowed, | |||
kCursor_ZoomIn, | |||
kCursor_ZoomOut, | |||
kCursor_Grab, | |||
kCursor_Grabbing, | |||
kCursor_Custom | |||
};[/code] | |||
<syntaxhighlight lang="lua"> | |||
onClientBrowserPopup | |||
Parameters: string targetURL, string openerURL, bool isPopup | |||
Source: The webbrowser element | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
onClientBrowserNavigate | |||
Parameters: string targetURL, bool isMainFrame | |||
Source: The webbrowser element | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
onClientBrowserLoadingFailed | |||
Parameters: string url, int errorCode, string errorDescription | |||
Source: The webbrowser element | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="lua"> | |||
onClientBrowserDocumentReady | |||
Parameters: string url | |||
Source: The webbrowser element | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 11:50, 3 August 2014
Features
Awesomium API
How to test
1.) Install the latest 1.4 nightly: nightly.mtasa.com/?mtasa-1.4-latest
2.) Replace the files you've got from http://jusonex.net/public/mta/awesomium/r6465.zip
If it doesn't work, you'll have to install the x86 VC++ Redist 2013 (http://www.microsoft.com/en-us/download/details.aspx?id=40784).
Functions
browser createBrowser(int width, int height, bool isLocal)
- isLocal: Specifies whether to use the browser in local or global mode
bool updateBrowser(browser webBrowser)
bool requestBrowserPages(table pages)
bool loadBrowserURL(browser webBrowser, string url)
bool isBrowserLoading(browser webBrowser)
string getBrowserTitle(browser webBrowser)
string getBrowserURL(browser webBrowser)
bool injectBrowserMouseMove(browser webBrowser, int x, int y)
bool injectBrowserMouseDown(browser webBrowser, string mouseButton) -- mouseButton: left/middle/right
bool injectBrowserMouseUp(browser webBrowser, string mouseButton) -- mouseButton: left/middle/right
bool injectBrowserMouseWheel(browser webBrowser, int scrollVertical, int scrolLHorizontal)
bool injectBrowserKeyDown(brower webBrowser, string key) -- key names: https://wiki.multitheftauto.com/wiki/Key_names
bool injectBrowserKeyUp(browser webBrowser, string key) -- key names: https://wiki.multitheftauto.com/wiki/Key_names
bool injectBrowserCharacter(browser webBrowser, string character) -- takes case sensitivity and unicode characters into account
bool setBrowserRenderingPaused(browser webBrowser, bool isPaused)
bool executeBrowserJavascript(brower webBrowser, string jsCode) -- works only in local mode
Events
onClientBrowserRequestResult Parameters: bool wasAllowed
onClientBrowserCursorChange Parameters: int cursor Source: The webbrowser element
Cursor IDs: [code] enum Cursor {
kCursor_Pointer, // ID: 0 kCursor_Cross, // ID: 1 kCursor_Hand, // ID: 2 kCursor_IBeam, // ID: 3 kCursor_Wait, // ID: 4 kCursor_Help, // ID: ... kCursor_EastResize, kCursor_NorthResize, kCursor_NorthEastResize, kCursor_NorthWestResize, kCursor_SouthResize, kCursor_SouthEastResize, kCursor_SouthWestResize, kCursor_WestResize, kCursor_NorthSouthResize, kCursor_EastWestResize, kCursor_NorthEastSouthWestResize, kCursor_NorthWestSouthEastResize, kCursor_ColumnResize, kCursor_RowResize, kCursor_MiddlePanning, kCursor_EastPanning, kCursor_NorthPanning, kCursor_NorthEastPanning, kCursor_NorthWestPanning, kCursor_SouthPanning, kCursor_SouthEastPanning, kCursor_SouthWestPanning, kCursor_WestPanning, kCursor_Move, kCursor_VerticalText, kCursor_Cell, kCursor_ContextMenu, kCursor_Alias, kCursor_Progress, kCursor_NoDrop, kCursor_Copy, kCursor_None, kCursor_NotAllowed, kCursor_ZoomIn, kCursor_ZoomOut, kCursor_Grab, kCursor_Grabbing, kCursor_Custom
};[/code]
onClientBrowserPopup Parameters: string targetURL, string openerURL, bool isPopup Source: The webbrowser element
onClientBrowserNavigate Parameters: string targetURL, bool isMainFrame Source: The webbrowser element
onClientBrowserLoadingFailed Parameters: string url, int errorCode, string errorDescription Source: The webbrowser element
onClientBrowserDocumentReady Parameters: string url Source: The webbrowser element
Examples
Example 1: A 2D browser with mouse and a simple input handler
local webBrowser = createBrowser(1024, 768, false) requestBrowserPages({"youtube.com"}) addCommandHandler("load", function() -- Load the url loadBrowserURL(webBrowser, "http://youtube.com") -- This line is potentially needless since YouTube is whitelisted end ) addEventHandler("onClientRender", root, function() -- Update the browser updateBrowser(webBrowser) -- Draw a nice border dxDrawRectangle(195, 95, 1024+10, 768+10, tocolor(255, 255, 0)) -- Draw the browser dxDrawImage(200, 100, 1024, 768, webBrowser) end ) addEventHandler("onClientCursorMove", root, function(relativeX, relativeY, absoluteX, absoluteY) injectBrowserMouseMove(webBrowser, absoluteX - 200, absoluteY - 100) end ) addEventHandler("onClientClick", root, function(button, state) if state == "down" then injectBrowserMouseDown(webBrowser, button) else injectBrowserMouseUp(webBrowser, button) end end ) addEventHandler("onClientKey", root, function(button, pressKey) if pressKey then injectBrowserKeyDown(webBrowser, button) else injectBrowserKeyUp(webBrowser, button) end if button == "mouse_wheel_down" then injectBrowserMouseWheel(webBrowser, -40, 0) elseif button == "mouse_wheel_up" then injectBrowserMouseWheel(webBrowser, 40, 0) end end ) addEventHandler("onClientCharacter", root, function(c) injectBrowserCharacter(webBrowser, c) end ) showCursor(true)
A 3D browser at the car cinema in Fort Carson (Demo: https://www.youtube.com/watch?v=9w2qU6mZDh8)
local width, height = 1600, 900 -- Create the browser local webBrowser = createBrowser(width, height, false) -- Request the pages requestBrowserPages({"www.youtube.com", "nyan.cat"}) addEventHandler("onClientRender", root, function() -- Update pixel data updateBrowser(webBrowser) -- Draw the line local x, y = 110.7, 1024.15 dxDrawMaterialLine3D(x, y, 23.25, x, y, 14.75, webBrowser, 18.2, tocolor(255, 255, 255, 255), x, y+1, 19) end ) addCommandHandler("youtube", function() outputChatBox("YouTube?") loadBrowserURL(webBrowser, "http://www.youtube.com/watch?v=kdemFfbS5H0") end ) addCommandHandler("nyan", function() outputChatBox("Nyan!") loadBrowserURL(webBrowser, "http://nyan.cat") end )
Notes
- Crosshair position (weapons that use the "normal" crosshair texture "siteM16"): X = screenWidth * 0.5299999714f; Y = screenHeight * 0.4f