From 14e929decc789dab8770b73f6345a8ab444048de Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Tue, 8 Jun 2010 00:15:20 +0200 Subject: [PATCH] Just a bit of the Script Manager code. I need to code a lot more, and it will be a bit hackish. Basically, the TMMLSettings is not able to handle childs with the same name. It can parse them into the tree, but the finding methods will not work. (They will always find the first.) Three possibilities: - Delete the one we just parsed, and search again. (We will get the next result) - Use WalkToNode and then manually parse the node. (This is more dangerous but doesn't delete the settints) - Do the XML parsing semi-manually, kind of like rewriting the settings unit. --- Projects/ScriptManager/project1.lpi | 169 +++++++++++++++++++---- Projects/ScriptManager/scriptmanager.lfm | 44 ++---- Projects/ScriptManager/scriptmanager.pas | 50 ++++++- 3 files changed, 201 insertions(+), 62 deletions(-) diff --git a/Projects/ScriptManager/project1.lpi b/Projects/ScriptManager/project1.lpi index 1c43f37..a1d406d 100644 --- a/Projects/ScriptManager/project1.lpi +++ b/Projects/ScriptManager/project1.lpi @@ -10,7 +10,6 @@ - @@ -35,12 +34,12 @@ - + - + @@ -51,9 +50,9 @@ - - - + + + @@ -61,76 +60,186 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -140,6 +249,7 @@ + @@ -148,12 +258,11 @@ - + - diff --git a/Projects/ScriptManager/scriptmanager.lfm b/Projects/ScriptManager/scriptmanager.lfm index 4f7ecd8..04f7c49 100644 --- a/Projects/ScriptManager/scriptmanager.lfm +++ b/Projects/ScriptManager/scriptmanager.lfm @@ -1,7 +1,7 @@ object Form1: TForm1 - Left = 369 + Left = 1499 Height = 567 - Top = 144 + Top = 51 Width = 825 ActiveControl = Button1 Caption = 'Form1' @@ -12,7 +12,7 @@ object Form1: TForm1 Left = 32 Height = 520 Top = 24 - Width = 216 + Width = 384 Columns = < item Caption = 'Scripts' @@ -20,12 +20,6 @@ object Form1: TForm1 end> IconOptions.Arrangement = iaLeft ItemIndex = -1 - Items.LazData = { - 640000000400000000000000FFFFFFFFFFFFFFFF000000000100000061000000 - 00FFFFFFFFFFFFFFFF00000000050000004974656D3100000000FFFFFFFFFFFF - FFFF00000000040000006664686400000000FFFFFFFFFFFFFFFF000000000200 - 00006466 - } LargeImages = ImageList1 ScrollBars = ssAutoBoth SmallImages = ImageList1 @@ -33,34 +27,26 @@ object Form1: TForm1 TabOrder = 0 ViewStyle = vsReport end - object ListBox1: TListBox - Left = 560 - Height = 520 - Top = 24 - Width = 240 - Items.Strings = ( - 'wat' - 'wa' - 'asd' - 'd' - 'd' - ) - ItemHeight = 40 - Style = lbOwnerDrawFixed - TabOrder = 1 - end object Button1: TButton - Left = 360 + Left = 432 Height = 25 - Top = 24 + Top = 504 Width = 75 Caption = 'Button1' OnClick = Button1Click + TabOrder = 1 + end + object TreeView1: TTreeView + Left = 528 + Height = 528 + Top = 16 + Width = 272 + DefaultItemHeight = 19 TabOrder = 2 end object ImageList1: TImageList - left = 288 - top = 16 + left = 368 + top = 504 Bitmap = { 4C69010000001000000010000000424242004242420042424200424242004242 420042424200424242004242420042424200424242004242420042424200A155 diff --git a/Projects/ScriptManager/scriptmanager.pas b/Projects/ScriptManager/scriptmanager.pas index b92cc79..a042790 100644 --- a/Projects/ScriptManager/scriptmanager.pas +++ b/Projects/ScriptManager/scriptmanager.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, - ExtCtrls, ComCtrls; + ExtCtrls, ComCtrls, settings, MufasaTypes; type @@ -15,7 +15,6 @@ type TForm1 = class(TForm) Button1: TButton; ImageList1: TImageList; - ListBox1: TListBox; ListView1: TListView; TreeView1: TTreeView; procedure Button1Click(Sender: TObject); @@ -23,7 +22,20 @@ type { private declarations } public { public declarations } - end; + end; + + TSimbaScript = class(TObject) + + public + Name, Version, Author, Description: String; + Tags, Files: TStringArray; + + private + + public + constructor Create(n: TTreeNode); + destructor Delete; + end; var Form1: TForm1; @@ -33,9 +45,41 @@ implementation {$R *.lfm} { TForm1 } +procedure fill(s: TMMLSettings); +var + i:integer; + n, nn: TTreeNode; + ss: TSimbaScript; +begin + n := s.WalkToNode('Scripts/ScriptList/'); + nn := n.GetFirstChild; + while nn <> nil do + begin + ss := TSimbaScript.Create(nn); + nn := nn.GetNextSibling; + end; +end; procedure TForm1.Button1Click(Sender: TObject); +var + s: TMMLSettings; begin + s := TMMLSettings.Create(TreeView1.Items); + s.LoadFromXML('/scratch/gittest/list.xml'); + fill(s); + s.Free; +end; + +{ TSimbaScript } + +constructor TSimbaScript.Create(n: TTreeNode); +begin + +end; + +destructor TSimbaScript.Delete; +begin + end; end.