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
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
|
surface.CreateFont( "DefaultBold", {
font = "Tahoma",
size = 16,
weight = 1000,
antialias = true,
additive = false
} )
surface.CreateFont( "GMSUnlockDescription", {
font = "Tahoma",
size = 14,
weight = 500,
antialias = true,
additive = false
} )
/*---------------------------------------------------------
Unlock window
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetTitle( "You have unlocked a new ability!" )
self:MakePopup()
self.Name = "Name"
self.Description = ""
self:SetSize( ScrW() / 3, 250 )
self:Center()
self.DescWindow = vgui.Create( "DLabel", self )
self.DescWindow:SetPos( 5, 100 )
self.DescWindow:SetSize( self:GetWide() - 10, self:GetTall() - 140 )
self.DescWindow:SetFont( "GMSUnlockDescription" )
self.DescWindow:SetWrap( true )
self.DescWindow:SetText( "" )
self.Okay = vgui.Create( "DButton", self )
self.Okay:SetSize( self:GetWide() - 10, 30 )
self.Okay:SetPos( 5, self:GetTall() - 35 )
self.Okay:SetText( "Okay" )
self.Okay.DoClick = function() self:Close() end
end
function PANEL:PaintOver( w, h )
draw.SimpleTextOutlined( self.Name, "ScoreboardHead", self:GetWide() / 2, 60, Color( 10, 200, 10 ), 1, 1, 0.5, Color( 100, 100, 100, 160 ) )
//draw.SimpleText( self.Description, "GMSUnlockDescription", self:GetWide() / 2, 140, Color( 200, 200, 200 ), 1, 1 )
end
function PANEL:SetUnlock( text )
local unlock = GMS.FeatureUnlocks[ text ]
if ( !unlock ) then return end
self.Name = unlock.Name
self.Description = unlock.Description
self.DescWindow:SetText( unlock.Description )
end
vgui.Register( "GMS_UnlockWindow", PANEL, "DFrame" )
/*---------------------------------------------------------
Tribe Menu
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetTitle( "Create-A-Tribe" )
self:SetSize( 275, 305 )
self:MakePopup()
self:Center()
local tnamelabel = vgui.Create( "DLabel", self )
tnamelabel:SetPos( 5, 21 )
tnamelabel:SetText( "Tribe name" )
local tname = vgui.Create( "DTextEntry", self )
tname:SetSize( self:GetWide() - 10, 20 )
tname:SetPos( 5, 40 )
local tpwlabel = vgui.Create( "DLabel", self )
tpwlabel:SetPos( 5, 65 )
tpwlabel:SetText( "Tribe password ( Optional )" )
tpwlabel:SizeToContents()
local tpw = vgui.Create( "DTextEntry", self )
tpw:SetSize( self:GetWide() - 10, 20 )
tpw:SetPos( 5, 80 )
local tcollabel = vgui.Create( "DLabel", self )
tcollabel:SetPos( 5, 105 )
tcollabel:SetText( "Tribe color" )
local tcolor = vgui.Create( "DColorMixer", self )
tcolor:SetSize( self:GetWide() - 15, 150 )
tcolor:SetPos( 5, 125 )
local button = vgui.Create( "DButton", self )
button:SetSize( self:GetWide() - 10, 20 )
button:SetPos( 5, 280 )
button:SetText( "Create Tribe!" )
button.DoClick = function()
RunConsoleCommand( "gms_createtribe", tname:GetValue(), tcolor:GetColor().r, tcolor:GetColor().g, tcolor:GetColor().b, tpw:GetValue() )
self:SetVisible( false )
end
end
vgui.Register( "GMS_TribeMenu", PANEL, "DFrame" )
/*---------------------------------------------------------
Tribes List
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetTitle( "Join-A-Tribe" )
self:MakePopup()
local width = ScrW() / 4
for id, tabl in pairs( Tribes ) do
surface.SetFont( "DefaultBold" )
local w = surface.GetTextSize( tabl.name )
width = math.max( width, w + 16 + 10 + 20 )
end
for id, tabl in pairs( Tribes ) do
local button = vgui.Create( "GMS_TribeButton", self )
button:SetSize( width - 16, 16 )
button:SetPos( 8, 10 + id * 21 )
button:SetInfo( tabl )
end
self:SetSize( width, #Tribes * 21 + 35 )
self:Center()
end
vgui.Register( "GMS_TribesList", PANEL, "DFrame" )
----------------------------------------------------------------------------------------------------
local PANEL = {}
function PANEL:Init()
self:SetText( "" )
self.Tribe = {}
end
function PANEL:Paint()
surface.SetDrawColor( self.Tribe.color )
surface.DrawRect( 0, 0, self:GetTall(), self:GetTall() )
surface.SetDrawColor( 0, 0, 0, 200 )
if ( self.Hovered ) then surface.SetDrawColor( 255, 255, 255, 64 ) end
surface.DrawRect( self:GetTall(), 0, self:GetWide() - self:GetTall(), self:GetTall() )
surface.SetFont( "DefaultBold" )
local w = surface.GetTextSize( self.Tribe.name )
draw.SimpleText( self.Tribe.name, "DefaultBold", ( self:GetWide() - 16 ) / 2 + 16, 0, color_white , 1 )
end
function PANEL:DoClick()
if ( self.Tribe.pass ) then
local name = self.Tribe.name
Derma_StringRequest( "Please enter password", "Please enter password for the tribe.", "", function( text ) RunConsoleCommand( "gms_join", name, text ) end )
else
RunConsoleCommand( "gms_join", self.Tribe.name )
end
self:GetParent():Close()
end
function PANEL:SetInfo( tbl )
self.Tribe = tbl
end
vgui.Register( "GMS_TribeButton", PANEL, "DButton" )
/*---------------------------------------------------------
Skills panel
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetPos( 1, 0 )
self:SetSize( ScrW() / 6, 34 )
self:SetVisible( true )
self.Extended = false
self.SkillLabels = {}
self:RefreshSkills()
end
function PANEL:Paint()
surface.SetDrawColor( StrandedBackgroundColor )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.SetDrawColor( StrandedBorderColor )
surface.DrawLine( self:GetWide() - 1, 0, self:GetWide() - 1, self:GetTall() ) -- Nice line instead of messy outlined rect
surface.DrawLine( 0, self:GetTall() - 1, self:GetWide(), self:GetTall() - 1 )
surface.DrawLine( 0, 0, 0, self:GetTall() )
if ( self.Extended ) then
surface.DrawLine( 0, 33, self:GetWide(), 33 )
end
draw.SimpleText( "Skills ( F1 )", "ScoreboardSub", self:GetWide() / 2, 17, Color( 255, 255, 255, 255 ), 1, 1 )
return true
end
function PANEL:RefreshSkills()
for k, v in pairs( self.SkillLabels ) do v:Remove() end
self.SkillLabels = {}
self.Line = 39
for k, v in SortedPairs( Skills ) do
local lbl = vgui.Create( "gms_SkillPanel", self )
lbl:SetPos( 0, self.Line )
lbl:SetSize( self:GetWide(), 16 )
local val = string.gsub( k, "_", " " )
lbl:SetSkill( val )
self.Line = self.Line + lbl:GetTall() + 5
table.insert( self.SkillLabels, lbl )
if ( !self.Extended ) then lbl:SetVisible( false ) end
end
if ( self.Extended ) then
self:SetSize( ScrW() / 6, 40 + ( table.Count( self.SkillLabels ) * 21 ) )
end
end
function PANEL:ToggleExtend()
if ( !self.Extended ) then
self:SetSize( ScrW() / 6, 40 + ( table.Count( self.SkillLabels ) * 21 ) )
self.Extended = true
for k, v in pairs( self.SkillLabels ) do v:SetVisible( true ) end
else
self:SetSize( ScrW() / 6, 34 )
self.Extended = false
for k, v in pairs( self.SkillLabels ) do v:SetVisible( false ) end
end
end
function PANEL:OnMousePressed( mc )
if ( mc == 107 ) then
self:ToggleExtend()
end
end
vgui.Register( "gms_SkillsHud", PANEL, "Panel" )
/*---------------------------------------------------------
Skill Sub-Panel
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
end
function PANEL:Paint()
surface.SetDrawColor( 0, 0, 0, 178 ) -- XP bar background
surface.DrawRect( 5, 0, self:GetWide() - 10, self:GetTall() )
local XP = math.floor( Experience[ self.Skill ] / 100 * ( self:GetWide() - 10 ) )
surface.SetDrawColor( 0, 128, 0, 220 ) -- XP bar
if ( self.TxtSkill == "Survival" ) then
surface.SetDrawColor( 0, 128, 176, 220 ) -- XP bar
end
surface.DrawRect( 5, 0, XP, self:GetTall() )
draw.SimpleText( self.TxtSkill .. ": " .. Skills[ self.Skill ] .. " ( " .. Experience[ self.Skill ] .. " / 100 )", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
return true
end
function PANEL:SetSkill( str )
self.TxtSkill = str
self.Skill = string.gsub( str, " ", "_" )
end
vgui.Register( "gms_SkillPanel", PANEL, "Panel" )
/*---------------------------------------------------------
Help
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetPos( ScrW() / 6 + 2, 0 )
self:SetSize( ScrW() / 6, 34 )
self:SetVisible( true )
self.Extended = false
end
function PANEL:Paint()
surface.SetDrawColor( StrandedBackgroundColor )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.SetDrawColor( StrandedBorderColor )
surface.DrawLine( 0, 0, 0, self:GetTall() )
surface.DrawLine( self:GetWide() - 1, 0, self:GetWide() - 1, self:GetTall() )
surface.DrawLine( 0, self:GetTall() - 1, self:GetWide(), self:GetTall() - 1 )
--print("test")
if ( self.Extended ) then
surface.DrawLine( 0, 33, self:GetWide(), 33 )
draw.SimpleText("Q - Inventory, tribes, and building","HudHintTextSmall",10,30,StrandedTextColor)
draw.SimpleText("Use your fists to hit trees and rocks!","HudHintTextSmall",10,40,StrandedTextColor)
draw.SimpleText("Press E on water to drink,","HudHintTextSmall",10,50,StrandedTextColor)
draw.SimpleText("\tor E on the ground to forage for seeds.","HudHintTextSmall",10,60,StrandedTextColor)
draw.SimpleText("You can plant seeds by clicking on them.","HudHintTextSmall",10,70,StrandedTextColor)
draw.SimpleText("You craft a bed to sleep in.","HudHintTextSmall",10,80,StrandedTextColor)
end
draw.SimpleText( "Help ( F2 )", "ScoreboardSub", self:GetWide() / 2, 17, StrandedTextColor, 1, 1 )
return true
end
function PANEL:ToggleExtend()
self:SetExtended( !self.Extended )
end
function PANEL:SetExtended( bool )
if ( bool ) then
self:SetSize( ScrW() / 6, 200 )
self.Extended = true
else
self:SetSize( ScrW() / 6, 34 )
self.Extended = false
end
if ( GAMEMODE.CommandsHud ) then GAMEMODE.CommandsHud:SetPos( ScrW() / 6 + 2, self:GetTall() ) end
end
function PANEL:OnMousePressed( mc )
if ( mc == 107 ) then self:ToggleExtend() end
end
vgui.Register( "gms_ResourcesHud", PANEL, "Panel" )
/*---------------------------------------------------------
Command panel
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetPos( ScrW() / 6 + 2, 33 )
self:SetSize( ScrW() / 6, 34 )
self:SetVisible( false )
self.Extended = true
self.CommandLabels = {}
self:RefreshCommands()
end
function PANEL:Paint()
surface.SetDrawColor( StrandedBackgroundColor )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
surface.SetDrawColor( StrandedBorderColor )
surface.DrawLine( self:GetWide() - 1, 0, self:GetWide() - 1, self:GetTall() )
surface.DrawLine( 0, 0, 0, self:GetTall() )
surface.DrawLine( 0, self:GetTall() - 1, self:GetWide(), self:GetTall() - 1 )
if ( self.Extended ) then surface.DrawLine( 0, 33, self:GetWide(), 33 ) end
draw.SimpleText( "Commands", "ScoreboardSub", self:GetWide() / 2, 17, Color( 255, 255, 255, 255 ), 1, 1 )
return true
end
function PANEL:CreateButton( x, y, w, h, cmd, txt, clr )
local line = vgui.Create( "gms_CommandPanel", self )
line:SetPos( x, y )
line:SetSize( w, h )
line:SetCommand( cmd, txt, clr )
if ( !self.Extended ) then line:SetVisible( false ) end
table.insert( self.CommandLabels, line )
return line
end
function PANEL:RefreshCommands()
for k, v in pairs( self.CommandLabels ) do v:Remove() end
self.CommandLabels = {}
self.Line = 39
self.Lines = 7
local halfsize = self:GetWide() / 2
local threesize = self:GetWide() / 4
local line1 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_sleep", "Sleep", Color( 0, 128, 255, 176 ) )
local line1b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_wakeup", "Wake up", Color( 0, 128, 255, 176 ) )
self.Line = self.Line + line1:GetTall() + 5
local line2 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_combinations", "Combinations", Color( 200, 200, 0, 176 ) )
local line2b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_structures", "Structures", Color( 200, 200, 0, 176 ) )
self.Line = self.Line + line2:GetTall() + 5
local line3 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_dropweapon", "Drop: Weapon", Color( 255, 0, 0, 176 ) )
local line3b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_dropall", "All resources", Color( 255, 0, 0, 176 ) )
self.Line = self.Line + line3:GetTall() + 5
local line4 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_salvage", "Prop: Salvage", Color( 200, 0, 0, 176 ) )
local line4b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_steal", "Steal", Color( 200, 0, 0, 176 ) )
self.Line = self.Line + line4:GetTall() + 5
local line5 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_savecharacter", "Save", Color( 0, 200, 0, 176 ) )
local line5b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_afk", "Toggle AFK", Color( 0, 200, 0, 176 ) )
self.Line = self.Line + line5:GetTall() + 5
local line6 = self:CreateButton( 0, self.Line, halfsize, 16, "gms_makefire", "Make Campfire", Color( 255, 128, 0, 176 ) )
local line6b = self:CreateButton( halfsize, self.Line, halfsize, 16, "gms_help", "Help", Color( 255, 128, 0, 176 ) )
self.Line = self.Line + line6:GetTall() + 5
local line7a = self:CreateButton( 0, self.Line, halfsize, 16, "gms_tribemenu", "Tribe: Create", Color( 200, 0, 200, 176 ) )
local line7b = self:CreateButton( halfsize, self.Line, threesize, 16, "gms_tribes", "Join", Color( 200, 0, 200, 176 ) )
local line7c = self:CreateButton( halfsize + threesize, self.Line, threesize, 16, "gms_leave", "Leave", Color( 200, 0, 200, 176 ) )
if ( self.Extended ) then
self:SetSize( ScrW() / 6, 40 + ( self.Lines * 21 ) )
end
end
function PANEL:ToggleExtend( b )
//self:SetExtended( !self.Extended, b )
end
function PANEL:SetExtended( bool ,b )
if ( bool ) then
self:SetSize( ScrW() / 6, 40 + ( self.Lines * 21 ) )
self.Extended = true
self:SetVisible( true )
for k,v in pairs( self.CommandLabels ) do v:SetVisible( true ) end
else
self:SetSize( ScrW() / 6, 34 )
self.Extended = false
self:SetVisible( false )
for k, v in pairs( self.CommandLabels ) do v:SetVisible( false ) end
end
end
vgui.Register( "gms_CommandsHud", PANEL, "Panel" )
/*---------------------------------------------------------
Command Sub-Panel
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetText( "" )
self.Cmd = ""
self.Text = ""
self.Clr = Color( 0, 128, 0, 178 )
end
function PANEL:Paint()
surface.SetDrawColor( self.Clr.r, self.Clr.g, self.Clr.b, self.Clr.a ) -- Resource bar background
surface.DrawRect( 5, 0, self:GetWide() - 10, self:GetTall() )
local colr = Color( 255, 255, 255, 255 )
if ( self.Clr.r >= 200 and self.Clr.g >= 200 and self.Clr.b >= 200 ) then colr = Color( 0, 0, 0, 255 ) end
draw.SimpleText( self.Text, "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, colr, 1, 1 )
if ( self.Hovered ) then
surface.SetDrawColor( 255, 255, 255, 64 )
surface.DrawRect( 5, 0, self:GetWide() - 10, self:GetTall() )
end
return true
end
function PANEL:DoClick()
RunConsoleCommand( self.Cmd )
end
function PANEL:SetCommand( str, text, clr )
self.Cmd = str
self.Text = text
self.Clr = clr
end
vgui.Register( "gms_CommandPanel", PANEL, "DButton" )
/*---------------------------------------------------------
Loading bar
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetSize( ScrW() / 2.7, ScrH() / 10 )
self:SetPos( ScrW() / 2 - ( self:GetWide() / 2 ), ScrH() / 2 - ( self:GetTall() / 2 ) )
self.Dots = "."
self.Message = ""
end
function PANEL:Paint()
draw.RoundedBox( 8, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 100, 150 ) ) //Background
//Text
draw.SimpleText( "Loading" .. self.Dots, "ScoreboardHead", self:GetWide() / 2, self:GetTall() / 2, Color( 255, 255, 255, 255 ), 1, 1 )
draw.SimpleText( self.Text, "ScoreboardText", self:GetWide() / 2, self:GetTall() / 1.2, Color( 255, 255, 255, 255 ), 1, 1 )
return true
end
function PANEL:Show( msg )
self.IsStopped = false
self.Text = msg
timer.Simple( 0.5, function() self:UpdateDots() end )
self:SetVisible( true )
end
function PANEL:Hide()
self.IsStopped = true
self:SetVisible( false )
end
function PANEL:UpdateDots()
if ( self.IsStopped ) then return end
if self.Dots == "...." then
self.Dots = "."
else
self.Dots = self.Dots .. "."
end
timer.Simple( 0.5, function() self:UpdateDots() end )
end
vgui.Register( "gms_LoadingBar", PANEL, "Panel" )
/*---------------------------------------------------------
Saving bar
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetSize( ScrW() / 2.7, ScrH() / 10 )
self:SetPos( ScrW() / 2 - ( self:GetWide() / 2 ), ScrH() / 2 - ( self:GetTall() / 2 ) )
self.Dots = "."
self.Message = ""
end
function PANEL:Paint()
//Background
draw.RoundedBox( 8, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 100, 150 ) )
//Text
draw.SimpleText( "Saving" .. self.Dots, "ScoreboardHead", self:GetWide() / 2, self:GetTall() / 2, Color( 255, 255, 255, 255 ), 1, 1 )
draw.SimpleText( self.Text, "ScoreboardText", self:GetWide() / 2, self:GetTall() / 1.2, Color( 255, 255, 255, 255 ), 1, 1 )
return true
end
function PANEL:Show( msg )
self.IsStopped = false
self.Text = msg
timer.Simple( 0.5, function() self:UpdateDots() end )
self:SetVisible( true )
end
function PANEL:Hide()
self.IsStopped = true
self:SetVisible( false )
end
function PANEL:UpdateDots()
if ( self.IsStopped ) then return end
if ( self.Dots == "...." ) then
self.Dots = "."
else
self.Dots = self.Dots .. "."
end
timer.Simple( 0.5, function() self:UpdateDots() end )
end
vgui.Register( "gms_SavingBar", PANEL, "Panel" )
/*---------------------------------------------------------
Command button
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
end
function PANEL:DoClick()
LocalPlayer():ConCommand( self.Command .. "\n" )
surface.PlaySound( Sound( "ui/buttonclickrelease.wav" ) )
end
function PANEL:SetConCommand( cmd )
self.Command = cmd
end
function PANEL:OnCursorEntered()
surface.PlaySound( Sound( "ui/buttonrollover.wav" ) )
end
vgui.Register( "gms_CommandButton", PANEL, "DButton" )
/*---------------------------------------------------------
Combination Window
---------------------------------------------------------*/
local PANEL = {}
function PANEL:Init()
self:SetSize( ScrW() / 1.3, ScrH() / 1.4 )
self:SetDeleteOnClose( false )
self:MakePopup()
self:Center()
self.CombiList = vgui.Create( "DPanelList", self )
self.CombiList:SetPos( 5, 25 )
self.CombiList:SetSize( self:GetWide() - 10, self:GetTall() * 0.55 )
self.CombiList:SetSpacing( 5 )
self.CombiList:SetPadding( 5 )
self.CombiList:EnableHorizontal( true )
self.CombiList:EnableVerticalScrollbar( true )
self.Info = vgui.Create( "DPanel", self )
self.Info:SetPos( 5, self.CombiList:GetTall() + 30 )
self.Info:SetSize( self:GetWide() - 10, self:GetTall() - self.CombiList:GetTall() - 70 )
self.Info.NameLabel = vgui.Create( "DLabel", self.Info )
self.Info.NameLabel:SetPos( 5, 5 )
self.Info.NameLabel:SetSize( self.Info:GetWide(), 20 )
self.Info.NameLabel:SetFont( "ScoreboardSub" )
self.Info.NameLabel:SetDark( true )
self.Info.NameLabel:SetText( "Select a recipe" )
self.Info.DescLabel = vgui.Create( "DLabel", self.Info )
self.Info.DescLabel:SetPos( 5, 25 )
self.Info.DescLabel:SetSize( self.Info:GetWide(), self.Info:GetTall() - 30 )
self.Info.DescLabel:SetDark( true )
self.Info.DescLabel:SetText( "" )
self.button = vgui.Create( "gms_CommandButton", self )
self.button:SetPos( 5, self:GetTall() - 35 )
self.button:SetSize( self:GetWide() - 10, 30 )
self.button:SetText( "Make" )
self.button:SetDisabled( true )
function self.button:DoClick()
local p = self:GetParent()
local combi = p.CombiGroupName or ""
local active = p.ActiveCombi or ""
p:Close()
LocalPlayer():ConCommand( "gms_MakeCombination " .. combi .. " " .. active .. "\n" )
end
self.IconSize = 86
self.CombiPanels = {}
end
function PANEL:SetTable( str )
self:SetTitle( "#" .. str )
self.CombiGroupName = str
self.CombiGroup = GMS.Combinations[ str ]
self:Clear()
for name, tbl in SortedPairs( self.CombiGroup or {} ) do
local icon = vgui.Create( "GMS_CombiIcon", self.CombiList )
icon:SetSize( self.IconSize, self.IconSize )
icon:SetInfo( name, tbl )
self.CombiList:AddItem( icon )
table.insert( self.CombiPanels, icon )
end
self:ClearActive()
end
function PANEL:SetActive( combi, tbl )
self.ActiveCombi = combi
self.ActiveTable = tbl
self.Info.NameLabel:SetText( tbl.Name )
local desc = tbl.Description
if ( tbl.Req or tbl.SkillReq ) then
desc = desc .. "\n\nYou need:"
end
if ( tbl.Req and table.Count( tbl.Req ) > 0 ) then
for res, num in pairs( tbl.Req ) do
if ( tbl.AllSmelt ) then
desc = desc .. "\n" .. string.Replace( res, "_", " " ) .. " ( " .. tbl.Max .. " max )"
else
desc = desc .. "\n" .. string.Replace( res, "_", " " ) .. ": " .. num
end
end
end
if ( tbl.SkillReq and table.Count( tbl.SkillReq ) > 0 ) then
for skill, num in pairs( tbl.SkillReq ) do
desc = desc .. "\n" .. string.Replace( skill, "_", " " ) .. " level " .. num
end
end
if ( tbl.FoodValue ) then
desc = desc .. "\n\nFood initial quality: " .. math.floor( tbl.FoodValue / 10 ) .. "%"
end
self.Info.DescLabel:SetText( desc )
end
function PANEL:ClearActive()
self.ActiveCombi = nil
self.ActiveTable = nil
self.Info.NameLabel:SetText( "Select a recipe" )
self.Info.DescLabel:SetText( "" )
end
function PANEL:Clear()
for k, v in pairs( self.CombiPanels ) do
v:Remove()
end
self.CombiPanels = {}
end
vgui.Register( "GMS_CombinationWindow", PANEL, "DFrame" )
/*---------------------------------------------------------
Combi Icon
---------------------------------------------------------*/
local PANEL = {}
PANEL.TexID = Material( "gms_icons/gms_none.png" )
PANEL.BGTexID = Material( "gms_icons/gms_none_bg.png" )
function PANEL:Paint( w, h )
surface.SetDrawColor( 200, 200, 200, 255 )
//surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )*/
//surface.SetMaterial( self.BGTexID )
//surface.DrawTexturedRect( -( 128 - w ) / 2, -( 128 - h ) / 2, 128, 128 )
surface.SetDrawColor( StrandedBorderColor )
surface.DrawOutlinedRect( 0, 0, self:GetWide(), self:GetTall() )
local hasskill = true
if ( self.CombiTable.SkillReq ) then
for k, v in pairs( self.CombiTable.SkillReq ) do
if ( GetSkill( k ) < v ) then hasskill = false end
end
end
local hasres = true
if ( self.CombiTable.Req ) then
for k, v in pairs( self.CombiTable.Req ) do
if ( GetResource( k ) < v ) then hasres = false end
end
end
if ( !hasskill ) then
surface.SetDrawColor( 200, 200, 0, 150 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
elseif ( !hasres ) then
surface.SetDrawColor( 200, 0, 0, 100 )
surface.DrawRect( 0, 0, self:GetWide(), self:GetTall() )
end
surface.SetDrawColor( 255, 255, 255, 255 )
//surface.SetMaterial( self.TexID )
//surface.DrawTexturedRect( -( 128 - w ) / 2, -( 128 - h ) / 2, 128, 128 )
local y = self:GetTall() / 2 + self:GetTall() / 4
draw.SimpleTextOutlined( self.CombiTable.Name, "DefaultSmall", self:GetWide() / 2, y, Color( 255, 255, 255, 255 ), 1, 1, 0.5, Color( 100, 100, 100, 140 ) )
return true
end
function PANEL:SetInfo( name, tbl )
//if ( tbl.Texture && Material( tbl.Texture ) ) then self.TexID = Material( tbl.Texture ) end
local img = vgui.Create("DImage", self)
img:SetPos(20, 10)
img:SetSize(self:GetWide()-40, self:GetTall()-40)
img:SetImage("vgui/avatar_default")
PrintTable(tbl)
if (tbl.Results != nil) then
for k,v in pairs(tbl.Results) do
if(GMS.Resources[k] == nil) then --This resource is not registered!
img:SetImage("vgui/avatar_default")
print("Resource:" .. k .. " not registed! This might be a bug!")
continue
elseif(GMS.Resources[k].Icon == nil) then
img:SetImage("vgui/avatar_default")
print("Resource:" .. k .. " does not have an .Icon field! This might be a bug!")
continue
else
img:SetImage(GMS.Resources[k].Icon)
end
end
elseif (tbl.FoodValue != nil) then
img:SetPos(0, 0)
img:SetSize(self:GetSize())
img:SetImage("items/gms_none.png")
else
img:SetPos(0, -10)
img:SetSize(self:GetSize())
img:SetImage("items/gms_weapon.png")
end
//if (GMS.GetResourceByName(name).Icon != nil) then img:SetImage(GMS.GetResourceByName(name).Icon) else img:SetImage("vgui/avatar_default") end
self.Combi = name
self.CombiTable = tbl
end
function PANEL:OnMousePressed( mc )
if ( mc != 107 ) then return end
surface.PlaySound( Sound( "ui/buttonclickrelease.wav" ) )
self:GetParent():GetParent():GetParent():SetActive( self.Combi, self.CombiTable )
self:GetParent():GetParent():GetParent().button:SetDisabled( false )
end
function PANEL:OnCursorEntered()
surface.PlaySound( Sound( "ui/buttonrollover.wav" ) )
end
vgui.Register( "GMS_CombiIcon", PANEL, "DPanel" )
/* Resource Pack GUI */
local PANEL = {}
function PANEL:Init()
self.Text = ""
self.Num = 0
self.TakeX = vgui.Create( "gms_takeButton", self )
self.TakeAll = vgui.Create( "gms_takeButton", self )
end
function PANEL:Paint()
draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 176, 176, 176, 255 ) )
draw.SimpleText( self.Text .. ": " .. self.Num, "DefaultBold", 5, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 0, 1 )
end
function PANEL:SetRes( str, num, isResPack )
self.Text = str
self.Num = num
if ( isResPack ) then
self.TakeX:SetRes( str, nil, false )
self.TakeAll:SetRes( str, num, true, false )
else
self.TakeX:Remove()
self.TakeX = nil
self.TakeAll:SetRes( str, 1, true, true )
end
end
function PANEL:PerformLayout()
self.TakeAll:SetSize( 64, self:GetTall() - 4 )
self.TakeAll:SetPos( self:GetWide() - 66, 2 )
if ( self.TakeX and self.TakeX != NULL ) then
self.TakeX:SetSize( 64, self:GetTall() - 4 )
self.TakeX:SetPos( self:GetWide() - 132, 2 )
end
end
vgui.Register( "gms_resourceLine", PANEL, "Panel" )
// Take button
local PANEL = {}
function PANEL:Init()
self.Text = ""
self.Num = 0
self.IsAll = false
self.IsFridge = false
self:SetText( "" )
end
function PANEL:Paint()
if ( self:GetDisabled() ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 50, 50, 50, 255 ) )
elseif ( self.Depressed /*|| self:GetSelected()*/ ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 50, 50, 176, 255 ) )
elseif ( self.Hovered ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 255, 255 ) )
else
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 100, 255 ) )
end
if ( self.IsFridge ) then
draw.SimpleText( "Take", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
elseif ( self.IsAll ) then
draw.SimpleText( "Take All", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
else
draw.SimpleText( "Take X", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
end
end
function PANEL:DoClick()
if ( self.IsAll ) then
RunConsoleCommand( "gms_TakeResources", string.gsub( self.Text, " ", "_" ), self.Num )
if ( self.IsFridge ) then self:GetParent():GetParent():GetParent():GetParent():Close() return end
else
local res = self.Text
Derma_StringRequest( "Please enter amount", "Please enter amount of " .. res .. " to take.", "", function( text )
RunConsoleCommand( "gms_TakeResources", string.gsub( res, " ", "_" ), text )
end )
end
end
function PANEL:SetRes( str, num, isAll, isFridge )
self.Text = str
self.Num = num
self.IsAll = isAll
self.IsFridge = isFridge
end
vgui.Register( "gms_takeButton", PANEL, "DButton" )
// Store Line
local PANEL = {}
function PANEL:Init()
self.Text = ""
self.Num = 0
self.StoreX = vgui.Create( "gms_StoreButton", self )
self.StoreAll = vgui.Create( "gms_StoreButton", self )
end
function PANEL:Paint()
draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 176, 176, 176, 255 ) )
draw.SimpleText( string.Replace( self.Text, "_", " " ) .. ": " .. self.Num, "DefaultBold", 5, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 0, 1 )
end
function PANEL:SetRes( str, num )
self.Text = str
self.Num = num
self.StoreX:SetRes( str, nil )
self.StoreAll:SetRes( str, num, true )
end
function PANEL:PerformLayout()
self.StoreAll:SetSize( 64, self:GetTall() - 4 )
self.StoreAll:SetPos( self:GetWide() - 66, 2 )
self.StoreX:SetSize( 64, self:GetTall() - 4 )
self.StoreX:SetPos( self:GetWide() - 132, 2 )
end
vgui.Register( "gms_resourceLineStore", PANEL, "Panel" )
// Store button
local PANEL = {}
function PANEL:Init()
self.Text = ""
self.Num = 0
self.IsAll = false
self:SetText( "" )
end
function PANEL:Paint()
if ( self:GetDisabled() ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 50, 50, 50, 255 ) )
elseif ( self.Depressed /*|| self:GetSelected()*/ ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 50, 50, 176, 255 ) )
elseif ( self.Hovered ) then
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 255, 255 ) )
else
draw.RoundedBox( 0, 0, 0, self:GetWide(), self:GetTall(), Color( 100, 100, 100, 255 ) )
end
if ( self.IsAll ) then
draw.SimpleText( "Store All", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
else
draw.SimpleText( "Store X", "DefaultBold", self:GetWide() / 2, self:GetTall() / 2 - 1, Color( 255, 255, 255, 255 ), 1, 1 )
end
end
function PANEL:DoClick()
if ( self.IsAll ) then
RunConsoleCommand( "gms_DropResources", string.gsub( self.Text, " ", "_" ), self.Num )
else
local res = self.Text
Derma_StringRequest( "Please enter amount", "Please enter amount of " .. res .. " to store.", "", function( text )
RunConsoleCommand( "gms_DropResources", string.gsub( res, " ", "_" ), text )
end )
end
end
function PANEL:SetRes( str, num, isAll )
self.Text = str
self.Num = num
self.IsAll = isAll
end
vgui.Register( "gms_StoreButton", PANEL, "DButton" )
|