Changeset 268 for trunk/UClientGUI.pas


Ignore:
Timestamp:
Jan 20, 2019, 9:32:16 PM (6 years ago)
Author:
chronos
Message:
  • Added: New menu action show/hide map grid lines.
  • Modified: Draw cell polygons without a gap so it can be drawn as solid surface without grid lines.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UClientGUI.pas

    r267 r268  
    4848  public
    4949    View: TView;
     50    ShowCellGrid: Boolean;
    5051    procedure DrawArrow(Canvas: TCanvas; Pos: TPoint; Angle: Double;
    5152      Text: string; View: TView);
     
    5859    procedure DrawCellLinks(Canvas: TCanvas; View: TView);
    5960    procedure DrawNeighborLinks(Canvas: TCanvas; View: TView);
     61    procedure DrawCities(Canvas: TCanvas; View: TView);
     62    procedure DrawSelection(Canvas: TCanvas; View: TView);
    6063    procedure Paint(Canvas: TCanvas; View: TView);
    6164    constructor Create; override;
     
    107110  end;
    108111  with Canvas do begin
    109     if Assigned(View.FocusedCell) and (View.FocusedCell = Cell) then begin
    110       Pen.Color := clYellow;
    111       Pen.Style := psSolid;
    112       Pen.Width := 1;
    113     end else
    114     if Cell.MapCell.Terrain = ttCity then begin
    115       // Cannot set clear border as it will display shifted on gtk2
    116       //Pen.Style := psClear;
     112    // Cannot set clear border as it will display shifted on gtk2
     113    //Pen.Style := psClear;
     114    Pen.Style := psSolid;
     115    if ShowCellGrid then begin
    117116      Pen.Color := clBlack;
    118       Pen.Style := psSolid;
    119       Pen.Width := 3;
     117      Pen.Width := Round(2 * View.Zoom);
    120118    end else begin
    121       // Cannot set clear border as it will display shifted on gtk2
    122       //Pen.Style := psClear;
    123119      Pen.Color := Brush.Color;
    124       Pen.Style := psSolid;
    125120      Pen.Width := 0;
    126121    end;
     122
    127123    // Transform view
    128124    SetLength(Points, Length(Cell.MapCell.Polygon.Points));
     
    130126      Points[I] := PointToStdPoint(View.CellToCanvasPos(Cell.MapCell.Polygon.Points[I]));
    131127    Brush.Style := bsSolid;
    132     //Polygon(Points, False, 0, Length(Points));
    133128    TCanvasEx.PolygonEx(Canvas, Points, False);
    134     //MoveTo(Points[0].X, Points[0].Y);
    135     //LineTo(Points[1].X, Points[1].Y);
    136129
    137130    // Show cell text
     
    237230        not ControlPlayer.PlayerMap.Cells.SearchCell(Move.CellTo.MapCell).InVisibleRange then
    238231        Continue;
    239       if Move.CountRepeat > 0 then Pen.Width := 2
    240         else Pen.Width := 1;
     232      if Move.CountRepeat > 0 then Pen.Width := Round(2 * View.Zoom)
     233        else Pen.Width := Round(1 * View.Zoom);
    241234      Angle := ArcTan2(PosTo.Y - PosFrom.Y, PosTo.X - PosFrom.X);
    242235      if (Angle > +Pi) or (Angle < -Pi) then
     
    312305  MapCell: TCell;
    313306  CellText: string;
     307  Points: array of Classes.TPoint;
     308  I: Integer;
    314309begin
    315310  with Canvas, View do begin
     
    404399end;
    405400
     401procedure TClientGUI.DrawCities(Canvas: TCanvas; View: TView);
     402var
     403  Cell: TPlayerCell;
     404  MapCell: TCell;
     405  CellText: string;
     406  Points: array of Classes.TPoint;
     407  I: Integer;
     408begin
     409  with Canvas, View do begin
     410    if Assigned(ControlPlayer) then begin
     411      for Cell in ControlPlayer.PlayerMap.Cells do begin
     412        if (Cell.MapCell.Terrain <> ttVoid) and View.IsCellVisible(Cell.MapCell) then begin
     413          if Cell.MapCell.Terrain = ttCity then begin
     414            // Cannot set clear border as it will display shifted on gtk2
     415            //Pen.Style := psClear;
     416            Pen.Color := clBlack;
     417            Pen.Style := psSolid;
     418            Pen.Width := Round(6 * View.Zoom);
     419
     420            // Transform view
     421            SetLength(Points, Length(Cell.MapCell.Polygon.Points) + 1);
     422            for I := 0 to Length(Cell.MapCell.Polygon.Points) - 1 do
     423              Points[I] := PointToStdPoint(View.CellToCanvasPos(Cell.MapCell.Polygon.Points[I]));
     424            Points[Length(Points) - 1] := Points[0];
     425            TCanvasEx.PolyLineEx(Canvas, Points);
     426          end;
     427        end;
     428      end;
     429    end else begin
     430      for MapCell in TGame(Game).Map.Cells do begin
     431        if (MapCell.Terrain <> ttVoid) and View.IsCellVisible(MapCell) then begin
     432          if View.IsCellVisible(MapCell) and (MapCell.Terrain <> ttVoid) then begin
     433            if MapCell.Terrain = ttCity then begin
     434              // Cannot set clear border as it will display shifted on gtk2
     435              //Pen.Style := psClear;
     436              Pen.Color := clBlack;
     437              Pen.Style := psSolid;
     438              Pen.Width := Round(6 * View.Zoom);
     439
     440              // Transform view
     441              SetLength(Points, Length(MapCell.Polygon.Points) + 1);
     442              for I := 0 to Length(MapCell.Polygon.Points) - 1 do
     443                Points[I] := PointToStdPoint(View.CellToCanvasPos(MapCell.Polygon.Points[I]));
     444              Points[Length(Points) - 1] := Points[0];
     445              TCanvasEx.PolyLineEx(Canvas, Points);
     446            end;
     447          end;
     448        end;
     449      end;
     450    end;
     451  end;
     452end;
     453
     454procedure TClientGUI.DrawSelection(Canvas: TCanvas; View: TView);
     455var
     456  Cell: TPlayerCell;
     457  MapCell: TCell;
     458  CellText: string;
     459  Points: array of Classes.TPoint;
     460  I: Integer;
     461begin
     462  with Canvas, View do begin
     463    if Assigned(ControlPlayer) then begin
     464      if Assigned(View.FocusedCell) then begin
     465        Pen.Color := clYellow;
     466        Pen.Style := psSolid;
     467        Pen.Width := Round(2 * View.Zoom);
     468
     469        // Transform view
     470        SetLength(Points, Length(View.FocusedCell.MapCell.Polygon.Points) + 1);
     471        for I := 0 to Length(View.FocusedCell.MapCell.Polygon.Points) - 1 do
     472          Points[I] := PointToStdPoint(View.CellToCanvasPos(View.FocusedCell.MapCell.Polygon.Points[I]));
     473        Points[Length(Points) - 1] := Points[0];
     474        TCanvasEx.PolyLineEx(Canvas, Points);
     475      end;
     476    end;
     477  end;
     478end;
     479
    406480{ TView }
    407481
Note: See TracChangeset for help on using the changeset viewer.