Jump to content

use guiCreateScollPane for dxDrawing


Fist

Recommended Posts

Since gui and dxDrawing are in no relation to each other I think this would be difficult.
I think that using a render target and dxDrawImageSection should work best, combined with the scroll values.
Depending on what exactly you want to do it might be easier to just use guiCreateStaticImage.

Link to comment
local renderTarget = dxCreateRenderTarget(500, 15)
local scrollerW, scrollerH = 20, 3.75 -- scrollerH = Rectangle height / Line count
local fullScrolled = 45 -- (Line count - 1) * dxGetFontHeight(currentSize, currentFont)
local fullSize = 60 -- Line count * dxGetFontHeight(currentSize, currentFont)
local moveY = 0 -- Default offset of Y position
local multiLine = [[This is a multiple line text.
2nd line
3rd line
4th line]]


function dxDraws()
	dxDrawRectangle(500, 200, 200, 15, tocolor(0, 0, 0, 255))
	dxSetRenderTarget(renderTarget, true)
	dxDrawText(multiLine, 0, moveY, 500, 15, tocolor(255, 255, 255, 255), 1)
	dxSetRenderTarget()
	dxDrawImage(500, 200, 500, 15, renderTarget)
	local scrollerPercentage = (-moveY)/fullSize
	dxDrawRectangle(500-scrollerW, 200+scrollerPercentage*15, scrollerW, scrollerH, tocolor(128, 128, 0, 255))
end
addEventHandler("onClientRender", getRootElement(), dxDraws)

addEventHandler("onClientKey", getRootElement(), function(cK, cS)
	if cS then
		if cK == "mouse_wheel_up" then
			outputChatBox(moveY)
			if moveY < 0 then
				moveY = moveY + 1
			end
		elseif cK == "mouse_wheel_down" then
			if moveY > -fullScrolled then -- Added an if statement, so it cannot be scrolled more than it should be.
				moveY = moveY - 1
			end
		end
	end
end)

 

Link to comment
9 minutes ago, NeXuS™ said:

local renderTarget = dxCreateRenderTarget(500, 15)
local scrollerW, scrollerH = 20, 3.75 -- scrollerH = Rectangle height / Line count
local fullScrolled = 45 -- (Line count - 1) * dxGetFontHeight(currentSize, currentFont)
local fullSize = 60 -- Line count * dxGetFontHeight(currentSize, currentFont)
local moveY = 0 -- Default offset of Y position
local multiLine = [[This is a multiple line text.
2nd line
3rd line
4th line]]


function dxDraws()
	dxDrawRectangle(500, 200, 200, 15, tocolor(0, 0, 0, 255))
	dxSetRenderTarget(renderTarget, true)
	dxDrawText(multiLine, 0, moveY, 500, 15, tocolor(255, 255, 255, 255), 1)
	dxSetRenderTarget()
	dxDrawImage(500, 200, 500, 15, renderTarget)
	local scrollerPercentage = (-moveY)/fullSize
	dxDrawRectangle(500-scrollerW, 200+scrollerPercentage*15, scrollerW, scrollerH, tocolor(128, 128, 0, 255))
end
addEventHandler("onClientRender", getRootElement(), dxDraws)

addEventHandler("onClientKey", getRootElement(), function(cK, cS)
	if cS then
		if cK == "mouse_wheel_up" then
			outputChatBox(moveY)
			if moveY < 0 then
				moveY = moveY + 1
			end
		elseif cK == "mouse_wheel_down" then
			if moveY > -fullScrolled then -- Added an if statement, so it cannot be scrolled more than it should be.
				moveY = moveY - 1
			end
		end
	end
end)

 

Well, i already figured out another way. But thanks anyway mate. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...