1 | unit UFormSettings;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
|
---|
9 | ULanguages;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormSettings }
|
---|
14 |
|
---|
15 | TFormSettings = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | ComboBoxLanguage: TComboBox;
|
---|
19 | Label1: TLabel;
|
---|
20 | Label2: TLabel;
|
---|
21 | TrackBar1: TTrackBar;
|
---|
22 | procedure ButtonCancelClick(Sender: TObject);
|
---|
23 | procedure ButtonOkClick(Sender: TObject);
|
---|
24 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
25 | procedure FormCreate(Sender: TObject);
|
---|
26 | procedure FormShow(Sender: TObject);
|
---|
27 | private
|
---|
28 |
|
---|
29 | public
|
---|
30 |
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | FormSettings: TFormSettings;
|
---|
35 |
|
---|
36 |
|
---|
37 | implementation
|
---|
38 |
|
---|
39 | {$R *.lfm}
|
---|
40 |
|
---|
41 | uses
|
---|
42 | UCore;
|
---|
43 |
|
---|
44 | resourcestring
|
---|
45 | SLanguageChangeTitle = 'Language change';
|
---|
46 | SLanguageChangeMessage = 'Interface language was changed. It may require restart of application.';
|
---|
47 |
|
---|
48 |
|
---|
49 | { TFormSettings }
|
---|
50 |
|
---|
51 | procedure TFormSettings.ButtonCancelClick(Sender: TObject);
|
---|
52 | begin
|
---|
53 | Close;
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TFormSettings.ButtonOkClick(Sender: TObject);
|
---|
57 | begin
|
---|
58 | Core.Game.AnimationDuration := TrackBar1.Position;
|
---|
59 | if ComboBoxLanguage.ItemIndex <> -1 then begin
|
---|
60 | if (Core.Translator1.Language <> TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex])) then
|
---|
61 | MessageDlg(SLanguageChangeTitle, SLanguageChangeMessage, mtInformation, [mbOk], 0);
|
---|
62 | Core.Translator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
---|
63 | end;
|
---|
64 | Close;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
68 | );
|
---|
69 | begin
|
---|
70 | Core.PersistentForm1.Save(Self);
|
---|
71 | end;
|
---|
72 |
|
---|
73 | procedure TFormSettings.FormCreate(Sender: TObject);
|
---|
74 | begin
|
---|
75 | Core.Translator1.TranslateComponentRecursive(Self);
|
---|
76 | Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TFormSettings.FormShow(Sender: TObject);
|
---|
80 | begin
|
---|
81 | Core.PersistentForm1.Load(Self);
|
---|
82 | TrackBar1.Position := Core.Game.AnimationDuration;
|
---|
83 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Translator1.Language);
|
---|
84 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | end.
|
---|
88 |
|
---|