Skip to content

Commit be39fc9

Browse files
committed
Scrolls the main TrainCarOperations window from the web page..
1 parent c5cdbd3 commit be39fc9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public class TrainCarOperationsWindow : Window
9696
public bool IsFullScreen = false;
9797
public int RowHeight;
9898
public int OldPositionHeight;
99+
public bool UpdateTrainCarOperation = false;
100+
public List<int> LabelPositionTop = new List<int>();
99101

100102
//Rectangle carLabelPosition;
101103
public string CarLabelText;
@@ -345,6 +347,16 @@ void AddSpace()
345347
RearBrakes = Enumerable.Repeat(true, PlayerTrain.Cars.Count).ToList();
346348
}
347349

350+
if (LabelPositionTop.Count == 0)
351+
{
352+
var n = scrollbox.Position.Y;// first row
353+
for (var i = 0; i < PlayerTrain.Cars.Count; i++)
354+
{ // Position of each row
355+
LabelPositionTop.Add(n);
356+
n += (textHeight + ControlLayout.SeparatorSize);
357+
}
358+
}
359+
348360
// reset WarningCarPosition
349361
WarningCarPosition = Enumerable.Repeat(false, PlayerTrain.Cars.Count).ToList();
350362

@@ -603,6 +615,15 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
603615
carOperations.CarOperationChanged = carOperations.Visible && carOperations.CarOperationChanged;
604616
}
605617

618+
if (CarPosition != trainCarViewer.CarPosition)
619+
{
620+
// Required to scroll the main window from the web version
621+
UpdateTrainCarOperation = true;
622+
CarPosition = trainCarViewer.CarPosition;
623+
LabelTop = LabelPositionTop[SelectedCarPosition];
624+
Layout();
625+
localScrollLayout(SelectedCarPosition);
626+
}
606627
//Resize this window after the font has been changed externally
607628
else if (MultiPlayerWindow.FontChanged)
608629
{

0 commit comments

Comments
 (0)