summaryrefslogtreecommitdiff
path: root/plugins/Chess4Net/LookFeelOptionsUnit.pas
blob: 138ab498ae1166238e8b558833ca6cdf54668f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
unit LookFeelOptionsUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls,
  ModalForm, TntStdCtrls,
  // Chess4Net units
  LocalizerUnit;

type
  TLookFeelOptionsForm = class(TModalForm, ILocalizable)
    OkButton: TTntButton;
    CancelButton: TTntButton;
    AnimationComboBox: TTntComboBox;
    AnimateLabel: TTntLabel;
    BoxPanel: TPanel;
    HilightLastMoveBox: TTntCheckBox;
    FlashIncomingMoveBox: TTntCheckBox;
    CoordinatesBox: TTntCheckBox;
    StayOnTopBox: TTntCheckBox;
    ExtraExitBox: TTntCheckBox;
    GUILangLabel: TTntLabel;
    GUILangComboBox: TTntComboBox;
    procedure FormCreate(Sender: TObject);
    procedure GUILangComboBoxChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure ILocalizable.Localize = FLocalize;
    procedure FLocalize;
  protected
    function GetModalID: TModalFormID; override;  
  end;

implementation

{$R *.dfm}

function TLookFeelOptionsForm. GetModalID: TModalFormID;
begin
  Result := mfLookFeel;
end;


procedure TLookFeelOptionsForm.FormCreate(Sender: TObject);
var
  i: integer;
begin
{$IFDEF SKYPE}
  StayOnTopBox.Enabled := FALSE; // TODO: this was done to prevent non-modal dialogs be overlapped by ChessForm. Resolve later
{$ENDIF}

  // Fill GUI Languages combo box
  GUILangComboBox.Clear;
  with TLocalizer.Instance do
  begin
    for i := 0 to LanguagesCount - 1 do
      GUILangComboBox.Items.Add(LanguageName[i]);
    GUILangComboBox.ItemIndex := ActiveLanguage;
  end;

  TLocalizer.Instance.AddSubscriber(self);
  FLocalize;
end;


procedure TLookFeelOptionsForm.FLocalize;
var
  iSavedAnimation: integer;
begin
  with TLocalizer.Instance do
  begin
    Caption := GetLabel(0);
    AnimateLabel.Caption := GetLabel(1);
    with AnimationComboBox do
    begin
      iSavedAnimation := ItemIndex;
      Items[0] := GetLabel(2);
      Items[1] := GetLabel(3);
      Items[2] := GetLabel(4);
      ItemIndex := iSavedAnimation;
    end;
    HilightLastMoveBox.Caption := GetLabel(5);
    FlashIncomingMoveBox.Caption := GetLabel(6);
    CoordinatesBox.Caption := GetLabel(7);
    StayOnTopBox.Caption := GetLabel(8);
    ExtraExitBox.Caption := GetLabel(9);
    GUILangLabel.Caption := GetLabel(10);

    OkButton.Caption := GetLabel(11);
    CancelButton.Caption := GetLabel(12);
  end;
end;


procedure TLookFeelOptionsForm.GUILangComboBoxChange(Sender: TObject);
begin
  TLocalizer.Instance.ActiveLanguage := GUILangComboBox.ItemIndex;
end;


procedure TLookFeelOptionsForm.FormDestroy(Sender: TObject);
begin
  TLocalizer.Instance.DeleteSubscriber(self);
end;

end.