Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- @author FusioN. | santex.
- @name Internet
- @server America RPG
- @type SERVER
- ]]
- local sW, sH = guiGetScreenSize()
- local availableWebPages = {
- ["americaweb://main"] = {pageNumber=1},
- ["americaweb://guide"] = {pageNumber=2},
- ["custom"] = {pageNumber=999},
- }
- local webPage = nil
- local mainPageFont = dxCreateFont(":g_assets/fonts/lato/regular.ttf", sW / 49.2307692308)
- local taskBarFont = dxCreateFont(":g_assets/fonts/lato/regular.ttf", sW / 116.363636364)
- local startTick = nil
- local webHeight = 2.5
- local searchBarText = ""
- local searchBarSelected = false
- local backspaceTicks = nil
- local guideButtonStartTick = nil
- local browser
- function isMouseInPosition ( x, y, width, height )
- if ( not isCursorShowing( ) ) then
- return false
- end
- local sx, sy = guiGetScreenSize ( )
- local cx, cy = getCursorPosition ( )
- local cx, cy = ( cx * sx ), ( cy * sy )
- if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
- return true
- else
- return false
- end
- end
- function renderWeb()
- if startTick then
- local animationProgress = (getTickCount() - startTick) / 1500
- webHeight = interpolateBetween(2.5, 0, 0, 0, 0, 0, animationProgress, "InBounce")
- if animationProgress >= 1 then
- startTick = nil
- end
- end
- dxDrawRectangle(sW * 0, sH * (0+ webHeight), sW * 1, sH * 1, tocolor(255, 255, 255, 255), false)
- dxDrawLine(sW * 0, sH * (0.0694+ webHeight), sW * 1, sH * (0.0694+ webHeight), tocolor(54, 54, 54, 255), 1, false)
- dxDrawRectangle(sW * 0, sH * (0+ webHeight), sW * 1, sH * 0.0694, tocolor(208, 208, 208, 255), false)
- dxDrawImage(sW * -0.0070, sH * (-0.0125+ webHeight), sW * 0.0500, sH * 0.0889, ":arpg_images_global/logoA.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
- dxDrawText("WEB", sW * 0.0313, sH * (0.0139+ webHeight), sW * 0.1391, sH * (0.0583+ webHeight), tocolor(254, 254, 254, 255), 1.00, taskBarFont, "left", "bottom", false, false, false, false, false)
- dxDrawLine((sW * 0.0609) - 1, (sH * (0.0139+ webHeight)) - 1, (sW * 0.0609) - 1, sH * (0.0542+ webHeight), tocolor(0, 0, 0, 255), 1, false)
- dxDrawLine(sW * 0.9516, (sH * (0.0139+ webHeight)) - 1, (sW * 0.0609) - 1, (sH * (0.0139+ webHeight)) - 1, tocolor(0, 0, 0, 255), 1, false)
- dxDrawLine((sW * 0.0609) - 1, sH * (0.0542+ webHeight), sW * 0.9516, sH * (0.0542+ webHeight), tocolor(0, 0, 0, 255), 1, false)
- dxDrawLine(sW * 0.9516, sH * (0.0542+ webHeight), sW * 0.9516, (sH * (0.0139+ webHeight)) - 1, tocolor(0, 0, 0, 255), 1, false)
- dxDrawRectangle(sW * 0.0609, sH * (0.0139+ webHeight), sW * 0.8906, sH * 0.0403, tocolor(241, 241, 241, 255), false)
- dxDrawText(searchBarText, sW * 0.0641, sH * (0.0139+ webHeight), sW * 0.9477, sH * (0.0542+ webHeight), tocolor(0, 0, 0, 255), 1.00, taskBarFont, "left", "bottom", false, false, false, false, false)
- dxDrawImage(sW * 0.9672, sH * (0.0111+ webHeight), sW * 0.0250, sH * 0.0444, ":arpg_images_web/closeWeb.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
- if availableWebPages[webPage] then
- if webPage == "americaweb://main" then
- dxDrawImage(sW * 0.4000, sH * (0.0722+ webHeight), sW * 0.2000, sH * 0.3556, ":arpg_images_global/logoA.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
- dxDrawText("WEB", sW * 0.4453, sH * (0.3347+ webHeight), sW * 0.5531, sH * (0.3792+ webHeight), tocolor(127, 127, 127, 255), 1.00, mainPageFont, "center", "center", false, false, false, false, false)
- elseif webPage == "americaweb://guide" then
- dxDrawImage(sW * 0.4000, sH * (0.0322+ webHeight), sW * 0.2000, sH * 0.3556, ":arpg_images_global/logoA.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
- dxDrawText("PRZEWODNIK", sW * 0.4453, sH * (0.2947+ webHeight), sW * 0.5531, sH * (0.3392+ webHeight), tocolor(127, 127, 127, 255), 1.00, mainPageFont, "center", "center", false, false, false, false, false)
- local buttonColor = tocolor(0, 131, 255, 255)
- if isMouseInPosition(sW * 0.4359, sH *(0.3347 + webHeight), sW * 0.1250, sH * 0.0444) and buttonColor == tocolor(0, 131, 255, 255) and guideButtonStartTick then
- local animationProgress = (getTickCount() - guideButtonStartTick) / 1000
- local buttonColor_r, buttonColor_g, buttonColor_b = interpolateBetween(0, 131, 255, 17, 153, 87, animationProgress, "Linear")
- buttonColor = tocolor(buttonColor_r, buttonColor_g, buttonColor_b, 255)
- outputChatBox(animationProgress)
- if animationProgress >= 1 then
- animationProgress = nil
- guideButtonStartTick = nil
- buttonColor = tocolor(17, 153, 87, 255)
- end
- end
- dxDrawImage(sW * 0.4359, sH *(0.3347 + webHeight), sW * 0.1250, sH * 0.0444, ":arpg_images_global/buttonTemplate.png", 0, 0, 0, buttonColor, false)
- elseif webPage == "custom" then
- dxDrawImage(sW * 0.4000, sH * (0.0722+ webHeight), sW * 0.2000, sH * 0.3556, ":arpg_images_global/logoA.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
- dxDrawText("Loading... ", sW * 0.4453, sH * (0.3347+ webHeight), sW * 0.5531, sH * (0.3792+ webHeight), tocolor(127, 127, 127, 255), 1.00, mainPageFont, "center", "center", false, false, false, false, false)
- dxDrawImage(sW * 0, sH * 0.0694, sW * 1, sH * 0.9306, browser)
- end
- end
- if searchBarSelected and backspaceTicks and getTickCount()-backspaceTicks > 75 and getKeyState("backspace") then
- local text = searchBarText
- local result = string.sub(text, 0, string.len(text)-1)
- backspaceTicks = getTickCount()
- searchBarText = result
- end
- end
- function onClick(button, state)
- if button == "left" and state == "down" then
- if isMouseInPosition(sW * -0.0070, sH * (-0.0125+ webHeight), sW * 0.0500, sH * 0.0889) then
- webPage = "americaweb://main"
- searchBarText = webPage
- end
- if isMouseInPosition(sW * 0.0609, sH * (0.0139+ webHeight), sW * 0.8906, sH * 0.0403) then
- searchBarSelected = true
- elseif not isMouseInPosition(sW * 0.0609, sH * (0.0139+ webHeight), sW * 0.8906, sH * 0.0403) then
- searchBarSelected = false
- end
- end
- end
- addEventHandler('onClientClick', root, onClick)
- function onCharacter(key)
- if searchBarSelected and key then
- local text = tostring(searchBarText)
- local result = text .. key
- searchBarText = result
- end
- end
- addEventHandler("onClientCharacter", root, onCharacter)
- function onKey(button, press)
- if searchBarSelected and button == "backspace" and press then
- local text = tostring(searchBarText)
- local result = string.sub(text, 0, string.len(text)-1)
- backspaceTicks = getTickCount()
- searchBarText = result
- elseif searchBarSelected and button == "enter" and press then
- if tostring(searchBarText) ~= "" then
- if searchBarText == "americaweb://main" then
- webPage = "americaweb://main"
- searchBarText = webPage
- if browser then browser = nil end
- elseif searchBarText == "americaweb://guide" then
- webPage = "americaweb://guide"
- searchBarText = webPage
- guideButtonStartTick = getTickCount()
- if browser then browser = nil end
- else
- webPage = "custom"
- if browser then browser = nil end
- browser = createBrowser(sW * 1, sH * 0.9306, false)
- addEventHandler( "onClientBrowserCreated", browser, function( )
- loadBrowserURL(source, tostring(searchBarText))
- end)
- end
- end
- end
- end
- addEventHandler("onClientKey", root, onKey)
- function createWeb(page)
- assert(page, "Brakujący argument 'page' w funkcji createWeb.")
- if type(page) ~= 'string' then outputDebugString("Zły argument @ 'createWeb' [Powinnien być string w argumencie 1, jest "..type(page).."]", 2) return false end
- if not availableWebPages[page] then outputDebugString("nie znaleziono takiej strony.", 1) return false end
- webPage = page
- searchBarText = webPage
- startTick = getTickCount()
- showCursor(true)
- showChat(false)
- addEventHandler('onClientRender', root, renderWeb)
- end
- addEvent('createWeb', true)
- addEventHandler('createWeb', root, createWeb)
- function changeBrowser(...)
- webPage = "custom"
- searchBarText = link
- browser = createBrowser(sW * 0.9555, sH * 0.9306, false)
- loadBrowserURL(browser, tostring(link))
- end
- addCommandHandler('browser', changeBrowser)
- function destroyWeb()
- end
- addEvent('destroyWeb', true)
- createWeb("americaweb://main")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement