1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 18:52:15 -05:00

Made a start with getting plugins to work correctly, therefore added TEIOS_Exported...

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@512 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2010-02-03 23:13:09 +00:00
parent 62996e54cf
commit ed96400df1
5 changed files with 168 additions and 0 deletions

View File

@ -61,6 +61,16 @@ begin
CurrThread.Client.IOManager.GetKeyMouseTarget(result);
end;
function ExportImageTarget : TEIOS_Exported;
begin;
result := CurrThread.Client.IOManager.ExportImageTarget;
end;
function ExportKeyMouseTarget : TEIOS_Exported;
begin;
result := CurrThread.Client.IOManager.ExportKeyMouseTarget;
end;
procedure FreeTarget(idx: integer); extdecl;
begin
CurrThread.Client.IOManager.FreeTarget(idx);

View File

@ -41,6 +41,7 @@ Sender.Comp.AddTypeS('TPointArrayArray','Array of TPointArray');
Sender.Comp.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)');
Sender.Comp.AddTypeS('TMask','record White, Black : TPointArray; WhiteHi,BlackHi : integer; W,H : integer;end;');
Sender.Comp.addtypeS('PPoint','record R,T : extended; end;');
Sender.Comp.AddTypeS('TEIOS_Exported','record int1,int2,int3,int4,int5,int6,int7,int8,int9,int10,int11,int12,int13,int14:integer; end;');
Sender.Comp.AddTypes('TDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, AreaShape: integer; end;');
Sender.Comp.AddTypes('TDTMPointDefArray', 'Array Of TDTMPointDef;');

View File

@ -79,6 +79,8 @@ AddFunction(@SetImageTarget,'procedure SetImageTarget(idx: integer);');
AddFunction(@SetKeyMouseTarget,'procedure SetKeyMouseTarget(idx: integer);');
AddFunction(@GetImageTarget,'function GetImageTarget: integer;');
AddFunction(@GetKeyMouseTarget,'function GetKeyMouseTarget: integer;');
AddFunction(@ExportImageTarget,'function ExportImageTarget : TEIOS_Exported;');
AddFunction(@ExportKeyMouseTarget,'function ExportKeyMouseTarget : TEIOS_Exported;');
AddFunction(@FreeTarget,'procedure FreeTarget(idx: integer);');
AddFunction(@SetDesktopAsClient,'procedure SetDesktopAsClient');
AddFunction(@ActivateClient, 'procedure ActivateClient;');

View File

@ -174,6 +174,7 @@ uses
uPSC_extctrls, //Compile-libs
uPSUtils,
fontloader,
IOmanager,//TEIOS_Exported
IniFiles,//Silly INI files
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
uPSR_extctrls, //Runtime-libs

View File

