Usage:
ChooseOption
--Take Raw Chicken
--Take Feather
--Examine Raw Chicken
--Examine Feather
SCAR Code:
writeln(IntToStr(CountOptions(['Take'])));
---> 2
writeln(IntToStr(CountOptions(['hick', 'eath'])));
---> 4
Code:
SCAR Code:
function CountOptions(Texts: TStringArray): Integer;
var
B: TBox;
TPA, TextTPA: TPointArray;
aTPA: T2DPointArray;
I, C, H, HH, ii: Integer;
P: TPoint;
Occurances: array [0..2] of TPointArray;
SmallBoxes: TBoxArray;
begin
GetClientDimensions(B.X2, B.Y2);
B.X1 := 0;
B.Y1 := 0;
SetLength(aTPA, 2);
FindColorsTolerance(aTPA[0], 4409686, B.X1, B.Y1, B.X2, B.Y2, 0);
FindColorsTolerance(aTPA[1], 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(aTPA);
SetLength(aTPA, 0);
If Length(TPA) < 10 Then
Exit;
B.X2 := 0;
B.Y2 := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X - 1 Then
Begin
If C > 5 Then
Begin
B.X1 := P.X;
B.Y1 := P.Y;
Break;
End Else
C := C + 1;
End
Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
InvertTPA(TPA);
C := 0;
P := TPA[0];
H := High(TPA);
Dec(H);
For I := 0 To H Do
If TPA[i].X = TPA[I+1].X + 1 Then
Begin
If C > 5 Then
Begin
B.X2 := P.X;
B.Y2 := P.Y;
Break;
End Else
C := C + 1;
End Else
Begin
P := TPA[I + 1];
C := 0;
End;
If I = Length(TPA) Then
Begin
WriteLn('Choose Option Menu Getting Failed');
Exit;
End;
///////////////////////////////////////
SetLength(SmallBoxes, (B.y2 - B.y1)/15);
for i := 0 to High(SmallBoxes) do
begin
SmallBoxes[i].x1 := B.x1;
SmallBoxes[i].y1 := B.y1 + i * 15 + 3;
SmallBoxes[i].x2 := B.x2;
SmallBoxes[i].y2 := B.y1 + (i + 1) * 15 + 3;
end;
for ii := 0 to High(Texts) do
begin
TextTPA := LoadTextTPA(Texts[ii], UpChars, HH);
for i := 0 to High(SmallBoxes) do
begin
FindColorsTolerance(Occurances[0], 1845035, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
FindColorsTolerance(Occurances[1], clBlack, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
FindColorsTolerance(Occurances[2], 6121839, SmallBoxes[i].X1, SmallBoxes[i].Y1 - 5, SmallBoxes[i].X2, SmallBoxes[i].Y2 + 5, 0);
TPA := MergeATPA(Occurances);
ClearDoubleTPA(TPA);
TPA := ReturnPointsNotInTPA(TPA, SmallBoxes[i]);
if FindTextTPAInTPA(HH, TextTPA, TPA, TPA) then
Inc(result);
end;
end;
end;
EDIT: Took away an unnecessary line