1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-12-22 15:28:50 -05:00

Merge ssh://villavu.com:54367/simba

This commit is contained in:
Niels 2010-09-17 20:01:22 +02:00
commit a231790b6b
19 changed files with 624 additions and 294 deletions

View File

@ -1,21 +1,16 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="7"/>
<Version Value="9"/>
<General>
<Flags>
<UseDefaultCompilerOptions Value="True"/>
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=""/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<VersionInfo>
<Language Value=""/>
<CharSet Value=""/>
<StringTable Comments="" CompanyName="" FileDescription="" FileVersion="" InternalName="" LegalCopyright="" LegalTrademarks="" OriginalFilename="" ProductName="" ProductVersion=""/>
<StringTable ProductVersion=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
@ -34,12 +29,12 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="10">
<Units Count="23">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<UsageCount Value="37"/>
<UsageCount Value="43"/>
</Unit0>
<Unit1>
<Filename Value="scriptmanager.pas"/>
@ -50,18 +45,18 @@
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="83"/>
<CursorPos X="15" Y="118"/>
<UsageCount Value="37"/>
<TopLine Value="251"/>
<CursorPos X="3" Y="195"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../../lazarus/lcl/interfaces/gtk/gtkwidgetset.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="1276"/>
<CursorPos X="1" Y="1294"/>
<UsageCount Value="8"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
<UsageCount Value="7"/>
</Unit2>
<Unit3>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
@ -69,16 +64,16 @@
<WindowIndex Value="0"/>
<TopLine Value="112"/>
<CursorPos X="79" Y="138"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</Unit3>
<Unit4>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<UnitName Value="settings"/>
<EditorIndex Value="1"/>
<EditorIndex Value="13"/>
<WindowIndex Value="0"/>
<TopLine Value="85"/>
<CursorPos X="29" Y="94"/>
<UsageCount Value="13"/>
<TopLine Value="132"/>
<CursorPos X="3" Y="169"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@ -87,26 +82,26 @@
<WindowIndex Value="0"/>
<TopLine Value="11"/>
<CursorPos X="64" Y="29"/>
<UsageCount Value="9"/>
<UsageCount Value="8"/>
</Unit5>
<Unit6>
<Filename Value="../../Units/MMLCore/mufasatypes.pas"/>
<UnitName Value="MufasaTypes"/>
<EditorIndex Value="3"/>
<EditorIndex Value="16"/>
<WindowIndex Value="0"/>
<TopLine Value="23"/>
<CursorPos X="1" Y="1"/>
<UsageCount Value="13"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="../../Units/MMLCore/mufasabase.pas"/>
<UnitName Value="mufasabase"/>
<EditorIndex Value="2"/>
<EditorIndex Value="15"/>
<WindowIndex Value="0"/>
<TopLine Value="7"/>
<CursorPos X="1" Y="1"/>
<UsageCount Value="13"/>
<UsageCount Value="16"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
@ -114,168 +109,277 @@
<WindowIndex Value="0"/>
<TopLine Value="2214"/>
<CursorPos X="1" Y="2232"/>
<SyntaxHighlighter Value="Delphi"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="Text"/>
<UsageCount Value="9"/>
</Unit8>
<Unit9>
<Filename Value="../../../fpc/rtl/inc/objpash.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="183"/>
<CursorPos X="21" Y="201"/>
<SyntaxHighlighter Value="Delphi"/>
<UsageCount Value="10"/>
<DefaultSyntaxHighlighter Value="Text"/>
<UsageCount Value="9"/>
</Unit9>
<Unit10>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/xmlread.pp"/>
<UnitName Value="XMLRead"/>
<EditorIndex Value="14"/>
<WindowIndex Value="0"/>
<TopLine Value="21"/>
<CursorPos X="11" Y="47"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<UnitName Value="updater"/>
<EditorIndex Value="10"/>
<WindowIndex Value="0"/>
<TopLine Value="97"/>
<CursorPos X="21" Y="102"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="../Simba/psextension.pas"/>
<UnitName Value="psextension"/>
<EditorIndex Value="11"/>
<WindowIndex Value="0"/>
<TopLine Value="168"/>
<CursorPos X="29" Y="178"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="../../Units/MMLAddon/internets.pas"/>
<UnitName Value="internets"/>
<EditorIndex Value="12"/>
<WindowIndex Value="0"/>
<TopLine Value="56"/>
<CursorPos X="6" Y="61"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="../Simba/updateform.pas"/>
<UnitName Value="updateform"/>
<EditorIndex Value="9"/>
<WindowIndex Value="0"/>
<TopLine Value="66"/>
<CursorPos X="1" Y="93"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="../Simba/simbaunit.pas"/>
<UnitName Value="SimbaUnit"/>
<EditorIndex Value="8"/>
<WindowIndex Value="0"/>
<TopLine Value="2898"/>
<CursorPos X="23" Y="2893"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit15>
<Unit16>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/dom.pp"/>
<UnitName Value="DOM"/>
<EditorIndex Value="7"/>
<WindowIndex Value="0"/>
<TopLine Value="178"/>
<CursorPos X="15" Y="204"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/syswideh.inc"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="10" Y="21"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="../../Units/MMLAddon/stringutil.pas"/>
<UnitName Value="stringutil"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="118"/>
<CursorPos X="6" Y="156"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit18>
<Unit19>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/sysstrh.inc"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="77"/>
<CursorPos X="10" Y="103"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/sysstr.inc"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="501"/>
<CursorPos X="7" Y="527"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/sysutilh.inc"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="223"/>
<CursorPos X="13" Y="249"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit21>
<Unit22>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/sysutils.inc"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="122"/>
<CursorPos X="9" Y="126"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit22>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="scriptmanager.pas"/>
<Caret Line="29" Column="62" TopLine="12"/>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="605" Column="7" TopLine="593"/>
</Position1>
<Position2>
<Filename Value="scriptmanager.pas"/>
<Caret Line="31" Column="31" TopLine="12"/>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/xmlread.pp"/>
<Caret Line="3846" Column="12" TopLine="3839"/>
</Position2>
<Position3>
<Filename Value="scriptmanager.pas"/>
<Caret Line="37" Column="23" TopLine="19"/>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="606" Column="11" TopLine="593"/>
</Position3>
<Position4>
<Filename Value="scriptmanager.pas"/>
<Caret Line="64" Column="25" TopLine="36"/>
<Caret Line="32" Column="54" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="scriptmanager.pas"/>
<Caret Line="55" Column="11" TopLine="45"/>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="118" Column="8" TopLine="69"/>
</Position5>
<Position6>
<Filename Value="scriptmanager.pas"/>
<Caret Line="52" Column="5" TopLine="28"/>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="14" Column="37" TopLine="1"/>
</Position6>
<Position7>
<Filename Value="scriptmanager.pas"/>
<Caret Line="59" Column="13" TopLine="34"/>
<Filename Value="../Simba/psextension.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="63" Column="24" TopLine="52"/>
<Filename Value="../../Units/MMLAddon/internets.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="scriptmanager.pas"/>
<Caret Line="53" Column="12" TopLine="34"/>
<Filename Value="../../Units/MMLAddon/updater.pas"/>
<Caret Line="117" Column="33" TopLine="106"/>
</Position9>
<Position10>
<Filename Value="scriptmanager.pas"/>
<Caret Line="57" Column="22" TopLine="35"/>
<Caret Line="32" Column="54" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="scriptmanager.pas"/>
<Caret Line="55" Column="21" TopLine="38"/>
<Filename Value="../Simba/updateform.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position11>
<Position12>
<Filename Value="scriptmanager.pas"/>
<Caret Line="33" Column="17" TopLine="27"/>
<Filename Value="../Simba/simbaunit.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position12>
<Position13>
<Filename Value="scriptmanager.pas"/>
<Caret Line="58" Column="34" TopLine="50"/>
<Filename Value="../Simba/simbaunit.pas"/>
<Caret Line="2894" Column="10" TopLine="2879"/>
</Position13>
<Position14>
<Filename Value="scriptmanager.pas"/>
<Caret Line="54" Column="10" TopLine="36"/>
<Caret Line="218" Column="10" TopLine="173"/>
</Position14>
<Position15>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="77" Column="22" TopLine="59"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="203" Column="13" TopLine="177"/>
</Position15>
<Position16>
<Filename Value="scriptmanager.pas"/>
<Caret Line="56" Column="20" TopLine="36"/>
<Caret Line="101" Column="23" TopLine="84"/>
</Position16>
<Position17>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="253" Column="11" TopLine="230"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="218" Column="27" TopLine="178"/>
</Position17>
<Position18>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="75" Column="24" TopLine="57"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="141" Column="13" TopLine="126"/>
</Position18>
<Position19>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="194" Column="30" TopLine="177"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="240" Column="34" TopLine="203"/>
</Position19>
<Position20>
<Filename Value="scriptmanager.pas"/>
<Caret Line="54" Column="17" TopLine="38"/>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/dom.pp"/>
<Caret Line="258" Column="48" TopLine="232"/>
</Position20>
<Position21>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="77" Column="22" TopLine="59"/>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/dom.pp"/>
<Caret Line="1061" Column="16" TopLine="1053"/>
</Position21>
<Position22>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="254" Column="14" TopLine="242"/>
<Filename Value="../../../FPC/FPCCheckout/packages/fcl-xml/src/dom.pp"/>
<Caret Line="229" Column="46" TopLine="204"/>
</Position22>
<Position23>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="75" Column="24" TopLine="57"/>
<Filename Value="../Simba/simbaunit.pas"/>
<Caret Line="2867" Column="13" TopLine="2856"/>
</Position23>
<Position24>
<Filename Value="scriptmanager.pas"/>
<Caret Line="71" Column="7" TopLine="49"/>
<Caret Line="281" Column="1" TopLine="238"/>
</Position24>
<Position25>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="73" Column="23" TopLine="56"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="234" Column="22" TopLine="214"/>
</Position25>
<Position26>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="107" Column="32" TopLine="89"/>
<Filename Value="../../Units/MMLAddon/stringutil.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position26>
<Position27>
<Filename Value="scriptmanager.pas"/>
<Caret Line="60" Column="15" TopLine="38"/>
<Caret Line="212" Column="17" TopLine="187"/>
</Position27>
<Position28>
<Filename Value="scriptmanager.pas"/>
<Caret Line="62" Column="15" TopLine="27"/>
<Filename Value="../../../FPC/FPCCheckout/rtl/objpas/sysutils/sysstr.inc"/>
<Caret Line="533" Column="34" TopLine="520"/>
</Position28>
<Position29>
<Filename Value="scriptmanager.pas"/>
<Caret Line="64" Column="7" TopLine="33"/>
<Caret Line="191" Column="10" TopLine="189"/>
</Position29>
<Position30>
<Filename Value="../../Units/MMLAddon/settings.pas"/>
<Caret Line="10" Column="27" TopLine="1"/>
<Filename Value="scriptmanager.pas"/>
<Caret Line="70" Column="34" TopLine="52"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<Version Value="9"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/>
<OtherUnitFiles Value="$(ProjPath)../../Units/MMLCore/;$(ProjPath)../../Units/MMLAddon/;$(ProjPath)../../Units/PascalScript/;$(ProjPath)../../Units/Misc/;$(ProjPath)../../Units/MMLAddon/PSInc/;$(ProjPath)../../Units/Linux/;$(LazarusDir)/components/mouseandkeyinput/"/>
<OtherUnitFiles Value="$(ProjPath)../../Units/MMLCore/;$(ProjPath)../../Units/MMLAddon/;$(ProjPath)../../Units/PascalScript/;$(ProjPath)../../Units/Misc/;$(ProjPath)../../Units/MMLAddon/PSInc/;$(ProjPath)../../Units/Linux/;$(LazarusDir)/components/mouseandkeyinput/;$(ProjPath)../../Units/Synapse/"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<UseAnsiStrings Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<TargetCPU Value="x86_64"/>
<TargetOS Value="Linux"/>
</CodeGeneration>
<Linking>
<Options>
<LinkerOptions Value="-L/home/merlijn/Programs/fpc/libcross/"/>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>

