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

Added various Set/Get target methods and a system where freeing targets is optional, but avaliable to those that might set lots of targets. All of a script's targets will be freed when the TIOManager is freed.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@476 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
BenLand100 2010-01-26 06:12:49 +00:00
parent 3fef7ac7ed
commit a0a89be1f2
6 changed files with 261 additions and 152 deletions

View File

@ -11,7 +11,7 @@
<Title Value="Simba"/> <Title Value="Simba"/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<Icon Value="0"/> <Icon Value="0"/>
<ActiveEditorIndexAtStart Value="10"/> <ActiveEditorIndexAtStart Value="5"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
@ -190,7 +190,7 @@
<UnitName Value="Client"/> <UnitName Value="Client"/>
<CursorPos X="15" Y="67"/> <CursorPos X="15" Y="67"/>
<TopLine Value="49"/> <TopLine Value="49"/>
<EditorIndex Value="7"/> <EditorIndex Value="8"/>
<UsageCount Value="201"/> <UsageCount Value="201"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit20> </Unit20>
@ -265,9 +265,9 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/> <Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/> <UnitName Value="mmlpsthread"/>
<CursorPos X="31" Y="260"/> <CursorPos X="61" Y="256"/>
<TopLine Value="243"/> <TopLine Value="331"/>
<EditorIndex Value="10"/> <EditorIndex Value="11"/>
<UsageCount Value="202"/> <UsageCount Value="202"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit30> </Unit30>
@ -349,7 +349,7 @@
<UnitName Value="bitmaps"/> <UnitName Value="bitmaps"/>
<CursorPos X="12" Y="93"/> <CursorPos X="12" Y="93"/>
<TopLine Value="83"/> <TopLine Value="83"/>
<EditorIndex Value="11"/> <EditorIndex Value="12"/>
<UsageCount Value="200"/> <UsageCount Value="200"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit42> </Unit42>
@ -495,8 +495,10 @@
<Unit64> <Unit64>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="90"/> <TopLine Value="95"/>
<EditorIndex Value="7"/>
<UsageCount Value="44"/> <UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit64> </Unit64>
<Unit65> <Unit65>
<Filename Value="../../Units/PascalScript/uPSCompiler.pas"/> <Filename Value="../../Units/PascalScript/uPSCompiler.pas"/>
@ -764,10 +766,10 @@
</Unit102> </Unit102>
<Unit103> <Unit103>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/window.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/Wrappers/window.inc"/>
<CursorPos X="12" Y="63"/> <CursorPos X="51" Y="34"/>
<TopLine Value="30"/> <TopLine Value="19"/>
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<UsageCount Value="16"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit103> </Unit103>
<Unit104> <Unit104>
@ -1540,7 +1542,7 @@
<CursorPos X="52" Y="609"/> <CursorPos X="52" Y="609"/>
<TopLine Value="585"/> <TopLine Value="585"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<UsageCount Value="37"/> <UsageCount Value="38"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit216> </Unit216>
<Unit217> <Unit217>
@ -1590,7 +1592,7 @@
<UnitName Value="framefunctionlist"/> <UnitName Value="framefunctionlist"/>
<CursorPos X="26" Y="295"/> <CursorPos X="26" Y="295"/>
<TopLine Value="7"/> <TopLine Value="7"/>
<UsageCount Value="182"/> <UsageCount Value="185"/>
</Unit223> </Unit223>
<Unit224> <Unit224>
<Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/> <Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/>
@ -1618,7 +1620,7 @@
<CursorPos X="59" Y="173"/> <CursorPos X="59" Y="173"/>
<TopLine Value="151"/> <TopLine Value="151"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="12"/> <UsageCount Value="13"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit227> </Unit227>
<Unit228> <Unit228>
@ -1647,7 +1649,7 @@
<UnitName Value="simpleanalyzer"/> <UnitName Value="simpleanalyzer"/>
<CursorPos X="52" Y="104"/> <CursorPos X="52" Y="104"/>
<TopLine Value="193"/> <TopLine Value="193"/>
<UsageCount Value="169"/> <UsageCount Value="172"/>
</Unit231> </Unit231>
<Unit232> <Unit232>
<Filename Value="../../Units/Misc/mPasLex.pas"/> <Filename Value="../../Units/Misc/mPasLex.pas"/>
@ -1705,10 +1707,10 @@
</Unit239> </Unit239>
<Unit240> <Unit240>
<Filename Value="../../Units/MMLAddon/PSInc/psexportedmethods.inc"/> <Filename Value="../../Units/MMLAddon/PSInc/psexportedmethods.inc"/>
<CursorPos X="40" Y="59"/> <CursorPos X="75" Y="68"/>
<TopLine Value="36"/> <TopLine Value="51"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<UsageCount Value="27"/> <UsageCount Value="28"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit240> </Unit240>
<Unit241> <Unit241>
@ -1724,7 +1726,7 @@
<UnitName Value="updater"/> <UnitName Value="updater"/>
<CursorPos X="38" Y="211"/> <CursorPos X="38" Y="211"/>
<TopLine Value="65"/> <TopLine Value="65"/>
<UsageCount Value="142"/> <UsageCount Value="145"/>
</Unit242> </Unit242>
<Unit243> <Unit243>
<Filename Value="updateform.pas"/> <Filename Value="updateform.pas"/>
@ -1735,7 +1737,7 @@
<ComponentState Value="1"/> <ComponentState Value="1"/>
<CursorPos X="111" Y="102"/> <CursorPos X="111" Y="102"/>
<TopLine Value="207"/> <TopLine Value="207"/>
<UsageCount Value="137"/> <UsageCount Value="140"/>
</Unit243> </Unit243>
<Unit244> <Unit244>
<Filename Value="../../../Documents/lazarus/lcl/fileutil.pas"/> <Filename Value="../../../Documents/lazarus/lcl/fileutil.pas"/>
@ -1856,7 +1858,7 @@
<UnitName Value="simbasettings"/> <UnitName Value="simbasettings"/>
<CursorPos X="26" Y="9"/> <CursorPos X="26" Y="9"/>
<TopLine Value="11"/> <TopLine Value="11"/>
<UsageCount Value="100"/> <UsageCount Value="103"/>
</Unit261> </Unit261>
<Unit262> <Unit262>
<Filename Value="../../Units/MMLAddon/settings.pas"/> <Filename Value="../../Units/MMLAddon/settings.pas"/>
@ -1894,7 +1896,7 @@
<UnitName Value="reportbug"/> <UnitName Value="reportbug"/>
<CursorPos X="53" Y="23"/> <CursorPos X="53" Y="23"/>
<TopLine Value="21"/> <TopLine Value="21"/>
<UsageCount Value="83"/> <UsageCount Value="86"/>
</Unit266> </Unit266>
<Unit267> <Unit267>
<Filename Value="../../Units/Synapse/synsock.pas"/> <Filename Value="../../Units/Synapse/synsock.pas"/>
@ -1951,7 +1953,7 @@
<UnitName Value="newinternets"/> <UnitName Value="newinternets"/>
<CursorPos X="37" Y="171"/> <CursorPos X="37" Y="171"/>
<TopLine Value="153"/> <TopLine Value="153"/>
<UsageCount Value="79"/> <UsageCount Value="82"/>
</Unit274> </Unit274>
<Unit275> <Unit275>
<Filename Value="reportbug.lrs"/> <Filename Value="reportbug.lrs"/>
@ -1997,19 +1999,19 @@
<Unit281> <Unit281>
<Filename Value="../../Units/MMLCore/iomanager.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<UnitName Value="IOManager"/> <UnitName Value="IOManager"/>
<CursorPos X="67" Y="53"/> <CursorPos X="53" Y="202"/>
<TopLine Value="34"/> <TopLine Value="194"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="30"/> <UsageCount Value="31"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit281> </Unit281>
<Unit282> <Unit282>
<Filename Value="../../Units/MMLCore/os_linux.pas"/> <Filename Value="../../Units/MMLCore/os_linux.pas"/>
<UnitName Value="os_linux"/> <UnitName Value="os_linux"/>
<CursorPos X="36" Y="69"/> <CursorPos X="48" Y="61"/>
<TopLine Value="56"/> <TopLine Value="45"/>
<EditorIndex Value="9"/> <EditorIndex Value="10"/>
<UsageCount Value="29"/> <UsageCount Value="30"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit282> </Unit282>
<Unit283> <Unit283>
@ -2022,10 +2024,10 @@
<Unit284> <Unit284>
<Filename Value="../../Units/MMLCore/os_windows.pas"/> <Filename Value="../../Units/MMLCore/os_windows.pas"/>
<UnitName Value="os_windows"/> <UnitName Value="os_windows"/>
<CursorPos X="22" Y="164"/> <CursorPos X="54" Y="348"/>
<TopLine Value="155"/> <TopLine Value="319"/>
<EditorIndex Value="12"/> <EditorIndex Value="13"/>
<UsageCount Value="25"/> <UsageCount Value="26"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit284> </Unit284>
<Unit285> <Unit285>
@ -2048,7 +2050,7 @@
<UnitName Value="libloader"/> <UnitName Value="libloader"/>
<CursorPos X="1" Y="149"/> <CursorPos X="1" Y="149"/>
<TopLine Value="128"/> <TopLine Value="128"/>
<UsageCount Value="37"/> <UsageCount Value="40"/>
</Unit287> </Unit287>
<Unit288> <Unit288>
<Filename Value="../../Units/MMLAddon/tpa.pas"/> <Filename Value="../../Units/MMLAddon/tpa.pas"/>
@ -2061,8 +2063,8 @@
<Filename Value="../../Units/PascalScript/x86.inc"/> <Filename Value="../../Units/PascalScript/x86.inc"/>
<CursorPos X="8" Y="157"/> <CursorPos X="8" Y="157"/>
<TopLine Value="140"/> <TopLine Value="140"/>
<EditorIndex Value="8"/> <EditorIndex Value="9"/>
<UsageCount Value="15"/> <UsageCount Value="16"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit289> </Unit289>
<Unit290> <Unit290>
@ -2084,127 +2086,131 @@
<CursorPos X="70" Y="1393"/> <CursorPos X="70" Y="1393"/>
<TopLine Value="1364"/> <TopLine Value="1364"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<UsageCount Value="12"/> <UsageCount Value="13"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit292> </Unit292>
</Units> </Units>
<JumpHistory Count="29" HistoryIndex="28"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/window.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="../../Units/PascalScript/x86.inc"/>
<Caret Line="592" Column="60" TopLine="584"/>
</Position2>
<Position3>
<Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="36" Column="17" TopLine="27"/>
</Position3>
<Position4>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<Caret Line="48" Column="50" TopLine="34"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="345" Column="27" TopLine="311"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<Caret Line="69" Column="36" TopLine="56"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="201" Column="29" TopLine="195"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/iomanager.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="372" Column="45" TopLine="348"/> <Caret Line="372" Column="45" TopLine="348"/>
</Position8> </Position1>
<Position9> <Position2>
<Filename Value="../../Units/MMLCore/iomanager.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="202" Column="29" TopLine="177"/> <Caret Line="202" Column="29" TopLine="177"/>
</Position9> </Position2>
<Position10> <Position3>
<Filename Value="../../Units/MMLCore/iomanager.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="346" Column="59" TopLine="328"/> <Caret Line="346" Column="59" TopLine="328"/>
</Position10> </Position3>
<Position11> <Position4>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="47" Column="34" TopLine="34"/> <Caret Line="47" Column="34" TopLine="34"/>
</Position11> </Position4>
<Position12> <Position5>
<Filename Value="../../Units/MMLCore/tpa.pas"/> <Filename Value="../../Units/MMLCore/tpa.pas"/>
<Caret Line="76" Column="21" TopLine="58"/> <Caret Line="76" Column="21" TopLine="58"/>
</Position12> </Position5>
<Position13> <Position6>
<Filename Value="../../Units/MMLCore/tpa.pas"/> <Filename Value="../../Units/MMLCore/tpa.pas"/>
<Caret Line="77" Column="21" TopLine="58"/> <Caret Line="77" Column="21" TopLine="58"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="31" Column="54" TopLine="23"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="85" Column="37" TopLine="69"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="25" Column="12" TopLine="12"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="26" Column="12" TopLine="12"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/>
<Caret Line="20" Column="13" TopLine="12"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="656" Column="23" TopLine="625"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLCore/fontloader.pas"/>
<Caret Line="63" Column="34" TopLine="37"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="31" Column="54" TopLine="23"/> <Caret Line="710" Column="61" TopLine="692"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="85" Column="37" TopLine="69"/> <Caret Line="55" Column="42" TopLine="37"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="25" Column="12" TopLine="12"/> <Caret Line="714" Column="22" TopLine="692"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/> <Filename Value="../../Units/MMLCore/fontloader.pas"/>
<Caret Line="26" Column="12" TopLine="12"/> <Caret Line="55" Column="29" TopLine="37"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="../../Units/MMLCore/ocrutil.pas"/> <Filename Value="../../Units/MMLCore/fontloader.pas"/>
<Caret Line="20" Column="13" TopLine="12"/> <Caret Line="79" Column="10" TopLine="61"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="656" Column="23" TopLine="625"/> <Caret Line="729" Column="26" TopLine="702"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="../../Units/MMLCore/fontloader.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="63" Column="34" TopLine="37"/> <Caret Line="712" Column="8" TopLine="703"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="710" Column="61" TopLine="692"/> <Caret Line="721" Column="23" TopLine="703"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/ocr.pas"/>
<Caret Line="55" Column="42" TopLine="37"/> <Caret Line="751" Column="10" TopLine="720"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="714" Column="22" TopLine="692"/> <Caret Line="233" Column="29" TopLine="438"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="../../Units/MMLCore/fontloader.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="55" Column="29" TopLine="37"/> <Caret Line="299" Column="27" TopLine="249"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="../../Units/MMLCore/fontloader.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="79" Column="10" TopLine="61"/> <Caret Line="294" Column="30" TopLine="282"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="729" Column="26" TopLine="702"/> <Caret Line="317" Column="30" TopLine="302"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="712" Column="8" TopLine="703"/> <Caret Line="249" Column="58" TopLine="230"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLCore/iomanager.pas"/>
<Caret Line="721" Column="23" TopLine="703"/> <Caret Line="354" Column="12" TopLine="331"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="../../Units/MMLCore/ocr.pas"/> <Filename Value="../../Units/MMLAddon/PSInc/psexportedmethods.inc"/>
<Caret Line="751" Column="10" TopLine="720"/> <Caret Line="14" Column="58" TopLine="1"/>
</Position29> </Position29>
<Position30>
<Filename Value="../../Units/MMLAddon/PSInc/psexportedmethods.inc"/>
<Caret Line="24" Column="102" TopLine="12"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@ -26,14 +26,44 @@ begin;
CurrThread.Client.IOManager.SetDesktop; CurrThread.Client.IOManager.SetDesktop;
end; end;
procedure SetTargetArray(P: Integer; w, h: integer); function SetTargetArray(P: Integer; w, h: integer): integer;
begin begin
CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h)); result:= CurrThread.Client.IOManager.SetTarget(PRGB32(P), classes.point(w,h));
end; end;
procedure SetTargetBitmap(bitmap: Integer); function SetTargetBitmap(bitmap: Integer): integer;
begin; begin;
CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]); result:= CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]);
end;
function SetEIOSTarget(name: string; args: Variant): integer;
begin
result:= CurrThread.Client.IOManager.SetTarget(name, @args);
end;
procedure SetImageTarget(idx: integer);
begin
CurrThread.Client.IOManager.SetImageTarget(idx);
end;
procedure SetKeyMouseTarget(idx: integer);
begin
CurrThread.Client.IOManager.SetKeyMouseTarget(idx);
end;
function GetImageTarget: integer;
begin
CurrThread.Client.IOManager.GetImageTarget(result);
end;
function GetKeyMouseTarget: integer;
begin
CurrThread.Client.IOManager.GetKeyMouseTarget(result);
end;
procedure FreeTarget(idx: integer);
begin
CurrThread.Client.IOManager.FreeTarget(idx);
end; end;
procedure GetClientDimensions(out w, h: integer); procedure GetClientDimensions(out w, h: integer);

