Changeset 187


Ignore:
Timestamp:
May 6, 2020, 9:54:34 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Made MiniMap separate class for better code readability and abstraction.
Location:
trunk
Files:
3 edited

Legend:

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

    r182 r187  
    170170  nGrExt: Integer;
    171171  GrExt: array [0 .. nGrExtmax - 1] of ^TGrExtDescr;
    172   HGrSystem, HGrSystem2, ClickFrameColor, MainTextureAge: Integer;
     172  HGrSystem: Integer;
     173  HGrSystem2: Integer;
     174  ClickFrameColor: Integer;
     175  MainTextureAge: Integer;
    173176  MainTexture: TTexture;
    174   Templates, Colors, Paper, BigImp, LogoBuffer: TBitmap;
    175   FullScreen, GenerateNames, InitOrnamentDone, Phrases2FallenBackToEnglish: Boolean;
     177  Templates: TBitmap;
     178  Colors: TBitmap;
     179  Paper: TBitmap;
     180  BigImp: TBitmap;
     181  LogoBuffer: TBitmap;
     182  FullScreen: Boolean;
     183  GenerateNames: Boolean;
     184  InitOrnamentDone: Boolean;
     185  Phrases2FallenBackToEnglish: Boolean;
    176186
    177187  UniFont: array [TFontType] of TFont;
  • trunk/Protocol.pas

    r148 r187  
    11151115// cost values accumulate if prerequisite is future tech / are maximized if not
    11161116nUpgrade = 15;
    1117 upgrade:
    1118 array [0 .. nDomains - 1, 0 .. nUpgrade - 1] of record
     1117upgrade: array [0 .. nDomains - 1, 0 .. nUpgrade - 1] of record
    11191118  Preq: Integer;
    11201119  Strength: Integer;
  • trunk/Start.pas

    r185 r187  
    3232
    3333  TStartTab = (tbMain, tbMap, tbNew, tbPrevious);
    34   TMiniMode = (mmNone, mmPicture, mmMultiPlayer);
    3534  TMainAction = (maConfig, maManual, maCredits, maAIDev, maWeb, maNone);
    3635  TMainActionSet = set of TMainAction;
    3736
    3837  TMapArray = array[0 .. lxmax * lymax - 1] of Byte;
     38
     39  TMiniMode = (mmNone, mmPicture, mmMultiPlayer);
     40
     41  { TMiniMap }
     42
     43  TMiniMap = class
     44  const
     45    MaxWidthMapLogo = 96;
     46    MaxHeightMapLogo = 96;
     47  var
     48    Bitmap: TBitmap; { game world sample preview }
     49    Size: TPoint;
     50    Colors: array [0 .. 11, 0 .. 1] of TColor;
     51    Mode: TMiniMode;
     52    procedure LoadFromLogFile(FileName: string; var LastTurn: Integer);
     53    procedure LoadFromMapFile(FileName: string; var nMapLandTiles, nMapStartPositions: Integer);
     54    procedure PaintRandom(Brightness, StartLandMass, WorldSize: Integer);
     55    procedure PaintFile(SaveMap: TMapArray);
     56    constructor Create;
     57    destructor Destroy; override;
     58  end;
    3959
    4060  { TStartDlg }
     
    98118    AutoDiff: Integer;
    99119    MultiControl: Integer;
    100     MiniSize: TPoint;
    101120    Page: TStartPage;
    102121    ShowTab: TStartTab;
     
    115134    FormerGames: TStringList;
    116135    Maps: TStringList;
    117     LogoBuffer, Mini: TBitmap; { game world sample preview }
    118     MiniColors: array [0 .. 11, 0 .. 1] of TColor;
     136    LogoBuffer: TBitmap;
    119137    // BookDate: string;
    120138    PlayerSlots: TPlayerSlots;
    121     MiniMode: TMiniMode;
    122139    ActionsOffered: TMainActionSet;
    123140    SelectedAction: TMainAction;
     
    125142    Tracking: Boolean;
    126143    DefaultAI: string;
     144    MiniMap: TMiniMap;
    127145    procedure DrawAction(y, IconIndex: integer; HeaderItem, TextItem: string);
    128146    procedure InitPopup(PlayerIndex: Integer);
    129147    procedure OfferBrain(Brain: TBrain; FixedLines: Integer);
    130     procedure PaintFileMini(SaveMap: TMapArray);
    131148    procedure PaintInfo;
    132149    procedure ChangePage(NewPage: TStartPage);
    133150    procedure ChangeTab(NewTab: TStartTab);
    134     procedure PaintRandomMini(Brightness: integer);
    135151    procedure UnlistBackupFile(FileName: string);
    136152    procedure SmartInvalidate(x0, y0, x1, y1: integer;
     
    160176    DefaultWorldTiles=4200; }
    161177  MaxWorldSize = 6;
    162   WorldSizes: array [0 .. MaxWorldSize - 1] of TPoint = ((X: 30; Y:46),
    163     (X: 40; Y:52), (X: 50; Y:60), (X: 60; Y:70), (X: 75; Y:82), (X: 100; Y:96));
     178  WorldSizes: array [0 .. MaxWorldSize - 1] of TPoint = ((X: 30; Y: 46),
     179    (X: 40; Y: 52), (X: 50; Y: 60), (X: 60; Y: 70), (X: 75; Y: 82),
     180    (X: 100; Y: 96));
    164181  DefaultWorldTiles = 4150;
    165182  DefaultWorldSize = 3;
     
    197214  TabHeight = 40;
    198215
    199   MaxWidthMapLogo = 96;
    200   MaxHeightMapLogo = 96;
    201 
    202216  InitAlive: array [1 .. nPl] of integer = (1, 1 + 2, 1 + 2 + 32,
    203217    1 + 2 + 8 + 128, 1 + 2 + 8 + 32 + 128, 1 + 2 + 8 + 16 + 64 + 128,
     
    210224  EnemyAutoDiff: array [1 .. 5] of integer = (4, 3, 2, 1, 1);
    211225
     226{ TMiniMap }
     227
     228constructor TMiniMap.Create;
     229var
     230  X, Y: Integer;
     231begin
     232  Bitmap := TBitmap.Create;
     233
     234  for X := 0 to 11 do
     235    for Y := 0 to 1 do
     236      Colors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y];
     237end;
     238
     239destructor TMiniMap.Destroy;
     240begin
     241  FreeAndNil(Bitmap);
     242  inherited Destroy;
     243end;
     244
     245procedure TMiniMap.LoadFromLogFile(FileName: string; var LastTurn: Integer);
     246var
     247  SaveMap: TMapArray;
     248  y: Integer;
     249  Dummy: Integer;
     250  FileLandMass: integer;
     251  LogFile: file;
     252  s: string[255];
     253  MapRow: array [0 .. lxmax - 1] of Cardinal;
     254begin
     255  AssignFile(LogFile, FileName);
     256  try
     257    Reset(LogFile, 4);
     258    BlockRead(LogFile, s[1], 2); { file id }
     259    BlockRead(LogFile, Dummy, 1); { format id }
     260    if Dummy >= $000E01 then
     261      BlockRead(LogFile, Dummy, 1); { item stored since 0.14.1 }
     262    BlockRead(LogFile, Size.X, 1);
     263    BlockRead(LogFile, Size.Y, 1);
     264    BlockRead(LogFile, FileLandMass, 1);
     265    if FileLandMass = 0 then
     266      for y := 0 to Size.Y - 1 do
     267        BlockRead(LogFile, MapRow, Size.X);
     268    BlockRead(LogFile, Dummy, 1);
     269    BlockRead(LogFile, Dummy, 1);
     270    BlockRead(LogFile, LastTurn, 1);
     271    BlockRead(LogFile, SaveMap, 1);
     272    if SaveMap[0] = $80 then
     273      Mode := mmMultiPlayer
     274    else
     275      Mode := mmPicture;
     276    if Mode = mmPicture then
     277      BlockRead(LogFile, SaveMap[4], (Size.X * Size.Y - 1) div 4);
     278    CloseFile(LogFile);
     279  except
     280    CloseFile(LogFile);
     281    LastTurn := 0;
     282    Size := WorldSizes[DefaultWorldSize];
     283    Mode := mmNone;
     284  end;
     285  PaintFile(SaveMap);
     286end;
     287
     288procedure TMiniMap.LoadFromMapFile(FileName: string; var nMapLandTiles, nMapStartPositions: Integer);
     289var
     290  x, y, lxFile, lyFile: integer;
     291  MapFile: file;
     292  s: string[255];
     293  MapRow: array [0 .. lxmax - 1] of Cardinal;
     294  ImageFileName: string;
     295begin
     296  ImageFileName := Copy(FileName, 1, Length(FileName) - Length(CevoMapExt)) + '.png';
     297  Mode := mmPicture;
     298  if LoadGraphicFile(Bitmap, ImageFileName, gfNoError) then
     299  begin
     300    if Bitmap.width div 2 > MaxWidthMapLogo then
     301      Bitmap.width := MaxWidthMapLogo * 2;
     302    if Bitmap.height > MaxHeightMapLogo then
     303      Bitmap.height := MaxHeightMapLogo;
     304    Size.X := Bitmap.width div 2;
     305    Size.Y := Bitmap.height;
     306  end
     307  else
     308  begin
     309    Mode := mmNone;
     310    Size.X := MaxWidthMapLogo;
     311    Size.Y := MaxHeightMapLogo;
     312  end;
     313
     314  AssignFile(MapFile, FileName);
     315  try
     316    Reset(MapFile, 4);
     317    BlockRead(MapFile, s[1], 2); { file id }
     318    BlockRead(MapFile, x, 1); { format id }
     319    BlockRead(MapFile, x, 1); // MaxTurn
     320    BlockRead(MapFile, lxFile, 1);
     321    BlockRead(MapFile, lyFile, 1);
     322    nMapLandTiles := 0;
     323    nMapStartPositions := 0;
     324    for y := 0 to lyFile - 1 do begin
     325      BlockRead(MapFile, MapRow, lxFile);
     326      for x := 0 to lxFile - 1 do
     327      begin
     328        if (MapRow[x] and fTerrain) in [fGrass, fPrairie, fTundra, fSwamp,
     329          fForest, fHills] then
     330          inc(nMapLandTiles);
     331        if MapRow[x] and (fPrefStartPos or fStartPos) <> 0 then
     332          inc(nMapStartPositions);
     333      end
     334    end;
     335    if nMapStartPositions > nPl then
     336      nMapStartPositions := nPl;
     337    CloseFile(MapFile);
     338  except
     339    CloseFile(MapFile);
     340  end;
     341end;
     342
     343procedure TMiniMap.PaintRandom(Brightness, StartLandMass, WorldSize: Integer);
     344var
     345  i, x, y, xm, cm: Integer;
     346  MiniPixel: TPixelPointer;
     347  Map: ^TTileList;
     348begin
     349  Map := PreviewMap(StartLandMass);
     350  Size := WorldSizes[WorldSize];
     351
     352  Bitmap.PixelFormat := pf24bit;
     353  Bitmap.SetSize(Size.X * 2, Size.Y);
     354  Bitmap.BeginUpdate;
     355  MiniPixel.Init(Bitmap);
     356  for y := 0 to Size.Y - 1 do begin
     357    for x := 0 to Size.X - 1 do begin
     358      for i := 0 to 1 do begin
     359        xm := (x * 2 + i + y and 1) mod (Size.X * 2);
     360        MiniPixel.SetX(xm);
     361        cm := Colors
     362          [Map[x * lxmax div Size.X + lxmax *
     363          ((y * (lymax - 1) + Size.Y div 2) div (Size.Y - 1))] and
     364          fTerrain, i];
     365        MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
     366        MiniPixel.Pixel^.G := ((cm shr 8) and $FF) * Brightness div 3;
     367        MiniPixel.Pixel^.R := ((cm shr 0) and $FF) * Brightness div 3;
     368      end;
     369    end;
     370    MiniPixel.NextLine;
     371  end;
     372  Bitmap.EndUpdate;
     373end;
     374
     375procedure TMiniMap.PaintFile(SaveMap: TMapArray);
     376var
     377  i, x, y, xm, cm, Tile, OwnColor, EnemyColor: integer;
     378  MiniPixel: TPixelPointer;
     379  PrevMiniPixel: TPixelPointer;
     380begin
     381  OwnColor := GrExt[HGrSystem].Data.Canvas.Pixels[95, 67];
     382  EnemyColor := GrExt[HGrSystem].Data.Canvas.Pixels[96, 67];
     383  Bitmap.PixelFormat := pf24bit;
     384  Bitmap.SetSize(Size.X * 2, Size.Y);
     385  if Mode = mmPicture then begin
     386    Bitmap.BeginUpdate;
     387    MiniPixel.Init(Bitmap);
     388    PrevMiniPixel.Init(Bitmap, 0, -1);
     389    for y := 0 to Size.Y - 1 do begin
     390      for x := 0 to Size.X - 1 do begin
     391        for i := 0 to 1 do begin
     392          xm := (x * 2 + i + y and 1) mod (Size.X * 2);
     393          MiniPixel.SetX(xm);
     394          Tile := SaveMap[x + Size.X * y];
     395          if Tile and fTerrain = fUNKNOWN then
     396            cm := $000000
     397          else if Tile and smCity <> 0 then
     398          begin
     399            if Tile and smOwned <> 0 then
     400              cm := OwnColor
     401            else
     402              cm := EnemyColor;
     403            if y > 0 then begin
     404              // 2x2 city dot covers two lines
     405              PrevMiniPixel.SetX(xm);
     406              PrevMiniPixel.Pixel^.B := cm shr 16;
     407              PrevMiniPixel.Pixel^.G:= cm shr 8 and $FF;
     408              PrevMiniPixel.Pixel^.R := cm and $FF;
     409            end;
     410          end
     411          else if (i = 0) and (Tile and smUnit <> 0) then
     412            if Tile and smOwned <> 0 then
     413              cm := OwnColor
     414            else cm := EnemyColor
     415          else
     416            cm := Colors[Tile and fTerrain, i];
     417          MiniPixel.Pixel^.B := (cm shr 16) and $ff;
     418          MiniPixel.Pixel^.G := (cm shr 8) and $ff;
     419          MiniPixel.Pixel^.R := (cm shr 0) and $ff;
     420        end;
     421      end;
     422      MiniPixel.NextLine;
     423      PrevMiniPixel.NextLine;
     424    end;
     425    Bitmap.EndUpdate;
     426  end;
     427end;
     428
     429{ TStartDlg }
    212430
    213431procedure TStartDlg.FormCreate(Sender: TObject);
    214432var
    215   x, y, i: Integer;
     433  x, i: Integer;
    216434  r0, r1: HRgn;
    217435  Location: TPoint;
     
    362580  LogoBuffer.Canvas.FillRect(0, 0, LogoBuffer.Width, LogoBuffer.Height);
    363581
    364   Mini := TBitmap.Create;
    365   for x := 0 to 11 do
    366     for y := 0 to 1 do
    367       MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y];
     582  MiniMap := TMiniMap.Create;
    368583  InitButtons;
    369584
     
    386601  FreeAndNil(FormerGames);
    387602  FreeAndNil(Maps);
    388   FreeAndNil(Mini);
    389603  FreeAndNil(EmptyPicture);
    390604  FreeAndNil(LogoBuffer);
    391605  FreeAndNil(PlayerSlots);
     606  FreeAndNil(MiniMap);
    392607end;
    393608
     
    8251040    BtnFrame(Canvas, ReplayBtn.BoundsRect, MainTexture);
    8261041
    827   if not(Page in [pgMain, pgNoLoad]) then
    828   begin
    829     xMini := x0Mini - MiniSize.X;
    830     yMini := y0Mini - MiniSize.Y div 2;
    831     Frame(Canvas, xMini, yMini, xMini + 3 + MiniSize.X * 2,
    832       yMini + 3 + MiniSize.Y, MainTexture.clBevelLight,
     1042  if not (Page in [pgMain, pgNoLoad]) then
     1043  begin
     1044    xMini := x0Mini - MiniMap.Size.X;
     1045    yMini := y0Mini - MiniMap.Size.Y div 2;
     1046    Frame(Canvas, xMini, yMini, xMini + 3 + MiniMap.Size.X * 2,
     1047      yMini + 3 + MiniMap.Size.Y, MainTexture.clBevelLight,
    8331048      MainTexture.clBevelShade);
    834     Frame(Canvas, xMini + 1, yMini + 1, xMini + 2 + MiniSize.X * 2,
    835       yMini + 2 + MiniSize.Y, MainTexture.clBevelShade,
     1049    Frame(Canvas, xMini + 1, yMini + 1, xMini + 2 + MiniMap.Size.X * 2,
     1050      yMini + 2 + MiniMap.Size.Y, MainTexture.clBevelShade,
    8361051      MainTexture.clBevelLight);
    8371052  end;
    8381053  s := '';
    839   if MiniMode = mmPicture then
    840   begin
    841     BitBlt(Canvas.Handle, xMini + 2, yMini + 2, MiniSize.X * 2, MiniSize.Y,
    842       Mini.Canvas.Handle, 0, 0, SRCCOPY);
     1054  if MiniMap.Mode = mmPicture then
     1055  begin
     1056    BitBlt(Canvas.Handle, xMini + 2, yMini + 2, MiniMap.Size.X * 2, MiniMap.Size.Y,
     1057      MiniMap.Bitmap.Canvas.Handle, 0, 0, SRCCOPY);
    8431058    if Page = pgStartRandom then
    8441059      s := Phrases.Lookup('RANMAP')
    8451060  end
    846   else if MiniMode = mmMultiPlayer then
     1061  else if MiniMap.Mode = mmMultiPlayer then
    8471062    s := Phrases.Lookup('MPMAP')
    8481063  else if Page = pgStartMap then
     
    10261241end;
    10271242
    1028 procedure TStartDlg.PaintRandomMini(Brightness: integer);
    1029 var
    1030   i, x, y, xm, cm: integer;
    1031   MiniPixel: TPixelPointer;
    1032   Map: ^TTileList;
    1033 begin
    1034   Map := PreviewMap(StartLandMass);
    1035   MiniSize := WorldSizes[WorldSize];
    1036 
    1037   Mini.PixelFormat := pf24bit;
    1038   Mini.SetSize(MiniSize.X * 2, MiniSize.Y);
    1039   Mini.BeginUpdate;
    1040   MiniPixel.Init(Mini);
    1041   for y := 0 to MiniSize.Y - 1 do begin
    1042     for x := 0 to MiniSize.X - 1 do begin
    1043       for i := 0 to 1 do begin
    1044         xm := (x * 2 + i + y and 1) mod (MiniSize.X * 2);
    1045         MiniPixel.SetX(xm);
    1046         cm := MiniColors
    1047           [Map[x * lxmax div MiniSize.X + lxmax *
    1048           ((y * (lymax - 1) + MiniSize.Y div 2) div (MiniSize.Y - 1))] and
    1049           fTerrain, i];
    1050         MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3;
    1051         MiniPixel.Pixel^.G := ((cm shr 8) and $FF) * Brightness div 3;
    1052         MiniPixel.Pixel^.R := ((cm shr 0) and $FF) * Brightness div 3;
    1053       end;
    1054     end;
    1055     MiniPixel.NextLine;
    1056   end;
    1057   Mini.EndUpdate;
    1058 end;
    1059 
    1060 procedure TStartDlg.PaintFileMini(SaveMap: TMapArray);
    1061 var
    1062   i, x, y, xm, cm, Tile, OwnColor, EnemyColor: integer;
    1063   MiniPixel, PrevMiniPixel: TPixelPointer;
    1064 begin
    1065   OwnColor := GrExt[HGrSystem].Data.Canvas.Pixels[95, 67];
    1066   EnemyColor := GrExt[HGrSystem].Data.Canvas.Pixels[96, 67];
    1067   Mini.PixelFormat := pf24bit;
    1068   Mini.SetSize(MiniSize.X * 2, MiniSize.Y);
    1069   if MiniMode = mmPicture then
    1070   begin
    1071     Mini.BeginUpdate;
    1072     MiniPixel.Init(Mini);
    1073     PrevMiniPixel.Init(Mini, 0, -1);
    1074     for y := 0 to MiniSize.Y - 1 do begin
    1075       for x := 0 to MiniSize.X - 1 do begin
    1076         for i := 0 to 1 do begin
    1077           xm := (x * 2 + i + y and 1) mod (MiniSize.X * 2);
    1078           MiniPixel.SetX(xm);
    1079           Tile := SaveMap[x + MiniSize.X * y];
    1080           if Tile and fTerrain = fUNKNOWN then
    1081             cm := $000000
    1082           else if Tile and smCity <> 0 then
    1083           begin
    1084             if Tile and smOwned <> 0 then
    1085               cm := OwnColor
    1086             else
    1087               cm := EnemyColor;
    1088             if y > 0 then begin
    1089               // 2x2 city dot covers two lines
    1090               PrevMiniPixel.SetX(xm);
    1091               PrevMiniPixel.Pixel^.B := cm shr 16;
    1092               PrevMiniPixel.Pixel^.G:= cm shr 8 and $FF;
    1093               PrevMiniPixel.Pixel^.R := cm and $FF;
    1094             end;
    1095           end
    1096           else if (i = 0) and (Tile and smUnit <> 0) then
    1097             if Tile and smOwned <> 0 then
    1098               cm := OwnColor
    1099             else
    1100               cm := EnemyColor
    1101           else
    1102             cm := MiniColors[Tile and fTerrain, i];
    1103           MiniPixel.Pixel^.B := cm shr 16;
    1104           MiniPixel.Pixel^.G:= cm shr 8 and $FF;
    1105           MiniPixel.Pixel^.R := cm and $FF;
    1106         end;
    1107       end;
    1108       MiniPixel.NextLine;
    1109       PrevMiniPixel.NextLine;
    1110     end;
    1111     Mini.EndUpdate;
    1112   end;
    1113 end;
    1114 
    11151243procedure TStartDlg.PaintInfo;
    1116 var
    1117   SaveMap: TMapArray;
    1118   x, y, Dummy, FileLandMass, lxFile, lyFile: integer;
    1119   LogFile, MapFile: file;
    1120   s: string[255];
    1121   MapRow: array [0 .. lxmax - 1] of Cardinal;
    11221244begin
    11231245  case Page of
    1124     pgStartRandom:
    1125       begin
    1126         MiniMode := mmPicture;
    1127         PaintRandomMini(3);
    1128       end;
    1129     pgNoLoad:
    1130       begin
    1131         MiniSize := WorldSizes[DefaultWorldSize];
    1132         MiniMode := mmNone;
    1133       end;
    1134     pgLoad:
    1135       begin
    1136         AssignFile(LogFile, GetSavedDir + DirectorySeparator + List.Items[List.ItemIndex]
    1137           + CevoExt);
    1138         try
    1139           Reset(LogFile, 4);
    1140           BlockRead(LogFile, s[1], 2); { file id }
    1141           BlockRead(LogFile, Dummy, 1); { format id }
    1142           if Dummy >= $000E01 then
    1143             BlockRead(LogFile, Dummy, 1); { item stored since 0.14.1 }
    1144           BlockRead(LogFile, MiniSize.X, 1);
    1145           BlockRead(LogFile, MiniSize.Y, 1);
    1146           BlockRead(LogFile, FileLandMass, 1);
    1147           if FileLandMass = 0 then
    1148             for y := 0 to MiniSize.Y - 1 do
    1149               BlockRead(LogFile, MapRow, MiniSize.X);
    1150           BlockRead(LogFile, Dummy, 1);
    1151           BlockRead(LogFile, Dummy, 1);
    1152           BlockRead(LogFile, LastTurn, 1);
    1153           BlockRead(LogFile, SaveMap, 1);
    1154           if SaveMap[0] = $80 then
    1155             MiniMode := mmMultiPlayer
    1156           else
    1157             MiniMode := mmPicture;
    1158           if MiniMode = mmPicture then
    1159             BlockRead(LogFile, SaveMap[4], (MiniSize.X * MiniSize.Y - 1) div 4);
    1160           CloseFile(LogFile);
    1161         except
    1162           CloseFile(LogFile);
    1163           LastTurn := 0;
    1164           MiniSize := WorldSizes[DefaultWorldSize];
    1165           MiniMode := mmNone;
    1166         end;
     1246    pgStartRandom: begin
     1247      MiniMap.Mode := mmPicture;
     1248      MiniMap.PaintRandom(3, StartLandMass, WorldSize);
     1249    end;
     1250    pgNoLoad: begin
     1251      MiniMap.Mode := mmNone;
     1252      MiniMap.Size := WorldSizes[DefaultWorldSize];
     1253    end;
     1254    pgLoad: begin
     1255        MiniMap.LoadFromLogFile(GetSavedDir + DirectorySeparator +
     1256          List.Items[List.ItemIndex] + CevoExt, LastTurn);
    11671257        // BookDate:=DateToStr(FileDateToDateTime(FileAge(FileName)));
    1168         PaintFileMini(SaveMap);
    1169         if not TurnValid then
    1170         begin
     1258        if not TurnValid then  begin
    11711259          LoadTurn := LastTurn;
    11721260          SmartInvalidate(xTurnSlider - 2, y0Mini + 61,
     
    11751263        TurnValid := True;
    11761264      end;
    1177     pgEditRandom:
    1178       begin
    1179         MapFileName := '';
    1180         MiniMode := mmPicture;
    1181         PaintRandomMini(4);
    1182       end;
     1265    pgEditRandom: begin
     1266      MapFileName := '';
     1267      MiniMap.Mode := mmPicture;
     1268      MiniMap.PaintRandom(4, StartLandMass, WorldSize);
     1269    end;
    11831270    pgStartMap, pgEditMap:
    11841271      begin
    1185         MiniMode := mmPicture;
    11861272        if Page = pgEditMap then
    11871273          MapFileName := List.Items[List.ItemIndex] + CevoMapExt;
    1188         if LoadGraphicFile(Mini, GetMapsDir + DirectorySeparator + Copy(MapFileName, 1,
    1189           Length(MapFileName) - 9) + '.png', gfNoError) then
    1190         begin
    1191           if Mini.width div 2 > MaxWidthMapLogo then
    1192             Mini.width := MaxWidthMapLogo * 2;
    1193           if Mini.height > MaxHeightMapLogo then
    1194             Mini.height := MaxHeightMapLogo;
    1195           MiniSize.X := Mini.width div 2;
    1196           MiniSize.Y := Mini.height;
    1197         end
    1198         else
    1199         begin
    1200           MiniMode := mmNone;
    1201           MiniSize.X := MaxWidthMapLogo;
    1202           MiniSize.Y := MaxHeightMapLogo;
    1203         end;
    1204 
    1205         AssignFile(MapFile, GetMapsDir + DirectorySeparator + MapFileName);
    1206         try
    1207           Reset(MapFile, 4);
    1208           BlockRead(MapFile, s[1], 2); { file id }
    1209           BlockRead(MapFile, x, 1); { format id }
    1210           BlockRead(MapFile, x, 1); // MaxTurn
    1211           BlockRead(MapFile, lxFile, 1);
    1212           BlockRead(MapFile, lyFile, 1);
    1213           nMapLandTiles := 0;
    1214           nMapStartPositions := 0;
    1215           for y := 0 to lyFile - 1 do
    1216           begin
    1217             BlockRead(MapFile, MapRow, lxFile);
    1218             for x := 0 to lxFile - 1 do
    1219             begin
    1220               if (MapRow[x] and fTerrain) in [fGrass, fPrairie, fTundra, fSwamp,
    1221                 fForest, fHills] then
    1222                 inc(nMapLandTiles);
    1223               if MapRow[x] and (fPrefStartPos or fStartPos) <> 0 then
    1224                 inc(nMapStartPositions);
    1225             end
    1226           end;
    1227           if nMapStartPositions > nPl then
    1228             nMapStartPositions := nPl;
    1229           CloseFile(MapFile);
    1230         except
    1231           CloseFile(MapFile);
    1232         end;
     1274        MiniMap.LoadFromMapFile(GetMapsDir + DirectorySeparator + MapFileName, nMapLandTiles, nMapStartPositions);
    12331275        if Page = pgEditMap then
    12341276          SmartInvalidate(x0Mini - 112, y0Mini + 61, x0Mini + 112, y0Mini + 91);
     
    15411583    Controls[i].Visible := Controls[i].Tag and (256 shl Integer(Page)) <> 0;
    15421584  if Page = pgLoad then
    1543     ReplayBtn.Visible := MiniMode <> mmMultiPlayer;
     1585    ReplayBtn.Visible := MiniMap.Mode <> mmMultiPlayer;
    15441586  List.Invalidate;
    15451587  SmartInvalidate(0, 0, ClientWidth, ClientHeight, invalidateTab0);
     
    17461788  PaintInfo;
    17471789  if Page = pgLoad then
    1748     ReplayBtn.Visible := MiniMode <> mmMultiPlayer;
     1790    ReplayBtn.Visible := MiniMap.Mode <> mmMultiPlayer;
    17491791end;
    17501792
     
    18581900          PaintInfo;
    18591901          if Page = pgLoad then
    1860             ReplayBtn.Visible := MiniMode <> mmMultiPlayer;
     1902            ReplayBtn.Visible := MiniMap.Mode <> mmMultiPlayer;
    18611903        end;
    18621904      end;
     
    20302072end;
    20312073
     2074
    20322075end.
Note: See TracChangeset for help on using the changeset viewer.