Program New function ReadGump GumpType Cardinal var GumpIndex Word var

 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
Program New;
function ReadGump(GumpType:Cardinal;var GumpIndex:Word;var GumpSerial:Cardinal):Boolean;
var
fIndex : Word;
fCount : Word;
begin
fCount := GetGumpsCount();
if(fCount > 0)then
begin
for fIndex := 0 to fCount - 1 do
begin
if(GetGumpID(fIndex) = GumpType)then
begin
GumpIndex := FIndex;
GumpSerial := GetGumpSerial(FIndex);
Result := True;
exit;
end;
end;
end;
Result := False;
GumpIndex := $0;
GumpSerial := $0;
end;
Procedure HandleIncomingGump(Serial,GumpID,X,Y:Cardinal);
var
Index_A : Array of Cardinal;
Index_B : Array of Cardinal;
Pic_A : Cardinal;
Pic_B : Cardinal;
fSerial : Cardinal;
fIndex : Word;
fInfo : TGumpInfo;
i : Cardinal;
begin
if(GumpID = $47D09E42)then
begin
if(ReadGump(GumpID,fIndex,fSerial))then
begin
Pic_A := 0;
Pic_B := 0;
GetGumpInfo(fIndex,fInfo);
for i := 0 to Length(fInfo.TilePicHue) - 1 do
begin
if(Pic_A = 0)then
begin
Pic_A := fInfo.TilePicHue[i].ID
end else if (fInfo.TilePicHue[i].ID <> Pic_A) and ( Pic_B = 0)then
begin
Pic_B := fInfo.TilePicHue[i].ID
end;
if(fInfo.TilePicHue[i].ID = Pic_A)then
begin
SetLength(Index_A,(Length(Index_A) + 1));
Index_A[Length(Index_A) - 1] := i;
end else begin
SetLength(Index_B,(Length(Index_B) + 1));
Index_B[Length(Index_B) - 1] := i;
end;
if(Length(Index_A) = 1)then
begin
NumGumpButton(fIndex,fInfo.RadioButtons[Index_A[0]].return_value);
end else begin
NumGumpButton(fIndex,fInfo.RadioButtons[Index_B[0]].return_value);
end;
end;
end;
end;
end;
begin
SetEventProc(evIncomingGump,'HandleIncomingGump');
while(Connected())do
begin
Wait(100);
end;
end.