Changeset 192
- Timestamp:
- May 7, 2020, 12:30:04 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GameServer.pas
r185 r192 122 122 Directories, CityProcessing, UnitProcessing, CmdList, LCLIntf, LCLType, 123 123 LMessages, Classes, SysUtils; 124 125 resourcestring 126 SNoAiFound = 'No AI libraries found in directory %s'; 124 127 125 128 var … … 256 259 BrainBeginner := nil; 257 260 258 if FindFirst( HomeDir + 'AI'+ DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then261 if FindFirst(GetAiDir + DirectorySeparator + '*', faDirectory or faArchive or faReadOnly, f) = 0 then 259 262 repeat 260 BasePath := HomeDir + 'AI'+ DirectorySeparator + f.Name;263 BasePath := GetAiDir + DirectorySeparator + f.Name; 261 264 if (f.Name <> '.') and (f.Name <> '..') and DirectoryExists(BasePath) then begin 262 265 NewBrain := Brains.AddNew; … … 272 275 273 276 if Brains.GetKindCount(btAI) = 0 then 274 raise Exception.Create(Format( 'No AI libraries found in directory %s', [HomeDir + 'AI']));277 raise Exception.Create(Format(SNoAiFound, [GetAiDir])); 275 278 end; 276 279 … … 4584 4587 constructor TBrain.Create; 4585 4588 begin 4586 Picture := nil; 4589 Picture := TBitmap.Create; 4590 Picture.SetSize(64, 64); 4587 4591 end; 4588 4592 4589 4593 destructor TBrain.Destroy; 4590 4594 begin 4591 if Assigned(Picture) then Picture.Free;4595 FreeAndNil(Picture); 4592 4596 inherited Destroy; 4593 4597 end; -
trunk/Packages/CevoComponents/Directories.pas
r190 r192 15 15 function GetGraphicsDir: string; 16 16 function GetSoundsDir: string; 17 function GetAiDir: string; 17 18 18 19 … … 126 127 end; 127 128 129 function GetAiDir: string; 130 begin 131 Result := HomeDir + 'AI'; 132 end; 133 128 134 end. -
trunk/Packages/CevoComponents/ScreenTools.pas
r190 r192 7 7 Windows, 8 8 {$ENDIF} 9 StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, 9 StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Math, 10 10 Forms, Menus, GraphType; 11 11 … … 35 35 procedure Sprite(dst: TBitmap; HGr, xDst, yDst, Width, Height, xGr, yGr: integer); 36 36 overload; 37 procedure MakeBlue(dst: TBitmap; x, y, w, h: integer);37 procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer); 38 38 procedure ImageOp_B(dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h: integer); 39 39 procedure ImageOp_BCC(dst, Src: TBitmap; … … 41 41 procedure ImageOp_CCC(bmp: TBitmap; x, y, w, h, Color0, Color1, Color2: integer); 42 42 function 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; 44 function BitBltCanvas(Dest: TCanvas; DestRect: TRect; 45 Src: TCanvas; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload; 46 function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer; 47 Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD = SRCCOPY): Boolean; overload; 48 function BitBltBitmap(Dest: TBitmap; DestRect: TRect; 49 Src: TBitmap; SrcPos: TPoint; Rop: DWORD = SRCCOPY): Boolean; overload; 44 50 procedure SLine(ca: TCanvas; x0, x1, y: integer; cl: TColor); 45 51 procedure DLine(ca: TCanvas; x0, x1, y: integer; cl0, cl1: TColor); … … 52 58 procedure InitOrnament; 53 59 procedure InitCityMark(const T: TTexture); 54 procedure Fill(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); 60 procedure Fill(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer); overload; 61 procedure Fill(Canvas: TCanvas; Rect: TRect; Offset: TPoint); overload; 55 62 procedure FillLarge(ca: TCanvas; x0, y0, x1, y1, xm: integer); 56 63 procedure FillSeamless(ca: TCanvas; Left, Top, Width, Height, xOffset, yOffset: integer; … … 82 89 procedure LoadPhrases; 83 90 procedure Texturize(Dest, Texture: TBitmap; TransparentColor: Integer); 91 procedure DarkenImage(Bitmap: TBitmap; Change: Integer); 84 92 85 93 const … … 527 535 end; 528 536 529 procedure MakeBlue(dst: TBitmap; x, y, w, h: integer);537 procedure MakeBlue(dst: TBitmap; x, y, Width, Height: Integer); 530 538 var 531 539 XX, YY: integer; … … 534 542 Dst.BeginUpdate; 535 543 PixelPtr.Init(Dst, X, Y); 536 for yy := 0 to h- 1 do begin537 for xx := 0 to w- 1 do begin544 for yy := 0 to Height - 1 do begin 545 for xx := 0 to Width - 1 do begin 538 546 PixelPtr.Pixel^.B := PixelPtr.Pixel^.B div 2; 539 547 PixelPtr.Pixel^.G := PixelPtr.Pixel^.G div 2; … … 730 738 Result := True; 731 739 end else Result := BitBlt(DestCanvas.Handle, X, Y, Width, Height, SrcCanvas.Handle, XSrc, YSrc, Rop); 740 end; 741 742 function BitBltCanvas(Dest: TCanvas; DestRect: TRect; Src: TCanvas; 743 SrcPos: TPoint; Rop: DWORD): Boolean; 744 begin 745 Result := BitBltCanvas(Dest, DestRect.Left, DestRect.Top, DestRect.Width, DestRect.Height, 746 Src, SrcPos.X, SrcPos.Y, Rop); 747 end; 748 749 function BitBltBitmap(Dest: TBitmap; X, Y, Width, Height: Integer; 750 Src: TBitmap; XSrc, YSrc: Integer; Rop: DWORD): Boolean; 751 begin 752 Result := BitBltCanvas(Dest.Canvas, X, Y, Width, Height, Src.Canvas, XSrc, YSrc, Rop); 753 end; 754 755 function BitBltBitmap(Dest: TBitmap; DestRect: TRect; Src: TBitmap; 756 SrcPos: TPoint; Rop: DWORD): Boolean; 757 begin 758 Result := BitBltCanvas(Dest.Canvas, DestRect, Src.Canvas, SrcPos, Rop); 732 759 end; 733 760 … … 901 928 BitBltCanvas(ca, Left, Top, Width, Height, MainTexture.Image.Canvas, 902 929 Left + xOffset, Top + yOffset); 930 end; 931 932 procedure Fill(Canvas: TCanvas; Rect: TRect; Offset: TPoint); 933 begin 934 Fill(Canvas, Rect.Left, Rect.Top, Rect.Width, Rect.Height, Offset.X, Offset.Y); 903 935 end; 904 936 … … 1426 1458 end; 1427 1459 1460 procedure DarkenImage(Bitmap: TBitmap; Change: Integer); 1461 var 1462 x, y: integer; 1463 PicturePixel: TPixelPointer; 1464 begin 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; 1477 end; 1478 1428 1479 procedure LoadFonts; 1429 1480 var -
trunk/Start.pas
r190 r192 154 154 procedure LoadConfig; 155 155 procedure SaveConfig; 156 procedure LoadAiBrainsPictures; 156 157 end; 157 158 … … 433 434 r0, r1: HRgn; 434 435 Location: TPoint; 436 PlayerSlot: TPlayerSlot; 435 437 AIBrains: TBrains; 436 PlayerSlot: TPlayerSlot;437 438 begin 438 439 PlayerSlots := TPlayerSlots.Create; … … 528 529 CustomizeBtn.ButtonIndex := 2; 529 530 530 Brains[0].Picture := TBitmap.Create; 531 Brains[0].Picture.SetSize(64, 64); 532 BitBltCanvas(Brains[0].Picture.Canvas, 0, 0, 64, 64, 533 GrExt[HGrSystem2].Data.Canvas, 1, 111); 534 Brains[1].Picture := TBitmap.Create; 535 Brains[1].Picture.SetSize(64, 64); 536 BitBltCanvas(Brains[1].Picture.Canvas, 0, 0, 64, 64, 537 GrExt[HGrSystem2].Data.Canvas, 66, 111); 538 Brains[2].Picture := TBitmap.Create; 539 Brains[2].Picture.SetSize(64, 64); 540 BitBltCanvas(Brains[2].Picture.Canvas, 0, 0, 64, 64, 541 GrExt[HGrSystem2].Data.Canvas, 131, 111); 542 Brains[3].Picture := TBitmap.Create; 543 Brains[3].Picture.SetSize(64, 64); 544 BitBltCanvas(Brains[3].Picture.Canvas, 0, 0, 64, 64, 545 GrExt[HGrSystem2].Data.Canvas, 131, 46); 546 547 AIBrains := TBrains.Create(False); 548 Brains.GetByKind(btAI, AIBrains); 549 for i := 0 to AIBrains.Count - 1 do 550 with AIBrains[I] do 551 begin 552 AIBrains[i].Picture := TBitmap.Create; 553 if not LoadGraphicFile(AIBrains[i].Picture, HomeDir + 'AI' + DirectorySeparator + 554 FileName + DirectorySeparator + FileName + '.png', gfNoError) then begin 555 AIBrains[i].Picture.SetSize(64, 64); 556 with AIBrains[i].Picture.Canvas do begin 557 Brush.Color := $904830; 558 FillRect(Rect(0, 0, 64, 64)); 559 Font.Assign(UniFont[ftTiny]); 560 Font.Style := []; 561 Font.Color := $5FDBFF; 562 Textout(32 - TextWidth(FileName) div 2, 563 32 - TextHeight(FileName) div 2, FileName); 564 end; 565 end; 566 end; 567 AIBrains.Free; 531 BitBltBitmap(BrainNoTerm.Picture, 0, 0, 64, 64, GrExt[HGrSystem2].Data, 1, 111); 532 BitBltBitmap(BrainSuperVirtual.Picture, 0, 0, 64, 64, GrExt[HGrSystem2].Data, 66, 111); 533 BitBltBitmap(BrainTerm.Picture, 0, 0, 64, 64, GrExt[HGrSystem2].Data, 131, 111); 534 BitBltBitmap(BrainRandom.Picture, 0, 0, 64, 64, GrExt[HGrSystem2].Data, 131, 46); 535 LoadAiBrainsPictures; 568 536 569 537 EmptyPicture := TBitmap.Create; … … 712 680 end; 713 681 682 procedure TStartDlg.LoadAiBrainsPictures; 683 var 684 AIBrains: TBrains; 685 I: Integer; 686 begin 687 AIBrains := TBrains.Create(False); 688 Brains.GetByKind(btAI, AIBrains); 689 for i := 0 to AIBrains.Count - 1 do 690 with AIBrains[I] do begin 691 if not LoadGraphicFile(AIBrains[i].Picture, GetAiDir + DirectorySeparator + 692 FileName + DirectorySeparator + FileName + '.png', gfNoError) then begin 693 with AIBrains[i].Picture.Canvas do begin 694 Brush.Color := $904830; 695 FillRect(Rect(0, 0, 64, 64)); 696 Font.Assign(UniFont[ftTiny]); 697 Font.Style := []; 698 Font.Color := $5FDBFF; 699 Textout(32 - TextWidth(FileName) div 2, 700 32 - TextHeight(FileName) div 2, FileName); 701 end; 702 end; 703 end; 704 AIBrains.Free; 705 end; 706 714 707 procedure TStartDlg.DrawAction(y, IconIndex: integer; HeaderItem, TextItem: string); 715 708 begin … … 828 821 if Page = pgMain then 829 822 begin 830 if SelectedAction >=maNone then // mark selected action823 if SelectedAction <> maNone then // mark selected action 831 824 for i := 0 to (ClientWidth - 2 * ActionSideBorder) div wBuffer + 1 do 832 825 begin … … 852 845 if MainAction in ActionsOffered then 853 846 case MainAction of 854 maConfig: 855 DrawAction(y, 25, 'ACTIONHEADER_CONFIG', 'ACTION_CONFIG'); 856 maManual: 857 DrawAction(y, 19, 'ACTIONHEADER_MANUAL', 'ACTION_MANUAL'); 858 maCredits: 859 DrawAction(y, 22, 'ACTIONHEADER_CREDITS', 'ACTION_CREDITS'); 860 maAIDev: 861 DrawAction(y, 24, 'ACTIONHEADER_AIDEV', 'ACTION_AIDEV'); 847 maConfig: DrawAction(y, 25, 'ACTIONHEADER_CONFIG', 'ACTION_CONFIG'); 848 maManual: DrawAction(y, 19, 'ACTIONHEADER_MANUAL', 'ACTION_MANUAL'); 849 maCredits: DrawAction(y, 22, 'ACTIONHEADER_CREDITS', 'ACTION_CREDITS'); 850 maAIDev: DrawAction(y, 24, 'ACTIONHEADER_AIDEV', 'ACTION_AIDEV'); 862 851 maWeb: 863 852 begin … … 1095 1084 1096 1085 procedure TStartDlg.FormShow(Sender: TObject); 1097 var1098 x, y: integer;1099 PicturePixel: TPixelPointer;1100 1086 begin 1101 1087 SetMainTextureByAge(-1); 1102 1088 List.Font.Color := MainTexture.clMark; 1103 1089 1104 Fill(EmptyPicture.Canvas, 0, 0, 64, 64, (wMaintexture - 64) div 2, 1105 (hMaintexture - 64) div 2); 1106 // darken texture for empty slot 1107 EmptyPicture.BeginUpdate; 1108 PicturePixel.Init(EmptyPicture); 1109 for y := 0 to 63 do begin 1110 for x := 0 to 64 - 1 do begin 1111 PicturePixel.Pixel^.B := Max(PicturePixel.Pixel^.B - 28, 0); 1112 PicturePixel.Pixel^.G := Max(PicturePixel.Pixel^.G - 28, 0); 1113 PicturePixel.Pixel^.R := Max(PicturePixel.Pixel^.R - 28, 0); 1114 PicturePixel.NextPixel; 1115 end; 1116 PicturePixel.NextLine; 1117 end; 1118 EmptyPicture.EndUpdate; 1090 Fill(EmptyPicture.Canvas, Bounds(0, 0, 64, 64), 1091 Point((wMaintexture - 64) div 2, (hMaintexture - 64) div 2)); 1092 1093 DarkenImage(EmptyPicture, 28); 1119 1094 1120 1095 Difficulty[0] := Diff0;
Note:
See TracChangeset
for help on using the changeset viewer.