fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

BkacjiosMake classes a bit easier to understand and setup. Moved GUI related textures to their own folder.7180fb3

settings-overhaul
1.0 KiB52 linesraw
1local PANEL = class.create("ContextMenu", "Panel")
2
3function PANEL:ContextMenu()
4	self:super() -- Initialize our baseclass
5
6	self.m_tEntries = {}
7
8	self:SetWidth(128 + 32)
9	self:MakePopup()
10end
11
12function PANEL:OnFocusChanged(b)
13	-- Remove on focus lost
14	if not b then self:Remove() end
15end
16
17function PANEL:PerformLayout()
18	self:SizeToChildren(false, true)
19end
20
21function PANEL:AddSeperator(height)
22	local entry = self:Add("Panel")
23	entry:SetHeight(height or 4)
24	entry:SetBGColor(color_blank)
25	entry:SetBorderColor(color_blank)
26	entry:DockMargin(0,0,0,0)
27	entry:Dock(DOCK_TOP)
28end
29
30function PANEL:AddEntry(name, callback)
31	local entry = self:Add("Button")
32	entry:SetTextAlignment("left")
33	entry:SetText(name)
34	entry:SetBGColor(color_blank)
35	entry:SetBorderColor(color_blank)
36	entry:DockMargin(0,0,0,0)
37	entry:Dock(DOCK_TOP)
38
39	self.m_tEntries[name] = callback
40
41	entry.OnClick = function(this)
42		self:OnEntryClicked(name, this)
43		if self.m_tEntries[name] then
44			self.m_tEntries[name](panel)
45		end
46	end
47
48	return entry
49end
50
51function PANEL:OnEntryClicked(name, panel)
52end