1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-02-16 07:10:10 -05:00

Getting the ScriptManager somewhere!

This commit is contained in:
Raymond 2010-09-11 23:24:53 +02:00
parent cf05f50411
commit 4a357ec461
5 changed files with 523 additions and 148 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

@ -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

@ -29,7 +29,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, ComCtrls, ActnList, Menus, settings, MufasaTypes;
ExtCtrls, ComCtrls, ActnList, Menus, settings, updater,strutils, MufasaTypes,dom;
type
@ -48,6 +48,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 +58,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 +146,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 +179,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 +252,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

@ -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,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