Changeset 64 for trunk


Ignore:
Timestamp:
Jan 14, 2017, 12:52:41 AM (8 years ago)
Author:
chronos
Message:
  • Added: New configuration dialog for selecting interface language.
  • Added: Czech and Deutch language recoded to UTF-8.
Location:
trunk
Files:
51 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Directories.pas

    r38 r64  
    66var
    77  HomeDir, DataDir: string;
     8  LocaleCode: string;
    89
    9 function LocalizedFilePath(path: string): string;
     10function LocalizedFilePath(const Path: string): string;
    1011
    1112
     
    2627end;
    2728
    28 function LocalizedFilePath(path: string): string;
     29function LocalizedFilePath(const Path: string): string;
    2930begin
    30   result := DataDir + 'Localization' + DirectorySeparator + path;
    31   if not FileExists(result) then
    32     result := HomeDir + path
     31  if LocaleCode <> '' then begin
     32    Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCode + DirectorySeparator + Path;
     33    if not FileExists(Result) then
     34      Result := HomeDir + Path;
     35  end else Result := HomeDir + Path;
    3336end;
    3437
    3538procedure InitUnit;
    3639begin
     40  LocaleCode := '';
    3741  HomeDir := ExtractFilePath(ParamStr(0));
    3842
  • trunk/Inp.pas

    r38 r64  
    66uses
    77  ScreenTools, Messg,
    8 
    98  LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms,
    109  ButtonA, StdCtrls;
     
    3938  TitleHeight := ClientHeight;
    4039  InitButtons();
    41   Center := true
     40  Center := true;
    4241end;
    4342
  • trunk/Integrated.lpi

    r55 r64  
    173173      </Item2>
    174174    </RequiredPackages>
    175     <Units Count="43">
     175    <Units Count="44">
    176176      <Unit0>
    177177        <Filename Value="Integrated.lpr"/>
     
    238238        <Filename Value="Inp.pas"/>
    239239        <IsPartOfProject Value="True"/>
    240         <HasResources Value="True"/>
     240        <ComponentName Value="InputDlg"/>
     241        <HasResources Value="True"/>
     242        <ResourceBaseClass Value="Form"/>
    241243      </Unit13>
    242244      <Unit14>
     
    408410        <IsPartOfProject Value="True"/>
    409411      </Unit42>
     412      <Unit43>
     413        <Filename Value="Locale.pas"/>
     414        <IsPartOfProject Value="True"/>
     415        <ComponentName Value="LocaleDlg"/>
     416        <ResourceBaseClass Value="Form"/>
     417      </Unit43>
    410418    </Units>
    411419  </ProjectOptions>
  • trunk/Integrated.lpr

    r55 r64  
    6363  DotNetClient := nil;
    6464  Application.Initialize;
    65   Application.Title := 'C-evo';
     65  Application.Title := 'c-evo';
    6666  Application.CreateForm(TDirectDlg, DirectDlg);
    6767  Application.CreateForm(TStartDlg, StartDlg);
  • trunk/LocalPlayer/Term.pas

    r61 r64  
    12711271  begin
    12721272    UnusedTribeFiles.Clear;
    1273     ok := FindFirst(DataDir + 'Localization' + DirectorySeparator + 'Tribes' +
    1274       DirectorySeparator + '*.tribe.txt', faArchive + faReadOnly,
    1275       SearchRec) = 0;
     1273    ok := FindFirst(LocalizedFilePath('Tribes') + DirectorySeparator + '*.tribe.txt',
     1274      faArchive + faReadOnly, SearchRec) = 0;
    12761275    if not ok then
    12771276    begin
    12781277      FindClose(SearchRec);
    1279       ok := FindFirst(HomeDir + 'Tribes' + DirectorySeparator + '*.tribe.txt',
     1278      ok := FindFirst(LocalizedFilePath('Tribes' + DirectorySeparator + '*.tribe.txt'),
    12801279        faArchive + faReadOnly, SearchRec) = 0;
    12811280    end;
  • trunk/ScreenTools.pas

    r63 r64  
    88  Windows,
    99  {$ENDIF}
    10   StringTables,
    11   LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
     10  StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
    1211  Forms, Menus;
    1312
     
    116115procedure PaintLogo(ca: TCanvas; x, y, clLight, clShade: integer);
    117116function SetMainTextureByAge(Age: integer): boolean;
     117procedure LoadPhrases;
    118118
    119119const
     
    15221522end;
    15231523
    1524 procedure UnitInit;
    1525 begin
    1526   Reg := TRegistry.create;
    1527   try
    1528     Reg.OpenKey('SOFTWARE\cevo\RegVer9', true);
    1529     if Reg.ValueExists('Gamma') then
    1530       Gamma := Reg.ReadInteger('Gamma')
    1531       else begin
    1532         Gamma := 100;
    1533         Reg.WriteInteger('Gamma', Gamma);
    1534       end;
    1535   finally
    1536     Reg.Free;
    1537   end;
    1538 
    1539   if Gamma <> 100 then
    1540   begin
    1541     GammaLUT[0] := 0;
    1542     for i := 1 to 255 do
    1543     begin
    1544       p := round(255.0 * exp(ln(i / 255.0) * 100.0 / Gamma));
    1545       assert((p >= 0) and (p < 256));
    1546       GammaLUT[i] := p;
    1547     end;
    1548   end;
    1549 
    1550   {$IFDEF WINDOWS}
    1551   EnumDisplaySettings(nil, $FFFFFFFF, StartResolution);
    1552   {$ENDIF}
    1553   ResolutionChanged := false;
    1554 
    1555   Phrases := TStringTable.create;
    1556   Phrases2 := TStringTable.create;
     1524procedure LoadPhrases;
     1525begin
     1526  if Phrases = nil then Phrases := TStringTable.create;
     1527  if Phrases2 = nil then Phrases2 := TStringTable.create;
    15571528  Phrases2FallenBackToEnglish := false;
    1558   if FileExists(DataDir + 'Localization' + DirectorySeparator + 'Language.txt') then
    1559   begin
    1560     Phrases.loadfromfile(DataDir + 'Localization' + DirectorySeparator + 'Language.txt');
    1561     if FileExists(DataDir + 'Localization' + DirectorySeparator + 'Language2.txt') then
    1562       Phrases2.loadfromfile(DataDir + 'Localization' + DirectorySeparator + 'Language2.txt')
     1529  if FileExists(LocalizedFilePath('Language.txt')) then
     1530  begin
     1531    Phrases.loadfromfile(LocalizedFilePath('Language.txt'));
     1532    if FileExists(LocalizedFilePath('Language2.txt')) then
     1533      Phrases2.loadfromfile(LocalizedFilePath('Language2.txt'))
    15631534    else
    15641535    begin
     
    15731544  end;
    15741545
    1575   Sounds := TStringTable.create;
     1546  if Sounds = nil then Sounds := TStringTable.create;
    15761547  if not Sounds.loadfromfile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then
    15771548  begin
    1578     Sounds.Free;
    1579     Sounds := nil
    1580   end;
     1549    FreeAndNil(Sounds);
     1550  end;
     1551end;
     1552
     1553procedure UnitInit;
     1554begin
     1555  Reg := TRegistry.create;
     1556  with Reg do
     1557  try
     1558    OpenKey('SOFTWARE\cevo\RegVer9', true);
     1559    if ValueExists('Gamma') then
     1560      Gamma := ReadInteger('Gamma')
     1561      else begin
     1562        Gamma := 100;
     1563        WriteInteger('Gamma', Gamma);
     1564      end;
     1565    if ValueExists('Locale') then LocaleCode := ReadString('Locale')
     1566      else LocaleCode := '';
     1567  finally
     1568    Free;
     1569  end;
     1570
     1571  if Gamma <> 100 then
     1572  begin
     1573    GammaLUT[0] := 0;
     1574    for i := 1 to 255 do
     1575    begin
     1576      p := round(255.0 * exp(ln(i / 255.0) * 100.0 / Gamma));
     1577      assert((p >= 0) and (p < 256));
     1578      GammaLUT[i] := p;
     1579    end;
     1580  end;
     1581
     1582  {$IFDEF WINDOWS}
     1583  EnumDisplaySettings(nil, $FFFFFFFF, StartResolution);
     1584  {$ENDIF}
     1585  ResolutionChanged := false;
     1586
     1587  LoadPhrases;
    15811588
    15821589  for section := Low(TFontType) to High(TFontType) do
     
    16551662
    16561663procedure UnitDone;
    1657 begin
     1664var
     1665  Reg: TRegistry;
     1666begin
     1667  Reg := TRegistry.create;
     1668  with Reg do
     1669  try
     1670    OpenKey('SOFTWARE\cevo\RegVer9', true);
     1671    WriteString('Locale', LocaleCode);
     1672  finally
     1673    Free;
     1674  end;
     1675
    16581676  RestoreResolution;
    16591677  for i := 0 to nGrExt - 1 do
  • trunk/Start.pas

    r53 r64  
    107107
    108108uses
    109   Directories, Protocol, Direct, ScreenTools, Inp, Back;
     109  Directories, Protocol, Direct, ScreenTools, Inp, Back, Locale;
    110110
    111111{$R *.lfm}
     
    249249
    250250  ActionsOffered := [maManual, maCredits, maWeb];
    251   if FileExists(HomeDir + 'Configurator.exe') then
    252     Include(ActionsOffered, maConfig);
     251  Include(ActionsOffered, maConfig);
    253252  if FileExists(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html') then
    254253    Include(ActionsOffered, maAIDev);
     
    404403  i: integer;
    405404begin
    406   FormerGames.Free;
    407   Maps.Free;
    408   Mini.Free;
    409   EmptyPicture.Free;
    410   LogoBuffer.Free;
     405  FreeAndNil(FormerGames);
     406  FreeAndNil(Maps);
     407  FreeAndNil(Mini);
     408  FreeAndNil(EmptyPicture);
     409  FreeAndNil(LogoBuffer);
    411410  for i := 0 to nBrain - 1 do
    412     BrainPicture[i].Free;
     411    FreeAndNil(BrainPicture[i]);
    413412end;
    414413
     
    15651564      maConfig:
    15661565        begin
    1567            OpenDocument(pchar(HomeDir + 'Configurator.exe'));
    1568           Close
     1566          LocaleDlg := TLocaleDlg.Create(nil);
     1567          if LocaleDlg.ShowModal = mrOk then begin
     1568            LoadPhrases;
     1569            Invalidate;
     1570          end;
     1571          FreeAndNil(LocaleDlg);
    15691572        end;
    15701573      maManual:
     
    15731576        DirectHelp(cStartCredits);
    15741577      maAIDev:
    1575          OpenDocument(pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));
     1578        OpenDocument(pchar(HomeDir + 'AI Template' + DirectorySeparator + 'AI development manual.html'));
    15761579      maWeb:
    15771580        OpenURL('http://c-evo.org')
Note: See TracChangeset for help on using the changeset viewer.