2010-01-05 13:35:42 -05:00
|
|
|
unit Unit1;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2010-01-06 14:06:20 -05:00
|
|
|
ComCtrls, StdCtrls;
|
2010-01-05 13:35:42 -05:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
|
|
|
ListView1: TListView;
|
|
|
|
SaveButton: TButton;
|
|
|
|
LoadButton: TButton;
|
|
|
|
TreeView1: TTreeView;
|
|
|
|
procedure SaveButtonClick(Sender: TObject);
|
|
|
|
procedure LoadButtonClick(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ private declarations }
|
|
|
|
|
|
|
|
public
|
|
|
|
{ public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
settings;
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
procedure TForm1.SaveButtonClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
sett: TMMLSettings;
|
|
|
|
s: TStringArray;
|
|
|
|
i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
sett := TMMLSettings.Create(TreeView1.Items);
|
2010-01-05 18:05:03 -05:00
|
|
|
sett.CreateKey('Settings/FullScreen/wat', true);
|
|
|
|
sett.SetKeyValue('Settings/FullScreen/wat', 'TRUE');
|
|
|
|
writeln(sett.GetKeyValue('Settings/FullScreen/wat'));
|
2010-01-05 13:35:42 -05:00
|
|
|
|
2010-01-05 18:05:03 -05:00
|
|
|
writeln(sett.GetSetDefaultKeyValue('Settings/FullScreen/wat2', 'OWAT'));
|
2010-01-05 13:35:42 -05:00
|
|
|
|
2010-01-05 18:05:03 -05:00
|
|
|
writeln(sett.GetSetDefaultKeyValue('Settings/Component1/hoiii', 'NO U'));
|
2010-01-05 13:35:42 -05:00
|
|
|
|
2010-01-05 18:05:03 -05:00
|
|
|
writeln(sett.GetSetDefaultKeyValue('Settings/Component2/hoi', 'OK'));
|
|
|
|
s := sett.ListKeys('Settings/FullScreen');
|
2010-01-05 13:35:42 -05:00
|
|
|
for i := 0 to high(s) do
|
|
|
|
writeln(s[i]);
|
|
|
|
|
|
|
|
|
|
|
|
{ ss:='Settings' + '/' + s[0];
|
|
|
|
while length(s) > 0 do
|
|
|
|
begin
|
|
|
|
s := sett.ListKeys(ss);
|
|
|
|
if(length(s)>0) then
|
|
|
|
ss:=ss +'/' + s[0];
|
|
|
|
end; }
|
|
|
|
|
2010-01-06 14:06:20 -05:00
|
|
|
sett.SaveToXML('settings.xml');
|
2010-01-05 13:35:42 -05:00
|
|
|
sett.Free;
|
2010-01-06 14:06:20 -05:00
|
|
|
//SaveToXML('settings.xml');
|
2010-01-05 13:35:42 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.LoadButtonClick(Sender: TObject);
|
|
|
|
var
|
2010-01-06 14:06:20 -05:00
|
|
|
s: TMMLSettings;
|
2010-01-05 13:35:42 -05:00
|
|
|
begin
|
|
|
|
if not FileExists('settings.xml') then
|
|
|
|
begin
|
|
|
|
TreeView1.Items.Clear;
|
2010-01-06 14:06:20 -05:00
|
|
|
s := TMMLSettings.Create(TreeView1.Items);
|
|
|
|
s.SaveToXML('settings.xml');
|
|
|
|
s.Free;
|
2010-01-05 13:35:42 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
TreeView1.Items.Clear;
|
2010-01-06 14:06:20 -05:00
|
|
|
s := TMMLSettings.Create(TreeView1.Items);
|
|
|
|
s.LoadFromXML('settings.xml');
|
2010-01-05 13:35:42 -05:00
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
{$I unit1.lrs}
|
|
|
|
|
|
|
|
end.
|
|
|
|
|