/
HUDWindow.cs
1689 lines (1528 loc) · 96.9 KB
/
HUDWindow.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// COPYRIGHT 2011, 2012, 2013 by the Open Rails project.
//
// This file is part of Open Rails.
//
// Open Rails is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Open Rails is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
// This file is the responsibility of the 3D & Environment Team.
#define SHOW_PHYSICS_GRAPHS //Matej Pacha - if commented, the physics graphs are not ready for public release
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Orts.Simulation.AIs;
using Orts.Simulation.Physics;
using Orts.Simulation.RollingStocks;
using Orts.Simulation.RollingStocks.SubSystems;
using Orts.Simulation.RollingStocks.SubSystems.Brakes;
using Orts.Simulation.RollingStocks.SubSystems.Brakes.MSTS;
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
using Orts.Simulation.RollingStocks.SubSystems.PowerTransmissions;
using Orts.Simulation.Simulation.RollingStocks.SubSystems.PowerSupplies;
using Orts.Viewer3D.Processes;
using ORTS.Common;
using ORTS.Scripting.Api;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace Orts.Viewer3D.Popups
{
public class HUDWindow : LayeredWindow
{
// Set this to the width of each column in font-height units.
readonly int ColumnWidth = 4;
// Set to distance from top-left corner to place text.
const int TextOffset = 10;
readonly Viewer Viewer;
readonly Action<TableData>[] TextPages;
public readonly int TextPagesLength;
readonly WindowTextFont TextFont;
readonly HUDGraphMaterial HUDGraphMaterial;
public int TextPage;
int LocomotivePage = 2;
int LastTextPage;
TableData TextTable = new TableData() { Cells = new string[0, 0] };
HUDGraphSet ForceGraphs;
HUDGraphMesh ForceGraphMotiveForce;
HUDGraphMesh ForceGraphDynamicForce;
HUDGraphMesh ForceGraphNumOfSubsteps;
HUDGraphSet LocomotiveGraphs;
HUDGraphMesh LocomotiveGraphsThrottle;
HUDGraphMesh LocomotiveGraphsInputPower;
HUDGraphMesh LocomotiveGraphsOutputPower;
HUDGraphSet DebugGraphs;
HUDGraphMesh DebugGraphMemory;
HUDGraphMesh DebugGraphGCs;
HUDGraphMesh DebugGraphFrameTime;
HUDGraphMesh DebugGraphProcessRender;
HUDGraphMesh DebugGraphProcessUpdater;
HUDGraphMesh DebugGraphProcessLoader;
HUDGraphMesh DebugGraphProcessSound;
HostProcess Host => Viewer.Game.HostProcess;
public HUDWindow(WindowManager owner)
: base(owner, TextOffset, TextOffset, "HUD")
{
Viewer = owner.Viewer;
LastTextPage = LocomotivePage;
var textPages = new List<Action<TableData>>();
textPages.Add(TextPageCommon);
textPages.Add(TextPageConsistInfo);
textPages.Add(TextPageLocomotiveInfo);
textPages.Add(TextPageDistributedPowerInfo);
textPages.Add(TextPagePowerSupplyInfo);
textPages.Add(TextPageBrakeInfo);
textPages.Add(TextPageForceInfo);
textPages.Add(TextPageDispatcherInfo);
textPages.Add(TextPageWeather);
textPages.Add(TextPageDebugInfo);
TextPages = textPages.ToArray();
TextPagesLength = TextPages.Length;
TextFont = owner.TextFontDefaultOutlined;
ColumnWidth *= TextFont.Height;
HUDGraphMaterial = (HUDGraphMaterial)Viewer.MaterialManager.Load("Debug");
LocomotiveGraphs = new HUDGraphSet(Viewer, HUDGraphMaterial);
LocomotiveGraphsThrottle = LocomotiveGraphs.Add(Viewer.Catalog.GetString("Throttle"), "0", "100%", Color.Blue, 50);
LocomotiveGraphsInputPower = LocomotiveGraphs.Add(Viewer.Catalog.GetString("Power In/Out"), "0", "100%", Color.Yellow, 50);
LocomotiveGraphsOutputPower = LocomotiveGraphs.AddOverlapped(Color.Green, 50);
ForceGraphs = new HUDGraphSet(Viewer, HUDGraphMaterial);
ForceGraphMotiveForce = ForceGraphs.Add(Viewer.Catalog.GetString("Motive force"), "0%", "100%", Color.Green, 75);
ForceGraphDynamicForce = ForceGraphs.AddOverlapped(Color.Red, 75);
ForceGraphNumOfSubsteps = ForceGraphs.Add(Viewer.Catalog.GetString("Num of substeps"), "0", "100", Color.Blue, 25);
DebugGraphs = new HUDGraphSet(Viewer, HUDGraphMaterial);
DebugGraphMemory = DebugGraphs.Add(Viewer.Catalog.GetString("Memory"), "0GB", String.Format("{0:F0}GB", (float)Host.CPUMemoryVirtualLimit / 1024 / 1024 / 1024), Color.Orange, 50);
DebugGraphGCs = DebugGraphs.Add(Viewer.Catalog.GetString("GCs"), "0", "2", Color.Magenta, 20); // Multiple of 4
DebugGraphFrameTime = DebugGraphs.Add(Viewer.Catalog.GetString("Frame time"), "0.0s", "0.1s", Color.LightGreen, 50);
DebugGraphProcessRender = DebugGraphs.Add(Viewer.Catalog.GetString("Render process"), "0%", "100%", Color.Red, 20);
DebugGraphProcessUpdater = DebugGraphs.Add(Viewer.Catalog.GetString("Updater process"), "0%", "100%", Color.Yellow, 20);
DebugGraphProcessLoader = DebugGraphs.Add(Viewer.Catalog.GetString("Loader process"), "0%", "100%", Color.Magenta, 20);
DebugGraphProcessSound = DebugGraphs.Add(Viewer.Catalog.GetString("Sound process"), "0%", "100%", Color.Cyan, 20);
#if WITH_PATH_DEBUG
TextPage = 5;
#endif
}
protected internal override void Save(BinaryWriter outf)
{
base.Save(outf);
outf.Write(TextPage);
outf.Write(LastTextPage);
}
protected internal override void Restore(BinaryReader inf)
{
base.Restore(inf);
var page = inf.ReadInt32();
if (page >= 0 && page <= TextPages.Length)
TextPage = page;
page = inf.ReadInt32();
if (page > 0 && page <= TextPages.Length)
LastTextPage = page;
else LastTextPage = LocomotivePage;
}
public override void Mark()
{
base.Mark();
HUDGraphMaterial.Mark();
}
public override bool Interactive
{
get
{
return false;
}
}
public override void TabAction()
{
TextPage = (TextPage + 1) % TextPages.Length;
if (TextPage != 0) LastTextPage = TextPage;
}
public void ToggleBasicHUD()
{
TextPage = TextPage == 0 ? LastTextPage : 0;
}
int[] lastGCCounts = new int[3];
public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime, bool updateFull)
{
base.PrepareFrame(frame, elapsedTime, updateFull);
#if SHOW_PHYSICS_GRAPHS
if (Visible && TextPages[TextPage] == TextPageForceInfo)
{
var loco = Viewer.PlayerLocomotive as MSTSLocomotive;
var locoD = Viewer.PlayerLocomotive as MSTSDieselLocomotive;
// For geared locomotives the Max Force base value needs to change for each gear.
if (locoD != null && locoD.DieselEngines.HasGearBox && locoD.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
{
ForceGraphMotiveForce.AddSample(loco.MotiveForceN / loco.HuDGearMaximumTractiveForce);
}
else
{
ForceGraphMotiveForce.AddSample(loco.MotiveForceN / loco.MaxForceN);
}
if (locoD != null && locoD.DieselEngines.HasGearBox && locoD.DieselTransmissionType == MSTSDieselLocomotive.DieselTransmissionTypes.Mechanic)
{
ForceGraphDynamicForce.AddSample(-loco.MotiveForceN / loco.HuDGearMaximumTractiveForce);
}
else
{
ForceGraphDynamicForce.AddSample(-loco.MotiveForceN / loco.MaxForceN);
}
ForceGraphNumOfSubsteps.AddSample(loco.LocomotiveAxles.NumOfSubstepsPS / 100.0f);
ForceGraphs.PrepareFrame(frame);
}
if (Visible && TextPages[TextPage] == TextPageLocomotiveInfo)
{
var loco = Viewer.PlayerLocomotive as MSTSLocomotive;
var locoD = Viewer.PlayerLocomotive as MSTSDieselLocomotive;
var locoE = Viewer.PlayerLocomotive as MSTSElectricLocomotive;
var locoS = Viewer.PlayerLocomotive as MSTSSteamLocomotive;
LocomotiveGraphsThrottle.AddSample(loco.ThrottlePercent * 0.01f);
if (locoD != null)
{
LocomotiveGraphsInputPower.AddSample(locoD.DieselEngines.MaxOutputPowerW / locoD.DieselEngines.MaxPowerW);
LocomotiveGraphsOutputPower.AddSample(locoD.DieselEngines.PowerW / locoD.DieselEngines.MaxPowerW);
}
if (locoE != null)
{
LocomotiveGraphsInputPower.AddSample(loco.ThrottlePercent * 0.01f);
LocomotiveGraphsOutputPower.AddSample((loco.MotiveForceN / loco.MaxPowerW) * loco.SpeedMpS);
}
//TODO: plot correct values
if (locoS != null)
{
LocomotiveGraphsInputPower.AddSample(loco.ThrottlePercent * 0.01f);
LocomotiveGraphsOutputPower.AddSample((loco.MotiveForceN / loco.MaxPowerW) * loco.SpeedMpS);
}
LocomotiveGraphs.PrepareFrame(frame);
}
#endif
if (Visible && TextPages[TextPage] == TextPageDebugInfo)
{
var gcCounts = new[] { GC.CollectionCount(0), GC.CollectionCount(1), GC.CollectionCount(2) };
DebugGraphMemory.AddSample((float)Host.CPUMemoryWorkingSet / Host.CPUMemoryVirtualLimit);
DebugGraphGCs.AddSample(gcCounts[2] > lastGCCounts[2] ? 1.0f : gcCounts[1] > lastGCCounts[1] ? 0.5f : gcCounts[0] > lastGCCounts[0] ? 0.25f : 0);
DebugGraphFrameTime.AddSample(Viewer.RenderProcess.FrameTime.Value * 10);
DebugGraphProcessRender.AddSample(Viewer.RenderProcess.Profiler.Wall.Value / 100);
DebugGraphProcessUpdater.AddSample(Viewer.UpdaterProcess.Profiler.Wall.Value / 100);
DebugGraphProcessLoader.AddSample(Viewer.LoaderProcess.Profiler.Wall.Value / 100);
DebugGraphProcessSound.AddSample(Viewer.SoundProcess.Profiler.Wall.Value / 100);
lastGCCounts = gcCounts;
DebugGraphs.PrepareFrame(frame);
}
}
public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
{
base.PrepareFrame(elapsedTime, updateFull);
if (updateFull)
{
var table = new TableData() { Cells = new string[TextTable.Cells.GetLength(0), TextTable.Cells.GetLength(1)] };
TextPages[0](table);
if (TextPage > 0)
TextPages[TextPage](table);
TextTable = table;
}
}
// ==========================================================================================================================================
// Method to construct the various Heads Up Display pages for use by the WebServer
// Replaces the Prepare Frame Method
// djr - 20171221
// ==========================================================================================================================================
public TableData PrepareTable(int PageNo)
{
var table = new TableData() { Cells = new string[1, 1] };
TextPages[PageNo](table);
return (table);
}
public override void Draw(SpriteBatch spriteBatch)
{
// Completely customise the rendering of the HUD - don't call base.Draw(spriteBatch).
for (var row = 0; row < TextTable.Cells.GetLength(0); row++)
{
for (var column = 0; column < TextTable.Cells.GetLength(1); column++)
{
if (TextTable.Cells[row, column] != null)
{
var text = TextTable.Cells[row, column];
var align = text.StartsWith(" ") ? LabelAlignment.Right : LabelAlignment.Left;
var color = Color.White;
if (text.EndsWith("!!!") || text.EndsWith("???"))
{
color = text.EndsWith("!!!") ? Color.OrangeRed : Color.Yellow;
text = text.Substring(0, text.Length - 3);
}
else if (text.EndsWith("%%%"))
{
color = Color.Cyan;
text = text.Substring(0, text.Length - 3);
}
else if (text.EndsWith("$$$"))
{
color = Color.Pink;
text = text.Substring(0, text.Length - 3);
}
TextFont.Draw(spriteBatch, new Rectangle(TextOffset + column * ColumnWidth, TextOffset + row * TextFont.Height, ColumnWidth, TextFont.Height), Point.Zero, text, align, color);
}
}
}
#if SHOW_PHYSICS_GRAPHS
if (Visible && TextPages[TextPage] == TextPageForceInfo)
ForceGraphs.Draw(spriteBatch);
if (Visible && TextPages[TextPage] == TextPageLocomotiveInfo)
LocomotiveGraphs.Draw(spriteBatch);
#endif
if (Visible && TextPages[TextPage] == TextPageDebugInfo)
DebugGraphs.Draw(spriteBatch);
}
#region Table handling
// ==========================================================================================================================================
// Class used to construct table for display of Heads Up Display pages
// Original Code has been altered making the class public for use by the WebServer
// djr - 20171221
// ==========================================================================================================================================
//sealed class TableData
//{
// public string[,] Cells;
// public int CurrentRow;
// public int CurrentLabelColumn;
// public int CurrentValueColumn;
//}
public sealed class TableData
{
public string[,] Cells;
public int CurrentRow;
public int CurrentLabelColumn;
public int CurrentValueColumn;
}
static void TableSetCell(TableData table, int cellColumn, string format, params object[] args)
{
TableSetCell(table, table.CurrentRow, cellColumn, format, args);
}
static void TableSetCell(TableData table, int cellRow, int cellColumn, string format, params object[] args)
{
if (cellRow > table.Cells.GetUpperBound(0) || cellColumn > table.Cells.GetUpperBound(1))
{
var newCells = new string[Math.Max(cellRow + 1, table.Cells.GetLength(0)), Math.Max(cellColumn + 1, table.Cells.GetLength(1))];
for (var row = 0; row < table.Cells.GetLength(0); row++)
for (var column = 0; column < table.Cells.GetLength(1); column++)
newCells[row, column] = table.Cells[row, column];
table.Cells = newCells;
}
Debug.Assert(!format.Contains('\n'), "HUD table cells must not contain newlines. Use the table positioning instead.");
table.Cells[cellRow, cellColumn] = args.Length > 0 ? String.Format(format, args) : format;
}
static void TableSetCells(TableData table, int startColumn, params string[] columns)
{
for (var i = 0; i < columns.Length; i++)
TableSetCell(table, startColumn + i, columns[i]);
}
static void TableAddLine(TableData table)
{
table.CurrentRow++;
}
static void TableAddLine(TableData table, string format, params object[] args)
{
TableSetCell(table, table.CurrentRow, 0, format, args);
table.CurrentRow++;
}
static void TableAddLines(TableData table, string lines)
{
if (lines == null)
return;
foreach (var line in lines.Split('\n'))
{
var column = 0;
foreach (var cell in line.Split('\t'))
TableSetCell(table, column++, "{0}", cell);
table.CurrentRow++;
}
}
static void TableSetLabelValueColumns(TableData table, int labelColumn, int valueColumn)
{
table.CurrentLabelColumn = labelColumn;
table.CurrentValueColumn = valueColumn;
}
static void TableAddLabelValue(TableData table, string label, string format, params object[] args)
{
TableSetCell(table, table.CurrentRow, table.CurrentLabelColumn, label);
TableSetCell(table, table.CurrentRow, table.CurrentValueColumn, format, args);
table.CurrentRow++;
}
#endregion
void TextPageCommon(TableData table)
{
var playerTrain = Viewer.PlayerLocomotive.Train;
var showMUReverser = Math.Abs(playerTrain.MUReverserPercent) != 100;
var showRetainers = playerTrain.RetainerSetting != RetainerSetting.Exhaust;
var engineBrakeStatus = Viewer.PlayerLocomotive.GetEngineBrakeStatus();
var brakemanBrakeStatus = Viewer.PlayerLocomotive.GetBrakemanBrakeStatus();
var dynamicBrakeStatus = Viewer.PlayerLocomotive.GetDPDynamicBrakeStatus();
var locomotiveStatus = Viewer.PlayerLocomotive.GetStatus();
var multipleUnitsConfiguration = Viewer.PlayerLocomotive.GetMultipleUnitsConfiguration();
var stretched = playerTrain.Cars.Count > 1 && playerTrain.NPull == playerTrain.Cars.Count - 1;
var bunched = !stretched && playerTrain.Cars.Count > 1 && playerTrain.NPush == playerTrain.Cars.Count - 1;
TableSetLabelValueColumns(table, 0, 2);
TableAddLabelValue(table, Viewer.Catalog.GetString("Version"), VersionInfo.VersionOrBuild);
// Client and server may have a time difference.
if (Orts.MultiPlayer.MPManager.IsClient())
TableAddLabelValue(table, Viewer.Catalog.GetString("Time"), FormatStrings.FormatTime(Viewer.Simulator.ClockTime + Orts.MultiPlayer.MPManager.Instance().serverTimeDifference));
else
TableAddLabelValue(table, Viewer.Catalog.GetString("Time"), FormatStrings.FormatTime(Viewer.Simulator.ClockTime));
if (Viewer.Simulator.IsReplaying)
TableAddLabelValue(table, Viewer.Catalog.GetString("Replay"), FormatStrings.FormatTime(Viewer.Log.ReplayEndsAt - Viewer.Simulator.ClockTime));
TableAddLabelValue(table, Viewer.Catalog.GetString("Speed"), FormatStrings.FormatSpeedDisplay(Viewer.PlayerLocomotive.SpeedMpS, Viewer.PlayerLocomotive.IsMetric));
TableAddLabelValue(table, Viewer.Catalog.GetString("Gradient"), "{0:F1}%", -Viewer.PlayerLocomotive.CurrentElevationPercent);
TableAddLabelValue(table, Viewer.Catalog.GetString("Direction"), showMUReverser ? "{1:F0} {0}" : "{0}", FormatStrings.Catalog.GetParticularString("Reverser", GetStringAttribute.GetPrettyName(Viewer.PlayerLocomotive.Direction)), Math.Abs(playerTrain.MUReverserPercent));
TableAddLabelValue(table, Viewer.PlayerLocomotive is MSTSSteamLocomotive ? Viewer.Catalog.GetString("Regulator") : Viewer.Catalog.GetString("Throttle"), "{0:F0}% {1}",
Viewer.PlayerLocomotive.ThrottlePercent,
Viewer.PlayerLocomotive is MSTSDieselLocomotive && Viewer.PlayerLocomotive.Train.DPMode == 1 ? string.Format("({0}%)", Viewer.PlayerLocomotive.Train.DPThrottlePercent) : "");
if ((Viewer.PlayerLocomotive as MSTSLocomotive).TrainBrakeFitted)
TableAddLabelValue(table, Viewer.Catalog.GetString("Train brake"), "{0}", Viewer.PlayerLocomotive.GetTrainBrakeStatus());
if (showRetainers)
TableAddLabelValue(table, Viewer.Catalog.GetString("Retainers"), "{0}% {1}", playerTrain.RetainerPercent, Viewer.Catalog.GetString(GetStringAttribute.GetPrettyName(playerTrain.RetainerSetting)));
if ((Viewer.PlayerLocomotive as MSTSLocomotive).EngineBrakeFitted) // ideally this test should be using "engineBrakeStatus != null", but this currently does not work, as a controller is defined by default
TableAddLabelValue(table, Viewer.Catalog.GetString("Engine brake"), "{0}", engineBrakeStatus);
if ((Viewer.PlayerLocomotive as MSTSLocomotive).BrakemanBrakeFitted)
TableAddLabelValue(table, Viewer.Catalog.GetString("Brakemen brake"), "{0}", brakemanBrakeStatus);
if (dynamicBrakeStatus != null)
TableAddLabelValue(table, Viewer.Catalog.GetString("Dynamic brake"), "{0}", dynamicBrakeStatus);
if (locomotiveStatus != null)
{
var lines = locomotiveStatus.Split('\n');
foreach (var line in lines)
{
if (line.Length > 0)
{
var parts = line.Split(new[] { " = " }, 2, StringSplitOptions.None);
TableAddLabelValue(table, parts[0], parts.Length > 1 ? parts[1] : "");
}
}
}
if ((Viewer.PlayerLocomotive as MSTSLocomotive).CruiseControl != null)
{
var cc = ((MSTSLocomotive)Viewer.PlayerLocomotive).CruiseControl;
TableAddLabelValue(table, Viewer.Catalog.GetString("Cruise control status"), "{0}", cc.SpeedRegMode.ToString());
if (cc.SpeedRegMode == Simulation.RollingStocks.SubSystems.CruiseControl.SpeedRegulatorMode.Auto)
{
TableAddLabelValue(table, Viewer.Catalog.GetString("Speed target"), "{0}", FormatStrings.FormatSpeedDisplay(cc.SelectedSpeedMpS, Viewer.PlayerLocomotive.IsMetric));
TableAddLabelValue(table, Viewer.Catalog.GetString("Max acceleration"), "{0:F0}%", cc.SelectedMaxAccelerationPercent);
}
}
if (multipleUnitsConfiguration != null)
TableAddLabelValue(table, Viewer.Catalog.GetString("Multiple Units"), "{0}", multipleUnitsConfiguration);
TableAddLine(table);
TableAddLabelValue(table, Viewer.Catalog.GetString("FPS"), "{0:F0}", Viewer.RenderProcess.FrameRate.SmoothedValue);
TableAddLine(table);
if (Viewer.PlayerLocomotive.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING)
TableAddLine(table, Viewer.Catalog.GetString("Autopilot") + "???");
if (Viewer.PlayerTrain.IsWheelSlip)
TableAddLine(table, Viewer.Catalog.GetString("Wheel slip") + "!!!");
else if (Viewer.PlayerTrain.IsWheelSlipWarninq)
TableAddLine(table, Viewer.Catalog.GetString("Wheel slip warning") + "???");
if (Viewer.PlayerTrain.IsBrakeSkid )
TableAddLine(table, Viewer.Catalog.GetString("Wheel skid") + "!!!");
if (Viewer.PlayerLocomotive.GetSanderOn())
{
var sanderBlocked = Viewer.PlayerLocomotive is MSTSLocomotive && Math.Abs(playerTrain.SpeedMpS) > ((MSTSLocomotive)Viewer.PlayerLocomotive).SanderSpeedOfMpS;
if (sanderBlocked)
TableAddLine(table, Viewer.Catalog.GetString("Sander blocked") + "!!!");
else
TableAddLine(table, Viewer.Catalog.GetString("Sander on") + "???");
}
bool flipped = (Viewer.PlayerLocomotive as MSTSLocomotive).GetCabFlipped() ^ (Viewer.PlayerLocomotive as MSTSLocomotive).Flipped;
var doorLeftOpen = Viewer.PlayerLocomotive.Train.DoorState(flipped ? DoorSide.Right : DoorSide.Left) != DoorState.Closed;
var doorRightOpen = Viewer.PlayerLocomotive.Train.DoorState(flipped ? DoorSide.Left : DoorSide.Right) != DoorState.Closed;
if (doorLeftOpen || doorRightOpen)
{
var color = Math.Abs(Viewer.PlayerLocomotive.SpeedMpS) > 0.1f ? "!!!" : "???";
var status = "";
if (doorLeftOpen)
status += Viewer.Catalog.GetString("Left");
if (doorRightOpen)
status += string.Format(status == "" ? "{0}" : " {0}", Viewer.Catalog.GetString("Right"));
status += color;
TableAddLabelValue(table, Viewer.Catalog.GetString("Doors open") + color, status);
}
if (Orts.MultiPlayer.MPManager.IsMultiPlayer())
{
var text = Orts.MultiPlayer.MPManager.Instance().GetOnlineUsersInfo();
TableAddLabelValue(table, Viewer.Catalog.GetString("MultiPlayerStatus: "), "{0}", Orts.MultiPlayer.MPManager.IsServer()
? Viewer.Catalog.GetString("Dispatcher") : Orts.MultiPlayer.MPManager.Instance().AmAider
? Viewer.Catalog.GetString("Helper") : Orts.MultiPlayer.MPManager.IsClient()
? Viewer.Catalog.GetString("Client") : "");
TableAddLine(table);
foreach (var t in text.Split('\t'))
TableAddLine(table, "{0}", t);
}
}
void TextPageConsistInfo(TableData table)
{
TextPageHeading(table, Viewer.Catalog.GetString("CONSIST INFORMATION"));
var locomotive = Viewer.PlayerLocomotive;
var mstsLocomotive = locomotive as MSTSLocomotive;
var train = locomotive.Train;
float tonnage = 0f;
foreach (var car in train.Cars)
{
if(car.WagonType == TrainCar.WagonTypes.Freight || car.WagonType == TrainCar.WagonTypes.Passenger)
tonnage += car.MassKG;
}
TableSetCells(table, 0,
Viewer.Catalog.GetString("Player"),
Viewer.Catalog.GetString("Tilted"),
Viewer.Catalog.GetString("Type"),
Viewer.Catalog.GetString("Length"),
Viewer.Catalog.GetString("Weight"), "",
Viewer.Catalog.GetString("Tonnage"), "",
Viewer.Catalog.GetString("Control Mode"), "",
Viewer.Catalog.GetString("Out of Control"), "",
Viewer.Catalog.GetString("Cab Aspect"));
TableAddLine(table);
TableSetCells(table, 0, locomotive.CarID + " " + (mstsLocomotive == null ? "" : mstsLocomotive.UsingRearCab ? Viewer.Catalog.GetParticularString("Cab", "R") : Viewer.Catalog.GetParticularString("Cab", "F")),
train.IsTilting ? Viewer.Catalog.GetString("Yes") : Viewer.Catalog.GetString("No"),
train.IsFreight ? Viewer.Catalog.GetString("Freight") : Viewer.Catalog.GetString("Pass"),
FormatStrings.FormatShortDistanceDisplay(train.Length, locomotive.IsMetric),
FormatStrings.FormatLargeMass(train.MassKg, locomotive.IsMetric, locomotive.IsUK), "",
FormatStrings.FormatLargeMass(tonnage, locomotive.IsMetric, locomotive.IsUK), "",
train.ControlMode.ToString(), "",
train.OutOfControlReason.ToString(), "",
mstsLocomotive.TrainControlSystem.CabSignalAspect.ToString());
TableAddLine(table);
TableAddLine(table);
TableSetCells(table, 0,
Viewer.Catalog.GetString("Car"),
Viewer.Catalog.GetString("Flipped"),
Viewer.Catalog.GetString("Type"),
Viewer.Catalog.GetString("Length"),
Viewer.Catalog.GetString("Weight"),
Viewer.Catalog.GetString("Drv/Cabs"),
Viewer.Catalog.GetString("Wheels"),
Viewer.Catalog.GetString("Temp"));
TableAddLine(table);
foreach (var car in train.Cars.Take(20))
{
TableSetCells(table, 0, car.CarID,
car.Flipped ? Viewer.Catalog.GetString("Yes") : Viewer.Catalog.GetString("No"),
train.IsFreight ? Viewer.Catalog.GetString("Freight") : Viewer.Catalog.GetString("Pass"),
FormatStrings.FormatShortDistanceDisplay(car.CarLengthM, locomotive.IsMetric),
FormatStrings.FormatLargeMass(car.MassKG, locomotive.IsMetric, locomotive.IsUK),
(car.IsDriveable ? Viewer.Catalog.GetParticularString("Cab", "D") : "") + (car.HasFrontCab || car.HasFront3DCab ? Viewer.Catalog.GetParticularString("Cab", "F") : "") + (car.HasRearCab || car.HasRear3DCab ? Viewer.Catalog.GetParticularString("Cab", "R") : ""),
GetCarWhyteLikeNotation(car),
car.WagonType == TrainCar.WagonTypes.Passenger || car.WagonSpecialType == TrainCar.WagonSpecialTypes.Heated ? FormatStrings.FormatTemperature(car.CarInsideTempC, locomotive.IsMetric, false) : string.Empty);
TableAddLine(table);
}
}
/// <summary>
/// Calculates Whyte notation for the vehicle
/// For duplex steam locomotives wheel axles can be grouped under the main object shape, and hence the multiple engines will be counted as a single grouping.
/// For multiple engines, the number of wheels defined in the attached axles will be used to determine the axles in the "non-bogie" groupings.
/// </summary>
static string GetCarWhyteLikeNotation(TrainCar car)
{
if (car.WheelAxles.Count == 0)
return "";
var whyte = new List<string>();
var currentCount = 0;
var currentBogie = car.WheelAxles[0].BogieIndex;
bool PreviousAxlePart = true; // Assume a bogie
var steamloco = car as MSTSSteamLocomotive;
if (car is MSTSSteamLocomotive && steamloco.SteamEngines.Count > 1)
{
var i = 0; // Count for number of steam engines
var axlesCount = 0;
foreach (var axle in car.WheelAxles)
{
if (!axle.Part.bogie) // if not a bogie then check for the number of axles.
{
if (currentBogie != axle.BogieIndex && currentCount != 0)
{
whyte.Add(currentCount.ToString());
currentBogie = axle.BogieIndex;
currentCount = 0;
}
if (steamloco.SteamEngines[i].AuxiliarySteamEngineType != SteamEngine.AuxiliarySteamEngineTypes.Booster)
{
currentCount += 2;
axlesCount += 1;
if (axlesCount >= steamloco.SteamEngines[i].AttachedAxle.NumWheelsetAxles && currentCount != 0)
{
whyte.Add(currentCount.ToString());
currentBogie = axle.BogieIndex;
currentCount = 0;
axlesCount = 0;
i = i + 1;
}
}
}
else if (axle.Part.bogie) // this is a bogie
{
if ( PreviousAxlePart)
{
currentBogie = axle.BogieIndex;
}
if (currentBogie != axle.BogieIndex && currentCount != 0)
{
whyte.Add(currentCount.ToString());
currentBogie = axle.BogieIndex;
currentCount = 0;
}
currentCount += 2;
}
if (axle.Part.bogie)
{
PreviousAxlePart = true;
}
else
{
PreviousAxlePart = false;
}
}
whyte.Add(currentCount.ToString());
return String.Join("-", whyte.ToArray());
}
else // default axle computation - used for most wheel configurations
{
foreach (var axle in car.WheelAxles)
{
if (currentBogie != axle.BogieIndex && currentCount != 0)
{
whyte.Add(currentCount.ToString());
currentBogie = axle.BogieIndex;
currentCount = 0;
}
currentCount += 2;
}
whyte.Add(currentCount.ToString());
return String.Join("-", whyte.ToArray());
}
}
void TextPageLocomotiveInfo(TableData table)
{
TextPageHeading(table, Viewer.Catalog.GetString("LOCOMOTIVE INFORMATION"));
var locomotive = Viewer.PlayerLocomotive;
var train = locomotive.Train;
TableAddLines(table, String.Format("{8}\t\t{0} {4}\t\t{1} {5:F0}%\t\t{2} {6:F0}%\t\t{3} {7}",
Viewer.Catalog.GetString("Direction"),
Viewer.PlayerLocomotive is MSTSSteamLocomotive ? Viewer.Catalog.GetParticularString("Steam", "Reverser") : Viewer.Catalog.GetParticularString("NonSteam", "Reverser"),
Viewer.PlayerLocomotive is MSTSSteamLocomotive ? Viewer.Catalog.GetString("Regulator") : Viewer.Catalog.GetString("Throttle"),
Viewer.Catalog.GetString("Dynamic brake"),
FormatStrings.Catalog.GetParticularString("Reverser", GetStringAttribute.GetPrettyName(train.MUDirection)),
train.MUReverserPercent,
train.MUThrottlePercent,
train.MUDynamicBrakePercent >= 0 ? string.Format("{0:F0}%", train.MUDynamicBrakePercent) : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("PlayerLoco")));
TableAddLine(table);
TableSetCells(table, 0,
Viewer.Catalog.GetString("Loco"),
Viewer.Catalog.GetString("Direction"),
Viewer.Catalog.GetString("Flipped"),
Viewer.Catalog.GetString("MU'd"),
Viewer.Catalog.GetString("Throttle"),
Viewer.Catalog.GetString("Speed"),
"",
Viewer.Catalog.GetString("Power"),
Viewer.Catalog.GetString("Force")
);
TableAddLine(table);
foreach (var car in train.Cars)
if (car is MSTSLocomotive)
TableAddLines(table, car.GetDebugStatus());
}
void TextPageDistributedPowerInfo(TableData table)
{
TextPageHeading(table, Viewer.Catalog.GetString("DISTRIBUTED POWER INFORMATION"));
var locomotive = Viewer.PlayerLocomotive;
if (!(locomotive is MSTSDieselLocomotive)) return;
var train = locomotive.Train;
int numberOfDieselLocomotives = 0;
for (var i = 0; i<train.Cars.Count; i++)
{
if (train.Cars[i] is MSTSDieselLocomotive)
{
numberOfDieselLocomotives++;
}
}
if (numberOfDieselLocomotives > 0)
{
var row = table.CurrentRow;
TableAddLines(table, MSTSDieselLocomotive.GetDebugTableBase(numberOfDieselLocomotives));
var k = 0;
var dpUnitId = 0;
for (var i = 0; i<train.Cars.Count; i++)
if (train.Cars[i] is MSTSDieselLocomotive)
{
k++;
var status = (train.Cars[i] as MSTSDieselLocomotive).GetDPDebugStatus().Split('\t');
var fence = (dpUnitId != (dpUnitId = train.Cars[i].RemoteControlGroup)) ? "| " : "";
for (var j = 0; j<status.Length; j++)
table.Cells[row + j, 2 * k] = fence + status[j];
}
}
}
void TextPagePowerSupplyInfo(TableData table)
{
TextPageHeading(table, Viewer.Catalog.GetString("POWER SUPPLY INFORMATION"));
Train train = Viewer.PlayerLocomotive.Train;
TableAddLine(table);
TableSetCells(table, 0,
Viewer.Catalog.GetString("Wagon"),
Viewer.Catalog.GetString("Type"),
Viewer.Catalog.GetParticularString("Pantograph", "Panto"),
Viewer.Catalog.GetParticularString("Engine", "Eng"),
Viewer.Catalog.GetParticularString("CircuitBreaker", "CB"),
Viewer.Catalog.GetParticularString("TractionCutOffRelay", "TCOR"),
Viewer.Catalog.GetString("MainPS"),
Viewer.Catalog.GetString("AuxPS"),
Viewer.Catalog.GetString("Battery"),
Viewer.Catalog.GetString("LowVoltPS"),
Viewer.Catalog.GetString("CabPS"),
Viewer.Catalog.GetString("ETS"),
Viewer.Catalog.GetString("ETSCable"),
Viewer.Catalog.GetString("Power")
);
foreach (TrainCar car in train.Cars.Where(car => car.PowerSupply != null))
{
IPowerSupply powerSupply = car.PowerSupply;
ILocomotivePowerSupply locomotivePowerSupply = powerSupply as ILocomotivePowerSupply;
string pantographState = string.Empty;
string dieselEngineState = string.Empty;
string circuitBreakerState = string.Empty;
string tractionCutOffRelayState = string.Empty;
string mainPowerSupplyState = string.Empty;
string auxiliaryPowerSupplyState = string.Empty;
string electricTrainSupplyState = string.Empty;
string electricTrainSupplyCableState = string.Empty;
string electricTrainSupplyPower = string.Empty;
if (powerSupply is ScriptedElectricPowerSupply electricPowerSupply)
{
pantographState = Viewer.Catalog.GetParticularString("Pantograph", GetStringAttribute.GetPrettyName((car as MSTSWagon).Pantographs.State));
circuitBreakerState = Viewer.Catalog.GetParticularString("CircuitBreaker", GetStringAttribute.GetPrettyName(electricPowerSupply.CircuitBreaker.State));
mainPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.MainPowerSupplyState));
auxiliaryPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.AuxiliaryPowerSupplyState));
if (locomotivePowerSupply.ElectricTrainSupplyState != PowerSupplyState.Unavailable)
{
electricTrainSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.ElectricTrainSupplyState));
electricTrainSupplyCableState = car.PowerSupply.FrontElectricTrainSupplyCableConnected ? Viewer.Catalog.GetString("connected") : Viewer.Catalog.GetString("disconnected");
electricTrainSupplyPower = FormatStrings.FormatPower(locomotivePowerSupply.ElectricTrainSupplyPowerW, true, false, false);
}
}
else if (powerSupply is ScriptedDieselPowerSupply dieselPowerSupply)
{
dieselEngineState = Viewer.Catalog.GetParticularString("Engine", GetStringAttribute.GetPrettyName((car as MSTSDieselLocomotive).DieselEngines.State));
tractionCutOffRelayState = Viewer.Catalog.GetParticularString("TractionCutOffRelay", GetStringAttribute.GetPrettyName(dieselPowerSupply.TractionCutOffRelay.State));
mainPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.MainPowerSupplyState));
auxiliaryPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.AuxiliaryPowerSupplyState));
if (locomotivePowerSupply.ElectricTrainSupplyState != PowerSupplyState.Unavailable)
{
electricTrainSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.ElectricTrainSupplyState));
electricTrainSupplyCableState = car.PowerSupply.FrontElectricTrainSupplyCableConnected ? Viewer.Catalog.GetString("connected") : Viewer.Catalog.GetString("disconnected");
electricTrainSupplyPower = FormatStrings.FormatPower(locomotivePowerSupply.ElectricTrainSupplyPowerW, true, false, false);
}
}
else if (powerSupply is ScriptedDualModePowerSupply dualModePowerSupply)
{
pantographState = Viewer.Catalog.GetParticularString("Pantograph", GetStringAttribute.GetPrettyName((car as MSTSWagon).Pantographs.State));
// TODO with DualModeLocomotive : dieselEngineState = Viewer.Catalog.GetParticularString("Engine", GetStringAttribute.GetPrettyName((car as MSTSDualModeLocomotive).DieselEngines.State));
circuitBreakerState = Viewer.Catalog.GetParticularString("CircuitBreaker", GetStringAttribute.GetPrettyName(dualModePowerSupply.CircuitBreaker.State));
tractionCutOffRelayState = Viewer.Catalog.GetParticularString("TractionCutOffRelay", GetStringAttribute.GetPrettyName(dualModePowerSupply.TractionCutOffRelay.State));
mainPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.MainPowerSupplyState));
auxiliaryPowerSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.AuxiliaryPowerSupplyState));
if (locomotivePowerSupply.ElectricTrainSupplyState != PowerSupplyState.Unavailable)
{
electricTrainSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.ElectricTrainSupplyState));
electricTrainSupplyCableState = car.PowerSupply.FrontElectricTrainSupplyCableConnected ? Viewer.Catalog.GetString("connected") : Viewer.Catalog.GetString("disconnected");
electricTrainSupplyPower = FormatStrings.FormatPower(locomotivePowerSupply.ElectricTrainSupplyPowerW, true, false, false);
}
}
else if (powerSupply is IPassengerCarPowerSupply passengerCarPowerSupply)
{
if (passengerCarPowerSupply.ElectricTrainSupplyState != PowerSupplyState.Unavailable)
{
electricTrainSupplyState = Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.ElectricTrainSupplyState));
electricTrainSupplyCableState = car.PowerSupply.FrontElectricTrainSupplyCableConnected ? Viewer.Catalog.GetString("connected") : Viewer.Catalog.GetString("disconnected");
electricTrainSupplyPower = FormatStrings.FormatPower(passengerCarPowerSupply.ElectricTrainSupplyPowerW, true, false, false);
}
}
// If power supply is steam power supply, do nothing.
TableAddLine(table);
TableSetCells(table, 0,
car.CarID,
car.WagonType.ToString(),
pantographState,
dieselEngineState,
circuitBreakerState,
tractionCutOffRelayState,
mainPowerSupplyState,
auxiliaryPowerSupplyState,
Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.BatteryState)),
Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(car.PowerSupply.LowVoltagePowerSupplyState)),
locomotivePowerSupply != null ? Viewer.Catalog.GetParticularString("PowerSupply", GetStringAttribute.GetPrettyName(locomotivePowerSupply.CabPowerSupplyState)) : string.Empty,
electricTrainSupplyState,
electricTrainSupplyCableState,
electricTrainSupplyPower
);
}
}
void TextPageBrakeInfo(TableData table)
{
TextPageHeading(table, Viewer.Catalog.GetString("BRAKE INFORMATION"));
var train = Viewer.PlayerLocomotive.Train;
var mstsLocomotive = Viewer.PlayerLocomotive as MSTSLocomotive;
var HUDSteamEngineType = mstsLocomotive.SteamEngineType;
var HUDEngineType = mstsLocomotive.EngineType;
if ((Viewer.PlayerLocomotive as MSTSLocomotive).TrainBrakeFitted) // Only display the following information if a train brake is defined.
{
// If vacuum brakes are used then use this display
if ((Viewer.PlayerLocomotive as MSTSLocomotive).BrakeSystem is VacuumSinglePipe)
{
if ((Viewer.PlayerLocomotive as MSTSLocomotive).VacuumBrakeEQFitted)
{
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("Exhauster"),
(Viewer.PlayerLocomotive as MSTSLocomotive).VacuumExhausterIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off")));
}
else if ((Viewer.PlayerLocomotive as MSTSLocomotive).VacuumPumpFitted && (Viewer.PlayerLocomotive as MSTSLocomotive).SmallEjectorControllerFitted)
{
// Display if vacuum pump, large ejector and small ejector fitted
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}\t{3}\t\t{4}\t{5}\t{6}\t\t{7}\t\t{8}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("Large Ejector"),
(Viewer.PlayerLocomotive as MSTSLocomotive).LargeSteamEjectorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Small Ejector"),
(Viewer.PlayerLocomotive as MSTSLocomotive).SmallSteamEjectorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Pressure"),
FormatStrings.FormatPressure((Viewer.PlayerLocomotive as MSTSLocomotive).SteamEjectorSmallPressurePSI, PressureUnit.PSI, (Viewer.PlayerLocomotive as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true),
Viewer.Catalog.GetString("Vacuum Pump"),
(Viewer.PlayerLocomotive as MSTSLocomotive).VacuumPumpOperating ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off")
));
}
else if ((Viewer.PlayerLocomotive as MSTSLocomotive).VacuumPumpFitted && !(Viewer.PlayerLocomotive as MSTSLocomotive).SmallEjectorControllerFitted) // Change display so that small ejector is not displayed for vacuum pump operated locomotives
{
// Display if vacuum pump, and large ejector only fitted
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}\t{3}\t\t{4}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("Large Ejector"),
(Viewer.PlayerLocomotive as MSTSLocomotive).LargeSteamEjectorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Vacuum Pump"),
(Viewer.PlayerLocomotive as MSTSLocomotive).VacuumPumpOperating ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off")));
}
else
{
// Display if large ejector and small ejector only fitted
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}\t{3}\t\t{4}\t{5}\t{6}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("Large Ejector"),
(Viewer.PlayerLocomotive as MSTSLocomotive).LargeSteamEjectorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Small Ejector"),
(Viewer.PlayerLocomotive as MSTSLocomotive).SmallSteamEjectorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Pressure"),
FormatStrings.FormatPressure((Viewer.PlayerLocomotive as MSTSLocomotive).SteamEjectorSmallPressurePSI, PressureUnit.PSI, (Viewer.PlayerLocomotive as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true)));
}
// Lines to show brake system volumes
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}\t{3}\t\t{4}\t{5}\t{6}",
Viewer.Catalog.GetString("Brake Sys Vol"),
Viewer.Catalog.GetString("Train Pipe"),
FormatStrings.FormatVolume(train.TotalTrainBrakePipeVolumeM3, mstsLocomotive.IsMetric),
Viewer.Catalog.GetString("Brake Cyl"),
FormatStrings.FormatVolume(train.TotalTrainBrakeCylinderVolumeM3, mstsLocomotive.IsMetric),
Viewer.Catalog.GetString("Air Vol"),
FormatStrings.FormatVolume(train.TotalCurrentTrainBrakeSystemVolumeM3, mstsLocomotive.IsMetric)
));
}
else // Default to air or electronically braked, use this display
{
if ((Viewer.PlayerLocomotive as MSTSLocomotive).EngineType == TrainCar.EngineTypes.Control)
{
// Control cars typically don't have reservoirs
TableAddLines(table, String.Format("{0}\t\t{1}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("No compressor or reservoir fitted")
));
}
else
{
TableAddLines(table, String.Format("{0}\t\t{1}\t\t{2}\t{3}\t\t{4}\t\t{5}\t\t{6}",
Viewer.Catalog.GetString("PlayerLoco"),
Viewer.Catalog.GetString("Main reservoir"),
FormatStrings.FormatPressure((Viewer.PlayerLocomotive as MSTSLocomotive).MainResPressurePSI, PressureUnit.PSI, (Viewer.PlayerLocomotive as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true),
Viewer.Catalog.GetString("Compressor"),
(Viewer.PlayerLocomotive as MSTSLocomotive).CompressorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Flow"),
FormatStrings.FormatAirFlow((Viewer.PlayerLocomotive as MSTSLocomotive).FilteredBrakePipeFlowM3pS, mstsLocomotive.IsMetric)));
}
}
// Display data for other locomotives
for (var i = 0; i < train.Cars.Count; i++)
{
var car = train.Cars[i];
if (car is MSTSLocomotive && car != Viewer.PlayerLocomotive)
{
if ((car as MSTSLocomotive).EngineType == TrainCar.EngineTypes.Control)
{
// Control cars typically don't have reservoirs
TableAddLines(table, String.Format("{0}\t{1}",
Viewer.Catalog.GetString("Loco"),
car.CarID
));
}
else
{
TableAddLines(table, String.Format("{0}\t{1}\t{2}\t\t{3}\t{4}\t\t{5}\t\t{6}\t\t{7}",
Viewer.Catalog.GetString("Loco"),
car.CarID,
Viewer.Catalog.GetString("Main reservoir"),
FormatStrings.FormatPressure((car as MSTSLocomotive).MainResPressurePSI, PressureUnit.PSI, (car as MSTSLocomotive).BrakeSystemPressureUnits[BrakeSystemComponent.MainReservoir], true),
Viewer.Catalog.GetString("Compressor"),
(car as MSTSLocomotive).CompressorIsOn ? Viewer.Catalog.GetString("on") : Viewer.Catalog.GetString("off"),
Viewer.Catalog.GetString("Flow"),
FormatStrings.FormatAirFlow((car as MSTSLocomotive).FilteredBrakePipeFlowM3pS, mstsLocomotive.IsMetric)));
}
}
}
TableAddLine(table);
}
// Different display depending upon whether vacuum braked, manual braked or air braked
if ((Viewer.PlayerLocomotive as MSTSLocomotive).BrakeSystem is VacuumSinglePipe)
{
if ((Viewer.PlayerLocomotive as MSTSLocomotive).NonAutoBrakePresent) // Straight brake system
{
TableSetCells(table, 0,
Viewer.Catalog.GetString("Car"),
Viewer.Catalog.GetString("Type"),
Viewer.Catalog.GetString("BrkCyl"),
Viewer.Catalog.GetString("BrkPipe"),