Changeset 13 for trunk/Forms


Ignore:
Timestamp:
Oct 5, 2019, 11:16:00 AM (5 years ago)
Author:
chronos
Message:
  • Added: Allow to change interface language in settings form.
Location:
trunk/Forms
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r8 r13  
    11object FormNew: TFormNew
    2   Left = 759
     2  Left = 753
    33  Height = 212
    4   Top = 822
     4  Top = 825
    55  Width = 487
    66  Caption = 'New game'
     
    3232      '9 x 9'
    3333      '10 x 10 '
     34      '11 x 11'
     35      '12 x 12'
    3436    )
    3537    Style = csDropDownList
  • trunk/Forms/UFormNew.pas

    r8 r13  
    11unit UFormNew;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
  • trunk/Forms/UFormSettings.lfm

    r11 r13  
    88  ClientWidth = 480
    99  DesignTimePPI = 144
     10  OnClose = FormClose
     11  OnCreate = FormCreate
    1012  OnShow = FormShow
    1113  LCLVersion = '2.0.2.0'
     
    4850    TabOrder = 2
    4951  end
     52  object ComboBoxLanguage: TComboBox
     53    Left = 208
     54    Height = 43
     55    Top = 86
     56    Width = 230
     57    ItemHeight = 0
     58    Style = csDropDownList
     59    TabOrder = 3
     60  end
     61  object Label2: TLabel
     62    Left = 19
     63    Height = 26
     64    Top = 94
     65    Width = 88
     66    Caption = 'Language:'
     67    ParentColor = False
     68  end
    5069end
  • trunk/Forms/UFormSettings.lrj

    r11 r13  
    33{"hash":69745274,"name":"tformsettings.label1.caption","sourcebytes":[65,110,105,109,97,116,105,111,110,32,115,112,101,101,100,58],"value":"Animation speed:"},
    44{"hash":1339,"name":"tformsettings.buttonok.caption","sourcebytes":[79,75],"value":"OK"},
    5 {"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"}
     5{"hash":77089212,"name":"tformsettings.buttoncancel.caption","sourcebytes":[67,97,110,99,101,108],"value":"Cancel"},
     6{"hash":82521866,"name":"tformsettings.label2.caption","sourcebytes":[76,97,110,103,117,97,103,101,58],"value":"Language:"}
    67]}
  • trunk/Forms/UFormSettings.pas

    r11 r13  
    66
    77uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls;
     8  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
     9  ULanguages;
    910
    1011type
     
    1516    ButtonOk: TButton;
    1617    ButtonCancel: TButton;
     18    ComboBoxLanguage: TComboBox;
    1719    Label1: TLabel;
     20    Label2: TLabel;
    1821    TrackBar1: TTrackBar;
    1922    procedure ButtonCancelClick(Sender: TObject);
    2023    procedure ButtonOkClick(Sender: TObject);
     24    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     25    procedure FormCreate(Sender: TObject);
    2126    procedure FormShow(Sender: TObject);
    2227  private
     
    2934  FormSettings: TFormSettings;
    3035
     36
    3137implementation
    3238
     
    3541uses
    3642  UCore;
     43
     44resourcestring
     45  SLanguageChangeTitle = 'Language change';
     46  SLanguageChangeMessage = 'Interface language was changed. It may require restart of application.';
     47
    3748
    3849{ TFormSettings }
     
    4657begin
    4758  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;
    4864  Close;
     65end;
     66
     67procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction
     68  );
     69begin
     70  Core.PersistentForm1.Save(Self);
     71end;
     72
     73procedure TFormSettings.FormCreate(Sender: TObject);
     74begin
     75  Core.Translator1.LanguageListToStrings(ComboBoxLanguage.Items);
    4976end;
    5077
    5178procedure TFormSettings.FormShow(Sender: TObject);
    5279begin
     80  Core.PersistentForm1.Load(Self);
    5381  TrackBar1.Position := Core.Game.AnimationDuration;
     82  ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Translator1.Language);
     83  if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
    5484end;
    5585
Note: See TracChangeset for help on using the changeset viewer.