Changeset 64 for trunk/ScreenTools.pas


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

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.