-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
overlayunit.pas
2918 lines (2254 loc) · 84.3 KB
/
overlayunit.pas
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
unit overlayunit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, process, Forms, Controls, Graphics, Dialogs, ExtCtrls,
unix, StdCtrls, Spin, ComCtrls, Buttons, ColorBox, ActnList, Menus, aboutunit,
ATStringProc_HtmlColor, crosshairUnit, customeffectsunit,LCLtype, FileUtil, StrUtils,Types;
type
{ Tgoverlayform }
Tgoverlayform = class(TForm)
aboutBitBtn: TBitBtn;
acteffectsListBox: TListBox;
addBitBtn: TBitBtn;
alphavalueLabel: TLabel;
Label1: TLabel;
MenuItem1: TMenuItem;
offsetSpinEdit: TSpinEdit;
fpsonlyBitBtn: TBitBtn;
fullBitBtn: TBitBtn;
basicBitBtn: TBitBtn;
basichorizontalBitBtn: TBitBtn;
fullLabel: TLabel;
basicLabel: TLabel;
basichorizontalLabel: TLabel;
fpsonlyLabel: TLabel;
customLabel: TLabel;
layoutImageList: TImageList;
popsaveMenu: TPopupMenu;
usercustomBitBtn: TBitBtn;
colorthemeLabel: TLabel;
hudcompactCheckBox: TCheckBox;
layoutsLabel: TLabel;
presetTabSheet: TTabSheet;
themesComboBox: TComboBox;
winesyncCheckBox: TCheckBox;
fpsavgCheckBox: TCheckBox;
fpsavgBitBtn: TBitBtn;
fahrenheitCheckBox: TCheckBox;
networkComboBox: TComboBox;
networkCheckBox: TCheckBox;
versioningCheckBox: TCheckBox;
backgroundGroupBox: TGroupBox;
backgroundLabel: TLabel;
logfolderBitBtn: TBitBtn;
columShape1: TShape;
columShape2: TShape;
columShape3: TShape;
columShape4: TShape;
columShape5: TShape;
columsGroupBox: TGroupBox;
logfolderEdit: TEdit;
fpscolor2ColorButton: TColorButton;
fpslimCheckGroup: TCheckGroup;
coreloadtypeBitBtn: TBitBtn;
borderGroupBox: TGroupBox;
bottomcenterRadioButton: TRadioButton;
logtoggleImage: TImage;
frametimetypeBitBtn: TBitBtn;
fpsCheckBox: TCheckBox;
gpudescEdit: TEdit;
fontComboBox: TComboBox;
fontcolorLabel: TLabel;
fontsizevalueLabel: TLabel;
archCheckBox: TCheckBox;
fpscolor2SpinEdit: TSpinEdit;
fpscolor3SpinEdit: TSpinEdit;
autouploadCheckBox: TCheckBox;
aveffectsListBox: TListBox;
basaltgeSpeedButton: TSpeedButton;
basaltGlobalenableLabel: TLabel;
basaltrunBitBtn: TBitBtn;
basaltsaveBitBtn: TBitBtn;
batteryCheckBox: TCheckBox;
batterywattCheckBox: TCheckBox;
batterytimeCheckBox: TCheckBox;
fpscolorCheckBox: TCheckBox;
engineshortCheckBox: TCheckBox;
cpuavgloadCheckBox: TCheckBox;
cpuColorButton: TColorButton;
cpufreqCheckBox: TCheckBox;
cpuGroupBox: TGroupBox;
cpuload1ColorButton: TColorButton;
cpuload2ColorButton: TColorButton;
cpuload3ColorButton: TColorButton;
cpuloadcolorCheckBox: TCheckBox;
cpuloadcoreCheckBox: TCheckBox;
cpunameEdit: TEdit;
cpupowerCheckBox: TCheckBox;
cputempCheckBox: TCheckBox;
customcommandEdit: TEdit;
diskioCheckBox: TCheckBox;
distroinfoCheckBox: TCheckBox;
cpuImage: TImage;
gpuvoltageCheckBox: TCheckBox;
gpuImage: TImage;
fpstoggleImage: TImage;
hudtoggleImage: TImage;
filterRadioGroup: TRadioGroup;
columShape: TShape;
columvalueLabel: TLabel;
Image2: TImage;
durationvalueLabel: TLabel;
delayvalueLabel: TLabel;
intervalvalueLabel: TLabel;
logtoggleLabel: TLabel;
logdurationLabel: TLabel;
logintervalLabel: TLabel;
logdelayLabel: TLabel;
logfolderLabel: TLabel;
sysinfoImage: TImage;
refreshrateCheckBox: TCheckBox;
showfpslimCheckBox: TCheckBox;
plusSpeedButton: TSpeedButton;
minusButton: TSpeedButton;
durationTrackBar: TTrackBar;
delayTrackBar: TTrackBar;
intervalTrackBar: TTrackBar;
vulkandriverCheckBox: TCheckBox;
engineColorButton: TColorButton;
engineversionCheckBox: TCheckBox;
extrasTabSheet: TTabSheet;
metricsSheet: TTabSheet;
FontcolorButton: TColorButton;
C: TComboBox;
fpslimmetComboBox: TComboBox;
fpslimLabel1: TLabel;
cpumainmetricsLabel: TLabel;
cputempLabel: TLabel;
memLabel: TLabel;
systemLabel: TLabel;
wineLabel: TLabel;
optionsLabel: TLabel;
batteryLabel: TLabel;
othersLabel: TLabel;
fpslimLabel3: TLabel;
mainmetricLabel: TLabel;
gputempLabel: TLabel;
gpupowerLabel: TLabel;
gpuinfoLabel: TLabel;
fpslimtoggleComboBox: TComboBox;
framecountCheckBox: TCheckBox;
frametimegraphCheckBox: TCheckBox;
frametimegraphColorButton: TColorButton;
batteryColorButton: TColorButton;
gamemodestatusCheckBox: TCheckBox;
deviceCheckBox: TCheckBox;
geSpeedButton: TSpeedButton;
GlobalenableLabel: TLabel;
glvsyncComboBox: TComboBox;
gpuavgloadCheckBox: TCheckBox;
gpuColorButton: TColorButton;
gpufreqCheckBox: TCheckBox;
gpuGroupBox: TGroupBox;
fpscolor1ColorButton: TColorButton;
gpuload1ColorButton: TColorButton;
gpuload2ColorButton: TColorButton;
fpscolor3ColorButton: TColorButton;
gpuload3ColorButton: TColorButton;
gpuloadcolorCheckBox: TCheckBox;
gpumemfreqCheckBox: TCheckBox;
gpumodelCheckBox: TCheckBox;
gpunameEdit: TEdit;
gpupowerCheckBox: TCheckBox;
gputempCheckBox: TCheckBox;
gpujunctempCheckBox: TCheckBox;
gpumemtempCheckBox: TCheckBox;
gpufanCheckBox: TCheckBox;
gputhrottlingCheckBox: TCheckBox;
gputhrottlinggraphCheckBox: TCheckBox;
fpsGroupBox: TGroupBox;
hImage: TImage;
horizontalRadioButton: TRadioButton;
hudbackgroundColorButton: TColorButton;
hudversionCheckBox: TCheckBox;
Image1: TImage;
systemGroupBox: TGroupBox;
logtoggleComboBox: TComboBox;
loggingGroupBox: TGroupBox;
mediaCheckBox: TCheckBox;
mediaColorButton: TColorButton;
hidehudCheckBox: TCheckBox;
hudonoffComboBox: TComboBox;
hudtitleEdit: TEdit;
orientationGroupBox: TGroupBox;
PaintBox1: TPaintBox;
fontLabel: TLabel;
fontsizeTrackBar: TTrackBar;
roundImage: TImage;
roundRadioButton: TRadioButton;
squareImage: TImage;
squareRadioButton: TRadioButton;
topleftRadioButton: TRadioButton;
topcenterRadioButton: TRadioButton;
bottomleftRadioButton: TRadioButton;
middleleftRadioButton: TRadioButton;
toprightRadioButton: TRadioButton;
bottomrightRadioButton: TRadioButton;
middlerightRadioButton: TRadioButton;
intelpowerfixBitBtn: TBitBtn;
iordrwColorButton: TColorButton;
hudtoggleLabel: TLabel;
mangohudPageControl: TPageControl;
mangohudPanel: TPanel;
notificationLabel: TLabel;
openglImage: TImage;
PageControl2: TPageControl;
pcidevComboBox: TComboBox;
fpslimiterGroupBox: TGroupBox;
performanceTabSheet: TTabSheet;
positionGroupBox: TGroupBox;
Process1: TProcess;
procmemCheckBox: TCheckBox;
ramColorButton: TColorButton;
ramusageCheckBox: TCheckBox;
reshadeLabel1: TLabel;
reshadeLabel2: TLabel;
reshadeProgressBar: TProgressBar;
reshadesyncBitBtn: TBitBtn;
resolutionCheckBox: TCheckBox;
afTrackBar: TTrackBar;
mipmapTrackBar: TTrackBar;
mipmapvalueLabel: TLabel;
afvalueLabel: TLabel;
popupBitBtn: TBitBtn;
runvkbasaltBitBtn: TBitBtn;
saveBitBtn: TBitBtn;
sessionCheckBox: TCheckBox;
subBitBtn: TBitBtn;
swapusageCheckBox: TCheckBox;
TabSheet8: TTabSheet;
timeCheckBox: TCheckBox;
transparencyLabel: TLabel;
afLabel: TLabel;
mipmapLabel: TLabel;
transpTrackBar: TTrackBar;
fontsGroupBox: TGroupBox;
verticalRadioButton: TRadioButton;
vImage: TImage;
visualTabSheet: TTabSheet;
vkbasaltPanel: TPanel;
vkbasaltstatusCheckBox: TCheckBox;
fsrCheckBox: TCheckBox;
hdrCheckBox: TCheckBox;
fcatCheckBox: TCheckBox;
vkbtogglekeyCombobox: TComboBox;
iconsImageList: TImageList;
columImageList: TImageList;
dependencieSpeedButton: TSpeedButton;
casTrackBar2: TTrackBar;
globalbuttonImageList: TImageList;
mangohudLabel: TLabel;
dependenciesLabel: TLabel;
vkbasaltLabel: TLabel;
goverlayimage: TImage;
mangohudShape: TShape;
vkbasaltShape: TShape;
vktoggleLabel: TLabel;
vramColorButton: TColorButton;
vramusageCheckBox: TCheckBox;
vsyncComboBox: TComboBox;
vsyncGroupBox: TGroupBox;
filtersGroupBox: TGroupBox;
vulkanImage: TImage;
wineCheckBox: TCheckBox;
wineColorButton: TColorButton;
vpsCheckBox: TCheckBox;
procedure aboutBitBtnClick(Sender: TObject);
procedure afTrackBarChange(Sender: TObject);
procedure basicBitBtnClick(Sender: TObject);
procedure basichorizontalBitBtnClick(Sender: TObject);
procedure delayTrackBarChange(Sender: TObject);
procedure durationTrackBarChange(Sender: TObject);
procedure fpsavgBitBtnClick(Sender: TObject);
procedure fpsonlyBitBtnClick(Sender: TObject);
procedure fullBitBtnClick(Sender: TObject);
procedure intelpowerfixBitBtnClick(Sender: TObject);
procedure intervalTrackBarChange(Sender: TObject);
procedure logfolderBitBtnClick(Sender: TObject);
procedure coreloadtypeBitBtnClick(Sender: TObject);
procedure fontsizeTrackBarChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure frametimetypeBitBtnClick(Sender: TObject);
procedure geSpeedButtonClick(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure minusButtonClick(Sender: TObject);
procedure mipmapTrackBarChange(Sender: TObject);
procedure PaintBox1Paint(Sender: TObject);
procedure pcidevComboBoxChange(Sender: TObject);
procedure plusSpeedButtonClick(Sender: TObject);
procedure popupBitBtnClick(Sender: TObject);
procedure saveBitBtnClick(Sender: TObject);
procedure transpTrackBarChange(Sender: TObject);
procedure SetAllCheckBoxesToFalse;
procedure SetAllCheckBoxesToTrue;
procedure usercustomBitBtnClick(Sender: TObject);
public
end;
var
goverlayform: Tgoverlayform;
s: string;
Color: string;
ORIENTATION, HUDTITLE, BORDERTYPE, HUDALPHA, HUDCOLOR, FONTTYPE, FONTPATH, FONTSIZE, FONTCOLOR, HUDPOSITION, TOGGLEHUD, HIDEHUD, HUDCOMPACT, PCIDEV, TABLECOLUMNS: string; //visualtab
GPUAVGLOAD, GPULOADCHANGE, GPULOADCOLOR , GPULOADVALUE, VRAM, VRAMCOLOR, GPUFREQ, GPUMEMFREQ, GPUTEMP, GPUMEMTEMP, GPUJUNCTEMP, GPUFAN, GPUPOWER, GPUTHR, GPUTHRG, GPUMODEL, VULKANDRIVER, GPUVOLTAGE: string; //metrics tab - GPU
CPUAVGLOAD, CPULOADCORE, CPULOADCHANGE, CPUCOLOR, CPULOADCOLOR, CPULOADVALUE, CPUCOREFREQ, CPUTEMP, CORELOADTYPE, CPUPOWER, GPUTEXT, GPUCOLOR, CPUTEXT, RAM, RAMCOLOR, IOSTATS, IOREAD, IOWRITE, SWAP, PROCMEM: string; //metrics tab - CPU
FPS, FPSAVG,FRAMETIMING, SHOWFPSLIM, FRAMECOUNT, FRAMETIMEC, HISTOGRAM, FPSLIM, FPSLIMMET, FPSCOLOR, FPSVALUE, FPSCHANGE, VSYNC, GLVSYNC, FILTER, AFFILTER, MIPMAPFILTER, FPSLIMTOGGLE, OFFSET: string; //performance tab
DISTROINFO1, DISTROINFO2, DISTROINFO3, DISTROINFO4, DISTRONAME, ARCH, RESOLUTION, SESSION, SESSIONTXT, TIME, WINE, WINECOLOR, ENGINE, ENGINECOLOR, ENGINESHORT, HUDVERSION,GAMEMODE: string; //extra tab
VKBASALT, FCAT, FSR, HDR, WINESYNC, VPS, FTEMP, REFRESHRATE, BATTERY, BATTERYCOLOR, BATTERYWATT, BATTERYTIME, DEVICE,DEVICEICON, MEDIA, MEDIACOLOR, CUSTOMCMD1, CUSTOMCMD2, LOGFOLDER, LOGDURATION, LOGDELAY, LOGINTERVAL, LOGTOGGLE, LOGVER, LOGAUTO, NETWORK: string; //extratab
//Boolean variables
mangohudsel: boolean;
vkbasaltsel: boolean;
//Mangohud variables ##########################
AUX, AUX2, MANGOHUDCFGFILE, MANGOHUDFOLDER, CUSTOMCFGFILE, FONTFOLDER, HOMEPATH, USERHOME, GOVERLAYFOLDER, GPU0, LSPCI0: string;
//########################################
i, GPUNUMBER, GPUCOUNT, COLUMNS, maxValue, currentValue: integer;
GPUDESC: TStringList;
ArquivoConfig: TextFile;
Linha: string;
CaminhoArquivo, NomeCampo, ValorCampo: string;
fpsArray: TStringArray;
implementation
{$R *.lfm}
{ Tgoverlayform }
//Function to convert color codes to #RRGGBB format
function ColorToHTMLColor(const AColor: TColor): string;
var
Red, Green, Blue: Byte;
begin
Red := Byte(AColor); // Red component
Green := Byte(AColor shr 8); // green component
Blue := Byte(AColor shr 16); // blue component
Result := Format('%.2x%.2x%.2x', [Red, Green, Blue]); // Formata a string no formato HTML (#RRGGBB)
end;
//Function to find font files (*.ttf) in /usr/share/fonts
procedure ListarFontesNoDiretorio(Diretorio: string; ComboBox: TComboBox);
var
Arquivos: TStringList;
Arquivo: String;
begin
Arquivos := FindAllFiles(Diretorio, '*.ttf'); // Locate TTF files in Diretorio
try
for Arquivo in Arquivos do
begin
ComboBox.Items.Add(ExtractFileName(Arquivo)); // Add filename into combobox
end;
finally
Arquivos.Free; // Free memory
end;
end;
//Procedure to WriteConfig to file
Procedure WriteConfig(PARAMETRO, FILEPATH: string);
var
Process1: TProcess;
begin
Process1 := TProcess.Create(nil);
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('echo ' + PARAMETRO + ' >> ' + FILEPATH);
Process1.Options := [poWaitOnExit, poUsePipes];
Process1.Execute;
Process1.Free;
end;
//Procedure to WriteConfig to file if checkbox is checked
Procedure WriteCheckboxConfig(CHECKBOXNAME: TCheckbox; PARAMETRO, FILEPATH: string);
var
Process1: TProcess;
begin
if CHECKBOXNAME.checked = true then
begin
Process1 := TProcess.Create(nil);
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('echo ' + PARAMETRO + ' >> ' + FILEPATH);
Process1.Options := [poWaitOnExit, poUsePipes];
Process1.Execute;
Process1.Free;
end;
end;
//Procedure to store info from checkboxes
procedure SaveCheckbox(CHECKBOXNAME: TCheckbox; var VARNAME: string; const VALUE: string);
begin
if CHECKBOXNAME.checked = true then
VARNAME := VALUE;
end;
//Procedure to store info from Radiobuttons
procedure SaveRadioButton(RADIOBUTTONNAME: TRadioButton; var VARNAME: string; const VALUE: string);
begin
if RADIOBUTTONNAME.checked = true then
VARNAME := VALUE;
end;
// ######## Function Load strings with values from mangohud variables
function LoadValue(const Parametro: string; out Valor: string): Boolean;
var
Process: TProcess;
Output: TStringList;
CaminhoArquivo: string;
begin
Process := TProcess.Create(nil);
Output := TStringList.Create;
CaminhoArquivo := GetEnvironmentVariable('HOME') + '/.config/MangoHud/MangoHud.conf';
Process.Executable := '/bin/bash';
Process.Parameters.Add('-c');
Process.Parameters.Add('cat ' + CaminhoArquivo);
Process.Options := [poUsePipes];
Process.Execute;
Output.LoadFromStream(Process.Output);
Valor := Output.Values[Parametro];
// Debug
WriteLn('Parametro: ', Parametro);
WriteLn('Value: ', Valor);
Result := Valor <> ''; // Retorna verdadeiro se o valor foi encontrado, falso caso contrário
end;
// ######## Function to Load strings from mangohud variables
function LoadName(const Parametro: string): Boolean;
var
Process: TProcess;
Output: TStringList;
CaminhoArquivo: string;
variavel: string;
begin
Process := TProcess.Create(nil);
Output := TStringList.Create;
CaminhoArquivo := GetEnvironmentVariable('HOME') + '/.config/MangoHud/MangoHud.conf';
Process.Executable := '/bin/bash';
Process.Parameters.Add('-c');
Process.Parameters.Add('cat ' + CaminhoArquivo + ' | grep ' + Parametro);
Process.Options := [poUsePipes];
Process.Execute;
Output.LoadFromStream(Process.Output);
// debug
WriteLn('Parametro: ', Parametro);
if output.Count > 0 then
Result := true
else
Result := false; // Retorna verdadeiro se o valor foi encontrado, falso caso contrário
end;
//Function to convert hexadecimal to TColor
function HexToColor(const HexValue: string): TColor;
begin
Result := RGBToColor(StrToInt('$' + Copy(HexValue, 1, 2)),
StrToInt('$' + Copy(HexValue, 3, 2)),
StrToInt('$' + Copy(HexValue, 5, 2)));
end;
//Procedure to uncheck all checkboxes
procedure Tgoverlayform.SetAllCheckBoxesToFalse;
var
i: Integer;
begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TCheckBox then
(Components[i] as TCheckBox).Checked := False;
end;
end;
//Procedure to check all checkboxes
procedure Tgoverlayform.SetAllCheckBoxesToTrue;
var
i: Integer;
begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TCheckBox then
(Components[i] as TCheckBox).Checked := True;
end;
end;
procedure Tgoverlayform.usercustomBitBtnClick(Sender: TObject);
begin
// Update the config files path
CUSTOMCFGFILE := GetEnvironmentVariable('HOME') + '/.config/MangoHud/custom.conf';
MANGOHUDCFGFILE := GetEnvironmentVariable('HOME') + '/.config/MangoHud/MangoHud.conf';
if not FileExists(CUSTOMCFGFILE) then
begin
ShowMessage('You need to save a custom preset first. Click on the hamburguer menu and click save as custom config.');
end
else
begin
Process1 := TProcess.Create(nil);
try
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('cp ' + CUSTOMCFGFILE + ' ' + MANGOHUDCFGFILE);
Process1.Options := [poWaitOnExit, poUsePipes];
Process1.Execute;
Process1.WaitOnExit;
finally
Process1.Free;
end;
end;
// Change button color
fullBitbtn.Color:=clDefault;
basicBitbtn.Color:=clDefault;
basichorizontalBitbtn.Color:=clDefault;
fpsonlyBitbtn.Color:=clDefault;
usercustomBitbtn.Color:=$007F5500;
Process1 := TProcess.Create(nil);
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('notify-send -e -i /usr/share/icons/hicolor/128x128/apps/goverlay.png "MangoHud" "Reloading custom user preset"');
Process1.Options := [poUsePipes];
Process1.Execute;
Process1.WaitOnExit;
Process1.Free;
end;
//Procedure to list network interfaces
procedure GetNetworkInterfaces(ComboBox: TComboBox);
var
AProcess: TProcess;
AStringList: TStringList;
OutputLine, InterfaceName: String;
i: Integer;
begin
// Inicializa o TProcess
AProcess := TProcess.Create(nil);
AStringList := TStringList.Create;
try
// Configura o processo para executar o comando 'ip link'
AProcess.Executable := '/sbin/ip';
AProcess.Parameters.Add('link');
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
// Executa o comando
AProcess.Execute;
// Lê a saída do comando
AStringList.LoadFromStream(AProcess.Output);
// Limpa o ComboBox
ComboBox.Items.Clear;
// Processa a saída para obter os nomes das interfaces
for i := 0 to AStringList.Count - 1 do
begin
OutputLine := AStringList[i];
if Pos(': ', OutputLine) > 0 then
begin
// Extrai o nome da interface (parte entre ": " e ":")
InterfaceName := Trim(Copy(OutputLine, Pos(': ', OutputLine) + 2, Pos(':', OutputLine, Pos(': ', OutputLine) + 2) - Pos(': ', OutputLine) - 2));
// Adiciona o nome da interface ao ComboBox
ComboBox.Items.Add(InterfaceName);
end;
end;
finally
AStringList.Free;
AProcess.Free;
end;
end;
// Procedure to search for values in a checkbox
procedure LoadCheckgroup(const ACheckGroup: TCheckGroup; const AString: string);
var
Values: TStringDynArray;
i, j: Integer;
begin
// Divide a string em substrings usando a vírgula como delimitador
Values := SplitString(AUX, ',');
// Percorre cada valor na string
for i := Low(Values) to High(Values) do
begin
// Remove espaços em branco em excesso antes e depois do valor
Values[i] := Trim(Values[i]);
// Percorre todos os itens do TCheckGroup
for j := 0 to ACheckGroup.Items.Count - 1 do
begin
// Verifica se o valor da substring é igual ao valor do item
if Values[i] = ACheckGroup.Items[j] then
begin
// Marca o checkbox correspondente
ACheckGroup.Checked[j] := True;
// Pode sair do loop interno, pois já encontrou correspondência para este valor
Break;
end;
end;
end;
end;
procedure Tgoverlayform.FormCreate(Sender: TObject);
var
Process: TProcess;
AppHandle: THandle;
saida: TStringList;
i: integer;
Output: TStringList;
begin
//Centralize window
// Left:=(Screen.Width-Width) div 2;
// Top:=(Screen.Height-Height) div 2;
//mangohudPageControl.ActivePage:=visualTabsheet; //Set initial TAB
mangohudPageControl.ActivePage:=presetTabsheet; //Set initial TAB
// Initialize menu selections
mangohudsel := true;
mangohudPanel.Visible:=true;
vkbasaltsel := false;
vkbasaltPanel.Visible:=false;
// Start vkcube (vulkan demo)
Process := TProcess.Create(nil);
Process.Executable := 'sh';
Process.Parameters.Add('-c');
Process.Parameters.Add('mangohud vkcube');
Process.Options := [poUsePipes];
Process.Execute;
// Define important file paths
GOVERLAYFOLDER:= '$HOME/.config/goverlay/' ;
MANGOHUDFOLDER:= '$HOME/.config/MangoHud/' ;
MANGOHUDCFGFILE:= '$HOME/.config/MangoHud/MangoHud.conf' ;
CUSTOMCFGFILE:= '$HOME/.config/MangoHud/custom.conf' ;
FONTFOLDER := '/usr/share/fonts/';
USERHOME := GetEnvironmentVariable('HOME') ;
//Load avaiable text fonts in /usr/share/fonts
ListarFontesNoDiretorio('/usr/share/fonts/', fontComboBox);
//Detect system GPUs
// Count the number of detected GPUs
Process1 := TProcess.Create(nil);
saida := TStringList.Create;
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('lspci | grep -i "VGA\|video" | wc -l'); //Count the number of lines
Process1.Options := [poUsePipes];
Process1.WaitOnExit;
Process1.Execute;
saida.LoadFromStream(Process1.output);
GPUNUMBER:= strtoint(saida[0]);
Process1.Free;
saida.Free;
i := 1; // Integer variable to the while loop
GPUDESC := TStringList.Create; // List variable for GPU descriptions
while i <= GPUNUMBER do
begin
//Read GPU0 pcidev
Process1 := TProcess.Create(nil);
saida := TStringList.Create;
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('lspci | grep -i "VGA\|video" | sed -n "' + inttostr(i) + 'p" | cut -c 1-7'); //Pick just the "i" line
Process1.Options := [poUsePipes];
Process1.WaitOnExit;
Process1.Execute;
saida.LoadFromStream(Process1.output);
pcidevComboBox.Items.Insert(i-1, saida[0]); //First position of combobox is 0, so we need i-1
Process1.Free;
saida.Free;
//Read GPU description
Process1 := TProcess.Create(nil);
saida := TStringList.Create;
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('lspci | grep -i "VGA\|video" | sed -n "' + inttostr(i) + 'p" |cut -d" " -f3- | cut -d ":" -f2-'); //Pick just the first line
Process1.Options := [poUsePipes];
Process1.WaitOnExit;
Process1.Execute;
saida.LoadFromStream(Process1.output);
GPUDESC.Add(saida[0]);
Process1.Free;
saida.Free;
i := i + 1; //increment "i"variable
end; //while
//Detect network devices on startup
GetNetworkInterfaces(networkcombobox);
//Determine toggle position - MangoHUD
Process1 := TProcess.Create(nil);
saida := TStringList.Create;
Process1.Executable := 'sh';
Process1.Parameters.Add('-c');
Process1.Parameters.Add('cat /etc/environment | grep MANGOHUD=1');
Process1.Options := [poUsePipes];
Process1.Execute;
Process1.WaitOnExit;
saida.LoadFromStream(Process1.output);
if saida.Count > 0 then // Count will prevent the out of bound error, case the string doesn't exist
geSpeedbutton.ImageIndex := 1
else
geSpeedbutton.ImageIndex := 0;
Process1.Free;
saida.Free;
// Initial STOCK values
alphavalueLabel.Caption:= FormatFloat('#0.0', transpTrackbar.Position/10);
fontsizevalueLabel.Caption:=inttostr(fontsizeTrackbar.Position);
fontcombobox.ItemIndex:=0;
afvalueLabel.Caption:= FormatFloat('#0', afTrackbar.Position);
mipmapvalueLabel.Caption:= FormatFloat('#0', mipmapTrackbar.Position);
logfolderEdit.text := USERHOME;
durationvalueLabel.Caption:=FormatFloat('#0', durationTrackbar.Position) +'s';
delayvalueLabel.Caption:=FormatFloat('#0', delayTrackbar.Position) + 's' ;
intervalvalueLabel.Caption:=FormatFloat('#0', intervalTrackbar.Position) + 'ms' ;
columvalueLabel.Caption:='3';
columShape.Visible:=true;
columShape1.Visible:=true;
columShape2.Visible:=true;
columShape3.Visible:=false;
columShape4.Visible:=false;
columShape5.Visible:=false;
// Load Mangohud config file
//################################################# EDITs
//HUD TILE
if LoadValue('custom_text_center',AUX) then
hudtitleEdit.Text:= AUX;
//GPU Text
if LoadValue('gpu_text',AUX) then
gpunameEdit.Text:= AUX;
//CPU Text
if LoadValue('cpu_text',AUX) then
cpunameEdit.Text:= AUX;
//Log folder
if LoadValue('output_folder',AUX) then
logfolderEdit.Text:= AUX;
//################################################# Trackbars
//Background alpha
if LoadValue('background_alpha',AUX) then
transpTrackbar.Position := Round(StrToFloat(AUX) * 10);
//Font size
if LoadValue('font_size',AUX) then
fontsizeTrackbar.Position := Round(StrToFloat(AUX));
//AF
if LoadValue('af',AUX) then
afTrackbar.Position := Round(StrToFloat(AUX));
//Mipmap
if LoadValue('picmip',AUX) then
mipmapTrackbar.Position := Round(StrToFloat(AUX));
//Log duration
if LoadValue('log_duration',AUX) then
durationTrackbar.Position := Round(StrToFloat(AUX));
//Log delay
if LoadValue('autostart_log',AUX) then
delayTrackbar.Position := Round(StrToFloat(AUX));
//Log interval
if LoadValue('log_interval',AUX) then
intervalTrackbar.Position := Round(StrToFloat(AUX));
//################################################# Spinedit
//offet
if LoadValue('#offset',AUX) then
offsetSpinedit.value := Round(StrToint(AUX) );
//################################################# Radio buttons
//Orientation
if LoadName('horizontal') then
horizontalRadiobutton.Checked := True
else
verticalRadiobutton.Checked := True;
//Round corners
if LoadValue('round_corners',AUX) then
begin
if strtoint(AUX) = 0 then
squareRadiobutton.Checked:=true
else
roundRadiobutton.Checked:=true;
end;
//Position
if LoadValue('position',AUX) then
begin
case AUX of
'top-left': topleftRadiobutton.Checked:=true;
'top-center': topcenterRadiobutton.Checked:=true;
'top-right': toprightRadiobutton.Checked:=true;
'middle-right': middlerightRadiobutton.Checked:=true;
'middle-left': middleleftRadiobutton.Checked:=true;
'bottom-left': bottomleftRadiobutton.Checked:=true;
'bottom-center': bottomcenterRadiobutton.Checked:=true;
'bottom-right': bottomrightRadiobutton.Checked:=true;
end; //case
end; //if
//################################################# Checkgroups
//FPS limits
if LoadValue('fps_limit',AUX) then
begin
LoadCheckgroup(fpslimCheckGroup, '240, 120, 30');
//################################################# Radiogroups
//Filters
if LoadName('bicubic') then
filterRadiogroup.ItemIndex:=1;
if LoadName('trilinear') then
filterRadiogroup.ItemIndex:=2;
if LoadName('retro') then
filterRadiogroup.ItemIndex:=3;
//################################################# Comboboxes
//Method
if LoadValue('fps_limit_method',AUX) then
begin
case AUX of
'late': fpslimmetCombobox.ItemIndex:=0;
'early': fpslimmetCombobox.ItemIndex:=1;
end; //case
end; //if
//toggle hud
if LoadValue('toggle_hud',AUX) then
begin
case AUX of
'Shift_R+F12': hudonoffCombobox.ItemIndex:=0;
'Shift_R+F1': hudonoffCombobox.ItemIndex:=1;
'Shift_R+F2': hudonoffCombobox.ItemIndex:=2;
'Shift_R+F3': hudonoffCombobox.ItemIndex:=3;
'Shift_R+F4': hudonoffCombobox.ItemIndex:=4;
else
hudonoffCombobox.ItemIndex:=5;
end; //case
end; //if
//toggle fps limit
if LoadValue('toggle_fps_limit',AUX) then
begin
case AUX of
'Shift_L+F1': fpslimtoggleCombobox.ItemIndex:=0;
'Shift_L+F2': fpslimtoggleCombobox.ItemIndex:=1;
'Shift_L+F3': fpslimtoggleCombobox.ItemIndex:=2;
'Shift_L+F4': fpslimtoggleCombobox.ItemIndex:=3;
else
fpslimtoggleCombobox.ItemIndex:=4;
end; //case
end; //if
//vulkan vsync
if LoadValue('vsync',AUX) then
begin
case AUX of
'0': vsyncCombobox.ItemIndex:=0;
'1': vsyncCombobox.ItemIndex:=1;
'2': vsyncCombobox.ItemIndex:=2;
'3': vsyncCombobox.ItemIndex:=3;
'4': vsyncCombobox.ItemIndex:=4;
end; //case
end; //if
//GL vsync
if LoadValue('gl_vsync',AUX) then
begin
case AUX of
'-1': glvsyncCombobox.ItemIndex:=0;
'0': glvsyncCombobox.ItemIndex:=1;
'1': glvsyncCombobox.ItemIndex:=2;