-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathList All Addon Nodes.pas
91 lines (74 loc) · 2.42 KB
/
List All Addon Nodes.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
{
Scans all the files you run this on, and generates a CSV containing all the Addon Nodes it found.
You will be asked where to save the CSV.
}
unit ListAllAddonNodes;
var
outData: TStringList;
targetFile: string;
function saveFileAs(title: string): string;
var
objFile: TSaveDialog;
begin
objFile := TSaveDialog.Create(nil);
Result := '';
objFile.Title := title;
objFile.Options := objFile.Options + [ofOverwritePrompt];
objFile.Filter := 'CSV files|*.csv|All files|*.*';
objFile.FilterIndex := 1;
//Result := objFile;
try
if objFile.Execute then begin
Result := objFile.FileName;
end;
finally
objFile.free;
end;
end;
// Called before processing
// You can remove it if script doesn't require initialization code
function Initialize: integer;
var
ext: string;
begin
outData := TStringList.create;
outData.add('Filename,Node Index,Editor ID');
targetFile := saveFileAs('Save CSV as');
if(targetFile = '') then begin
AddMessage('Cancelled');
Result := 1;
exit;
end;
ext := LowerCase(ExtractFileExt(targetFile));
if(ext = '') then begin
targetFile := targetFile + '.csv';
end;
AddMessage('Target file: '+targetFile);
Result := 0;
end;
// called for every record selected in xEdit
function Process(e: IInterface): integer;
var
curIndex, numSoFar: integer;
begin
Result := 0;
if(Signature(e) <> 'ADDN') or (not IsMaster(e)) then begin
exit;
end;
curIndex := GetElementNativeValues(e, 'DATA');
outData.add(GetFileName(GetFile(e))+','+IntToStr(curIndex)+','+EditorID(e));
numSoFar := (outData.count - 1);
if((numSoFar mod 50) = 0) then begin
AddMessage('Found '+IntToStr(numSoFar)+' AddOn Nodes so far');
end;
end;
// Called after processing
// You can remove it if script doesn't require finalization code
function Finalize: integer;
begin
AddMessage('Saving file '+targetFile);
outData.saveToFile(targetFile);
Result := 0;
outData.free();
end;
end.