1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-03-03 10:51:49 -05:00

Tried to got DTM editor working as extension, but it still needs a lot of work.

This commit is contained in:
Niels 2010-05-20 10:08:54 +02:00
parent 363e7d394f
commit 0acdef9d72
13 changed files with 1668 additions and 167 deletions

1349
Extensions/dtm_editor.sex Normal file

File diff suppressed because it is too large Load Diff

View File

@ -370,7 +370,7 @@ begin
end; end;
if (Data <> nil) then //If showing automatically if (Data <> nil) then //If showing automatically
if (s <> '') and (((mp.DeclarationAtPos <> nil) and (mp.DeclarationAtPos is TciCompoundStatement)) or ((mp.DeclarationAtPos.Owner <> nil) and (mp.DeclarationAtPos.Owner is TciCompoundStatement))) then if (s <> '') and ((mp.DeclarationAtPos <> nil) and ((mp.DeclarationAtPos is TciCompoundStatement) or mp.DeclarationAtPos.HasOwnerClass(TciCompoundStatement, d, True))) then
Data := nil; Data := nil;
if (Data = nil) then if (Data = nil) then

View File

@ -5,8 +5,9 @@ unit psextension;
interface interface
uses uses
Classes, SysUtils,mufasabase, virtualextension, MufasaTypes, Classes, SysUtils, virtualextension, forms, client, uPSComponent,uPSCompiler,
uPSComponent,uPSCompiler, uPSRuntime, uPSPreProcessor,forms; uPSRuntime, stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties, settingssandbox;
@ -35,7 +36,7 @@ type
protected protected
procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler); procedure RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter); procedure RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
procedure RegisterMyMethods(Sender: TPSScript); procedure RegisterMyMethods(x: TPSScript);
procedure OnPSExecute(Sender: TPSScript); procedure OnPSExecute(Sender: TPSScript);
procedure SetEnabled(bool : boolean);override; procedure SetEnabled(bool : boolean);override;
end; end;
@ -43,12 +44,48 @@ type
implementation implementation
uses uses
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms, colour_conv,dtmutil,
uPSC_extctrls,uPSC_menus, uPSC_mml, //Compile libs {$ifdef mswindows}windows, MMSystem,{$endif}//MMSystem -> Sounds
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms, uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms, uPSC_menus,
uPSR_extctrls,uPSR_menus, uPSR_mml, //Runtime-libs uPSC_extctrls, uPSC_mml, //Compile-libs
SimbaUnit,updateform,settingssandbox,bitmaps,files,Dialogs, mmisc//Writeln uPSUtils,
; fontloader,
IOmanager,//TTarget_Exported
IniFiles,//Silly INI files
stringutil, //String st00f
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms, uPSR_mml,
uPSR_menus, uPSI_ComCtrls, uPSI_Dialogs,
files,
dialogs,
dtm, //Dtms!
uPSR_extctrls, //Runtime-libs
Graphics, //For Graphics types
math, //Maths!
mmath, //Real maths!
strutils,
fileutil,
tpa, //Tpa stuff
SynRegExpr,
lclintf,
SimbaUnit,updateform, mmisc, mmlpsthread; // for GetTickCount and others.//Writeln
{$ifdef Linux}
{$define PS_SafeCall}
{$else}
//{$define PS_SafeCall}
{$endif}
{$MACRO ON}
{$ifdef PS_SafeCall}
{$define extdecl := safecall}
{$else}
{$define extdecl := register}
{$endif}
procedure psWriteLn(s: string);
begin
formWritelnEx(s);
end;
function TSimbaPSExtension.HookExists(const HookName: String): Boolean; function TSimbaPSExtension.HookExists(const HookName: String): Boolean;
begin begin
@ -68,7 +105,7 @@ begin
result := SExt_ok; result := SExt_ok;
except except
on e : exception do on e : exception do
formWritelnEx(format('Error in Simba extension (%s): %s',[Self.GetName,e.message])); //formWritelnEx(format('Error in Simba extension (%s): %s',[Self.GetName,e.message]));
end; end;
end; end;
@ -111,35 +148,63 @@ begin
result := ExecuteHook('Free',Args,bla) = SExt_ok; result := ExecuteHook('Free',Args,bla) = SExt_ok;
end; end;
{$I ../../Units/MMLAddon/PSInc/Wrappers/extensions.inc} {$DEFINE MML_EXPORT_THREADSAFE}
{$I Wrappers/other.inc}
{$I Wrappers/settings.inc}
{$I Wrappers/bitmap.inc}
{$I Wrappers/window.inc}
{$I Wrappers/tpa.inc}
{$I Wrappers/strings.inc}
{$I Wrappers/colour.inc}
{$I Wrappers/colourconv.inc}
{$I Wrappers/math.inc}
{$I Wrappers/mouse.inc}
{$I Wrappers/file.inc}
{$I Wrappers/keyboard.inc}
{$I Wrappers/dtm.inc}
{$I Wrappers/ocr.inc}
{$I Wrappers/internets.inc}
{$I Wrappers/extensions.inc}
procedure TSimbaPSExtension.RegisterMyMethods(Sender: TPSScript); procedure TSimbaPSExtension.RegisterMyMethods(x: TPSScript);
procedure SetCurrSection(s: string);
begin
end;
var
AppPath, ScriptPath: string;
i: Integer;
begin begin
Sender.Comp.AddTypes('TStringArray','Array of String'); AppPath := MainDir + DirectorySeparator;
Sender.Comp.AddConstantN('AppPath','string').SetString(MainDir + DirectorySeparator); ScriptPath := ExtractFileDir(Filename);
Sender.Comp.AddConstantN('IncludePath','string').SetString(SimbaForm.IncludePath);
Sender.Comp.AddConstantN('PluginPath','string').SetString(SimbaForm.PluginPath); with SimbaForm, x do
Sender.Comp.AddConstantN('FontPath','string').SetString(SimbaForm.FontPath); begin
Sender.Comp.AddConstantN('ExtPath','string').SetString(SimbaForm.ExtPath); with Comp do
Sender.Comp.AddTypeS('TMsgDlgType', '( mtWarning, mtError, mtInformation, mtConfirmati' begin
+'on, mtCustom )'); {$I ../../Units/MMLAddon/PSInc/pscompile.inc}
Sender.Comp.AddTypeS('TMsgDlgBtn', '( mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, m' AddTypes('TStringArray','Array of String');
+'bIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp )'); AddConstantN('ExtPath','string').SetString(ExtPath);
Sender.Comp.AddTypeS('TMsgDlgButtons', 'set of TMsgDlgBtn'); AddTypeS('TMsgDlgType', '( mtWarning, mtError, mtInformation, mtConfirmation, mtCustom )');
Sender.AddFunction(@formWritelnEx,'procedure Writeln(s : string)'); AddTypeS('TMsgDlgBtn', '( mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp )');
Sender.AddFunction(@ext_GetPage,'function GetPage(const url : string) : string'); AddTypeS('TMsgDlgButtons', 'set of TMsgDlgBtn');
Sender.AddFunction(@ext_DecompressBZip2,'function DecompressBZip2(const input: string;out output : string; const BlockSize: Cardinal): boolean;');
Sender.AddFunction(@ext_UnTar,'function UnTar(const Input : string; out Content : TStringArray) : boolean;'); for i := 0 to high(VirtualKeys) do
Sender.AddFunction(@ext_UnTarEx,'function UnTarEx(const Input : string;const outputdir : string; overwrite : boolean): boolean;'); AddConstantN(Format('VK_%S',[VirtualKeys[i].Str]),'Byte').SetInt(VirtualKeys[i].Key);
Sender.AddFunction(@DirectoryExists,'Function DirectoryExists (Const Directory : String) : Boolean;'); end;
Sender.AddFunction(@FileExists,'Function FileExists (Const FileName : String) : Boolean;');
Sender.AddFunction(@ForceDirectories,'function ForceDirectories(Const Dir: string): Boolean;'); {$i ../../Units/MMLAddon/PSInc/psexportedmethods.inc}
Sender.AddFunction(@GetFiles, 'function GetFiles(Path, Ext: string): TStringArray;');
Sender.AddFunction(@GetDirectories,'function GetDirectories(Path: string): TstringArray;'); AddFunction(@ext_GetPage,'function GetPage(const url : string) : string');
Sender.AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;'); AddFunction(@ext_DecompressBZip2,'function DecompressBZip2(const input: string;out output : string; const BlockSize: Cardinal): boolean;');
Sender.AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox'); AddFunction(@ext_UnTar,'function UnTar(const Input : string; out Content : TStringArray) : boolean;');
Sender.AddRegisteredVariable('Simba','TForm'); AddFunction(@ext_UnTarEx,'function UnTarEx(const Input : string;const outputdir : string; overwrite : boolean): boolean;');
Sender.AddRegisteredVariable('Simba_MainMenu','TMainMenu'); AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;');
AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox');
AddRegisteredVariable('Simba','TForm');
AddRegisteredVariable('Simba_MainMenu','TMainMenu');
end;
end; end;
procedure TSimbaPSExtension.OnPSExecute(Sender: TPSScript); procedure TSimbaPSExtension.OnPSExecute(Sender: TPSScript);
@ -183,14 +248,42 @@ end;
procedure TSimbaPSExtension.RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler); procedure TSimbaPSExtension.RegisterPSCComponents(Sender: TObject; x: TPSPascalCompiler);
begin begin
SIRegister_Std(x); SIRegister_Std(x);
SIRegister_Classes(x, True);
SIRegister_Controls(x); SIRegister_Controls(x);
SIRegister_Graphics(x, True); SIRegister_Classes(x, true);
SIRegister_Graphics(x, true);
SIRegister_stdctrls(x); SIRegister_stdctrls(x);
SIRegister_Forms(x); SIRegister_Forms(x);
SIRegister_ExtCtrls(x); SIRegister_ExtCtrls(x);
SIRegister_Menus(x); SIRegister_Menus(x);
SIRegister_ComCtrls(x);
SIRegister_Dialogs(x);
SIRegister_MML(x); SIRegister_MML(x);
with x.AddFunction('procedure writeln;').decl do
with AddParam do
begin
OrgName:= 'x';
Mode:= pmIn;
end;
with x.AddFunction('function ToStr:string').decl do
with addparam do
begin
OrgName:= 'x';
Mode:= pmIn;
end;
with x.AddFunction('procedure swap;').decl do
begin
with addparam do
begin
OrgName:= 'x';
Mode:= pmInOut;
end;
with addparam do
begin
OrgName:= 'y';
Mode:= pmInOut;
end;
end;
end; end;
procedure TSimbaPSExtension.RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter); procedure TSimbaPSExtension.RegisterPSRComponents(Sender: TObject; se: TPSExec; x: TPSRuntimeClassImporter);
@ -203,9 +296,17 @@ begin
RIRegister_Forms(x); RIRegister_Forms(x);
RIRegister_ExtCtrls(x); RIRegister_ExtCtrls(x);
RIRegister_Menus(x); RIRegister_Menus(x);
RIRegister_ComCtrls(x);
RIRegister_Dialogs(x);
RIRegister_MML(x); RIRegister_MML(x);
with x.FindClass('TMufasaBitmap') do with x.FindClass('TMufasaBitmap') do
begin
RegisterMethod(@TMufasaBitmapCopyClientToBitmap,'CopyClientToBitmap'); RegisterMethod(@TMufasaBitmapCopyClientToBitmap,'CopyClientToBitmap');
end;
se.RegisterFunctionName('WRITELN',@Writeln_,nil,nil);
se.RegisterFunctionName('TOSTR',@ToStr_,nil,nil);
se.RegisterFunctionName('SWAP',@swap_,nil,nil);
end; end;
destructor TSimbaPSExtension.Destroy; destructor TSimbaPSExtension.Destroy;
@ -223,6 +324,11 @@ begin
{ Create script, and see if the extension is valid. (If it compiles) } { Create script, and see if the extension is valid. (If it compiles) }
PSInstance := TPSScript.Create(nil); PSInstance := TPSScript.Create(nil);
with PSInstance do
begin
{$I ../../Units/MMLAddon/PSInc/psdefines.inc}
end;
PSInstance.Script := Self.Script; PSInstance.Script := Self.Script;
PSInstance.OnCompImport:=@RegisterPSCComponents; PSInstance.OnCompImport:=@RegisterPSCComponents;
PSInstance.OnExecImport:=@RegisterPSRComponents; PSInstance.OnExecImport:=@RegisterPSRComponents;

