Skip to content

Commit 44c05de

Browse files
committed
Automatic merge of T1.5.1-553-g4b9199858 and 14 pull requests
- Pull request #757 at 98dd1a7: Unify RailDriver code implementations - Pull request #831 at 61bbf43: poor mans switch panel on tablet - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #841 at 410a585: https://blueprints.launchpad.net/or/+spec/animating-trainset-windows - Pull request #853 at d05f581: Notify out of focus - Pull request #855 at b39e5d8: Adds new route from TrainSimulations - Pull request #857 at 9afc8c3: Adding Air Flow Meters - Pull request #859 at fff2560: Steam adhesion bug#1 - Pull request #860 at d2b8a52: Changes in the Car Operations Menu for the lines with brake information - Pull request #862 at 489f261: Fix engine leak problem - Pull request #863 at a34b857: Alternate preset 3D cabviewpoints - Pull request #864 at 18c5481: Fixes for Undesired Emergency Applications - Pull request #865 at 776d6df: Dispatcher window improvements - Pull request #866 at a6cbc52: Fix Articulation For 0-Axle Train Cars
16 parents e8505cb + 4b91998 + 98dd1a7 + 61bbf43 + d00beb9 + 410a585 + d05f581 + b39e5d8 + 9afc8c3 + fff2560 + d2b8a52 + 489f261 + a34b857 + 18c5481 + 776d6df + a6cbc52 commit 44c05de

File tree

7 files changed

+39
-45
lines changed

7 files changed

+39
-45
lines changed

Source/RunActivity/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static class Program
4242
public static Simulator Simulator;
4343
public static Viewer Viewer;
4444
public static DispatchViewer DebugViewer;
45-
public static DispatchViewerBeta DebugViewerBeta;
45+
public static MapViewer DebugViewerBeta;
4646
public static SoundDebugForm SoundDebugForm;
4747
public static ORTraceListener ORTraceListener;
4848
public static string logFileName = ""; // contains path to file

Source/RunActivity/Viewer3D/Debugging/MapDataProvider.cs renamed to Source/RunActivity/Viewer3D/Map/MapDataProvider.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
using Orts.MultiPlayer;
2424
using Orts.Simulation.Physics;
2525
using Orts.Simulation.Signalling;
26+
using Orts.Viewer3D.Debugging;
2627

