|
19 | 19 |
|
20 | 20 | using System; |
21 | 21 | using System.Collections.Generic; |
| 22 | +using System.Linq; |
22 | 23 | using Microsoft.Xna.Framework; |
23 | 24 | using Microsoft.Xna.Framework.Graphics; |
24 | 25 | using Orts.Viewer3D.Popups; |
@@ -92,8 +93,10 @@ public LocatedTexture(Texture2D texture, int x, int y) |
92 | 93 | public PlanningWindow(DriverMachineInterface dmi) : base(dmi, 246, 300) |
93 | 94 | { |
94 | 95 | ButtonScaleUp = new DMIIconButton("NA_03.bmp", "NA_05.bmp", Viewer.Catalog.GetString("Scale Up"), true, ScaleUp, 40, 15, dmi); |
95 | | - ButtonScaleDown = new DMIIconButton("NA_04.bmp", "NA_06.bmp", Viewer.Catalog.GetString("Scale Down"), true, ScaleDown, 40, 15, dmi); |
96 | | - ButtonScaleDown.ExtendedSensitiveArea = new Rectangle(0, 15, 0, 0); |
| 96 | + ButtonScaleDown = new DMIIconButton("NA_04.bmp", "NA_06.bmp", Viewer.Catalog.GetString("Scale Down"), true, ScaleDown, 40, 15, dmi) |
| 97 | + { |
| 98 | + ExtendedSensitiveArea = new Rectangle(0, 15, 0, 0) |
| 99 | + }; |
97 | 100 | ButtonScaleUp.ExtendedSensitiveArea = new Rectangle(0, 0, 0, 15); |
98 | 101 | ButtonScaleUp.ShowButtonBorder = false; |
99 | 102 | ButtonScaleDown.ShowButtonBorder = false; |
@@ -134,7 +137,7 @@ public override void Draw(SpriteBatch spriteBatch, Point position) |
134 | 137 | } |
135 | 138 |
|
136 | 139 | // Distance lines |
137 | | - for (int i = 0; i < 9; i++) |
| 140 | + foreach (int i in Enumerable.Range(0, 9)) |
138 | 141 | { |
139 | 142 | if (i == 0 || i == 5 || i == 8) DrawIntRectangle(spriteBatch, position, 40, LinePositions[i], 200, 2, ColorMediumGrey); |
140 | 143 | else DrawIntRectangle(spriteBatch, position, 40, LinePositions[i], 200, 1, ColorDarkGrey); |
@@ -190,7 +193,7 @@ void CreateGradient(List<GradientProfileElement> GradientProfile) |
190 | 193 | { |
191 | 194 | var gradientText = new List<TextPrimitive>(); |
192 | 195 | var gradientRectangles = new Dictionary<Point, bool>(); |
193 | | - for (int i = 0; i + 1 < GradientProfile.Count; i++) |
| 196 | + foreach (int i in Enumerable.Range(0, GradientProfile.Count - 1)) |
194 | 197 | { |
195 | 198 | GradientProfileElement e = GradientProfile[i]; |
196 | 199 | if (e.DistanceToTrainM > MaxViewingDistanceM) break; |
@@ -231,7 +234,7 @@ void CreatePASP(List<PlanningTarget> SpeedTargets) |
231 | 234 | bool oth2 = false; |
232 | 235 | float widthFactor = 1; |
233 | 236 | float allowedSpeedMpS = prev_pasp.TargetSpeedMpS; |
234 | | - for (int i = 1; i < SpeedTargets.Count; i++) |
| 237 | + foreach (int i in Enumerable.Range(1, SpeedTargets.Count - 1)) |
235 | 238 | { |
236 | 239 | PlanningTarget cur = SpeedTargets[i]; |
237 | 240 | PlanningTarget prev = SpeedTargets[i - 1]; |
@@ -277,10 +280,10 @@ void CreateTargetSpeeds(List<PlanningTarget> speedTargets) |
277 | 280 | var speedTargetText = new List<TextPrimitive>(speedTargets.Count); |
278 | 281 | var speedTargetTextures = new List<LocatedTexture>(speedTargets.Count); |
279 | 282 | int ld = 0; |
280 | | - for (int i = 1; i < speedTargets.Count; i++) |
| 283 | + foreach (int i in Enumerable.Range(1, speedTargets.Count - 1)) |
281 | 284 | { |
282 | 285 | bool overlap = false; |
283 | | - for (int j = 1; j < speedTargets.Count; j++) |
| 286 | + foreach (int j in Enumerable.Range(1, speedTargets.Count - 1)) |
284 | 287 | { |
285 | 288 | if (i != j && CheckTargetOverlap(speedTargets[i], speedTargets[j])) |
286 | 289 | { |
@@ -317,7 +320,7 @@ void CreateTrackConditions(List<PlanningTrackCondition> trackConditions) |
317 | 320 | { |
318 | 321 | var trackConditionTextures = new List<LocatedTexture>(trackConditions.Count); |
319 | 322 | int[] prevObject = { LinePositions[0] + 10, LinePositions[0] + 10, LinePositions[0] + 10 }; |
320 | | - for (int i = 0; i < trackConditions.Count; i++) |
| 323 | + foreach (int i in Enumerable.Range(0, trackConditions.Count)) |
321 | 324 | { |
322 | 325 | PlanningTrackCondition condition = trackConditions[i]; |
323 | 326 | int posy = GetPlanningHeight(condition.DistanceToTrainM) - 35; |
@@ -471,7 +474,7 @@ void SetFont() |
471 | 474 | void SetDistanceText() |
472 | 475 | { |
473 | 476 | var distanceScaleText = new List<TextPrimitive>(DistanceScaleText.Count); |
474 | | - for (int i = 0; i < 9; i++) |
| 477 | + foreach (int i in Enumerable.Range(0, 9)) |
475 | 478 | { |
476 | 479 | if (i == 0 || i > 4) |
477 | 480 | { |
|
0 commit comments