-
Notifications
You must be signed in to change notification settings - Fork 2
/
WynImport.pas
103 lines (81 loc) · 3.32 KB
/
WynImport.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
{
New script template, only shows processed records
Assigning any nonzero value to Result will terminate script
}
unit ExportWyn;
uses praFunctions;
var
formIdName, fileNameName: string;
whiteList: TStringList;
blackList: TStringList;
// Called before processing
// You can remove it if script doesn't require initialization code
function Initialize: integer;
begin
formIdName := 'actorBaseFormId';
fileNameName := 'sourceFile';
whiteList := TStringList.create;
blackList := TStringList.create;
whiteList.LoadFromFile(ScriptsPath+'wyn-whitelist.txt');
blackList.LoadFromFile(ScriptsPath+'wyn-blacklist.txt');
Result := 0;
end;
procedure processProp(e: IInterface; list: TStringList);
var
i, j, k, charpos: Integer;
val, arrayOfStruct, curStruct, curMember: IInterface;
memberName, memberValue, formId, fileName, curLine: string;
begin
// get value?
val := ElementByName(e, 'Value');
arrayOfStruct := ElementByName(val, 'Array of Struct');
if(assigned(arrayOfStruct)) then begin
remove(arrayOfStruct);
end;
SetToDefault(val);
arrayOfStruct := ElementByName(val, 'Array of Struct');
{
// now try adding them back in
arrayOfStruct := Add(val, 'Array of Struct', False);
if(not assigned(arrayOfStruct)) then begin
addMessage('Nope');
end;}
//curMember := ElementAssign(curStruct, HighInteger, nil, False);
for i:=0 to list.count-1 do begin
// try adding a struct?
curLine := list[i];
charpos := getCharPos(curLine, ';');
if(charpos > -1) then begin
formId := IntToStr(StrToInt('$'+copy(curLine, 1, charpos-1)));
fileName := copy(curLine, charpos+1, length(curLine));
addMessage('id: '+formId+'; name: '+fileName);
curStruct := ElementAssign(arrayOfStruct, HighInteger, nil, False);
addStructMemberScalar(curStruct, fileNameName, 'String', fileName);
addStructMemberScalar(curStruct, formIdName, 'Int32', formId);
end;
end;
end;
// called for every record selected in xEdit
function Process(e: IInterface): integer;
var
whitelistProp, blacklistProp: IInterface;
begin
Result := 0;
// find the prop
whitelistProp := getPropertyOfScript(e, 'pra:praRenameQuestScript', 'whitelistNpcs');
blacklistProp := getPropertyOfScript(e, 'pra:praRenameQuestScript', 'blacklistNpcs');
AddMessage('==Whitelist==');
processProp(whitelistProp, whiteList);
AddMessage('==Blacklist==');
processProp(blacklistProp, blackList);
{ AddMessage('==Blacklist=='); }
{ dumpElem(blacklistProp); }
// processing code goes here
end;
// Called after processing
// You can remove it if script doesn't require finalization code
function Finalize: integer;
begin
Result := 0;
end;
end.