mirror of
https://github.com/moparisthebest/Simba
synced 2024-12-23 15:58:51 -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);
|
||||
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;
|
||||
begin
|
||||
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(@pssqr,'function Sqr(e : extended) : extended;');
|
||||
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(@Unfreeze, 'function unfreeze: boolean;');
|
||||
Sender.AddFunction(@SaveScreenshot,'procedure SaveScreenshot(FileName: string);');
|
||||
|
||||
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;');
|
||||
|
@ -79,13 +79,20 @@ threadvar
|
||||
|
||||
{Some General PS Functions here}
|
||||
procedure psWriteln(str : string);
|
||||
var
|
||||
CriticalSec : TRTLCriticalSection;
|
||||
begin
|
||||
{$IFNDEF MSWINDOWS}
|
||||
writeln(str);
|
||||
{$ELSE}
|
||||
System.InitCriticalSection(CriticalSec);
|
||||
System.EnterCriticalSection(CriticalSec);
|
||||
try
|
||||
if CurrThread.DebugTo <> nil then
|
||||
begin;
|
||||
CurrThread.DebugTo.lines.add(str);
|
||||
{$ENDIF}
|
||||
CurrThread.DebugTo.Refresh;
|
||||
end;
|
||||
finally
|
||||
System.LeaveCriticalSection(CriticalSec);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;
|
||||
@ -162,7 +169,6 @@ end;
|
||||
{$I PSInc/Wrappers/dtm.inc}
|
||||
|
||||
|
||||
|
||||
procedure TMMLPSThread.PSScriptProcessUnknowDirective(Sender: TPSPreProcessor;
|
||||
Parser: TPSPascalPreProcessorParser; const Active: Boolean;
|
||||
const DirectiveName, DirectiveParam: string; var Continue: Boolean);
|
||||
|
Loading…
Reference in New Issue
Block a user