1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-23 07:48:50 -05:00

Property changes, and a workaround for a - for now unknown - bug.

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@28 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Wizzup? 2009-09-04 18:20:45 +00:00
parent badc4a3c3b
commit faca7515f0
5 changed files with 227 additions and 221 deletions

View File

@ -38,7 +38,7 @@
<CursorPos X="41" Y="17"/> <CursorPos X="41" Y="17"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="55"/> <UsageCount Value="58"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -167,10 +167,10 @@
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="46" Y="50"/> <CursorPos X="61" Y="24"/>
<TopLine Value="38"/> <TopLine Value="91"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<UsageCount Value="21"/> <UsageCount Value="24"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
@ -299,20 +299,20 @@
<Filename Value="../../Units/MMLCore/client.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Client"/> <UnitName Value="Client"/>
<CursorPos X="30" Y="29"/> <CursorPos X="34" Y="29"/>
<TopLine Value="14"/> <TopLine Value="14"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<UsageCount Value="20"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit37> </Unit37>
<Unit38> <Unit38>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/> <Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="MufasaTypes"/> <UnitName Value="MufasaTypes"/>
<CursorPos X="1" Y="1"/> <CursorPos X="3" Y="16"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<UsageCount Value="20"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit38> </Unit38>
<Unit39> <Unit39>
@ -321,27 +321,27 @@
<CursorPos X="18" Y="8"/> <CursorPos X="18" Y="8"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="6"/> <EditorIndex Value="6"/>
<UsageCount Value="20"/> <UsageCount Value="21"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit39> </Unit39>
<Unit40> <Unit40>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="files"/> <UnitName Value="files"/>
<CursorPos X="54" Y="19"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="5"/> <EditorIndex Value="5"/>
<UsageCount Value="21"/> <UsageCount Value="24"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit40> </Unit40>
<Unit41> <Unit41>
<Filename Value="../../Units/MMLCore/window.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Window"/> <UnitName Value="Window"/>
<CursorPos X="15" Y="40"/> <CursorPos X="49" Y="38"/>
<TopLine Value="1"/> <TopLine Value="11"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<UsageCount Value="20"/> <UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit41> </Unit41>
<Unit42> <Unit42>
@ -357,130 +357,130 @@
<CursorPos X="80" Y="9"/> <CursorPos X="80" Y="9"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<UsageCount Value="10"/> <UsageCount Value="11"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit43> </Unit43>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="project1.lpr"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="17" Column="17" TopLine="1"/> <Caret Line="43" Column="20" TopLine="28"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="13" Column="20" TopLine="7"/> <Caret Line="55" Column="24" TopLine="40"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="../../../cogat/Units/CogatUnits/compfiles.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="30" Column="22" TopLine="11"/> <Caret Line="36" Column="27" TopLine="31"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="../../../cogat/Units/CogatUnits/compfiles.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="31" Column="23" TopLine="11"/> <Caret Line="41" Column="46" TopLine="31"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="439" Column="74" TopLine="11"/> <Caret Line="463" Column="34" TopLine="448"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="43" Column="20" TopLine="28"/> <Caret Line="34" Column="12" TopLine="30"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="55" Column="24" TopLine="40"/> <Caret Line="46" Column="19" TopLine="31"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="36" Column="27" TopLine="31"/> <Caret Line="72" Column="19" TopLine="50"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="41" Column="46" TopLine="31"/> <Caret Line="37" Column="11" TopLine="21"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="463" Column="34" TopLine="448"/> <Caret Line="38" Column="96" TopLine="28"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="34" Column="12" TopLine="30"/> <Caret Line="417" Column="42" TopLine="402"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="46" Column="19" TopLine="31"/> <Caret Line="449" Column="1" TopLine="431"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="72" Column="19" TopLine="50"/> <Caret Line="37" Column="18" TopLine="12"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../Units/MMLCore/files.pas"/>
<Caret Line="37" Column="11" TopLine="21"/> <Caret Line="20" Column="29" TopLine="11"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="38" Column="96" TopLine="28"/> <Caret Line="211" Column="1" TopLine="182"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="417" Column="42" TopLine="402"/> <Caret Line="154" Column="49" TopLine="140"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="449" Column="1" TopLine="431"/> <Caret Line="155" Column="8" TopLine="140"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="../../Units/MMLCore/client.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="37" Column="18" TopLine="12"/> <Caret Line="160" Column="23" TopLine="145"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="../../Units/MMLCore/files.pas"/> <Filename Value="../../../cogat/Units/CogatUnits/compfiles.pas"/>
<Caret Line="20" Column="29" TopLine="11"/> <Caret Line="8" Column="18" TopLine="1"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="211" Column="1" TopLine="182"/> <Caret Line="29" Column="14" TopLine="11"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="154" Column="49" TopLine="140"/> <Caret Line="161" Column="39" TopLine="146"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="155" Column="8" TopLine="140"/> <Caret Line="29" Column="20" TopLine="16"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="160" Column="23" TopLine="145"/> <Caret Line="51" Column="14" TopLine="46"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="../../../cogat/Units/CogatUnits/compfiles.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="8" Column="18" TopLine="1"/> <Caret Line="54" Column="17" TopLine="48"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="29" Column="14" TopLine="11"/> <Caret Line="31" Column="71" TopLine="14"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="testunit.pas"/> <Filename Value="testunit.pas"/>
<Caret Line="161" Column="39" TopLine="146"/> <Caret Line="137" Column="62" TopLine="121"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="29" Column="20" TopLine="16"/> <Caret Line="157" Column="52" TopLine="141"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="51" Column="14" TopLine="46"/> <Caret Line="232" Column="59" TopLine="217"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="testunit.pas"/> <Filename Value="../../Units/MMLCore/window.pas"/>
<Caret Line="54" Column="17" TopLine="48"/> <Caret Line="236" Column="29" TopLine="217"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="../../Units/MMLCore/client.pas"/> <Filename Value="../../Units/MMLCore/client.pas"/>
<Caret Line="31" Column="71" TopLine="14"/> <Caret Line="1" Column="1" TopLine="1"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>

