fork/m-overlay

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

BkacjiosMore class changes27686d7

settings-overhaul
1.9 KiB71 linesraw
1local PANEL = class.create("ToolTip", "BasePanel")
2
3PANEL:ACCESSOR("Enabled", "m_bEnabled", true)
4PANEL:ACCESSOR("ArrowX", "m_iArrowX", 0)
5PANEL:ACCESSOR("ArrowY", "m_iArrowY", 0)
6
7PANEL.ToolTipColor = color(240, 240, 240)
8
9function PANEL:ToolTip()
10	self:super() -- Initialize our baseclass
11	self:SetFocusable(false) -- Ignore focus
12
13	self:SetSize(256, 256)
14	self:DockPadding(8, 8, 8, 0)
15
16	self.m_pTitle = self:Add("Label")
17	self.m_pTitle:Dock(DOCK_TOP)
18	self.m_pTitle:SetLineHeight(0.75)
19	self.m_pTitle:SetTextColor(color_red)
20
21	self.m_pBody = self:Add("Label")
22	self.m_pBody:Dock(DOCK_FILL)
23	self.m_pBody:SetWrapped(true)
24	self.m_pBody:SetFont("fonts/melee.otf", 10)
25	self.m_pBody:SetLineHeight(0.75)
26	self.m_pBody:SetPos(8, 16+24)
27	self.m_pBody:SetSize(236, 228)
28end
29
30function PANEL:SetArrowPos(x, y)
31	self.m_iArrowX = x
32	self.m_iArrowY = y
33end
34
35function PANEL:GetArrowPos()
36	return math.max(5, math.min(self:GetWidth() - 5, self.m_iArrowX)), math.max(5, math.min(self:GetHeight() - 5, self.m_iArrowY))
37end
38
39function PANEL:SetTitle(str)
40	self.m_pTitle:SetText(str)
41end
42
43function PANEL:SetBody(str)
44	self.m_pBody:SetText(str)
45	self.m_pBody:HeightToText()
46	self:SizeToChildren(false, true)
47end
48
49function PANEL:Paint(w, h)
50	graphics.setColor(color_black)
51	graphics.roundRect(4, 4, w-8, h-8, 4)
52
53	local s1 = 5.65685424949 -- sqrt(4^2+4^2)
54	local s2 = 7.07106781187 -- sqrt(5^2+5^2)
55
56	graphics.setColor(self.ToolTipColor)
57
58	graphics.push()
59	graphics.translate(self:GetArrowPos()) -- move relative (0,0) to (x,y)
60	graphics.rotate(math.rad(45)) -- rotate coordinate system around relative (0,0) (absolute (x,y))
61
62	graphics.setColor(color_black)
63	graphics.rectangle("fill", -s2/2, -s2/2, s2, s2) -- draw rectangle centered around relative (0,0)
64
65	graphics.setColor(self.ToolTipColor)
66	graphics.rectangle("fill", -s1/2, -s1/2, s1, s1) -- draw rectangle centered around relative (0,0)
67	graphics.pop()
68
69	graphics.setColor(self.ToolTipColor)
70	graphics.roundRect(5, 5, w-10, h-10, 4)
71end