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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
local surface = surface
local Color = Color
local mskin = SKIN
SKIN = {}
setmetatable(SKIN,{__index = mskin})
SKIN.PrintName = "Golden Skin"
SKIN.Author = "Apickx"
SKIN.DermaVersion = 1
SKIN.GwenTexture = Material("golden.png")
local gctn = GWEN.CreateTextureNormal
--Panel
SKIN.tex.Panels.tl = gctn(0,0,32,32)
SKIN.tex.Panels.t = gctn(32,0,32,32)
SKIN.tex.Panels.tr = gctn(64,0,32,32)
SKIN.tex.Panels.ml = gctn(0,32,32,32)
SKIN.tex.Panels.m = gctn(32,32,32,32)
SKIN.tex.Panels.mr = gctn(64,32,32,32)
SKIN.tex.Panels.bl = gctn(0,64,32,32)
SKIN.tex.Panels.bm = gctn(32,64,32,32)
SKIN.tex.Panels.br = gctn(64,64,32,32)
--Button up
SKIN.tex.bu = {}
SKIN.tex.bu.left = gctn(0,96,24,24)
SKIN.tex.bu.mid = gctn(24,96,24,24)
SKIN.tex.bu.right = gctn(48,96,24,24)
SKIN.tex.bu.left_b = gctn(0,224,48,24)
--Button down
SKIN.tex.bd = {}
SKIN.tex.bd.left = gctn(0,120,24,24)
SKIN.tex.bd.mid = gctn(24,120,24,24)
SKIN.tex.bd.right = gctn(48,120,24,24)
SKIN.tex.bd.left_b = gctn(0,200,48,24)
--Frame
SKIN.tex.fr = {}
SKIN.tex.fr.tl = gctn(0,144,32,56)
SKIN.tex.fr.t = gctn(32,144,32,56)
SKIN.tex.fr.tr = gctn(64,144,32,56)
SKIN.tex.fr.t_b = gctn(92,144,32,56)
SKIN.tex.fr.tr_b = gctn(128,144,32,56)
--Property sheet tab
SKIN.tex.tab = {}
SKIN.tex.tab.right = gctn(96,48,16,32)
SKIN.tex.tab.left = gctn(112,48,16,32)
for k,v in pairs({"down","up"}) do
SKIN.tex.tab[v] = {}
for i,j in pairs({"start","mid","end_c","start_c","end"}) do
local sx = 128 + ((i - 1) * 16)
local sy = 48 + ((k - 1) * 32)
SKIN.tex.tab[v][j] = gctn(sx,sy,16,32)
end
end
-- Progress bar
SKIN.tex.bar = {}
SKIN.tex.bar.back = {}
for k,v in pairs({"start","mid","fin"}) do
SKIN.tex.bar.back[v] = gctn(128 + ((k - 1) * 24),112,24,24)
end
SKIN.tex.bar.fill = {}
for k,v in pairs({"start","mid","fin"}) do
SKIN.tex.bar.fill[v] = gctn(200 + ((k - 1) * 8),112,8,24)
end
--Round buttons
--[[
frame = vgui.Create("DFrame")
frame.Paint = function(s,w,h) GWEN.CreateTextureNormal(0,0,1024,1024)(0,0,w,h) end
frame:SetSize(300,300)
]]
SKIN.tex.buttons = {}
for k,v in pairs({"green","blue","red","gray"}) do
SKIN.tex.buttons[v] = {}
for i,j in pairs({"off","on","down"}) do
local sx = 96 + (16 * (k - 1))
local sy = 16 * (i - 1)
SKIN.tex.buttons[v][j] = gctn(sx, sy, 16, 16)
end
end
SKIN.tex.buttonframe = gctn(72,120,24,24)
-- Button icons
SKIN.tex.icons = {}
for k,v in pairs({
"save",
"search",
"talk",
"plus",
"minus",
"left",
"right",
"check",
"close",
"up",
"down",
"square"
}) do
SKIN.tex.icons[v] = gctn(162 + ((k-1) * 16),0,16,16)
end
-- hook.Add( "HUDPaint", "PaintStuff", function()
-- local i = 1
-- for k,v in pairs(SKIN.tex.bu) do
-- v(i,0,24,24,Color(255,255,255,255))
-- i = i + 24
-- end
-- end )
function SKIN:PaintPanel(panel,w,h)
if not panel.m_bBackground then return end
if w >= 64 and h >= 64 then
self.tex.Panels.tl(0,0,32,32)
self.tex.Panels.t(32,0,w-64,32)
self.tex.Panels.tr(w-32,0,32,32)
self.tex.Panels.ml(0,32,32,h-64)
self.tex.Panels.m(32,32,w-64,h-64)
self.tex.Panels.mr(w-32,32,32,h-64)
self.tex.Panels.bl(0,h-32,32,32)
self.tex.Panels.bm(32,h-32,w-64,32)
self.tex.Panels.br(w-32,h-32,32,32)
end
-- self.tex.Panels.Normal(0,0,w,h,panel.m_bgColor)
end
function SKIN:PaintButton(panel,w,h)
--print("Golden PaintButton called")
local bt = self.tex.bu
if panel.Depressed || panel:IsSelected() || panel:GetToggle() then
bt = self.tex.bd
end
if panel.m_Image then
bt.left_b(0,0,48,h)
bt.mid(48,0,w - 48,h)
bt.right(w - 24,0,24,h)
if panel.Hovered then
self.tex.buttons.blue.on(5,5,16,16)
elseif panel.Depressed || panel:IsSelected() || panel:GetToggle() then
self.tex.buttons.blue.down(5,5,16,16)
else
self.tex.buttons.blue.off(5,5,16,16)
end
else
bt.left(0,0,24,h)
bt.mid(24,0,w-48,h)
bt.right(w-24,0,24,h)
end
end
function SKIN:PaintFrame( panel, w, h )
if ( panel.m_bPaintShadow ) then
DisableClipping( true )
SKIN.tex.Shadow( -4, -4, w+10, h+10 )
DisableClipping( false )
end
self.tex.fr.tl(0,0,32,56)
self.tex.fr.t(32,0,w-(32 * 4),56)
if panel.btnMinim:IsEnabled() then
self.tex.fr.t_b(w - (32 * 3), 0, 32, 56)
else
self.tex.fr.t(w - (32 * 3), 0, 32, 56)
end
if panel.btnMaxim:IsEnabled() then
self.tex.fr.t_b(w - (32 * 2), 0, 32, 56)
else
self.tex.fr.t(w - (32 * 2), 0, 32, 56)
end
if panel.btnClose:IsEnabled() then
self.tex.fr.tr_b(w - 32,0,32,56)
else
self.tex.fr.tr(w - 32,0,32,56)
end
-- The rest of the frame
self.tex.Panels.ml(0,56,32,h - (32 + 56))
self.tex.Panels.m(32,56,w-64,h - (32 + 56))
self.tex.Panels.mr(w-32,56,32,h - (32 + 56))
self.tex.Panels.bl(0,h-32,32,32)
self.tex.Panels.bm(32,h-32,w-64,32)
self.tex.Panels.br(w-32,h-32,32,32)
-- if ( panel:HasHierarchicalFocus() ) then
--
-- --self.tex.Window.Normal( 0, 0, w, h )
--
-- else
--
-- --self.tex.Window.Inactive( 0, 0, w, h )
--
-- end
end
--Helper function for frame buttons
local function draw_colored_button(panel,w,h,t,x,y)
x = x or 0
y = y or 0
if ( panel.Depressed || panel:IsSelected() ) then
t.down(x,y,w,h)
elseif ( panel.Hovered ) then
t.on( x, y, w, h )
else
t.off( x, y, w, h )
end
end
function SKIN:PaintWindowCloseButton( panel, w, h )
if ( panel:GetDisabled() ) then return end
draw_colored_button(panel,w,h,self.tex.buttons.red)
self.tex.icons.close(0,0,w,h)
end
function SKIN:PaintWindowMinimizeButton( panel, w, h )
if ( panel:GetDisabled() ) then return end
draw_colored_button(panel,w,h,self.tex.buttons.blue)
self.tex.icons.minus(0,0,w,h)
end
function SKIN:PaintWindowMaximizeButton( panel, w, h )
if ( panel:GetDisabled() ) then return end
draw_colored_button(panel,w,h,self.tex.buttons.blue)
self.tex.icons.square(0,0,w,h, tbt)
end
function SKIN:PaintPropertySheet( panel, w, h )
-- local ActiveTab = panel:GetActiveTab()
-- local Offset = 0
-- if ( ActiveTab ) then Offset = ActiveTab:GetTall() - 8 end
--self.tex.Tab_Control( 0, Offset, w, h-Offset )
end
function SKIN:PaintTab( panel, w, h )
local tp
if ( panel:IsActive() ) then
tp = self.tex.tab.down
else
tp = self.tex.tab.up
end
local sf,mf,ef
mf = tp.mid
if panel:IsFirst() then
sf = tp.start
ef = tp.end_c
elseif panel:IsLast() then
sf = tp.start_c
ef = tp["end"] --Bad field name choice
else
sf = tp.start_c
ef = tp.end_c
end
sf(0,0,16,32)
mf(16,0,w-32,32)
ef(w-16,0,16,32)
end
function SKIN:PaintButtonLeft( panel, w, h )
if ( !panel.m_bBackground ) then return end
draw_colored_button(panel,16,16,self.tex.buttons.blue,4,4)
self.tex.icons.left(4,4,16,16)
self.tex.buttonframe(0,0,24,24)
end
function SKIN:PaintButtonRight( panel, w, h )
if ( !panel.m_bBackground ) then return end
draw_colored_button(panel,16,16,self.tex.buttons.blue,4,4)
self.tex.icons.right(4,4,16,16)
self.tex.buttonframe(0,0,24,24)
end
function SKIN:PaintMenuRightArrow( panel, w, h )
self.tex.tab.right(0,0,w,h)
end
function SKIN:PaintMenuLeftArrow( panel, w, h)
self.tex.tab.left(0,0,w,h)
end
--Progressbar
function SKIN:PaintProgress(panel, w,h)
self.tex.bar.back.start(0,0,24,h)
self.tex.bar.back.mid(24,0,w-48,h)
self.tex.bar.back.fin(w-24,0,24,h)
local barlen = (w - 18) * panel:GetFraction()
self.tex.bar.fill.start(9,0,8,h)
if barlen > 8 then
self.tex.bar.fill.fin(barlen-8 + 9,0,8,h)
if barlen > 16 then
self.tex.bar.fill.mid(8 + 9,0,barlen - 16 + 9,h)
end
end
-- self.tex.ProgressBar.Back( 0, 0, w, h )
-- self.tex.ProgressBar.Front( 0, 0, w * panel:GetFraction(), h )
end
function SKIN:PaintScrollBarGrip(panel, width, height)
draw.RoundedBox(0, 0, 0, width, height, Color(0, 0, 0, 200))
end
-- SKIN.PaintButtonDown = SKIN.PaintButton
-- SKIN.PaintButtonUp = SKIN.PaintButton
-- SKIN.PaintButtonLeft = SKIN.PaintButton
-- SKIN.PaintButtonRight = SKIN.PaintButton
print("Golden skin defined")
derma.DefineSkin( "Golden", "Media Acie ", SKIN )
--Change some elements to work with the new skin visuals
--Frame
do
local dframetbl = vgui.GetControlTable("DFrame")
local odfpl = dframetbl.PerformLayout
function dframetbl:PerformLayout()
odfpl(self)
self.btnClose:SetPos( self:GetWide() - 26, 4 )
self.btnClose:SetSize( 16, 16 )
self.btnMaxim:SetPos(self:GetWide() - 32 - 26, 4)
self.btnMaxim:SetSize( 16, 16)
self.btnMinim:SetPos(self:GetWide() - 64 - 26, 4)
self.btnMinim:SetSize( 16, 16)
self.lblTitle:SetPos(8,4)
end
local odfpi = dframetbl.Init
function dframetbl:Init()
odfpi(self)
self:DockPadding(6,58-32+6,6,6)
end
end
--Panel
do
local dpaneltbl = vgui.GetControlTable("DPanel")
local odpi = dpaneltbl.Init
function dpaneltbl:Init()
odpi(self)
self:DockPadding(6,6,6,6)
end
end
--[[
frame = vgui.Create("DFrame")
frame:SetSize(300,300)
vsheet = vgui.Create("DPropertySheet",frame)
vsheet:Dock(FILL)
for i = 1,10 do
vsheet:AddSheet("Sheet " .. tostring(i), vgui.Create("DPanel"))
end
]]
--Property sheet
do
local dproptbl = vgui.GetControlTable("DPropertySheet")
end
--DTab
do
local dtab = vgui.GetControlTable("DTab")
function dtab:GetPosition()
local vsheet = self:GetPropertySheet()
for i = 1,#vsheet.Items do
if vsheet.Items[i].Tab == self then
return i
end
end
end
function dtab:IsFirst()
return self:GetPosition() == 1
end
function dtab:IsLast()
local vsheet = self:GetPropertySheet()
return self:GetPosition() == #vsheet.Items
end
end
--Horizontal scroller
do
local dhs = vgui.GetControlTable("DHorizontalScroller")
local odhspl = dhs.PerformLayout
function dhs:PerformLayout()
odhspl(self)
self.btnLeft:SetSize(24,24)
self.btnRight:SetSize(24,24)
self.btnRight:AlignTop(0)
self.btnRight:AlignRight(0)
self.btnLeft:AlignTop(0)
self.btnLeft:AlignLeft(0)
end
end
--Detour vgui.Create to always use golden skin
local ovgc = vgui.Create
function vgui.Create(...)
local r = ovgc(...)
r:SetSkin("Golden")
return r
end
|