View File

@ -26,7 +26,7 @@ constructor TClient.Create;
begin begin
inherited Create; inherited Create;
MWindow := TMWindow.Create(); MWindow := TMWindow.Create(Self);
MInput := TMInput.Create(Self); MInput := TMInput.Create(Self);
MFiles := TMFiles.Create; MFiles := TMFiles.Create;
end; end;

View File

@ -1,30 +1,31 @@
unit MufasaTypes; unit MufasaTypes;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils; Classes, SysUtils;
type type
TRGB32 = packed record TRGB32 = packed record
B, G, R, A: Byte; B, G, R, A: Byte;
end; end;
PRGB32 = ^TRGB32; PRGB32 = ^TRGB32;
TRetData = record
Ptr : PRGB32; TRetData = record
IncPtrWith : integer; Ptr : PRGB32;
end; IncPtrWith : integer;
end;
TTargetWindowMode = (w_BMP, w_Window, w_HDC, w_ArrayPtr, w_XWindow);
TClickType = (mouse_Left, mouse_Right, mouse_Middle); TTargetWindowMode = (w_BMP, w_Window, w_HDC, w_ArrayPtr, w_XWindow);
TMousePress = (mouse_Down, mouse_Up); TClickType = (mouse_Left, mouse_Right, mouse_Middle);
TMousePress = (mouse_Down, mouse_Up);
implementation
implementation
end.
end.

View File