@ -207,6 +207,28 @@ interface
function FindClient(name:string): integer;
end;
{Basically like TEIOS_Client, only this is exported to some plugin, whilst TEIOS_Client is Imported
Not all functions have to be 'set', it depends on the kind of target (Image/KeyMouse) }
TEIOS_Exported = packed record
Target : Pointer;
GetTargetDimensions: procedure(target: pointer; var w, h: integer); stdcall;
GetColor : function(target: pointer;x,y : integer) : integer; stdcall;
ReturnData : function(target: pointer;xs, ys, width, height: Integer): TRetData; stdcall;
FreeReturnData : procedure(target: pointer); stdcall;
GetMousePosition: procedure(target: pointer; var x,y: integer); stdcall;
MoveMouse: procedure(target: pointer; x,y: integer); stdcall;
HoldMouse: procedure(target: pointer; x,y: integer; left: boolean); stdcall;
ReleaseMouse: procedure(target: pointer; x,y: integer; left: boolean); stdcall;
SendString: procedure(target: pointer; str: PChar); stdcall;
HoldKey: procedure(target: pointer; key: integer); stdcall;
ReleaseKey: procedure(target: pointer; key: integer); stdcall;
IsKeyHeld: function(target: pointer; key: integer): boolean; stdcall;
GetKeyCode : function(target : pointer; C : char) : integer; stdcall;
end;
{ This class specifies the object that will go in the ThreadVar to give the script access
| to targets. This class is abstract, i.e., the actual os-specific Implementation of
| TIOManager is in one of the os units.
@ -255,6 +277,8 @@ interface
function GetImageTarget: TTarget; overload;
function GetKeyMouseTarget: TTarget; overload;
function ExportImageTarget : TEIOS_Exported; overload;
function ExportKeyMouseTarget : TEIOS_Exported; overload;
procedure GetImageTarget(var idx: integer); overload;
procedure GetKeyMouseTarget(var idx: integer); overload;
@ -285,6 +309,23 @@ interface
property Stopping: Boolean Read FStopping write SetState;
end;
{These wrappers are for an exported TEIOS_Exported. This is done so a plugin can acces the current target and use its methodes}
procedure TEIOS_Exported_GetTargetDimensions(target: pointer; var w, h: integer); stdcall;
function TEIOS_Exported_GetColor (target: pointer;x,y : integer) : integer; stdcall;
function TEIOS_Exported_ReturnData (target: pointer;xs, ys, width, height: Integer): TRetData; stdcall;
procedure TEIOS_Exported_FreeReturnData(target: pointer); stdcall;
procedure TEIOS_Exported_GetMousePosition(target: pointer; var x,y: integer); stdcall;
procedure TEIOS_Exported_MoveMouse(target: pointer; x,y: integer); stdcall;
procedure TEIOS_Exported_HoldMouse(target: pointer; x,y: integer; left: boolean); stdcall;
procedure TEIOS_Exported_ReleaseMouse(target: pointer; x,y: integer; left: boolean); stdcall;
procedure TEIOS_Exported_SendString(target: pointer; str: PChar); stdcall;
procedure TEIOS_Exported_HoldKey(target: pointer; key: integer); stdcall;
procedure TEIOS_Exported_ReleaseKey(target: pointer; key: integer); stdcall;
function TEIOS_Exported_IsKeyHeld(target: pointer; key: integer): boolean; stdcall;
function TEIOS_Exported_GetKeyCode(target : pointer; C : char) : integer; stdcall;
implementation
uses FileUtil,
@ -293,6 +334,7 @@ implementation
var eios_controller: TEIOS_Controller;
//***implementation*** TIOManager
constructor TIOManager_Abstract.Create(plugin_dir: string);
@ -392,6 +434,37 @@ begin
result := keymouse;
end;
function TIOManager_Abstract.ExportImageTarget: TEIOS_Exported;
begin
FillChar(result,sizeof(TEIOS_Exported),0);
with result do
begin
Target:= image;
GetTargetDimensions:= @TEIOS_Exported_GetTargetDimensions;
GetColor:= @TEIOS_Exported_GetColor;
ReturnData := @TEIOS_Exported_ReturnData;
FreeReturnData:= @TEIOS_Exported_FreeReturnData;
end;
end;
function TIOManager_Abstract.ExportKeyMouseTarget: TEIOS_Exported;
begin
with result do
begin
Target:= KeyMouse;
GetMousePosition := @TEIOS_Exported_GetMousePosition;
MoveMouse := @TEIOS_Exported_MoveMouse;
HoldMouse := @TEIOS_Exported_HoldMouse;
ReleaseMouse := @TEIOS_Exported_ReleaseMouse;
SendString := @TEIOS_Exported_SendString;
HoldKey := @TEIOS_Exported_HoldKey;
ReleaseKey := @TEIOS_Exported_ReleaseKey;
IsKeyHeld := @TEIOS_Exported_IsKeyHeld;
GetKeyCode := @TEIOS_Exported_GetKeyCode;
end;
end;
function TIOManager_Abstract.SetBothTargets(target: TTarget): integer;
begin
if IsFrozen then
@ -844,6 +917,87 @@ begin
result:= plugs[i].client
end;
//***implementation*** TEIS_Exported wrappers
procedure TEIOS_Exported_GetTargetDimensions(target: pointer; var w,
h: integer); stdcall;
begin
TTarget(Target).GetTargetDimensions(w,h);
end;
function TEIOS_Exported_GetColor(target: pointer;x, y: integer): integer; stdcall;
begin
result := TTarget(Target).GetColor(x,y);
end;
function TEIOS_Exported_ReturnData(target: pointer;xs, ys, width, height: Integer): TRetData;
stdcall;
begin
result := TTarget(Target).ReturnData(xs,ys,width,height);
end;
procedure TEIOS_Exported_FreeReturnData(target: pointer); stdcall;
begin
TTarget(target).FreeReturnData;
end;
procedure TEIOS_Exported_GetMousePosition(target: pointer; var x, y: integer
); stdcall;
begin
TTarget(Target).GetMousePosition(x,y);
end;
procedure TEIOS_Exported_MoveMouse(target: pointer; x, y: integer); stdcall;
begin
TTarget(Target).MoveMouse(x,y);
end;
procedure TEIOS_Exported_HoldMouse(target: pointer; x, y: integer;
left: boolean); stdcall;
begin
if left then
TTarget(Target).HoldMouse(x,y,mouse_left)
else
TTarget(Target).HoldMouse(x,y,mouse_right);
end;
procedure TEIOS_Exported_ReleaseMouse(target: pointer; x, y: integer;
left: boolean); stdcall;
begin
if left then
TTarget(Target).ReleaseMouse(x,y,mouse_left)
else
TTarget(Target).ReleaseMouse(x,y,mouse_right);
end;
procedure TEIOS_Exported_SendString(target: pointer; str: PChar); stdcall;
begin
TTarget(Target).SendString(str);
end;
procedure TEIOS_Exported_HoldKey(target: pointer; key: integer); stdcall;
begin
TTarget(Target).HoldKey(key);
end;
procedure TEIOS_Exported_ReleaseKey(target: pointer; key: integer); stdcall;
begin
TTarget(Target).ReleaseKey(key);
end;
function TEIOS_Exported_IsKeyHeld(target: pointer; key: integer): boolean;
stdcall;
begin
result := TTarget(Target).IsKeyHeld(key);
end;
function TEIOS_Exported_GetKeyCode(target: pointer; C: char): integer;
stdcall;
begin
result := TTarget(target).GetKeyCode(c);
end;
initialization
eios_controller:= TEIOS_Controller.Create;
finalization