Hello and thanks for taking the time to read this. I am having issues adding a custom panel I made to a DIconLayout because every time I add several panels to it, it spazes out. I am trying to make a F4 menu. EX:
[IMG]http://images.akamai.steamusercontent.com/ugc/316747301012673586/D75404F5A1E4C490EE7C9FC2819B035A1D976A1F/[/IMG]
Here is the code:
[code]
local display = vgui.Create("DScrollPanel", base)
display:SetSize(w-(p*2), h-bh-(p*2))
display:SetPos(p, bh+(p*2))
display:SetVisible(false)
local pnlDisplay = vgui.Create("DIconLayout", display)
display:SetSize(w-(p*3), h-bh-(p*3))
display:SetPos(0, 0)
pages["Jobs"][1].DoClick = function()
for _, v in ipairs(RPExtraTeams) do
local job = pnlDisplay:Add("SATPGBrowser")
job:SetSize(display:GetWide()-(p*2), display:GetTall()/5)
job:UpdateInfo(v.model[1], v.name, v.description, v.salary)
job:Invalidate()
end
end
[/code]
Here is the code for the panel:
[code]
local p = 6
local PANEL = {}
function PANEL:FormatNumber(n)
if not n then return "" end
if n >= 1e14 then return tostring(n) end
n = tostring(n)
local sep = sep or ","
local dp = string.find(n, "%.") or #n+1
for i=dp-4, 1, -3 do
n = n:sub(1, i) .. sep .. n:sub(i+1)
end
return n
end
function PANEL:Init()
self:SetText("")
self:NoClipping(false)
self.model = vgui.Create("ModelImage", self)
self.title = vgui.Create("DPanel", self)
self.title.txt = ""
self.desc = vgui.Create("DPanel", self)
self.desc.txt = ""
self.price = vgui.Create("DPanel", self)
self.price.value = ""
end
function PANEL:Invalidate()
local w, h = self:GetSize()
local mw = h-12
self:SetVisible(false)
self.model:SetSize(mw, mw)
self.model:SetPos(6, 6)
self.title:SetSize(w-(mw-p), h/4)
self.title:SetPos(((w/2)-(self.title:GetWide()/2))+(mw/2), (h/2)-(h/4)-3)
self.desc:SetSize(w-(mw-p), h/4)
self.desc:SetPos(((w/2)-(self.desc:GetWide()/2))+(mw/2), (h/2)+3)
self.price:SetSize(w-(mw-p), h/4)
self.price:SetPos(((w/2)-(self.desc:GetWide()/2))+(mw/2), h-self.price:GetTall()-p)
self:SetVisible(true)
end
function PANEL:Paint(pnl, w, h)
local w, h = self:GetWide(), self:GetTall()
//draw.RoundedBox(6, 3, 3, w, h, Color(255, 255, 255, 255))
draw.RoundedBox(6, 0, 0, w, h, Color(64, 64, 64, 255))
self.title.Paint = function(pnl, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(255, 255, 255, 0))
draw.SimpleText(self.title.txt, "DermaLarge", 10, h/2, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
self.desc.Paint = function(pnl, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(255, 255, 255, 0))
draw.SimpleText(self.desc.txt, "ChatFont", 10, h/2, Color(255, 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
self.price.Paint = function(pnl, w, h)
draw.RoundedBox(0, 0, 0, w, h, Color(255, 255, 255, 0))
draw.SimpleText(self.price.value, "ChatFont", w/2, h/2, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
end
function PANEL:UpdateInfo(model, title, desc, price, fnc)
self.title.txt = title
self.desc.txt = desc
self.DoClick = fnc
self.price.value = "$" .. self:FormatNumber(price)
self:Invalidate()
self.model:SetModel(model)
end
vgui.Register("SATPGBrowser", PANEL, "DButton")
[/code]
Thanks for any help!
Bump
Not sure if this will help whatsoever, but
[CODE]
job:Invalidate()
[/CODE]
Isn't a real command (at least according to the wiki)
[QUOTE=MPan1;49882970]Not sure if this will help whatsoever, but
[CODE]
job:Invalidate()
[/CODE]
Isn't a real command (at least according to the wiki)[/QUOTE]
probably should be
[code]
InvalidateLayout()
[/code]
[QUOTE=whitestar;49883964]probably should be
[code]
InvalidateLayout()
[/code][/QUOTE]
Its a custom function in the custom panel. Code is in the main post now. Thanks for trying to help! :)
-snip-
Sorry, you need to Log In to post a reply to this thread.