Skip to content

Commit

Permalink
docs + version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Sep 17, 2023
1 parent d6f2dcf commit 6368834
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 55 deletions.
43 changes: 26 additions & 17 deletions DocGen/source/plugins/plugin-cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,37 @@ main.h

struct __attribute__((__packed__)) TSimbaMethods
{
void (*RunOnMainThread)(void(*Method)(void*), void* data);
void (*RunOnMainThread)(void(*Method)(void*), void* data);

void* (*GetMem)(NativeUInt size);
void (*FreeMem)(void* ptr);
void* (*AllocMem)(NativeUInt Size);
void* (*ReAllocMem)(void** ptr, NativeUInt size);
NativeUInt (*MemSize)(void* ptr);
void* (*GetMem)(NativeUInt size);
void (*FreeMem)(void* ptr);
void* (*AllocMem)(NativeUInt Size);
void* (*ReAllocMem)(void** ptr, NativeUInt size);
NativeUInt (*MemSize)(void* ptr);

void (*RaiseException)(char* Message);
void* (*GetTypeInfo)(void* Compiler, char* Typ);
NativeUInt (*GetTypeInfoSize)(void* TypeInfo);
NativeInt (*GetTypeInfoFieldOffset)(void* TypeInfo, char* FieldName);
void (*RaiseException)(char* Message);
void* (*GetTypeInfo)(void* Compiler, char* Typ);
NativeUInt (*GetTypeInfoSize)(void* TypeInfo);
NativeInt (*GetTypeInfoFieldOffset)(void* TypeInfo, char* FieldName);

void* (*AllocateRawArray)(NativeInt ElementSize, NativeUInt Len);
void (*ReAllocateRawArray)(void** ptr, NativeInt ElementSize, NativeUInt Len);
void* (*AllocateRawArray)(NativeInt ElementSize, NativeUInt Len);
void (*ReAllocateRawArray)(void** ptr, NativeInt ElementSize, NativeUInt Len);

void* (*AllocateArray)(void* TypeInfo, NativeUInt Len);
void* (*AllocateString)(void* Data);
void* (*AllocateUnicodeString)(void* Data);
void* (*AllocateArray)(void* TypeInfo, NativeUInt Len);
void* (*AllocateString)(void* Data);
void* (*AllocateUnicodeString)(void* Data);

void (*SetArrayLength)(void* TypeInfo, void**ptr, NativeInt NewLen);
NativeInt (*GetArrayLength)(void* AVar);
void (*SetArrayLength)(void* TypeInfo, void**ptr, NativeInt NewLen);
NativeInt (*GetArrayLength)(void* AVar);

void* (*ExternalImage_Create)(bool FreeOnTerminate);
void (*ExternalImage_SetMemory)(void* img, void* data, int width, int height);
bool (*ExternalImage_TryLock)(void* img);
void (*ExternalImage_Lock)(void* img);
void (*ExternalImage_UnLock)(void* img);

void (*ExternalImage_AddCallbackOnUnlock)(void* img, void(*callback)(void*));
void (*ExternalImage_RemoveCallbackOnUnlock)(void* img, void(*callback)(void*));
};

TSimbaInfo* SIMBA_INFO = {0};
Expand Down
18 changes: 16 additions & 2 deletions DocGen/source/plugins/writing-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,24 @@ These pointers are provided to these structures:
AllocateArray: function(TypeInfo: Pointer; Len: NativeInt): Pointer; cdecl;
AllocateString: function(Data: PChar): Pointer; cdecl;
AllocateUnicodeString: function(Data: PUnicodeChar): Pointer; cdecl;
AllocateUnicodeString: function(Data: PUnicodeChar): Pointer; cdecl;
SetArrayLength: procedure(TypeInfo: Pointer; var AVar: Pointer; NewLen: NativeInt); cdecl;
GetArrayLength: function(AVar: Pointer): NativeInt; cdecl;
ExternalImage_Create: function(FreeOnTerminate: Boolean): Pointer; cdecl;
ExternalImage_SetMemory: procedure(Img: Pointer; Data: PColorBGRA; AWidth, AHeight: Integer); cdecl;
ExternalImage_TryLock: function(Img: Pointer): Boolean; cdecl;
ExternalImage_Lock: procedure(Img: Pointer); cdecl;
ExternalImage_UnLock: procedure(Img: Pointer); cdecl;
ExternalImage_AddCallbackOnUnlock: procedure(Img: Pointer; Callback: TSimbaExternalImageCallback); cdecl;
ExternalImage_RemoveCallbackOnUnlock: procedure(Img: Pointer; Callback: TSimbaExternalImageCallback); cdecl;
end;
See the `Example C++ plugin <plugin-cpp.html>`_ to see how TypeInfo is used to allocate custom records & arrays.
See the `Example C++ plugin <plugin-cpp.html>`_ to see how TypeInfo is used to allocate custom records & arrays.

