1 | unit UFormOptions;
|
---|
2 |
|
---|
3 | {$mode delphi}{$H+}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | Spin, ComCtrls, ExtCtrls, UTarget, UTheme;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormOptions }
|
---|
14 |
|
---|
15 | TFormOptions = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | CheckBox1: TCheckBox;
|
---|
19 | CheckBoxDPIAuto: TCheckBox;
|
---|
20 | CheckBoxOptimizeAddSub: TCheckBox;
|
---|
21 | CheckBoxOptimizeCopyMultiply: 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 FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
45 | procedure FormCreate(Sender: TObject);
|
---|
46 | procedure FormShow(Sender: TObject);
|
---|
47 | private
|
---|
48 | { private declarations }
|
---|
49 | public
|
---|
50 | procedure UpdateInterface;
|
---|
51 | procedure Load;
|
---|
52 | procedure Save;
|
---|
53 | end;
|
---|
54 |
|
---|
55 | var
|
---|
56 | FormOptions: TFormOptions;
|
---|
57 |
|
---|
58 | implementation
|
---|
59 |
|
---|
60 | {$R *.lfm}
|
---|
61 |
|
---|
62 | uses
|
---|
63 | UCore, ULanguages;
|
---|
64 |
|
---|
65 | { TFormOptions }
|
---|
66 |
|
---|
67 | procedure TFormOptions.FormShow(Sender: TObject);
|
---|
68 | begin
|
---|
69 | Core.PersistentForm1.Load(Self);
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TFormOptions.UpdateInterface;
|
---|
73 | begin
|
---|
74 | SpinEditDPIX.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
75 | SpinEditDPIY.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
76 | LabelDPI.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
77 | LabelX.Enabled := not CheckBoxDPIAuto.Checked;
|
---|
78 | if CheckBoxDPIAuto.Checked then begin
|
---|
79 | SpinEditDPIX.Value := ScreenInfo.PixelsPerInchX;
|
---|
80 | SpinEditDPIY.Value := ScreenInfo.PixelsPerInchY;
|
---|
81 | end;
|
---|
82 | CheckBoxOptimizeAddSub.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
83 | CheckBoxOptimizeMerge.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
84 | CheckBoxOptimizeRelativeIndexes.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
85 | CheckBoxOptimizeCopyMultiply.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TFormOptions.Load;
|
---|
89 | begin
|
---|
90 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
|
---|
91 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
---|
92 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.ThemeManager.Theme);
|
---|
93 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
---|
94 | CheckBox1.Checked := Core.OpenProjectOnStart;
|
---|
95 | CheckBoxOptimizeAddSub.Checked := Core.Optimizations.AddSub;
|
---|
96 | CheckBoxOptimizeMerge.Checked := Core.Optimizations.Merge;
|
---|
97 | CheckBoxOptimizeRelativeIndexes.Checked := Core.Optimizations.RelativeIndexes;
|
---|
98 | CheckBoxOptimizeCopyMultiply.Checked := Core.Optimizations.CopyMultiply;
|
---|
99 | SpinEditDPIX.Value := Core.ScaleDPI1.DPI.X;
|
---|
100 | SpinEditDPIY.Value := Core.ScaleDPI1.DPI.Y;
|
---|
101 | CheckBoxDPIAuto.Checked := Core.ScaleDPI1.AutoDetect;
|
---|
102 | ComboBoxOptimization.ItemIndex := Integer(Core.OptimizationLevel);
|
---|
103 | SpinEditCellSize.Value := Core.CellSize;
|
---|
104 | SpinEditMemorySize.Value := Core.MemorySize;
|
---|
105 | UpdateInterface;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | procedure TFormOptions.Save;
|
---|
109 | begin
|
---|
110 | if ComboBoxLanguage.ItemIndex <> -1 then
|
---|
111 | Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
---|
112 | if ComboBoxTheme.ItemIndex <> -1 then
|
---|
113 | Core.ThemeManager.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
---|
114 | Core.OpenProjectOnStart := CheckBox1.Checked;
|
---|
115 | Core.ScaleDPI1.DPI := Point(SpinEditDPIX.Value, SpinEditDPIY.Value);
|
---|
116 | Core.ScaleDPI1.AutoDetect := CheckBoxDPIAuto.Checked;
|
---|
117 | Core.OptimizationLevel := TCompilerOptimization(ComboBoxOptimization.ItemIndex);
|
---|
118 | Core.CellSize := SpinEditCellSize.Value;
|
---|
119 | Core.MemorySize := SpinEditMemorySize.Value;
|
---|
120 | Core.Optimizations.AddSub := CheckBoxOptimizeAddSub.Checked;
|
---|
121 | Core.Optimizations.Merge := CheckBoxOptimizeMerge.Checked;
|
---|
122 | Core.Optimizations.RelativeIndexes := CheckBoxOptimizeRelativeIndexes.Checked;
|
---|
123 | Core.Optimizations.CopyMultiply := CheckBoxOptimizeCopyMultiply.Checked;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | procedure TFormOptions.CheckBoxDPIAutoChange(Sender: TObject);
|
---|
127 | begin
|
---|
128 | UpdateInterface;
|
---|
129 | end;
|
---|
130 |
|
---|
131 | procedure TFormOptions.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
132 | );
|
---|
133 | begin
|
---|
134 | Core.PersistentForm1.Save(Self);
|
---|
135 | end;
|
---|
136 |
|
---|
137 | procedure TFormOptions.FormCreate(Sender: TObject);
|
---|
138 | begin
|
---|
139 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
---|
140 | Core.ThemeManager.UseTheme(Self);
|
---|
141 | Core.ThemeManager.Themes.LoadToStrings(ComboBoxTheme.Items);
|
---|
142 | Core.CoolTranslator1.LanguageListToStrings(ComboBoxLanguage.Items);
|
---|
143 | end;
|
---|
144 |
|
---|
145 | end.
|
---|
146 |
|
---|