View File

@ -21,10 +21,6 @@
Mouse.inc for the Mufasa Macro Library Mouse.inc for the Mufasa Macro Library
} }
const
ps_mouse_right = 0;
ps_mouse_left = 1;
ps_mouse_middle = 2;
procedure ps_MoveMouse(x, y: integer); extdecl; procedure ps_MoveMouse(x, y: integer); extdecl;
begin begin
CurrThread.Client.IOManager.MoveMouse(X, Y); CurrThread.Client.IOManager.MoveMouse(X, Y);

View File

@ -21,6 +21,56 @@
Other.inc for the Mufasa Macro Library Other.inc for the Mufasa Macro Library
} }
function MakeString(data : TPSVariantIFC) : string;
begin;
if data.Dta = nil then
result := 'Nil'
else
if data.aType.basetype in [btString,btChar] then
result := PSGetAnsiString(Data.Dta,data.aType)
else if data.aType.ExportName = 'BOOLEAN' then
result := BoolToStr(PSGetInt(Data.Dta,data.aType) <> 0,true)
else
result := PSVariantToString(data,'');
end;
function writeln_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
begin
Result:=true;
psWriteln(makeString(NewTPSVariantIFC(Stack[Stack.Count-1],false)));
end;
function swap_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
var
Param1,Param2: TPSVariantIFC;
tempCopy : pointer;
begin
Result:=true;
Param1 := NewTPSVariantIFC(Stack[Stack.count-1],true);
Param2 := NewTPSVariantIFC(Stack[Stack.count-2],true);
if Param1.aType.BaseType <> Param2.aType.BaseType then
exit(false)
else
begin
Param1.aType.CalcSize;
param2.aType.CalcSize;
if Param1.aType.RealSize <> Param2.aType.RealSize then
exit(false);
GetMem(tempcopy,Param1.aType.RealSize);
Move(Param1.Dta^,tempCopy^,param1.atype.realsize);
Move(Param2.Dta^,Param1.Dta^,param1.atype.realsize);
Move(tempCopy^,Param2.Dta^,param1.atype.realsize);
Freemem(tempcopy);
end;
end;
function ToStr_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
begin
result := true;
Stack.SetAnsiString(-1, MakeString(NewTPSVariantIFC(Stack[Stack.Count-2],false)));
end;
{$IFNDEF MML_EXPORT_THREADSAFE}
function ps_SetScriptProp(prop : TSP_Property; Value: TVariantArray): boolean; extdecl; function ps_SetScriptProp(prop : TSP_Property; Value: TVariantArray): boolean; extdecl;
begin begin
Exit(CurrThread.Prop.SetProp(prop, Value)); Exit(CurrThread.Prop.SetProp(prop, Value));
@ -30,6 +80,7 @@ function ps_GetScriptProp(prop : TSP_Property; var Value : TVariantArray) : bool
begin; begin;
exit(CurrThread.Prop.GetProp(prop,value)); exit(CurrThread.Prop.GetProp(prop,value));
end; end;
{$ENDIF}
procedure ps_Wait(t: Integer); extdecl; procedure ps_Wait(t: Integer); extdecl;
{$ifdef MSWINDOWS} {$ifdef MSWINDOWS}
@ -70,6 +121,7 @@ begin
{$endif} {$endif}
end; end;
{$IFNDEF MML_EXPORT_THREADSAFE}
procedure ps_ClearDebug; extdecl; procedure ps_ClearDebug; extdecl;
begin begin
if Assigned(CurrThread.DebugClear) then if Assigned(CurrThread.DebugClear) then
@ -122,6 +174,7 @@ function ps_GetTimeRunning: LongWord; extdecl;
begin; begin;
result := GetTickCount - CurrThread.StartTime; result := GetTickCount - CurrThread.StartTime;
end; end;
{$ENDIF}
procedure ps_ConvertTime(Time : integer; var h,m,s : integer); extdecl; procedure ps_ConvertTime(Time : integer; var h,m,s : integer); extdecl;
var var
@ -174,6 +227,7 @@ begin
result := Random(int); result := Random(int);
end; end;
{$IFNDEF MML_EXPORT_THREADSAFE}
function ps_InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;extdecl; function ps_InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;extdecl;
begin begin
CurrThread.InputQueryData.ACaption:= ACaption; CurrThread.InputQueryData.ACaption:= ACaption;
@ -183,3 +237,4 @@ begin
Value := CurrThread.InputQueryData.Value; Value := CurrThread.InputQueryData.Value;
result := CurrThread.InputQueryData.Res; result := CurrThread.InputQueryData.Res;
end; end;
{$ENDIF}

