Changeset 164 for trunk/UGame.pas
- Timestamp:
- Nov 21, 2017, 6:39:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r162 r164 174 174 private 175 175 FSize: TPoint; 176 FUpdateCount: Integer; 176 177 function GetSize: TPoint; virtual; 177 178 procedure PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView; … … 213 214 procedure CreateLinks; 214 215 procedure Clear; 216 procedure BeginUpdate; 217 procedure EndUpdate; 215 218 constructor Create; virtual; 216 219 destructor Destroy; override; … … 982 985 CellText: string; 983 986 CellLink: TCellLink; 987 NeighCell: TCell; 984 988 begin 985 989 with Canvas, View do … … 1028 1032 Player.Game.Map.PaintCell(Canvas, Cell.MapCell.PosPx, '', View, Cell.MapCell); 1029 1033 end; 1034 1035 {// Draw links to neighbors 1036 for NeighCell in Cell.MapCell.Neighbors do begin 1037 Pen.Color := clYellow; 1038 MoveTo(View.CellToCanvasPos(Cell.MapCell.PosPx)); 1039 LineTo(View.CellToCanvasPos(NeighCell.PosPx)); 1040 end; 1041 } 1030 1042 end; 1031 1043 … … 1340 1352 if (FSize.X <> AValue.X) or (FSize.Y <> AValue.Y) then begin 1341 1353 FSize := AValue; 1342 Generate;1354 if FUpdateCount = 0 then Generate; 1343 1355 end; 1344 1356 end; … … 1434 1446 // I: Integer; 1435 1447 begin 1448 FUpdateCount := Source.FUpdateCount; 1436 1449 MaxPower := Source.MaxPower; 1437 1450 Game := Source.Game; … … 1713 1726 Cells.Clear; 1714 1727 FNewCellId := 1; 1728 end; 1729 1730 procedure TMap.BeginUpdate; 1731 begin 1732 Inc(FUpdateCount); 1733 end; 1734 1735 procedure TMap.EndUpdate; 1736 begin 1737 if FUpdateCount > 0 then Dec(FUpdateCount); 1738 if FUpdateCount = 0 then Generate; 1715 1739 end; 1716 1740 … … 3217 3241 begin 3218 3242 with Config do begin 3219 MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(mtHexagon))); 3243 try 3244 Map.BeginUpdate; 3245 MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(mtHexagon))); 3246 Map.Size := Point(GetValue(DOMString(Path + '/MapSizeX'), 10), 3247 GetValue(DOMString(Path + '/MapSizeY'), 10)); 3248 finally 3249 Map.EndUpdate; 3250 end; 3220 3251 MapImageFileName := string(GetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName))); 3221 3252 SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), False); … … 3223 3254 VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), True); 3224 3255 VoidPercentage := GetValue(DOMString(Path + '/VoidPercentage'), 20); 3225 Map.Size := Point(GetValue(DOMString(Path + '/MapSizeX'), 10),3226 GetValue(DOMString(Path + '/MapSizeY'), 10));3227 3256 Value := GetValue(DOMString(Path + '/MapShape'), 0); 3228 3257 if (Value >= Integer(Low(TMapShape))) and (Value <= Integer(High(TMapShape))) then
Note:
See TracChangeset
for help on using the changeset viewer.