1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-01-30 23:00:18 -05:00

Some DTM functions.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@97 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-10-03 19:17:54 +00:00
parent 3561203791
commit 88710ef066
10 changed files with 1180 additions and 822 deletions

View File

@ -7,7 +7,7 @@
<TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="9"/>
<ActiveEditorIndexAtStart Value="3"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -33,15 +33,15 @@
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="125">
<Units Count="128">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<CursorPos X="10" Y="7"/>
<CursorPos X="26" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="143"/>
<UsageCount Value="153"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -172,8 +172,8 @@
<UnitName Value="TestUnit"/>
<CursorPos X="37" Y="115"/>
<TopLine Value="84"/>
<EditorIndex Value="8"/>
<UsageCount Value="109"/>
<EditorIndex Value="11"/>
<UsageCount Value="119"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
@ -302,20 +302,20 @@
<Filename Value="../../Units/MMLCore/client.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Client"/>
<CursorPos X="25" Y="17"/>
<TopLine Value="1"/>
<EditorIndex Value="3"/>
<UsageCount Value="108"/>
<CursorPos X="23" Y="18"/>
<TopLine Value="18"/>
<EditorIndex Value="2"/>
<UsageCount Value="118"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/>
<CursorPos X="69" Y="25"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="108"/>
<CursorPos X="1" Y="35"/>
<TopLine Value="21"/>
<EditorIndex Value="1"/>
<UsageCount Value="118"/>
<Loaded Value="True"/>
</Unit38>
<Unit39>
@ -329,18 +329,18 @@
<Filename Value="../../Units/MMLCore/files.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="files"/>
<CursorPos X="37" Y="42"/>
<TopLine Value="271"/>
<UsageCount Value="109"/>
<CursorPos X="30" Y="20"/>
<TopLine Value="1"/>
<UsageCount Value="119"/>
</Unit40>
<Unit41>
<Filename Value="../../Units/MMLCore/window.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Window"/>
<CursorPos X="24" Y="84"/>
<TopLine Value="75"/>
<EditorIndex Value="10"/>
<UsageCount Value="108"/>
<CursorPos X="29" Y="233"/>
<TopLine Value="233"/>
<EditorIndex Value="12"/>
<UsageCount Value="118"/>
<Loaded Value="True"/>
</Unit41>
<Unit42>
@ -353,10 +353,10 @@
<Unit43>
<Filename Value="../../../cogat/Units/CogatUnits/comptypes.pas"/>
<UnitName Value="CompTypes"/>
<CursorPos X="59" Y="545"/>
<TopLine Value="524"/>
<EditorIndex Value="14"/>
<UsageCount Value="18"/>
<CursorPos X="35" Y="727"/>
<TopLine Value="712"/>
<EditorIndex Value="6"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit43>
<Unit44>
@ -364,8 +364,8 @@
<UnitName Value="windowutil"/>
<CursorPos X="86" Y="19"/>
<TopLine Value="1"/>
<EditorIndex Value="11"/>
<UsageCount Value="36"/>
<EditorIndex Value="13"/>
<UsageCount Value="41"/>
<Loaded Value="True"/>
</Unit44>
<Unit45>
@ -373,19 +373,17 @@
<UnitName Value="Input"/>
<CursorPos X="32" Y="251"/>
<TopLine Value="220"/>
<EditorIndex Value="4"/>
<UsageCount Value="16"/>
<EditorIndex Value="7"/>
<UsageCount Value="21"/>
<Loaded Value="True"/>
</Unit45>
<Unit46>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="finder"/>
<CursorPos X="39" Y="38"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<UsageCount Value="101"/>
<Loaded Value="True"/>
<CursorPos X="20" Y="29"/>
<TopLine Value="14"/>
<UsageCount Value="111"/>
</Unit46>
<Unit47>
<Filename Value="../../../lazarus/lcl/graphics.pp"/>
@ -400,7 +398,7 @@
<UnitName Value="MMLThread"/>
<CursorPos X="132" Y="5"/>
<TopLine Value="1"/>
<UsageCount Value="99"/>
<UsageCount Value="109"/>
</Unit48>
<Unit49>
<Filename Value="../../../Documents/fpc/rtl/objpas/classes/classesh.inc"/>
@ -412,10 +410,10 @@
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mmlpsthread"/>
<CursorPos X="46" Y="167"/>
<TopLine Value="157"/>
<EditorIndex Value="6"/>
<UsageCount Value="97"/>
<CursorPos X="18" Y="177"/>
<TopLine Value="174"/>
<EditorIndex Value="8"/>
<UsageCount Value="107"/>
<Loaded Value="True"/>
</Unit50>
<Unit51>
@ -523,9 +521,11 @@
</Unit65>
<Unit66>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<CursorPos X="31" Y="13"/>
<CursorPos X="49" Y="13"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit66>
<Unit67>
<Filename Value="../../../FPC/FPCCheckout/rtl/win/tthread.inc"/>
@ -545,7 +545,7 @@
<UnitName Value="bitmaps"/>
<CursorPos X="63" Y="428"/>
<TopLine Value="387"/>
<UsageCount Value="87"/>
<UsageCount Value="97"/>
</Unit69>
<Unit70>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.pp"/>
@ -565,7 +565,7 @@
<IsPartOfProject Value="True"/>
<CursorPos X="30" Y="34"/>
<TopLine Value="22"/>
<UsageCount Value="86"/>
<UsageCount Value="96"/>
</Unit72>
<Unit73>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-image/src/fpcanvas.inc"/>
@ -697,9 +697,7 @@
<UnitName Value="colour_conv"/>
<CursorPos X="11" Y="148"/>
<TopLine Value="140"/>
<EditorIndex Value="1"/>
<UsageCount Value="69"/>
<Loaded Value="True"/>
<UsageCount Value="79"/>
</Unit92>
<Unit93>
<Filename Value="../../../cogat/Units/CogatUnits/compcolors.pas"/>
@ -710,17 +708,15 @@
</Unit93>
<Unit94>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/mouse.inc"/>
<CursorPos X="65" Y="9"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
<UsageCount Value="11"/>
</Unit94>
<Unit95>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit95>
<Unit96>
<Filename Value="../../Units/PascalScript/uPSCompiler.pas"/>
@ -760,7 +756,7 @@
<UnitName Value="plugins"/>
<CursorPos X="86" Y="128"/>
<TopLine Value="128"/>
<UsageCount Value="63"/>
<UsageCount Value="73"/>
</Unit101>
<Unit102>
<Filename Value="../../../Compilertje/Units/CogatUnits/compfiles.pas"/>
@ -842,17 +838,21 @@
<Unit114>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<UnitName Value="compDTM"/>
<CursorPos X="1" Y="44"/>
<TopLine Value="41"/>
<UsageCount Value="11"/>
<CursorPos X="29" Y="11"/>
<TopLine Value="11"/>
<EditorIndex Value="5"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit114>
<Unit115>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dtm"/>
<CursorPos X="52" Y="15"/>
<TopLine Value="1"/>
<UsageCount Value="44"/>
<CursorPos X="30" Y="133"/>
<TopLine Value="104"/>
<EditorIndex Value="3"/>
<UsageCount Value="54"/>
<Loaded Value="True"/>
</Unit115>
<Unit116>
<Filename Value="../../../cogat/Units/CogatUnits/comppicker.pas"/>
@ -867,18 +867,14 @@
<UnitName Value="colourpicker"/>
<CursorPos X="27" Y="34"/>
<TopLine Value="13"/>
<EditorIndex Value="5"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
<UsageCount Value="50"/>
</Unit117>
<Unit118>
<Filename Value="../../../cogat/Units/CogatUnits/compdragger.pas"/>
<UnitName Value="CompDragger"/>
<CursorPos X="101" Y="26"/>
<TopLine Value="26"/>
<EditorIndex Value="12"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit118>
<Unit119>
<Filename Value="../../../cogat/mainform.pas"/>
@ -896,9 +892,7 @@
<UnitName Value="windowselector"/>
<CursorPos X="76" Y="83"/>
<TopLine Value="65"/>
<EditorIndex Value="13"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
<UsageCount Value="40"/>
</Unit120>
<Unit121>
<Filename Value="../../../../../../usr/lib64/fpc/2.2.4/source/rtl/objpas/classes/classesh.inc"/>
@ -926,104 +920,153 @@
<TopLine Value="59"/>
<UsageCount Value="10"/>
</Unit124>
<Unit125>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dtmutil"/>
<CursorPos X="1" Y="17"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<UsageCount Value="27"/>
<Loaded Value="True"/>
</Unit125>
<Unit126>
<Filename Value="../../../cogat/Units/CogatUnits/compmaths.pas"/>
<UnitName Value="CompMaths"/>
<CursorPos X="1" Y="226"/>
<TopLine Value="211"/>
<UsageCount Value="11"/>
</Unit126>
<Unit127>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/dtm.inc"/>
<CursorPos X="85" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="10"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit127>
</Units>
<JumpHistory Count="24" HistoryIndex="23">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="testunit.pas"/>
<Caret Line="25" Column="37" TopLine="25"/>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="79" Column="21" TopLine="61"/>
</Position1>
<Position2>
<Filename Value="testunit.pas"/>
<Caret Line="46" Column="25" TopLine="25"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="22" Column="4" TopLine="6"/>
</Position2>
<Position3>
<Filename Value="testunit.pas"/>
<Caret Line="47" Column="25" TopLine="25"/>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="79" Column="9" TopLine="61"/>
</Position3>
<Position4>
<Filename Value="testunit.pas"/>
<Caret Line="136" Column="48" TopLine="108"/>
<Filename Value="../../Units/MMLCore/dtmutil.pas"/>
<Caret Line="23" Column="1" TopLine="11"/>
</Position4>
<Position5>
<Filename Value="testunit.pas"/>
<Caret Line="139" Column="15" TopLine="117"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="118" Column="25" TopLine="95"/>
</Position5>
<Position6>
<Filename Value="project1.lpr"/>
<Caret Line="7" Column="10" TopLine="1"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="199" Column="23" TopLine="131"/>
</Position6>
<Position7>
<Filename Value="testunit.pas"/>
<Caret Line="92" Column="29" TopLine="73"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="103" Column="7" TopLine="88"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="11" Column="86" TopLine="2"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="11" Column="42" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="32" Column="38" TopLine="2"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="291" Column="31" TopLine="276"/>
</Position9>
<Position10>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="307" Column="52" TopLine="269"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="10" Column="45" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="48" Column="71" TopLine="10"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="5" Column="49" TopLine="1"/>
</Position11>
<Position12>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="238" Column="59" TopLine="233"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="263" Column="31" TopLine="263"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="33" Column="65" TopLine="13"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="80" Column="60" TopLine="68"/>
</Position13>
<Position14>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="285" Column="5" TopLine="253"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="269" Column="53" TopLine="18"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="134" Column="22" TopLine="108"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="306" Column="48" TopLine="291"/>
</Position15>
<Position16>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/other.inc"/>
<Caret Line="16" Column="12" TopLine="1"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="1" Column="77" TopLine="1"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="134" Column="22" TopLine="108"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="12" Column="63" TopLine="1"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="112" Column="19" TopLine="79"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="7" Column="46" TopLine="1"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="176" Column="20" TopLine="151"/>
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<Caret Line="6" Column="63" TopLine="1"/>
</Position19>
<Position20>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="134" Column="24" TopLine="115"/>
<Filename Value="../../../cogat/Units/CogatUnits/compdtm.pas"/>
<Caret Line="11" Column="29" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="176" Column="7" TopLine="146"/>
<Filename Value="../../../cogat/Units/CogatUnits/comptypes.pas"/>
<Caret Line="11" Column="40" TopLine="1"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="179" Column="71" TopLine="157"/>
<Filename Value="../../../cogat/Units/CogatUnits/comptypes.pas"/>
<Caret Line="137" Column="11" TopLine="122"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLCore/finder.pas"/>
<Caret Line="302" Column="15" TopLine="283"/>
<Filename Value="../../../cogat/Units/CogatUnits/comptypes.pas"/>
<Caret Line="138" Column="17" TopLine="122"/>
</Position23>
<Position24>
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
<Caret Line="19" Column="19" TopLine="4"/>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="40" Column="55" TopLine="27"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="44" Column="27" TopLine="27"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="139" Column="22" TopLine="121"/>
</Position26>
<Position27>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="138" Column="22" TopLine="121"/>
</Position27>
<Position28>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="139" Column="32" TopLine="121"/>
</Position28>
<Position29>
<Filename Value="../../Units/MMLAddon/mmlpsthread.pas"/>
<Caret Line="177" Column="18" TopLine="174"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLAddon/PSInc/pscompile.inc"/>
<Caret Line="15" Column="1" TopLine="1"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -9,7 +9,7 @@ uses
Interfaces, // this includes the LCL widgetset
Forms, LResources, Window, files, MufasaTypes, Client, TestUnit, finder,
MMLThread, mmlpsthread, bitmaps, colour_conv, plugins, DTM, colourpicker,
windowselector;
windowselector, dtmutil;
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}