.. note::

`RunOnMainThread` is available for creating forms, installing windows hooks and other things that must be done on the main thread.
Simba scripts are not ran on the processes main thread for this reason.
52 changes: 52 additions & 0 deletions DocGen/source/tutorials/Input & Finder Target.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#####################
Input & Finder Target
#####################

Both :code:`Input` and :code:`Finder` records have a :code:`Target` field.
If this is not set (is default value) the global :code:`Target` variable is used.

-----

These examples will use the global :code:`Target` variable. This by default is set to Simba's target window when the script was started, or the desktop if no window has been selected.

.. code-block::
Input.MouseTeleport([100,100]);
Of course you can also change the global :code:`Target` variable and the Input/Finder variables will keep updated.

.. code-block::
Target.SetWindow(some_window_handle);
Input.MouseTeleport([100,100]);
-----

In these examples since :code:`Input.Target` has a value that target is used.

.. code-block::
Input.Target.SetWindow(some_window_handle);
Input.MouseTeleport([100,100]);
You can also declare as many Input/Finder variables as you like, all with different targets.

.. code-block::
var
MyOtherInput: TInput;
begin
MyOtherInput.Target.SetWindow(123456);
MyOtherInput.MouseTeleport([100,100]);
end;
-----

You can clear the :code:`Input.Target` variable so the global :code:`Target` variable is once again used.

.. code-block::
begin
Input.Target := [];
Input.MouseTeleport([100,100]);
end;
3 changes: 2 additions & 1 deletion DocGen/source/tutorials/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Simba
:maxdepth: 2

Color Finding.rst
Sleep Until.rst
Sleep Until.rst
Input & Finder Target.rst
5 changes: 2 additions & 3 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
</General>
<VersionInfo>
<UseVersionInfo Value="True"/>
<MajorVersionNr Value="1"/>
<MinorVersionNr Value="5"/>
<MajorVersionNr Value="2"/>
<Language Value="0809"/>
<CharSet Value="04B0"/>
<StringTable CompanyName="villavu.com" FileDescription="Simba: http://wizzup.org/simba/" OriginalFilename="Simba.exe" ProductName="Simba" ProductVersion="1.5"/>
<StringTable CompanyName="villavu.com" FileDescription="Simba: http://wizzup.org/simba/" OriginalFilename="Simba.exe" ProductName="Simba" ProductVersion="2.0"/>
</VersionInfo>
<BuildModes Count="7">
<Item1 Name="DEBUG" Default="True"/>
Expand Down
Binary file modified Source/Simba.res
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/macosbundle/Simba.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.5</string>
<string>2.0</string>
<key>CFBundleVersion</key>
<string>1500</string>
<string>2000</string>
<key>CSResourcesFileMapped</key>
<false/>
<key>CFBundleDocumentTypes</key>
Expand Down
4 changes: 3 additions & 1 deletion Source/script/imports/simba/simba.import_matchtemplate.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ implementation
(*
Match Template
==============
Template matching
Template matching.
Note:: These functions outputs are equal to OpenCV's matchTemplate.
*)

(*
Expand Down
18 changes: 0 additions & 18 deletions Source/script/simba.scriptthread.pas
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

{$i simba.inc}

{$IFDEF DARWIN}
{$DEFINE COCOA_TERMINATE_FIX} // https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39496
{$MODESWITCH OBJECTIVEC1}
{$ENDIF}

interface

uses
Expand Down Expand Up @@ -42,13 +37,9 @@ TSimbaScriptRunner = class(TThread)
); reintroduce;
end;


implementation

