-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptions.pas
1614 lines (1456 loc) · 52.3 KB
/
Options.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
{ MPUI-hcb, an MPlayer frontend for Windows
Copyright (C) 2006-2013 Huang Chen Bin <hcb428@foxmail.com>
based on work by Martin J. Fiedler <martin.fiedler@gmx.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit Options;
interface
uses
Windows, TntWindows, Messages, SysUtils, TntSysUtils, Variants, Classes, Graphics, Controls,
Forms, TntForms, TntDialogs, StdCtrls, ShellAPI, ComCtrls, ExtCtrls, TntSystem,
TntExtCtrls, TntComCtrls, TntStdCtrls, TntFileCtrl, TntRegistry, TntClasses,
jpeg, CheckLst, ShlObj, Dialogs, ActiveX, TntGraphics, Math, TntMenus;
type
Tass = class(TThread)
protected
procedure Execute; override;
end;
TOptionsForm = class(TTntForm)
BOK: TTntButton;
BApply: TTntButton;
BSave: TTntButton;
BClose: TTntButton;
EParams: TTntEdit;
LParams: TTntLabel;
LHelp: TTntLabel;
Tab: TTntPageControl;
TSystem: TTntTabSheet;
TVideo: TTntTabSheet;
TAudio: TTntTabSheet;
TLog: TTntTabSheet;
TSub: TTntTabSheet;
LAudioOut: TTntLabel;
CAudioOut: TTntComboBox;
LPostproc: TTntLabel;
CPostproc: TTntComboBox;
LAspect: TTntLabel;
CAspect: TTntComboBox;
LDeinterlace: TTntLabel;
CDeinterlace: TTntComboBox;
LLanguage: TTntLabel;
CLanguage: TTntComboBox;
LAudioDev: TTntLabel;
CAudioDev: TComboBox;
CSoftVol: TTntCheckBox;
CVolnorm: TTntCheckBox;
double: TTntCheckBox;
CDr: TTntCheckBox;
nfconf: TTntCheckBox;
EMplayerLocation: TTntEdit;
BSubfont: TTntButton;
BMplayer: TTntButton;
CSubcp: TComboBox;
CMAspect: TComboBox;
LMAspect: TTntLabel;
CSPDIF: TTntCheckBox;
CCh: TComboBox;
CWid: TTntCheckBox;
CFlip: TTntCheckBox;
CYuy2: TTntCheckBox;
CEq2: TTntCheckBox;
CIndex: TTntCheckBox;
CMir: TTntCheckBox;
CNi: TTntCheckBox;
CDnav: TTntCheckBox;
CUtf: TTntCheckBox;
CUni: TTntCheckBox;
TFsize: TTrackBar;
TFol: TTrackBar;
EWadsp: TTntEdit;
BWadsp: TTntButton;
CWadsp: TTntCheckBox;
CLavf: TTntCheckBox;
RCMplayer: TTntRadioButton;
RMplayer: TTntRadioButton;
TFB: TTrackBar;
SSubcode: TTntStaticText;
SSubfont: TTntStaticText;
SFsize: TTntStaticText;
SFB: TTntStaticText;
SFol: TTntStaticText;
SFsP: TTntStaticText;
SFBl: TTntStaticText;
SFo: TTntStaticText;
CFd: TTntCheckBox;
CAsync: TTntCheckBox;
EAsync: TTntEdit;
UAsync: TTntUpDown;
CCache: TTntCheckBox;
ECache: TTntEdit;
UCache: TTntUpDown;
CPriorityBoost: TTntCheckBox;
CRFScr: TTntCheckBox;
CSubfont: TTntComboBox;
BOsdfont: TButton;
SFontColor: TTntStaticText;
SOutline: TTntStaticText;
PTc: TPanel;
POc: TPanel;
ColorDialog1: TColorDialog;
CAss: TTntCheckBox;
CEfont: TTntCheckBox;
CRot: TComboBox;
CISub: TTntCheckBox;
SSF: TTntStaticText;
BSsf: TTntButton;
ESsf: TTntEdit;
SOsdfont: TTntCheckBox;
LCh: TTntStaticText;
LRot: TTntStaticText;
Cone: TTntCheckBox;
CGUI: TTntCheckBox;
CNobps: TTntCheckBox;
CFilter: TTntCheckBox;
TLyric: TTntGroupBox;
LTCL: TTntLabel;
PLTC: TPanel;
LHCL: TTntLabel;
PLBC: TPanel;
LBCL: TTntLabel;
PLHC: TPanel;
SLyric: TTntLabel;
ELyric: TTntEdit;
BLyric: TTntButton;
Ldlod: TTntCheckBox;
CVSync: TTntCheckBox;
BFont: TButton;
FontDialog1: TFontDialog;
LVideoout: TTntLabel;
CVideoOut: TComboBox;
THelp: TTntTabSheet;
TAbout: TTntTabSheet;
LURL: TLabel;
MCredits: TMemo;
HelpText: TTntMemo;
PLogo: TPanel;
ILogo: TImage;
MTitle: TTntLabel;
LVersionMPUI: TTntLabel;
VersionMPUI: TTntLabel;
LVersionMPlayer: TTntLabel;
VersionMPlayer: TTntLabel;
FY: TTntLabel;
CRS: TTntCheckBox;
CSP: TTntCheckBox;
HCB: TTntLabel;
TheLog: TTntMemo;
Command: TTntEdit;
CRP: TTntCheckBox;
CTime: TTntCheckBox;
TOther: TTntTabSheet;
TFass: TCheckListBox;
TFadd: TTntButton;
TEAss: TTntEdit;
TFSet: TTntButton;
TFdel: TTntButton;
TBa: TTntButton;
TBn: TTntButton;
CDs: TTntCheckBox;
HK: TTntListView;
RHK: TTntButton;
TseekL: TTntLabel;
Eseek: TTntEdit;
TUnit: TTntLabel;
nmsgm: TTntCheckBox;
Esubfont: TTntEdit;
Cosdfont: TTntComboBox;
Eosdfont: TTntEdit;
Cconfig: TTntCheckBox;
CAddsfiles: TTntCheckBox;
CLS: TTntCheckBox;
EAV: TTntEdit;
UDAV: TTntUpDown;
CAV: TTntCheckBox;
ads: TTntCheckBox;
procedure BCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure LHelpClick(Sender: TObject);
procedure BApplyClick(Sender: TObject);
procedure BOKClick(Sender: TObject);
procedure BSaveClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CAudioOutChange(Sender: TObject);
procedure BSubfontClick(Sender: TObject);
procedure BMplayerClick(Sender: TObject);
procedure CDDXAClick(Sender: TObject);
procedure TFsizeChange(Sender: TObject);
procedure TFolChange(Sender: TObject);
procedure CWadspClick(Sender: TObject);
procedure BWadspClick(Sender: TObject);
procedure RMplayerClick(Sender: TObject);
procedure RCMplayerClick(Sender: TObject);
procedure TFBChange(Sender: TObject);
procedure CAsyncClick(Sender: TObject);
procedure CCacheClick(Sender: TObject);
procedure FontChange(Sender: TObject);
procedure BOsdfontClick(Sender: TObject);
procedure SetColor(Sender: TObject);
procedure CAssClick(Sender: TObject);
procedure SOsdfontClick(Sender: TObject);
procedure BSsfClick(Sender: TObject);
procedure BFontClick(Sender: TObject);
procedure CommandKeyPress(Sender: TObject; var Key: Char);
procedure CommandKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure TabChange(Sender: TObject);
procedure TFaddClick(Sender: TObject);
procedure TFdelClick(Sender: TObject);
procedure TBaClick(Sender: TObject);
procedure TBnClick(Sender: TObject);
procedure TFSetClick(Sender: TObject);
procedure HKDblClick(Sender: TObject);
procedure HKKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure HKClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure HKKeyPress(Sender: TObject; var Key: Char);
procedure LoadHotKey;
procedure SaveHotKey;
procedure RHKClick(Sender: TObject);
procedure CSubfontDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure CSubfontMeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
procedure CSubfontChange(Sender: TObject);
procedure LURLClick(Sender: TObject);
procedure CosdfontMeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
procedure CosdfontDrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure CSubfontDropDown(Sender: TObject);
procedure CAVClick(Sender: TObject);
private
{ Private declarations }
HelpFile, tCap: WideString;
Changed, oML, Ikey: boolean;
History: TTntStringList;
HistoryPos, sIndex: integer;
public
{ Public declarations }
procedure Localize;
procedure ApplyValues;
procedure LoadValues;
procedure AddLine(const Line: Widestring);
function HotKeyToOldKey(var Shift: TShiftState; var Key: Word): TListItem;
procedure GetFass;
procedure SetFass;
end;
PDSEnumCallback = function(lpGuid: PGUID; lpcstrDescription, lpcstrModule: PChar; lpContext: pointer): LongBool; stdcall;
ASSOCIATIONLEVEL = (AL_MACHINE, AL_EFFECTIVE, AL_USER);
ASSOCIATIONTYPE = (AT_FILEEXTENSION, AT_URLPROTOCOL, AT_STARTMENUCLIENT, AT_MIMETYPE);
IApplicationAssociationRegistration = interface(IUnknown)
['{4e530b0a-e611-4c77-a3ac-9031d022281b}']
function QueryCurrentDefault(pszQuery: PWChar; atQueryType: ASSOCIATIONTYPE; alQueryLevel: ASSOCIATIONLEVEL; out ppszAssociation: PPWideChar): HRESULT; stdcall;
function QueryAppIsDefault(pszQuery: PWChar; atQueryType: ASSOCIATIONTYPE; alQueryLevel: ASSOCIATIONLEVEL; pszAppRegistryName: PWChar; out pfDefault: PBool): HRESULT; stdcall;
function QueryAppIsDefaultAll(alQueryLevel: ASSOCIATIONLEVEL; pszAppRegistryName: PWChar; out pfDefault: PBool): HRESULT; stdcall;
function SetAppAsDefault(pszAppRegistryName: PWChar; pszSet: PWChar; atSetType: ASSOCIATIONTYPE): HRESULT; stdcall;
function SetAppAsDefaultAll(pszAppRegistryName: PWChar): HRESULT; stdcall;
function ClearUserAssociations: HRESULT; stdcall;
end;
const CLSID_ApplicationAssociationRegistration: TGUID = '{591209c7-767b-42b2-9fba-44ee4615f2c7}';
IID_IApplicationAssociationRegistration: TGUID = '{4e530b0a-e611-4c77-a3ac-9031d022281b}';
procedure LoadDsLibrary;
procedure UnLoadDsLibrary;
function KeyboardHook(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LResult; stdcall;
procedure regAss();
procedure HkToShiftKey(const Hk: integer; var Shift: TShiftState; var Key: Word);
var
OptionsForm: TOptionsForm; IsDsLoaded: THandle = 0; OptionsFormHook: HHOOK; ctrlkey: TShiftState = [];
implementation
uses Core, Config, Main, Locale, plist, unrar, LyricShow;
{$R *.dfm}
var DirectSoundEnumerate: function(lpDSEnumCallback: PDSEnumCallback; lpContext: pointer): HRESULT; stdcall;
procedure LoadDsLibrary;
begin
if IsDsLoaded <> 0 then exit;
IsDsLoaded := Tnt_LoadLibraryW('dsound.dll');
if IsDsLoaded <> 0 then
@DirectSoundEnumerate := GetProcAddress(IsDsLoaded, 'DirectSoundEnumerateA');
end;
procedure UnLoadDsLibrary;
begin
if IsDsLoaded <> 0 then begin
FreeLibrary(IsDsLoaded);
IsDsLoaded := 0;
DirectSoundEnumerate := nil;
end;
end;
procedure TOptionsForm.BCloseClick(Sender: TObject);
begin
Close;
end;
function GetProductVersion(const FileName: WideString): WideString;
var BufSize, cbSize, VerLen: Cardinal;
VerOut: PWideChar; Buf: array of WideChar;
begin
Result := '?';
BufSize := Tnt_GetFileVersionInfoSizeW(PWideChar(FileName), cbSize);
if BufSize = 0 then exit;
SetLength(Buf, BufSize);
if not Tnt_GetFileVersionInfoW(PWideChar(FileName), 0, BufSize, Buf) then exit;
if not Tnt_VerQueryValueW(Buf, '\StringFileInfo\000004B0\ProductVersion', Pointer(VerOut), VerLen) then exit;
Result := VerOut;
end;
function GetFileVersion(const FileName: WideString): WideString;
var BufSize, cbSize, VerLen: Cardinal;
Info: ^VS_FIXEDFILEINFO; Buf: array of WideChar;
begin
Result := '?';
BufSize := Tnt_GetFileVersionInfoSizeW(PWideChar(FileName), cbSize);
if BufSize = 0 then exit;
SetLength(Buf, BufSize);
if not Tnt_GetFileVersionInfoW(PWideChar(FileName), 0, BufSize, Buf) then exit;
if not Tnt_VerQueryValueW(Buf, '\', Pointer(Info), VerLen) then exit;
Result := IntToStr(Info.dwFileVersionMS shr 16) + '.' +
IntToStr(Info.dwFileVersionMS and $FFFF) + '.' +
IntToStr(Info.dwFileVersionLS shr 16) + ' build ' +
IntToStr(Info.dwFileVersionLS and $FFFF);
if (Info.dwFileFlags and VS_FF_DEBUG <> 0) then Result := Result + ' (debug)';
if (Info.dwFileFlags and VS_FF_PRERELEASE <> 0) then Result := Result + ' (pre-release)';
end;
procedure TOptionsForm.Localize;
var i: integer;
begin
with MainForm do begin
MTitle.Caption := LOCstr_Title;
LAspect.Caption := MAspects.Caption;
CAspect.Items[0] := MAutoAspect.Caption;
CAspect.Items[MAspects.Count - 1] := Copy(MCustomAspect.Caption, 1, Pos(' ', MCustomAspect.Caption)) + IntToStr(InterW) + ':' + IntToStr(InterH);
LDeinterlace.Caption := MDeinterlace.Caption;
CDeinterlace.Items[0] := MNoDeint.Caption;
CDeinterlace.Items[1] := MSimpleDeint.Caption;
CDeinterlace.Items[2] := MAdaptiveDeint.Caption;
MPostproc.Caption := LPostproc.Caption;
MPostOff.Caption := CPostproc.Items[0];
MPostAuto.Caption := CPostproc.Items[1];
MPostquality.Caption := CPostproc.Items[2];
CAudioOut.Items[2] := LOCstr_AutoLocale;
LLanguage.Caption := MLanguage.Caption;
PlaylistForm.PLTC.Hint := LTCL.Caption;
PlaylistForm.PLHC.Hint := LHCL.Caption;
PlaylistForm.PLBC.Hint := LBCL.Caption;
CLanguage.Clear;
CLanguage.Items.Add(LOCstr_AutoLocale);
for i := 0 to High(Locales) do
CLanguage.Items.Add(Locales[i].Name);
end;
end;
procedure TOptionsForm.FormShow(Sender: TObject);
begin
LoadValues; TabChange(nil); Changed := false;
if ML then HelpFile := WideExtractFileDir(MplayerLocation) + '\Mplayer.html'
else HelpFile := HomeDir + 'Mplayer.html';
if not WideFileExists(HelpFile) then begin
HelpFile := WideExtractFileDir(HelpFile) + '\MPlayer.html';
if not WideFileExists(HelpFile) then HelpFile := '';
end;
if length(HelpFile) > 0 then begin
LHelp.Visible := true;
HelpFile := #34 + HelpFile + #34;
end
else
LHelp.Visible := false;
if (left + width) >= (CurMonitor.Left + CurMonitor.Width) then left := CurMonitor.Left + CurMonitor.Width - width;
if left < CurMonitor.Left then left := CurMonitor.Left; if top < CurMonitor.Top then top := CurMonitor.Top;
if (top + height) >= (CurMonitor.Top + CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top) then
top := CurMonitor.Top + CurMonitor.WorkareaRect.Bottom - CurMonitor.WorkareaRect.Top - height;
end;
procedure TOptionsForm.LHelpClick(Sender: TObject);
begin
if length(HelpFile) > 0 then begin
if Win32PlatformIsUnicode then
ShellExecuteW(Handle, 'open', PWideChar(HelpFile), nil, nil, SW_SHOW)
else ShellExecute(Handle, 'open', PAnsiChar(AnsiString(HelpFile)), nil, nil, SW_SHOW);
end;
end;
procedure TOptionsForm.GetFass;
var i: integer;
begin
if fass = '' then fass := DefaultFass;
TFass.Items.CommaText := fass;
for i := 0 to TFass.Count - 1 do begin
TFass.Checked[i] := TFass.Items[i][1] <> '0';
TFass.Items[i] := Trim(Tnt_WideLowerCase(copy(TFass.Items[i], 2, MaxInt)));
end;
end;
procedure TOptionsForm.SetFass;
var i: integer;
begin
fass := '';
for i := 0 to TFass.Count - 1 do begin
if TFass.Checked[i] then fass := fass + ',1' + TFass.Items[i]
else fass := fass + ',0' + TFass.Items[i];
end;
delete(fass, 1, 1);
end;
procedure TOptionsForm.LoadValues;
begin
Load(HomeDir + DefaultFileName, 1);
CAudioOut.ItemIndex := AudioOut;
CAudioDev.ItemIndex := AudioDev;
Ldlod.Checked := dlod;
Ldlod.Enabled:= Assigned(LyricShowForm);
CIndex.Checked := ReIndex;
CSoftVol.Checked := SoftVol;
CRFScr.Checked := RFScr;
CAddsfiles.Checked := Addsfiles;
CLS.Checked := ADls;
CDr.Checked := Dr;
Double.Checked := dbbuf;
CVolnorm.Checked := Volnorm;
nfconf.Checked := nfc;
nmsgm.Checked := nmsg;
CSubcp.Text := subcode;
oML := ML;
EAV.Text:=avThread;
CAV.Checked:=UAV; CAVClick(nil);
RMplayer.Checked := ML;
RCMplayer.Checked := not ML;
EMplayerLocation.Enabled := ML;
BMplayer.Enabled := ML;
CWid.Checked := Wid;
CDs.Checked := ds;
CRS.Checked := RS;
CSP.Checked := SP;
CRP.Checked := RP;
CTime.Checked := CT;
EMplayerLocation.Text := MplayerLocation;
CMAspect.Text := MAspect;
CVideoOut.Text := VideoOut;
CCh.ItemIndex := Ch;
CRot.ItemIndex := Rot;
CSPDIF.Checked := SPDIF;
CFlip.Checked := Flip;
CMir.Checked := Mirror;
CEq2.Checked := Eq2;
CYuy2.Checked := Yuy2;
CVSync.Checked := vsync;
CEq2.Enabled := not Dda;
CYuy2.Enabled := CEq2.Enabled;
LDeinterlace.Enabled := CEq2.Enabled;
CDeinterlace.Enabled := CEq2.Enabled;
CNi.Checked := ni;
CNobps.Checked := nobps;
CFilter.Checked := FilterDrop;
CDnav.Checked := Dnav;
CUni.Checked := Uni;
CUtf.Checked := Utf;
CWadsp.Checked := Wadsp;
EWadsp.Enabled := Wadsp;
BWadsp.Enabled := Wadsp;
Cconfig.Enabled := Wadsp;
Cconfig.Checked := sconfig;
EWadsp.Text := WadspL;
Clavf.Checked := lavf;
CFd.Checked := Fd;
CAsync.Checked := Async;
EAsync.Enabled := Async;
UAsync.Enabled := Async;
EAsync.Text := AsyncV;
CCache.Checked := Cache;
ECache.Enabled := Cache;
UCache.Enabled := Cache;
ECache.Text := CacheV;
CPriorityBoost.Checked := Pri;
EParams.Text := Params;
CAudioOutChange(nil);
TFsize.Position := round(FSize * 10);
TFol.Position := round(Fol * 10);
TFB.Position := round(FB * 10);
CAspect.Items[MainForm.MAspects.Count - 1] := Copy(MainForm.MCustomAspect.Caption, 1, Pos(' ', MainForm.MCustomAspect.Caption)) + IntToStr(InterW) + ':' + IntToStr(InterH);
CAspect.ItemIndex := Aspect;
CDeinterlace.ItemIndex := Deinterlace;
CLanguage.ItemIndex := DefaultLocale + 1;
CPostproc.ItemIndex := Postproc;
EOsdfont.Text := osdfont;
Esubfont.Text := subfont;
PLTC.Color := LTextColor;
PLBC.Color := LbgColor;
PLHC.Color := LhgColor;
BFont.Caption := LyricF;
BFont.Font.Size:=LyricS;
PTc.color := TextColor;
PTc.Enabled := Ass;
POc.color := OutColor;
POc.Enabled := Ass;
CAss.Checked := Ass;
CEfont.Checked := Efont;
CEfont.Enabled := Ass;
SfontColor.Enabled := Ass;
SOutline.Enabled := Ass;
CISub.Checked := ISub;
ESsf.Text := ShotDir;
ELyric.Text := LyricDir;
SOsdfont.Checked := uof;
COsdfont.Enabled := uof;
BOsdfont.Enabled := uof;
EOsdfont.Enabled := uof;
Cone.Checked := oneM;
CGUI.Checked := GUI;
Eseek.Text := IntToStr(seekLen);
ads.Checked:= AutoDs;
fontchange(EOsdfont); fontchange(ESubfont);
end;
procedure TOptionsForm.ApplyValues;
var s: string; ws: WideString; i,a: integer; f: real; b: boolean;
begin
if AudioOut <> CAudioOut.ItemIndex then begin
AudioOut := CAudioOut.ItemIndex; changed := true;
end;
if AudioDev <> CAudioDev.ItemIndex then begin
AudioDev := CAudioDev.ItemIndex; changed := true;
end;
if Postproc <> CPostproc.ItemIndex then begin
Postproc := CPostproc.ItemIndex; changed := true;
end;
if Aspect <> CAspect.ItemIndex then begin
Aspect := CAspect.ItemIndex; changed := true;
end;
if Deinterlace <> CDeinterlace.ItemIndex then begin
Deinterlace := CDeinterlace.ItemIndex; changed := true;
end;
if ReIndex <> CIndex.Checked then begin
ReIndex := CIndex.Checked; changed := true;
end;
if SoftVol <> CSoftVol.Checked then begin
SoftVol := CSoftVol.Checked; changed := true;
end;
MainForm.UpdateVolSlider;
if Dr <> CDr.Checked then begin
Dr := CDr.Checked; changed := true;
end;
if dbbuf <> double.Checked then begin
dbbuf := double.Checked; changed := true;
end;
if Volnorm <> CVolnorm.Checked then begin
Volnorm := CVolnorm.Checked; changed := true;
end;
if nfc <> nfconf.Checked then begin
nfc := nfconf.Checked; changed := true;
end;
if nmsg <> nmsgm.Checked then begin
nmsg := nmsgm.Checked; changed := true;
end;
if subcode <> CSubcp.Text then begin
subcode := CSubcp.Text; changed := true;
MainForm.SSD.Caption := subcode; MainForm.SSD.Checked := True;
end;
if uof <> SOsdfont.Checked then begin
uof := SOsdfont.Checked; changed := true;
end;
if CheckSubfont(osdfont) <> CheckSubfont(EOsdfont.Text) then begin
osdfont := EOsdfont.Text;
if EOsdfont.Enabled then changed := true;
end;
if CheckSubfont(subfont) <> CheckSubfont(Esubfont.Text) then begin
subfont := ESubfont.Text; changed := true;
end;
if oML <> ML then begin
ML := oML; changed := true;
end;
if MplayerLocation <> EMplayerLocation.Text then begin
MplayerLocation := EMplayerLocation.Text;
if EMplayerLocation.Enabled then changed := true;
end;
s := Trim(CMAspect.Text);
if MAspect <> s then begin
MAspect := s; changed := true;
end;
s := Trim(CVideoOut.Text);
if VideoOut <> s then begin
VideoOut := s; changed := true;
end;
b := Trim(LowerCase(VideoOut)) = 'directx:noaccel';
if Dda <> b then begin
Dda := b; changed := true;
end;
if Ch <> CCh.ItemIndex then begin
Ch := CCh.ItemIndex; changed := true;
end;
if Rot <> CRot.ItemIndex then begin
Rot := CRot.ItemIndex; changed := true;
end;
if SPDIF <> CSPDIF.Checked then begin
SPDIF := CSPDIF.Checked; changed := true;
end;
if Wid <> CWid.Checked then begin
Wid := CWid.Checked; changed := true;
end;
if Flip <> CFlip.Checked then begin
Flip := CFlip.Checked; changed := true;
end;
if Mirror <> CMir.Checked then begin
Mirror := CMir.Checked; changed := true;
end;
if Eq2 <> CEq2.Checked then begin
Eq2 := CEq2.Checked; changed := true;
end;
if Yuy2 <> CYuy2.Checked then begin
Yuy2 := CYuy2.Checked; changed := true;
end;
if ni <> CNi.Checked then begin
ni := CNi.Checked; changed := true;
end;
if nobps <> CNobps.Checked then begin
nobps := CNobps.Checked; changed := true;
end;
if FilterDrop <> CFilter.Checked then begin
FilterDrop := CFilter.Checked; changed := true;
end;
if Dnav <> CDnav.Checked then begin
Dnav := CDnav.Checked; changed := true;
end;
if Uni <> CUni.Checked then begin
Uni := CUni.Checked; changed := true;
end;
if Utf <> CUtf.Checked then begin
Utf := CUtf.Checked; changed := true;
end;
f := TFsize.Position / 10;
if FSize <> f then begin
FSize := f; changed := true;
end;
f := TFol.Position / 10;
if Fol <> f then begin
Fol := f; changed := true;
end;
f := TFB.Position / 10;
if FB <> f then begin
FB := f; changed := true;
end;
if Wadsp <> CWadsp.Checked then begin
Wadsp := CWadsp.Checked; changed := true;
end;
if WadspL <> EWadsp.Text then begin
WadspL := EWadsp.Text;
if EWadsp.Enabled then changed := true;
end;
if Cconfig.Checked <> sconfig then begin
sconfig := Cconfig.Checked;
if Cconfig.Enabled then changed := true;
end;
if lavf <> Clavf.Checked then begin
lavf := Clavf.Checked; changed := true;
end;
if Fd <> CFd.Checked then begin
Fd := CFd.Checked; changed := true;
end;
if Async <> CAsync.Checked then begin
Async := CAsync.Checked; changed := true;
end;
if AsyncV <> EAsync.Text then begin
AsyncV := EAsync.Text;
if EAsync.Enabled then changed := true;
end;
if UAV <> CAV.Checked then begin
UAV := CAV.Checked; changed := true;
end;
if AVThread <> EAV.Text then begin
AVThread := EAV.Text;
if CAV.Enabled then changed := true;
end;
if Cache <> CCache.Checked then begin
Cache := CCache.Checked; changed := true;
end;
if CacheV <> ECache.Text then begin
CacheV := ECache.Text;
if ECache.Enabled then changed := true;
end;
if Pri <> CPriorityBoost.Checked then begin
Pri := CPriorityBoost.Checked; changed := true;
end;
ws := Trim(EParams.Text);
if Params <> ws then begin
Params := ws; changed := true;
end;
i := ColorToRGB(PTc.color);
if TextColor <> i then begin
TextColor := i; changed := true;
end;
i := ColorToRGB(POc.color);
if OutColor <> i then begin
OutColor := i; changed := true;
end;
if Ass <> CAss.Checked then begin
Ass := CAss.Checked; changed := true;
end;
if Efont <> CEfont.Checked then begin
Efont := CEfont.Checked;
if CEfont.Enabled then changed := true;
end;
if ISub <> CISub.Checked then begin
ISub := CISub.Checked; changed := true;
end;
if GUI <> CGUI.Checked then begin
GUI := CGUI.Checked; changed := true;
end;
if ShotDir <> ESsf.Text then begin
ShotDir := ESsf.Text; changed := true;
end;
RFScr := CRFScr.Checked;
with MainForm do begin
if RFScr then begin
OPanel.PopupMenu := nil; IPanel.PopupMenu := nil;
end
else begin
OPanel.PopupMenu := MPopup; IPanel.PopupMenu := MPopup;
end;
end;
if Running and (vsync <> CVSync.Checked) then begin
if CVSync.Checked then SendCommand('set_property vsync 1')
else SendCommand('set_property vsync 0');
end;
if DefaultLocale <> (CLanguage.ItemIndex - 1) then begin
DefaultLocale := CLanguage.ItemIndex - 1;
ActivateLocale(DefaultLocale);
end;
if WideDirectoryExists(ELyric.Text) then LyricDir := ELyric.Text;
ds := CDs.Checked;
RP := CRP.Checked;
RS := CRS.Checked;
SP := CSP.Checked;
CT := CTime.Checked;
if not (CT or Running) then MainForm.LTime.Caption := '';
seekLen := StrToIntdef(Eseek.Text, 10);
vsync := CVSync.Checked;
oneM := Cone.Checked;
if dlod <> Ldlod.Checked then begin
if Ldlod.Checked then begin
GDILyric.FontName := Bfont.Caption;
if HaveLyric = 0 then exit;
GDILyric.GetFontHeight;
if MSecPos < Lyric.LyricTime[0].timecode then begin
if LyricCount=0 then GDILyric.DisplayLyricD(Lyric.GetLyricString(0),'')
else GDILyric.DisplayLyricD(Lyric.GetLyricString(0),Lyric.GetLyricString(1));
end;
if MSecPos > Lyric.LyricTime[LyricCount].timecode then begin
if CurLyric mod 2 = 0 then GDILyric.DisplayLyricD(Lyric.GetLyricString(CurLyric),'')
else GDILyric.DisplayLyricD(Lyric.GetLyricString(CurLyric-1),Lyric.GetLyricString(CurLyric));
end;
if (MSecPos >= Lyric.LyricTime[CurLyric].timecode) and (MSecPos <= Lyric.LyricTime[NextLyric].timecode) then begin
if CurLyric mod 2 = 0 then begin
if CurLyric = LyricCount then GDILyric.DisplayLyricD(Lyric.GetLyricString(CurLyric),'')
else GDILyric.DisplayLyricD(Lyric.GetLyricString(CurLyric),Lyric.GetLyricString(NextLyric));
end
else begin
if CurLyric = LyricCount then GDILyric.DisplayLyricD(Lyric.GetLyricString(CurLyric-1),Lyric.GetLyricString(CurLyric))
else GDILyric.DisplayLyricD(Lyric.GetLyricString(NextLyric),Lyric.GetLyricString(CurLyric));
end;
end;
if HaveLyric <> 0 then LyricShowForm.Show;
end
else
LyricShowForm.Hide;
end;
dlod := Ldlod.Checked;
LTextColor := ColorToRGB(PLTC.Color);
LbgColor := ColorToRGB(PLBC.Color);
LhgColor := ColorToRGB(PLHC.Color);
PlaylistForm.PLTC.Color := LTextColor;
PlaylistForm.PLBC.Color := LbgColor;
PlaylistForm.PLHC.Color := LhgColor;
if (LyricF <> Bfont.Caption) or (LyricS<> BFont.Font.Size) then begin
LyricF := Bfont.Caption; LyricS := BFont.Font.Size;
if Assigned(LyricShowForm) then GDILyric.SetFont(LyricF);
PlaylistForm.CLyricF.Text:=LyricF; PlaylistForm.CLyricS.Text:=IntToStr(LyricS);
Lyric.BitMap.Canvas.Font.Name := LyricF; Lyric.BitMap.Canvas.Font.Size := LyricS;
Lyric.ItemHeight:= WideCanvasTextHeight(Lyric.BitMap.Canvas,'S') + 4;
UpdatePW := True;
end;
ADls:=CLS.Checked;
AutoDs:=ads.Checked;
if Addsfiles=false then LastAddsfiles:= false;
Addsfiles := CAddsfiles.Checked;
if PlaylistForm.Visible then PlaylistForm.TMLyricPaint(nil);
MainForm.UpdateMenuCheck; SaveHotKey;
Save(HomeDir + DefaultFileName, 2);
for i := 0 to MainForm.SCodepage.Count - 3 do begin
s:= MainForm.SCodepage.Items[i].Caption;
a:=Pos('&',s);
s:=Copy(s,1,a-1)+ Copy(s,a+1,MaxInt);
if s=subcode then begin
MainForm.SCodepage.Items[i].Checked:=True;
Break;
end
else MainForm.SCodepage.Items[i].Checked:=false;
end;
end;
procedure TOptionsForm.BApplyClick(Sender: TObject);
begin
ApplyValues;
if Changed then begin
Changed := false;
Restart;
end;
CLanguage.ItemIndex := DefaultLocale + 1;
CAspect.ItemIndex := Aspect;
CDeinterlace.ItemIndex := Deinterlace;
CPostproc.ItemIndex := Postproc;
CAudioOut.ItemIndex := AudioOut;
CAudioDev.ItemIndex := AudioDev;
CSubcp.Text := subcode;
COsdfont.Text := osdfont;
CSubfont.Text := subfont;
EMplayerLocation.Text := MplayerLocation;
CMAspect.Text := MAspect;
CCh.ItemIndex := Ch;
CRot.ItemIndex := Rot;
ESsf.Text := ShotDir;
end;
procedure TOptionsForm.BSaveClick(Sender: TObject);
begin
BApplyClick(nil);
Config.Save(HomeDir + Config.DefaultFileName, 0);
end;
procedure TOptionsForm.BOKClick(Sender: TObject);
begin
Close;
ApplyValues;
if Changed then Restart;
end;
function EnumFunc(lpGuid: PGUID; lpcstrDescription, lpcstrModule: PChar; lpContext: pointer): LongBool; stdcall;
begin
TComboBox(lpContext^).Items.Add(lpcstrDescription);
Result := True;
end;
procedure TOptionsForm.FormCreate(Sender: TObject);
var o: Integer;
procedure initFontList;
var i, j: integer; s: string; sn, sp, lsn: widestring; DefaultFont: TFont;
reg: TTntRegistry; a: TTntStringList;
begin
DefaultFont := TFont.Create; DefaultFont.Handle := GetStockObject(DEFAULT_GUI_FONT);
FontPaths := TTntStringList.Create; a := TTntStringList.Create;
reg := TTntRegistry.Create; DefaultFontIndex := -1;
DefaultFont.Name := Trim(Tnt_WideLowerCase(DefaultFont.Name));
if Win32PlatformIsUnicode then s := '\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
else s := '\SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts';
with reg do begin
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly(s) then begin
GetValueNames(a); a.Sort;
for i := 0 to a.Count - 1 do begin
j := pos(' (TrueType)', a.Strings[i]);
if j > 0 then begin
sn := a.Strings[i]; sp := ReadString(sn);
sn := Trim(copy(sn, 1, j));
CSubfont.Items.Add(sn);
FontPaths.Add(Trim(Tnt_WideLowerCase(sp)));
lsn := Tnt_WideLowerCase(sn);
if (lsn = DefaultFont.Name) or
(Pos(DefaultFont.Name + ' & ', lsn) = 1) or
(Pos(' & ' + DefaultFont.Name, lsn) > 1) then
DefaultFontIndex := CSubfont.Items.Count - 1;
end;
end;
CloseKey;
end;
finally
Free; a.free;
end;
end;
COsdfont.Items := CSubfont.Items;
if subfont = '' then begin
if DefaultFontIndex = -1 then subfont := 'Arial'
else subfont := CSubfont.Items[DefaultFontIndex];
end;
if osdfont = '' then osdfont := subfont;
if not WideFileExists(CheckSubfont(subfont)) then subfont := HomeDir + 'mplayer\subfont.ttf';
if not WideFileExists(CheckSubfont(osdfont)) then osdfont := HomeDir + 'mplayer\subfont.ttf';
if LyricF = '' then begin
if DefaultFontIndex = -1 then LyricF := 'Tahoma'
else LyricF := DefaultFont.Name;
end;
DefaultFont.Free;
end;
begin
OptionsFormHook := SetWindowsHookEx(WH_KEYBOARD, @KeyboardHook, 0, GetCurrentThreadID);
initFontList; Ikey := false; LoadHotKey; GetFass;
Tab.TabIndex := 0; History := TTntStringList.Create;
if IsDsLoaded = 0 then LoadDsLibrary;
if IsDsLoaded <> 0 then DirectSoundEnumerate(EnumFunc, @CAudioDev);
CMAspect.Items.Add('Default'); CAspect.Items.Add('');
for o := 1 to MainForm.MAspects.Count - 2 do begin
CMAspect.Items.Add(MainForm.MAspects.Items[o].caption);
CAspect.Items.Add(CMAspect.Items[o]);
end;
CAspect.Items.Add('');
for o := 0 to MainForm.MPostproc.Count - 1 do