View File

@ -1,7 +1,7 @@
object Form1: TForm1
Left = 354
Left = 436
Height = 541
Top = 208
Top = 110
Width = 763
ActiveControl = SynEdit1
Caption = 'Mufasa v2'
@ -25,7 +25,6 @@ object Form1: TForm1
ParentColor = False
ParentFont = False
TabOrder = 0
BookMarkOptions.OnChange = nil
Gutter.Width = 61
Gutter.MouseActions = <
item

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
begin
Result := CurrThread.Client.MDTM.FindDTM(DTM, x, y, x1, y1, x2, y2);
end;
function ps_StringFromDTM(DTMString: String): Integer;
var
dtm: pDTM;
begin
With CurrThread.Client.MDTM do
begin
dtm := StringToDTM(DTMString);
Result := AddpDTM(dtm);
end;
end;
procedure ps_FreeDTM(DTM: Integer);
begin
CurrThread.Client.MDTM.FreeDTM(DTM);
end;

View File

@ -3,10 +3,17 @@ Sender.Comp.AddTypeS('TIntegerArray', 'Array of integer');
Sender.Comp.AddTypeS('TPointArray','Array of TPoint');
Sender.Comp.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)');
//Sender.Comp.AddTypeS('pDTM','pDTM = record p: TPointArray; c, t, asz, ash: TIntegerArray; end');
Sender.AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;');
Sender.AddFunction(@psWriteln,'procedure writeln(s : string);');
{ DTM }
Sender.AddFunction(@ps_StringFromDTM, 'function StringFromDTM(DTMString: String): Integer;');
Sender.AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);');
Sender.AddFunction(@FindDTM, 'function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;');
{maths}
sender.AddFunction(@power,'function pow(base,exponent : extended) : extended');