uses
{$IFDEF COCOA_TERMINATE_FIX}
cocoaall, cocoaint, cocoautils,
{$ENDIF}
Forms, FileUtil,
simba.env, simba.files, simba.datetime, simba.script_communication;

Expand All @@ -75,15 +66,6 @@ procedure TSimbaScriptRunner.DoTerm(Sender: TObject);
Application.Terminate();
while (not Application.Terminated) do
Application.ProcessMessages();

{$IFDEF COCOA_TERMINATE_FIX}
NSApplication.sharedApplication.postEvent_AtStart(
nsEvent.otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2(
NSApplicationDefined, GetNSPoint(0, 0), 0, NSTimeIntervalSince1970, 0, nil, 0, 0, 0
),
True
);
{$ENDIF}
end;

procedure TSimbaScriptRunner.DoInputThread;
Expand Down
15 changes: 6 additions & 9 deletions Source/simba.ide_initialization.pas
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,16 @@ procedure SimbaIDEInitialization_CallBeforeCreate;
begin
for Method in BeforeCreateMethods do
begin
Debug('[SimbaIDEInitialization.BeforeCreate]: %s ', [Method.Name]);
try
T := HighResolutionTime();

if Assigned(Method.Proc) then Method.Proc() else
if Assigned(Method.ProcObj) then Method.ProcObj();

DebugLn('(%f ms)', [HighResolutionTime() - T]);
DebugLn('[SimbaIDEInitialization.BeforeCreate]: %s (%f ms)', [Method.Name, HighResolutionTime() - T]);
except
on E: Exception do
DebugLn('Exception: (%s)', [E.Message]);
DebugLn('[SimbaIDEInitialization.BeforeCreate]: %s (exception: %s)', [Method.Name, E.Message]);
end;
end;
end;
Expand All @@ -123,17 +122,16 @@ procedure SimbaIDEInitialization_CallBeforeShow_Background;
if not Method.BackgroundTask then
Continue;

Debug('[SimbaIDEInitialization.BeforeShow (Background task)]: %s ', [Method.Name]);
try
T := HighResolutionTime();

if Assigned(Method.Proc) then Method.Proc() else
if Assigned(Method.ProcObj) then Method.ProcObj();

DebugLn('(%f ms)', [HighResolutionTime() - T]);
DebugLn('[SimbaIDEInitialization.BeforeShow_Background]: %s (%f ms)', [Method.Name, HighResolutionTime() - T]);
except
on E: Exception do
DebugLn('Exception: (%s)', [E.Message]);
DebugLn('[SimbaIDEInitialization.BeforeShow_Background]: %s (exception: %s)', [Method.Name, E.Message]);
end;
end;
end;
Expand All @@ -148,17 +146,16 @@ procedure SimbaIDEInitialization_CallBeforeShow;
if Method.BackgroundTask then
Continue;

Debug('[SimbaIDEInitialization.BeforeShow]: %s ', [Method.Name]);
try
T := HighResolutionTime();

if Assigned(Method.Proc) then Method.Proc() else
if Assigned(Method.ProcObj) then Method.ProcObj();

DebugLn('(%f ms)', [HighResolutionTime() - T]);
DebugLn('[SimbaIDEInitialization.BeforeShow]: %s (%f ms)', [Method.Name, HighResolutionTime() - T]);
except
on E: Exception do
DebugLn('Exception: (%s)', [E.Message]);
DebugLn('[SimbaIDEInitialization.BeforeShow]: %s (exception: %s)', [Method.Name, E.Message]);
end;
end;

Expand Down
4 changes: 2 additions & 2 deletions Source/simba.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
{$MODESWITCH ARRAYOPERATORS}
{$MODESWITCH NESTEDPROCVARS}

{$DEFINE SIMBA_MAJOR := 1500} // this should be 980 even if SimbaVersion is 981, etc
{$DEFINE SIMBA_VERSION := 1500}
{$DEFINE SIMBA_MAJOR := 2000} // this should be 980 even if SimbaVersion is 981, etc
{$DEFINE SIMBA_VERSION := 2000}

{$DEFINE SIMBA_GITHUB_URL := 'https://github.com/Villavu/Simba'}
{$DEFINE SIMBA_BUGS_URL := 'https://github.com/Villavu/Simba/issues'}
Expand Down

0 comments on commit 6368834

Please sign in to comment.