Skip to content

Commit

Permalink
Clean up debug image imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Aug 5, 2023
1 parent a080c08 commit b998460
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
60 changes: 31 additions & 29 deletions Source/script/imports/simba/simba.import_debugimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,39 @@ implementation
*)

(*
UpdateDebugImage
DebugImageUpdate
~~~~~~~~~~~~~~~~
> procedure UpdateDebugImage(Bitmap: TSimbaImage);
> procedure DebugImageUpdate(Bitmap: TSimbaImage);
*)

(*
ShowDebugImage
~~~~~~~~~~~~~~
> procedure ShowDebugImage(Width, Height: Integer);
DebugImageDisplay
~~~~~~~~~~~~~~~~~
> procedure DebugImageDisplay(Width, Height: Integer);
*)

(*
ShowDebugImage
~~~~~~~~~~~~~~
> procedure ShowDebugImage(X, Y,Width, Height: Integer);
DebugImageDisplay
~~~~~~~~~~~~~~~~
> procedure DebugImageDisplay(X, Y,Width, Height: Integer);
*)

(*
DebugImageClose
~~~~~~~~~~~~~~~
> procedure DebugImageClose;
*)

(*
SetDebugImageMaxSize
DebugImageSetMaxSize
~~~~~~~~~~~~~~~~~~~~
> procedure SetDebugImageMaxSize(MaxWidth, MaxHeight: Integer);
> procedure DebugImageSetMaxSize(MaxWidth, MaxHeight: Integer);
*)

(*
HideDebugImage
DebugImageShow
~~~~~~~~~~~~~~
> procedure HideDebugImage;
> procedure DebugImageShow(Image: TImage; EnsureVisible: Boolean = True);
*)

procedure ImportDebugImage(Compiler: TSimbaScript_Compiler);
Expand All @@ -149,58 +155,47 @@ procedure ImportDebugImage(Compiler: TSimbaScript_Compiler);
ImportingSection := 'Debug Image';

addGlobalFunc(
'procedure SetDebugImageMaxSize(MaxWidth, MaxHeight: Integer);', [
'procedure DebugImageSetMaxSize(MaxWidth, MaxHeight: Integer);', [
'begin',
' _SimbaScript.DebugImage_SetMaxSize(MaxWidth, MaxHeight);',
'end;'
]);

addGlobalFunc(
'procedure ShowDebugImage(Width, Height: Integer); overload;', [
'procedure DebugImageDisplay(Width, Height: Integer); overload;', [
'begin',
' _SimbaScript.DebugImage_Display(Width, Height);',
'end;'
]);

addGlobalFunc(
'procedure ShowDebugImage(X, Y, Width, Height: Integer); overload;', [
'procedure DebugImageDisplay(X, Y, Width, Height: Integer); overload;', [
'begin',
' _SimbaScript.DebugImage_Display(X, Y, Width, Height);',
'end;'
]);

addGlobalFunc(
'procedure HideDebugImage;', [
'procedure DebugImageClose;', [
'begin',
' _SimbaScript.DebugImage_Hide();',
'end;'
]);

addGlobalFunc(
'procedure UpdateDebugImage(Image: TImage);', [
'procedure DebugImageUpdate(Image: TImage);', [
'begin',
' _SimbaScript.DebugImage_Update(Image);',
'end;'
]);

addGlobalFunc(
'procedure Show(Image: TImage; EnsureVisible: Boolean = True);', [
'procedure DebugImageShow(Image: TImage; EnsureVisible: Boolean = True);', [
'begin',
' _SimbaScript.DebugImage_Show(Image, EnsureVisible);',
'end;'
]);

ImportingSection := 'TImage';

addGlobalFunc(
'procedure TImage.Show(EnsureVisible: Boolean = True);', [
'begin',
' Show(Self, EnsureVisible);',
'end;'
]);

ImportingSection := 'Debug Image';

addGlobalFunc(
'procedure Show(Matrix: TIntegerMatrix); overload;', [
'begin',
Expand Down Expand Up @@ -369,6 +364,13 @@ procedure ImportDebugImage(Compiler: TSimbaScript_Compiler);
'end;'
]);

addGlobalFunc(
'procedure TImage.Show(EnsureVisible: Boolean = True); override;', [
'begin',
' _SimbaScript.DebugImage_Show(Self, EnsureVisible);',
'end;'
]);

ImportingSection := '';
end;
end;
Expand Down
3 changes: 1 addition & 2 deletions Source/script/imports/simba/simba.import_target.pas
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ procedure ImportTarget(Compiler: TSimbaScript_Compiler);

addGlobalFunc('function ToString(constref Target: TSimbaTarget): String; override;', @_LapeSimbaTarget_ToString);


ImportingSection := 'TImage';
ImportingSection := 'Image';

addGlobalFunc(
'function TImage.CreateFromTarget(Target: TSimbaTarget; Bounds: TBox = [-1,-1,-1,-1]): TImage; static; overload;', [
Expand Down
15 changes: 15 additions & 0 deletions Source/script/imports/simbaclasses/simba.import_class_bitmap.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,14 @@ procedure _LapeImage_RowPtrs(const Params: PParamArray; const Result: Pointer);
> procedure TImage.DrawTarget(P: TPoint; Bounds: TBox = [-1,-1,-1,-1]); overload;
*)

(*
TImage.Show
~~~~~~~~~~~
> procedure TImage.Show;
Show a image on the debug image.
*)

procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
begin
with Compiler do
Expand Down Expand Up @@ -1409,6 +1417,13 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TImage.SaveUnfreedImages(Directory: String); static;', @_LapeImage_SaveUnfreedImages);
addGlobalFunc('procedure TImage.FreeOnTerminate(Value: Boolean);', @_LapeImage_FreeOnTerminate);

// overrided in debugimage import
addGlobalFunc(
'procedure TImage.Show(EnsureVisible: Boolean = True);', [
'begin',
'end;'
]);

ImportingSection := '';
end;
end;
Expand Down

0 comments on commit b998460

Please sign in to comment.