Ignore:
Timestamp:
May 7, 2020, 12:46:55 AM (4 years ago)
Author:
chronos
Message:
  • Added: New Global unit with global constants.
  • Modified: Multiple occurence of string constants used for subdirectories replaced by functions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r188 r189  
    188188
    189189  UniFont: array [TFontType] of TFont;
    190   AppRegistryKey: string = '\SOFTWARE\C-evo';
     190  Gamma: Integer; // global gamma correction (cent)
    191191
    192192procedure UnitInit;
    193193procedure UnitDone;
     194procedure InitGammaLookupTable;
     195
    194196
    195197implementation
     
    204206  {$ENDIF}
    205207
    206   Gamma: Integer; // global gamma correction (cent)
    207   GammaLookupTable: array [0 .. 255] of Byte;
     208  GammaLookupTable: array [0..255] of Byte;
    208209
    209210{$IFDEF WINDOWS}
     
    468469    Source := TBitmap.Create;
    469470    Source.PixelFormat := pf24bit;
    470     FileName := HomeDir + 'Graphics' + DirectorySeparator + Name;
     471    FileName := GetGraphicsDir + DirectorySeparator + Name;
    471472    if not LoadGraphicFile(Source, FileName) then begin
    472473      Result := -1;
     
    13521353    with MainTexture do begin
    13531354      MainTextureAge := Age;
    1354       LoadGraphicFile(Image, HomeDir + 'Graphics' + DirectorySeparator +
     1355      LoadGraphicFile(Image, GetGraphicsDir + DirectorySeparator +
    13551356        'Texture' + IntToStr(Age + 1) + '.jpg');
    13561357      clBevelLight := Colors.Canvas.Pixels[clkAge0 + Age, cliBevelLight];
     
    13911392
    13921393  if Sounds = nil then Sounds := TStringTable.Create;
    1393   if not Sounds.LoadFromFile(HomeDir + 'Sounds' + DirectorySeparator + 'sound.txt') then
     1394  if not Sounds.LoadFromFile(GetSoundsDir + DirectorySeparator + 'sound.txt') then
    13941395  begin
    13951396    FreeAndNil(Sounds);
     
    14701471
    14711472procedure UnitInit;
    1472 var
    1473   Reg: TRegistry;
    1474 begin
    1475   Reg := TRegistry.Create;
    1476   with Reg do
    1477     try
    1478       OpenKey(AppRegistryKey, True);
    1479       if ValueExists('Gamma') then
    1480         Gamma := ReadInteger('Gamma')
    1481       else
    1482       begin
    1483         Gamma := 100;
    1484         WriteInteger('Gamma', Gamma);
    1485       end;
    1486       if ValueExists('Locale') then
    1487         LocaleCode := ReadString('Locale')
    1488       else
    1489         LocaleCode := '';
    1490     finally
    1491       Free;
    1492     end;
    1493 
    1494   if Gamma <> 100 then InitGammaLookupTable;
     1473begin
     1474  Gamma := 100;
     1475  InitGammaLookupTable;
    14951476
    14961477  {$IFDEF WINDOWS}
     
    15121493  Templates := TBitmap.Create;
    15131494  Templates.PixelFormat := pf24bit;
    1514   LoadGraphicFile(Templates, HomeDir + 'Graphics' + DirectorySeparator +
     1495  LoadGraphicFile(Templates, GetGraphicsDir + DirectorySeparator +
    15151496    'Templates.png', gfNoGamma);
    15161497  Colors := TBitmap.Create;
    15171498  Colors.PixelFormat := pf24bit;
    1518   LoadGraphicFile(Colors, HomeDir + 'Graphics' + DirectorySeparator + 'Colors.png');
     1499  LoadGraphicFile(Colors, GetGraphicsDir + DirectorySeparator + 'Colors.png');
    15191500  Paper := TBitmap.Create;
    15201501  Paper.PixelFormat := pf24bit;
    1521   LoadGraphicFile(Paper, HomeDir + 'Graphics' + DirectorySeparator + 'Paper.jpg');
     1502  LoadGraphicFile(Paper, GetGraphicsDir + DirectorySeparator + 'Paper.jpg');
    15221503  BigImp := TBitmap.Create;
    15231504  BigImp.PixelFormat := pf24bit;
    1524   LoadGraphicFile(BigImp, HomeDir + 'Graphics' + DirectorySeparator + 'Icons.png');
     1505  LoadGraphicFile(BigImp, GetGraphicsDir + DirectorySeparator + 'Icons.png');
    15251506  MainTexture.Image := TBitmap.Create;
    15261507  MainTextureAge := -2;
     
    15321513procedure UnitDone;
    15331514var
    1534   Reg: TRegistry;
    15351515  I: integer;
    15361516begin
    1537   Reg := TRegistry.Create;
    1538   with Reg do
    1539     try
    1540       OpenKey(AppRegistryKey, True);
    1541       WriteString('Locale', LocaleCode);
    1542       WriteInteger('Gamma', Gamma);
    1543       if FullScreen then WriteInteger('ScreenMode', 1)
    1544         else WriteInteger('ScreenMode', 0);
    1545     finally
    1546       Free;
    1547     end;
    1548 
    15491517  RestoreResolution;
    15501518  for I := 0 to nGrExt - 1 do begin
Note: See TracChangeset for help on using the changeset viewer.