User:Jusonex: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(22 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Features==
==Features==
===Awesomium API===
===CEF===
====Functions====
*[[CEF_Tutorial]]
<syntaxhighlight lang="lua">
*[[Client_Scripting_Functions#Browser_functions]]
browser createBrowser(int width, int height)
*[[Client_Scripting_Events#Browser_events]]
</syntaxhighlight>
*[[CWebBrowser]]
<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">
bool injectBrowserMouseMove(browser webBrowser, int x, int y)
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseDown(browser webBrowser, int mouseButton) -- mouseButton: 0 = left, 1 = middle, 3 = right
</syntaxhighlight>
<syntaxhighlight lang="lua">
bool injectBrowserMouseUp(browser webBrowser, int mouseButton) -- mouseButton: 0 = left, 1 = middle, 3 = right
</syntaxhighlight>
 
====Events====
Todo
 
====Examples====
=====Example 1: A 2D browser with mouse input (keyboard input is missing yet)=====
<syntaxhighlight lang="lua">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 = 2, right = 3}
addEventHandler("onClientClick", root,
function(button, state)
if state == "down" then
injectBrowserMouseDown(webBrowser, buttons[button])
else
injectBrowserMouseUp(webBrowser, buttons[button])
end
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)
 
-- There is an issue with alpha at the moment --> render everything into a renderTarget first
local renderTarget = dxCreateRenderTarget(width, height, true)
 
-- Request the pages
requestBrowserPages({"www.youtube.com", "nyan.cat"})
 
addEventHandler("onClientRender", root,
function()
-- Update pixel data
updateBrowser(webBrowser)
-- Switch to the rendertarget (@issue above)
dxSetRenderTarget(renderTarget)
dxDrawImage(0, 0, width, height, webBrowser)
dxSetRenderTarget()
-- Draw the line
local x, y = 110.7, 1024.15
dxDrawMaterialLine3D(x, y, 23.25, x, y, 14.75, renderTarget, 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
)</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