Changeset 417 for trunk


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.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Global.pas

    r411 r417  
    2424    ((CevoVersionBugFix and $ff) shl 0);
    2525
    26 
    2726implementation
    2827
  • trunk/Graphics/System2.grs

    r314 r417  
    99      <Height>26</Height>
    1010    </Item>
     11    <Item>
     12      <Name>BrainNoTerm</Name>
     13      <Left>1</Left>
     14      <Top>111</Top>
     15      <Width>64</Width>
     16      <Height>64</Height>
     17    </Item>
     18    <Item>
     19      <Name>BrainSuperVirtual</Name>
     20      <Left>66</Left>
     21      <Top>111</Top>
     22      <Width>64</Width>
     23      <Height>64</Height>
     24    </Item>
     25    <Item>
     26      <Name>BrainTerm</Name>
     27      <Left>131</Left>
     28      <Top>111</Top>
     29      <Width>64</Width>
     30      <Height>64</Height>
     31    </Item>
     32    <Item>
     33      <Name>BrainRandom</Name>
     34      <Left>131</Left>
     35      <Top>46</Top>
     36      <Width>64</Width>
     37      <Height>64</Height>
     38    </Item>
    1139  </Items>
    1240</GraphicSet>
  • trunk/LocalPlayer/CityScreen.pas

    r380 r417  
    9393    procedure OnPlaySound(var Msg: TMessage); message WM_PLAYSOUND;
    9494  public
    95     RestoreUnFocus: integer;
     95    RestoreUnFocus: Integer;
    9696    CloseAction: TCityCloseAction;
    9797    procedure OffscreenPaint; override;
     
    148148  wZoomEnvironment = 68;
    149149
    150   ImpPosition: array [28 .. nImp - 1] of integer = (-1, // imTrGoods
     150  ImpPosition: array [28 .. nImp - 1] of Integer = (
     151    -1, // imTrGoods
    151152    21, // imBarracks
    152153    6, // imGranary
     
    192193
    193194var
    194   ImpSorted: array [0 .. nImp - 1] of integer;
     195  ImpSorted: array [0 .. nImp - 1] of Integer;
    195196
    196197procedure TCityDlg.FormCreate(Sender: TObject);
     
    206207  SmallMapMode := smImprovements;
    207208  ZoomArea := 1;
    208   ProdHint := false;
     209  ProdHint := False;
    209210  RestoreUnFocus := -1;
    210211  OpenSoundEvent := -1;
     
    489490var
    490491  x, y, xGr, i, j, iix, d, dx, dy, PrCost, Cnt, Loc1, FreeSupp, Paintiix,
    491     HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: integer;
    492   av: integer;
     492    HappyGain, OptiType, rx, ry, TrueFood, TrueProd, TruePoll: Integer;
     493  av: Integer;
    493494  PrName, s: string;
    494495  UnitInfo: TUnitInfo;
    495496  UnitReport: TUnitReport;
    496   IsCityAlive, CanGrow: boolean;
     497  IsCityAlive, CanGrow: Boolean;
    497498begin
    498499  inherited;
     
    509510  TrueProd := c.Prod;
    510511  TruePoll := c.Pollution;
    511   if supervising or (cix < 0) then
     512  if Supervising or (cix < 0) then
    512513  begin // normalize city from after-turn state
    513     dec(TrueFood, Report.FoodSurplus);
     514    Dec(TrueFood, Report.FoodSurplus);
    514515    if TrueFood < 0 then
    515516      TrueFood := 0; // shouldn't happen
    516     dec(TrueProd, Report.Production);
     517    Dec(TrueProd, Report.Production);
    517518    if TrueProd < 0 then
    518519      TrueProd := 0; // shouldn't happen
    519     dec(TruePoll, Report.AddPollution);
     520    Dec(TruePoll, Report.AddPollution);
    520521    if TruePoll < 0 then
    521522      TruePoll := 0; // shouldn't happen
     
    534535
    535536  Offscreen.Canvas.Font.Assign(UniFont[ftCaption]);
    536   RisedTextOut(offscreen.Canvas, 42, 7, Caption);
    537   with offscreen.Canvas do
     537  RisedTextOut(Offscreen.Canvas, 42, 7, Caption);
     538  with Offscreen.Canvas do
    538539  begin // city size
    539     brush.Color := $000000;
     540    Brush.Color := $000000;
    540541    FillRect(Rect(8 + 1, 7 + 1, 36 + 1, 32 + 1));
    541     brush.Color := $FFFFFF;
     542    Brush.Color := $FFFFFF;
    542543    FillRect(Rect(8, 7, 36, 32));
    543     brush.style := bsClear;
     544    Brush.style := bsClear;
    544545    Font.Color := $000000;
    545     s := inttostr(c.Size);
    546     TextOut(8 + 14 - textwidth(s) div 2, 7, s);
     546    s := IntToStr(c.Size);
     547    TextOut(8 + 14 - TextWidth(s) div 2, 7, s);
    547548  end;
    548549  Offscreen.Canvas.Font.Assign(UniFont[ftSmall]);
     
    959960          end // unit visible in display
    960961          else
    961             dec(FreeSupp, UnitReport.ProdSupport);
    962           inc(Cnt);
     962            Dec(FreeSupp, UnitReport.ProdSupport);
     963          Inc(Cnt);
    963964        end;
    964965    PageCount := (Cnt + 5) div 6;
     
    973974  PageDownBtn.Visible := PageCount > 1;
    974975
    975   with offscreen.Canvas do
     976  with Offscreen.Canvas do
    976977  begin
    977978    { display project now }
     
    10671068    end;
    10681069
    1069     NextCityBtn.Visible := false;
    1070     PrevCityBtn.Visible := false;
     1070    NextCityBtn.Visible := False;
     1071    PrevCityBtn.Visible := False;
    10711072  end;
    10721073  Page := 0;
     
    10821083
    10831084  // check if port
    1084   IsPort := false;
     1085  IsPort := False;
    10851086  for dx := -2 to 2 do
    10861087    for dy := -2 to 2 do
    1087       if abs(dx) + abs(dy) = 2 then
     1088      if Abs(dx) + Abs(dy) = 2 then
    10881089      begin
    10891090        Loc1 := dLoc(cLoc, dx, dy);
    10901091        if (Loc1 >= 0) and (Loc1 < G.lx * G.ly) and
    10911092          (MyMap[Loc1] and fTerrain < fGrass) then
    1092           IsPort := true;
     1093          IsPort := True;
    10931094      end;
    10941095
     
    11051106  OpenSoundEvent := -1;
    11061107  OffscreenPaint;
    1107   Timer1.Enabled := true;
     1108  Timer1.Enabled := True;
    11081109end;
    11091110
     
    11521153    InitZoomCityMap;
    11531154    SmartUpdateContent;
    1154     exit;
     1155    Exit;
    11551156  end;
    11561157  if (ssLeft in Shift) and (x >= xSupport) and (x < xSupport + wSupport) and
     
    11611162    InitZoomCityMap;
    11621163    SmartUpdateContent;
    1163     exit;
     1164    Exit;
    11641165  end;
    11651166  if not AllowChange then
    1166     exit; // not an own city
     1167    Exit; // Not an own city
    11671168
    11681169  if (ssLeft in Shift) then
     
    15851586procedure TCityDlg.FormClose(Sender: TObject; var Action: TCloseAction);
    15861587begin
    1587   Timer1.Enabled := false;
    1588   ProdHint := false;
     1588  Timer1.Enabled := False;
     1589  ProdHint := False;
    15891590  MarkCityLoc := -1;
    15901591  if Optimize_cixTileChange >= 0 then
     
    17511752  if Page > 0 then
    17521753  begin
    1753     dec(Page);
     1754    Dec(Page);
    17541755    SmartUpdateContent;
    17551756  end;
     
    17601761  if Page < PageCount - 1 then
    17611762  begin
    1762     inc(Page);
     1763    Inc(Page);
    17631764    SmartUpdateContent;
    17641765  end;
  • trunk/LocalPlayer/Nego.pas

    r352 r417  
    136136    'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII', 'XIV', 'XV', 'XVI');
    137137
    138   ButtonPrice: array [0 .. 11] of cardinal = (opChoose, opCivilReport,
     138  ButtonPrice: array [0 .. 11] of Cardinal = (opChoose, opCivilReport,
    139139    opMilReport, opMap, opAllTech, opAllTech, opAllModel, opMoney, opTreaty,
    140140    opLowTreaty, opShipParts, opShipParts);
     
    142142procedure TNegoDlg.FormCreate(Sender: TObject);
    143143var
    144   cix: integer;
     144  cix: Integer;
    145145begin
    146146  InitButtons;
     
    153153        BackGraphic := HGrSystem2.Data;
    154154        case Tag shr 8 of
    155           1:
    156             SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6);
    157           2:
    158             SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6);
     155          1: SmartHint := Phrases.Lookup('WANT', ButtonIndex - 6);
     156          2: SmartHint := Phrases.Lookup('OFFER', ButtonIndex - 6);
    159157        end;
    160158      end;
    161159
    162   fillchar(History, sizeof(History), 0);
     160  FillChar(History, SizeOf(History), 0);
    163161  RomanFont := TFont.Create;
    164162  RomanFont.Name := 'Times New Roman';
  • trunk/LocalPlayer/Term.pas

    r414 r417  
    43354335    if ClientMode <> cEditMap then
    43364336    begin
    4337       if supervising then
     4337      if Supervising then
    43384338      begin
    43394339        ScreenTools.Frame(Panel.Canvas, ClientWidth - xPalace - 1, yPalace - 1,
  • trunk/LocalPlayer/Tribes.pas

    r315 r417  
    430430        if CompareText(Item, 'stdcities') = 0 then
    431431          case cpix of
    432             3:
    433               cpix := 0;
    434             6:
    435             begin
     432            3: cpix := 0;
     433            6: begin
    436434              cpix := 0;
    437435              Item := 'Nation2';
    438             end
     436            end;
    439437          end;
    440438        cHGr := LoadGraphicSet(Item + '.png');
    441439        for x := 0 to 3 do
    442           with CityPicture[x] do
    443           begin
     440          with CityPicture[x] do begin
    444441            FindPosition(cHGr, x * 65, cpix * 49, 63, 47, $00FFFF,
    445442              xShield, yShield);
  • trunk/NoTerm.pas

    r364 r417  
    123123  else
    124124    EndCommand := sResign;
    125   Server(EndCommand, me, 0, nil^)
     125  Server(EndCommand, Me, 0, nil^);
    126126end;
    127127
     
    370370end;
    371371
    372 procedure Client(Command, Player: integer; var Data);
     372procedure Client(Command, Player: Integer; var Data);
    373373begin
    374374  if not FormsCreated then
    375375  begin
    376     FormsCreated := true;
     376    FormsCreated := True;
    377377    Application.CreateForm(TNoTermDlg, NoTermDlg);
    378378  end;
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r380 r417  
    2929function ExtractFileNameWithoutExt(const Filename: string): string;
    3030function LoadGraphicFile(Bmp: TBitmap; FileName: string; Options: TLoadGraphicFileOptions = []): boolean;
    31 function LoadGraphicSet(const Name: string): TGraphicSet;
    32 function LoadGraphicSet2(const Name: string): TGraphicSet;
     31function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
    3332procedure Dump(dst: TBitmap; HGr: TGraphicSet; xDst, yDst, Width, Height, xGr, yGr: integer);
    3433procedure BitmapReplaceColor(Dst: TBitmap; X, Y, Width, Height: Integer; OldColor, NewColor: TColor);
     
    151150  Phrases2: TStringTable;
    152151  GrExt: TGraphicSets;
     152
    153153  HGrSystem: TGraphicSet;
    154   HGrSystem2: TGraphicSet;
    155   ClickFrameColor: Integer;
    156   MainTexture: TTexture;
    157   Templates: TGraphicSet;
    158   Colors: TBitmap;
    159   Paper: TBitmap;
    160   BigImp: TBitmap;
    161   LogoBuffer: TBitmap;
    162   FullScreen: Boolean;
    163   GenerateNames: Boolean;
    164   InitOrnamentDone: Boolean;
    165   Phrases2FallenBackToEnglish: Boolean;
    166 
    167   // Graphic set items
    168154  CityMark1: TGraphicSetItem;
    169155  CityMark2: TGraphicSetItem;
     156
     157  HGrSystem2: TGraphicSet;
    170158  Ornament: TGraphicSetItem;
     159  GBrainNoTerm: TGraphicSetItem;
     160  GBrainSuperVirtual: TGraphicSetItem;
     161  GBrainTerm: TGraphicSetItem;
     162  GBrainRandom: TGraphicSetItem;
     163
     164  Templates: TGraphicSet;
    171165  Logo: TGraphicSetItem;
    172166  BigBook: TGraphicSetItem;
     
    181175  WeightOn: TGraphicSetItem;
    182176  WeightOff: TGraphicSetItem;
     177
     178  ClickFrameColor: Integer;
     179  MainTexture: TTexture;
     180  Colors: TBitmap;
     181  Paper: TBitmap;
     182  BigImp: TBitmap;
     183  LogoBuffer: TBitmap;
     184  FullScreen: Boolean;
     185  GenerateNames: Boolean;
     186  InitOrnamentDone: Boolean;
     187  Phrases2FallenBackToEnglish: Boolean;
    183188
    184189  UniFont: array [TFontType] of TFont;
     
    485490end;
    486491
    487 function LoadGraphicSet(const Name: string): TGraphicSet;
     492function LoadGraphicSet(const Name: string; Transparency: Boolean = True): TGraphicSet;
    488493var
    489494  x: Integer;
     
    510515    Result.ResetPixUsed;
    511516
    512     Result.Mask.SetSize(Result.Data.Width, Result.Data.Height);
    513 
    514     Result.Data.BeginUpdate;
    515     Result.Mask.BeginUpdate;
    516     DataPixel := PixelPointer(Result.Data);
    517     MaskPixel := PixelPointer(Result.Mask);
    518     for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin
    519       for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin
    520         OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF;
    521         if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin
    522           MaskPixel.Pixel^.R := $FF;
    523           MaskPixel.Pixel^.G := $FF;
    524           MaskPixel.Pixel^.B := $FF;
    525           DataPixel.Pixel^.R := 0;
    526           DataPixel.Pixel^.G := 0;
    527           DataPixel.Pixel^.B := 0;
    528         end else begin
    529           MaskPixel.Pixel^.R := $00;
    530           MaskPixel.Pixel^.G := $00;
    531           MaskPixel.Pixel^.B := $00;
     517    if Transparency then begin
     518      Result.Mask.SetSize(Result.Data.Width, Result.Data.Height);
     519
     520      Result.Data.BeginUpdate;
     521      Result.Mask.BeginUpdate;
     522      DataPixel := PixelPointer(Result.Data);
     523      MaskPixel := PixelPointer(Result.Mask);
     524      for y := 0 to ScaleToNative(Result.Data.Height) - 1 do begin
     525        for x := 0 to ScaleToNative(Result.Data.Width) - 1 do begin
     526          OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF;
     527          if (OriginalColor = TransparentColor1) or (OriginalColor = TransparentColor2) then begin
     528            MaskPixel.Pixel^.R := $FF;
     529            MaskPixel.Pixel^.G := $FF;
     530            MaskPixel.Pixel^.B := $FF;
     531            DataPixel.Pixel^.R := 0;
     532            DataPixel.Pixel^.G := 0;
     533            DataPixel.Pixel^.B := 0;
     534          end else begin
     535            MaskPixel.Pixel^.R := $00;
     536            MaskPixel.Pixel^.G := $00;
     537            MaskPixel.Pixel^.B := $00;
     538          end;
     539          DataPixel.NextPixel;
     540          MaskPixel.NextPixel;
    532541        end;
    533         DataPixel.NextPixel;
    534         MaskPixel.NextPixel;
     542        DataPixel.NextLine;
     543        MaskPixel.NextLine;
    535544      end;
    536       DataPixel.NextLine;
    537       MaskPixel.NextLine;
    538     end;
    539     Result.Data.EndUpdate;
    540     Result.Mask.EndUpdate;
    541 
    542     if Gamma <> 100 then
    543       ApplyGammaToBitmap(Result.Data);
    544   end;
    545 end;
    546 
    547 function LoadGraphicSet2(const Name: string): TGraphicSet;
    548 var
    549   FileName: string;
    550 begin
    551   Result := GrExt.SearchByName(Name);
    552   if not Assigned(Result) then begin
    553     Result := GrExt.AddNew(Name);
    554     FileName := GetGraphicsDir + DirectorySeparator + Name;
    555     if not LoadGraphicFile(Result.Data, FileName, [gfNoGamma]) then begin
    556       Result := nil;
    557       Exit;
    558     end;
    559 
    560     FileName := ExtractFileNameWithoutExt(FileName) + GraphicSetFileExt;
    561     if FileExists(FileName) then
    562       Result.LoadFromFile(FileName);
    563 
    564     Result.ResetPixUsed;
     545      Result.Data.EndUpdate;
     546      Result.Mask.EndUpdate;
     547
     548      if Gamma <> 100 then
     549        ApplyGammaToBitmap(Result.Data);
     550    end;
    565551  end;
    566552end;
     
    10501036    MainTexture.ColorBevelLight and $FCFCFC shr 2);
    10511037  HGrSystem2.Data.BeginUpdate;
    1052   PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left), ScaleToNative(Ornament.Top));
     1038  PixelPtr := PixelPointer(HGrSystem2.Data, ScaleToNative(Ornament.Left),
     1039    ScaleToNative(Ornament.Top));
    10531040  if PixelPtr.BytesPerPixel = 3 then begin
    10541041    for Y := 0 to ScaleToNative(Ornament.Height) - 1 do begin
     
    17401727  LoadPhrases;
    17411728  LoadFonts;
    1742   Templates := LoadGraphicSet2('Templates.png');
     1729  Templates := LoadGraphicSet('Templates.png', False);
    17431730  with Templates do begin
    17441731    Logo := GetItem('Logo');
     
    17791766
    17801767  HGrSystem := LoadGraphicSet('System.png');
    1781   CityMark1 := HGrSystem.GetItem('CityMark1');
    1782   CityMark2 := HGrSystem.GetItem('CityMark2');
     1768  with HGrSystem do begin
     1769    CityMark1 := GetItem('CityMark1');
     1770    CityMark2 := GetItem('CityMark2');
     1771  end;
    17831772
    17841773  HGrSystem2 := LoadGraphicSet('System2.png');
    1785   Ornament := HGrSystem2.GetItem('Ornament');
     1774  with HGrSystem2 do begin
     1775    Ornament := GetItem('Ornament');
     1776    GBrainNoTerm := GetItem('BrainNoTerm');
     1777    GBrainSuperVirtual := GetItem('BrainSuperVirtual');
     1778    GBrainTerm := GetItem('BrainTerm');
     1779    GBrainRandom := GetItem('BrainRandom');
     1780  end;
    17861781
    17871782  Colors := TBitmap.Create;
  • trunk/Packages/CevoComponents/UGraphicSet.pas

    r315 r417  
    5555  end;
    5656
     57  TGraphicSetClass = class of TGraphicSet;
     58
    5759  { TGraphicSets }
    5860
  • trunk/Start.pas

    r416 r417  
    1010
    1111type
    12 
    1312  { TPlayerSlot }
    1413
     
    295294    CustomizeBtn.ButtonIndex := 2;
    296295
    297   BitBltBitmap(BrainNoTerm.Picture, 0, 0, 64, 64, HGrSystem2.Data, 1, 111);
    298   BitBltBitmap(BrainSuperVirtual.Picture, 0, 0, 64, 64, HGrSystem2.Data, 66, 111);
    299   BitBltBitmap(BrainTerm.Picture, 0, 0, 64, 64, HGrSystem2.Data, 131, 111);
    300   BitBltBitmap(BrainRandom.Picture, 0, 0, 64, 64, HGrSystem2.Data, 131, 46);
     296  BitBltBitmap(BrainNoTerm.Picture, 0, 0, 64, 64, HGrSystem2.Data, GBrainNoTerm.Left, GBrainNoTerm.Top);
     297  BitBltBitmap(BrainSuperVirtual.Picture, 0, 0, 64, 64, HGrSystem2.Data, GBrainSuperVirtual.Left, GBrainSuperVirtual.Top);
     298  BitBltBitmap(BrainTerm.Picture, 0, 0, 64, 64, HGrSystem2.Data, GBrainTerm.Left, GBrainTerm.Top);
     299  BitBltBitmap(BrainRandom.Picture, 0, 0, 64, 64, HGrSystem2.Data, GBrainRandom.Left, GBrainRandom.Top);
     300
    301301  LoadAiBrainsPictures;
    302302
     
    480480procedure TStartDlg.LoadAiBrainsPictures;
    481481var
    482   AIBrains: TBrains;
    483   I: Integer;
    484   TextSize: TSize;
    485 begin
    486   AIBrains := TBrains.Create(False);
    487   Brains.GetByKind(btAI, AIBrains);
    488   for i := 0 to AIBrains.Count - 1 do
    489   with AIBrains[I] do begin
    490     if not LoadGraphicFile(AIBrains[i].Picture, GetAiDir + DirectorySeparator +
    491       FileName + DirectorySeparator + FileName + '.png', [gfNoError]) then begin
    492       with AIBrains[i].Picture.Canvas do begin
    493         Brush.Color := $904830;
    494         FillRect(Rect(0, 0, 64, 64));
    495         Font.Assign(UniFont[ftTiny]);
    496         Font.Style := [];
    497         Font.Color := $5FDBFF;
    498         TextSize := TextExtent(FileName);
    499         Textout(32 - TextSize.Width div 2,
    500           32 - TextSize.Height div 2, FileName);
    501       end;
    502     end;
    503   end;
    504   FreeAndNil(AIBrains);
     482  AiBrains: TBrains;
     483begin
     484  AiBrains := TBrains.Create(False);
     485  try
     486    Brains.GetByKind(btAI, AiBrains);
     487    AiBrains.LoadPictures;
     488  finally
     489    FreeAndNil(AiBrains);
     490  end;
    505491end;
    506492
     
    727713    begin
    728714      for i := 12 to 19 do
    729         if (i < 13) or (i > 17) then
    730         begin
     715        if (i < 13) or (i > 17) then begin
    731716          BitBltCanvas(Canvas, 9 + i * 27, yLogo - 2, Ornament.Width, Ornament.Height,
    732717            HGrSystem2.Mask.Canvas, Ornament.Left, Ornament.Top, SRCAND);
     
    813798
    814799      for i := 0 to 19 do
    815         if (i < 2) or (i > 6) then
    816         begin
     800        if (i < 2) or (i > 6) then begin
    817801          BitBltCanvas(Canvas, 9 + i * 27, yLogo - 2, Ornament.Width, Ornament.Height,
    818802            HGrSystem2.Mask.Canvas, Ornament.Left, Ornament.Top, SRCAND);
  • 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.