mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-24 16:28:53 -05:00
Added few functions + made psWriteln use Critical Sections (Not sure wether it w0rks on linux).
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@135 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
7c2fd48297
commit
50adef2299
@ -31,6 +31,26 @@ begin
|
|||||||
Sleep(t);
|
Sleep(t);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure SaveScreenshot(FileName: string);
|
||||||
|
var
|
||||||
|
w,h : integer;
|
||||||
|
begin;
|
||||||
|
with CurrThread.Client.MWindow do
|
||||||
|
begin;
|
||||||
|
GetDimensions(w,h);
|
||||||
|
with CopyClientToBitmap(0,0,w-1,h-1) do
|
||||||
|
begin;
|
||||||
|
SaveToFile(FileName);
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Distance(x1, y1, x2, y2: Integer): Integer;
|
||||||
|
begin;
|
||||||
|
Result := Round(Sqrt(Sqr(x2-x1) + Sqr(y2-y1)));
|
||||||
|
end;
|
||||||
|
|
||||||
function Freeze: boolean;
|
function Freeze: boolean;
|
||||||
begin
|
begin
|
||||||
result := CurrThread.Client.MWindow.Freeze();
|
result := CurrThread.Client.MWindow.Freeze();
|
||||||
|
@ -56,9 +56,11 @@ Sender.AddFunction(@max,'function Max(a, b: Integer): Integer;');
|
|||||||
Sender.AddFunction(@min,'function Min(a, b: Integer): Integer;');
|
Sender.AddFunction(@min,'function Min(a, b: Integer): Integer;');
|
||||||
Sender.AddFunction(@pssqr,'function Sqr(e : extended) : extended;');
|
Sender.AddFunction(@pssqr,'function Sqr(e : extended) : extended;');
|
||||||
Sender.AddFunction(@classes.point,'function Point(x,y:integer) : TPoint;');
|
Sender.AddFunction(@classes.point,'function Point(x,y:integer) : TPoint;');
|
||||||
|
Sender.AddFunction(@Distance,'function Distance(x1,y1,x2,y2 : integer) : integer;');
|
||||||
|
|
||||||
Sender.AddFunction(@Freeze, 'function freeze:boolean;');
|
Sender.AddFunction(@Freeze, 'function freeze:boolean;');
|
||||||
Sender.AddFunction(@Unfreeze, 'function unfreeze: boolean;');
|
Sender.AddFunction(@Unfreeze, 'function unfreeze: boolean;');
|
||||||
|
Sender.AddFunction(@SaveScreenshot,'procedure SaveScreenshot(FileName: string);');
|
||||||
|
|
||||||
Sender.AddFunction(@GetColor,'function GetColor(x, y: Integer): Integer;');
|
Sender.AddFunction(@GetColor,'function GetColor(x, y: Integer): Integer;');
|
||||||
Sender.AddFunction(@FindColor, 'function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean;');
|
Sender.AddFunction(@FindColor, 'function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean;');
|
||||||
|
@ -79,13 +79,20 @@ threadvar
|
|||||||
|
|
||||||
{Some General PS Functions here}
|
{Some General PS Functions here}
|
||||||
procedure psWriteln(str : string);
|
procedure psWriteln(str : string);
|
||||||
|
var
|
||||||
|
CriticalSec : TRTLCriticalSection;
|
||||||
begin
|
begin
|
||||||
{$IFNDEF MSWINDOWS}
|
System.InitCriticalSection(CriticalSec);
|
||||||
writeln(str);
|
System.EnterCriticalSection(CriticalSec);
|
||||||
{$ELSE}
|
try
|
||||||
if CurrThread.DebugTo <> nil then
|
if CurrThread.DebugTo <> nil then
|
||||||
CurrThread.DebugTo.lines.add(str);
|
begin;
|
||||||
{$ENDIF}
|
CurrThread.DebugTo.lines.add(str);
|
||||||
|
CurrThread.DebugTo.Refresh;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
System.LeaveCriticalSection(CriticalSec);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;
|
function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;
|
||||||
@ -162,7 +169,6 @@ end;
|
|||||||
{$I PSInc/Wrappers/dtm.inc}
|
{$I PSInc/Wrappers/dtm.inc}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMMLPSThread.PSScriptProcessUnknowDirective(Sender: TPSPreProcessor;
|
procedure TMMLPSThread.PSScriptProcessUnknowDirective(Sender: TPSPreProcessor;
|
||||||
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
|
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
|
||||||
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
|
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
|
||||||
|
Loading…
Reference in New Issue
Block a user