SRL Archive - Archive

Marpis: Aristocrat


Sir R. M8gic1an

2009-08-13 04:23:24

Rasta Magician has reported a post.

Reason:
Aristocrat + Useful poster

Post: CountOptions(Texts: TStringArray)]: integer;
Forum: Core
Assigned Moderators: n3ss3s, Markus, N1ke!, ZephyrsFury, EvilChicken!, Narcle, Nava2

Posted by: marpis
Original Content:
Usage:

ChooseOption
–Take Raw Chicken
–Take Feather
–Examine Raw Chicken
–Examine Feather


writeln(IntToStr(CountOptions(['Take'])));
---> 2

writeln(IntToStr(CountOptions(['hick', 'eath'])));
---> 4

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

Sir R. M8gic1an

2009-08-13 04:24:55

Also other contributions and good posts

~RM

JAD

2009-08-13 04:34:28

Yes definitely.

Sir R. M8gic1an

2009-08-13 15:40:32

He was also the one who came up with the WaitUpText idea and he fixed bank.scar.

~RM

Naike

2009-08-13 16:05:59

Yes..

EvilChicken!

2009-08-13 20:19:37

From: Rasta Magician
He was also the one who came up with the WaitUpText idea and he fixed bank.scar.

~RM


That did it for me.
Yes.

HyperSecret

2009-08-13 20:29:57

From: Rasta Magician
He was also the one who came up with the WaitUpText idea and he fixed bank.scar.

~RM


munk has used UTWait (UpTextWait) for ages. marpis did not come up with the idea.

Sure give him the cup.

Sir R. M8gic1an

2009-08-14 15:35:21

Aristocrated.

~RM