diff --git a/Projects/SAMufasaGUI/colourhistory.lrs b/Projects/SAMufasaGUI/colourhistory.lrs
index 4c419fb..f407234 100644
--- a/Projects/SAMufasaGUI/colourhistory.lrs
+++ b/Projects/SAMufasaGUI/colourhistory.lrs
@@ -1,3 +1,5 @@
+{ This is an automatically generated lazarus resource file }
+
LazarusResources.Add('TColourHistoryForm','FORMDATA',[
'TPF0'#18'TColourHistoryForm'#17'ColourHistoryForm'#4'Left'#3'v'#1#6'Height'#3
+#4#1#3'Top'#3'O'#1#5'Width'#3#243#1#13'ActiveControl'#7#13'SelectionName'#7
@@ -40,4 +42,4 @@ LazarusResources.Add('TColourHistoryForm','FORMDATA',[
+'HAboutClick'#0#0#0#0#11'TSaveDialog'#12'CHSaveDialog'#10'DefaultExt'#6#4'.x'
+'ml'#4'left'#3#136#1#3'top'#3#160#0#0#0#11'TOpenDialog'#12'CHOpenDialog'#10
+'DefaultExt'#6#4'.xml'#4'left'#3#200#1#3'top'#3#160#0#0#0#0
-]);
+]);
\ No newline at end of file
diff --git a/Projects/SAMufasaGUI/colourhistory.pas b/Projects/SAMufasaGUI/colourhistory.pas
index 89291bf..9fd49c9 100644
--- a/Projects/SAMufasaGUI/colourhistory.pas
+++ b/Projects/SAMufasaGUI/colourhistory.pas
@@ -138,7 +138,8 @@ var
begin
bmp:=TBitmap.Create;
bmp.SetSize(16,16);
- bmp.Canvas.Brush.Color:=TColourPickerObject(n.Data).Colour;
+ if(Assigned(n.Data)) then
+ bmp.Canvas.Brush.Color:=TColourPickerObject(n.Data).Colour;
bmp.Canvas.Rectangle(0,0,16,16);
n.ImageIndex:=CHImages.Add(bmp, nil);
@@ -172,7 +173,13 @@ begin
If Assigned(N.Data) then
TColourPickerObject(N.Data).Free;
WriteLn('Deleting ImageIndex: ' + IntToStr(n.ImageIndex) + '; Text: ' + N.Text);
- Img.Delete(n.ImageIndex);
+
+ // yeah....
+ try
+ if n.ImageIndex <> -1 Then
+ Img.Delete(n.ImageIndex);
+ except end;
+
WalkDeleteTree(n, img);
n := n.GetNextSibling;
end;
@@ -192,7 +199,8 @@ begin
WalkDeleteTree(ColourTree.Selected, CHImages);
WriteLn('Deleting ImageIndex: ' + IntToStr(ColourTree.Selected.ImageIndex) + '; Text: ' + ColourTree.Selected.Text);
- CHImages.Delete(ColourTree.Selected.ImageIndex);
+ if ColourTree.Selected.ImageIndex <> -1 then
+ CHImages.Delete(ColourTree.Selected.ImageIndex);
ColourTree.Selected.Delete;
TreeChanged := True;
diff --git a/Projects/SAMufasaGUI/project1.lpi b/Projects/SAMufasaGUI/project1.lpi
index 643fbdb..f8d471a 100644
--- a/Projects/SAMufasaGUI/project1.lpi
+++ b/Projects/SAMufasaGUI/project1.lpi
@@ -10,7 +10,7 @@
-
+
@@ -36,16 +36,14 @@
-
+
-
-
+
-
@@ -139,8 +137,8 @@
-
-
+
+
@@ -206,7 +204,7 @@
-
+
@@ -229,9 +227,11 @@
-
-
+
+
+
+
@@ -260,7 +260,7 @@
-
+
@@ -282,8 +282,8 @@
-
-
+
+
@@ -346,8 +346,8 @@
-
-
+
+
@@ -563,11 +563,9 @@
-
-
-
+
+
-
@@ -646,7 +644,7 @@
-
+
@@ -663,9 +661,11 @@
-
-
+
+
+
+
@@ -722,9 +722,9 @@
-
+
-
+
@@ -871,8 +871,8 @@
-
-
+
+
@@ -1437,9 +1437,11 @@
-
-
+
+
+
+
@@ -1703,7 +1705,7 @@
-
+
@@ -1712,7 +1714,7 @@
-
+
@@ -1722,7 +1724,7 @@
-
+
@@ -1844,7 +1846,7 @@
-
+
@@ -1899,7 +1901,7 @@
-
+
@@ -1959,9 +1961,7 @@
-
-
@@ -1976,7 +1976,7 @@
-
+
@@ -1986,7 +1986,7 @@
-
+
@@ -2093,127 +2093,154 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/Projects/SAMufasaGUI/project1.lpr b/Projects/SAMufasaGUI/project1.lpr
index 212d01d..d035027 100644
--- a/Projects/SAMufasaGUI/project1.lpr
+++ b/Projects/SAMufasaGUI/project1.lpr
@@ -32,7 +32,7 @@ uses
Interfaces, // this includes the LCL widgetset
LResources ,
Forms, testunit, colourhistory, About, internets, debugimage,
- framefunctionlist, simpleanalyzer, updater, updateform;
+ framefunctionlist, simpleanalyzer, updater, updateform, simbasettings;
{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
begin
@@ -45,6 +45,7 @@ begin
Application.CreateForm(TAboutForm, AboutForm);
Application.CreateForm(TDebugImgForm, DebugImgForm);
Application.CreateForm(TSimbaUpdateForm, SimbaUpdateForm);
+ Application.CreateForm(TSettingsForm, SettingsForm);
Application.Run;
end.
diff --git a/Projects/SAMufasaGUI/simbasettings.lfm b/Projects/SAMufasaGUI/simbasettings.lfm
new file mode 100644
index 0000000..e32a8c7
--- /dev/null
+++ b/Projects/SAMufasaGUI/simbasettings.lfm
@@ -0,0 +1,21 @@
+object SettingsForm: TSettingsForm
+ Left = 747
+ Height = 438
+ Top = 283
+ Width = 333
+ Caption = 'Simba Settings'
+ ClientHeight = 438
+ ClientWidth = 333
+ OnCreate = FormCreate
+ OnDestroy = FormDestroy
+ LCLVersion = '0.9.29'
+ object SettingsTreeView: TTreeView
+ Left = 16
+ Height = 401
+ Top = 16
+ Width = 297
+ DefaultItemHeight = 19
+ ScrollBars = ssAutoBoth
+ TabOrder = 0
+ end
+end
diff --git a/Projects/SAMufasaGUI/simbasettings.lrs b/Projects/SAMufasaGUI/simbasettings.lrs
new file mode 100644
index 0000000..ad44462
--- /dev/null
+++ b/Projects/SAMufasaGUI/simbasettings.lrs
@@ -0,0 +1,10 @@
+{ This is an automatically generated lazarus resource file }
+
+LazarusResources.Add('TSettingsForm','FORMDATA',[
+ 'TPF0'#13'TSettingsForm'#12'SettingsForm'#4'Left'#3#235#2#6'Height'#3#182#1#3
+ +'Top'#3#27#1#5'Width'#3'M'#1#7'Caption'#6#14'Simba Settings'#12'ClientHeight'
+ +#3#182#1#11'ClientWidth'#3'M'#1#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7
+ +#11'FormDestroy'#10'LCLVersion'#6#6'0.9.29'#0#9'TTreeView'#16'SettingsTreeVi'
+ +'ew'#4'Left'#2#16#6'Height'#3#145#1#3'Top'#2#16#5'Width'#3')'#1#17'DefaultIt'
+ +'emHeight'#2#19#10'ScrollBars'#7#10'ssAutoBoth'#8'TabOrder'#2#0#0#0#0
+]);
diff --git a/Projects/SAMufasaGUI/simbasettings.pas b/Projects/SAMufasaGUI/simbasettings.pas
new file mode 100644
index 0000000..ca3d3ad
--- /dev/null
+++ b/Projects/SAMufasaGUI/simbasettings.pas
@@ -0,0 +1,74 @@
+unit simbasettings;
+
+{$mode objfpc} {$M+}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
+ ComCtrls, settings;
+
+type
+
+ { TSettingsForm }
+
+ TSettingsForm = class(TForm)
+ SettingsTreeView: TTreeView;
+ Settings: TMMLSettings;
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ { private declarations }
+ public
+ procedure SaveCurrent;
+ procedure Reload;
+ { public declarations }
+ end;
+
+var
+ SettingsForm: TSettingsForm;
+
+implementation
+
+{ TSettingsForm }
+
+procedure TSettingsForm.FormCreate(Sender: TObject);
+
+begin
+ Settings := TMMLSettings.Create(SettingsTreeView.Items);
+ if not FileExists('settings.xml') then
+ begin
+ SettingsTreeView.Items.Clear;
+ Settings.SaveToXML('settings.xml');
+ end;
+
+ SettingsTreeView.Items.Clear;
+ Settings.LoadFromXML('settings.xml');
+end;
+
+procedure TSettingsForm.FormDestroy(Sender: TObject);
+begin
+ Settings.Free;
+end;
+
+procedure TSettingsForm.SaveCurrent;
+begin
+ Settings.SaveToXML('settings.xml');
+end;
+
+procedure TSettingsForm.Reload;
+begin
+ if not FileExists('settings.xml') then
+ begin
+ SettingsTreeView.Items.Clear;
+ Settings.SaveToXML('settings.xml');
+ end;
+
+ SettingsTreeView.Items.Clear;
+ Settings.LoadFromXML('settings.xml');
+end;
+
+initialization
+ {$I simbasettings.lrs}
+
+end.
+
diff --git a/Projects/settings/settings.pas b/Projects/settings/settings.pas
index 7ea14eb..23a8019 100644
--- a/Projects/settings/settings.pas
+++ b/Projects/settings/settings.pas
@@ -32,7 +32,6 @@ type
Nodes: TTreeNodes;
function KeyNameToKeys(KeyName: String): TStringArray;
function WalkToNode(KeyName: String): TTreeNode;
- function GetNodePath(Node: TTreeNode): String;
procedure InternalLoadFromXML(XMLDoc: TXMLDocument);
procedure WriteXMLData(n: TTreeNode;
@@ -42,6 +41,7 @@ type
var C: Integer);
public
+ function GetNodePath(Node: TTreeNode): String;
function ListKeys(KeyName: String): TStringArray;
function KeyExists(KeyName: String): Boolean;
function IsKey(KeyName: String): Boolean;
diff --git a/Units/MMLAddon/colourpicker.pas b/Units/MMLAddon/colourpicker.pas
index cf2642d..f32b9b8 100644
--- a/Units/MMLAddon/colourpicker.pas
+++ b/Units/MMLAddon/colourpicker.pas
@@ -100,7 +100,6 @@ var
procedure TMColorPicker.Pick(Out C, X, Y: Integer);
var
w, h: integer;
- box : TBox;
SS : TShiftState;
p : TPoint;
@@ -227,7 +226,6 @@ procedure TMColorPicker.ImageMainMouseMove(Sender: TObject; Shift: TShiftState;
Y: Integer);
var
TempPoint : TPoint;
- Data : TRetData;
R : TRect;
px, py : Integer;
MouseX, MouseY: Integer;
diff --git a/Units/MMLAddon/mmlpsthread.pas b/Units/MMLAddon/mmlpsthread.pas
index 337c167..76c4c9e 100644
--- a/Units/MMLAddon/mmlpsthread.pas
+++ b/Units/MMLAddon/mmlpsthread.pas
@@ -313,8 +313,7 @@ begin
end;
procedure SIRegister_Mufasa(cl: TPSPascalCompiler);
-var
- Ptr : PtrUInt;
+
begin;
with cl.AddClassN(cl.FindClass('TObject'),'TMufasaBitmap') do
begin;
diff --git a/Units/MMLAddon/settings.pas b/Units/MMLAddon/settings.pas
new file mode 100644
index 0000000..f4f0d18
--- /dev/null
+++ b/Units/MMLAddon/settings.pas
@@ -0,0 +1,489 @@
+unit settings;
+
+{$mode objfpc}{$M+}
+
+interface
+
+uses
+ Classes, SysUtils, ComCtrls, xmlread, xmlwrite, DOM;
+
+
+
+type
+ // remove later
+ TStringArray = Array Of String;
+
+ TSettingData = class(TObject)
+ public
+ Val: String;
+
+ constructor Create;
+ destructor Destroy; override;
+
+ end;
+
+ TMMLSettings = class(TObject)
+
+ public
+ constructor Create(aNodes: TTreeNodes);
+ destructor Destroy; override;
+
+ private
+ Nodes: TTreeNodes;
+ function KeyNameToKeys(KeyName: String): TStringArray;
+ function WalkToNode(KeyName: String): TTreeNode;
+
+ procedure InternalLoadFromXML(XMLDoc: TXMLDocument);
+ procedure WriteXMLData(n: TTreeNode;
+ XMLNode: TDOMNode; XMLDoc: TXMLDocument;
+ var XMLChild: TDOMNode; var C: Integer);
+ procedure WalkTree(Node: TTreeNode; XMLNode: TDOMNode; XMLDoc: TXMLDocument;
+ var C: Integer);
+
+ public
+ function GetNodePath(Node: TTreeNode): String;
+ function ListKeys(KeyName: String): TStringArray;
+ function KeyExists(KeyName: String): Boolean;
+ function IsKey(KeyName: String): Boolean;
+ function IsDirectory(KeyName: String): Boolean;
+ procedure SetKeyValue(KeyName: String; KeyValue: String);
+ function CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
+ function GetKeyValue(KeyName: String): String;
+ function GetSetDefaultKeyValue(KeyName, defVal: String): String;
+
+ public
+ procedure LoadFromXML(fileName: String);
+ procedure SaveToXML(fileName: String);
+
+ end;
+
+implementation
+uses
+ strutils;
+
+constructor TSettingData.Create;
+begin
+ inherited;
+ Val := '';
+end;
+
+destructor TSettingData.Destroy;
+begin
+ Val := '';
+ inherited;
+end;
+
+
+constructor TMMLSettings.Create(aNodes: TTreeNodes);
+begin
+ Self.Nodes := aNodes;
+end;
+
+destructor TMMLSettings.Destroy;
+begin
+ Nodes := nil;
+
+ inherited;
+end;
+
+procedure TMMLSettings.InternalLoadFromXML(XMLDoc: TXMLDocument);
+var
+ iNode: TDOMNode;
+
+ procedure ProcessNode(Node: TDOMNode; TreeNode: TTreeNode);
+ var
+ cNode: TDOMNode;
+ s: string;
+ d: TSettingData;
+
+ begin
+ if Node = nil then Exit; // Stops if reached a leaf
+
+ // Adds a node to the tree
+ if (Node.NodeType = 3) then
+ s := 'Data'
+ else
+ s := Node.NodeName;
+
+ TreeNode := Nodes.AddChild(TreeNode, s);
+ if (Node.NodeType = 3) then
+ begin
+ d := TSettingData.Create;
+ D.Val := Node.NodeValue;
+ TreeNode.Data := D;
+
+ TreeNode.Text := 'Value';
+ end;
+ // Goes to the child node
+ cNode := Node.FirstChild;
+
+ // Processes all child nodes
+ while cNode <> nil do
+ begin
+ ProcessNode(cNode, TreeNode);
+ cNode := cNode.NextSibling;
+ end;
+ end;
+
+begin
+ iNode := XMLDoc.DocumentElement;
+ while iNode <> nil do
+ begin
+ ProcessNode(iNode, nil); // Recursive
+ iNode := iNode.NextSibling;
+ end;
+end;
+
+function TMMLSettings.KeyNameToKeys(KeyName: String): TStringArray;
+ // yay for SRL!
+ function srl_Explode(str, del: string): TStringArray;
+ var
+ i, l, dL: Integer;
+ begin
+ i := 0;
+ l := -1;
+ SetLength(Result, 0);
+ if (str = '') then
+ Exit;
+ dL := Length(del) - 1;
+ repeat
+ Inc(l);
+ SetLength(Result, l + 1);
+ i := Pos(del, str);
+ if i <= 0 then
+ Break;
+ Result[l] := Copy(str, 1, i - 1);
+ Delete(str, 1, i + dL);
+ until false;
+ Result[l] := Copy(str, 1, Length(str));
+ end;
+begin
+ Result := srl_Explode(KeyName, '/');
+end;
+
+function TMMLSettings.WalkToNode(KeyName: String): TTreeNode;
+var
+ N: TTreeNode;
+ i: Integer;
+ S: TStringArray;
+begin
+ Result := nil;
+
+ if KeyName[length(KeyName)]='/' then setlength(KeyName,length(KeyName)-1);
+ S := KeyNameToKeys(KeyName);
+
+ if not assigned(s) then
+ Exit(nil);
+
+ N := Nodes.GetFirstNode;
+ i := 0;
+
+ while N <> nil do
+ begin
+ if N.Text = s[i] then
+ begin
+ inc(i);
+ if i = length(s) then
+ break;
+ N := N.GetFirstChild;
+ end else
+ N := N.GetNextSibling;
+ end;
+
+ Result := N;
+end;
+
+function TMMLSettings.GetNodePath(Node: TTreeNode): String;
+var
+ N: TTreeNode;
+ s: TStringArray;
+ i: Integer;
+begin
+ if Node = nil then
+ Exit('');
+
+ N := Node;
+ setlength(s, 0);
+ while N <> nil do
+ begin
+ setlength(s,length(s) + 1);
+ s[high(s)] := N.Text;
+ N := N.Parent;
+ end;
+
+ result := '';
+ for i := high(s) downto 0 do
+ result := result + s[i] + '/';
+end;
+
+function TMMLSettings.ListKeys(KeyName: String): TStringArray;
+var
+ N: TTreeNode;
+ i: Integer;
+ S: TStringArray;
+begin
+ SetLength(Result, 0);
+ N := WalkToNode(KeyName);
+ if N <> nil then
+ N := N.GetFirstChild;
+
+ while N <> nil do
+ begin
+ setlength(result,length(result)+1);
+ result[high(result)] := N.Text;
+ N := N.GetNextSibling;
+ end;
+end;
+
+function TMMLSettings.KeyExists(KeyName: String): Boolean;
+
+begin
+ Result := WalkToNode(KeyName) <> nil;
+end;
+
+function TMMLSettings.IsKey(KeyName: String): Boolean;
+var
+ N: TTreeNode;
+ i: Integer;
+begin
+ N := WalkToNode(KeyName);
+ if N = nil then
+ Exit(False);
+
+ i := 0;
+
+ N := N.GetNextSibling;
+ while N <> nil do
+ begin
+ if N.Text <> 'Value' then
+ inc(i);
+ N := N.GetNextSibling;
+ end;
+
+ Exit(i = 0);
+end;
+
+function TMMLSettings.IsDirectory(KeyName: String): Boolean;
+var
+ N: TTreeNode;
+begin
+ N := WalkToNode(KeyName);
+ if N <> nil then
+ Exit(N.HasChildren);
+ Exit(False);
+end;
+
+function TMMLSettings.GetKeyValue(KeyName: String): String;
+var
+ N: TTreeNode;
+begin
+ if not KeyExists(KeyName) then
+ Exit('');
+ N := WalkToNode(KeyName);
+ if N <> nil then
+ N := N.GetFirstChild;
+ while N <> nil do
+ begin
+ if N.Text = 'Value' then
+ if assigned(n.Data) then
+ Exit(TSettingData(n.Data).Val);
+ N := N.GetNextSibling;
+ end;
+ Exit('');
+end;
+
+function TMMLSettings.GetSetDefaultKeyValue(KeyName, defVal: String): String;
+var
+ Res: String;
+begin
+ if not IsKey(KeyName) then
+ begin
+ CreateKey(KeyName, True);
+ SetKeyValue(KeyName, defVal);
+ exit(defVal);
+ end;
+ Res := GetKeyValue(KeyName);
+ if Res = '' then
+ begin
+ SetKeyValue(KeyName, defVal);
+ exit(defVal);
+ end;
+ Exit(Res);
+end;
+
+function TMMLSettings.CreateKey(KeyName: String; CreatePath: Boolean = False): Boolean;
+var
+ N, newN, nParent: TTreeNode;
+ Path: TStringArray;
+ NewPath: String;
+ i: Integer;
+
+begin
+ if KeyExists(KeyName) then
+ begin
+ Exit(False);
+ end;
+ NewPath := '';
+ N := nil;
+ nParent := Nodes.GetFirstNode;
+
+ Path := KeyNameToKeys(KeyName);
+ if length(path) < 2 then
+ begin
+ writeln('Path too short!');
+ exit(false);
+ end;
+
+ if path[0] <> nParent.Text then
+ begin
+ writeln('First key doesn''t match. First key should always match');
+ exit(false);
+ end;
+ for i := 0 to length(Path) - 2 do
+ begin
+ if Path[i] = '' then
+ begin
+ writeln('Invalid Key Path / Name');
+ exit(false);
+ end;
+ NewPath := NewPath + Path[i] + '/';
+ N := WalkToNode(NewPath);
+
+ if (N = nil) and (not CreatePath) then
+ begin
+ writeln('(N = nil) and (not CreatePath)');
+ exit(false);
+ end;
+
+ if (N = nil) and CreatePath then
+ begin
+ newN := TTreeNode.Create(Nodes);
+ newN.Text := Path[i];
+ if (nParent = nil) then
+ begin
+ writeln('This shouldn''t happen...');
+ newN.MoveTo(Nodes.GetFirstNode, naAddChild);
+ nParent := newN;
+ end
+ else
+ begin
+ newN.MoveTo(nParent, naAddChild);
+ nParent := newN;
+ end;
+ end;
+
+ if N <> nil then
+ nParent := N;
+ end;
+
+ if nParent = nil then
+ exit(false);
+
+ newN := TTreeNode.Create(Nodes);
+ newN.Text := Path[High(Path)];
+ newN.MoveTo(nParent, naAddChild);
+end;
+
+procedure TMMLSettings.SetKeyValue(KeyName: String; KeyValue: String);
+var
+ N, NN: TTreeNode;
+begin
+ if not KeyExists(KeyName) then
+ Exit;
+ if not IsKey(KeyName) then
+ Exit;
+
+ N := WalkToNode(KeyName);
+
+ if not N.HasChildren then
+ begin
+ NN := TTreeNode.Create(Nodes);
+ NN.Text := 'Value';
+ NN.MoveTo(N, naAddChild);
+ end;
+
+ if n <> nil then
+ N := N.GetFirstChild;
+ while N <> nil do
+ begin
+ if N.Text = 'Value' then
+ begin
+ if Assigned(N.Data) then
+ TSettingData(N.Data).Free;
+ N.Data := TSettingData.Create;
+ TSettingData(N.Data).Val := KeyValue;
+ end;
+ N := N.GetNextSibling;
+ end;
+end;
+
+procedure TMMLSettings.LoadFromXML(fileName: String);
+var
+ Doc: TXMLDocument;
+begin
+ ReadXMLFile(Doc, fileName);
+ InternalLoadFromXML(Doc);
+ Doc.Free;
+end;
+
+procedure TMMLSettings.WriteXMLData(n: TTreeNode;
+ XMLNode: TDOMNode; XMLDoc: TXMLDocument;
+ var XMLChild: TDOMNode; var C: Integer);
+
+var
+ DDataNode, DataNode: TDOMNode;
+
+begin
+ if n.Text = 'Value' then
+ begin
+ XMLChild := XMLDoc.CreateTextNode(TSettingData(N.Data).Val);
+ end else
+ begin
+ XMLChild := XMLDoc.CreateElement(n.Text);
+ end;
+ Inc(C);
+ XMLNode.AppendChild(XMLChild);
+end;
+
+procedure TMMLSettings.WalkTree(Node: TTreeNode; XMLNode: TDOMNode; XMLDoc: TXMLDocument;
+ var C: Integer);
+var
+ N: TTreeNode;
+ XMLChild: TDOMNode;
+
+begin
+ N := Node.GetFirstChild;
+
+ while assigned(n) do
+ begin
+ WriteXMLData(n, XMLNode, XMLDoc, XMLChild, C);
+
+ WalkTree(n, XMLChild, XMLDoc, C);
+ n := n.GetNextSibling;
+ end;
+end;
+
+procedure TMMLSettings.SaveToXML(fileName: String);
+var
+ XMLDoc: TXMLDocument;
+ RootNode: TDOMNode;
+ C: Integer;
+begin
+ XMLDoc := TXMLDocument.Create;
+
+ RootNode := XMLDoc.CreateElement('Settings');
+ XMLDoc.AppendChild(RootNode);
+
+ RootNode := XMLDoc.DocumentElement;
+
+ C := 0;
+ if Nodes.GetFirstNode <> nil then
+ WalkTree(Nodes.GetFirstNode, RootNode, XMLDoc, C);
+
+ WriteXMLFile(XMLDoc, fileName);
+
+ XMLDoc.Free;
+end;
+
+end.
+