View File

@ -3,9 +3,9 @@ program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
{$IFDEF UNIX}
cthreads, cmem,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, scriptmanager
{ you can add units after this };

View File

@ -35,7 +35,7 @@ object Form1: TForm1
Height = 24
Top = 440
Width = 32
DefaultItemHeight = 19
DefaultItemHeight = 15
TabOrder = 1
Visible = False
end
@ -57,31 +57,32 @@ object Form1: TForm1
Width = 520
Anchors = [akLeft, akBottom]
Caption = 'Button1'
OnClick = Button1Click
TabOrder = 3
end
object Edit1: TEdit
Left = 72
Height = 27
Top = 536
Height = 21
Top = 542
Width = 176
Anchors = [akLeft, akBottom]
TabOrder = 4
end
object Label1: TLabel
Left = 24
Height = 18
Top = 536
Width = 35
Height = 14
Top = 540
Width = 29
Anchors = [akLeft, akBottom]
Caption = 'Filter:'
ParentColor = False
end
object SearchIn: TComboBox
Left = 344
Height = 29
Height = 21
Top = 534
Width = 192
ItemHeight = 0
ItemHeight = 13
ItemIndex = 0
Items.Strings = (
'Tags, Name, Author'
@ -94,9 +95,9 @@ object Form1: TForm1
end
object Label2: TLabel
Left = 272
Height = 18
Height = 14
Top = 536
Width = 53
Width = 44
Caption = 'Filter by:'
ParentColor = False
end

View File

@ -28,8 +28,10 @@ unit scriptmanager;
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, ComCtrls, ActnList, Menus, settings, MufasaTypes;
{$IFDEF UNIX}cthreads,cmem,{$ENDIF} Classes, SysUtils, FileUtil, Forms,
Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, ComCtrls, ActnList, Menus, settings, updater,strutils, MufasaTypes,
dom;
type
@ -48,6 +50,7 @@ type
MenuItem2: TMenuItem;
ScriptPopup: TPopupMenu;
TreeView1: TTreeView;
procedure Button1Click(Sender: TObject);
procedure ClickItem(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
@ -57,24 +60,59 @@ type
{ public declarations }
end;
TSimbaScript = class(TObject)
{ TSimbaScript }
TSimbaScript = class(TObject)
private
procedure LoadFromNode( Script : TDOMNode);
public
Name, Version, Author, Description: String;
Tags, Files: TStringArray;
private
public
Tags, Files: TStringList;
procedure Dbg;
constructor Create;
destructor Delete;
destructor Destroy; override;
end;
{ TLSimbaScript }
TLSimbaScript = class(TSimbaScript) //Installed Script (Local Simba Script)
public
procedure LoadFromFile(const filename : string);
procedure SaveToFile(const FileName : string);
procedure Save(const MainDir : string); //MainDir = maindir of ScriptManager
end;
{ TScriptManager }
TScriptManager = class (TObject)
private
FScripts : TList; //Array of the online scripts
FLScripts: TList; //Array of the local scripts
FVersion : String;
FUpdating : boolean;
function GetLScriptCount: integer;
function GetScriptCount: integer;
public
MainDir : string;
procedure Update; //Gets the new online scripts
procedure LUpdate; //Loads the local scripts, uses MainDir
procedure LSave; //Saves the local scripts, uses MainDir
property LScriptCount : integer read GetLScriptCount; //LScript = Local Script = Installed Script
property ScriptCount : integer read GetScriptCount; //Online script
property Version : string read FVersion;
constructor Create;
destructor Destroy; override;
end;
var
Form1: TForm1;
implementation
uses
XMLRead,XMLWrite;
{$R *.lfm}
{ TForm1 }
@ -110,10 +148,10 @@ procedure TForm1.FormCreate(Sender: TObject);
var
s: TMMLSettings;
begin
s := TMMLSettings.Create(TreeView1.Items);
{ s := TMMLSettings.Create(TreeView1.Items);
s.LoadFromXML('/scratch/gittest/list.xml');
fill(s);
s.Free();
s.Free();}
end;
procedure TForm1.ClickItem(Sender: TObject; Button: TMouseButton;
@ -143,8 +181,72 @@ begin
//form1.Memo1.Text := TSimbaScript(item.data).Description;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Mngr : TScriptManager;
begin
Mngr := TScriptManager.Create;
Mngr.Update;
Mngr.free;
end;
{ TSimbaScript }
procedure TSimbaScript.LoadFromNode(Script: TDOMNode);
function NodeContents(ItemStr : string; node : TDOMNode) : string;
var
tmpNode : TDOMNode;
begin
result := '';
if node = nil then
exit;
tmpNode := node.FindNode(itemstr);
if tmpNode <> nil then
result := Trim(tmpNode.TextContent);
end;
function NodeSubContents(ItemStr : string; node : TDOMNode) : TStringList;
var
tmpNode : TDOMNode;
begin
Result := TStringList.Create;
if node = nil then
exit;
tmpNode := node.FindNode(itemstr);
if tmpNode <> nil then
begin
tmpNode := tmpNode.FirstChild;
while tmpNode <> nil do
begin
Result.add(trim(tmpNode.TextContent));
tmpNode := tmpNode.NextSibling;
end;
end;
end;
begin
Author:= NodeContents('Author',script);
Name := NodeContents('Name',script);
Version := NodeContents('Version',script);
Description:= NodeContents('Description',script);
Tags := NodeSubContents('Tags',script);
Files := NodeSubContents('Files',script);
end;
procedure TSimbaScript.Dbg;
var
i : integer;
begin
Writeln(Name);
Writeln(' Author: ' + Author);
Writeln(' Version: ' + Version);
Writeln(' Description: ' + Description);
Writeln(' Tags:');
for i := 0 to Tags.Count - 1 do
Writeln(' ' + Tags[i]);
Writeln(' Files:');
for i := 0 to Files.Count - 1 do
Writeln(' ' + Files[i]);
end;
constructor TSimbaScript.Create;
begin
inherited;
@ -152,13 +254,184 @@ begin
{stuff here}
end;
destructor TSimbaScript.Delete;
destructor TSimbaScript.Destroy;
begin
if Files <> nil then
FreeAndNil(Files);
if Tags <> nil then
FreeAndNil(Tags);
{stuff here}
inherited;
end;
{ TScriptManager }
function TScriptManager.GetLScriptCount: integer;
begin
result := FLScripts.Count;
end;
function TScriptManager.GetScriptCount: integer;
begin
result := FScripts.Count;
end;
procedure TScriptManager.Update;
var
XMLFile : string;
Stream : TStringStream;
XMLDoc : TXMLDocument;
Node,Script : TDOMNode;
Subs : TStringList;
Down : TDownloadThread;
SimbaScript : TLSimbaScript;
begin
if FUpdating then
exit;
FUpdating := True;
Down := TDownloadThread.Create('http://old.villavu.com/sm',@XMLFile);
down.Execute;
while down.Done = false do
begin
Application.ProcessMessages;
Sleep(25);
end;
Stream := TStringStream.Create(XMLFile);
ReadXMLFile(XMLDoc,Stream);
Stream.Free;
Node := XMLDoc.FirstChild.FindNode('Version');
if node <> nil then
FVersion:= Node.TextContent;
Node := XMLDoc.FirstChild.FindNode('ScriptList');
if node <> nil then
begin
script := Node.FirstChild;
while Script <> nil do
begin
SimbaScript := TLSimbaScript.Create;
SimbaScript.LoadFromNode(Script);
FLScripts.Add(SimbaScript);
SimbaScript.Dbg;
Script := Script.NextSibling;
end;
end;
SimbaScript.SaveToFile('c:\testme.xml');
XMLDoc.Free;
FUpdating := false;
end;
procedure TScriptManager.LUpdate;
begin
if DirectoryExists(MainDir) = false then
exit;
if FileExists( IncludeTrailingPathDelimiter(maindir) + 'General' + DirectorySeparator+
'scripts.xml') then
begin
end;
end;
procedure TScriptManager.LSave;
var
XMLDoc : TXMLDocument;
procedure AddTextElement(root : TDOMNode; Element : string; Text : string);
var
node : TDOMNode;
begin
Node := XMLDoc.createElement(Element);
root.AppendChild(node);
node.TextContent:= Text;
end;
var
Node : TDOMNode;
i : integer;
begin
if DirectoryExists(MainDir) = false then
exit;
XMLDoc := TXMLDocument.Create;
Node := XMLDoc.CreateElement('Scripts');
XMLDoc.AppendChild(node);
for i := 0 to FLScripts.Count - 1 do
AddTextElement(node,'Script', TLSimbaScript(FLScripts[i]).Name);
WriteXMLFile(XMLDoc,IncludeTrailingPathDelimiter(maindir) + 'General' + DirectorySeparator+
'scripts.xml');
XMLDoc.Free;
end;
constructor TScriptManager.Create;
begin
inherited;
FLScripts := TList.Create;
FScripts := TList.Create;
FVersion := '';
FUpdating:= False;
end;
destructor TScriptManager.Destroy;
begin
while FScripts.Count > 0 do
begin
TSimbaScript(FScripts[0]).Free;
FScripts.Delete(0);
end;
while FLScripts.Count > 0 do
begin
TLSimbaScript(FLScripts[0]).Free;
FLScripts.Delete(0);
end;
inherited Destroy;
end;
{ TLSimbaScript }
procedure TLSimbaScript.LoadFromFile(const filename: string);
var
XMLDoc : TXMLDocument;
begin
ReadXMLFile(XMLDoc,filename);
Self.LoadFromNode(XMLDoc.FirstChild);
end;
procedure TLSimbaScript.SaveToFile(const FileName: string);
var
XMLDoc : TXMLDocument;
procedure AddTextElement(root : TDOMNode; Element : string; Text : string);
var
node : TDOMNode;
begin
Node := XMLDoc.createElement(Element);
root.AppendChild(node);
node.TextContent:= Text;
end;
var
Node,SubNode : TDOMNode;
i : integer;
begin
XMLDoc := TXMLDocument.Create;
Node := XMLDoc.CreateElement('Script');
XMLDoc.AppendChild(Node);
AddTextElement(node,'Name',Name);
AddTextElement(node,'Author',Author);
AddTextElement(node,'Version',Version);
AddTextElement(node,'Description',description);
SubNode := XMLDoc.CreateElement('Tags');
Node.AppendChild(SubNode);
for i := 0 to Tags.Count - 1 do
AddTextElement(SubNode,'Tag',Tags[i]);
SubNode := XMLDoc.CreateElement('Files');
Node.AppendChild(SubNode);
for i := 0 to Files.Count - 1 do
AddTextElement(SubNode,'File',Files[i]);
WriteXMLFile(XMLDoc,FileName);
XMLDoc.Free;
end;
procedure TLSimbaScript.Save(const MainDir: string);
begin
end;
end.

View File

@ -7,7 +7,7 @@ interface
uses
Classes, SysUtils, virtualextension, forms, client, uPSComponent,uPSCompiler,
uPSRuntime, stdCtrls, uPSPreProcessor,MufasaTypes,MufasaBase, web,
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties, settingssandbox;
bitmaps, plugins, libloader, dynlibs,internets,scriptproperties, settingssandbox, updater;

View File

@ -42,7 +42,7 @@ uses
stringutil,mufasatypesutil,mufasabase, v_ideCodeParser,
about, framefunctionlist, ocr, updateform, Simbasettings, psextension, virtualextension,
extensionmanager, settingssandbox, v_ideCodeInsight, CastaliaPasLexTypes,
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump, settings;
CastaliaSimplePasPar, v_AutoCompleteForm, PSDump, settings, updater;
const
SimbaVersion = 715;

View File

@ -11,18 +11,6 @@ uses
type
{ TSimbaUpdateForm }
{ TDownloadThread }
TDownloadThread = class(TThread)
private
InputURL : string;
ResultStr : PString;
public
Done : boolean;
constructor Create(const URL : string; const Output : PString);
procedure Execute; override;
end;
TSimbaUpdateForm = class(TForm)
DownloadSpeed: TLabel;
UpdateLog: TMemo;
@ -268,22 +256,6 @@ begin
FUpdating:= false;
end;
constructor TDownloadThread.Create(const url : String; const Output : PString);
begin
inherited Create(true);
FreeOnTerminate:= True;
InputURL:= url;
ResultStr:= Output;
end;
{ TDownloadThread }
procedure TDownloadThread.Execute;
begin
ResultStr^:= GetPage(InputURL);
done := true;
end;
initialization
{$R *.lfm}

View File

@ -16,7 +16,7 @@ Const
MOUSE_DOWN = 1;
var
last_error: PChar;
last_error: String;
debug: boolean;
function init: integer;
@ -31,7 +31,7 @@ begin
result := Assigned(C);
if not result then
begin
last_error := PChar('PClient is NULL');
last_error := 'PClient is NULL';
if debug then
writeln(last_error);
end;
@ -48,7 +48,7 @@ begin
begin
writeln('ERROR');
result := PtrUInt(RESULT_ERROR);
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
writeln(format('C: %d, IOManager: %d', [PtrUInt(C), PtrUInt(C.IOManager)]));
@ -73,9 +73,15 @@ begin
exit(debug);
end;
{
VERY IMPORTANT: If you use get_last_error, you must immediately store the
resulting string somewhere else. As soon as you do other calls, the last error
may be reset or assigned a different memory position, making your old
pointer invalid.
}
function get_last_error: pchar;
begin
exit(last_error);
exit(@last_error[1]);
end;
function array_to_ptr(ptr: Pointer; size: PtrUInt; objsize: PtrUInt): Pointer;
@ -93,7 +99,7 @@ begin
if debug then
writeln(last_error);
end else
Free(ptr);
FreeMem(ptr);
end;
function alloc_mem(size, objsize: PtrUInt): Pointer;
@ -103,7 +109,7 @@ end;
function realloc_mem(ptr: Pointer; size, objsize: PtrUInt): Pointer;
begin
result := ReAlloc(ptr, size*objsize);
result := ReAllocMem(ptr, size*objsize);
end;
{ Mouse }
@ -122,7 +128,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
end;
@ -140,7 +146,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
end;
@ -168,7 +174,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
end;
@ -193,7 +199,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
end;
@ -213,7 +219,8 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
writeln('last_error: ' + last_error);
end;
end;
end;
@ -234,7 +241,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
end;
@ -254,7 +261,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;
@ -278,7 +285,7 @@ begin
except on e : Exception do
begin
result := RESULT_ERROR;
last_error := PChar(e.Message);
last_error := e.Message;
end;
end;

View File

@ -4,6 +4,7 @@ from ctypes import *
from mmlmouse import Mouse
from mmlcolor import Color
from time import sleep
from mmltypes import PINTEGER
class MMLCoreException(Exception):
def __init__(self, err):
@ -21,10 +22,27 @@ class MMLCore(object):
self.dll.init.argtypes = None
self.dll.create_client.restype = c_ulong
self.dll.create_client.argtypes = None
self.dll.get_last_error.restype = c_char_p
self.dll.get_last_error.argtypes = None
self.dll.free_ptr.restype = c_bool
self.dll.free_ptr.argtypes = [c_void_p]
if self.dll.init() != 0:
del self.dll
raise MMLCoreException("Could not initialize the DLL")
def get_last_error(self):
t = self.dll.get_last_error()
s = str(t)
del t
return s
def free(self, ptr):
_ptr = cast(ptr, c_void_p)
self.dll.free_ptr(_ptr)
def __del__(self):
del self.dll
@ -38,15 +56,14 @@ if __name__ == '__main__':
raise Exception('Could create a client');
c = Color(DLL, client)
ret = c.find((0, 0, 100, 100), 0)
print ret
ret = c.findAll((0, 0, 100, 100), 0)
ret = c.findAll((0, 0, 100, 100), 0, tol=100)
print ret
raise Exception('WAT')
m = Mouse(DLL, client)
@ -59,14 +76,10 @@ if __name__ == '__main__':
sleep(2)
print 'Done'
#
# # Reset all buttons..
m[(Mouse.Left, Mouse.Right, Mouse.Middle)] = [False for x in range(3)]
for v in zip((Mouse.Left, Mouse.Right), m[(Mouse.Left, Mouse.Right)]):
print v
print m.getPos()
# if hasattr(ret,'__iter__'):
# m.setPos(ret)
del DLL

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
class Bitmap(object):
# Pixels, alleen ter illustratie atm
@ -21,28 +22,3 @@ class Bitmap(object):
raise Exception("Invalid argument")
# Hier volgen gewoon de juiste calls
class Mouse(object):
lastPolledPos = (0,0)
states = None
def __init__(self):
self.states = {'left': 'down', 'right' : 'up', 'middle' : ' up'}
pass
def _getButtonState(self, button):
return self.states[button]
def __getitem__(self, item):
if iterable(item):
if item['state'] in ('left', 'right', 'middle'):
return self._getButtonState(item['state'])
iterable = lambda x: hasattr(x, '__iter__')
m = Mouse()
print m[{'state' : 'left'}]
a = Bitmap()
print a[(2,3)]
a.find()

View File

@ -2,6 +2,7 @@ from ctypes import *
from mmltypes import isiterable
from mmltypes import POINT, PPOINT, PINTEGER
from mmltypes import RESULT_OK, RESULT_FALSE, RESULT_ERROR
from mmltypes import MMLException
"""
The Color Class
@ -10,10 +11,9 @@ The Color Class
This class does the color finding.
"""
class ColorException(Exception):
class ColorException(MMLException):
def __init__(self, err):
Exception.__init__(self, err)
MMLException.__init__(self, err)
# FIXME: Complete...
@ -48,6 +48,8 @@ class Color(object):
if ret is RESULT_OK:
return (x, y)
elif ret is RESULT_ERROR:
raise ColorException(self._mc.get_last_error())
return None
@ -57,7 +59,6 @@ class Color(object):
returned are all the matching points
"""
ptr, _len = PPOINT(), c_int(42)
print type(_len)
if tol is 0:
self._mc.dll.find_colors(self._cli, byref(ptr), byref(_len),
color, *box)
@ -65,12 +66,13 @@ class Color(object):
self._mc.dll.find_colors_tolerance(self._cli, byref(ptr),
byref(_len), color, tol, *box)
# print 'Length:', _len
# for x in range(_len.value):
# print ptr[x].x
# print ptr
# FIXME return python list?
return ''
# Construct list
l = [(ptr[x].x, ptr[x].y) for x in range(_len.value)]
# Free PPOINT
self._mc.free(ptr)
return l
def _initialiseDLLFuncs(self):
self._mc.dll.find_color.restype = c_int
@ -86,3 +88,4 @@ class Color(object):
self._mc.dll.find_colors_tolerance.argtypes = [c_ulong,
POINTER(PPOINT), POINTER(c_int), c_int, c_int,
c_int, c_int, c_int, c_int]

31
Projects/libmml/pymml/mmldtm.py Executable file
View File

@ -0,0 +1,31 @@
from ctypes import *
from mmltypes import RESULT_OK, RESULT_FALSE, RESULT_ERROR
# TODO:
# Load from user defined points. (So called dynamic)
class DTM(object):
def __init__(self):
pass
def __del__(self):
pass
def __repr__(self):
pass
def to_str(self):
pass
def from_str(self):
pass
def find(self):
pass
def set_name(self):
pass

View File

@ -10,6 +10,11 @@ class POINT(Structure):
_fields_ = [('x', c_int),
('y', c_int)]
class MMLException(Exception):
def __init__(self, err):
Exception.__init__(self, err)
#class PascalArray(object):
# """
# PascalArray is a class that allows one to easily use a Pascal-style

View File

@ -16,6 +16,18 @@ type
constructor Create(CreateSuspended: Boolean);
destructor Destroy; override;
end; }
{ TDownloadThread }
TDownloadThread = class(TThread)
private
InputURL : string;
ResultStr : PString;
public
Done : boolean;
constructor Create(const URL : string; const Output : PString);
procedure Execute; override;
end;
TMemory = pointer;
TMMLFunctionBoolean = function: boolean of object;
@ -87,8 +99,23 @@ type
implementation
uses
FileUtil;
FileUtil,internets;
constructor TDownloadThread.Create(const url : String; const Output : PString);
begin
inherited Create(true);
FreeOnTerminate:= True;
InputURL:= url;
ResultStr:= Output;
end;
{ TDownloadThread }
procedure TDownloadThread.Execute;
begin
ResultStr^:= GetPage(InputURL);
done := true;
end;
procedure TMMLFileDownloader.SetBasePath(s: string);
begin

View File

@ -1,82 +0,0 @@
# hash value = 257594117
rutis_errors.err_scanner_unexpected_char='E000: Unexpected char found in '+
'code'
# hash value = 23719812
rutis_errors.err_unallowed_statement='E002: Unallowed Statement'
# hash value = 248294455
rutis_errors.err_unknown_ident='E003: Unknown Identifier '#39'%s'#39
# hash value = 195210244
rutis_errors.err_expected_found='E010: '#39'%s'#39' expected, '#39'%s'#39+
' found instead'
# hash value = 2386388
rutis_errors.err_op_or_semi_expected='E011: Operator or semicolon expecte'+
'd'
# hash value = 184443412
rutis_errors.err_var_constant_expected='E012: Variable or Constant expect'+
'ed'
# hash value = 80568548
rutis_errors.err_var_expected='E013: Variable expected'
# hash value = 25156852
rutis_errors.err_rec_expected='E014: Record expected'
# hash value = 95149172
rutis_errors.err_array_expected='E015: Array expected'
# hash value = 90164228
rutis_errors.err_procedure_expected='E016: Procedure expected'
# hash value = 50540276
rutis_errors.err_string_expected='E017: String expected'
# hash value = 51366068
rutis_errors.err_expected='E019: %s expected'
# hash value = 159220885
rutis_errors.err_no_const_allowed='E020: No Constant allowed here'
# hash value = 3854691
rutis_errors.err_not_enough_parameters='E030: Not enough actual parameter'+
's'
# hash value = 50133859
rutis_errors.err_too_many_parameters='E031: Too many parameters'
# hash value = 62647742
rutis_errors.err_unallowed_string_action='E040: Unallowed String action'
# hash value = 255120181
rutis_errors.err_unallowed_datatype='E041: Unallowed Datatype'
# hash value = 91098180
rutis_errors.err_code_after_program_end='W001: Code after Program END. is'+
' ignored'
# hash value = 102976020
rutis_errors.err_code_after_unit_end='W002: Code after Unit END. is ignor'+
'ed'