Changeset 258 for trunk/UMap.pas
- Timestamp:
- Sep 23, 2018, 1:43:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMap.pas
r248 r258 467 467 end; 468 468 469 {procedure TMap.Paint(Canvas: TCanvas; View: TView);470 var471 I: Integer;472 Cell: TCell;473 PosFrom, PosTo: TPoint;474 Angle: Double;475 ArrowCenter: TPoint;476 Move: TUnitMove;477 CellLink: TCellLink;478 begin479 with Canvas, View do480 try481 Lock;482 483 // Draw cell links484 Pen.Color := clBlack;485 Pen.Style := psSolid;486 Pen.Width := 3;487 for CellLink in CellLinks do488 with CellLink do begin489 if Length(Points) >= 2 then begin490 MoveTo(PointToStdPoint(View.CellToCanvasPos(Points[0])));491 for I := 1 to Length(Points) - 1 do492 LineTo(PointToStdPoint(View.CellToCanvasPos(Points[I])));493 end;494 end;495 496 // Draw cells497 for Cell in Cells do begin498 if (Cell.Terrain <> ttVoid) and Cell.IsVisible(View) then begin499 if Assigned(SelectedCell) and (SelectedCell.MapCell = Cell) then500 Brush.Color := clGreen501 else if Assigned(SelectedCell) and IsCellsNeighbor(SelectedCell.MapCell, Cell) then502 Brush.Color := clPurple503 else Brush.Color := Cell.GetColor;504 //Pen.Color := clBlack;505 PaintCell(Canvas, Cell.PosPx, IntToStr(Cell.Power), View, Cell);506 end;507 end;508 finally509 Unlock;510 end;511 end;512 }513 514 469 function TMap.GetNewCellId: Integer; 515 470 begin … … 647 602 Result := Cell.PosPx; 648 603 end; 649 650 {procedure TMap.PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView;651 Cell: TCell);652 var653 I: Integer;654 TextPos: TPoint;655 Points: array of Classes.TPoint;656 TextSize: TSize;657 begin658 if Cell.Extra = etObjectiveTarget then begin659 Text := Text + '!';660 end;661 with Canvas do begin662 if Assigned(View.FocusedCell) and (View.FocusedCell.MapCell = Cell) then begin663 Pen.Color := clYellow;664 Pen.Style := psSolid;665 Pen.Width := 1;666 end else667 if Cell.Terrain = ttCity then begin668 // Cannot set clear border as it will display shifted on gtk2669 //Pen.Style := psClear;670 Pen.Color := clBlack;671 Pen.Style := psSolid;672 Pen.Width := 3;673 end else begin674 // Cannot set clear border as it will display shifted on gtk2675 //Pen.Style := psClear;676 Pen.Color := Brush.Color;677 Pen.Style := psSolid;678 Pen.Width := 0;679 end;680 // Transform view681 SetLength(Points, Length(Cell.Polygon.Points));682 for I := 0 to Length(Points) - 1 do683 Points[I] := PointToStdPoint(View.CellToCanvasPos(Cell.Polygon.Points[I]));684 Brush.Style := bsSolid;685 //Polygon(Points, False, 0, Length(Points));686 TCanvasEx.PolygonEx(Canvas, Points, False);687 //MoveTo(Points[0].X, Points[0].Y);688 //LineTo(Points[1].X, Points[1].Y);689 690 // Show cell text691 if (Cell.Power <> 0) or (Cell.Extra = etObjectiveTarget) then begin692 Pen.Style := psSolid;693 Font.Color := clWhite;694 Brush.Style := bsClear;695 Font.Size := Trunc(42 * View.Zoom);696 TextPos := View.CellToCanvasPos(Pos);697 TextSize := TextExtent(Text);698 TCanvasEx.TextOutEx(Canvas, Round(TextPos.X) - TextSize.cx div 2,699 Round(TextPos.Y) - TextSize.cy div 2, Text, False);700 end;701 end;702 end;703 }704 604 705 605 procedure TMap.ComputePlayerStats; … … 1010 910 procedure TCell.ConnectTo(Cell: TCell); 1011 911 begin 912 if Cell = Self then 913 raise Exception.Create('Can''t connect map cell to itself'); 1012 914 // Connect only if already not connected 1013 915 if Neighbors.IndexOf(Cell) < 0 then begin … … 1068 970 var 1069 971 I: Integer; 972 Cell: TCell; 1070 973 begin 1071 974 Player := TGame(Map.Game).Players.FindById(PlayerId); 1072 975 1073 976 Neighbors.Count := Length(NeighborsId); 977 for I := 0 to Length(NeighborsId) - 1 do 978 Neighbors[I] := nil; 1074 979 for I := 0 to Length(NeighborsId) - 1 do begin 1075 Neighbors[I] := Map.Cells.FindById(NeighborsId[I]); 980 Cell := Map.Cells.FindById(NeighborsId[I]); 981 if not Assigned(Cell) then 982 raise Exception.Create('Neighbor cell id not found ' + IntToStr(NeighborsId[I])); 983 if Neighbors.IndexOf(Cell) <> -1 then 984 raise Exception.Create('Duplicate neighbor cell ' + IntToStr(NeighborsId[I]) + ' found for cell ' + IntToStr(Id)); 985 Neighbors[I] := Cell; 1076 986 end; 1077 987 end;
Note:
See TracChangeset
for help on using the changeset viewer.