27-
namespace Orts.Viewer3D.Debugging
28+
namespace Orts.Viewer3D.Map
2829
{
2930
public class MapDataProvider
3031
{
31-
public DispatchViewerBeta F { get; set; } // Shortest possible abbreviation so code is easier to read
32+
public MapViewer F { get; set; } // Shortest possible abbreviation so code is easier to read
3233

33-
public MapDataProvider(DispatchViewerBeta form)
34+
public MapDataProvider(MapViewer form)
3435
{
3536
F = form;
3637
}
@@ -174,7 +175,7 @@ private PointF GetMidPoint(PointF location1, PointF location2)
174175

175176
private PointF GetRightHandPoint(PointF location1, PointF location2)
176177
{
177-
return (location1.X > location2.X) ? location1 : location2;
178+
return location1.X > location2.X ? location1 : location2;
178179
}
179180

180181
public void ShowSimulationTime()
@@ -203,9 +204,9 @@ public void FixForBadData(float width, ref PointF scaledA, ref PointF scaledB, P
203204
public bool IsActiveTrain(Simulation.AIs.AITrain t)
204205
{
205206
return t != null
206-
&& ((t.MovementState != Simulation.AIs.AITrain.AI_MOVEMENT_STATE.AI_STATIC
207+
&& (t.MovementState != Simulation.AIs.AITrain.AI_MOVEMENT_STATE.AI_STATIC
207208
&& !(t.TrainType == Train.TRAINTYPE.AI_INCORPORATED && !t.IncorporatingTrain.IsPathless)
208-
)
209+
209210
|| t.TrainType == Train.TRAINTYPE.PLAYER);
210211
}
211212

@@ -254,14 +255,14 @@ public float GetUnusedYLocation(float startX, float wantY, string name)
254255
if (endX < 0)
255256
return noFreeSlotFound;
256257

257-
int positionY = desiredPositionY;
258+
var positionY = desiredPositionY;
258259
while (positionY >= 0 && positionY < F.alignedTextY.Length)
259260
{
260261
//if the line contains no text yet, put it there
261262
if (F.alignedTextNum[positionY] == 0)
262263
return SaveLabelLocation(startX, endX, positionY);
263264

264-
bool conflict = false;
265+
var conflict = false;
265266

266267
//check if it intersects with any labels already in this row
267268
for (var col = 0; col < F.alignedTextNum[positionY]; col++)

Source/RunActivity/Viewer3D/Debugging/DebugViewerBetaForm.Designer.cs renamed to Source/RunActivity/Viewer3D/Map/MapForm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/RunActivity/Viewer3D/Debugging/DebugViewerBetaForm.cs renamed to Source/RunActivity/Viewer3D/Map/MapForm.cs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
using Orts.Simulation.RollingStocks;
1414
using Orts.Simulation.Signalling;
1515
using Orts.Simulation.Timetables;
16+
using Orts.Viewer3D.Map;
1617
using Orts.Viewer3D.Popups;
1718
using ORTS.Common;
1819
using Color = System.Drawing.Color;
1920

2021
namespace Orts.Viewer3D.Debugging
2122
{
22-
public partial class DispatchViewerBeta : Form
23+
public partial class MapViewer : Form
2324
{
2425
#region Variables
2526
/// <summary>
@@ -45,8 +46,6 @@ public partial class DispatchViewerBeta : Form
4546
public float xScale = 1; // pixels / metre
4647
public float yScale = 1; // pixels / metre
4748

48-
readonly string name = "";
49-
5049
public List<SwitchWidget> switchItemsDrawn;
5150
public List<SignalWidget> signalItemsDrawn;
5251
public SwitchWidget switchPickedItem;
@@ -104,7 +103,7 @@ public partial class DispatchViewerBeta : Form
104103
private bool MapCustomizationVisible = false;
105104
#endregion
106105

107-
public DispatchViewerBeta(Simulator simulator, Viewer viewer)
106+
public MapViewer(Simulator simulator, Viewer viewer)
108107
{
109108
InitializeComponent();
110109

@@ -496,7 +495,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
496495

497496
selectedTrainList.Clear();
498497

499-
if (simulator.TimetableMode)
498+
/*if (simulator.TimetableMode)
500499
{
501500
// Add the player's train...
502501
if (simulator.PlayerLocomotive.Train is AITrain)
@@ -507,10 +506,10 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
507506
selectedTrainList.Add(train);
508507
}
509508
else
510-
{
511-
foreach (var train in simulator.Trains)
512-
selectedTrainList.Add(train);
513-
}
509+
{*/
510+
foreach (var train in simulator.Trains)
511+
selectedTrainList.Add(train);
512+
/*}*/
514513

515514
foreach (var train in selectedTrainList)
516515
{
@@ -532,7 +531,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
532531

533532
// Skip trains with no loco
534533
if (locoCar == null)
535-
continue;
534+
locoCar = train.Cars[0];
536535
}
537536
else
538537
continue;
@@ -543,8 +542,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
543542
float y = mapCanvas.Height - (((loc.TileZ * 2048) + loc.Location.Z - subY) * yScale);
544543

545544
// If train out of view then skip it.
546-
if (x < -margin2
547-
|| y < -margin2)
545+
if (x < -margin2 || y < -margin2)
548546
continue;
549547

550548
DrawTrainPath(train, subX, subY, pathPen, g, scaledA, scaledB, pDist, mDist);
@@ -573,7 +571,7 @@ private void DrawTrains(Graphics g, PointF scaledA, PointF scaledB)
573571
Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale)
574572
};
575573
if (showTrainLabelsCheckbox.Checked)
576-
DrawTrainLabels(g, train, trainName, locoCar, scaledTrain);
574+
DrawTrainLabels(g, train, trainName, scaledTrain);
577575
}
578576
}
579577

@@ -602,7 +600,7 @@ private void DrawCar(Graphics g, Train train, TrainCar car, TrainCar locoCar, fl
602600
if (x < -margin || y < -margin)
603601
return;
604602

605-
t.Move(-car.CarLengthM + (1 / xScale)); // Move from front of car to rear less 1 pixel to create a visible gap
603+
t.Move(-car.CarLengthM + (2 / xScale)); // Move from front of car to rear less 1 pixel to create a visible gap // TODO: investigate `(1 / xScale)` ==> `(2 / xScale)` car gap consequences
606604
scaledTrain.X = x; scaledTrain.Y = y;
607605
}
608606
else // Draw the train as 2 boxes of fixed size
@@ -659,32 +657,27 @@ private void SetTrainColor(Train t, TrainCar locoCar, TrainCar car)
659657
// inactive loco: RGB 153,128,0
660658
// active car: RGB 0,204,0
661659
// inactive car: RGB 0,153,0
662-
if (MapDataProvider.IsActiveTrain(t as AITrain))
663-
{
664-
trainPen.Color = car is MSTSLocomotive
660+
trainPen.Color = MapDataProvider.IsActiveTrain(t as AITrain)
661+
? car is MSTSLocomotive
665662
? (car == locoCar) ? Color.FromArgb(204, 170, 0) : Color.FromArgb(153, 128, 0)
666-
: Color.FromArgb(0, 204, 0);
667-
}
668-
else
669-
{
670-
trainPen.Color = car is MSTSLocomotive ? Color.FromArgb(153, 128, 0) : Color.FromArgb(0, 153, 0);
671-
}
663+
: Color.FromArgb(0, 204, 0)
664+
: car is MSTSLocomotive ? Color.FromArgb(153, 128, 0) : Color.FromArgb(0, 153, 0);
672665

673666
if (t.TrainType == Train.TRAINTYPE.STATIC || (t.TrainType == Train.TRAINTYPE.AI && t.GetAIMovementState() == AITrain.AI_MOVEMENT_STATE.AI_STATIC))
674667
{
675-
trainPen.Color = Color.FromArgb(83, 237, 214);
668+
trainPen.Color = car is MSTSLocomotive ? Color.FromArgb(19, 185, 160) : Color.FromArgb(83, 237, 214);
676669
}
677670

678671
// Draw player train with loco in red
679672
if (t.TrainType == Train.TRAINTYPE.PLAYER && car == locoCar)
680673
trainPen.Color = Color.Red;
681674
}
682675

683-
private void DrawTrainLabels(Graphics g, Train t, string trainName, TrainCar firstCar, PointF scaledTrain)
676+
private void DrawTrainLabels(Graphics g, Train t, string trainName, PointF scaledTrain)
684677
{
685-
WorldPosition worldPos = firstCar.WorldPosition;
678+
/*WorldPosition worldPos = firstCar.WorldPosition;
686679
scaledTrain.X = ((worldPos.TileX * 2048) - subX + worldPos.Location.X) * xScale;
687-
scaledTrain.Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale);
680+
scaledTrain.Y = -25 + mapCanvas.Height - (((worldPos.TileZ * 2048) - subY + worldPos.Location.Z) * yScale);*/
688681
if (showActiveTrainsRadio.Checked)
689682
{
690683
if (t is AITrain && MapDataProvider.IsActiveTrain(t as AITrain))
File renamed without changes.

Source/RunActivity/Viewer3D/Debugging/MapThemeProvider.cs renamed to Source/RunActivity/Viewer3D/Map/MapThemeProvider.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
using System.Linq;
44
using System.Windows.Forms;
55

6-
namespace Orts.Viewer3D.Debugging
6+
namespace Orts.Viewer3D.Map
77
{
88
public class MapThemeProvider
99
{
1010
public void InitializeThemes()
1111
{
12-
ThemeStyle LightTheme = new ThemeStyle
12+
var LightTheme = new ThemeStyle
1313
{
1414
BackColor = Color.Transparent,
1515
ForeColor = SystemColors.ControlText,
@@ -19,7 +19,7 @@ public void InitializeThemes()
1919
TrackColor = Color.FromArgb(46, 64, 83),
2020
};
2121

22-
ThemeStyle DarkTheme = new ThemeStyle
22+
var DarkTheme = new ThemeStyle
2323
{
2424
BackColor = Color.FromArgb(44, 62, 80),
2525
ForeColor = Color.FromArgb(247, 249, 249),
@@ -30,7 +30,7 @@ public void InitializeThemes()
3030
};
3131

3232
// Reference for "solarized" themes: https://github.com/altercation/solarized?tab=readme-ov-file#the-values
33-
ThemeStyle LightSolarizedTheme = new ThemeStyle
33+
var LightSolarizedTheme = new ThemeStyle
3434
{
3535
BackColor = Color.FromArgb(253, 246, 227),
3636
ForeColor = Color.FromArgb(101, 123, 131),
@@ -40,7 +40,7 @@ public void InitializeThemes()
4040
TrackColor = Color.FromArgb(88, 110, 117),
4141
};
4242

43-
ThemeStyle DarkSolarizedTheme = new ThemeStyle
43+
var DarkSolarizedTheme = new ThemeStyle
4444
{
4545
BackColor = Color.FromArgb(0, 43, 54),
4646
ForeColor = Color.FromArgb(131, 148, 150),
@@ -56,11 +56,11 @@ public void InitializeThemes()
5656
Themes.Add("dark", DarkTheme);
5757
}
5858

59-
private Dictionary<string, ThemeStyle> Themes = new Dictionary<string, ThemeStyle>();
59+
private readonly Dictionary<string, ThemeStyle> Themes = new Dictionary<string, ThemeStyle>();
6060

6161
public ThemeStyle GetTheme(string themeName)
6262
{
63-
if (Themes.TryGetValue(themeName, out ThemeStyle theme))
63+
if (Themes.TryGetValue(themeName, out var theme))
6464
{
6565
return theme;
6666
}

Source/RunActivity/Viewer3D/Processes/GameStateViewer3D.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal override void BeginRender(RenderFrame frame)
5656
Program.DebugViewer.Hide();
5757
Viewer.DebugViewerEnabled = false;
5858

59-
Program.DebugViewerBeta = new DispatchViewerBeta(Viewer.Simulator, Viewer);
59+
Program.DebugViewerBeta = new MapViewer(Viewer.Simulator, Viewer);
6060
Program.DebugViewerBeta.Hide();
6161
Viewer.DebugViewerBetaEnabled = false;
6262

0 commit comments

Comments
 (0)