View File

@ -63,9 +63,15 @@ SetCurrSection('Window');
AddFunction(@Freeze, 'function Freeze: boolean;'); AddFunction(@Freeze, 'function Freeze: boolean;');
AddFunction(@Unfreeze, 'function Unfreeze: boolean;'); AddFunction(@Unfreeze, 'function Unfreeze: boolean;');
AddFunction(@GetClientDimensions, 'procedure GetClientDimensions(var w, h:integer);'); AddFunction(@GetClientDimensions, 'procedure GetClientDimensions(var w, h:integer);');
AddFunction(@SetTargetBitmap,'procedure SetTargetBitmap(Bitmap : integer);'); AddFunction(@SetTargetBitmap,'function SetTargetBitmap(Bitmap : integer): integer;');
AddFunction(@SetTargetArray, 'function SetTargetArray(P: Integer; w, h: integer): integer;');
AddFunction(@SetEIOSTarget, 'function SetEIOSTarget(name: string; initargs: Variant): integer;');
AddFunction(@SetImageTarget,'procedure SetImageTarget(idx: integer);');
AddFunction(@SetKeyMouseTarget,'procedure SetKeyMouseTarget(idx: integer);');
AddFunction(@GetImageTarget,'function GetImageTarget: integer;');
AddFunction(@GetKeyMouseTarget,'function GetKeyMouseTarget: integer;');
AddFunction(@FreeTarget,'procedure FreeTarget(idx: integer);');
AddFunction(@SetDesktopAsClient,'procedure SetDesktopAsClient'); AddFunction(@SetDesktopAsClient,'procedure SetDesktopAsClient');
AddFunction(@SetTargetArray, 'procedure SetTargetArray(P: Integer; w, h: integer);');
AddFunction(@ActivateClient, 'procedure ActivateClient;'); AddFunction(@ActivateClient, 'procedure ActivateClient;');
AddFunction(@IsTargetValid, 'function IsTargetValid: boolean;'); AddFunction(@IsTargetValid, 'function IsTargetValid: boolean;');

