Changeset 13


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
Files:
9 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
  • trunk/Languages/Game2048.cs.po

    r12 r13  
    1313
    1414#: tcore.aabout.caption
    15 #, fuzzy
    1615msgctxt "tcore.aabout.caption"
    1716msgid "About"
     
    1918
    2019#: tcore.aexit.caption
    21 #, fuzzy
    2220msgctxt "tcore.aexit.caption"
    2321msgid "Exit"
     
    2523
    2624#: tcore.agamenew.caption
    27 #, fuzzy
    2825msgctxt "tcore.agamenew.caption"
    2926msgid "New..."
     
    3128
    3229#: tcore.asettings.caption
    33 #, fuzzy
    3430msgctxt "tcore.asettings.caption"
    3531msgid "Settings"
     
    8884
    8985#: tformsettings.buttoncancel.caption
    90 #, fuzzy
    9186msgctxt "tformsettings.buttoncancel.caption"
    9287msgid "Cancel"
     
    9489
    9590#: tformsettings.buttonok.caption
    96 #, fuzzy
    9791msgctxt "tformsettings.buttonok.caption"
    9892msgid "OK"
     
    106100#: tformsettings.label1.caption
    107101msgid "Animation speed:"
    108 msgstr ""
     102msgstr "Rychlost animace:"
     103
     104#: tformsettings.label2.caption
     105msgid "Language:"
     106msgstr "Jazyk:"
    109107
    110108#: uformabout.slicense
     
    120118msgstr "Verze"
    121119
     120#: uformsettings.slanguagechangemessage
     121msgid "Interface language was changed. It may require restart of application."
     122msgstr "Jazyk rozhraní byl změněn. To může vyžadovat restart aplikace."
     123
     124#: uformsettings.slanguagechangetitle
     125msgid "Language change"
     126msgstr "Změna jazyka"
     127
    122128#: ugame.sgameovercaption
    123129msgid "Lost"
    124 msgstr ""
     130msgstr "Prohra"
    125131
    126132#: ugame.sgameovermessage
    127133msgid "Game over!"
    128 msgstr ""
     134msgstr "Konec hry!"
    129135
    130136#: ugame.swincaption
    131137msgid "Win"
    132 msgstr ""
     138msgstr "Vítězství"
    133139
    134140#: ugame.swinmessage
    135141msgid "You won! Do you want to continue to play?"
    136 msgstr ""
    137 
     142msgstr "Vyhrál jsi! Chceš pokračovat ve hře?"
  • trunk/Languages/Game2048.po

    r12 r13  
    9292msgstr ""
    9393
     94#: tformsettings.label2.caption
     95msgid "Language:"
     96msgstr ""
     97
    9498#: uformabout.slicense
    9599msgid "License"
     
    102106#: uformabout.sversion
    103107msgid "Version"
     108msgstr ""
     109
     110#: uformsettings.slanguagechangemessage
     111msgid "Interface language was changed. It may require restart of application."
     112msgstr ""
     113
     114#: uformsettings.slanguagechangetitle
     115msgid "Language change"
    104116msgstr ""
    105117
  • trunk/UCore.pas

    r11 r13  
    118118    Game.Size := Point(ReadIntegerWithDefault('SizeX', 4), ReadIntegerWithDefault('SizeY', 4));
    119119    Game.AnimationDuration := ReadIntegerWithDefault('AnimationDuration', 30);
     120    if ValueExists('LanguageCode') then
     121      Translator1.Language := Translator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
     122      else Translator1.Language := Translator1.Languages.SearchByCode('');
    120123  finally
    121124    Free;
     
    133136    WriteInteger('SizeY', Game.Size.Y);
    134137    WriteInteger('AnimationDuration', Game.AnimationDuration);
     138    if Assigned(Translator1.Language) and (Translator1.Language.Code <> '') then
     139      WriteString('LanguageCode', Translator1.Language.Code)
     140      else DeleteValue('LanguageCode');
    135141  finally
    136142    Free;
Note: See TracChangeset for help on using the changeset viewer.