Ignore:
Timestamp:
Nov 30, 2023, 10:16:14 PM (6 months ago)
Author:
chronos
Message:
  • Modified: Updated high dpi branch from trunk.
  • Modified: Use generics.collections instead of fgl.
  • Modified: Compile with Delphi syntax.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Brain.pas

    r464 r465  
    1 unit UBrain;
    2 
    3 {$mode delphi}
     1unit Brain;
    42
    53interface
    64
    75uses
    8   UDpiControls, Classes, SysUtils, fgl, Graphics, Protocol, LazFileUtils, dynlibs;
     6  UDpiControls, Classes, SysUtils, Generics.Collections, Graphics, Protocol, LazFileUtils,
     7  dynlibs, Types;
    98
    109const
     
    3534    Picture: TDpiBitmap;
    3635    Beginner: Boolean;
     36    procedure LoadPicture;
    3737    procedure LoadFromFile(AIFileName: string);
    3838    constructor Create;
     
    4242  { TBrains }
    4343
    44   TBrains = class(TFPGObjectList<TBrain>)
     44  TBrains = class(TObjectList<TBrain>)
    4545    function AddNew: TBrain;
    4646    function GetKindCount(Kind: TBrainType): Integer;
    4747    procedure GetByKind(Kind: TBrainType; Brains: TBrains);
    4848    function GetBeginner: TBrain;
     49    procedure LoadPictures;
    4950  end;
    5051
     
    5354
    5455uses
    55   ScreenTools;
     56  ScreenTools, Directories;
    5657
    5758{ TBrain }
     59
     60procedure TBrain.LoadPicture;
     61var
     62  TextSize: TSize;
     63begin
     64  if not LoadGraphicFile(Picture, GetAiDir + DirectorySeparator +
     65    FileName + DirectorySeparator + FileName + '.png', [gfNoError]) then begin
     66    with Picture.Canvas do begin
     67      Brush.Color := $904830;
     68      FillRect(Rect(0, 0, 64, 64));
     69      Font.Assign(UniFont[ftTiny]);
     70      Font.Style := [];
     71      Font.Color := $5FDBFF;
     72      TextSize := TextExtent(FileName);
     73      TextOut(32 - TextSize.Width div 2, 32 - TextSize.Height div 2, FileName);
     74    end;
     75  end;
     76end;
    5877
    5978procedure TBrain.LoadFromFile(AIFileName: string);
     
    106125      DLLName := BasePath + DirectorySeparator + Value
    107126    {$ENDIF}{$ENDIF}
    108     {$IFDEF LINUX}{$IFDEF CPU32}
    109     else if Key = '#PATH_LINUX32' then
    110       DLLName := BasePath + DirectorySeparator + Value
    111     {$ENDIF}{$ENDIF}
    112     {$IFDEF LINUX}{$IFDEF CPU64}
    113     else if Key = '#PATH_LINUX64' then
     127    {$IFDEF UNIX}{$IFDEF CPUI386}
     128    else if Key = '#PATH_LINUX_I386' then
     129      DLLName := BasePath + DirectorySeparator + Value
     130    {$ENDIF}{$ENDIF}
     131    {$IFDEF UNIX}{$IFDEF CPUAMD64}
     132    else if Key = '#PATH_LINUX_AMD64' then
     133      DLLName := BasePath + DirectorySeparator + Value
     134    {$ENDIF}{$ENDIF}
     135    {$IFDEF UNIX}{$IFDEF CPUARM}
     136    else if Key = '#PATH_LINUX_ARM32' then
     137      DLLName := BasePath + DirectorySeparator + Value
     138    {$ENDIF}{$ENDIF}
     139    {$IFDEF UNIX}{$IFDEF CPUAARCH64}
     140    else if Key = '#PATH_LINUX_ARM64' then
    114141      DLLName := BasePath + DirectorySeparator + Value
    115142    {$ENDIF}{$ENDIF}
     
    177204end;
    178205
     206procedure TBrains.LoadPictures;
     207var
     208  I: Integer;
     209begin
     210  for I := 0 to Count - 1 do
     211    with Items[I] do LoadPicture;
     212end;
     213
    179214end.
    180215
     216
     217
Note: See TracChangeset for help on using the changeset viewer.