/
dpaneloverlay.lua
89 lines (59 loc) · 2.41 KB
/
dpaneloverlay.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--[[ _
( )
_| | __ _ __ ___ ___ _ _
/'_` | /'__`\( '__)/' _ ` _ `\ /'_` )
( (_| |( ___/| | | ( ) ( ) |( (_| |
`\__,_)`\____)(_) (_) (_) (_)`\__,_)
DPanelOverlay
--]]
local InnerCorner8 = surface.GetTextureID( "gui/icorner8" )
local PANEL = {}
AccessorFunc( PANEL, "m_Color", "Color" )
AccessorFunc( PANEL, "m_Type", "Type" )
--[[---------------------------------------------------------
-----------------------------------------------------------]]
function PANEL:Init()
self:SetColor( Color( 255, 255, 255, 255 ) )
self:SetMouseInputEnabled( false )
self:SetKeyboardInputEnabled( false )
self:SetType( 1 )
end
function PANEL:PaintInnerCorners( size )
local w, h = self:GetSize();
surface.SetTexture( InnerCorner8 );
surface.DrawTexturedRectRotated( size*0.5, size*0.5, size, size, 0 )
surface.DrawTexturedRectRotated( w-size*0.5, size*0.5, size, size, -90 )
surface.DrawTexturedRectRotated( w-size*0.5, h-size*0.5, size, size, 180 )
surface.DrawTexturedRectRotated( size*0.5, h-size*0.5, size, size, 90 )
end
function PANEL:PaintDifferentColours( cola, colb, colc, cold, size )
local w, h = self:GetSize();
surface.SetTexture( InnerCorner8 );
surface.SetDrawColor( cola )
surface.DrawTexturedRectRotated( size*0.5, size*0.5, size, size, 0 )
surface.SetDrawColor( colb )
surface.DrawTexturedRectRotated( w-size*0.5, size*0.5, size, size, -90 )
surface.SetDrawColor( colc )
surface.DrawTexturedRectRotated( w-size*0.5, h-size*0.5, size, size, 180 )
surface.SetDrawColor( cold )
surface.DrawTexturedRectRotated( size*0.5, h-size*0.5, size, size, 90 )
end
--[[---------------------------------------------------------
-----------------------------------------------------------]]
function PANEL:Paint()
self:SetPos( 0, 0 )
self:SetSize( self:GetParent():GetSize() )
surface.SetDrawColor( self.m_Color.r, self.m_Color.g, self.m_Color.b, self.m_Color.a )
if ( self.m_Type == 1 ) then
return self:PaintInnerCorners( 8 )
end
if ( self.m_Type == 2 ) then
return self:PaintInnerCorners( 4 )
end
if ( self.m_Type == 3 ) then
local c = Color( 40, 40, 40, 255 )
return self:PaintDifferentColours( c, c, self.m_Color, self.m_Color, 8 )
end
return true
end
derma.DefineControl( "DPanelOverlay", "", PANEL, "DPanel" )