User:Jusonex: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Features==
==Features==
===Awesomium API===
===CEF===
====How to test====
*[[CEF_Tutorial]]
1.) Install the latest 1.4 nightly: nightly.mtasa.com/?mtasa-1.4-latest
*[[Client_Scripting_Functions#Browser_functions]]
 
*[[Client_Scripting_Events#Browser_events]]
2.) Replace the files you've got from http://jusonex.net/public/mta/awesomium/r6465.zip
*[[CWebBrowser]]
 
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====
<syntaxhighlight lang="lua">
browser createBrowser(int width, int height, bool isLocal)
</syntaxhighlight>
*'''isLocal:''' Specifies whether to use the browser in local or global mode
<syntaxhighlight lang="lua">
bool updateBrowser(browser webBrowser)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool requestBrowserPages(table pages)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool loadBrowserURL(browser webBrowser, string url)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool isBrowserLoading(browser webBrowser)
</syntaxhighlight>
<syntaxhighlight lang="lua">
string getBrowserTitle(browser webBrowser)
</syntaxhighlight>
<syntaxhighlight lang="lua">
string getBrowserURL(browser webBrowser)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseMove(browser webBrowser, int x, int y)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseDown(browser webBrowser, string mouseButton) -- mouseButton: left/middle/right
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseUp(browser webBrowser, string mouseButton) -- mouseButton: left/middle/right
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseWheel(browser webBrowser, int scrollVertical, int scrolLHorizontal)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserKeyDown(brower webBrowser, string key) -- key names: https://wiki.multitheftauto.com/wiki/Key_names
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserKeyUp(browser webBrowser, string key) -- key names: https://wiki.multitheftauto.com/wiki/Key_names
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserCharacter(browser webBrowser, string character) -- takes case sensitivity and unicode characters into account
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool setBrowserRenderingPaused(browser webBrowser, bool isPaused)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool executeBrowserJavascript(brower webBrowser, string jsCode) -- works only in local mode
</syntaxhighlight>
 
 
====Events====
<syntaxhighlight lang="lua">
onClientBrowserRequestResult
Parameters: bool wasAllowed
</syntaxhighlight>
 
====Examples====
=====Example 1: A 2D browser with mouse and a simple input handler=====
<syntaxhighlight lang="lua">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)</syntaxhighlight>
 
=====A 3D browser at the car cinema in Fort Carson (Demo: https://www.youtube.com/watch?v=9w2qU6mZDh8)=====
<syntaxhighlight lang="lua">
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
)
</syntaxhighlight>


==Notes==
==Notes==

Latest revision as of 17:11, 12 April 2015

Features

CEF

Notes

  • Crosshair position (weapons that use the "normal" crosshair texture "siteM16"): X = screenWidth * 0.5299999714f; Y = screenHeight * 0.4f

Useful stuff

Resources

Tools

SA Reversing