@ -35,9 +35,12 @@ type
function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload; function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload;
function SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload; function SetTarget(ArrPtr: PRGB32; Size: TPoint): integer; overload;
constructor Create; constructor Create(Client: TObject);
destructor Destroy; override; destructor Destroy; override;
public public
// Client
Client: TObject;
// Target Window Mode. // Target Window Mode.
TargetMode: TTargetWindowMode; TargetMode: TTargetWindowMode;
@ -104,10 +107,12 @@ uses
GraphType // For TRawImage GraphType // For TRawImage
; ;
constructor TMWindow.Create; constructor TMWindow.Create(Client: TObject);
begin begin
inherited Create; inherited Create;
Self.Client := Client;
Self.ArrayPtr := nil; Self.ArrayPtr := nil;
Self.ArraySize := Classes.Point(-1, -1); Self.ArraySize := Classes.Point(-1, -1);

View File

@ -1,129 +1,129 @@
unit windowutil; unit windowutil;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, Classes, SysUtils,
ctypes, // for cint, etc ctypes, // for cint, etc
GraphType, // For TRawImage GraphType, // For TRawImage
{$IFDEF LINUX} {$IFDEF LINUX}
x, xlib, // For X* stuff. x, xlib, // For X* stuff.
{$ENDIF} {$ENDIF}
mufasatypes; mufasatypes;
{$IFDEF LINUX} {$IFDEF LINUX}
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage); Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl; function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
{$ENDIF} {$ENDIF}
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage); Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
implementation implementation
{$IFDEF LINUX} {$IFDEF LINUX}
// Too global. // Too global.
function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl; function MufasaXErrorHandler(para1:PDisplay; para2:PXErrorEvent):cint;cdecl;
begin; begin;
result := 0; result := 0;
Writeln('X Error: '); Writeln('X Error: ');
writeln('Error code: ' + inttostr(para2^.error_code)); writeln('Error code: ' + inttostr(para2^.error_code));
writeln('Display: ' + inttostr(LongWord(para2^.display))); writeln('Display: ' + inttostr(LongWord(para2^.display)));
writeln('Minor code: ' + inttostr(para2^.minor_code)); writeln('Minor code: ' + inttostr(para2^.minor_code));
writeln('Request code: ' + inttostr(para2^.request_code)); writeln('Request code: ' + inttostr(para2^.request_code));
writeln('Resource ID: ' + inttostr(para2^.resourceid)); writeln('Resource ID: ' + inttostr(para2^.resourceid));
writeln('Serial: ' + inttostr(para2^.serial)); writeln('Serial: ' + inttostr(para2^.serial));
writeln('Type: ' + inttostr(para2^._type)); writeln('Type: ' + inttostr(para2^._type));
end; end;
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage); Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
Begin Begin
RawImage.Init; { Calls raw.Description.Init as well } RawImage.Init; { Calls raw.Description.Init as well }
RawImage.Description.PaletteColorCount:=0; RawImage.Description.PaletteColorCount:=0;
RawImage.Description.MaskBitsPerPixel:=0; RawImage.Description.MaskBitsPerPixel:=0;
RawImage.Description.Width := XImg^.width; RawImage.Description.Width := XImg^.width;
RawImage.Description.Height:= XImg^.height; RawImage.Description.Height:= XImg^.height;
RawImage.Description.Format := ricfRGBA; RawImage.Description.Format := ricfRGBA;
if XImg^.byte_order = LSBFirst then if XImg^.byte_order = LSBFirst then
RawImage.Description.ByteOrder := riboLSBFirst RawImage.Description.ByteOrder := riboLSBFirst
else else
RawImage.Description.ByteOrder:= riboMSBFirst; RawImage.Description.ByteOrder:= riboMSBFirst;
RawImage.Description.BitOrder:= riboBitsInOrder; // should be fine RawImage.Description.BitOrder:= riboBitsInOrder; // should be fine
RawImage.Description.Depth:=XImg^.depth; RawImage.Description.Depth:=XImg^.depth;
RawImage.Description.BitsPerPixel:=XImg^.bits_per_pixel; RawImage.Description.BitsPerPixel:=XImg^.bits_per_pixel;
RawImage.Description.LineOrder:=riloTopToBottom; RawImage.Description.LineOrder:=riloTopToBottom;
RawImage.Description.LineEnd := rileDWordBoundary; RawImage.Description.LineEnd := rileDWordBoundary;
RawImage.Description.RedPrec := 8; RawImage.Description.RedPrec := 8;
RawImage.Description.GreenPrec:= 8; RawImage.Description.GreenPrec:= 8;
RawImage.Description.BluePrec:= 8; RawImage.Description.BluePrec:= 8;
RawImage.Description.AlphaPrec:=0; RawImage.Description.AlphaPrec:=0;
// Can be adjusted to the XImage RedMask, etc. // Can be adjusted to the XImage RedMask, etc.
// For now I just assume the tester uses BGR. // For now I just assume the tester uses BGR.
RawImage.Description.RedShift:=16; RawImage.Description.RedShift:=16;
RawImage.Description.GreenShift:=8; RawImage.Description.GreenShift:=8;
RawImage.Description.BlueShift:=0; RawImage.Description.BlueShift:=0;
RawImage.DataSize := RawImage.Description.Width * RawImage.Description.Height RawImage.DataSize := RawImage.Description.Width * RawImage.Description.Height
* (RawImage.Description.bitsperpixel shr 3); * (RawImage.Description.bitsperpixel shr 3);
//RawImage.DataSize := RawImage.Description.Height * RawImage.Description.BitsPerLine; //RawImage.DataSize := RawImage.Description.Height * RawImage.Description.BitsPerLine;
RawImage.Data := PByte(XImg^.data); RawImage.Data := PByte(XImg^.data);
End; End;
{$ENDIF} {$ENDIF}
Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage); Procedure ArrDataToRawImage(Ptr: PRGB32; Size: TPoint; Var RawImage: TRawImage);
Begin Begin
RawImage.Init; { Calls raw.Description.Init as well } RawImage.Init; { Calls raw.Description.Init as well }
RawImage.Description.PaletteColorCount:=0; RawImage.Description.PaletteColorCount:=0;
RawImage.Description.MaskBitsPerPixel:=0; RawImage.Description.MaskBitsPerPixel:=0;
RawImage.Description.Width := Size.X; RawImage.Description.Width := Size.X;
RawImage.Description.Height:= Size.Y; RawImage.Description.Height:= Size.Y;
RawImage.Description.Format := ricfRGBA; RawImage.Description.Format := ricfRGBA;
RawImage.Description.ByteOrder := riboLSBFirst; RawImage.Description.ByteOrder := riboLSBFirst;
RawImage.Description.BitOrder:= riboBitsInOrder; // should be fine RawImage.Description.BitOrder:= riboBitsInOrder; // should be fine
RawImage.Description.Depth:=24; RawImage.Description.Depth:=24;
RawImage.Description.BitsPerPixel:=32; RawImage.Description.BitsPerPixel:=32;
RawImage.Description.LineOrder:=riloTopToBottom; RawImage.Description.LineOrder:=riloTopToBottom;
RawImage.Description.LineEnd := rileDWordBoundary; RawImage.Description.LineEnd := rileDWordBoundary;
RawImage.Description.RedPrec := 8; RawImage.Description.RedPrec := 8;
RawImage.Description.GreenPrec:= 8; RawImage.Description.GreenPrec:= 8;
RawImage.Description.BluePrec:= 8; RawImage.Description.BluePrec:= 8;
RawImage.Description.AlphaPrec:=0; RawImage.Description.AlphaPrec:=0;
RawImage.Description.RedShift:=16; RawImage.Description.RedShift:=16;
RawImage.Description.GreenShift:=8; RawImage.Description.GreenShift:=8;
RawImage.Description.BlueShift:=0; RawImage.Description.BlueShift:=0;
RawImage.DataSize := RawImage.Description.Width * RawImage.Description.Height RawImage.DataSize := RawImage.Description.Width * RawImage.Description.Height
* (RawImage.Description.bitsperpixel shr 3); * (RawImage.Description.bitsperpixel shr 3);
RawImage.Data := PByte(Ptr); RawImage.Data := PByte(Ptr);
End; End;
end. end.