View File

@ -136,6 +136,7 @@ end;
{$I PSInc/Wrappers/colour.inc}
{$I PSInc/Wrappers/math.inc}
{$I PSInc/Wrappers/mouse.inc}
{$I PSInc/Wrappers/dtm.inc}

View File

@ -5,16 +5,49 @@ unit dtm;
interface
uses
Classes, SysUtils;
Classes, SysUtils, MufasaTypes;
type
TMDTM = class(TObject)
constructor Create(Owner: TObject);
destructor Destroy; override;
constructor Create(Owner: TObject);
destructor Destroy; override;
function AddDTM(d: TDTM): Integer;
function AddpDTM(d: pDTM): Integer;
function GetDTM(index: Integer; var dtm: pDTM): Boolean;
procedure FreeDTM(DTM: Integer);
Function StringToDTM(S: String): pDTM;
function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2,
y2: Integer): Boolean;
{ function FindDTMs(DTM: Integer; var Points: TPointArray; x1, y1, x2,
y2: Integer): Boolean;
function FindDTMRotated(DTM: Integer; var x, y: Integer; x1, y1, x2,
y2: Integer; sAngle, eAngle, aStep: Extended;
var aFound: Extended): Boolean;
function FindDTMsRotated(DTM: Integer; var Points: TPointArray; x1,
y1, x2, y2: Integer; sAngle, eAngle,
aStep: Extended; var aFound: T2DExtendedArray)
: Boolean; }
function pFindDTM(DTM: pDTM; var x, y: Integer; x1, y1, x2, y2:
Integer): Boolean;
private
Client: TObject;
// For decompressing.
BufferString: String;
DTMList: Array Of pDTM;
FreeSpots: Array Of Integer;
end;
const
dtm_Rectangle = 0;
dtm_Cross = 1;
dtm_DiagonalCross = 2;
dtm_Circle = 3;
dtm_Triangle = 4;
{
I am not sure wether I should simply copy and paste the old DTM implementation,
@ -36,22 +69,254 @@ type
~Wizz
}
implementation
uses
Client;
Client, dtmutil, paszlib;
type
TBufferByteArray = Array[0..524288] of Byte;
PBufferByteArray = ^TBufferByteArray;
constructor TMDTM.Create(Owner: TObject);
begin
inherited Create;
Self.Client := Owner;
SetLength(DTMList, 0);
SetLength(FreeSpots, 0);
SetLength(BufferString, 524288);
end;
destructor TMDTM.Destroy;
begin
//Something
SetLength(DTMList, 0);
SetLength(FreeSpots, 0);
SetLength(BufferString, 0);
inherited Destroy;
end;
function HexToInt(HexNum: string): LongInt;inline;
begin
Result:=StrToInt('$' + HexNum);
end;
function TMDTM.StringToDTM(S: String): pDTM;
var
b: PBufferByteArray;
Source : String;
DestLen : LongWord;
i,ii,c : integer;
begin
SetLength(Result.p,0);
SetLength(Result.c,0);
SetLength(Result.t,0);
SetLength(Result.asz,0);
SetLength(Result.ash,0);
ii := Length(S);
if (ii = 0) or (ii mod 2 <> 0) then
Exit;
ii := ii div 2;
SetLength(Source,ii);
for i := 1 to ii do
Source[i] := Chr(HexToInt(S[i * 2 - 1] + S[i * 2]));
DestLen := Length(Self.BufferString);
if uncompress(PChar(Self.Bufferstring),Destlen,pchar(Source), ii) = Z_OK then
begin;
if (Destlen mod 36) > 0 then
begin;
Writeln('Invalid DTM');
Exit;
end;
DestLen := DestLen div 36;
SetLength(Result.p,DestLen);
SetLength(Result.c,DestLen);
SetLength(Result.t,DestLen);
SetLength(Result.asz,DestLen);
SetLength(Result.ash,DestLen);
b := @Self.Bufferstring[1];
for i := 0 to DestLen - 1 do
begin;
c := i * 36;
Result.p[i].x := PInteger(@b^[c+1])^;
Result.p[i].y := PInteger(@b^[c+5])^;
Result.asz[i] := PInteger(@b^[c+12])^;
Result.ash[i] := PInteger(@b^[c+16])^;
Result.c[i] := PInteger(@b^[c+20])^;
Result.t[i] := PInteger(@b^[c+24])^;
end;
end;
end;
function TMDTM.AddDTM(d: TDTM): Integer;
begin
if Length(FreeSpots) > 0 then
begin
DTMList[FreeSpots[High(FreeSpots)]] := TDTMTopDTM(d);
Result := FreeSpots[High(FreeSpots)];
SetLength(FreeSpots, High(FreeSpots));
end
else
begin
SetLength(DTMList, Length(DTMList) + 1);
DTMList[High(DTMList)] := TDTMTopDTM(d);
Result := High(DTMList);
end;
end;
{/\
Adds the given pDTM to the DTM Array, and returns it's index.
/\}
function TMDTM.AddpDTM(d: pDTM): Integer;
begin
if Length(FreeSpots) > 0 then
begin
DTMList[FreeSpots[High(FreeSpots)]] := d;
Result := FreeSpots[High(FreeSpots)];
SetLength(FreeSpots, High(FreeSpots));
end
Else
begin
SetLength(DTMList, Length(DTMList) + 1);
DTMList[High(DTMList)] := d;
Result := High(DTMList);
end;
end;
{/\
Returns the DTM (pDTM type) in the variable dtm at the given index.
Returns true is succesfull, false if the dtm does not exist.
/\}
function TMDTM.GetDTM(index: Integer; var dtm: pDTM): Boolean;
begin
Result := True;
try
dtm := DTMList[index];
except
begin
raise Exception.CreateFmt('The given DTM Index ([%d]) is invalid.',
[index]);
//WriteLn('DTM Index ' + IntToStr(index) + ' does not exist');
Result := False;
end;
end
end;
{/\
Unloads the DTM at the given index from the DTM Array.
Notes:
Will keep track of not used index, so it is very memory efficient.
/\}
Procedure TMDTM.FreeDTM(DTM: Integer);
begin
try
SetLength(DTMList[DTM].p, 0);
SetLength(DTMList[DTM].c, 0);
SetLength(DTMList[DTM].t, 0);
SetLength(DTMList[DTM].asz, 0);
SetLength(DTMList[DTM].ash, 0);
except
//WriteLn('Invalid DTM');
end;
SetLength(FreeSpots, Length(FreeSpots) + 1);
FreeSpots[High(FreeSpots)] := DTM;
end;
{
Tries to find the given DTM (index). If found will put the point the dtm has
been found at in x, y and result to true.
}
function TMDTM.FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
var
temp: pDTM;
begin
if GetDTM(DTM, temp) then
Result := pFindDTM(temp, x, y, x1, y1, x2, y2)
else
begin
x := 0;
y := 0;
Result := False;
end;
end;
{
Tries to find the given pDTM. If found will put the point the dtm has
been found at in x, y and result to true.
}
function TMDTM.pFindDTM(DTM: pDTM; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;
var
mP: TPointArray;
I, J, H, dH: Integer;
Found: Boolean;
TempTP: TPoint;
RetData: TRetData;
begin
for I := 1 to High(DTM.p) do
begin
DTM.p[I].x := DTM.p[I].x - DTM.p[0].x;
DTM.p[I].y := DTM.p[I].y - DTM.p[0].y;
end;
// X2 := X2 - MaxSubPointDist.X
// Y2 := Y2 - MaxSubPointDist.Y
// X1 := X1 + MaxSubPointDist.X
// Y1 := Y1 + MaxSubPointDist.Y
// If X2 > X1 then Exit
// If Y2 > Y1 then Exit
// Will make sure there are no out of bounds exceptions, and will make it faster
TClient(Client).MWindow.Freeze();
TClient(Client).MFinder.FindColorsTolerance(mP, DTM.c[Low(DTM.c)],
x1, y1, x2, y2, DTM.t[Low(DTM.t)]);
TClient(Client).MWindow.GetDimensions(H, dH);
RetData := TClient(Client).MWindow.ReturnData(0, 0, H, dH);
H := High(mP);
dH := High(DTM.p);
for I := 0 to H do
begin
// Use MainPoint's AreaSize and Shape.
// for Loop on mP, depending on the AreaShape. then on all the code beneath
// this point, use the var that is retrieved from the for loop.
Found := True;
for J := 1 to dH do
begin
TempTP.X := DTM.p[J].X + mP[I].X;
TempTP.Y := DTM.p[J].Y + mP[I].Y;
//Now would be the time to Rotate TempTP
//If Not AreaShape(DTM.c[J], DTM.t[J], DTM.asz[J], DTM.ash[J], TempTP) then
if False then
begin
Found := False;
Break;
end;
end;
if Found then
begin
Result := True;
x := mP[I].X;
y := mP[I].Y;
TClient(Client).MWindow.UnFreeze();
Exit;
end;
end;
TClient(Client).MWindow.UnFreeze();
Result := False;
end;
end.

View File

@ -10,6 +10,7 @@ uses
windowutil // for mufasa window utils
{$IFDEF LINUX}
,x, xlib // for X* stuff
// do non silent keys with XTest.
{$ENDIF};
type
TMInput = class(TObject)

View File

@ -28,6 +28,28 @@ type
TPointArray = array of TPoint;
TVariantArray = Array of Variant;
TIntegerArray = Array of Integer;
T2DExtendedArray = Array of Array of Extended;
{ DTM Types }
pDTM = record
p: TPointArray;
c, t, asz, ash: TIntegerArray;
end;
{ Other DTM Types }
TDTMPointDef = record
x, y, Color, Tolerance, AreaSize, AreaShape: integer;
end;
TDTMPointDefArray = Array Of TDTMPointDef;
TDTM = record
MainPoint: TDTMPointDef;
SubPoints: TDTMPointDefArray;
end;
var
PluginsGlob : TMPlugins;