SRL Archive - SRL Suggestions

DebugTPAs - Multi-color debugging.


Frement

2010-12-06 18:32:32

So, I searched for some time and I didn't find a function that would allow debugging with different colors, so I made one.

function DebugTPAs(TPAs: Array of TPointArray; Colors: TIntegerArray): Boolean;
var BMP, I: Integer;
Box: TBox;
BoxTPA: TPointArray;
TempTPA: TPointArray;
begin
if (High(TPAs) <> High(Colors)) then begin
Result := False;
Exit;
end;
for I := 0 to High(TPAs) do begin
AppendTPA(BoxTPA, TPAs[I]);
end;
Box := GetTPABounds(BoxTPA);
BMP := BitmapFromClient(Box.X1, Box.Y1, Box.X2, Box.Y2);
for I := 0 to High(TPAs) do begin
TempTPA := CopyTPA(TPAs[I]);
OffsetTPA(TempTPA, Point(-Box.X1, -Box.Y1));
DrawTPABitmap(BMP, TempTPA, Colors[I]);
end;
DisplayDebugImgWindow(Box.X2 - Box.X1 + 1, Box.Y2 - Box.Y1 + 1);
DrawBitmapDebugImg(BMP);
FreeBitmap(BMP);
Result := True;
end;

Usage is simple:
DebugTPAs([GetNPCs, GetWhite, GetWater], [14680313, 65280, 15245824]);

And this is how it would look with 3 colors:

mormonman

2010-12-06 19:17:26

Isn't there one in MSI? Looks nice tho :D

Cstrike

2010-12-06 19:44:25

Cool you could color paths as well :P

mormonman

2010-12-06 20:33:09

Like a tile path?

Wanted

2010-12-06 20:41:59

DebugATPA

TomTuff

2010-12-06 20:48:09

From: IceFire908
DebugATPA


DebugATPA doesn't allow custom colors. It works the same though, the color customization really isn't necessary honestly.

Wanted

2010-12-06 20:59:32

If it were to be added to SRL it would be done like this

function DebugATPAEx(aPoints: T2DPointArray; BmpName: string; Colors: TIntegerArray): Boolean;
var
Width, Height, ClientBMP{$ifdef scar}, I, L, h, hh{$endif}: Integer;
{$ifdef Simba} ATPA : T2DPointArray; {$endif}
Box : TBox;
begin
result := false;
if length(aPoints) = 0 then
exit;
Box := GetATPABounds(aPoints);
Width := box.x2 - box.x1 + 1;
Height := box.y2 - box.y1 + 1;
DisplayDebugImgWindow(Width, Height);
{$ifdef Simba}
ClientBMP := BitmapFromClient(box.x1,box.y1,box.x2,box.y2);
ATPA := CopyATPA(aPoints);
OffsetATPA(ATPA,point(-box.x1,-box.y1));
DrawATPABitmap(ClientBMP,ATPA);
DrawBitmapDebugImg(ClientBMP);
{$else}
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, box.x1, box.y1, box.x2, box.y2);
H := High(aPoints);
for I := 0 to H do
begin
HH := High(aPoints[i]);
for L := 0 to HH do
FastSetPixel(ClientBMP, aPoints[i][L].X - box.x1, aPoints[i][L].Y - box.y1, Colors[I]);
end;
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
{$endif}
if BmpName <> '' then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
FreeBitmap(ClientBMP);
Result := True;
end;

but there's really no necessity for it

Cstrike

2010-12-06 21:10:23

From: mormonman
Like a tile path?


That'd be even cooler!
Making a drawn line from where you're aimed at… I like that idea :) gonna try and see how that works

Frement

2010-12-07 04:01:12

From: IceFire908
If it were to be added to SRL it would be done like this

function DebugATPAEx(aPoints: T2DPointArray; BmpName: string; Colors: TIntegerArray): Boolean;
var
Width, Height, ClientBMP{$ifdef scar}, I, L, h, hh{$endif}: Integer;
{$ifdef Simba} ATPA : T2DPointArray; {$endif}
Box : TBox;
begin
result := false;
if length(aPoints) = 0 then
exit;
Box := GetATPABounds(aPoints);
Width := box.x2 - box.x1 + 1;
Height := box.y2 - box.y1 + 1;
DisplayDebugImgWindow(Width, Height);
{$ifdef Simba}
ClientBMP := BitmapFromClient(box.x1,box.y1,box.x2,box.y2);
ATPA := CopyATPA(aPoints);
OffsetATPA(ATPA,point(-box.x1,-box.y1));
DrawATPABitmap(ClientBMP,ATPA);
DrawBitmapDebugImg(ClientBMP);
{$else}
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, box.x1, box.y1, box.x2, box.y2);
H := High(aPoints);
for I := 0 to H do
begin
HH := High(aPoints[i]);
for L := 0 to HH do
FastSetPixel(ClientBMP, aPoints[i][L].X - box.x1, aPoints[i][L].Y - box.y1, Colors[I]);
end;
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
{$endif}
if BmpName <> '' then
SaveBitmap(ClientBMP, ScriptPath + BmpName + '.bmp');
FreeBitmap(ClientBMP);
Result := True;
end;

but there's really no necessity for it


I really think this makes debugging easier. It's not a necessity, but certainly would be a great addition.

Wanted

2010-12-07 12:39:00

From: Frement
I really think this makes debugging easier. It's not a necessity, but certainly would be a great addition.


I disagree. Seldom does anyone need to debug a specific amount of TPAs. Even more seldom someone needs to have certain colors for each TPA. If you want a color other than red for a single DebugATPA([TPA]);

To keep the include at a reasonable size (even though its already filled with tons of unused functions) we have to draw the line, this thread is an example.