riwu
2012-10-02 07:12:51
I was looking into how the TextType parameter (used in Option functions) treat 'action' and 'player', two rather distinct color as the same. And to my surprise, TextType isn't used in the function at all, meaning that no matter what you input as parameter will have no impact at all (you can even put a random string of numbers and not get any error).
Code below for quick reference.
From comments of related functions:
Code below for quick reference.
GetChooseOptions
~~~~~~~~~~~~~~~~
.. code-block:: pascal
function GetChooseOptions(TextType: string): Array of TOptions;
Gets the texe from the options menu.
.. note::
by Wizzup? & Narcle
Example:
.. code-block:: pascal
*)
Function GetChooseOptions(TextType: string): Array of TOptions;
var
B, BB, sB, BigBox: TBox;
TPA, TPA1, TPA2: TPointArray;
ATPA, tempatpa: T2DPointArray;
I, L, target, bmp,w,h, cts: Integer;
BoxColors: TIntegerArray;
begin
target := GetImageTarget;
GetClientDimensions(B.X2, B.Y2);
B := IntToBox(0, 0, B.X2-1, B.Y2-1);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
// Black, Top Blue, grey
BoxColors := [131843, 3682593, 3552822];
SetLength(ATPA, Length(BoxColors));
for i := 0 to High(BoxColors) do
FindColorsTolerance(ATPA[i], BoxColors[i], B.X1, B.Y1, B.X2, B.Y2, 0);
TPA := MergeATPA(ATPA);
If Length(TPA) < 100 Then
begin
ColorToleranceSpeed(cts);
Exit;
end;
ATPA := SplitTPA(TPA, 4);
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);
FindColorsTolerance(TPA1, 4996381, B.X1, B.Y1, B.X2, B.Y2, 18);//One color covers both Highlighted and non
sB := GetTPABounds(TPA1);
ReturnPointsNotInTPAWrap(TPA1, sB, TPA);
FindColorsTolerance(TPA2, 460291, B.X1, B.Y1, B.X2, B.Y2, 6);//shadow
SetColorToleranceSpeed(cts);
bmp := CreateBitmap(B.X2-B.X1+2, B.Y2-B.Y1+2);
OffsetTPA(TPA, Point(-B.X1, -B.Y1));
OffsetTPA(TPA2, Point(-B.X1, -B.Y1));
FastDrawClear(bmp, 0);
DrawTPABitmap(bmp, TPA, clRed);//Text
DrawTPABitmap(bmp, TPA2, clPurple);//Shadow
ocr_FilterUpTextByCharacteristics(GetMufasaBitmap(bmp));
GetbitmapSize(bmp,w,h);
SetTargetBitmap(bmp); // new target for findcolorstolerance.
SetLength(ATPA, H div 16);
for i := 0 to High(ATPA) do
FindColorsTolerance(ATPA[i], clRed, 0, 2+i*16, W-1, 18+i*16, 0);//+2 to y to line it up
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); // Split one into characters
SortATPAFromFirstPointX(tempatpa, Point(0, 0));
Result[i].Str := GetTextATPA(tempatpa, 5, 'UpCharsEx'); //Writeln(Result[i].Str);
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; From comments of related functions:
Searches for TextType you input.
'action', 'player': The white text
'item': The orange text
'npc': The yellow text
'object': The cyan text
'all': Searches for all colors of text.
Will default to 'all'.