-
Notifications
You must be signed in to change notification settings - Fork 2
/
EndRoundMusic.lua
869 lines (583 loc) · 21.2 KB
/
EndRoundMusic.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
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
if ( SERVER ) then
--[[
Set up sound tables here.
Must be in the format of { "url", "Artist - Songname" }
Make sure to add commas between table entries, and don't put a comma on the last entry.
--]]
innowinsounds = {
}
traitorwinsounds = {
}
timelimitsounds = {
}
extrasounds = {
}
end
if ( CLIENT ) then
MsgN( "End Round Music by Cobalt loaded!" )
end
-- ULX Commands
function ulx.playurl( calling_ply, url, volume )
umsg.Start( "playurl", player.GetAll() )
umsg.String( url )
umsg.Long ( volume )
umsg.End()
ulx.fancyLogAdmin( calling_ply, "#A played URL #s (type !stop to stop)", url )
end
local playurl = ulx.command( "Fun", "ulx playurl", ulx.playurl, "!playurl" )
playurl:addParam{ type=ULib.cmds.StringArg, hint="url" }
playurl:addParam{ type=ULib.cmds.NumArg, min=0, max=100, default=50, hint="volume", ULib.cmds.optional, ULib.cmds.round }
playurl:defaultAccess( ULib.ACCESS_ADMIN )
playurl:help( "Play a sound from a URL." )
function ulx.playurlcl( calling_ply, url, volume )
umsg.Start( "playurlcl", calling_ply )
umsg.String( url )
umsg.Long( volume )
umsg.End()
ulx.fancyLog( { calling_ply }, "URL #s playing locally (type !stop to stop)", url )
end
local playurlcl = ulx.command( "Fun", "ulx playurlcl", ulx.playurlcl, "!playurlcl" )
playurlcl:addParam{ type=ULib.cmds.StringArg, hint="url" }
playurlcl:addParam{ type=ULib.cmds.NumArg, min=0, max=100, default=50, hint="volume", ULib.cmds.optional, ULib.cmds.round }
playurlcl:defaultAccess( ULib.ACCESS_ALL )
playurlcl:help( "Play a sound from a URL for yourself." )
function ulx.playvolume( calling_ply, volume )
umsg.Start( "playvolume", player.GetAll() )
umsg.Long( volume )
umsg.End()
ulx.fancyLogAdmin( calling_ply, "#A set volume #s", volume )
end
local playvolume = ulx.command( "Fun", "ulx playvolume", ulx.playvolume, "!playvolume" )
playvolume:addParam{ type=ULib.cmds.NumArg, min=0, max=100, default=50, hint="times", ULib.cmds.optional, ULib.cmds.round }
playvolume:defaultAccess( ULib.ACCESS_ADMIN )
playvolume:help( "Sets the volume." )
function ulx.stopurl( calling_ply )
umsg.Start( "stopurl", player.GetAll() )
umsg.End()
ulx.fancyLogAdmin( calling_ply, "#A stopped the URL for the server" )
end
local stopurl = ulx.command( "Fun", "ulx stopurl", ulx.stopurl, "!stopurl" )
stopurl:defaultAccess( ULib.ACCESS_ADMIN )
stopurl:help( "Play a sound from a URL." )
function ulx.endroundmenu( calling_ply )
umsg.Start( "open_endround_menu", calling_ply )
umsg.End()
end
local endroundmenu = ulx.command( "Fun", "ulx endroundmenu", ulx.endroundmenu, "!endround" )
endroundmenu:defaultAccess( ULib.ACCESS_ALL )
endroundmenu:help( "Open the end round music menu." )
function ulx.queuesong( calling_ply )
if calling_ply:GetPData( "Cooldown" ) and tonumber( calling_ply:GetPData( "Cooldown" ) ) > 0 then
calling_ply:ChatPrint( "You are unable to queue a song right now. Try again in " .. calling_ply:GetPData( "Cooldown" ) .. " minute(s)." )
return
end
umsg.Start( "EnterInfo", calling_ply )
umsg.End()
end
local queuesong = ulx.command( "Fun", "ulx queuesong", ulx.queuesong, { "!queuesong", "!queue" } )
queuesong:defaultAccess( ULib.ACCESS_ADMIN )
queuesong:help( "Queue a song for the end of the round." )
function ulx.stopurlcl( calling_ply )
umsg.Start( "stopurl", calling_ply )
umsg.End()
end
local stopurlcl = ulx.command( "Fun", "ulx stopurlcl", ulx.stopurlcl, { "!stop", "!stopurlcl" } )
stopurlcl:defaultAccess( ULib.ACCESS_ALL )
stopurlcl:help( "Stop sounds for yourself." )
-- Serverside Networking
if ( SERVER ) then
util.AddNetworkString( "RequestTables" )
util.AddNetworkString( "RequestTablesCallback" )
util.AddNetworkString( "SendQueueInfo" )
util.AddNetworkString( "RequestQueue" )
util.AddNetworkString( "RequestQueueCallback" )
util.AddNetworkString( "Queue_Remove" )
util.AddNetworkString( "SendCooldownInfo" )
local QueueTable = {}
if GetConVar( "gamemode" ):GetString() == "terrortown" then
hook.Add( "TTTEndRound", "PlayMusicOnEndRound", function( win )
if table.Count( QueueTable ) > 0 then
local toPlay = QueueTable[ 1 ]
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 3 ] )
umsg.Long ( 50 )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
ulx.fancyLog( player.GetAll(), "Playing queued song #s requested by #s", toPlay[ 2 ], toPlay[ 1 ] )
table.remove( QueueTable, 1 )
else
if win == WIN_INNOCENT then
local toPlay = table.Random( innowinsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.Long ( 50 )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
elseif win == WIN_TRAITOR then
local toPlay = table.Random( traitorwinsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.Long ( 50 )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
elseif win == WIN_TIMELIMIT then
local toPlay = table.Random( timelimitsounds )
umsg.Start( "playurl", player.GetAll() )
umsg.String( toPlay[ 1 ] )
umsg.Long ( 50 )
umsg.End()
umsg.Start( "SendSongName", player.GetAll() )
umsg.String( toPlay[ 2 ] )
umsg.End()
end
end
end )
hook.Add( "TTTPrepareRound", "StopSounds", function()
umsg.Start( "stop_preround", player.GetAll() )
umsg.End()
umsg.Start( "StopHUDPaint", player.GetAll() )
umsg.End()
end )
end
concommand.Add( "endround_menu", function( ply, cmd, args )
umsg.Start( "open_endround_menu", ply )
umsg.End()
end )
net.Receive( "RequestTables", function( len, ply )
net.Start( "RequestTablesCallback" )
net.WriteTable( innowinsounds )
net.WriteTable( traitorwinsounds )
net.WriteTable( timelimitsounds )
net.WriteTable( extrasounds )
net.Send( ply )
end )
net.Receive( "SendQueueInfo", function( len, ply )
local sName = net.ReadString()
local sUrl = net.ReadString()
if sName:len() > 0 and sUrl:len() > 0 then
table.insert( QueueTable, { ply:Nick(), sName, sUrl } )
end
ulx.fancyLog( player.GetAll(), "#s queued song #s", ply:Nick(), sName )
end )
net.Receive( "RequestQueue", function( len, ply )
if ply:IsValid() then
net.Start( "RequestQueueCallback" )
net.WriteTable( QueueTable )
net.Send( ply )
end
end )
net.Receive( "Queue_Remove", function( len, ply )
if not ply:IsAdmin() then
ply:ChatPrint( "You don't have access to this command, " .. ply:Nick() .. "!" )
return
end
local name = net.ReadString()
local pos = net.ReadDouble()
table.remove( QueueTable, pos )
ulx.fancyLog( player.GetAll(), "#s removed song #s from the queue", ply:Nick(), name )
end )
net.Receive( "SendCooldownInfo", function( len, ply )
ply:SetPData( "Cooldown", 3 )
end )
timer.Create( "CooldownTimer", 60, 0, function()
for k, v in pairs( player.GetAll() ) do
if v:GetPData( "Cooldown" ) and tonumber( v:GetPData( "Cooldown" ) ) > 0 then
if tonumber( v:GetPData( "Cooldown" ) ) - 1 == 0 then
v:RemovePData( "Cooldown" )
v:ChatPrint( "You are now able to request a song again." )
else
v:SetPData( "Cooldown", tonumber( v:GetPData( "Cooldown" ) ) - 1 )
end
end
end
end )
end
-- Clientside networking and GUI
if ( CLIENT ) then
CreateClientConVar( "ttt_eor_music_enabled", "1", FCVAR_ARCHIVE )
if not file.Exists( "radio", "DATA" ) then
file.CreateDir( "radio" )
end
if not file.Exists( "radio/stations.txt", "DATA" ) then
file.Write( "radio/stations.txt" )
end
usermessage.Hook( "playurlcl", function( um )
local url = um:ReadString()
local volume = um:ReadLong() / 100
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:Stop()
end
sound.PlayURL( url, "", function( station )
if station and IsValid( station ) then
station:Play()
LocalPlayer().channel = station
LocalPlayer().channel:SetVolume(volume)
end
end )
end )
usermessage.Hook( "playurl", function( um )
local url = um:ReadString()
local volume = um:ReadLong() / 100
local isEOR = um:ReadBool()
if isEOR == true and GetConVar( "ttt_eor_music_enabled" ):GetInt() == 0 then
return
end
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:Stop()
end
sound.PlayURL( url, "", function( station )
if station and IsValid( station ) then
station:Play()
LocalPlayer().channel = station
LocalPlayer().channel:SetVolume(volume)
end
end )
end )
usermessage.Hook( "playvolume", function( um )
local volume = um:ReadLong() / 100
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:SetVolume(volume)
end
end )
usermessage.Hook( "stopurl", function( um )
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:Stop()
chat.AddText( "Sound stopped." )
else
chat.AddText( "No music playing!" )
end
end )
usermessage.Hook( "SendSongName", function( um )
local name = um:ReadString()
hook.Add( "HUDPaint", "DrawSongName", function()
local width
if string.len( name ) >= 15 then
width = 18 * string.len( name )
else
width = 270
end
draw.WordBox( 8, 5, 5, "Now Playing: " .. name, "Trebuchet24", Color( 0, 0, 0, 100 ), Color( 255, 255, 255, 200 ) )
end )
end )
usermessage.Hook( "StopHUDPaint", function( um )
hook.Remove( "HUDPaint", "DrawSongName" )
end )
usermessage.Hook( "stop_preround", function( um )
if GetConVar( "ttt_eor_music_enabled" ):GetInt() == 0 then
return
end
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:Stop()
end
end )
usermessage.Hook( "EnterInfo", function()
local name = ""
local url = ""
Derma_StringRequest(
"Request Song",
"Enter the artist and song title",
"",
function( text )
name = text
if text:len() >= 10 then
Derma_StringRequest(
"Request Song",
"Enter the .mp3 URL of the song",
"",
function( text2 )
if string.sub( text2, 1, 4 ) == "http" then
url = text2
net.Start( "SendQueueInfo" )
net.WriteString( name )
net.WriteString( url )
net.SendToServer()
net.Start( "SendCooldownInfo" )
net.SendToServer()
else
chat.AddText( "Invalid URL!" )
end
end,
function()
chat.AddText( "Song Queue Canceled." )
end,
"Finish"
)
else
chat.AddText( "This text must be ten or more characters." )
end
end,
function()
chat.AddText( "Song Queue Canceled." )
end,
"Next"
)
end )
usermessage.Hook( "open_endround_menu", function()
local main = vgui.Create( "DFrame" )
main:SetPos( 50,50 )
main:SetSize( 700, 500 )
main:SetTitle( "End Round Music Menu" )
main:SetVisible( true )
main:SetDraggable( true )
main:ShowCloseButton( true )
main:MakePopup()
main:Center()
local PropertySheet = vgui.Create( "DPropertySheet", main )
PropertySheet:SetPos( 0, 25 )
PropertySheet:SetSize( 700, 475 )
local ulist = vgui.Create( "DListView", PropertySheet )
ulist:SetPos( 4, 27 )
ulist:SetSize( 692, 469 )
ulist:SetMultiSelect( false )
ulist:AddColumn( "Type" ):SetMaxWidth( 40 )
ulist:AddColumn( "Song Title" ):SetMaxWidth( 275 )
ulist:AddColumn( "URL" )
net.Start( "RequestTables" )
net.SendToServer()
net.Receive( "RequestTablesCallback", function()
local innowinsound = net.ReadTable()
local traitorwinsound = net.ReadTable()
local timelimitsound = net.ReadTable()
local extrasound = net.ReadTable()
ulist:Clear()
for k, v in ipairs( innowinsound ) do
ulist:AddLine( "Inno", v[ 2 ], v[ 1 ] )
end
for k, v in ipairs( traitorwinsound ) do
ulist:AddLine( "Trator", v[ 2 ], v[ 1 ] )
end
for k, v in ipairs( timelimitsound ) do
ulist:AddLine( "Time", v[ 2 ], v[ 1 ] )
end
if table.Count( extrasound ) > 0 then
for k, v in ipairs( extrasound ) do
ulist:AddLine( "Extra", v[ 2 ], v[ 1 ] )
end
end
end )
ulist.OnRowRightClick = function( main, line )
local menu = DermaMenu()
menu:AddOption( "Play for all", function()
RunConsoleCommand( "ulx", "playurl", ulist:GetLine( line ):GetValue( 3 ) )
end ):SetIcon( "icon16/control_play_blue.png" )
menu:AddOption( "Play for self", function()
RunConsoleCommand( "ulx", "playurlcl" , ulist:GetLine( line ):GetValue( 3 ) )
end ):SetIcon( "icon16/control_play.png")
menu:AddOption( "Stop all sounds", function()
RunConsoleCommand( "ulx", "stopurl" )
end ):SetIcon( "icon16/control_stop_blue.png" )
menu:AddOption( "Stop sounds for self", function()
local ply = LocalPlayer()
if ply.channel and IsValid( ply.channel ) then
ply.channel:Stop()
chat.AddText( "Sound stopped." )
else
chat.AddText( "No music playing!" )
end
end ):SetIcon("icon16/control_stop.png")
menu:AddOption( "Queue Song", function()
if ULib.ucl.query( LocalPlayer(), "ulx queuesong" ) then
net.Start( "SendQueueInfo" )
net.WriteString( ulist:GetLine( line ):GetValue( 2 ) )
net.WriteString( ulist:GetLine( line ):GetValue( 3 ) )
net.SendToServer()
net.Start( "SendCooldownInfo" )
net.SendToServer()
else
chat.AddText( "You don't have access to this command!" )
end
end ):SetIcon( "icon16/table_row_insert.png" )
menu:Open()
end
PropertySheet:AddSheet( "Music", ulist, "icon16/music.png", false, false, "Show all songs in the webserver" )
local queuetab = vgui.Create( "DPanel", PropertySheet )
queuetab:SetPos( 4, 27 )
queuetab:SetSize( 692, 469 )
local queue = vgui.Create( "DListView", queuetab )
queue:SetPos( 4, 4 )
queue:SetSize( 572, 431 )
queue:SetMultiSelect( false )
queue:AddColumn( "User" )
queue:AddColumn( "Song Title" )
queue:AddColumn( "URL" )
queue:SetSortable( false )
net.Start( "RequestQueue" )
net.SendToServer()
net.Receive( "RequestQueueCallback", function()
local queuetab = net.ReadTable()
queue:Clear()
for k, v in ipairs( queuetab ) do
queue:AddLine( v[ 1 ], v[ 2 ], v[ 3 ] )
end
end )
queue.OnRowRightClick = function( main, line, number )
local menu = DermaMenu()
menu:AddOption( "Play for all", function()
RunConsoleCommand( "ulx", "playurl", queue:GetLine( line ):GetValue( 3 ) )
end ):SetIcon( "icon16/control_play_blue.png" )
menu:AddOption( "Play for self", function()
RunConsoleCommand( "ulx", "playurlcl", queue:GetLine( line ):GetValue( 3 ) )
end ):SetIcon( "icon16/control_play.png" )
menu:AddOption( "Remove", function()
net.Start( "Queue_Remove" )
net.WriteString( queue:GetLine( line ):GetValue( 2 ) )
net.WriteDouble( tonumber( queue:GetSelectedLine( number ) ) )
net.SendToServer()
net.Start( "RequestQueue" )
net.SendToServer()
net.Receive( "RequestQueueCallback", function()
local queuetab = net.ReadTable()
queue:Clear()
for k, v in ipairs( queuetab ) do
queue:AddLine( v[ 1 ], v[ 2 ], v[ 3 ] )
end
end )
end ):SetIcon( "icon16/table_row_delete.png" )
menu:Open()
end
local browse = vgui.Create( "DButton", queuetab )
browse:SetSize( 100, 30 )
browse:SetPos( 580, 4 )
browse:SetText( "Browse .mp3s" )
browse.DoClick = function( browse )
gui.OpenURL( "http://mp3skull.com/" )
end
local q = vgui.Create( "DButton", queuetab )
q:SetSize( 100, 30 )
q:SetPos( 580, 40 )
q:SetText( "Queue a song" )
q.DoClick = function( q )
RunConsoleCommand( "ulx", "queuesong" )
end
PropertySheet:AddSheet( "Queue", queuetab, "icon16/table_go.png", false, false, "View Queued Songs" )
local radio = vgui.Create( "DPanel", PropertySheet )
radio:SetPos( 4, 27 )
radio:SetSize( 692, 469 )
local stations = vgui.Create( "DListView", radio )
stations:SetPos( 4, 4 )
stations:SetSize( 572, 431 )
stations:SetMultiSelect( false )
stations:AddColumn( "Station" )
local toAdd = file.Read( "radio/stations.txt", "DATA" )
if toAdd:len() > 0 then
local tab = string.Explode( "\n", toAdd )
for k, v in ipairs( tab ) do
if v ~= "" then
stations:AddLine( v )
end
end
end
stations.OnRowRightClick = function( main, line, number )
local menu = DermaMenu()
menu:AddOption( "Start Radio", function()
RunConsoleCommand( "ulx", "playurlcl", string.sub( stations:GetLine( line ):GetValue( 1 ), string.find( stations:GetLine( line ):GetValue( 1 ), "|" ) + 2 ) )
end ):SetIcon( "icon16/control_play.png" )
menu:AddOption( "Stop Radio", function()
RunConsoleCommand( "ulx", "stopurlcl" )
end ):SetIcon( "icon16/control_stop.png" )
menu:AddOption( "Copy URL", function()
SetClipboardText( string.sub( stations:GetLine( line ):GetValue( 1 ), string.find( stations:GetLine( line ):GetValue( 1 ), "|" ) + 2 ) )
chat.AddText( "URL Copied." )
end ):SetIcon( "icon16/tag_blue_edit.png" )
menu:AddOption( "Remove Station", function()
chat.AddText( "Station \"" .. string.sub( stations:GetLine( line ):GetValue( 1 ), 1, string.find( stations:GetLine( line ):GetValue( 1 ), "|" ) - 2 ) .. "\" removed." )
stations:RemoveLine( line )
local newTab2 = {}
for k, v in pairs( stations:GetLines() ) do
local url = v:GetValue( 1 )
table.insert( newTab2, url )
end
file.Delete( "radio/stations.txt" )
file.Write( "radio/stations.txt" )
for k, v in pairs( newTab2 ) do
file.Append( "radio/stations.txt", v .. "\n" )
end
stations:Clear()
local toAdd = file.Read( "radio/stations.txt", "DATA" )
if toAdd:len() > 0 then
local tab = string.Explode( "\n", toAdd )
for k, v in ipairs( tab ) do
stations:AddLine( v )
end
end
end ):SetIcon( "icon16/table_row_delete.png" )
menu:Open()
end
local browse = vgui.Create( "DButton", radio )
browse:SetSize( 100, 30 )
browse:SetPos( 580, 4 )
browse:SetText( "Browse Stations" )
browse.DoClick = function( browse )
gui.OpenURL( "http://www.shoutcast.com/" )
end
local add = vgui.Create( "DButton", radio )
add:SetSize( 100, 30 )
add:SetPos( 580, 40 )
add:SetText( "Add Station by URL" )
add.DoClick = function( add )
local name = ""
Derma_StringRequest(
"Add Station",
"Name this station",
"",
function( text )
name = text
Derma_StringRequest(
"Add Station",
"Enter the URL for this station",
"",
function( text2 )
file.Append( "radio/stations.txt", text .. " | " .. text2 .. "\n" )
stations:AddLine( text:Trim() .. " | " .. text2:Trim() )
local newTab = {}
for i = 1, #stations:GetLines() do
local url = stations:GetLine( i ):GetValue( 1 )
table.insert( newTab, url )
end
file.Delete( "radio/stations.txt" )
file.Write( "radio/stations.txt" )
for k, v in pairs( newTab ) do
file.Append( "radio/stations.txt", v .. "\n" )
end
end,
function()
chat.AddText( "Station Add Canceled." )
end,
"Add"
)
end,
function()
chat.AddText( "Station Add Canceled." )
end,
"Next"
)
end
PropertySheet:AddSheet( "Radio", radio, "icon16/sound.png", false, false, "View Radio Stations" )
end )
local function AddSettings( dtabs )
local musicsettings = vgui.Create( "DPanelList", dtabs )
musicsettings:StretchToParent( 0, 0, padding, 0 )
musicsettings:EnableVerticalScrollbar( true )
musicsettings:SetPadding( 10 )
musicsettings:SetSpacing( 10 )
local setting = nil
local Music = vgui.Create( "DForm", musicsettings )
Music:SetName( "End Round Music" )
setting = Music:CheckBox( "Enable End Round Music", "ttt_eor_music_enabled" )
setting:SetTooltip( "Disable EOR Music" )
musicsettings:AddItem( Music )
dtabs:AddSheet( "EOR Music", musicsettings, "icon16/music.png", false, false, "End Round Music Settings" )
end
hook.Add( "TTTSettingsTabs", "AddSettings", AddSettings )
end