User:Jusonex
Jump to navigation
Jump to search
Features
Awesomium API
How to test
1.) Install the 1.4 r6293 nightly build. Link: http://nightly.mtasa.com/mtasa-1.4-full_unstable-6293-20140409.exe
2.) Replace the files you've got from https://github.com/Jusonex/mtasa-awesomium/releases/download/testbuild/Awesomium0.2.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).
Sourcecode and progress
https://github.com/Jusonex/mtasa-awesomium
Functions
browser createBrowser(int width, int height)
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, int mouseButton) -- mouseButton: 0 = left, 1 = middle, 2 = right
bool injectBrowserMouseUp(browser webBrowser, int mouseButton) -- mouseButton: 0 = left, 1 = middle, 2 = right
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
Events
onClientWebsiteRequestResult Parameters: bool wasAllowed
Examples
Example 1: A 2D browser with mouse and a simple input handler
local webBrowser = createBrowser(1024, 768) requestBrowserPages({"youtube.com"}) addCommandHandler("load", function() -- Load the url loadBrowserURL(webBrowser, "http://youtube.com") 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 ) local buttons = {left = 0, middle = 1, right = 2} addEventHandler("onClientClick", root, function(button, state) if state == "down" then injectBrowserMouseDown(webBrowser, buttons[button]) else injectBrowserMouseUp(webBrowser, buttons[button]) end end ) addEventHandler("onClientKey", root, function(button, pressKey) if pressKey then injectBrowserKeyDown(webBrowser, button) else injectBrowserKeyUp(webBrowser, button) 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) -- 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 ) addCommandHandler("url", function(cmd, url) if not url then return end outputChatBox("Opening: "..url) loadBrowserURL(webBrowser, url) end )
Notes
- Crosshair position (weapons that use the "normal" crosshair texture "siteM16"): X = screenWidth * 0.5299999714f; Y = screenHeight * 0.4f