1 | unit FormOptions;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
7 | Spin, ComCtrls, ExtCtrls, Target, Theme;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormOptions }
|
---|
12 |
|
---|
13 | TFormOptions = class(TForm)
|
---|
14 | ButtonOk: TButton;
|
---|
15 | ButtonCancel: TButton;
|
---|
16 | CheckBoxReopenLastFile: TCheckBox;
|
---|
17 | CheckBoxDPIAuto: TCheckBox;
|
---|
18 | CheckBoxOptimizeAddSub: TCheckBox;
|
---|
19 | CheckBoxDebugEnabled: TCheckBox;
|
---|
20 | CheckBoxOptimizeCopyMultiply: TCheckBox;
|
---|
21 | CheckBoxOptimizeSetZero: TCheckBox;
|
---|
22 | CheckBoxOptimizeMerge: TCheckBox;
|
---|
23 | CheckBoxOptimizeRelativeIndexes: TCheckBox;
|
---|
24 | ComboBoxLanguage: TComboBox;
|
---|
25 | ComboBoxOptimization: TComboBox;
|
---|
26 | ComboBoxTheme: TComboBox;
|
---|
27 | Label1: TLabel;
|
---|
28 | Label2: TLabel;
|
---|
29 | Label3: TLabel;
|
---|
30 | Label4: TLabel;
|
---|
31 | LabelDPI: TLabel;
|
---|
32 | LabelTheme: TLabel;
|
---|
33 | LabelX: TLabel;
|
---|
34 | PageControl1: TPageControl;
|
---|
35 | Panel1: TPanel;
|
---|
36 | Panel2: TPanel;
|
---|
37 | SpinEditCellSize: TSpinEdit;
|
---|
38 | SpinEditDPIX: TSpinEdit;
|
---|
39 | SpinEditDPIY: TSpinEdit;
|
---|
40 | SpinEditMemorySize: TSpinEdit;
|
---|
41 | TabSheetGeneral: TTabSheet;
|
---|
42 | TabSheetBuild: TTabSheet;
|
---|
43 | procedure CheckBoxDPIAutoChange(Sender: TObject);
|
---|
44 | procedure CheckBoxOptimizeCopyMultiplyChange(Sender: TObject);
|
---|
45 | procedure CheckBoxOptimizeRelativeIndexesChange(Sender: TObject);
|
---|
46 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
47 | procedure FormCreate(Sender: TObject);
|
---|
48 | procedure FormShow(Sender: TObject);
|
---|
49 | public
|
---|
50 | procedure UpdateInterface;
|
---|
51 | procedure Load;
|
---|
52 | procedure Save;
|
---|
53 | end;
|
---|
54 |
|
---|
55 |
|
---|
56 | implementation
|
---|
57 |
|
---|
58 | {$R *.lfm}
|
---|
59 |
|
---|
60 | uses
|
---|
61 | Core, Languages;
|
---|
62 |
|
---|
63 | { TFormOptions }
|
---|
64 |
|
---|
65 | procedure TFormOptions.FormShow(Sender: TObject);
|
---|
66 | begin
|
---|
67 | Core.Core.PersistentForm1.Load(Self);
|
---|
68 | end;
|
---|
69 |
|
---|
70 | procedure TFormOptions.UpdateInterface;
|
---|
71 | begin
|
---|
72 | SpinEditDPIX.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
73 | SpinEditDPIY.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
74 | LabelDPI.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
75 | LabelX.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
76 | if CheckBoxDPIAuto.Checked then begin
|
---|
77 | SpinEditDPIX.Value := ScreenInfo.PixelsPerInchX;
|
---|
78 | SpinEditDPIY.Value := ScreenInfo.PixelsPerInchY;
|
---|
79 | end;
|
---|
80 | CheckBoxOptimizeAddSub.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
81 | CheckBoxOptimizeSetZero.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
82 | CheckBoxOptimizeMerge.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
83 | CheckBoxOptimizeRelativeIndexes.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
84 | CheckBoxOptimizeCopyMultiply.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TFormOptions.Load;
|
---|
88 | begin
|
---|
89 | with Core.Core do begin
|
---|
90 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Translator.Language);
|
---|
91 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
---|
92 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(ThemeManager.Theme);
|
---|
93 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
---|
94 | CheckBoxReopenLastFile.Checked := OpenProjectOnStart;
|
---|
95 | CheckBoxOptimizeAddSub.Checked := Optimizations.AddSub;
|
---|
96 | CheckBoxOptimizeSetZero.Checked := Optimizations.SetZero;
|
---|
97 | CheckBoxOptimizeMerge.Checked := Optimizations.Merge;
|
---|
98 | CheckBoxOptimizeRelativeIndexes.Checked := Optimizations.RelativeIndexes;
|
---|
99 | CheckBoxOptimizeCopyMultiply.Checked := Optimizations.CopyMultiply;
|
---|
100 | SpinEditDPIX.Value := ScaleDPI1.DPI.X;
|
---|
101 | SpinEditDPIY.Value := ScaleDPI1.DPI.Y;
|
---|
102 | CheckBoxDPIAuto.Checked := ScaleDPI1.AutoDetect;
|
---|
103 | ComboBoxOptimization.ItemIndex := Integer(OptimizationLevel);
|
---|
104 | SpinEditCellSize.Value := CellSize;
|
---|
105 | SpinEditMemorySize.Value := MemorySize;
|
---|
106 | CheckBoxDebugEnabled.Checked := DebugEnabled;
|
---|
107 | if OptionsFormTabIndex < PageControl1.PageCount then
|
---|
108 | PageControl1.TabIndex := OptionsFormTabIndex
|
---|
109 | else PageControl1.TabIndex := 0;
|
---|
110 | end;
|
---|
111 | UpdateInterface;
|
---|
112 | end;
|
---|
113 |
|
---|
114 | procedure TFormOptions.Save;
|
---|
115 | begin
|
---|
116 | with Core.Core do begin
|
---|
117 | if ComboBoxLanguage.ItemIndex <> -1 then
|
---|
118 | Translator.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
---|
119 | if ComboBoxTheme.ItemIndex <> -1 then
|
---|
120 | ThemeManager.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
---|
121 | OpenProjectOnStart := CheckBoxReopenLastFile.Checked;
|
---|
122 | ScaleDPI1.DPI := Point(SpinEditDPIX.Value, SpinEditDPIY.Value);
|
---|
123 | ScaleDPI1.AutoDetect := CheckBoxDPIAuto.Checked;
|
---|
124 | OptimizationLevel := TCompilerOptimization(ComboBoxOptimization.ItemIndex);
|
---|
125 | CellSize := SpinEditCellSize.Value;
|
---|
126 | MemorySize := SpinEditMemorySize.Value;
|
---|
127 | Optimizations.AddSub := CheckBoxOptimizeAddSub.Checked;
|
---|
128 | Optimizations.SetZero := CheckBoxOptimizeSetZero.Checked;
|
---|
129 | Optimizations.Merge := CheckBoxOptimizeMerge.Checked;
|
---|
130 | Optimizations.RelativeIndexes := CheckBoxOptimizeRelativeIndexes.Checked;
|
---|
131 | Optimizations.CopyMultiply := CheckBoxOptimizeCopyMultiply.Checked;
|
---|
132 | DebugEnabled := CheckBoxDebugEnabled.Checked;
|
---|
133 | OptionsFormTabIndex := PageControl1.TabIndex;
|
---|
134 | end;
|
---|
135 | end;
|
---|
136 |
|
---|
137 | procedure TFormOptions.CheckBoxDPIAutoChange(Sender: TObject);
|
---|
138 | begin
|
---|
139 | UpdateInterface;
|
---|
140 | end;
|
---|
141 |
|
---|
142 | procedure TFormOptions.CheckBoxOptimizeCopyMultiplyChange(Sender: TObject);
|
---|
143 | begin
|
---|
144 | // Needed for optimize copy multiply
|
---|
145 | if CheckBoxOptimizeCopyMultiply.Checked then
|
---|
146 | CheckBoxOptimizeRelativeIndexes.Checked := True;
|
---|
147 | end;
|
---|
148 |
|
---|
149 | procedure TFormOptions.CheckBoxOptimizeRelativeIndexesChange(Sender: TObject);
|
---|
150 | begin
|
---|
151 | // Needed for optimize copy multiply
|
---|
152 | if not CheckBoxOptimizeRelativeIndexes.Checked then
|
---|
153 | CheckBoxOptimizeCopyMultiply.Checked := False;
|
---|
154 | end;
|
---|
155 |
|
---|
156 | procedure TFormOptions.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
157 | );
|
---|
158 | begin
|
---|
159 | Core.Core.PersistentForm1.Save(Self);
|
---|
160 | end;
|
---|
161 |
|
---|
162 | procedure TFormOptions.FormCreate(Sender: TObject);
|
---|
163 | begin
|
---|
164 | with Core.Core do begin
|
---|
165 | Translator.TranslateComponentRecursive(Self);
|
---|
166 | ThemeManager.UseTheme(Self);
|
---|
167 | ThemeManager.Themes.LoadToStrings(ComboBoxTheme.Items);
|
---|
168 | Translator.LanguageListToStrings(ComboBoxLanguage.Items);
|
---|
169 | end;
|
---|
170 | ComboBoxOptimization.Items.Clear;
|
---|
171 | ComboBoxOptimization.Items.Add(CompilerOptimizationText[coNone]);
|
---|
172 | ComboBoxOptimization.Items.Add(CompilerOptimizationText[coNormal]);
|
---|
173 | end;
|
---|
174 |
|
---|
175 | end.
|
---|
176 |
|
---|