Changeset 53


Ignore:
Timestamp:
Jan 4, 2022, 3:27:03 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Update Common package.
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r52 r53  
    55  Width = 770
    66  Caption = 'Tunneler'
    7   ClientHeight = 588
     7  ClientHeight = 584
    88  ClientWidth = 770
    99  DesignTimePPI = 144
     
    1919  object StatusBar1: TStatusBar
    2020    Left = 0
    21     Height = 36
    22     Top = 552
     21    Height = 27
     22    Top = 557
    2323    Width = 770
    2424    Panels = <   
     
    4949  object Image1: TImage
    5050    Left = 0
    51     Height = 552
     51    Height = 557
    5252    Top = 0
    5353    Width = 770
     
    135135  end
    136136  object AboutDialog1: TAboutDialog
    137     CoolTranslator = Core.Translator1
     137    Translator = Core.Translator1
    138138    ThemeManager = Core.ThemeManager1
    139139    ApplicationInfo = Core.ApplicationInfo
  • trunk/Forms/UFormMain.pas

    r52 r53  
    5555    procedure TimerEngineTickTimer(Sender: TObject);
    5656  private
    57     OriginalBounds: TRect;
    58     OriginalWindowState: TWindowState;
    59     ScreenBounds: TRect;
    6057    StartTime: TDateTime;
    6158    Drawing: Boolean;
     
    9289    StartTime := NowPrecise;
    9390    //Engine.Draw;
    94     Engine.Lock.Acquire;
    95     try
    96       //StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
    97       //  IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
    98       //  IntToStr(TPlayer(Engine.Players[0]).Direction);
    99       StatusBar1.Panels[2].Text := FloatToStr(RoundTo(Engine.DrawDuration / OneMillisecond, -2));
    100       StatusBar1.Panels[3].Text := Format(SRound, [IntToStr(Engine.CurrentRound),
    101         IntToStr(Engine.MaxRound)]);
    102     finally
    103       Engine.Lock.Release;
     91    if Assigned(Engine) then begin
     92      Engine.Lock.Acquire;
     93      try
     94        //StatusBar1.Panels[1].Text := IntToStr(TPlayer(Engine.Players[0]).Position.X) + ', ' +
     95        //  IntToStr(TPlayer(Engine.Players[0]).Position.Y) + ' ' +
     96        //  IntToStr(TPlayer(Engine.Players[0]).Direction);
     97        StatusBar1.Panels[2].Text := FloatToStr(RoundTo(Engine.DrawDuration / OneMillisecond, -2));
     98        StatusBar1.Panels[3].Text := Format(SRound, [IntToStr(Engine.CurrentRound),
     99          IntToStr(Engine.MaxRound)]);
     100      finally
     101        Engine.Lock.Release;
     102      end;
    104103    end;
    105104  finally
  • trunk/Languages/Tunneler.cs.po

    r52 r53  
    1313
    1414#: tformdebug.caption
    15 #, fuzzy
    1615msgctxt "tformdebug.caption"
    1716msgid "Debug"
     
    1918
    2019#: tformgameresult.caption
    21 #, fuzzy
    2220msgctxt "tformgameresult.caption"
    2321msgid "Game result"
     
    2523
    2624#: tformmain.aabout.caption
    27 #, fuzzy
    2825msgctxt "tformmain.aabout.caption"
    2926msgid "About"
     
    3128
    3229#: tformmain.aexit.caption
    33 #, fuzzy
    3430msgctxt "tformmain.aexit.caption"
    3531msgid "Exit"
     
    3733
    3834#: tformmain.afullscreen.caption
    39 #, fuzzy
    4035msgctxt "tformmain.afullscreen.caption"
    4136msgid "Fullscreen mode"
    42 msgstr "ReÅŸim celé obrazovky"
     37msgstr "Celá obrazovka"
    4338
    4439#: tformmain.anewgame.caption
    45 #, fuzzy
    4640msgctxt "tformmain.anewgame.caption"
    4741msgid "New game"
     
    4943
    5044#: tformmain.ashowmap.caption
    51 #, fuzzy
    5245msgctxt "tformmain.ashowmap.caption"
    5346msgid "Show map"
     
    5548
    5649#: tformmain.ashowrawimagedesc.caption
    57 #, fuzzy
    5850msgctxt "tformmain.ashowrawimagedesc.caption"
    5951msgid "Show RawImage Description"
     
    6153
    6254#: tformmain.caption
    63 #, fuzzy
    6455msgctxt "tformmain.caption"
    6556msgid "Tunneler"
     
    6758
    6859#: tformmain.menuitem1.caption
    69 #, fuzzy
    7060msgctxt "tformmain.menuitem1.caption"
    7161msgid "Game"
     
    7363
    7464#: tformmain.menuitem4.caption
    75 #, fuzzy
    7665msgctxt "tformmain.menuitem4.caption"
    7766msgid "View"
     
    8170msgctxt "tformmain.menuitem7.caption"
    8271msgid "Help"
    83 msgstr ""
     72msgstr "Nápověda"
    8473
    8574#: tformmap.caption
    86 #, fuzzy
    8775msgctxt "tformmap.caption"
    8876msgid "Map"
     
    183171msgid "%0:s of %1:s"
    184172msgstr "%0:s z %1:s"
    185 
  • trunk/Packages/Common/Common.lpk

    r51 r53  
    4141Source: https://svn.zdechov.net/PascalClassLibrary/Common/"/>
    4242    <License Value="Copy left."/>
    43     <Version Minor="8"/>
     43    <Version Minor="9"/>
    4444    <Files Count="29">
    4545      <Item1>
  • trunk/Packages/Common/UAboutDialog.pas

    r51 r53  
    1616  private
    1717    FApplicationInfo: TApplicationInfo;
    18     FCoolTranslator: TTranslator;
     18    FTranslator: TTranslator;
    1919    FThemeManager: TThemeManager;
    2020  public
     
    2222    procedure Show;
    2323  published
    24     property CoolTranslator: TTranslator read FCoolTranslator write FCoolTranslator;
     24    property Translator: TTranslator read FTranslator write FTranslator;
    2525    property ThemeManager: TThemeManager read FThemeManager write FThemeManager;
    2626    property ApplicationInfo: TApplicationInfo read FApplicationInfo write
  • trunk/Packages/Common/UFormAbout.pas

    r51 r53  
    5050  if Assigned(AboutDialog) then
    5151  with TAboutDialog(AboutDialog) do begin
    52     if Assigned(CoolTranslator) then
    53       CoolTranslator.TranslateComponentRecursive(Self);
     52    if Assigned(Translator) then
     53      Translator.TranslateComponentRecursive(Self);
    5454    if Assigned(ThemeManager) then
    5555      ThemeManager.UseTheme(Self);
  • trunk/Packages/Common/ULanguages.pas

    r51 r53  
    11unit ULanguages;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, Contnrs;
     8  Classes, SysUtils, fgl;
    99
    1010type
     
    1515  end;
    1616
    17   { TLanguageList }
    18 
    19   TLanguageList = class(TObjectList)
     17  { TLanguages }
     18
     19  TLanguages = class(TFPGObjectList<TLanguage>)
    2020    function SearchByCode(ACode: string): TLanguage;
    2121    procedure AddNew(Code: string; Name: string);
    22     constructor Create;
     22    constructor Create(FreeObjects: Boolean = True);
    2323  end;
    2424
     
    223223
    224224
    225 { TLanguageList }
    226 
    227 function TLanguageList.SearchByCode(ACode: string): TLanguage;
     225{ TLanguages }
     226
     227function TLanguages.SearchByCode(ACode: string): TLanguage;
    228228var
    229229  I: Integer;
     
    235235end;
    236236
    237 procedure TLanguageList.AddNew(Code: string; Name: string);
     237procedure TLanguages.AddNew(Code: string; Name: string);
    238238var
    239239  NewItem: TLanguage;
     
    245245end;
    246246
    247 constructor TLanguageList.Create;
     247constructor TLanguages.Create(FreeObjects: Boolean);
    248248begin
    249   inherited Create;
     249  inherited;
    250250  AddNew('', SLangAuto);
    251251  AddNew('aa', SLang_aa);
  • trunk/Packages/Common/UTranslator.pas

    r51 r53  
    11unit UTranslator;
    22
    3 {$mode Delphi}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8,
     8  Classes, SysUtils, Forms, ExtCtrls, Controls, fgl, LazFileUtils, LazUTF8,
    99  Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType,
    1010  LCLVersion;
     
    1212type
    1313  THandleStringEvent = function (AValue: string): string of object;
     14
     15  TPoFiles = class(TFPGObjectList<TPOFile>)
     16  end;
    1417
    1518  { TComponentExcludes }
     
    2427  { TComponentExcludesList }
    2528
    26   TComponentExcludesList = class(TObjectList)
     29  TComponentExcludesList = class(TFPGObjectList<TComponentExcludes>)
    2730    function FindByClassType(AClassType: TClass): TComponentExcludes;
    2831    procedure DumpToStrings(Strings: TStrings);
     
    3639    FOnAutomaticLanguage: THandleStringEvent;
    3740    FOnTranslate: TNotifyEvent;
    38     FPOFilesFolder: string;
    39     FPOFiles: TObjectList; // TObjectList<TPOFile>;
     41    FPoFilesFolder: string;
     42    FPoFiles: TPoFiles;
    4043    function GetLocale: string;
    4144    function GetLocaleShort: string;
     
    5053  public
    5154    ComponentExcludes: TComponentExcludesList;
    52     Languages: TLanguageList;
     55    Languages: TLanguages;
    5356    procedure Translate;
    54     procedure LanguageListToStrings(Strings: TStrings);
     57    procedure LanguageListToStrings(Strings: TStrings; WithCode: Boolean = True);
    5558    procedure TranslateResourceStrings(PoFileName: string);
    5659    procedure TranslateUnitResourceStrings(UnitName: string; PoFileName: string);
     
    6366    destructor Destroy; override;
    6467  published
    65     property POFilesFolder: string read FPOFilesFolder write SetPOFilesFolder;
     68    property POFilesFolder: string read FPoFilesFolder write SetPOFilesFolder;
    6669    property Language: TLanguage read FLanguage write SetLanguage;
    6770    property OnTranslate: TNotifyEvent read FOnTranslate write FOnTranslate;
     
    7174
    7275procedure Register;
     76
    7377
    7478implementation
     
    117121destructor TComponentExcludes.Destroy;
    118122begin
    119   PropertyExcludes.Free;
    120   inherited Destroy;
     123  FreeAndNil(PropertyExcludes);
     124  inherited;
    121125end;
    122126
     
    128132  I, J: Integer;
    129133  Po: TPoFile;
    130   Item: TPOFileItem;
     134  Item: TPoFileItem;
    131135begin
    132136  TranslateComponentRecursive(Application);
     
    134138  // Merge files to single translation file
    135139  try
    136     Po := TPOFile.Create;
    137     for I := 0 to FPOFiles.Count - 1 do
     140    Po := TPoFile.Create;
     141    for I := 0 to FPoFiles.Count - 1 do
    138142    with TPoFile(FPoFiles[I]) do
    139143      for J := 0 to Items.Count - 1 do
     
    162166  SearchMask: string;
    163167begin
    164   FPOFiles.Clear;
     168  FPoFiles.Clear;
    165169  if Assigned(FLanguage) then
    166170  try
     
    177181      if FileExists(FileName) and (
    178182      ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or
    179       (LocaleShort <> '')) then FPOFiles.Add(TPOFile.Create(FileName));
     183      (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName));
    180184    end;
    181185  finally
     
    281285var
    282286  Item: TClass;
    283 
    284287  Excludes: TComponentExcludes;
    285288begin
     
    301304function TTranslator.GetLangFileDir: string;
    302305begin
    303   Result := FPOFilesFolder;
     306  Result := FPoFilesFolder;
    304307  if Copy(Result, 1, 1) <> DirectorySeparator then
    305308    Result := ExtractFileDir(Application.ExeName) +
     
    307310end;
    308311
    309 procedure TTranslator.LanguageListToStrings(Strings: TStrings);
     312procedure TTranslator.LanguageListToStrings(Strings: TStrings; WithCode: Boolean = True);
    310313var
    311314  I: Integer;
     
    313316begin
    314317  with Strings do begin
    315     Clear;
    316     for I := 0 to Languages.Count - 1 do
    317     with TLanguage(Languages[I]) do
    318       if Available then begin
    319         ItemName := Name;
    320         if Code <> '' then ItemName := ItemName + ' (' + Code + ')';
    321         AddObject(ItemName, Languages[I]);
    322       end;
     318    BeginUpdate;
     319    try
     320      Clear;
     321      for I := 0 to Languages.Count - 1 do
     322      with Languages[I] do
     323        if Available then begin
     324          ItemName := Name;
     325          if WithCode and (Code <> '') then ItemName := ItemName + ' (' + Code + ')';
     326          AddObject(ItemName, Languages[I]);
     327        end;
     328    finally
     329      EndUpdate;
     330    end;
    323331  end;
    324332end;
     
    342350  if Text <> '' then begin
    343351    for I := 0 to FPoFiles.Count - 1 do begin
    344       Result := TPoFile(FPOFiles[I]).Translate(Identifier, Text);
     352      Result := TPoFile(FPoFiles[I]).Translate(Identifier, Text);
    345353      if Result <> Text then Break;
    346354    end;
     
    369377begin
    370378  LangDir := GetLangFileDir;
    371   TLanguage(Languages[0]).Available := True; // Automatic
     379  Languages.SearchByCode('').Available := True; // Automatic
    372380
    373381  for I := 1 to Languages.Count - 1 do
    374   with TLanguage(Languages[I]) do begin
     382  with Languages[I] do begin
    375383    Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) +
    376384      '.' + Code + ExtensionSeparator + 'po') or (Code = 'en');
     
    381389begin
    382390  inherited;
    383   FPOFiles := TObjectList.Create;
     391  FPoFiles := TPoFiles.Create;
    384392  ComponentExcludes := TComponentExcludesList.Create;
    385   Languages := TLanguageList.Create;
     393  Languages := TLanguages.Create;
    386394  POFilesFolder := 'Languages';
    387395  CheckLanguageFiles;
     
    395403destructor TTranslator.Destroy;
    396404begin
    397   FPOFiles.Free;
    398   Languages.Free;
    399   ComponentExcludes.Free;
    400   inherited Destroy;
     405  FreeAndNil(FPoFiles);
     406  FreeAndNil(Languages);
     407  FreeAndNil(ComponentExcludes);
     408  inherited;
    401409end;
    402410
  • trunk/tunneler.lpi

    r52 r53  
    6565      </Item2>
    6666      <SharedMatrixOptions Count="2">
    67         <Item1 ID="486260008827" Targets="Common,CoolTranslator,TemplateGenerics,CoolAudio" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
    68         <Item2 ID="478750724916" Targets="Common,CoolTranslator,TemplateGenerics,CoolAudio" Modes="Release" Value="-CX -XX -O3"/>
     67        <Item1 ID="486260008827" Targets="Common,TemplateGenerics,CoolAudio" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
     68        <Item2 ID="478750724916" Targets="Common,TemplateGenerics,CoolAudio" Modes="Release" Value="-CX -XX -O3"/>
    6969      </SharedMatrixOptions>
    7070    </BuildModes>
Note: See TracChangeset for help on using the changeset viewer.