| 1 | unit FormSettings;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
|
|---|
| 7 | Languages, Theme, FormEx;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 10 |
|
|---|
| 11 | { TFormSettings }
|
|---|
| 12 |
|
|---|
| 13 | TFormSettings = class(TFormEx)
|
|---|
| 14 | ButtonOk: TButton;
|
|---|
| 15 | ButtonCancel: TButton;
|
|---|
| 16 | ComboBoxLanguage: TComboBox;
|
|---|
| 17 | ComboBoxTheme: TComboBox;
|
|---|
| 18 | Label1: TLabel;
|
|---|
| 19 | Label2: TLabel;
|
|---|
| 20 | Label3: TLabel;
|
|---|
| 21 | ScrollBox1: TScrollBox;
|
|---|
| 22 | TrackBar1: TTrackBar;
|
|---|
| 23 | procedure ButtonCancelClick(Sender: TObject);
|
|---|
| 24 | procedure ButtonOkClick(Sender: TObject);
|
|---|
| 25 | procedure FormCreate(Sender: TObject);
|
|---|
| 26 | procedure FormShow(Sender: TObject);
|
|---|
| 27 | end;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | implementation
|
|---|
| 31 |
|
|---|
| 32 | {$R *.lfm}
|
|---|
| 33 |
|
|---|
| 34 | uses
|
|---|
| 35 | Core;
|
|---|
| 36 |
|
|---|
| 37 | resourcestring
|
|---|
| 38 | SLanguageChangeTitle = 'Language change';
|
|---|
| 39 | SLanguageChangeMessage = 'Interface language was changed. It may require restart of application.';
|
|---|
| 40 |
|
|---|
| 41 | { TFormSettings }
|
|---|
| 42 |
|
|---|
| 43 | procedure TFormSettings.ButtonCancelClick(Sender: TObject);
|
|---|
| 44 | begin
|
|---|
| 45 | Close;
|
|---|
| 46 | end;
|
|---|
| 47 |
|
|---|
| 48 | procedure TFormSettings.ButtonOkClick(Sender: TObject);
|
|---|
| 49 | begin
|
|---|
| 50 | Core.Core.Game.AnimationDuration := TrackBar1.Position;
|
|---|
| 51 | if ComboBoxLanguage.ItemIndex <> -1 then begin
|
|---|
| 52 | if (Core.Core.Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then
|
|---|
| 53 | MessageDlg(SLanguageChangeTitle, SLanguageChangeMessage, mtInformation, [mbOk], 0);
|
|---|
| 54 | Core.Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
|---|
| 55 | end;
|
|---|
| 56 | if ComboBoxTheme.ItemIndex <> -1 then
|
|---|
| 57 | Core.Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
|---|
| 58 | ModalResult := mrOk;
|
|---|
| 59 | end;
|
|---|
| 60 |
|
|---|
| 61 | procedure TFormSettings.FormCreate(Sender: TObject);
|
|---|
| 62 | begin
|
|---|
| 63 | Core.Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
|
|---|
| 64 | Core.Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
|
|---|
| 65 | end;
|
|---|
| 66 |
|
|---|
| 67 | procedure TFormSettings.FormShow(Sender: TObject);
|
|---|
| 68 | begin
|
|---|
| 69 | TrackBar1.Position := Core.Core.Game.AnimationDuration;
|
|---|
| 70 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Core.Translator1.Language);
|
|---|
| 71 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
|---|
| 72 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.Core.ThemeManager1.Theme);
|
|---|
| 73 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
|---|
| 74 | end;
|
|---|
| 75 |
|
|---|
| 76 | end.
|
|---|
| 77 |
|
|---|