Changeset 417 for trunk/UBrain.pas


Ignore:
Timestamp:
Nov 17, 2021, 11:11:01 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Merged LoadGraphicSet and LoadGraphicSet2 into single method.
  • Modified: Moved brain load picture code into TBrain.LoadPicture method.
  • Added: Brain pictures loaded as TGraphicSetItem.
  • Modified: Code cleanup.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UBrain.pas

    r375 r417  
    66
    77uses
    8   Classes, SysUtils, fgl, Graphics, Protocol, LazFileUtils, dynlibs;
     8  Classes, SysUtils, fgl, Graphics, Protocol, LazFileUtils, dynlibs, Types;
    99
    1010const
     
    3535    Picture: TBitmap;
    3636    Beginner: Boolean;
     37    procedure LoadPicture;
    3738    procedure LoadFromFile(AIFileName: string);
    3839    constructor Create;
     
    4748    procedure GetByKind(Kind: TBrainType; Brains: TBrains);
    4849    function GetBeginner: TBrain;
     50    procedure LoadPictures;
    4951  end;
    5052
     
    5355
    5456uses
    55   ScreenTools;
     57  ScreenTools, Directories;
    5658
    5759{ TBrain }
     60
     61procedure TBrain.LoadPicture;
     62var
     63  TextSize: TSize;
     64begin
     65  if not LoadGraphicFile(Picture, GetAiDir + DirectorySeparator +
     66    FileName + DirectorySeparator + FileName + '.png', [gfNoError]) then begin
     67    with Picture.Canvas do begin
     68      Brush.Color := $904830;
     69      FillRect(Rect(0, 0, 64, 64));
     70      Font.Assign(UniFont[ftTiny]);
     71      Font.Style := [];
     72      Font.Color := $5FDBFF;
     73      TextSize := TextExtent(FileName);
     74      TextOut(32 - TextSize.Width div 2, 32 - TextSize.Height div 2, FileName);
     75    end;
     76  end;
     77end;
    5878
    5979procedure TBrain.LoadFromFile(AIFileName: string);
     
    177197end;
    178198
     199procedure TBrains.LoadPictures;
     200var
     201  I: Integer;
     202begin
     203  for I := 0 to Count - 1 do
     204    with Items[I] do LoadPicture;
     205end;
     206
     207
    179208end.
    180209
Note: See TracChangeset for help on using the changeset viewer.