- Timestamp:
- Mar 17, 2021, 10:42:18 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r310 r312 2546 2546 Jump[0] := 999999; 2547 2547 GameMode := Command; 2548 for i := 0 to nGrExt - 1 do2549 FillChar(GrExt[i].pixUsed, GrExt[i].Data.height div 49 * 10, 0);2548 for i := 0 to GrExt.Count - 1 do 2549 GrExt[i].ResetPixUsed; 2550 2550 IsoEngine.Reset; 2551 2551 Tribes.Init; -
trunk/LocalPlayer/Tribes.pas
r301 r312 623 623 ok := True; 624 624 TestPic.GrName := Copy(Input, 8, 255) + '.png'; 625 HGr := nGrExt - 1;625 HGr := GrExt.Count - 1; 626 626 while (HGr >= 0) and (GrExt[HGr].Name <> TestPic.GrName) do 627 627 Dec(HGr); -
trunk/Packages/CevoComponents/ScreenTools.pas
r300 r312 8 8 {$ENDIF} 9 9 StringTables, LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Math, 10 Forms, Menus, GraphType ;10 Forms, Menus, GraphType, fgl; 11 11 12 12 type … … 106 106 107 107 const 108 nGrExtmax = 64;109 108 wMainTexture = 640; 110 109 hMainTexture = 480; … … 170 169 171 170 type 172 TGrExtDescr = record { don't use dynamic strings here! } 173 Name: string[31]; 171 172 { TGrExtDescr } 173 174 TGrExtDescr = class 175 Name: string; 174 176 Data: TBitmap; 175 177 Mask: TBitmap; 176 pixUsed: array [Byte] of Byte; 177 end; 178 179 TGrExtDescrSize = record { for size calculation only - must be the same as 180 TGrExtDescr, but without pixUsed } 181 Name: string[31]; 182 Data: TBitmap; 183 Mask: TBitmap; 178 pixUsed: array of Byte; 179 procedure ResetPixUsed; 180 constructor Create; 181 destructor Destroy; override; 182 end; 183 184 { TGrExtDescrs } 185 186 TGrExtDescrs = class(TFPGObjectList<TGrExtDescr>) 187 function SearchByName(Name: string): TGrExtDescr; 188 function AddNew(Name: string): TGrExtDescr; 184 189 end; 185 190 … … 189 194 Phrases: TStringTable; 190 195 Phrases2: TStringTable; 191 nGrExt: Integer; 192 GrExt: array [0 .. nGrExtmax - 1] of ^TGrExtDescr; 196 GrExt: TGrExtDescrs; 193 197 HGrSystem: Integer; 194 198 HGrSystem2: Integer; … … 493 497 function LoadGraphicSet(const Name: string): Integer; 494 498 var 495 I, x, y, xmax, OriginalColor: Integer; 499 I: Integer; 500 x: Integer; 501 y: Integer; 502 xmax: Integer; 503 OriginalColor: Integer; 496 504 FileName: string; 497 Source: TBitmap; 498 DataPixel, MaskPixel: TPixelPointer; 499 begin 500 I := 0; 501 while (I < nGrExt) and (GrExt[i].Name <> Name) do 502 Inc(I); 503 Result := I; 504 if I = nGrExt then begin 505 Source := TBitmap.Create; 506 Source.PixelFormat := pf24bit; 505 DataPixel: TPixelPointer; 506 MaskPixel: TPixelPointer; 507 NewGrExt: TGrExtDescr; 508 begin 509 NewGrExt := GrExt.SearchByName(Name); 510 if not Assigned(NewGrExt) then begin 511 NewGrExt := GrExt.AddNew(Name); 507 512 FileName := GetGraphicsDir + DirectorySeparator + Name; 508 if not LoadGraphicFile( Source, FileName) then begin513 if not LoadGraphicFile(NewGrExt.Data, FileName) then begin 509 514 Result := -1; 510 515 Exit; 511 516 end; 512 517 513 GetMem(GrExt[nGrExt], SizeOf(TGrExtDescrSize) + Source.Height div 49 * 10); 514 GrExt[nGrExt].Name := Name; 515 516 xmax := Source.Width - 1; // allows 4-byte access even for last pixel 518 NewGrExt.ResetPixUsed; 519 520 xmax := NewGrExt.Data.Width - 1; // allows 4-byte access even for last pixel 517 521 // Why there was that limit? 518 522 //if xmax > 970 then 519 523 // xmax := 970; 520 524 521 GrExt[nGrExt].Data := Source; 522 GrExt[nGrExt].Data.PixelFormat := pf24bit; 523 GrExt[nGrExt].Mask := TBitmap.Create; 524 GrExt[nGrExt].Mask.PixelFormat := pf24bit; 525 GrExt[nGrExt].Mask.SetSize(Source.Width, Source.Height); 526 527 GrExt[nGrExt].Data.BeginUpdate; 528 GrExt[nGrExt].Mask.BeginUpdate; 529 DataPixel := PixelPointer(GrExt[nGrExt].Data); 530 MaskPixel := PixelPointer(GrExt[nGrExt].Mask); 531 for y := 0 to ScaleToNative(Source.Height) - 1 do begin 525 NewGrExt.Mask.SetSize(NewGrExt.Data.Width, NewGrExt.Data.Height); 526 527 NewGrExt.Data.BeginUpdate; 528 NewGrExt.Mask.BeginUpdate; 529 DataPixel := PixelPointer(NewGrExt.Data); 530 MaskPixel := PixelPointer(NewGrExt.Mask); 531 for y := 0 to ScaleToNative(NewGrExt.Data.Height) - 1 do begin 532 532 for x := 0 to ScaleToNative(xmax) - 1 do begin 533 533 OriginalColor := DataPixel.Pixel^.ARGB and $FFFFFF; … … 548 548 MaskPixel.NextLine; 549 549 end; 550 GrExt[nGrExt].Data.EndUpdate; 551 GrExt[nGrExt].Mask.EndUpdate; 552 553 FillChar(GrExt[nGrExt].pixUsed, GrExt[nGrExt].Data.Height div 49 * 10, 0); 554 Inc(nGrExt); 555 end; 550 NewGrExt.Data.EndUpdate; 551 NewGrExt.Mask.EndUpdate; 552 end; 553 Result := GrExt.IndexOf(NewGrExt); 556 554 end; 557 555 … … 1701 1699 UniFont[Section] := TFont.Create; 1702 1700 1703 nGrExt := 0;1701 GrExt := TGrExtDescrs.Create; 1704 1702 HGrSystem := LoadGraphicSet('System.png'); 1705 1703 HGrSystem2 := LoadGraphicSet('System2.png'); … … 1723 1721 procedure UnitDone; 1724 1722 var 1725 I: integer;1723 I: Integer; 1726 1724 begin 1727 1725 RestoreResolution; 1728 for I := 0 to nGrExt - 1 do begin 1729 FreeAndNil(GrExt[I].Data); 1730 FreeAndNil(GrExt[I].Mask); 1731 FreeMem(GrExt[I]); 1732 end; 1733 1726 FreeAndNil(GrExt); 1734 1727 ReleaseFonts; 1735 1736 1728 FreeAndNil(Phrases); 1737 1729 FreeAndNil(Phrases2); … … 1744 1736 end; 1745 1737 1738 { TGrExtDescr } 1739 1740 procedure TGrExtDescr.ResetPixUsed; 1741 begin 1742 SetLength(pixUsed, Data.Height div 49 * 10); 1743 if Length(pixUsed) > 0 then 1744 FillChar(pixUsed[0], Length(pixUsed), 0); 1745 end; 1746 1747 constructor TGrExtDescr.Create; 1748 begin 1749 Data := TBitmap.Create; 1750 Data.PixelFormat := pf24bit; 1751 Mask := TBitmap.Create; 1752 Mask.PixelFormat := pf24bit; 1753 end; 1754 1755 destructor TGrExtDescr.Destroy; 1756 begin 1757 FreeAndNil(Data); 1758 FreeAndNil(Mask); 1759 inherited; 1760 end; 1761 1762 { TGrExtDescrs } 1763 1764 function TGrExtDescrs.SearchByName(Name: string): TGrExtDescr; 1765 var 1766 I: Integer; 1767 begin 1768 I := 0; 1769 while (I < Count) and (Items[I].Name <> Name) do Inc(I); 1770 if I < Count then Result := Items[I] 1771 else Result := nil; 1772 end; 1773 1774 function TGrExtDescrs.AddNew(Name: string): TGrExtDescr; 1775 begin 1776 Result := TGrExtDescr.Create; 1777 Result.Name := Name; 1778 Add(Result); 1779 end; 1780 1746 1781 end.
Note:
See TracChangeset
for help on using the changeset viewer.