Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- make the grey box
- local P = {}
- AccessorFunc(P, "m_bkgc", "BackgroundColor")
- AccessorFunc(P, "m_lnc", "LineColor")
- AccessorFunc(P, "m_Border", "BorderSize", FORCE_NUMBER)
- function P:SetTexture(txt)
- if type(txt) == "string" then
- txt = surface.GetTextureID(txt)
- elseif type(txt) ~= "number" then
- txt = -1
- end
- self.m_Texture = txt
- end
- function P:GetTexture() return self.m_Texture end
- AccessorFunc(P, "m_txtc", "TextureColor")
- AccessorFunc(P, "m_btnsp", "ButtonSpacing")
- function P:GetButtons()
- return m_btns
- end
- function P:Init()
- local W, H = ScrW(), ScrH()
- local w, h = W/3, H/5
- local x, y = W-w, H-h
- self.m_btns = {}
- self:SetSize(w, h)
- self:SetPos(x, y)
- self:SetBorderSize(0)
- self:SetBackgroundColor(Color(0, 0, 0, 200))
- self:SetLineColor(Color(100, 100, 100, 255))
- self:SetTextureColor(Color(150,150,150, 75))
- self:SetTexture"gui/center_gradient"
- self:SetButtonSpacing(20)
- end
- function P:Paint()
- local w, h = self:GetSize()
- draw.RoundedBox(self:GetBorderSize(), 0, 0, w, h, self:GetBackgroundColor())
- do local c = self:GetLineColor()
- surface.SetDrawColor(c.r, c.g, c.b, c.a)
- end
- surface.DrawOutlinedRect(0, 0, w, h)
- surface.SetTexture(self:GetTexture())
- do local c = self:GetTextureColor()
- surface.SetDrawColor(c.r, c.g, c.b, c.a)
- end
- surface.DrawTexturedRect(0, 0, w, h)
- return true
- end
- function P:AddButton(btn)
- table.insert(self.m_btns, btn)
- btn:SetParent(self)
- self:InvalidateLayout()
- end
- function P:PerformLayout()
- local w, h = self:GetSize()
- local space = self:GetButtonSpacing()
- local bw = (w - space * (1 + #self.m_btns)) / #self.m_btns
- local bt = h - space * 2
- for i, btn in ipairs(self.m_btns) do
- btn:SetPos(space * i + bw * (i-1), space)
- btn:SetSize(bw, bt)
- end
- end
- vgui.Register("sunControlPanel", P, "DPanel")
- local ButtonInfo = {
- {mat = "VGUI/entities/npc_hunter", func = function(btn) print"ASD" end},
- {mat = "VGUI/entities/npc_combine_s", func = function(btn) print"SDS" end},
- {mat = "VGUI/entities/npc_metropolice", func = function(btn) print"FGD" end}
- }
- hook.Add("InitPostEntity", "sunrisedev", function()
- local basePanel = vgui.Create"sunControlPanel"
- for i, bdata in ipairs(ButtonInfo) do
- local btn = vgui.Create("DImageButton")
- btn:SetMaterial(bdata.mat)
- btn.DoClick = bdata.func
- basePanel:AddButton(btn)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement