Simba Code:
{$loadlib GLHook}
type TModel = record
ID: Cardinal;
SX, SY: Integer;
Stride: Cardinal;
TriangleCount: Integer;
end;
type TFontInfo = record
ID: Cardinal;
R, G, B, A: Byte;
Colour: Integer;
X, Y: Single;
Symbol: Char;
Shadow: Boolean;
Translate: Array [0..2] Of Single;
VX, VY, TX, TY: Array [0..3] Of Integer;
end;
type PFontInfo = ^TFontInfo;
type TFontArray = array of TFontInfo;
type pByte = ^Byte;
type pInt = ^Integer;
type pBool = ^Boolean;
type pFloat = ^Single;
//Brandons
Function GLHook_GetFontsByArea(Area: TBox): TFontArray;
var
Ptr: Pointer;
Size, I: Integer;
begin
Ptr := GLHGetFontsArea(Area.X1, Area.Y1, Area.X2, Area.Y2, Size);
SetLength(Result, Size);
For I := 0 To Size - 1 Do
begin
Result[I].ID := pInt(Ptr)^;
Ptr := Ptr + sizeof(Integer);
Result[I].R := pByte(Ptr)^;
Result[I].G := pByte(Ptr + sizeof(Byte))^;
Result[I].B := pByte(Ptr + (2 * sizeof(Byte)))^;
Result[I].A := pByte(Ptr + (3 * sizeof(Byte)))^;
Ptr := Ptr + (sizeof(Byte) * 4);
Result[I].Colour := RGBToColor(Result[I].R, Result[I].G, Result[I].B);
Result[I].X := pFloat(Ptr)^;
Result[I].Y := pFloat(Ptr + sizeof(Single))^;
Ptr := Ptr + (sizeof(Single) * 2);
Result[I].Symbol := pChar(Ptr)^;
Result[I].Shadow := pBool(Ptr + sizeof(Boolean))^;
Ptr := Ptr + (sizeof(Char) + sizeof(Boolean)) + 2; //Padded by 2.
Result[I].Translate[0] := pFloat(Ptr)^;
Result[I].Translate[1] := pFloat(Ptr + sizeof(Single))^;
Result[I].Translate[2] := pFloat(Ptr + (2 * sizeof(Single)))^;
Ptr := Ptr + (sizeof(Single) * 3);
Result[I].VX[0] := pInt(Ptr)^;
Result[I].VX[1] := pInt(Ptr + sizeof(Integer))^;
Result[I].VX[2] := pInt(Ptr + (2 * sizeof(Integer)))^;
Result[I].VX[3] := pInt(Ptr + (3 * sizeof(Integer)))^;
Ptr := Ptr + (sizeof(Integer) * 4);
Result[I].VY[0] := pInt(Ptr)^;
Result[I].VY[1] := pInt(Ptr + sizeof(Integer))^;
Result[I].VY[2] := pInt(Ptr + (2 * sizeof(Integer)))^;
Result[I].VY[3] := pInt(Ptr + (3 * sizeof(Integer)))^;
Ptr := Ptr + (sizeof(Integer) * 4);
Result[I].TX[0] := pInt(Ptr)^;
Result[I].TX[1] := pInt(Ptr + sizeof(Integer))^;
Result[I].TX[2] := pInt(Ptr + (2 * sizeof(Integer)))^;
Result[I].TX[3] := pInt(Ptr + (3 * sizeof(Integer)))^;
Ptr := Ptr + (sizeof(Integer) * 4);
Result[I].TY[0] := pInt(Ptr)^;
Result[I].TY[1] := pInt(Ptr + sizeof(Integer))^;
Result[I].TY[2] := pInt(Ptr + (2 * sizeof(Integer)))^;
Result[I].TY[3] := pInt(Ptr + (3 * sizeof(Integer)))^;
Ptr := Ptr + (sizeof(Integer) * 4);
end;
end;
//Brandons
Function FontsToText(var FontArray: TFontArray; Shadow: Boolean; MinHSpacing: Integer; MinVSpacing: Integer): TStringArray;
var
I, J, L: Integer;
Str: String;
Begin
L := High(FontArray);
If Shadow Then J := 1 Else J := 2;
SetLength(Result, 1);
For I := 0 To L Do
If (FontArray[I].Shadow = Shadow) Then
Begin
If (((FontArray[I].Translate[0] - (FontArray[I - J].Translate[0] + FontArray[I - J].VX[3] - FontArray[I - J].VX[0])) >= MinHSpacing) And (I >= 2)) Then
Str := Str + ' ';
If ((((FontArray[I].Translate[1] - FontArray[I - J].Translate[1]) >= MinVSpacing) And (I >= 2) And MinVSpacing > 0) Or (Ord(FontArray[I].Symbol) = 10)) Then
Str := Str + Chr(13);
If (Ord(FontArray[I].Symbol) <> 10) Then
Str := Str + FontArray[I].Symbol;
End;
ExplodeWrap(Chr(13), Str, Result);
For I := 0 To High(Result) Do
Result[I] := Trim(Result[I]);
End;
function GLGetTextPosEx(TB:TBox;Text:String):TPoint;
var
FF:TFontArray;
TP:TPoint;
Found:TStringArray;
begin
FF:=GLHook_GetFontsByArea(TB);
Found:=FontsToText(FF,0,0,0);
if Found[0] = Text then
begin
writeln(Found);
Result:=Point(round(FF[0].x),round(FF[0].y));
end else
writeln('faied');
end;
function GLIsTextEx(TB: TBox; Text: string): Boolean;
var
FA: TFontArray;
Found: TStringArray;
begin
FA := GLHook_GetFontsByArea(TB);
Found := FontsToText(FA, 0, 0, 0);
if Found[0] = Text then
begin
Result := true;
writeln(Found[0]);
end else
Result := false;
end;
function GLGetTextEx(TB: TBox): string;
var
FA: TFontArray;
Found: TStringArray;
begin
FA := GLHook_GetFontsByArea(TB);
Found := FontsToText(FA, 0, 0, 0);
Result:=Found[0];
end;
function GLIsUpText(Text:string):Boolean;
var
TB:TBox;
begin
TB:=IntToBox(7, 56, 83, 74);
Result:=GLIsTextEx(TB,Text);
end;
function GLGetModelPos(ID:integer):TPoint;
var
P: Pointer;
M: ^TModel;
X, Y, Size:integer;
begin
P := GLHGetModelsByID(ID, Size);
M := P;
Result:=Point(Result.x:=M^.SX+randomRange(-2, 2),Result.y:=M^.SY+randomRange(-2, 2));
end;
function GLGetItemPos(ID:integer):TPoint;
var
P: Pointer;
M: ^TModel;
X,Y,Size:integer;
begin
P := GLHGetItemsByID(ID, Size);
M := P;
Result:=Point(Result.x:=M^.SX+randomRange(-2, 2),Result.y:=M^.SY+randomRange(-2, 2));
end;;