From: Ashaman88
Nice job lj :)
Having trouble with choose option in banking functions, can't remember has choose options been updated?
We'll, I've got the function updated for the most part, added some commented-like-line breaks for reffering to, here's my up-to-date snippet so far:
(*
GetChooseOptions
~~~~~~~~~~~~~~~~
.. code-block:: pascal
function GetChooseOptions(TextType: string): Array of TOptions;
Gets the texe from the options menu.
.. note::
by Wizzup? & Narcle
Edit [Old School RS] by : Le Jingle (Feb. 28th, 2013)
Example:
.. code-block:: pascal
*)
Function GetChooseOptions(): Array of TOptions; // args weren't used..
var
I, L, w, h, n, m, cts, bmp, target : Integer;
B, BB, BigBox : TBox;
TPA, TPA1 : TPointArray;
ATPA, tempatpa : T2DPointArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(TPA, 4674653, B.X1, B.Y1, B.X2, B.Y2, 0);
if (Length(TPA) < 100) then
begin
ColorToleranceSpeed(cts);
Exit;
end;
ATPA := SplitTPA(TPA, 4);
// DebugATPA(ATPA, ''); // - this looks good...
for i := 0 to High(ATPA) do
begin
B := GetTPABounds(ATPA[i]);
if ((B.x2-B.x1) > 90) and ((B.y2-B.y1) > 18) then
Break
else
B := IntToBox(0, 0, 0, 0);
end;
If (B.x2 = 0) then
begin
ColorToleranceSpeed(cts);
Exit;
end;
BigBox := B;
SetColorToleranceSpeed(3);
B := GetATPABounds(ATPA);
FindColorsTolerance(TPA1, 0, B.X1, B.Y1, B.X2, B.Y2, 0);
CombineTPAWrap(TPA, TPA1, TPA);
ReturnPointsNotInTPAWrap(TPA, B, TPA);
//debugTPA(tpa, ''); // - get percisely the Text TPA for any non-shadow/backdrop in option list
{**
* START Debugging from here............
*
*
**}
SetColorToleranceSpeed(cts);
B := GetTPABounds(TPA);
n := B.Y2 - B.Y1;
m := 15 - n mod 15;
n := n + m;
bmp := CreateBitmap(B.X2 - B.X1 + 3, n + 1);
OffSetTPA(TPA, Point(-B.X1, -B.Y1));
//FastDrawClear(bmp, 0); // ToDo: ??
DrawTPABitmap(bmp, TPA, clRed);
//ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp)); // ToDo: ??
GetbitmapSize(bmp, w, h);
SetTargetBitmap(bmp);
SetLength(ATPA, h div 15);
for i := 0 to High(ATPA) do
FindColorsTolerance(ATPA[i], clRed, 0, i*15, w-1, 15+i*15, 0);
L := High(ATPA);
SortATPAFromFirstPointY(ATPA, Point(w div 2, 0));
SetArrayLength(Result, Length(ATPA));
Result[0].BigBox := BigBox;
for i := 0 to high(ATPA) do
begin
TPA := ATPA[i];
tempatpa := SplitTPAEx(TPA, 1, 10);
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 5, 'UpChars07');
BB := GetTPABounds(ATPA[i]);
Result[i].Bounds := IntToBox(BB.X1+B.X1, BB.Y1+B.Y1, BB.X2+B.X1, BB.Y2+B.Y1);
setlength(tempatpa,0);
setlength(TPA,0);
end;
ColorToleranceSpeed(cts);
SetImageTarget(target);
FreeBitmap(bmp);
end;
I think I need to better adjust the box coordinates and line-loops, because the Text TPA's are fine