1 | unit UCore;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, XMLConf, FileUtil, Controls, UProject, UPhysDrive,
|
---|
9 | UCoolTranslator, UPersistentForm, UApplicationInfo, URegistry, UScaleDPI,
|
---|
10 | Registry;
|
---|
11 |
|
---|
12 | type
|
---|
13 |
|
---|
14 | { TCore }
|
---|
15 |
|
---|
16 | TCore = class(TDataModule)
|
---|
17 | ApplicationInfo1: TApplicationInfo;
|
---|
18 | CoolTranslator1: TCoolTranslator;
|
---|
19 | ImageList1: TImageList;
|
---|
20 | PersistentForm1: TPersistentForm;
|
---|
21 | ScaleDPI1: TScaleDPI;
|
---|
22 | XMLConfig1: TXMLConfig;
|
---|
23 | procedure DataModuleCreate(Sender: TObject);
|
---|
24 | procedure DataModuleDestroy(Sender: TObject);
|
---|
25 | private
|
---|
26 | RegistryContext: TRegistryContext;
|
---|
27 | public
|
---|
28 | DevelMode: Boolean;
|
---|
29 | DriveList: TDriveList;
|
---|
30 | Project: TProject;
|
---|
31 | procedure LoadConfig;
|
---|
32 | procedure SaveConfig;
|
---|
33 | end;
|
---|
34 |
|
---|
35 | var
|
---|
36 | Core: TCore;
|
---|
37 |
|
---|
38 | implementation
|
---|
39 |
|
---|
40 | {$R *.lfm}
|
---|
41 |
|
---|
42 | { TCore }
|
---|
43 |
|
---|
44 | procedure TCore.DataModuleCreate(Sender: TObject);
|
---|
45 | begin
|
---|
46 | DriveList := TDriveList.Create;
|
---|
47 | Project := nil;
|
---|
48 | XMLConfig1.Filename := 'config.xml';
|
---|
49 | Randomize;
|
---|
50 | end;
|
---|
51 |
|
---|
52 | procedure TCore.DataModuleDestroy(Sender: TObject);
|
---|
53 | begin
|
---|
54 | if Assigned(Project) then FreeAndNil(Project);
|
---|
55 | FreeAndNil(DriveList);
|
---|
56 | end;
|
---|
57 |
|
---|
58 | procedure TCore.LoadConfig;
|
---|
59 | begin
|
---|
60 | RegistryContext := TRegistryContext.Create(ApplicationInfo1.RegistryRoot, ApplicationInfo1.RegistryKey);
|
---|
61 | PersistentForm1.RegistryContext := RegistryContext;
|
---|
62 | XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
|
---|
63 | ForceDirectories(ExtractFileDir(XMLConfig1.Filename));
|
---|
64 |
|
---|
65 | CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(string(XMLConfig1.GetValue('Language', unicodestring(''))));
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TCore.SaveConfig;
|
---|
69 | begin
|
---|
70 | XMLConfig1.SetValue('Language', UnicodeString(CoolTranslator1.Language.Code));
|
---|
71 | end;
|
---|
72 |
|
---|
73 | end.
|
---|
74 |
|
---|