View File

@ -223,21 +223,33 @@ interface
procedure SendText(text: string); procedure SendText(text: string);
function isKeyDown(key: Word): Boolean; function isKeyDown(key: Word): Boolean;
function GetImageTarget: TTarget; function GetImageTarget: TTarget; overload;
function GetKeyMouseTarget: TTarget; overload;
procedure GetImageTarget(var idx: integer); overload;
procedure GetKeyMouseTarget(var idx: integer); overload;
procedure SetImageTarget(idx: integer);
procedure SetKeyMouseTarget(idx: integer);
procedure FreeTarget(idx: integer);
protected protected
function SetImageTarget(target: TTarget): integer;
function SetKeyMouseTarget(target: TTarget): integer;
function SetBothTargets(target: TTarget): integer;
procedure NativeInit; virtual; abstract;
procedure NativeFree; virtual; abstract;
private
keymouse: TTarget; keymouse: TTarget;
image: TTarget; image: TTarget;
frozen: TTarget; frozen: TTarget;
freezebuffer: prgb32; freezebuffer: prgb32;
bothsame: boolean; bothsame: boolean;
procedure SetImageTarget(target: TTarget); idxarr: array of TTarget;
procedure SetKeyMouseTarget(target: TTarget); function GetTargetIdx(target: TTarget): integer;
procedure SetBothTargets(target: TTarget); function GetIdxTarget(idx: integer): TTarget;
procedure NativeInit; virtual; abstract;
procedure NativeFree; virtual; abstract;
end; end;
implementation implementation
@ -253,16 +265,13 @@ implementation
constructor TIOManager_Abstract.Create(plugin_dir: string); constructor TIOManager_Abstract.Create(plugin_dir: string);
begin begin
inherited Create; inherited Create;
SetLength(idxarr,0);
eios_controller.AddPath(plugin_dir); eios_controller.AddPath(plugin_dir);
keymouse:= nil; keymouse:= nil;
image:= nil; image:= nil;
frozen:= nil; frozen:= nil;
NativeInit; NativeInit;
SetDesktop; SetDesktop;
{
self.create;
eios_controller.AddAndLoadPath(plugin_dir);
}
end; end;
constructor TIOManager_Abstract.Create; constructor TIOManager_Abstract.Create;
@ -276,22 +285,61 @@ begin
end; end;
destructor TIOManager_Abstract.Destroy; destructor TIOManager_Abstract.Destroy;
var
i: integer;
begin begin
if bothsame then keymouse.Destroy() else for i:= high(idxarr) downto 0 do
begin idxarr[i].Free;
keymouse.Free();
image.Free();
end;
if IsFrozen then frozen.Destroy();
end; end;
procedure TIOManager_Abstract.SetImageTarget(target: TTarget); procedure TIOManager_Abstract.FreeTarget(idx: integer);
begin
if idx > high(idxarr) then
raise Exception.Create('Invalid target index');
if idxarr[idx] = nil then
raise Exception.Create('Double free of target');
idxarr[idx].Free;
idxarr[idx]:= nil;
end;
function TIOManager_Abstract.GetTargetIdx(target: TTarget): integer;
var
i: integer;
begin
result:= -1;
for i:= 0 to high(idxarr) do
begin
if idxarr[i] = target then
begin
result:= i;
exit;
end;
if (idxarr[i] = nil) and (result = -1) then
result:= i;
end;
if result = -1 then
begin
SetLength(idxarr,Length(idxarr) + 1);
result:= high(idxarr);
end;
idxarr[result]:= target;
end;
function TIOManager_Abstract.GetIdxTarget(idx: integer): TTarget;
begin
if idx > high(idxarr) then
raise Exception.Create('Invalid target index');
if idxarr[idx] = nil then
raise Exception.Create('No target with specified index');
result:= idxarr[idx];
end;
function TIOManager_Abstract.SetImageTarget(target: TTarget): integer;
begin begin
if IsFrozen then if IsFrozen then
raise Exception.Create('You cannot set a target when Frozen'); raise Exception.Create('You cannot set a target when Frozen');
if not(bothsame) then image.Free(); result:= GetTargetIdx(target);
image:= target; image:= target;
bothsame:= false;
end; end;
function TIOManager_Abstract.GetImageTarget: TTarget; function TIOManager_Abstract.GetImageTarget: TTarget;
@ -299,24 +347,24 @@ begin
result := image; result := image;
end; end;
procedure TIOManager_Abstract.SetKeyMouseTarget(target: TTarget); function TIOManager_Abstract.SetKeyMouseTarget(target: TTarget): integer;
begin begin
if not(bothsame) then keymouse.Free(); result:= GetTargetIdx(target);
keymouse:= target; keymouse:= target;
bothsame:= false;
end; end;
procedure TIOManager_Abstract.SetBothTargets(target: TTarget);
function TIOManager_Abstract.GetKeyMouseTarget: TTarget;
begin
result := keymouse;
end;
function TIOManager_Abstract.SetBothTargets(target: TTarget): integer;
begin begin
if IsFrozen then if IsFrozen then
raise Exception.Create('You cannot set a target when Frozen'); raise Exception.Create('You cannot set a target when Frozen');
if bothsame then image.Destroy() else result:= GetTargetIdx(target);
begin
image.Free();
keymouse.Free();
end;
image:= target; image:= target;
keymouse:= target; keymouse:= target;
bothsame:= true;
end; end;
procedure TIOManager_Abstract.SetFrozen(makefrozen: boolean); procedure TIOManager_Abstract.SetFrozen(makefrozen: boolean);
@ -326,9 +374,6 @@ var
begin begin
if (makefrozen) and (IsFrozen) then if (makefrozen) and (IsFrozen) then
raise Exception.Create('The window is already frozen.'); raise Exception.Create('The window is already frozen.');
//BenLand100 edit: I say we leave this exception out. POLS
//if not(isfrozen) and (frozen = nil) then
// raise Exception.Create('The window is not frozen.');
if makefrozen then //No need for the Frozen = nil check, already done above with the exception. if makefrozen then //No need for the Frozen = nil check, already done above with the exception.
begin begin
frozen:= image; frozen:= image;
@ -364,11 +409,11 @@ end;
function TIOManager_Abstract.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; function TIOManager_Abstract.SetTarget(ArrPtr: PRGB32; Size: TPoint): integer;
begin begin
SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y)); result:= SetImageTarget(TRawTarget.Create(ArrPtr,Size.X,Size.Y));
end; end;
function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer; function TIOManager_Abstract.SetTarget(bmp : TMufasaBitmap) : integer;
begin begin
SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height)); result:= SetImageTarget(TRawTarget.Create(bmp.FData,bmp.width,bmp.height));
end; end;
function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer; function TIOManager_Abstract.SetTarget(name: string; initargs: pointer): integer;
@ -378,7 +423,29 @@ begin
if not eios_controller.ClientExists(name) then if not eios_controller.ClientExists(name) then
raise Exception.Create('EIOS Client by specified name does not exist'); raise Exception.Create('EIOS Client by specified name does not exist');
client:= eios_controller.GetClient(name); client:= eios_controller.GetClient(name);
SetBothTargets(TEIOS_Target.Create(client, initargs)); result:= SetBothTargets(TEIOS_Target.Create(client, initargs));
end;
procedure TIOManager_Abstract.SetImageTarget(idx: integer);
begin
image:= GetIdxTarget(idx);
end;
procedure TIOManager_Abstract.SetKeyMouseTarget(idx: integer);
begin
keymouse:= GetIdxTarget(idx);
end;
procedure TIOManager_Abstract.GetImageTarget(var idx: integer);
begin
if IsFrozen then
raise Exception.Create('Cannot get image target while frozen');
idx:= GetTargetIdx(image);
end;
procedure TIOManager_Abstract.GetKeyMouseTarget(var idx: integer);
begin
idx:= GetTargetIdx(keymouse);
end; end;
function TIOManager_Abstract.TargetValid: Boolean; function TIOManager_Abstract.TargetValid: Boolean;