View File

@ -21,47 +21,46 @@
PSCompile.inc for the Mufasa Macro Library PSCompile.inc for the Mufasa Macro Library
} }
x.AddConstantN('AppPath','string').SetString(Self.AppPath); AddConstantN('AppPath','string').SetString(AppPath);
x.AddConstantN('ScriptPath','string').SetString(Self.ScriptPath); AddConstantN('ScriptPath','string').SetString(ScriptPath);
x.AddConstantN('IncludePath','string').SetString(Self.IncludePath); AddConstantN('IncludePath','string').SetString(IncludePath);
x.AddConstantN('PluginPath','string').SetString(Self.PluginPath); AddConstantN('PluginPath','string').SetString(PluginPath);
x.AddConstantN('FontPath','string').SetString(Self.FontPath); AddConstantN('FontPath','string').SetString(FontPath);
x.AddConstantN('MaxLongInt','integer').SetInt(maxLongint); AddConstantN('MaxLongInt','integer').SetInt(maxLongint);
x.AddConstantN('MaxInt','integer').SetInt(maxLongint); AddConstantN('MaxInt','integer').SetInt(maxLongint);
x.AddTypeS('TReplaceFlag', '(rfReplaceAll, rfIgnoreCase)'); AddTypeS('TReplaceFlag', '(rfReplaceAll, rfIgnoreCase)');
x.AddTypeS('TReplaceFlags','set of TReplaceFlag'); AddTypeS('TReplaceFlags','set of TReplaceFlag');
x.AddTypeS('StrExtr','(Numbers, Letters, Others);'); AddTypeS('StrExtr','(Numbers, Letters, Others);');
x.AddTypeS('TDateTime','Double'); AddTypeS('TDateTime','Double');
x.AddTypeS('TIntegerArray', 'Array of LongInt'); AddTypeS('TIntegerArray', 'Array of LongInt');
x.AddTypeS('TByteArray','Array of byte'); AddTypeS('TByteArray','Array of byte');
x.AddTypeS('TExtendedArray','Array of extended'); AddTypeS('TExtendedArray','Array of extended');
x.AddTypeS('TBoolArray', 'Array of Boolean'); AddTypeS('TBoolArray', 'Array of Boolean');
x.AddTypes('TBox', 'record X1,Y1,X2,Y2 : Integer; end;'); AddTypes('TBox', 'record X1,Y1,X2,Y2 : Integer; end;');
x.AddTypeS('TBoxArray','Array of TBox'); AddTypeS('TBoxArray','Array of TBox');
x.AddTypeS('TPointArray','Array of TPoint'); AddTypeS('TPointArray','Array of TPoint');
x.AddTypeS('T2DPointArray','Array of TPointArray'); AddTypeS('T2DPointArray','Array of TPointArray');
x.AddTypeS('TPointArrayArray','Array of TPointArray'); AddTypeS('TPointArrayArray','Array of TPointArray');
x.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)'); AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)');
x.AddTypeS('TMask','record White, Black : TPointArray; WhiteHi,BlackHi : integer; W,H : integer;end;'); AddTypeS('TMask','record White, Black : TPointArray; WhiteHi,BlackHi : integer; W,H : integer;end;');
x.addtypeS('PPoint','record R,T : extended; end;'); addtypeS('PPoint','record R,T : extended; end;');
x.AddTypeS('TTarget_Exported','record int1,int2,int3,int4,int5,int6,int7,int8,int9,int10,int11,int12,int13,int14,int15,int16:integer; end;'); AddTypeS('TTarget_Exported','record int1,int2,int3,int4,int5,int6,int7,int8,int9,int10,int11,int12,int13,int14,int15,int16:integer; end;');
x.AddTypes('TSDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, AreaShape: integer; end;'); AddTypes('TSDTMPointDef', 'record x, y, Color, Tolerance, AreaSize, AreaShape: integer; end;');
x.AddTypes('TSDTMPointDefArray', 'Array Of TSDTMPointDef;'); AddTypes('TSDTMPointDefArray', 'Array Of TSDTMPointDef;');
x.AddTypes('TSDTM','record MainPoint: TSDTMPointDef; SubPoints: TSDTMPointDefArray; end;'); AddTypes('TSDTM','record MainPoint: TSDTMPointDef; SubPoints: TSDTMPointDefArray; end;');
x.AddTypes('TMDTMPoint','record x,y,c,t,asz : integer; bp : boolean; end;'); AddTypes('TMDTMPoint','record x,y,c,t,asz : integer; bp : boolean; end;');
x.AddTypes('TMDTMPointArray','array of TMDTMPoint;'); AddTypes('TMDTMPointArray','array of TMDTMPoint;');
x.AddTypeS('T2DExtendedArray', 'array of array of extended;'); AddTypeS('T2DExtendedArray', 'array of array of extended;');
x.AddTypeS('T3DExtendedArray','array of array of array of extended;'); AddTypeS('T3DExtendedArray','array of array of array of extended;');
x.AddTypeS('T2DIntegerArray','array of array of integer;'); AddTypeS('T2DIntegerArray','array of array of integer;');
x.AddTypeS('TStringArray','Array of string;'); AddTypeS('TStringArray','Array of string;');
x.AddTypeS('TMousePress', '(mouse_Down, mouse_Up);'); AddTypeS('TMousePress', '(mouse_Down, mouse_Up);');
x.AddTypeS('Pointer', 'Integer'); AddTypeS('Pointer', 'Integer');
x.AddTypeS('TSP_Property','(SP_WriteTimeStamp,SP_OnTerminate)'); AddTypeS('TSP_Property','(SP_WriteTimeStamp,SP_OnTerminate)');
AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0
x.AddConstantN('mouse_Right','integer').SetInt(ps_mouse_right); //0 AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1
x.AddConstantN('mouse_Left','integer').SetInt(ps_mouse_left);//1 AddConstantN('mouse_Middle','integer').SetInt(ps_mouse_middle);//2
x.AddConstantN('mouse_Middle','integer').SetInt(ps_mouse_middle);//2

View File

