1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-12 04:15:07 -05:00
Simba/Projects/SAMufasaGUI/simbasettings.pas
Wizzup? ef804714c4 More changes
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@382 3f818213-9676-44b0-a9b4-5e4c4e03d09d
2010-01-07 20:25:10 +00:00

100 lines
2.1 KiB
ObjectPascal

unit simbasettings;
{$mode objfpc} {$M+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
ComCtrls, StdCtrls, settings;
const
SimbaSettingsFile = 'settings.xml';
type
{ TSettingsForm }
TSettingsForm = class(TForm)
SettingsFormButtonCancel: TButton;
SettingsFormButtonOK: TButton;
SettingsTreeView: TTreeView;
Settings: TMMLSettings;
procedure SettingsFormButtonCancelClick(Sender: TObject);
procedure SettingsFormButtonOKClick(Sender: TObject);
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.SettingsFormButtonOKClick(Sender: TObject);
begin
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
SettingsForm.ModalResult:=mrOK;
end;
procedure TSettingsForm.SettingsFormButtonCancelClick(Sender: TObject);
begin
if not FileExists(SimbaSettingsFile) then
begin
SettingsForm.SettingsTreeView.Items.Clear;
SettingsForm.Settings.SaveToXML(SimbaSettingsFile);
SettingsForm.SettingsTreeView.Items.Clear;
SettingsForm.Settings.LoadFromXML(SimbaSettingsFile);
end;
SettingsForm.ModalResult:=mrOK;
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.