Changeset 140 for trunk/UEngine.pas
- Timestamp:
- May 17, 2023, 12:18:41 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UEngine.pas
r135 r140 361 361 OldHighestServedDaysCount: Integer; 362 362 RegistryContext: TRegistryContext; 363 CurvedLines: Boolean; 363 364 procedure InitMenus; 364 365 procedure InitCities; … … 415 416 TrackClickDistance = 15; 416 417 EndStationLength = 50; 418 EndStationWidth = 20; 417 419 ShowDistances = False; 418 420 TimePerSecondNormal = 60 * OneMinute; … … 3086 3088 var 3087 3089 MetroLine: TMetroLine; 3088 S: Integer; 3090 I: Integer; 3091 Points: array of TPoint; 3092 Vector: TVector; 3093 HalfDownPoint: TPoint; 3094 HalfUpPoint: TPoint; 3095 Angle: Double; 3096 EndPoint: TPoint; 3097 const 3098 CurveRadius: Double = 0; 3089 3099 begin 3090 3100 for MetroLine in Lines do … … 3093 3103 Canvas.Pen.Style := psSolid; 3094 3104 Canvas.Pen.Width := GetMetroLineThickness; 3095 if Track.Points.Count > 0 then Canvas.MoveTo(Track.Points[0].Position); 3096 for S := 1 to Track.Points.Count - 1 do begin 3097 Canvas.LineTo(Track.Points[S].Position); 3098 { if (S = TrackPoints.Count - 1) then begin 3105 3106 if CurvedLines then begin 3107 Points := nil; 3108 if Track.Points.Count >= 2 then begin 3109 SetLength(Points, (Track.Points.Count - 1) * 3 - 2); 3110 for I := 1 to Track.Points.Count - 2 do begin 3111 if I = 1 then begin 3112 HalfDownPoint := Track.Points[I - 1].Position; 3113 end else 3114 if I > 0 then begin 3115 HalfDownPoint := Point((Track.Points[I].Position.X + Track.Points[I - 1].Position.X) div 2, 3116 (Track.Points[I].Position.Y + Track.Points[I - 1].Position.Y) div 2) 3117 end else begin 3118 HalfDownPoint := Track.Points[0].Position; 3119 end; 3120 3121 if I = Track.Points.Count - 2 then begin 3122 HalfUpPoint := Track.Points[I + 1].Position 3123 end else 3124 if I < Track.Points.Count - 1 then begin 3125 HalfUpPoint := Point((Track.Points[I].Position.X + Track.Points[I + 1].Position.X) div 2, 3126 (Track.Points[I].Position.Y + Track.Points[I + 1].Position.Y) div 2) 3127 end else begin 3128 HalfUpPoint := Track.Points[Track.Points.Count - 1].Position; 3129 end; 3130 3131 Points[(I - 1) * 3] := HalfDownPoint; 3132 Points[I * 3] := HalfUpPoint; 3133 3134 if (I > 0) and (I < Track.Points.Count - 1) then begin 3135 Vector := TVector.Create(HalfDownPoint, Track.Points[I].Position); 3136 Vector.SetLength(Vector.GetLength - CurveRadius); 3137 Points[(I - 1) * 3 + 1] := AddPoint(Vector.Position, Vector.Direction); 3138 end; 3139 if I < Track.Points.Count - 1 then begin 3140 Vector := TVector.Create(HalfUpPoint, Track.Points[I].Position); 3141 Vector.SetLength(Vector.GetLength - CurveRadius); 3142 Points[(I - 1) * 3 + 2] := AddPoint(Vector.Position, Vector.Direction); 3143 end; 3144 end; 3145 if Length(Points) > 1 then 3146 Canvas.PolyBezier(@Points[0], Length(Points)); 3147 end; 3148 end else begin 3149 if Track.Points.Count > 0 then Canvas.MoveTo(Track.Points[0].Position); 3150 for I := 1 to Track.Points.Count - 1 do begin 3151 Canvas.LineTo(Track.Points[I].Position); 3152 end; 3153 end; 3154 3155 if VisualStyle = vsLondon then begin 3156 // Starting orthogonal line 3157 if (Track.Points.Count > 1) then begin 3099 3158 Canvas.Pen.EndCap := pecSquare; 3100 Angle := arctan2D(((TrackPoints[S].Position.Y - TrackPoints[S - 1].Position.Y), 3101 (TrackPoints[S].Position.X - TrackPoints[S - 1].Position.X)); 3102 EndPoint := Point(Round(TrackPoints[S].Position.X + EndStationLength * Cos(Angle)), 3103 Round(TrackPoints[S].Position.Y + EndStationLength * Sin(Angle))); 3159 Angle := Arctan2((Track.Points[1].Position.Y - Track.Points[0].Position.Y), 3160 (Track.Points[1].Position.X - Track.Points[0].Position.X)); 3161 Canvas.MoveTo(Track.Points[1].Position); 3162 EndPoint := Point(Round(Track.Points[1].Position.X - EndStationLength * Cos(Angle)), 3163 Round(Track.Points[1].Position.Y - EndStationLength * Sin(Angle))); 3104 3164 Canvas.LineTo(EndPoint); 3105 Canvas.MoveTo(Point(Round(EndPoint.X + Cos(Angle + Pi / 2) * EndStationLength / 3),3106 Round(EndPoint.Y + Sin(Angle + Pi / 2) * EndStationLength / 3)));3107 Canvas.LineTo(Point(Round(EndPoint.X + Cos(Angle - Pi / 2) * EndStationLength / 3),3108 Round(EndPoint.Y + Sin(Angle - Pi / 2) * EndStationLength / 3)));3165 Canvas.MoveTo(Point(Round(EndPoint.X - Cos(Angle + Pi / 2) * EndStationWidth / 2), 3166 Round(EndPoint.Y - Sin(Angle + Pi / 2) * EndStationWidth / 2))); 3167 Canvas.LineTo(Point(Round(EndPoint.X - Cos(Angle - Pi / 2) * EndStationWidth / 2), 3168 Round(EndPoint.Y - Sin(Angle - Pi / 2) * EndStationWidth / 2))); 3109 3169 Canvas.Pen.EndCap := pecRound; 3110 end;} 3111 end; 3112 (* Canvas.Pen.Color := Color; 3113 Canvas.Pen.Style := psSolid; 3114 Canvas.Pen.Width := GetMetroLineThickness div 2; 3115 if Track.Points.Count > 0 then Canvas.MoveTo(Track.Points[0].PositionDesigned); 3116 for S := 1 to Track.Points.Count - 1 do begin 3117 Canvas.LineTo(Track.Points[S].PositionDesigned); 3118 { if (S = TrackPoints.Count - 1) then begin 3170 end; 3171 3172 // Ending orthogonal line 3173 if (Track.Points.Count > 1) then begin 3119 3174 Canvas.Pen.EndCap := pecSquare; 3120 Angle := arctan2((TrackPoints[S].Position.Y - TrackPoints[S - 1].Position.Y), 3121 (TrackPoints[S].Position.X - TrackPoints[S - 1].Position.X)); 3122 EndPoint := Point(Round(TrackPoints[S].Position.X + EndStationLength * Cos(Angle)), 3123 Round(TrackPoints[S].Position.Y + EndStationLength * Sin(Angle))); 3175 Angle := Arctan2((Track.Points[Track.Points.Count - 1].Position.Y - Track.Points[Track.Points.Count - 2].Position.Y), 3176 (Track.Points[Track.Points.Count - 1].Position.X - Track.Points[Track.Points.Count - 2].Position.X)); 3177 Canvas.MoveTo(Track.Points[Track.Points.Count - 2].Position); 3178 EndPoint := Point(Round(Track.Points[Track.Points.Count - 2].Position.X + EndStationLength * Cos(Angle)), 3179 Round(Track.Points[Track.Points.Count - 2].Position.Y + EndStationLength * Sin(Angle))); 3124 3180 Canvas.LineTo(EndPoint); 3125 Canvas.MoveTo(Point(Round(EndPoint.X + Cos(Angle + Pi / 2) * EndStation Length / 3),3126 Round(EndPoint.Y + Sin(Angle + Pi / 2) * EndStationLength / 3)));3127 Canvas.LineTo(Point(Round(EndPoint.X + Cos(Angle - Pi / 2) * EndStation Length / 3),3128 Round(EndPoint.Y + Sin(Angle - Pi / 2) * EndStation Length / 3)));3181 Canvas.MoveTo(Point(Round(EndPoint.X + Cos(Angle + Pi / 2) * EndStationWidth / 2), 3182 Round(EndPoint.Y + Sin(Angle + Pi / 2) * EndStationWidth / 2))); 3183 Canvas.LineTo(Point(Round(EndPoint.X + Cos(Angle - Pi / 2) * EndStationWidth / 2), 3184 Round(EndPoint.Y + Sin(Angle - Pi / 2) * EndStationWidth / 2))); 3129 3185 Canvas.Pen.EndCap := pecRound; 3130 end;} 3131 end; 3132 { 3133 if (TrackPoints.Count > 1) then begin 3134 Canvas.Pen.EndCap := pecSquare; 3135 Angle := arctan2((TrackPoints[1].Position.Y - TrackPoints[0].Position.Y), 3136 (TrackPoints[1].Position.X - TrackPoints[0].Position.X)); 3137 Canvas.MoveTo(TrackPoints[0].Position); 3138 EndPoint := Point(Round(TrackPoints[0].Position.X - EndStationLength * Cos(Angle)), 3139 Round(TrackPoints[0].Position.Y - EndStationLength * Sin(Angle))); 3140 Canvas.LineTo(EndPoint); 3141 Canvas.MoveTo(Point(Round(EndPoint.X - Cos(Angle + Pi / 2) * EndStationLength / 3), 3142 Round(EndPoint.Y - Sin(Angle + Pi / 2) * EndStationLength / 3))); 3143 Canvas.LineTo(Point(Round(EndPoint.X - Cos(Angle - Pi / 2) * EndStationLength / 3), 3144 Round(EndPoint.Y - Sin(Angle - Pi / 2) * EndStationLength / 3))); 3145 Canvas.Pen.EndCap := pecRound; 3146 end; } 3147 *) 3186 end; 3187 end; 3148 3188 end; 3149 3189 … … 4233 4273 begin 4234 4274 inherited; 4275 CurvedLines := True; 4235 4276 MovableTracks := True; 4236 4277 Colors := TColors.Create;
Note:
See TracChangeset
for help on using the changeset viewer.