Jump to content

xmlNodeGetValue and Dx functions


botshara

Recommended Posts

Hello!

Im getting a huge fps drop when I use xmlNodeGetValue in dxDrawText. From 60 fps to 7 fps.

Here is my code example. Btw I use library to make GUIs.

xmlRules = xmlLoadFile( "commands/rules.xml" )

function testMyGui()
	help_window = interface:dxCreateWindow(x, y, width, height, tocolor(0, 0, 0, 125), false, "Help panel", (35/1080)*sy, tocolor(0, 0, 0, 225), tocolor(255, 255, 255, 255), nil)
	interface:dxAddBorder(help_window, "bottom", tocolor(255, 102, 255), 1)
	interface:setActiveGUI(help_window)
	interface:dxSetMovable(help_window, true)
	local tabPanel = interface:dxCreateTabPanel(0.025, 0.15, 0.95, 0.8, width*0.1521, true, help_window, tocolor(0, 0, 0, 125))
		
	local tabRules = interface:dxCreateTab(tabPanel, "Rules", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))

	local RulesBox = interface:dxCreateTextWindow(0.025, 0.05, 0.95, 0.9, true, tabRules, tocolor(0, 0, 0, 100), tocolor(255,0,0,255), tocolor(0,255,0,255), false)
	interface:dxTextWindowAddText(RulesBox, xmlNodeGetValue( xmlRules  ), tocolor(255, 255, 255, 255))

	local tabOverview = interface:dxCreateTab(tabPanel, "Command usage", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
	local tabCommands = interface:dxCreateTab(tabPanel, "All comannds", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
end
addEventHandler("onClientResourceStart", getRootElement(), testMyGui)

 

Link to post

Well of course, those functions are not meant to be used every frame.

Just simply store the text in a variable and use that in the render handler instead.

xmlRules = xmlNodeGetValue(xmlLoadFile("commands/rules.xml")) --store the text and not the node (btw. you should check if the file exists first)

function testMyGui()
	help_window = interface:dxCreateWindow(x, y, width, height, tocolor(0, 0, 0, 125), false, "Help panel", (35/1080)*sy, tocolor(0, 0, 0, 225), tocolor(255, 255, 255, 255), nil)
	interface:dxAddBorder(help_window, "bottom", tocolor(255, 102, 255), 1)
	interface:setActiveGUI(help_window)
	interface:dxSetMovable(help_window, true)
	local tabPanel = interface:dxCreateTabPanel(0.025, 0.15, 0.95, 0.8, width*0.1521, true, help_window, tocolor(0, 0, 0, 125))
		
	local tabRules = interface:dxCreateTab(tabPanel, "Rules", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))

	local RulesBox = interface:dxCreateTextWindow(0.025, 0.05, 0.95, 0.9, true, tabRules, tocolor(0, 0, 0, 100), tocolor(255,0,0,255), tocolor(0,255,0,255), false)
	interface:dxTextWindowAddText(RulesBox, xmlRules, tocolor(255, 255, 255, 255)) --show the text

	local tabOverview = interface:dxCreateTab(tabPanel, "Command usage", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
	local tabCommands = interface:dxCreateTab(tabPanel, "All comannds", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
end
addEventHandler("onClientResourceStart", getRootElement(), testMyGui)

 

Link to post
12 minutes ago, MIKI785 said:

Well of course, those functions are not meant to be used every frame.

Just simply store the text in a variable and use that in the render handler instead.


xmlRules = xmlNodeGetValue(xmlLoadFile("commands/rules.xml")) --store the text and not the node (btw. you should check if the file exists first)

function testMyGui()
	help_window = interface:dxCreateWindow(x, y, width, height, tocolor(0, 0, 0, 125), false, "Help panel", (35/1080)*sy, tocolor(0, 0, 0, 225), tocolor(255, 255, 255, 255), nil)
	interface:dxAddBorder(help_window, "bottom", tocolor(255, 102, 255), 1)
	interface:setActiveGUI(help_window)
	interface:dxSetMovable(help_window, true)
	local tabPanel = interface:dxCreateTabPanel(0.025, 0.15, 0.95, 0.8, width*0.1521, true, help_window, tocolor(0, 0, 0, 125))
		
	local tabRules = interface:dxCreateTab(tabPanel, "Rules", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))

	local RulesBox = interface:dxCreateTextWindow(0.025, 0.05, 0.95, 0.9, true, tabRules, tocolor(0, 0, 0, 100), tocolor(255,0,0,255), tocolor(0,255,0,255), false)
	interface:dxTextWindowAddText(RulesBox, xmlRules, tocolor(255, 255, 255, 255)) --show the text

	local tabOverview = interface:dxCreateTab(tabPanel, "Command usage", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
	local tabCommands = interface:dxCreateTab(tabPanel, "All comannds", tocolor(0, 0, 0, 125), nil, tocolor(255, 255, 255, 255))
end
addEventHandler("onClientResourceStart", getRootElement(), testMyGui)

 

still drop

Link to post
20 minutes ago, MIKI785 said:

I see now that it's not actually onClientRender that you're using, so that was never an issue.

I don't see anything wrong with it, the issue is most likely in that 'interface' library.

Yea, looks like problem is in interface script. Interface script store data in setElementData, and use getElementData to display data, maybe there is problem? Desync or something like that.  Bug also happens with shorter text but with smaller fps drop.

Edited by botshara
Link to post

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...