Hello, I am having an issue.
[IMG]http://vxservers.com/help.png[/IMG]
This is what i'm trying to do. On the gray see through derma panel, I want to auto-position each tab automatically. This is my current positioning code.
[code]
tabs = {"", "servers", "shop", "inventory", "stats", "scoreboard"}
for k,v in pairs(tabs) do
if k == 1 then
else
local realv = v
local v = vgui.Create("DButton", hub)
surface.SetFont("AgencyFB")
local getvlength = tostring(realv)
local strspacing = surface.GetTextSize( tabs[k - 1] )
local realvlength = surface.GetTextSize( getvlength )
print(tabs[k-1].. " " ..strspacing)
v:SetPos(k*256 + strspacing, hub:GetTall() - hub:GetTall()/1.5)
v:SetText("")
v:SetSize(string.len(realv)*17, 100)
v.Paint = function()
draw.SimpleTextOutlined(string.upper(realv), "AgencyFB", 0, 0, Color(255, 255, 255, 175), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 1, Color(91, 0, 117))
end
v.DoClick = function()
opentab(realv)
end
hubopened = true
end
end
end
end
[/code]
At
[code]
v:SetPos(k*256 + strspacing, hub:GetTall() - hub:GetTall()/1.5)
[/code]
It "tries" to position the tabs. I want it to add to the default width the width of the string before it (to make up for long string lengths).
Do you want to make them evenly spaced across the width of the screen?
[QUOTE=brandonj4;42473917]Do you want to make them evenly spaced across the width of the screen?[/QUOTE]
Yes, It's not supposed to be cut off. what my concept right now is getting the row's key from the loop, then multiplying that to get a base width between the two, then add the length of the previous (tabs[k - 1]), and add it to the base width, which should evenly distribute them.
[editline]10th October 2013[/editline]
Nevermind, decided to move to a DGrid, much easier and cleaner.
Sorry, you need to Log In to post a reply to this thread.