| 1 | unit FormOptions;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 7 | Spin, ComCtrls, ExtCtrls, Target, Theme, FormEx;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 10 |
|
|---|
| 11 | { TFormOptions }
|
|---|
| 12 |
|
|---|
| 13 | TFormOptions = class(TFormEx)
|
|---|
| 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 FormCreate(Sender: TObject);
|
|---|
| 47 | public
|
|---|
| 48 | procedure UpdateInterface;
|
|---|
| 49 | procedure Load;
|
|---|
| 50 | procedure Save;
|
|---|
| 51 | end;
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | implementation
|
|---|
| 55 |
|
|---|
| 56 | {$R *.lfm}
|
|---|
| 57 |
|
|---|
| 58 | uses
|
|---|
| 59 | Core, Languages;
|
|---|
| 60 |
|
|---|
| 61 | { TFormOptions }
|
|---|
| 62 |
|
|---|
| 63 | procedure TFormOptions.UpdateInterface;
|
|---|
| 64 | begin
|
|---|
| 65 | SpinEditDPIX.Enabled := not CheckBoxDPIAuto.Checked;
|
|---|
| 66 | SpinEditDPIY.Enabled := not CheckBoxDPIAuto.Checked;
|
|---|
| 67 | LabelDPI.Enabled := not CheckBoxDPIAuto.Checked;
|
|---|
| 68 | LabelX.Enabled := not CheckBoxDPIAuto.Checked;
|
|---|
| 69 | if CheckBoxDPIAuto.Checked then begin
|
|---|
| 70 | SpinEditDPIX.Value := ScreenInfo.PixelsPerInchX;
|
|---|
| 71 | SpinEditDPIY.Value := ScreenInfo.PixelsPerInchY;
|
|---|
| 72 | end;
|
|---|
| 73 | CheckBoxOptimizeAddSub.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
|---|
| 74 | CheckBoxOptimizeSetZero.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
|---|
| 75 | CheckBoxOptimizeMerge.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
|---|
| 76 | CheckBoxOptimizeRelativeIndexes.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
|---|
| 77 | CheckBoxOptimizeCopyMultiply.Enabled := ComboBoxOptimization.ItemIndex > 0;
|
|---|
| 78 | end;
|
|---|
| 79 |
|
|---|
| 80 | procedure TFormOptions.Load;
|
|---|
| 81 | begin
|
|---|
| 82 | with Core.Core do begin
|
|---|
| 83 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Translator.Language);
|
|---|
| 84 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
|---|
| 85 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(ThemeManager.Theme);
|
|---|
| 86 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
|---|
| 87 | CheckBoxReopenLastFile.Checked := OpenProjectOnStart;
|
|---|
| 88 | CheckBoxOptimizeAddSub.Checked := Optimizations.AddSub;
|
|---|
| 89 | CheckBoxOptimizeSetZero.Checked := Optimizations.SetZero;
|
|---|
| 90 | CheckBoxOptimizeMerge.Checked := Optimizations.Merge;
|
|---|
| 91 | CheckBoxOptimizeRelativeIndexes.Checked := Optimizations.RelativeIndexes;
|
|---|
| 92 | CheckBoxOptimizeCopyMultiply.Checked := Optimizations.CopyMultiply;
|
|---|
| 93 | SpinEditDPIX.Value := ScaleDPI1.DPI.X;
|
|---|
| 94 | SpinEditDPIY.Value := ScaleDPI1.DPI.Y;
|
|---|
| 95 | CheckBoxDPIAuto.Checked := ScaleDPI1.AutoDetect;
|
|---|
| 96 | ComboBoxOptimization.ItemIndex := Integer(OptimizationLevel);
|
|---|
| 97 | SpinEditCellSize.Value := CellSize;
|
|---|
| 98 | SpinEditMemorySize.Value := MemorySize;
|
|---|
| 99 | CheckBoxDebugEnabled.Checked := DebugEnabled;
|
|---|
| 100 | if OptionsFormTabIndex < PageControl1.PageCount then
|
|---|
| 101 | PageControl1.TabIndex := OptionsFormTabIndex
|
|---|
| 102 | else PageControl1.TabIndex := 0;
|
|---|
| 103 | end;
|
|---|
| 104 | UpdateInterface;
|
|---|
| 105 | end;
|
|---|
| 106 |
|
|---|
| 107 | procedure TFormOptions.Save;
|
|---|
| 108 | begin
|
|---|
| 109 | with Core.Core do begin
|
|---|
| 110 | if ComboBoxLanguage.ItemIndex <> -1 then
|
|---|
| 111 | Translator.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
|---|
| 112 | if ComboBoxTheme.ItemIndex <> -1 then
|
|---|
| 113 | ThemeManager.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
|---|
| 114 | OpenProjectOnStart := CheckBoxReopenLastFile.Checked;
|
|---|
| 115 | ScaleDPI1.DPI := Point(SpinEditDPIX.Value, SpinEditDPIY.Value);
|
|---|
| 116 | ScaleDPI1.AutoDetect := CheckBoxDPIAuto.Checked;
|
|---|
| 117 | OptimizationLevel := TCompilerOptimization(ComboBoxOptimization.ItemIndex);
|
|---|
| 118 | CellSize := SpinEditCellSize.Value;
|
|---|
| 119 | MemorySize := SpinEditMemorySize.Value;
|
|---|
| 120 | Optimizations.AddSub := CheckBoxOptimizeAddSub.Checked;
|
|---|
| 121 | Optimizations.SetZero := CheckBoxOptimizeSetZero.Checked;
|
|---|
| 122 | Optimizations.Merge := CheckBoxOptimizeMerge.Checked;
|
|---|
| 123 | Optimizations.RelativeIndexes := CheckBoxOptimizeRelativeIndexes.Checked;
|
|---|
| 124 | Optimizations.CopyMultiply := CheckBoxOptimizeCopyMultiply.Checked;
|
|---|
| 125 | DebugEnabled := CheckBoxDebugEnabled.Checked;
|
|---|
| 126 | OptionsFormTabIndex := PageControl1.TabIndex;
|
|---|
| 127 | end;
|
|---|
| 128 | end;
|
|---|
| 129 |
|
|---|
| 130 | procedure TFormOptions.CheckBoxDPIAutoChange(Sender: TObject);
|
|---|
| 131 | begin
|
|---|
| 132 | UpdateInterface;
|
|---|
| 133 | end;
|
|---|
| 134 |
|
|---|
| 135 | procedure TFormOptions.CheckBoxOptimizeCopyMultiplyChange(Sender: TObject);
|
|---|
| 136 | begin
|
|---|
| 137 | // Needed for optimize copy multiply
|
|---|
| 138 | if CheckBoxOptimizeCopyMultiply.Checked then
|
|---|
| 139 | CheckBoxOptimizeRelativeIndexes.Checked := True;
|
|---|
| 140 | end;
|
|---|
| 141 |
|
|---|
| 142 | procedure TFormOptions.CheckBoxOptimizeRelativeIndexesChange(Sender: TObject);
|
|---|
| 143 | begin
|
|---|
| 144 | // Needed for optimize copy multiply
|
|---|
| 145 | if not CheckBoxOptimizeRelativeIndexes.Checked then
|
|---|
| 146 | CheckBoxOptimizeCopyMultiply.Checked := False;
|
|---|
| 147 | end;
|
|---|
| 148 |
|
|---|
| 149 | procedure TFormOptions.FormCreate(Sender: TObject);
|
|---|
| 150 | begin
|
|---|
| 151 | with Core.Core do begin
|
|---|
| 152 | ThemeManager.Themes.LoadToStrings(ComboBoxTheme.Items);
|
|---|
| 153 | Translator.LanguageListToStrings(ComboBoxLanguage.Items);
|
|---|
| 154 | end;
|
|---|
| 155 | ComboBoxOptimization.Items.Clear;
|
|---|
| 156 | ComboBoxOptimization.Items.Add(CompilerOptimizationText[coNone]);
|
|---|
| 157 | ComboBoxOptimization.Items.Add(CompilerOptimizationText[coNormal]);
|
|---|
| 158 | end;
|
|---|
| 159 |
|
|---|
| 160 | end.
|
|---|
| 161 |
|
|---|