source: trunk/Forms/FormSettings.pas

Last change on this file was 318, checked in by chronos, 6 months ago
  • Modified: Code cleanup.
File size: 3.0 KB
Line 
1unit FormSettings;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Spin, ComCtrls, ExtCtrls, FormEx;
8
9type
10
11 { TFormSettings }
12
13 TFormSettings = class(TFormEx)
14 ButtonOk: TButton;
15 ButtonCancel: TButton;
16 CheckBox2: TCheckBox;
17 CheckBoxAutoSaveTurn: TCheckBox;
18 CheckBoxDevelMode: TCheckBox;
19 CheckBoxReopenLastFile: TCheckBox;
20 ComboBoxLanguage: TComboBox;
21 ComboBoxTheme: TComboBox;
22 Label1: TLabel;
23 Label2: TLabel;
24 Label3: TLabel;
25 Label4: TLabel;
26 Label5: TLabel;
27 Label6: TLabel;
28 PageControl1: TPageControl;
29 Panel1: TPanel;
30 Panel2: TPanel;
31 SpinEditAnimSpeed: TSpinEdit;
32 SpinEditX: TSpinEdit;
33 SpinEditY: TSpinEdit;
34 TabSheetGeneral: TTabSheet;
35 TabSheetDebug: TTabSheet;
36 procedure CheckBox2Change(Sender: TObject);
37 procedure FormCreate(Sender: TObject);
38 procedure FormShow(Sender: TObject);
39 public
40 procedure Load;
41 procedure Save;
42 end;
43
44
45implementation
46
47{$R *.lfm}
48
49uses
50 Core, Languages, Theme;
51
52{ TFormSettings }
53
54procedure TFormSettings.CheckBox2Change(Sender: TObject);
55begin
56 SpinEditX.Enabled := not CheckBox2.Checked;
57 SpinEditY.Enabled := not CheckBox2.Checked;
58end;
59
60procedure TFormSettings.FormCreate(Sender: TObject);
61begin
62 PageControl1.TabIndex := 0;
63 Core.Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
64 Core.Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
65end;
66
67procedure TFormSettings.FormShow(Sender: TObject);
68begin
69 {$IFDEF DEBUG}
70 TabSheetDebug.TabVisible := True;
71 {$ELSE}
72 TabSheetDebug.TabVisible := False;
73 {$ENDIF}
74end;
75
76procedure TFormSettings.Load;
77begin
78 ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Core.Translator1.Language);
79 if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
80 ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.Core.ThemeManager1.Theme);
81 if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
82 CheckBoxDevelMode.Checked := Core.Core.DevelMode;
83 SpinEditAnimSpeed.Value := Core.Core.AnimationSpeed;
84 CheckBox2.Checked := Core.Core.ScaleDPI1.AutoDetect;
85 SpinEditX.Value := Core.Core.ScaleDPI1.DPI.X;
86 SpinEditY.Value := Core.Core.ScaleDPI1.DPI.Y;
87 CheckBoxAutoSaveTurn.Checked := Core.Core.AutoSaveEnabled;
88 CheckBoxReopenLastFile.Checked := Core.Core.ReopenLastFile;
89end;
90
91procedure TFormSettings.Save;
92begin
93 if ComboBoxLanguage.ItemIndex <> -1 then
94 Core.Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
95 if ComboBoxTheme.ItemIndex <> -1 then
96 Core.Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
97 Core.Core.DevelMode := CheckBoxDevelMode.Checked;
98 Core.Core.AnimationSpeed := SpinEditAnimSpeed.Value;
99 Core.Core.ScaleDPI1.AutoDetect := CheckBox2.Checked;
100 Core.Core.ScaleDPI1.DPI := Point(SpinEditX.Value, SpinEditY.Value);
101 Core.Core.AutoSaveEnabled := CheckBoxAutoSaveTurn.Checked;
102 Core.Core.ReopenLastFile := CheckBoxReopenLastFile.Checked;
103end;
104
105end.
106
Note: See TracBrowser for help on using the repository browser.