Changeset 98 for trunk/UEngine.pas


Ignore:
Timestamp:
Sep 28, 2022, 1:45:58 PM (20 months ago)
Author:
chronos
Message:
  • Modified: Do not change view zoom if new station is already visible.
  • Fixed: Line icon normalized.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UEngine.pas

    r97 r98  
    10321032{ TEngine }
    10331033
     1034// Need to see all stations on screen
    10341035procedure TEngine.ResizeView;
    10351036var
    10361037  NewPoint: TPoint;
    1037 begin
    1038   // Need to see all stations on screen
    1039   View.SourceRect := RectEnlarge(Stations.GetRect, 100);
    1040 
     1038  Intersected: TRect;
     1039  NewView: TView;
     1040begin
     1041  NewView := TView.Create;
     1042  NewView.Assign(View);
     1043
     1044  NewView.SourceRect := RectEnlarge(Stations.GetRect, 100);
    10411045  NewPoint := Point(
    1042     Trunc((View.SourceRect.Left + (View.SourceRect.Right - View.SourceRect.Left) / 2) -
    1043     (View.DestRect.Left + (View.DestRect.Right - View.DestRect.Left) / 2 / View.Zoom)),
    1044     Trunc((View.SourceRect.Top + (View.SourceRect.Bottom - View.SourceRect.Top) / 2) -
    1045     (View.DestRect.Top + (View.DestRect.Bottom - View.DestRect.Top) / 2 / View.Zoom)));
    1046   View.SourceRect := Bounds(NewPoint.X, NewPoint.Y, Trunc((View.DestRect.Right - View.DestRect.Left) / View.Zoom),
    1047     Trunc((View.DestRect.Bottom - View.DestRect.Top) / View.Zoom));
     1046    Trunc((NewView.SourceRect.Left + (NewView.SourceRect.Right - NewView.SourceRect.Left) / 2) -
     1047    (NewView.DestRect.Left + (NewView.DestRect.Right - NewView.DestRect.Left) / 2 / NewView.Zoom)),
     1048    Trunc((NewView.SourceRect.Top + (NewView.SourceRect.Bottom - NewView.SourceRect.Top) / 2) -
     1049    (NewView.DestRect.Top + (NewView.DestRect.Bottom - NewView.DestRect.Top) / 2 / NewView.Zoom)));
     1050  NewView.SourceRect := Bounds(NewPoint.X, NewPoint.Y, Trunc((NewView.DestRect.Right - NewView.DestRect.Left) / NewView.Zoom),
     1051    Trunc((NewView.DestRect.Bottom - NewView.DestRect.Top) / NewView.Zoom));
     1052
     1053  Intersected := NewView.SourceRect;
     1054  Intersected.Union(View.SourceRect);
     1055  if Intersected = View.SourceRect then Exit;
     1056
     1057  View.Assign(NewView);
     1058
     1059  NewView.Free;
    10481060end;
    10491061
     
    25602572    end;
    25612573
    2562     // Add new stations
     2574    // Add new station
    25632575    if (Time - LastNewStationTime) > NewStationPeriod then begin
    25642576      LastNewStationTime := Time;
     
    28602872  KeyF4 = 115;
    28612873  KeyF5 = 116;
     2874  KeyF6 = 117;
    28622875begin
    28632876  if Key = KeyEsc then begin
     
    28932906      Redraw;
    28942907    end;
     2908  end else
     2909  if Key = KeyF6 then begin
     2910    if State = gsRunning then begin
     2911      Stations.AddNew;
     2912      ResizeView;
     2913      Redraw;
     2914    end;
    28952915  end;
    28962916  {$ENDIF}
     
    29102930  Lines.Clear;
    29112931  Stations.Clear;
     2932  View.SourceRect := Bounds(0, 0, 0, 0);
    29122933end;
    29132934
Note: See TracChangeset for help on using the changeset viewer.