-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwbInit.pas
709 lines (633 loc) · 23.3 KB
/
wbInit.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
{*******************************************************************************
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
*******************************************************************************}
unit wbInit;
{$I wbDefines.inc}
interface
uses
Classes;
var
wbApplicationTitle : string;
wbTheGameIniFileName : String;
wbScriptsPath : string;
wbScriptToRun : string;
wbBackupPath : string;
wbTempPath : string;
wbMyGamesTheGamePath : string;
wbPluginsFileName : String;
wbSettingsFileName : string;
wbModGroupFileName : string;
wbPluginToUse : string; // Passed a specific plugin as parameter
wbLogFile : string; // Optional log file for this session
wbMasterUpdateDone : Boolean;
wbDontSave : Boolean;
wbDontBackup : Boolean = False;
wbRemoveTempPath : Boolean = True;
wbQuickShowConflicts : Boolean;
wbQuickClean : Boolean;
wbParamIndex : integer = 1; // First unused parameter
wbPluginsToUse : TStringList;
function wbFindNextValidCmdLineFileName(var startingIndex : integer; out aValue : string; defaultPath : string = '') : Boolean;
function wbFindNextValidCmdLinePlugin(var startingIndex : integer; out aValue : string; defaultPath : string) : Boolean;
function wbFindCmdLineParam(const aSwitch : string; out aValue : string): Boolean; overload;
function wbLoadMOHookFile: Boolean;
implementation
uses
SysUtils,
Windows,
Registry,
ShellApi,
Dialogs,
ShlObj,
IOUtils,
IniFiles,
wbHelpers,
wbInterface,
wbImplementation,
wbDefinitionsFNV,
wbDefinitionsFO3,
wbDefinitionsTES3,
wbDefinitionsTES4,
wbDefinitionsTES5;
function wbFindCmdLineParam(const aSwitch : string;
const aChars : TSysCharSet;
aIgnoreCase : Boolean;
out aValue : string)
: Boolean; overload;
var
i : Integer;
s : string;
begin
Result := False;
aValue := '';
for i := 1 to ParamCount do begin
s := ParamStr(i);
if (aChars = []) or (s[1] in aChars) then
if aIgnoreCase then begin
if AnsiCompareText(Copy(s, 2, Length(aSwitch)), aSwitch) = 0 then begin
if (length(s)>(length(aSwitch)+2)) and (s[Length(aSwitch) + 2] = ':') then begin
aValue := Copy(s, Length(aSwitch) + 3, MaxInt);
Result := True;
end;
Exit;
end;
end else
if AnsiCompareStr(Copy(s, 2, Length(aSwitch)), aSwitch) = 0 then begin
if s[Length(aSwitch) + 2] = ':' then begin
aValue := Copy(s, Length(aSwitch) + 3, MaxInt);
Result := True;
end;
Exit;
end;
end;
end;
function wbFindCmdLineParam(var startingIndex : integer;
const aChars : TSysCharSet;
out aValue : string)
: Boolean; overload;
var
i : integer;
s : string;
begin
Result := False;
aValue := '';
for i := startingIndex to ParamCount do begin
s := ParamStr(i);
if (aChars = []) or (s[1] in aChars) then // skipped
Inc(startingIndex)
else begin
aValue := ParamStr(i);
startingIndex := i+1;
Result := True;
break;
end
end;
end;
function wbFindCmdLineParam(const aSwitch : string;
out aValue : string)
: Boolean; overload;
begin
Result := wbFindCmdLineParam(aSwitch, SwitchChars, True, aValue);
end;
function wbFindCmdLineParam(var startingIndex : integer; out aValue : string) : Boolean; overload;
begin
Result := wbFindCmdLineParam(startingIndex, SwitchChars, aValue);
end;
function wbCheckForValidExtension(aFilePath : string; const anExtension : string): Boolean; overload;
begin
Result := UpperCase(ExtractFileExt(aFilePath)) = UpperCase(anExtension);
end;
function wbCheckForPluginExtension(aFilePath : string): Boolean;
begin
Result := wbCheckForValidExtension(aFilePath, '.esp') or wbCheckForValidExtension(aFilePath, '.esm');
end;
function wbCheckForValidExtension(aFilePath : string): Boolean; overload;
begin
Result := wbCheckForPluginExtension(aFilePath) or
wbCheckForValidExtension(aFilePath, '.fos') or wbCheckForValidExtension(aFilePath, '.ess');
end;
function wbFindNextValidCmdLineFileName(var startingIndex : integer; out aValue : string; defaultPath : string = '') : Boolean;
begin
Result := wbFindCmdLineParam(startingIndex, SwitchChars, aValue);
if Result and not FileExists(aValue) then
if (defaultPath<>'') then
if FileExists(defaultPath+'\'+aValue) then
aValue := ExpandFileName(defaultPath+'\'+aValue)
else
Result := False
else
Result := False;
end;
function wbFindNextValidCmdLinePlugin(var startingIndex : integer; out aValue : string; defaultPath : string) : Boolean;
begin
repeat
Result := wbFindNextValidCmdLineFileName(startingIndex, aValue, defaultPath);
until not Result or wbCheckForPluginExtension(aValue);
if Result then
if (AnsiCompareText(ExpandFileName(ExtractFilePath(aValue)), ExpandFileName(defaultPath)) = 0) then begin
aValue := ExtractFileName(aValue);
if not Assigned(wbPluginsToUse) then wbPluginsToUse := TStringList.Create;
wbPluginsToUse.Add(aValue);
end else
Result := False;
end;
// several ini settings should be read before record definitions
// they may affect definitions like wbSimpleRecords
// and should be overridden by command line parameters
procedure ReadSettings;
var
Settings: TMemIniFile;
begin
try
Settings := TMemIniFile.Create(wbSettingsFileName);
try
wbLoadBSAs := Settings.ReadBool('Options', 'LoadBSAs', wbLoadBSAs);
wbSimpleRecords := Settings.ReadBool('Options', 'SimpleRecords', wbSimpleRecords);
wbShowFlagEnumValue := Settings.ReadBool('Options', 'ShowFlagEnumValue', wbShowFlagEnumValue);
wbTrackAllEditorID := Settings.ReadBool('Options', 'TrackAllEditorID', wbTrackAllEditorID);
finally
Settings.Free;
end;
finally
end;
end;
function GetCSIDLShellFolder(CSIDLFolder: integer): string;
begin
SetLength(Result, MAX_PATH);
SHGetSpecialFolderPath(0, PChar(Result), CSIDLFolder, True);
SetLength(Result, StrLen(PChar(Result)));
if (Result <> '') then
Result := IncludeTrailingBackslash(Result);
end;
function CheckAppPath: string;
const
//gmFNV, gmFO3, gmTES3, gmTES4, gmTES5
ExeName : array[TwbGameMode] of string =
('FalloutNV.exe', 'Fallout3.exe', 'Morrowind.exe', 'Oblivion.exe', 'TESV.exe');
var
s: string;
begin
Result := '';
s := ExtractFilePath(ParamStr(0));
while Length(s) > 3 do begin
if FileExists(s + ExeName[wbGameMode]) and DirectoryExists(s + 'Data') then begin
Result := s;
Exit;
end;
s := ExtractFilePath(ExcludeTrailingPathDelimiter(s));
end;
end;
{===SafeLoadLibrary============================================================}
function TestAndClearFPUExceptions(AExceptionMask: Word): Boolean;
asm
PUSH ECX
MOV CX, AX
FSTSW AX
TEST AX, CX
JNE @@bad
XOR EAX, EAX
INC EAX
JMP @@exit
@@bad:
XOR EAX, EAX
@@exit:
POP ECX
FCLEX
RET
end;
{------------------------------------------------------------------------------}
function SafeLoadLibrary(const Filename: string; ErrorMode: UINT): HMODULE;
var
OldMode: UINT;
FPUControlWord: Word;
begin
OldMode := SetErrorMode(ErrorMode);
try
FPUControlWord := Get8087CW();
Result := LoadLibrary(PChar(Filename));
TestAndClearFPUExceptions(0);
Set8087CW(FPUControlWord);
finally
SetErrorMode(OldMode);
end;
end;
{==============================================================================}
function wbLoadMOHookFile: Boolean;
var
HookDll : HMODULE;
Init : function(logLevel: Integer; profileName: LPCWSTR): BOOL; cdecl;
begin
if not wbShouldLoadMOHookFile then
Exit(True);
Result := False;
if not FileExists(wbMOHookFile) then
Exit;
HookDll := SafeLoadLibrary(wbMOHookFile, SEM_NOOPENFILEERRORBOX);
if HookDll <> 0 then begin
Pointer(@Init) := GetProcAddress(HookDll, 'Init');
if Assigned(Pointer(@Init)) then
Result := Init(0, PWideChar(UnicodeString(wbMOProfile)));
end;
end;
procedure DoInitPath(const ParamIndex: Integer);
const
sBethRegKey = '\SOFTWARE\Bethesda Softworks\';
sBethRegKey64 = '\SOFTWARE\Wow6432Node\Bethesda Softworks\';
var
s : String;
begin
wbModGroupFileName := wbProgramPath + wbAppName + wbToolName + '.modgroups';
if not wbFindCmdLineParam('S', wbScriptsPath) then
wbScriptsPath := wbProgramPath + 'Edit Scripts\';
if not wbFindCmdLineParam('T', wbTempPath) then
wbTempPath := IncludeTrailingPathDelimiter(TPath.GetTempPath + wbAppName + 'Edit')
else
wbRemoveTempPath := not DirectoryExists(wbTempPath);
if not wbFindCmdLineParam('D', wbDataPath) then begin
wbDataPath := CheckAppPath;
if wbDataPath = '' then with TRegistry.Create do try
RootKey := HKEY_LOCAL_MACHINE;
if not OpenKeyReadOnly(sBethRegKey + wbGameName + '\') then
if not OpenKeyReadOnly(sBethRegKey64 + wbGameName + '\') then begin
s := 'Fatal: Could not open registry key: ' + sBethRegKey + wbGameName + '\';
if wbGameMode = gmTES5 then
ShowMessage(s+#13+#10+'This can happen after Steam updates, run game''s launcher to restore registry settings');
wbDontSave := True;
Exit;
end;
wbDataPath := ReadString('Installed Path');
if wbDataPath = '' then begin
s := 'Fatal: Could not determine '+wbGameName+' installation path, no "Installed Path" registry key';
if wbGameMode = gmTES5 then
ShowMessage(s+#13+#10+'This can happen after Steam updates, run game''s launcher to restore registry settings');
wbDontSave := True;
end;
finally
Free;
end;
if wbDataPath <>'' then
wbDataPath := IncludeTrailingPathDelimiter(wbDataPath) + 'Data\';
end else
wbDataPath := IncludeTrailingPathDelimiter(wbDataPath);
wbOutputPath := wbDataPath;
if wbFindCmdLineParam('O', s) and (Length(s) > 0) then
if s[1] = '.' then
//assume relative path
wbOutputPath := IncludeTrailingPathDelimiter(wbOutputPath + s)
else
//assume absolute path
wbOutputPath := IncludeTrailingPathDelimiter(s);
wbMOHookFile := wbDataPath + '..\Mod Organizer\hook.dll';
if not wbFindCmdLineParam('I', wbTheGameIniFileName) then begin
wbTheGameIniFileName := GetCSIDLShellFolder(CSIDL_PERSONAL);
if wbTheGameIniFileName = '' then begin
ShowMessage('Fatal: Could not determine my documents folder');
Exit;
end;
wbMyGamesTheGamePath := wbTheGameIniFileName + 'My Games\'+ wbGameName +'\';
if wbGameMode in [gmFO3, gmFNV] then
wbTheGameIniFileName := wbMyGamesTheGamePath + 'Fallout.ini'
else
wbTheGameIniFileName := wbMyGamesTheGamePath + wbGameName + '.ini';
end;
wbParamIndex := ParamIndex;
if not wbFindCmdLineParam('P', wbPluginsFileName) then
if not (wbFindNextValidCmdLineFileName(wbParamIndex, wbPluginsFileName) and SameText(ExtractFileExt(wbPluginsFileName), '.txt'))
or wbCheckForValidExtension(wbPluginsFileName)
then begin
wbParamIndex := ParamIndex;
wbPluginsFileName := GetCSIDLShellFolder(CSIDL_LOCAL_APPDATA);
if wbPluginsFileName = '' then begin
ShowMessage('Fatal: Could not determine the local application data folder');
Exit;
end;
wbPluginsFileName := wbPluginsFileName + wbGameName + '\Plugins.txt';
end;
// settings in the ini file next to app, or in the same folder with plugins.txt
wbSettingsFileName := wbProgramPath + wbAppName + wbToolName + '.ini';
if not FileExists(wbSettingsFileName) then
wbSettingsFileName := ChangeFileExt(wbPluginsFileName, '.'+LowerCase(wbAppName)+'viewsettings');
wbBackupPath := '';
if not (wbDontSave or wbFindCmdLineParam('B', wbBackupPath)) then begin
wbBackupPath := wbDataPath + wbAppName + 'Edit Backups\';
if not DirectoryExists(wbBackupPath) then
if not ForceDirectories(wbBackupPath) then
wbBackupPath := wbDataPath;
end;
wbFindCmdLineParam('R', wbLogFile);
end;
var
wbForcedModes: string;
function isMode(aMode: String): Boolean;
var
s: string;
begin
Result := (Pos(Uppercase(aMode), UpperCase(wbForcedModes)) <> 0) or
FindCmdLineSwitch(aMode) or
wbFindCmdLineParam(aMode, s) or
(Pos(Uppercase(aMode), UpperCase(ExtractFileName(ParamStr(0)))) <> 0);
end;
// Force app modes
function CheckForcedMode: Boolean;
var
s: string;
i: integer;
begin
Result := False;
// there is a game specific script provided to execute
i := 1;
if wbFindCmdLineParam('script', s) or wbFindNextValidCmdLineFileName(i, s) then begin
if not FileExists(s) then
Exit;
wbScriptToRun := s;
s := ExtractFileExt(s);
i := Pos(UpperCase('pas'), UpperCase(s));
if (i > 0) and (i = Length(s) - 2) then begin
wbForcedModes := Copy(s, 2, Length(s) - 4) + ',script';
Result := True;
end;
end;
end;
procedure wbDoInit;
var
s: string;
begin
wbReportMode := False;
if isMode('Saves') then begin
wbToolSource := tsSaves;
wbSourceName := 'Saves';
end else begin // defaults to plugin
wbToolSource := tsPlugins;
wbSourceName := 'Plugins';
end;
wbEditAllowed := True;
wbDontSave := False;
CheckForcedMode;
if isMode('View') then begin
wbToolMode := tmView;
wbToolName := 'View';
wbEditAllowed := False;
wbDontSave := True;
end else if isMode('MasterUpdate') then begin
wbToolMode := tmMasterUpdate;
wbToolName := 'MasterUpdate';
end else if isMode('MasterRestore') then begin
wbToolMode := tmMasterRestore;
wbToolName := 'MasterRestore';
end else if isMode('LODGen') then begin
wbToolMode := tmLODgen;
wbToolName := 'LODGen';
wbEditAllowed := False;
wbDontSave := True;
end else if isMode('Script') then begin
wbToolMode := tmScript;
wbToolName := 'Script';
end else if isMode('Translate') then begin
wbToolMode := tmTranslate;
wbToolName := 'Trans';
end else if isMode('setESM') then begin
wbToolMode := tmESMify;
wbToolName := 'SettingESMflag';
end else if isMode('clearESM') then begin
wbToolMode := tmESPify;
wbToolName := 'ClearingESMflag';
end else if isMode('SortAndClean') then begin
wbToolMode := tmSortAndCleanMasters;
wbToolName := 'SortAndCleanMasters';
end else if isMode('CheckForErrors') then begin
wbToolMode := tmCheckForErrors;
wbToolName := 'CheckForErrors';
end else if isMode('CheckForITM') then begin
wbToolMode := tmCheckForITM;
wbToolName := 'CheckForITM';
end else if isMode('CheckForDR') then begin
wbToolMode := tmCheckForDR;
wbToolName := 'CheckForDR';
end else if isMode('Edit') then begin
wbToolMode := tmEdit;
wbToolName := 'Edit';
end else begin
ShowMessage('Application name must contain Edit, View, LODGen, MasterUpdate, MasterRestore, setESM, clearESM, sortAndCleanMasters, CheckForITM, CheckForDR or CheckForErrors to select mode.');
Exit;
end;
if isMode('FNV') then begin
wbGameMode := gmFNV;
wbAppName := 'FNV';
wbGameName := 'FalloutNV';
if not (wbToolMode in wbAlwaysMode) and not (wbToolMode in [tmMasterUpdate, tmMasterRestore]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbSourceName);
Exit;
end;
end else if isMode('FO3') then begin
wbGameMode := gmFO3;
wbAppName := 'FO3';
wbGameName := 'Fallout3';
if not (wbToolMode in wbAlwaysMode) and not (wbToolMode in [tmMasterUpdate, tmMasterRestore]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbSourceName);
Exit;
end;
end else if isMode('TES3') then begin
wbGameMode := gmTES3;
wbAppName := 'TES3';
wbGameName := 'Morrowind';
if not (wbToolMode in [tmView]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbSourceName);
Exit;
end;
end else if isMode('TES4') then begin
wbGameMode := gmTES4;
wbAppName := 'TES4';
wbGameName := 'Oblivion';
if not (wbToolMode in wbAlwaysMode) and not (wbToolMode in []) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbSourceName);
Exit;
end;
end else if isMode('TES5') then begin
wbGameMode := gmTES5;
wbAppName := 'TES5';
wbGameName := 'Skyrim';
if not (wbToolMode in wbAlwaysMode) and not (wbToolMode in [tmTranslate]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbToolName);
Exit;
end;
if not (wbToolSource in [tsPlugins]) then begin
ShowMessage('Application '+wbGameName+' does not currently support '+wbSourceName);
Exit;
end;
end else begin
ShowMessage('Application name must contain FNV, FO3, TES4 or TES5 to select game.');
Exit;
end;
DoInitPath(wbParamIndex);
if wbGameMode = gmFNV then begin
wbVWDInTemporary := True;
wbLoadBSAs := False;
ReadSettings;
end else if wbGameMode = gmFO3 then begin
wbVWDInTemporary := True;
wbLoadBSAs := False;
ReadSettings;
end else if wbGameMode = gmTES3 then begin
wbLoadBSAs := False;
wbAllowInternalEdit := false;
wbSizeOfSubRecordHeaderStruct := wbSizeOfSubRecordHeaderStructOld;
ReadSettings;
end else if wbGameMode = gmTES4 then begin
wbLoadBSAs := True;
wbAllowInternalEdit := false;
ReadSettings;
end else if wbGameMode = gmTES5 then begin
wbVWDInTemporary := True;
wbLoadBSAs := True; // localization won't work otherwise
wbHideIgnored := False; // to show Form Version
ReadSettings;
end else begin
Exit;
end;
if wbGameMode = gmFNV then
DefineFNV
else if wbGameMode = gmFO3 then
DefineFO3
else if wbGameMode = gmTES3 then
DefineTES3
else if wbGameMode = gmTES4 then
DefineTES4
else if wbGameMode = gmTES5 then
case wbToolSource of
tsPlugins: DefineTES5;
end
else begin
ShowMessage('Application name must contain FNV, FO3, TES4 or TES5 to select game.');
Exit;
end;
wbLanguage := 'English';
if wbFindCmdLineParam('l', s) then
wbLanguage := s;
if FindCmdLineSwitch('speed') then
wbSpeedOverMemory := True;
if FindCmdLineSwitch('memory') then
wbSpeedOverMemory := False;
if FindCmdLineSwitch('report') then
wbReportMode := (DebugHook <> 0);
if FindCmdLineSwitch('MoreInfoForIndex') then
wbMoreInfoForIndex := true;
if FindCmdLineSwitch('fixup') then
wbAllowInternalEdit := True
else if FindCmdLineSwitch('nofixup') then
wbAllowInternalEdit := False;
if FindCmdLineSwitch('skipbsa') then
wbLoadBSAs := False
else if FindCmdLineSwitch('forcebsa') then
wbLoadBSAs := True;
if FindCmdLineSwitch('skipInternalEditing') then
wbAllowInternalEdit := False
else if FindCmdLineSwitch('forceInternalEditing') then
wbAllowInternalEdit := True;
if FindCmdLineSwitch('showfixup') then
wbShowInternalEdit := True
else if FindCmdLineSwitch('hidefixup') then
wbShowInternalEdit := False;
if FindCmdLineSwitch('quickshowconflicts') then
wbQuickShowConflicts := True;
if FindCmdLineSwitch('IKnowWhatImDoing') then
wbIKnowWhatImDoing := True;
if FindCmdLineSwitch('quickclean') then
wbQuickClean := wbIKnowWhatImDoing;
if FindCmdLineSwitch('TrackAllEditorID') then
wbTrackAllEditorID := True;
if wbToolMode in wbPluginModes then // look for the file name
if not wbFindNextValidCmdLinePlugin(wbParamIndex, wbPluginToUse, wbDataPath) then begin
ShowMessage(wbToolName+' mode requires a valid plugin name!');
Exit;
end;
if wbToolMode = tmLODgen then begin
wbIKnowWhatImDoing := True;
wbAllowInternalEdit := False;
wbShowInternalEdit := False;
wbLoadBSAs := True;
wbBuildRefs := False;
end else if wbToolMode = tmScript then begin
wbIKnowWhatImDoing := True;
wbLoadBSAs := True;
wbBuildRefs := True;
end else if wbToolMode in [tmMasterUpdate, tmESMify] then begin
wbIKnowWhatImDoing := True;
wbAllowInternalEdit := False;
wbShowInternalEdit := False;
wbLoadBSAs := False;
wbBuildRefs := False;
wbMasterUpdateFilterONAM := wbToolMode in [tmESMify];
if FindCmdLineSwitch('filteronam') then
wbMasterUpdateFilterONAM := True
else if FindCmdLineSwitch('noFilteronam') then
wbMasterUpdateFilterONAM := True;
if FindCmdLineSwitch('FixPersistence') then
wbMasterUpdateFixPersistence := True
else if FindCmdLineSwitch('NoFixPersistence') then
wbMasterUpdateFixPersistence := False;
end else if wbToolMode in [tmMasterRestore, tmESPify, tmCheckForDR, tmCheckForITM, tmCheckForErrors] then begin
wbIKnowWhatImDoing := True;
wbAllowInternalEdit := False;
wbShowInternalEdit := False;
wbLoadBSAs := False;
wbBuildRefs := False;
end else if wbToolMode = tmTranslate then begin
wbTranslationMode := True;
end;
wbApplicationTitle := wbAppName + wbToolName + ' ' + VersionString;
{$IFDEF LiteVersion}
wbApplicationTitle := wbApplicationTitle + ' Lite';
{$ENDIF}
if FindCmdLineSwitch('fixuppgrd') then
wbFixupPGRD := True;
wbShouldLoadMOHookFile := wbFindCmdLineParam('moprofile', wbMOProfile);
if (wbToolMode = tmEdit) and not wbIsAssociatedWithExtension('.' + wbAppName + 'pas') then try
wbAssociateWithExtension('.' + wbAppName + 'pas', wbAppName + 'Script', wbAppName + wbToolName + ' script');
except end;
end;
initialization
wbDoInit;
end.