@ -22,17 +22,17 @@
} }
{$IFDEF CPU386 } {$IFDEF CPU386 }
PSScript.Defines.Add('CPU386'); Defines.Add('CPU386');
{$ENDIF } {$ENDIF }
PSScript.Defines.Add('MUFASA'); Defines.Add('MUFASA');
PSScript.Defines.Add('COGAT'); Defines.Add('COGAT');
PSScript.Defines.Add('SIMBA'); Defines.Add('SIMBA');
PSScript.Defines.Add('RAYMONDPOWNS'); Defines.Add('RAYMONDPOWNS');
{$IFDEF MSWINDOWS } {$IFDEF MSWINDOWS }
PSScript.Defines.Add('MSWINDOWS'); Defines.Add('MSWINDOWS');
PSScript.Defines.Add('WIN32'); Defines.Add('WIN32');
PSScript.Defines.Add('WINDOWS'); Defines.Add('WINDOWS');
{$ENDIF } {$ENDIF }
{$IFDEF LINUX } {$IFDEF LINUX }
PSScript.Defines.Add('LINUX'); Defines.Add('LINUX');
{$ENDIF } {$ENDIF }

View File

@ -21,13 +21,16 @@
psexportedmethods.inc for the Mufasa Macro Library psexportedmethods.inc for the Mufasa Macro Library
} }
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;'); AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
AddFunction(@pswriteln,'procedure Writeln(x: string);'); //PS defines a special, keep this for CPascal AddFunction(@pswriteln,'procedure Writeln(x: string);'); //PS defines a special, keep this for CPascal
AddFunction(@ps_debugln,'procedure DebugLn(str : string);'); AddFunction(@ps_debugln,'procedure DebugLn(str : string);');
{$ENDIF}
{ DTM } { DTM }
SetCurrSection('DTM'); SetCurrSection('DTM');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_SetDTMName, 'procedure SetDTMName(DTM : integer;const name : string);'); AddFunction(@ps_SetDTMName, 'procedure SetDTMName(DTM : integer;const name : string);');
AddFunction(@ps_DTMFromString, 'function DTMFromString(const DTMString: String): Integer;'); AddFunction(@ps_DTMFromString, 'function DTMFromString(const DTMString: String): Integer;');
AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);'); AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);');
@ -42,6 +45,7 @@ AddFunction(@ps_addDTM, 'function AddDTM(const d: TMDTM): Integer;');
AddFunction(@ps_addTSDTM, 'function AddSDTM(const d: TSDTM): Integer;'); AddFunction(@ps_addTSDTM, 'function AddSDTM(const d: TSDTM): Integer;');
AddFunction(@ps_PrintDTM, 'procedure PrintDTM(const DTM : TMDTM);'); AddFunction(@ps_PrintDTM, 'procedure PrintDTM(const DTM : TMDTM);');
AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM'); AddFunction(@ps_GetDTM ,'function GetDTM(index: Integer) : TMDTM');
{$ENDIF}
AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;'); AddFunction(@ps_MDTMToSDTM, 'function MDTMToSDTM(Const DTM: TMDTM): TSDTM;');
AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;'); AddFunction(@ps_SDTMToMDTM, 'function SDTMToMDTM(Const DTM: TSDTM): TMDTM;');
AddFunction(@ps_CreateDTMPoint,'function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;'); AddFunction(@ps_CreateDTMPoint,'function CreateDTMPoint(x,y,c,t,asz : integer; bp : boolean) : TMDTMPoint;');
@ -79,6 +83,8 @@ AddFunction(@ps_hextoint,'function HexToInt(Hex : string) : integer');
AddFunction(@ps_sar,'function sar(AValue : longint; shift : byte) : longint;'); AddFunction(@ps_sar,'function sar(AValue : longint; shift : byte) : longint;');
AddFunction(@ps_ror,'function ror(num : longword; shift : byte) : LongWord;'); AddFunction(@ps_ror,'function ror(num : longword; shift : byte) : LongWord;');
AddFunction(@ps_rol,'function rol(num : longword; shift : byte) : LongWord;'); AddFunction(@ps_rol,'function rol(num : longword; shift : byte) : LongWord;');
{$IFNDEF MML_EXPORT_THREADSAFE}
{window} {window}
SetCurrSection('Window'); SetCurrSection('Window');
AddFunction(@ps_Freeze, 'function Freeze: boolean;'); AddFunction(@ps_Freeze, 'function Freeze: boolean;');
@ -97,10 +103,12 @@ AddFunction(@ps_FreeTarget,'procedure FreeTarget(idx: integer);');
AddFunction(@ps_SetDesktopAsClient,'procedure SetDesktopAsClient;'); AddFunction(@ps_SetDesktopAsClient,'procedure SetDesktopAsClient;');
AddFunction(@ps_ActivateClient, 'procedure ActivateClient;'); AddFunction(@ps_ActivateClient, 'procedure ActivateClient;');
AddFunction(@ps_IsTargetValid, 'function IsTargetValid: boolean;'); AddFunction(@ps_IsTargetValid, 'function IsTargetValid: boolean;');
{$ENDIF}
{files} {files}
SetCurrSection('Files'); SetCurrSection('Files');
AddFunction(@ps_CreateFile, 'function CreateFile(const Path: string): Integer;'); AddFunction(@ps_CreateFile, 'function CreateFile(const Path: string): Integer;');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_OpenFile, 'function OpenFile(const Path: string; Shared: Boolean): Integer;'); AddFunction(@ps_OpenFile, 'function OpenFile(const Path: string; Shared: Boolean): Integer;');
AddFunction(@ps_RewriteFile, 'function RewriteFile(const Path: string; Shared: Boolean): Integer;'); AddFunction(@ps_RewriteFile, 'function RewriteFile(const Path: string; Shared: Boolean): Integer;');
AddFunction(@ps_CloseFile, 'procedure CloseFile(FileNum: Integer);'); AddFunction(@ps_CloseFile, 'procedure CloseFile(FileNum: Integer);');
@ -110,10 +118,11 @@ AddFunction(@ps_ReadFileString, 'function ReadFileString(FileNum: Integer; var s
AddFunction(@ps_WriteFileString, 'function WriteFileString(FileNum: Integer; s: string): Boolean;'); AddFunction(@ps_WriteFileString, 'function WriteFileString(FileNum: Integer; s: string): Boolean;');
AddFunction(@ps_SetFileCharPointer, 'function SetFileCharPointer(FileNum, cChars, Origin: Integer): Integer;'); AddFunction(@ps_SetFileCharPointer, 'function SetFileCharPointer(FileNum, cChars, Origin: Integer): Integer;');
AddFunction(@ps_FilePointerPos, 'function FilePointerPos(FileNum: Integer): Integer;'); AddFunction(@ps_FilePointerPos, 'function FilePointerPos(FileNum: Integer): Integer;');
{$ENDIF}
AddFunction(@ps_DirectoryExists,'function DirectoryExists(const DirectoryName : string ) : Boolean;'); AddFunction(@ps_DirectoryExists,'function DirectoryExists(const DirectoryName : string ) : Boolean;');
AddFunction(@ps_CreateDirectory,'function CreateDirectory(const DirectoryName : string) : boolean;'); AddFunction(@ps_CreateDirectory,'function CreateDirectory(const DirectoryName : string) : boolean;');
AddFunction(@ps_FileExists,'function FileExists (const FileName : string ) : Boolean;'); AddFunction(@ps_FileExists,'function FileExists (const FileName : string ) : Boolean;');
AddFunction(@ps_ForceDirectores,'function ForceDirectores(const dir : string) : boolean;'); AddFunction(@ps_ForceDirectores,'function ForceDirectories(const dir : string) : boolean;');
AddFunction(@ps_GetFiles,'function GetFiles(const Path, Ext : string) : TStringArray;'); AddFunction(@ps_GetFiles,'function GetFiles(const Path, Ext : string) : TStringArray;');
AddFunction(@ps_GetDirectories,'function GetDirectories(const path : string) : TStringArray;'); AddFunction(@ps_GetDirectories,'function GetDirectories(const path : string) : TStringArray;');
AddFunction(@ps_WriteINI,'procedure WriteINI(const Section, KeyName, NewString, FileName: string);'); AddFunction(@ps_WriteINI,'procedure WriteINI(const Section, KeyName, NewString, FileName: string);');
@ -123,31 +132,37 @@ AddFunction(@ps_ExtractFileExt,'function ExtractFileExt(const FileName: string):
{other} {other}
SetCurrSection('Other'); SetCurrSection('Other');
AddFunction(@ps_SetSupressExceptions, 'procedure SetSupressExceptions(Supress : boolean);');
AddFunction(@ps_SaveScreenshot,'procedure SaveScreenshot(FileName: string);');
AddFunction(@ps_Wait, 'procedure wait(t: integer);'); AddFunction(@ps_Wait, 'procedure wait(t: integer);');
AddFunction(@ps_Wait, 'procedure Sleep(t: integer);'); AddFunction(@ps_Wait, 'procedure Sleep(t: integer);');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_SetSupressExceptions, 'procedure SetSupressExceptions(Supress : boolean);');
AddFunction(@ps_SaveScreenshot,'procedure SaveScreenshot(FileName: string);');
AddFunction(@ps_TerminateScript,'procedure TerminateScript;');
{$ENDIF}
AddFunction(@ps_now,'function Now: TDateTime;'); AddFunction(@ps_now,'function Now: TDateTime;');
AddFunction(@ps_date,'function Date : TDateTime;'); AddFunction(@ps_date,'function Date : TDateTime;');
AddFunction(@ps_GetTickCount, 'function GetSystemTime: LongWord;'); AddFunction(@ps_GetTickCount, 'function GetSystemTime: LongWord;');
AddFunction(@ps_GetTickCount, 'function GetTickCount: LongWord;'); AddFunction(@ps_GetTickCount, 'function GetTickCount: LongWord;');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_GetTimeRunning,'function GetTimeRunning: LongWord;'); AddFunction(@ps_GetTimeRunning,'function GetTimeRunning: LongWord;');
{$ENDIF}
AddFunction(@ps_DecodeTime,'procedure DecodeTime(DateTime : TDateTime; var Hour,Min,Sec,MSec : word);'); AddFunction(@ps_DecodeTime,'procedure DecodeTime(DateTime : TDateTime; var Hour,Min,Sec,MSec : word);');
AddFunction(@ps_DecodeDate,'procedure DecodeDate ( const SourceDate : TDateTime; var Year, Month, Day : Word );'); AddFunction(@ps_DecodeDate,'procedure DecodeDate ( const SourceDate : TDateTime; var Year, Month, Day : Word );');
AddFunction(@ps_ConvertTime,'procedure ConvertTime(Time: integer; var h, m, s: integer);'); AddFunction(@ps_ConvertTime,'procedure ConvertTime(Time: integer; var h, m, s: integer);');
AddFunction(@ps_HakunaMatata,'procedure HakunaMatata;'); AddFunction(@ps_HakunaMatata,'procedure HakunaMatata;');
AddFunction(@ps_Simba,'procedure Simba;'); AddFunction(@ps_Simba,'procedure Simba;');
AddFunction(@ps_TerminateScript,'procedure TerminateScript;'); AddFunction(@ps_Random,'function Random(Int: integer): integer;');
AddFunction(@ps_PlaySound,'procedure PlaySound( Sound : string);');
AddFunction(@ps_StopSound,'procedure StopSound;');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(@ps_DisplayDebugImgWindow,'procedure DisplayDebugImgWindow(w, h: integer);'); AddFunction(@ps_DisplayDebugImgWindow,'procedure DisplayDebugImgWindow(w, h: integer);');
AddFunction(@ps_DrawBitmapDebugImg,'procedure DrawBitmapDebugImg(bmp: integer);'); AddFunction(@ps_DrawBitmapDebugImg,'procedure DrawBitmapDebugImg(bmp: integer);');
AddFunction(@ps_GetDebugBitmap,'function GetDebugBitmap: integer;'); AddFunction(@ps_GetDebugBitmap,'function GetDebugBitmap: integer;');
AddFunction(@ps_Random,'function Random(Int: integer): integer;');
AddFunction(@ps_ClearDebug,'procedure ClearDebug;'); AddFunction(@ps_ClearDebug,'procedure ClearDebug;');
AddFunction(@ps_PlaySound,'procedure PlaySound( Sound : string);');
AddFunction(@ps_StopSound,'procedure StopSound;');
AddFunction(@ps_SetScriptProp, 'function SetScriptProp(Prop : TSP_Property; Value: TVariantArray): boolean;'); AddFunction(@ps_SetScriptProp, 'function SetScriptProp(Prop : TSP_Property; Value: TVariantArray): boolean;');
AddFunction(@ps_GetScriptProp, 'function GetScriptProp(Prop : TSP_Property;var Value: TVariantArray): boolean;'); AddFunction(@ps_GetScriptProp, 'function GetScriptProp(Prop : TSP_Property;var Value: TVariantArray): boolean;');
AddFunction(@ps_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;'); AddFunction(@ps_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;');
{$ENDIF}
{string} {string}
SetCurrSection('String'); SetCurrSection('String');
@ -157,7 +172,9 @@ AddFunction(@ps_DecompressString,'function DecompressString(const Compressed : s
AddFunction(@ps_Base64Encode,'function Base64Encode(const str : string) : string;'); AddFunction(@ps_Base64Encode,'function Base64Encode(const str : string) : string;');
AddFunction(@ps_Base64Decode,'function Base64Decode(const str : string) : string;'); AddFunction(@ps_Base64Decode,'function Base64Decode(const str : string) : string;');
AddFunction(@ps_Format,'function Format(const fmt : string;const args : array of const) : string;'); AddFunction(@ps_Format,'function Format(const fmt : string;const args : array of const) : string;');
{$IFNDEF MML_EXPORT_THREADSAFE}
AddFunction(nil,'function ToStr(x) : string;'); AddFunction(nil,'function ToStr(x) : string;');
{$ENDIF}
AddFunction(@ps_Between,'function Between(s1, s2, str: string): string;'); AddFunction(@ps_Between,'function Between(s1, s2, str: string): string;');
AddFunction(@ps_IntToStr, 'function IntToStr(value: Integer): String;'); AddFunction(@ps_IntToStr, 'function IntToStr(value: Integer): String;');
AddFunction(@ps_FloatToStr, 'function FloatToStr(value: Extended): String;'); AddFunction(@ps_FloatToStr, 'function FloatToStr(value: Extended): String;');
@ -181,6 +198,7 @@ AddFunction(@ps_ExecRegExpr,'function ExecRegExpr( const RegExpr, InputStr : Str
AddFunction(@ps_SplitRegExpr,'procedure SplitRegExpr( const RegExpr, InputStr : String; Pieces : TStrings);'); AddFunction(@ps_SplitRegExpr,'procedure SplitRegExpr( const RegExpr, InputStr : String; Pieces : TStrings);');
addfunction(@ps_ReplaceRegExpr,'function ReplaceRegExpr( const RegExpr, InputStr, ReplaceStr : String; UseSubstitution : boolean) : String;'); addfunction(@ps_ReplaceRegExpr,'function ReplaceRegExpr( const RegExpr, InputStr, ReplaceStr : String; UseSubstitution : boolean) : String;');
{$IFNDEF MML_EXPORT_THREADSAFE}
{web} {web}
SetCurrSection('Web'); SetCurrSection('Web');
AddFunction(@ps_OpenWebPage,'procedure OpenWebPage(const url : string);'); AddFunction(@ps_OpenWebPage,'procedure OpenWebPage(const url : string);');
@ -195,8 +213,7 @@ AddFunction(@ps_PostHTTPPageEx,'function PostHTTPPageEx(Client: Integer;const Ur
AddFunction(@ps_ClearPostData,'procedure ClearPostData(Client: Integer);'); AddFunction(@ps_ClearPostData,'procedure ClearPostData(Client: Integer);');
AddFunction(@ps_AddPostVariable,'procedure AddPostVariable(Client: Integer;const VarName, VarValue: string);'); AddFunction(@ps_AddPostVariable,'procedure AddPostVariable(Client: Integer;const VarName, VarValue: string);');
AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;'); AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;');
{$ENDIF}
{ Color Conversions and Speed } { Color Conversions and Speed }
SetCurrSection('Color Convert'); SetCurrSection('Color Convert');
@ -211,6 +228,7 @@ AddFunction(@ps_HSLToRGB, 'procedure HSLtoRGB(H, S, L: extended; var R, G ,B: In
AddFunction(@ps_RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Integer;var x, y ,z: Extended);'); AddFunction(@ps_RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Integer;var x, y ,z: Extended);');
AddFunction(@ps_XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; var R, G, B: Integer);'); AddFunction(@ps_XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; var R, G, B: Integer);');
{$IFNDEF MML_EXPORT_THREADSAFE}
{ Color Finding } { Color Finding }
SetCurrSection('Color'); SetCurrSection('Color');
AddFunction(@ps_SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(cts: integer);'); AddFunction(@ps_SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(cts: integer);');
@ -234,7 +252,9 @@ AddFunction(@ps_FindColorSpiralTolerance,'function FindColorSpiralTolerance(var
AddFunction(@ps_FindColorsSpiralTolerance,'function FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean;'); AddFunction(@ps_FindColorsSpiralTolerance,'function FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean;');
AddFunction(@ps_FindColoredArea, 'function FindColoredArea(var x, y: Integer; color, xs, ys, xe, ye, MinArea: Integer): Boolean'); AddFunction(@ps_FindColoredArea, 'function FindColoredArea(var x, y: Integer; color, xs, ys, xe, ye, MinArea: Integer): Boolean');
AddFunction(@ps_FindColoredAreaTolerance, 'function FindColoredAreaTolerance(var x, y : Integer; color, xs, ys, xe, ye, MinArea, Tolerance : Integer): Boolean'); AddFunction(@ps_FindColoredAreaTolerance, 'function FindColoredAreaTolerance(var x, y : Integer; color, xs, ys, xe, ye, MinArea, Tolerance : Integer): Boolean');
{$ENDIF}
{$IFNDEF MML_EXPORT_THREADSAFE}
{Mouse etc.} {Mouse etc.}
SetCurrSection('Mouse'); SetCurrSection('Mouse');
AddFunction(@ps_MoveMouse, 'procedure MoveMouse(x, y: integer);'); AddFunction(@ps_MoveMouse, 'procedure MoveMouse(x, y: integer);');
@ -244,7 +264,9 @@ AddFunction(@ps_HoldMouse, 'procedure HoldMouse(x, y: integer; clickType: intege
AddFunction(@ps_ReleaseMouse, 'procedure ReleaseMouse(x, y: integer; clickType: integer);'); AddFunction(@ps_ReleaseMouse, 'procedure ReleaseMouse(x, y: integer; clickType: integer);');
AddFunction(@ps_ClickMouse, 'procedure ClickMouse(x, y: integer; clickType: integer);'); AddFunction(@ps_ClickMouse, 'procedure ClickMouse(x, y: integer; clickType: integer);');
AddFunction(@ps_IsMouseButtonDown,'function IsMouseButtonDown( button : integer) : boolean;'); AddFunction(@ps_IsMouseButtonDown,'function IsMouseButtonDown( button : integer) : boolean;');
{$ENDIF}
{$IFNDEF MML_EXPORT_THREADSAFE}
{Keyboard} {Keyboard}
SetCurrSection('Keyboard'); SetCurrSection('Keyboard');
AddFunction(@ps_KeyDown, 'procedure KeyDown(key: Word);'); AddFunction(@ps_KeyDown, 'procedure KeyDown(key: Word);');
@ -253,7 +275,9 @@ AddFunction(@ps_PressKey, 'procedure PressKey(key: Word);');
AddFunction(@ps_SendKeys, 'procedure SendKeys(const s: string);'); AddFunction(@ps_SendKeys, 'procedure SendKeys(const s: string);');
AddFunction(@ps_isKeyDown, 'function IsKeyDown(key: Word): Boolean;'); AddFunction(@ps_isKeyDown, 'function IsKeyDown(key: Word): Boolean;');
AddFunction(@ps_GetKeyCode,'function GetKeyCode(c : char) : integer;'); AddFunction(@ps_GetKeyCode,'function GetKeyCode(c : char) : integer;');
{$ENDIF}
{$IFNDEF MML_EXPORT_THREADSAFE}
{ OCR} { OCR}
SetCurrSection('OCR'); SetCurrSection('OCR');
AddFunction(@ps_rs_GetUpText, 'function rs_GetUpText: string;'); AddFunction(@ps_rs_GetUpText, 'function rs_GetUpText: string;');
@ -269,7 +293,9 @@ AddFunction(@ps_gettextATPA,'function GetTextATPA(const ATPA : T2DPointArray; co
AddFunction(@ps_LoadSystemFont,'function LoadSystemFont(const SysFont : TFont; const FontName : string) : boolean;'); AddFunction(@ps_LoadSystemFont,'function LoadSystemFont(const SysFont : TFont; const FontName : string) : boolean;');
AddFunction(@ps_LoadFont, 'function LoadFont(const FontName: string; shadow: boolean): boolean;'); AddFunction(@ps_LoadFont, 'function LoadFont(const FontName: string; shadow: boolean): boolean;');
AddFunction(@ps_FreeFont, 'function FreeFont(const FontName: string): boolean;'); AddFunction(@ps_FreeFont, 'function FreeFont(const FontName: string): boolean;');
{$ENDIF}
{$IFNDEF MML_EXPORT_THREADSAFE}
{Bitmaps} {Bitmaps}
SetCurrSection('Bitmaps'); SetCurrSection('Bitmaps');
AddFunction(@ps_CreateBitmapString,'function CreateBitmapString(bmp : integer) : string;'); AddFunction(@ps_CreateBitmapString,'function CreateBitmapString(bmp : integer) : string;');
@ -323,6 +349,7 @@ AddFunction(@ps_RectangleBitmap,'procedure RectangleBitmap(bitmap : integer; con
AddFunction(@ps_FloodfillBitmap,'procedure FloodFillBitmap(bitmap : integer; const StartPoint : TPoint; const SearchCol,ReplaceCol : TColor);'); AddFunction(@ps_FloodfillBitmap,'procedure FloodFillBitmap(bitmap : integer; const StartPoint : TPoint; const SearchCol,ReplaceCol : TColor);');
AddFunction(@ps_CalculatePixelShift,'function CalculatePixelShift(Bmp1,Bmp2 : Integer; CompareBox : TBox) : integer;'); AddFunction(@ps_CalculatePixelShift,'function CalculatePixelShift(Bmp1,Bmp2 : Integer; CompareBox : TBox) : integer;');
AddFunction(@ps_CalculatePixelTolerance,'function CalculatePixelTolerance(Bmp1,Bmp2 : Integer; CompareBox : TBox; CTS : integer) : extended;'); AddFunction(@ps_CalculatePixelTolerance,'function CalculatePixelTolerance(Bmp1,Bmp2 : Integer; CompareBox : TBox; CTS : integer) : extended;');
{$ENDIF}
{tpa} {tpa}
SetCurrSection('TPA'); SetCurrSection('TPA');
@ -411,6 +438,7 @@ AddFunction(@ps_offsetATPA,'procedure OffsetATPA(var ATPA : T2DPointArray; const
AddFunction(@ps_copyTPA,'function CopyTPA(const TPA : TPointArray) : TPointArray;'); AddFunction(@ps_copyTPA,'function CopyTPA(const TPA : TPointArray) : TPointArray;');
AddFunction(@ps_CopyATPA,'function CopyATPA(const ATPA : T2DPointArray) : T2DPointArray;'); AddFunction(@ps_CopyATPA,'function CopyATPA(const ATPA : T2DPointArray) : T2DPointArray;');
{$IFNDEF MML_EXPORT_THREADSAFE}
SetCurrSection('Settings'); SetCurrSection('Settings');
AddFunction(@ps_KeyIsSetting, 'function KeyIsSetting(const KeyName: String): Boolean;'); AddFunction(@ps_KeyIsSetting, 'function KeyIsSetting(const KeyName: String): Boolean;');
AddFunction(@ps_KeyIsDirectory, 'function KeyIsDirectory(const KeyName: String): Boolean;'); AddFunction(@ps_KeyIsDirectory, 'function KeyIsDirectory(const KeyName: String): Boolean;');
@ -420,3 +448,4 @@ AddFunction(@ps_SetSettingValue,'function SetSettingValue(const KeyName,value :
AddFunction(@ps_ListSettings, 'function ListSettings(const KeyName: String; var KeyReturn: TStringArray) : boolean;'); AddFunction(@ps_ListSettings, 'function ListSettings(const KeyName: String; var KeyReturn: TStringArray) : boolean;');
AddFunction(@ps_DeleteSetting, 'function DeleteSetting(const KeyName: String): Boolean;'); AddFunction(@ps_DeleteSetting, 'function DeleteSetting(const KeyName: String): Boolean;');
AddFunction(@ps_DeleteSubSettings, 'function DeleteSubSettings(const KeyName: String): Boolean;'); AddFunction(@ps_DeleteSubSettings, 'function DeleteSubSettings(const KeyName: String): Boolean;');
{$ENDIF}

View File

@ -17,6 +17,7 @@ begin
RegisterMethod('procedure FastSetPixels(TPA : TPointArray; Colors : TIntegerArray);'); RegisterMethod('procedure FastSetPixels(TPA : TPointArray; Colors : TIntegerArray);');
RegisterMethod('procedure DrawATPA(ATPA : T2DPointArray; Colors : TIntegerArray);'); RegisterMethod('procedure DrawATPA(ATPA : T2DPointArray; Colors : TIntegerArray);');
RegisterMethod('procedure DrawTPA(TPA : TPointArray; Color : TColor);'); RegisterMethod('procedure DrawTPA(TPA : TPointArray; Color : TColor);');
RegisterMethod('procedure DrawToCanvas(x, y: Integer; Canvas: TCanvas);');
RegisterMethod('function FastGetPixel(x,y : integer) : TColor;'); RegisterMethod('function FastGetPixel(x,y : integer) : TColor;');
RegisterMethod('procedure CopyClientToBitmap(Resize : boolean;x,y : integer; xs, ys, xe, ye: Integer);'); RegisterMethod('procedure CopyClientToBitmap(Resize : boolean;x,y : integer; xs, ys, xe, ye: Integer);');
RegisterMethod('procedure Rectangle(const Box : TBox; FillCol : TColor);'); RegisterMethod('procedure Rectangle(const Box : TBox; FillCol : TColor);');

View File

@ -76,6 +76,7 @@ begin
RegisterMethod(@TMufasaBitmap.FastSetPixels,'FASTSETPIXELS'); RegisterMethod(@TMufasaBitmap.FastSetPixels,'FASTSETPIXELS');
RegisterMethod(@TMufasaBitmap.DrawATPA,'DRAWATPA'); RegisterMethod(@TMufasaBitmap.DrawATPA,'DRAWATPA');
RegisterMethod(@TMufasaBitmap.DrawTPA,'DRAWTPA'); RegisterMethod(@TMufasaBitmap.DrawTPA,'DRAWTPA');
RegisterMethod(@TMufasaBitmap.DrawToCanvas, 'DRAWTOCANVAS');
RegisterMethod(@TMufasaBitmap.FloodFill,'FLOODFILL'); RegisterMethod(@TMufasaBitmap.FloodFill,'FLOODFILL');
RegisterMethod(@TMufasaBitmap.Rectangle,'RECTANGLE'); RegisterMethod(@TMufasaBitmap.Rectangle,'RECTANGLE');
RegisterMethod(@TMufasaBitmap.FastGetPixel,'FASTGETPIXEL'); RegisterMethod(@TMufasaBitmap.FastGetPixel,'FASTGETPIXEL');

View File

@ -86,17 +86,17 @@ type
protected protected
ScriptPath, AppPath, IncludePath, PluginPath, FontPath: string; ScriptPath, AppPath, IncludePath, PluginPath, FontPath: string;
DebugTo: TWritelnProc; DebugTo: TWritelnProc;
DebugClear : TClearDebugProc; FDebugClear : TClearDebugProc;
DebugImg : TDbgImgInfo; FDebugImg : TDbgImgInfo;
ExportedMethods : TExpMethodArr; ExportedMethods : TExpMethodArr;
Includes : TStringList; Includes : TStringList;
Prop: TScriptProperties;
FOpenConnectionEvent : TOpenConnectionEvent; FOpenConnectionEvent : TOpenConnectionEvent;
FWriteFileEvent : TWriteFileEvent; FWriteFileEvent : TWriteFileEvent;
FOpenFileEvent : TOpenFileEvent; FOpenFileEvent : TOpenFileEvent;
procedure LoadPlugin(plugidx: integer); virtual; abstract; procedure LoadPlugin(plugidx: integer); virtual; abstract;
public public
Prop: TScriptProperties;
Client : TClient; Client : TClient;
MInternet : TMInternet; MInternet : TMInternet;
StartTime : LongWord; StartTime : LongWord;
@ -134,6 +134,8 @@ type
property OpenConnectionEvent : TOpenConnectionEvent read FOpenConnectionEvent write SetOpenConnectionEvent; property OpenConnectionEvent : TOpenConnectionEvent read FOpenConnectionEvent write SetOpenConnectionEvent;
property WriteFileEvent : TWriteFileEvent read FWriteFileEvent write SetWriteFileEvent; property WriteFileEvent : TWriteFileEvent read FWriteFileEvent write SetWriteFileEvent;
property OpenFileEvent : TOpenFileEvent read FOpenFileEvent write SetOpenFileEvent; property OpenFileEvent : TOpenFileEvent read FOpenFileEvent write SetOpenFileEvent;
property DebugClear : TClearDebugProc read FDebugClear write SetDebugClear;
property DebugImg : TDbgImgInfo read FDebugImg write SetDbgImg;
end; end;
{ TPSThread } { TPSThread }
@ -257,55 +259,6 @@ begin
mDebugLn(str); mDebugLn(str);
end; end;
function MakeString(data : TPSVariantIFC) : string;
begin;
if data.Dta = nil then
result := 'Nil'
else
if data.aType.basetype in [btString,btChar] then
result := PSGetAnsiString(Data.Dta,data.aType)
else if data.aType.ExportName = 'BOOLEAN' then
result := BoolToStr(PSGetInt(Data.Dta,data.aType) <> 0,true)
else
result := PSVariantToString(data,'');
end;
function writeln_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
begin
Result:=true;
psWriteln(makeString(NewTPSVariantIFC(Stack[Stack.Count-1],false)));
end;
function swap_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
var
Param1,Param2: TPSVariantIFC;
tempCopy : pointer;
begin
Result:=true;
Param1 := NewTPSVariantIFC(Stack[Stack.count-1],true);
Param2 := NewTPSVariantIFC(Stack[Stack.count-2],true);
if Param1.aType.BaseType <> Param2.aType.BaseType then
exit(false)
else
begin
Param1.aType.CalcSize;
param2.aType.CalcSize;
if Param1.aType.RealSize <> Param2.aType.RealSize then
exit(false);
GetMem(tempcopy,Param1.aType.RealSize);
Move(Param1.Dta^,tempCopy^,param1.atype.realsize);
Move(Param2.Dta^,Param1.Dta^,param1.atype.realsize);
Move(tempCopy^,Param2.Dta^,param1.atype.realsize);
Freemem(tempcopy);
end;
end;
function ToStr_(Caller: TPSExec; p: TPSExternalProcRec; Global, Stack: TPSStack): Boolean;
begin
result := true;
Stack.SetAnsiString(-1, MakeString(NewTPSVariantIFC(Stack[Stack.Count-2],false)));
end;
{***implementation TMThread***} {***implementation TMThread***}
constructor TMThread.Create(CreateSuspended: boolean; TheSyncInfo: PSyncInfo; plugin_dir: string); constructor TMThread.Create(CreateSuspended: boolean; TheSyncInfo: PSyncInfo; plugin_dir: string);
begin begin
@ -466,12 +419,12 @@ end;
procedure TMThread.SetDebugClear(clearProc: TClearDebugProc); procedure TMThread.SetDebugClear(clearProc: TClearDebugProc);
begin begin
DebugClear:= clearProc; FDebugClear:= clearProc;
end; end;
procedure TMThread.SetDbgImg(DebugImageInfo: TDbgImgInfo); procedure TMThread.SetDbgImg(DebugImageInfo: TDbgImgInfo);
begin begin
DebugImg := DebugImageInfo; FDebugImg := DebugImageInfo;
end; end;
procedure TMThread.SetSettings(S: TMMLSettingsSandbox); procedure TMThread.SetSettings(S: TMMLSettingsSandbox);
@ -567,8 +520,13 @@ begin
PSScript.OnCompImport:= @OnCompImport; PSScript.OnCompImport:= @OnCompImport;
PSScript.OnExecImport:= @OnExecImport; PSScript.OnExecImport:= @OnExecImport;
PSScript.OnFindUnknownFile:=@PSScriptFindUnknownFile; PSScript.OnFindUnknownFile:=@PSScriptFindUnknownFile;
// Set some defines
{$I PSInc/psdefines.inc} with PSScript do
begin
// Set some defines
{$I PSInc/psdefines.inc}
end;
for i := 0 to high(ExportedMethods) do for i := 0 to high(ExportedMethods) do
if pos('Writeln',exportedmethods[i].FuncDecl) > 0 then if pos('Writeln',exportedmethods[i].FuncDecl) > 0 then
begin begin
@ -683,7 +641,12 @@ begin
SIRegister_Menus(x); SIRegister_Menus(x);
SIRegister_ComCtrls(x); SIRegister_ComCtrls(x);
SIRegister_Dialogs(x); SIRegister_Dialogs(x);
{$I PSInc/pscompile.inc}
with x do
begin
{$I PSInc/pscompile.inc}
end;
SIRegister_Mufasa(x); SIRegister_Mufasa(x);
with x.AddFunction('procedure writeln;').decl do with x.AddFunction('procedure writeln;').decl do
with AddParam do with AddParam do
@ -792,7 +755,6 @@ begin
psWriteln(PSScript.CompilerErrorToStr(l) + ' at line ' + inttostr(PSScript.CompilerMessages[l].Row - 1)); psWriteln(PSScript.CompilerErrorToStr(l) + ' at line ' + inttostr(PSScript.CompilerMessages[l].Row - 1));
end else end else
psWriteln(PSScript.CompilerErrorToStr(l) + ' at line ' + inttostr(PSScript.CompilerMessages[l].Row - 1)); psWriteln(PSScript.CompilerErrorToStr(l) + ' at line ' + inttostr(PSScript.CompilerMessages[l].Row - 1));
end; end;
end; end;

View File

@ -33,6 +33,9 @@ uses
const const
DS = DirectorySeparator; DS = DirectorySeparator;
MEOL = {$ifdef MSWINDOWS}#13+{$endif}#10; MEOL = {$ifdef MSWINDOWS}#13+{$endif}#10;
ps_mouse_right = 0;
ps_mouse_left = 1;
ps_mouse_middle = 2;
{ Overloaded Operators} { Overloaded Operators}

View File

@ -198,11 +198,11 @@ begin
CL.AddTypeS('TFindOptions', 'set of TFindOption'); CL.AddTypeS('TFindOptions', 'set of TFindOption');
SIRegister_TFindDialog(CL); SIRegister_TFindDialog(CL);
SIRegister_TReplaceDialog(CL); SIRegister_TReplaceDialog(CL);
CL.AddTypeS('TMsgDlgType', '( mtWarning, mtError, mtInformation, mtConfirmati' //CL.AddTypeS('TMsgDlgType', '( mtWarning, mtError, mtInformation, mtConfirmati'
+'on, mtCustom )'); // +'on, mtCustom )');
CL.AddTypeS('TMsgDlgBtn', '( mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, m' //CL.AddTypeS('TMsgDlgBtn', '( mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, m'
+'bIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp )'); // +'bIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp )');
CL.AddTypeS('TMsgDlgButtons', 'set of TMsgDlgBtn'); //CL.AddTypeS('TMsgDlgButtons', 'set of TMsgDlgBtn');
CL.AddConstantN('mbYesNoCancel','LongInt').SetInt(ord(mbYes) or ord(mbNo) or ord(mbCancel)); CL.AddConstantN('mbYesNoCancel','LongInt').SetInt(ord(mbYes) or ord(mbNo) or ord(mbCancel));
CL.AddConstantN('mbOKCancel','LongInt').SetInt(ord(mbOK) or ord(mbCancel)); CL.AddConstantN('mbOKCancel','LongInt').SetInt(ord(mbOK) or ord(mbCancel));
CL.AddConstantN('mbAbortRetryIgnore','LongInt').SetInt(ord(mbAbort) or ord(mbRetry) or ord(mbIgnore)); CL.AddConstantN('mbAbortRetryIgnore','LongInt').SetInt(ord(mbAbort) or ord(mbRetry) or ord(mbIgnore));
@ -565,13 +565,13 @@ begin T := Self.Handle; end;
procedure RIRegister_Dialogs_Routines(S: TPSExec); procedure RIRegister_Dialogs_Routines(S: TPSExec);
begin begin
S.RegisterDelphiFunction(@CreateMessageDialog, 'CreateMessageDialog', cdRegister); S.RegisterDelphiFunction(@CreateMessageDialog, 'CreateMessageDialog', cdRegister);
S.RegisterDelphiFunction(@MessageDlg, 'MessageDlg', cdRegister); {S.RegisterDelphiFunction(@MessageDlg, 'MessageDlg', cdRegister);
S.RegisterDelphiFunction(@MessageDlgPos, 'MessageDlgPos', cdRegister); S.RegisterDelphiFunction(@MessageDlgPos, 'MessageDlgPos', cdRegister);
S.RegisterDelphiFunction(@MessageDlgPosHelp, 'MessageDlgPosHelp', cdRegister); S.RegisterDelphiFunction(@MessageDlgPosHelp, 'MessageDlgPosHelp', cdRegister);
S.RegisterDelphiFunction(@ShowMessage, 'ShowMessage', cdRegister); S.RegisterDelphiFunction(@ShowMessage, 'ShowMessage', cdRegister);
S.RegisterDelphiFunction(@ShowMessagePos, 'ShowMessagePos', cdRegister); S.RegisterDelphiFunction(@ShowMessagePos, 'ShowMessagePos', cdRegister);
S.RegisterDelphiFunction(@InputBox, 'InputBox', cdRegister); S.RegisterDelphiFunction(@InputBox, 'InputBox', cdRegister);
S.RegisterDelphiFunction(@InputQuery, 'InputQuery', cdRegister); S.RegisterDelphiFunction(@InputQuery, 'InputQuery', cdRegister);}
end; end;
(*----------------------------------------------------------------------------*) (*----------------------------------------------------------------------------*)