Ignore:
Timestamp:
May 7, 2020, 12:30:04 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Code cleanup.
  • Modified: Simplified initialization of brain pictures.
  • Modified: Use GetAiDir function for AI subdirectory.
Location:
trunk/Packages/CevoComponents
Files:
2 edited

Legend:

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

    r190 r192  
    1515function GetGraphicsDir: string;
    1616function GetSoundsDir: string;
     17function GetAiDir: string;
    1718
    1819
     
    126127end;
    127128
     129function GetAiDir: string;
     130begin
     131  Result := HomeDir + 'AI';
     132end;
     133
    128134end.
  • trunk/Packages/CevoComponents/ScreenTools.pas

    r190 r192  
    77  Windows,
    88  {$ENDIF}
    9   StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls,
     9  StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Math,
    1010  Forms, Menus, GraphType;
    1111
     
    3535procedure Sprite(dst: TBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer);
    3636  overload;
    37 procedure MakeBlue(dst: TBitmap; x, y, w, h: integer);
     37procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer);
    3838procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: integer);
    3939procedure ImageOp_BCC(dst, Src: TBitmap;
     
    4141procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: integer);
    4242function BitBltCanvas(DestCanvas: TCanvas; X, Y, Width, Height: Integer;
    43   SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean;
     43  SrcCanvas: TCanvas; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload;
     44function BitBltCanvas(Dest: TCanvas; DestRect: TRect;
     45  Src: TCanvas; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload;
     46function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer;
     47  Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload;
     48function BitBltBitmap(Dest: TBitmap; DestRect: TRect;
     49  Src: TBitmap; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload;
    4450procedure SLine(ca: TCanvas; x0, x1, y: integer; cl: TColor);
    4551procedure DLine(ca: TCanvas; x0, x1, y: integer; cl0, cl1: TColor);
     
    5258procedure InitOrnament;
    5359procedure InitCityMark(const T: TTexture);
    54 procedure Fill(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer);
     60procedure Fill(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); overload;
     61procedure Fill(Canvas: TCanvas; Rect: TRect; Offset: TPoint); overload;
    5562procedure FillLarge(ca: TCanvas; x0, y0, x1, y1, xm: integer);
    5663procedure FillSeamless(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer;
     
    8289procedure LoadPhrases;
    8390procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Integer);
     91procedure DarkenImage(Bitmap: TBitmap; Change: Integer);
    8492
    8593const
     
    527535end;
    528536
    529 procedure MakeBlue(dst: TBitmap; x, y, w, h: integer);
     537procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer);
    530538var
    531539  XX, YY: integer;
     
    534542  Dst.BeginUpdate;
    535543  PixelPtr.Init(Dst, X, Y);
    536   for yy := 0 to h - 1 do begin
    537     for xx := 0 to w - 1 do begin
     544  for yy := 0 to Height - 1 do begin
     545    for xx := 0 to Width - 1 do begin
    538546      PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2;
    539547      PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2;
     
    730738    Result := True;
    731739  end else Result := BitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop);
     740end;
     741
     742function BitBltCanvas(Dest: TCanvas; DestRect: TRect; Src: TCanvas;
     743  SrcPos: TPoint; Rop: DWORD): Boolean;
     744begin
     745  Result := BitBltCanvas(Dest, DestRect.Left, DestRect.Top, DestRect.Width, DestRect.Height,
     746    Src, SrcPos.X, SrcPos.Y, Rop);
     747end;
     748
     749function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer;
     750  Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD): Boolean;
     751begin
     752  Result := BitBltCanvas(Dest.Canvas, X, Y, Width, Height, Src.Canvas, XSrc, YSrc, Rop);
     753end;
     754
     755function BitBltBitmap(Dest: TBitmap; DestRect: TRect; Src: TBitmap;
     756  SrcPos: TPoint; Rop: DWORD): Boolean;
     757begin
     758  Result := BitBltCanvas(Dest.Canvas, DestRect, Src.Canvas, SrcPos, Rop);
    732759end;
    733760
     
    901928  BitBltCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas,
    902929    Left + xOffset, Top + yOffset);
     930end;
     931
     932procedure Fill(Canvas: TCanvas; Rect: TRect; Offset: TPoint);
     933begin
     934  Fill(Canvas, Rect.Left, Rect.Top, Rect.Width, Rect.Height, Offset.X, Offset.Y);
    903935end;
    904936
     
    14261458end;
    14271459
     1460procedure DarkenImage(Bitmap: TBitmap; Change: Integer);
     1461var
     1462  x, y: integer;
     1463  PicturePixel: TPixelPointer;
     1464begin
     1465  Bitmap.BeginUpdate;
     1466  PicturePixel.Init(Bitmap);
     1467  for y := 0 to Bitmap.Height - 1 do begin
     1468    for x := 0 to Bitmap.Width - 1 do begin
     1469      PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - Change, 0);
     1470      PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - Change, 0);
     1471      PicturePixel.Pixel^.R := Max(PicturePixel.Pixel^.R - Change, 0);
     1472      PicturePixel.NextPixel;
     1473    end;
     1474    PicturePixel.NextLine;
     1475  end;
     1476  Bitmap.EndUpdate;
     1477end;
     1478
    14281479procedure LoadFonts;
    14291480var
Note: See TracChangeset for help on using the changeset viewer.