-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmOptionsForm.pas
298 lines (261 loc) · 8.41 KB
/
frmOptionsForm.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
unit frmOptionsForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, wbInterface,
Vcl.Styles.Utils.SystemMenu, Vcl.Samples.Spin, Vcl.Themes,
System.Generics.Collections, Vcl.Styles.Ext;
type
TfrmOptions = class(TForm)
pcOptions: TPageControl;
tsCleaning: TTabSheet;
btnOK: TButton;
btnCancel: TButton;
cbUDRSetXESP: TCheckBox;
cbUDRSetScale: TCheckBox;
cbUDRSetZ: TCheckBox;
edUDRSetScaleValue: TEdit;
edUDRSetZValue: TEdit;
cbUDRSetMSTT: TCheckBox;
edUDRSetMSTTValue: TEdit;
Label1: TLabel;
tsGeneral: TTabSheet;
cbHideUnused: TCheckBox;
cbHideIgnored: TCheckBox;
cbHideNeverShow: TCheckBox;
cbLoadBSAs: TCheckBox;
cbSortFLST: TCheckBox;
tsUISettings: TTabSheet;
clbConflictThis: TColorBox;
Label3: TLabel;
cbConflictThis: TComboBox;
Label4: TLabel;
cbConflictAll: TComboBox;
clbConflictAll: TColorBox;
cbSimpleRecords: TCheckBox;
cbShowUnsavedHint: TCheckBox;
cbTrackAllEditorID: TCheckBox;
cbSortINFO: TCheckBox;
cbShowFlagEnumValue: TCheckBox;
cbRemoveOffsetData: TCheckBox;
pnlFontRecords: TPanel;
pnlFontMessages: TPanel;
pnlFontViewer: TPanel;
cbActorTemplateHide: TCheckBox;
cbClampFormID: TCheckBox;
cbShowGroupRecordCount: TCheckBox;
Label5: TLabel;
edColumnWidth: TEdit;
edRowHeight: TEdit;
Label6: TLabel;
cbShowTip: TCheckBox;
sedAutoCompareSelectedLimit: TSpinEdit;
Label7: TLabel;
Label8: TLabel;
cbShowFileFlags: TCheckBox;
cbAlignArrayElements: TCheckBox;
Label9: TLabel;
sedNavChangeDelay: TSpinEdit;
Label10: TLabel;
cbRequireCtrlForDblClick: TCheckBox;
cbFocusAddedElement: TCheckBox;
tbsUITheme: TTabSheet;
pnlThemeTop: TPanel;
rbThemeSystem: TRadioButton;
cbThemeSystem: TComboBox;
rbThemeLight: TRadioButton;
cbThemeLight: TComboBox;
rbThemeDark: TRadioButton;
cbThemeDark: TComboBox;
pnlThemePreview: TPanel;
cbPatron: TCheckBox;
cbNoGitHubCheck: TCheckBox;
cbNoNexusModsCheck: TCheckBox;
cbResetModifiedOnSave: TCheckBox;
cbAlwaysSaveOnam: TCheckBox;
tsExperts: TTabSheet;
cbFillPNAM: TCheckBox;
cbManualCleaningHide: TCheckBox;
cbManualCleaningAllow: TCheckBox;
cbShrinkButtons: TCheckBox;
cbCollapseConditions: TCheckBox;
cbCollapseBenignArray: TCheckBox;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormCreate(Sender: TObject);
procedure cbConflictThisChange(Sender: TObject);
procedure clbConflictThisChange(Sender: TObject);
procedure cbConflictAllChange(Sender: TObject);
procedure clbConflictAllChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure pnlFontRecordsClick(Sender: TObject);
procedure rbThemeClick(Sender: TObject);
procedure cbThemeSystemSelect(Sender: TObject);
private
vspThemePreview: TVclStylesPreview;
procedure UpdateThemePreview;
public
{ Public declarations }
_Files: ^TDynFiles;
function GetSelectedTheme: string;
end;
implementation
{$R *.dfm}
uses
frmViewMain,
FileSelectFrm, TypInfo;
var
wbColorConflictAllDefault: TConflictAllColors;
wbColorConflictThisDefault: TConflictThisColors;
procedure TfrmOptions.cbConflictAllChange(Sender: TObject);
begin
clbConflictAll.Selected := wbColorConflictAll[TConflictAll(cbConflictAll.Items.Objects[cbConflictAll.ItemIndex])];
end;
procedure TfrmOptions.cbConflictThisChange(Sender: TObject);
begin
clbConflictThis.Selected := wbColorConflictThis[TConflictThis(cbConflictThis.Items.Objects[cbConflictThis.ItemIndex])];
end;
procedure TfrmOptions.cbThemeSystemSelect(Sender: TObject);
begin
UpdateThemePreview;
end;
procedure TfrmOptions.clbConflictAllChange(Sender: TObject);
begin
wbColorConflictAll[TConflictAll(cbConflictAll.Items.Objects[cbConflictAll.ItemIndex])] := clbConflictAll.Selected;
end;
procedure TfrmOptions.clbConflictThisChange(Sender: TObject);
begin
wbColorConflictThis[TConflictThis(cbConflictThis.Items.Objects[cbConflictThis.ItemIndex])] := clbConflictThis.Selected;
end;
procedure TfrmOptions.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ModalResult <> mrOk then begin
wbColorConflictAll := wbColorConflictAllDefault;
wbColorConflictThis := wbColorConflictThisDefault;
end;
end;
procedure TfrmOptions.FormCreate(Sender: TObject);
var
ct: TConflictThis;
ca: TConflictAll;
s : string;
LStyleNames: TArray<string>;
Style : TCustomStyleServices;
cb: TComboBox;
rb: TRadioButton;
begin
wbApplyFontAndScale(Self);
if wbThemesSupported then begin
with TVclStylesSystemMenu.Create(Self) do begin
ShowNativeStyle := True;
MenuCaption := 'Theme';
end;
vspThemePreview := TVclStylesPreview.Create(Self);
with vspThemePreview do begin
Parent:= pnlThemePreview;
Align := alClient;
end;
LStyleNames:=TStyleManager.StyleNames;
TArray.Sort<String>(LStyleNames);
for s in LStyleNames do begin
Style := TStyleManager.Style[s];
if not Assigned(Style) then
Continue;
if Style.IsSystemStyle then begin
cb := cbThemeSystem;
rb := rbThemeSystem;
end else if IsDarkStyle(Style) then begin
cb := cbThemeDark;
rb := rbThemeDark;
end else begin
cb := cbThemeLight;
rb := rbThemeLight;
end;
cb.Items.Add(s);
if TStyleManager.ActiveStyle = Style then begin
rb.Checked := True;
cb.ItemIndex := Pred(cb.Items.Count);
vspThemePreview.Style := Style;
vspThemePreview.Caption := s;
end;
end;
rbThemeSystem.Enabled := cbThemeSystem.Items.Count > 0;
rbThemeLight.Enabled := cbThemeLight.Items.Count > 0;
rbThemeDark.Enabled := cbThemeDark.Items.Count > 0;
cbThemeSystem.Enabled := rbThemeSystem.Checked;
cbThemeLight.Enabled := rbThemeLight.Checked;
cbThemeDark.Enabled := rbThemeDark.Checked;
if rbThemeSystem.Enabled and (cbThemeSystem.ItemIndex < 0) then
cbThemeSystem.ItemIndex := 0;
if rbThemeLight.Enabled and (cbThemeLight.ItemIndex < 0) then
cbThemeLight.ItemIndex := 0;
if rbThemeDark.Enabled and (cbThemeDark.ItemIndex < 0) then begin
cbThemeDark.ItemIndex := cbThemeDark.Items.IndexOf('Carbon');
if cbThemeDark.ItemIndex < 0 then
cbThemeDark.ItemIndex := 0;
end;
UpdateThemePreview;
end else
tbsUITheme.TabVisible := False;
for ct := ctNotDefined to High(TConflictThis) do
cbConflictThis.Items.AddObject(Copy(GetEnumName(TypeInfo(TConflictThis), Integer(ct)), 3, 100), Pointer(ct));
cbConflictThis.ItemIndex := 0;
cbConflictThisChange(nil);
for ca := caNoConflict to High(TConflictAll) do
cbConflictAll.Items.AddObject(Copy(GetEnumName(TypeInfo(TConflictAll), Integer(ca)), 3, 100), Pointer(ca));
cbConflictAll.ItemIndex := 0;
cbConflictAllChange(nil);
wbColorConflictAllDefault := wbColorConflictAll;
wbColorConflictThisDefault := wbColorConflictThis;
pcOptions.ActivePageIndex := 0;
tsExperts.TabVisible := wbIKnowWhatImDoing;
end;
procedure TfrmOptions.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then
ModalResult := mrCancel;
end;
function TfrmOptions.GetSelectedTheme: string;
begin
if rbThemeSystem.Checked then
Result := cbThemeSystem.Text
else if rbThemeLight.Checked then
Result := cbThemeLight.Text
else if rbThemeDark.Checked then
Result := cbThemeDark.Text
else
Result := '';
end;
procedure TfrmOptions.pnlFontRecordsClick(Sender: TObject);
begin
with TFontDialog.Create(Self) do try
Font := TPanel(Sender).Font;
if Execute then
TPanel(Sender).Font := Font;
finally
Free;
end;
end;
procedure TfrmOptions.rbThemeClick(Sender: TObject);
begin
cbThemeSystem.Enabled := rbThemeSystem.Checked;
cbThemeLight.Enabled := rbThemeLight.Checked;
cbThemeDark.Enabled := rbThemeDark.Checked;
UpdateThemePreview;
end;
procedure TfrmOptions.UpdateThemePreview;
var
Style : TCustomStyleServices;
begin
if not Assigned(vspThemePreview) then
Exit;
Style := TStyleManager.Style[GetSelectedTheme];
if Assigned(Style) and not Style.IsSystemStyle then begin
vspThemePreview.Caption := Style.Name;
vspThemePreview.Style := Style;
pnlThemePreview.Visible := True;
vspThemePreview.Repaint;
end else
pnlThemePreview.Visible := False;
end;
end.