View File

@ -58,7 +58,7 @@ interface
procedure ReleaseKey(key: integer); override; procedure ReleaseKey(key: integer); override;
function IsKeyHeld(key: integer): boolean; override; function IsKeyHeld(key: integer): boolean; override;
function GetNativeWindow: x.TWindow; function GetNativeWindow: TNativeWindow;
private private
display: PDisplay; display: PDisplay;
screennum: integer; screennum: integer;
@ -134,7 +134,7 @@ implementation
inherited Destroy; inherited Destroy;
end; end;
function TWindow.GetNativeWindow: x.TWindow; function TWindow.GetNativeWindow: TNativeWindow;
begin begin
result := self.window; result := self.window;
end; end;

View File

@ -59,7 +59,7 @@ interface
procedure ReleaseKey(key: integer); override; procedure ReleaseKey(key: integer); override;
function IsKeyHeld(key: integer): boolean; override; function IsKeyHeld(key: integer): boolean; override;
function GetNativeWindow: Hwnd; function GetNativeWindow: TNativeWindow;
private private
handle: Hwnd; handle: Hwnd;
dc: HDC; dc: HDC;
@ -74,7 +74,7 @@ interface
public public
constructor Create; constructor Create;
constructor Create(plugin_dir: string); constructor Create(plugin_dir: string);
function SetTarget(target: Hwnd): integer; overload; function SetTarget(target: TNativeWindow): integer; overload;
procedure SetDesktop; override; procedure SetDesktop; override;
protected protected
DesktopHWND : Hwnd; DesktopHWND : Hwnd;
@ -162,7 +162,7 @@ implementation
inherited Destroy; inherited Destroy;
end; end;
function TWindow.GetNativeWindow: Hwnd; function TWindow.GetNativeWindow: TNativeWindow;
begin begin
result := handle; result := handle;
end; end;
@ -345,7 +345,7 @@ implementation
SetBothTargets(TWindow.Create(DesktopHWND)); SetBothTargets(TWindow.Create(DesktopHWND));
end; end;
function TIOManager.SetTarget(target: Hwnd): integer; function TIOManager.SetTarget(target: TNativeWindow): integer;
begin begin
SetBothTargets(TWindow.Create(target)); SetBothTargets(TWindow.Create(target));
end; end;