SRL Archive - SRL Archives

TextCoords Fixed


TRiLeZ

2009-10-24 15:20:32

The last line of text (line 8) has moved 1 pixel down so I fixed it.


{*******************************************************************************
Function TextCoords(textn: Integer): TPoint;
By: Wizzup?
Description: Returns x, y for text. (1 to 8)
*******************************************************************************}

Function TextCoords(textn: Integer): TPoint;

Begin
Result.X := 11;
if (textn = 8) then Result.Y := 445
else
Result.Y := 346 + (14 * (textn - 1));
End;

Edit:
Made shorter by NaumanAkhlaQ


{*******************************************************************************
Function TextCoords(textn: Integer): TPoint;
By: Wizzup?
Description: Returns x, y for text. (1 to 8)
*******************************************************************************}

Function TextCoords(textn: Integer): TPoint;

Begin
Result := Point(11, (346 + (14 * (textn - 1))) + Integer(Textn = 8));
End;

Naum

2009-10-24 15:25:55

Are you sure this works? GetText subtracts pixels, so in theory it shouldn't be that much of a problem:

Function TextCoords(textn : Byte) : TPoint;
Begin
Result := Point(11, (346 + (14 * (textn - 1))) + Integer(Textn = 8));
End;

TRiLeZ

2009-10-24 15:32:59

My way and your way works.
I like your way better because it's shorter. :)

Naike

2009-10-25 17:43:37

It haven't been moved, and the chat.scar functions still works?

YoHoJo

2009-10-25 19:39:08

I confirm that SOMETHING is wrong with Texcoords. I tried testing this and im getting stupid DIB-shit errors. So cant confirm it it works or not (error is my/scars fault).

Naike

2009-10-25 20:22:45

The fit in perfectly when I checked 2 hours ago?

Are they moving :l, that would be a pain..

TRiLeZ

2009-11-11 03:13:18

Can anyone confirm that TextCoords is broken? Something has to be done because it's not working.

Narcle

2009-11-11 10:10:39

It could be moving. I suggest a TPA find using the text color so we get exact coords of the text every time it moves.

TRiLeZ

2009-11-11 18:45:54

From: Narcle
It could be moving. I suggest a TPA find using the text color so we get exact coords of the text every time it moves.


y's q's p's, g's and j's go down into the text area of the line below so that will create a problem if I use a TPA.

I modified TextCoords to get text in the 8th line and see if it contains any letters other than "i". (With this function broken, I get I's, .'s and ,'s as a result when chat text grabbing).


{*******************************************************************************
function TextCoords(textn: Integer): TPoint;
By: TRiLeZ
Description: Returns x, y for text. (1 to 8)
*******************************************************************************}
function TextCoords(textn: Integer): TPoint;
var
P: TPoint;
cArr: TPointArray;
B: TBox;
ChatText: string;
begin
Result := Point(11, 346 + (14 * (textn - 1)));
if (FindColorsTolerance(cArr, clBlue, MCX1, Result.y, MCX2, Result.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
ChatText := Trim(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, clBlue, 80, False, tr_AllChars));
end else
if (FindColorsTolerance(cArr, clBlack, MCX1, Result.y, MCX2, Result.y + 13, 0)) then
begin
B := GetTPABounds(cArr);
ChatText := Trim(GetTextAtEx(B.x1 - 1, B.y1 - 2, 0, SmallChars, False, False,
0, 1, clBlack, 80, False, tr_AllChars));
end;
if (not ArrInStr(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], ChatText)) then
Result := Point(11, (346 + (14 * (textn - 1))) + Integer(Textn = 8));
end;

Narcle

2009-11-11 21:22:51

From: TRiLeZ
y's q's p's, g's and j's go down into the text area of the line below so that will create a problem if I use a TPA.


That shouldn't matter. The key is getting the correct top-left starting point. Look at GetAmount for referance, I had to change it to a TPA search to work correctly.

TRiLeZ

2009-11-11 22:32:12

From: Narcle
That shouldn't matter. The key is getting the correct top-left starting point. Look at GetAmount for referance, I had to change it to a TPA search to work correctly.


There is no top-left starting point in Q, O, A, S, G, J, or C so how would I be able to work around that?

Also, people are able to change their names to lower case letters so how would I be able to work around that?

Narcle

2009-11-12 03:33:09

From: TRiLeZ
There is no top-left starting point in Q, O, A, S, G, J, or C so how would I be able to work around that?

Also, people are able to change their names to lower case letters so how would I be able to work around that?


…you use TBox

Box := GetTPABounds(TPA);

You then proceed to use x1/y1. You didn't look at Getamount(x,y) did you?

TRiLeZ

2009-11-12 04:38:30

From: Narcle
…you use TBox

Box := GetTPABounds(TPA);

You then proceed to use x1/y1. You didn't look at Getamount(x,y) did you?


I did but I didn't know if it would work for me. I'll try using a TPA in a little while.

Edit: I used a TBox and I tested the function that I made when there was only the text "There to help me make my bids." and it resulted in the correct TPoint but when there were 2 lines of the "There to help me make my bids.", the function resulted in 1 pixel up (the top of where I set it to search for the color), where the text used to be, but isn't anymore because it has moved down. The reason for the function's result being 1 pixel up was because of the y in the 7th line.