-
Notifications
You must be signed in to change notification settings - Fork 1
/
DM_Find plugins with X armor.pas
125 lines (106 loc) · 2.59 KB
/
DM_Find plugins with X armor.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
unit DM_Find_X_Armor;
interface
uses xEditApi;
implementation
var
armorToFind: string;
function IsXArmor(e: IInterface): Boolean;
begin
Result := GetElementEditValues(WinningOverride(e), 'BOD2\Armor Type') = armorToFind;
end;
function HasXArmor(f: IInterface): Boolean;
var
armors: IInterface;
i, n: Integer;
begin
Result := false;
if not HasGroup(f, 'ARMO') then Exit;
armors := GroupBySignature(f, 'ARMO');
n := ElementCount(armors);
for i := 0 to n do begin
Result := IsXArmor(ElementByIndex(armors, i));
if Result then Exit;
end;
end;
function CreateButton(AParent: TControl): TButton;
begin
Result := TButton.Create(AParent);
Result.Parent := AParent;
Result.Left := 0;
Result.Top := 0;
Result.Width := 180;
Result.Height := 32;
end;
function ShowForm: Integer;
var
frm: TForm;
btnExit, btnOk: TButton;
rgpOptions: TRadioGroup;
const
x = 120;
y = 30;
dy = 40;
begin
frm := TForm.Create(nil);
Result := 0;
try
frm.Caption := 'Search for armor type';
frm.Position := poScreenCenter;
frm.BorderStyle := bsDialog;
frm.Height := 290;
frm.Width := 440;
rgpOptions := TRadioGroup.Create(frm);
rgpOptions.Parent := frm;
rgpOptions.Left := x;
rgpOptions.Top := y;
rgpOptions.Caption := 'New type';
rgpOptions.Items.Add('&Clothing');
rgpOptions.Items.Add('&Light');
rgpOptions.Items.Add('&Heavy');
rgpOptions.ItemIndex := 0;
btnExit := CreateButton(frm);
btnExit.Caption := '&Cancel';
btnExit.Cancel := true;
btnExit.ModalResult := mrCancel;
btnExit.Left := x - 85;
btnExit.Top := y + (4 * dy);
btnOk := CreateButton(frm);
btnOk.Caption := '&Ok';
btnOk.Default := true;
btnOk.ModalResult := mrOk;
btnOk.Left := btnExit.Left + btnExit.Width + 10;
btnOk.Top := btnExit.Top;
if frm.ShowModal <> mrOk then begin
Result := 1;
end
else begin
case rgpOptions.ItemIndex of
0: armorToFind := 'Clothing';
1: armorToFind := 'Light Armor';
2: armorToFind := 'Heavy Armor';
end;
end;
finally
frm.Release;
end;
end;
function Initialize: Integer;
var
i: integer;
f: IInterface;
begin
Result := ShowForm;
if Result <> 0 then Exit;
AddMessage(#13#10#13#10);
// iterate over loaded plugins
for i := 0 to Pred(FileCount) do begin
f := FileByIndex(i);
if HasXArmor(f) then begin
AddMessage(IntToHex(GetLoadOrder(f), 2) + ' ' + GetFileName(f));
end;
end;
AddMessage(#13#10);
AddMessage(Format('Finished searching for armor type: %s', [armorToFind]));
AddMessage(#13#10#13#10);
end;
end.