SRL Archive - Unofficial Development

OpenGL Include [Development]


Mark

2012-10-03 07:28:53

Been Playing with Brandons OGL and thought i would help try get the ball rolling with the development of the include.

here's what ive played about with so far

{$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;;

djborec

2012-10-03 10:28:37

Is there any other way o read text from OGL expect OCR? or is it planned for future developing?

Olly

2012-10-03 11:41:25

From: djborec
Is there any other way o read text from OGL expect OCR? or is it planned for future developing?


What do you mean? the current method (ogl) can read text 100% correctly.

Sirenia

2012-10-03 13:02:21

Not to be a dick but you did a double ";" at the bottom :D

Mark

2012-10-03 13:12:32

oh lol i just copy pasted parts from my own include :D

Brandon

2012-10-03 15:08:13

I'm at school right now.. so I don't have time to check over everything but as far as I can tell from skimming through, this won't work.


P := GLHGetModelsByID(ID, Size);
M := P;
Result:=Point(Result.x:=M^.SX+randomRange(-2, 2),Result.y:=M^.SY+randomRange(-2, 2));


That kind of stuff won't work. The functions from the DLL include return a pointer to an array of "Whatever".. NOT a single entity.

Mark

2012-10-03 15:27:00

these function are just wht i used to test out your plugin didnt need to sort though the array as there was only 1 matching id available
i will continue to develop these function just wanted to get others interested in your project


I have tested all Function they do work maybe explode the Text again to remove spaces but all seems fine to me

wantonman

2012-10-15 01:27:05

$i ogl? lol not that easy