// draw reversal information int drawReversal(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, float firstLabelDistance, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown) { var displayItem = reversalSprite; var newLabelPosition = lastLabelPosition; if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor)) { var itemOffset = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor); var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing); // What was this offset all about? Shouldn't we draw the icons in the correct location ALL the time? -- James Ross // var correctingOffset = Program.Simulator.TimetableMode || !Program.Simulator.Settings.EnhancedActCompatibility ? 0 : 7; var markerPlacement = new Rectangle(offset.X + reversalPosition[0], offset.Y + itemLocation + reversalPosition[forward ? 1 : 2], reversalPosition[3], reversalPosition[4]); spriteBatch.Draw(TrackMonitorImages, markerPlacement, displayItem, thisItem.Enabled ? Color.LightGreen : Color.White); // Only show distance for enhanced MSTS compatibility (this is the only time the position is controlled by the author). if (itemOffset < firstLabelDistance && !firstLabelShown && !Program.Simulator.TimetableMode) { var labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]); var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric); Font.Draw(spriteBatch, labelPoint, distanceString, Color.White); firstLabelShown = true; } } return(newLabelPosition); }
// draw waiting point information int drawWaitingPoint(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, float firstLabelDistance, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown) { var displayItem = waitingPointSprite; var newLabelPosition = lastLabelPosition; if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor)) { var itemOffset = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor); var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing); var markerPlacement = new Rectangle(offset.X + waitingPointPosition[0], offset.Y + itemLocation + waitingPointPosition[forward ? 1 : 2], waitingPointPosition[3], waitingPointPosition[4]); spriteBatch.Draw(TrackMonitorImages, markerPlacement, displayItem, thisItem.Enabled ? Color.Yellow : Color.Red); if (itemOffset < firstLabelDistance && !firstLabelShown) { var labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]); var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric); Font.Draw(spriteBatch, labelPoint, distanceString, Color.White); firstLabelShown = true; } } return(newLabelPosition); }
// draw speedpost information int drawSpeedpost(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, int firstLabelPosition, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool firstLabelShown) { var newLabelPosition = lastLabelPosition; if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor)) { var itemOffset = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor); var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; newLabelPosition = forward ? Math.Min(itemLocation, lastLabelPosition - textSpacing) : Math.Max(itemLocation, lastLabelPosition + textSpacing); var allowedSpeed = thisItem.AllowedSpeedMpS; if (allowedSpeed > 998) { if (!Program.Simulator.TimetableMode) { allowedSpeed = (float)Program.Simulator.TRK.Tr_RouteFile.SpeedLimit; } } var labelPoint = new Point(offset.X + speedTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]); var speedString = FormatStrings.FormatSpeedLimit(allowedSpeed, metric); Font.Draw(spriteBatch, labelPoint, speedString, thisItem.SpeedObjectType == Train.TrainObjectItem.SpeedItemType.Standard ? Color.White : (thisItem.SpeedObjectType == Train.TrainObjectItem.SpeedItemType.TempRestrictedStart ? Color.Red : Color.LightGreen)); if (itemOffset < firstLabelPosition && !firstLabelShown) { labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + newLabelPosition + textOffset[forward ? 0 : 1]); var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric); Font.Draw(spriteBatch, labelPoint, distanceString, Color.White); firstLabelShown = true; } } return(newLabelPosition); }
// draw fixed distance markers float drawDistanceMarkers(SpriteBatch spriteBatch, Point offset, float maxDistance, float distanceFactor, int zeroPoint, int numberOfMarkers, bool forward) { var maxDistanceD = Me.FromM(maxDistance, metric); // in displayed units var markerIntervalD = maxDistanceD / numberOfMarkers; var roundingValue = roundingValues[0]; foreach (var thisValue in roundingValues) { if (markerIntervalD > thisValue.Key) { roundingValue = thisValue.Value; } } markerIntervalD = Convert.ToInt32(markerIntervalD / roundingValue) * roundingValue; var markerIntervalM = Me.ToM(markerIntervalD, metric); // from display back to metre for (var ipos = 1; ipos <= numberOfMarkers; ipos++) { var actDistanceM = markerIntervalM * ipos; if (actDistanceM < maxDistance) { var itemOffset = Convert.ToInt32(actDistanceM * distanceFactor); var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; var distanceString = FormatStrings.FormatDistanceDisplay(actDistanceM, metric); Font.Draw(spriteBatch, new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]), distanceString, Color.White); } } return(markerIntervalM); }
// draw signal information int drawSignal(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, int firstLabelPosition, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem, ref bool signalShown, ref bool firstLabelShown) { var displayItem = SignalMarkers[thisItem.SignalState]; var newLabelPosition = lastLabelPosition; var displayRequired = false; var itemLocation = 0; var itemOffset = 0; var maxDisplayDistance = maxDistance - (textSpacing / 2) / distanceFactor; if (thisItem.DistanceToTrainM < maxDisplayDistance) { itemOffset = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor); itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; displayRequired = true; signalShown = true; } else if (!signalShown) { itemOffset = 2 * startObjectArea; itemLocation = forward ? startObjectArea : endObjectArea; displayRequired = true; signalShown = true; } if (displayRequired) { spriteBatch.Draw(SignalAspects, new Rectangle(offset.X + signalPosition[0], offset.Y + itemLocation + signalPosition[forward ? 1 : 2], signalPosition[3], signalPosition[4]), displayItem, Color.White); if (thisItem.SignalState != TrackMonitorSignalAspect.Stop && thisItem.AllowedSpeedMpS > 0) { var labelPoint = new Point(offset.X + speedTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]); var speedString = FormatStrings.FormatSpeedLimit(thisItem.AllowedSpeedMpS, metric); Font.Draw(spriteBatch, labelPoint, speedString, Color.White); } if ((itemOffset < firstLabelPosition && !firstLabelShown) || thisItem.DistanceToTrainM > maxDisplayDistance) { var labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]); var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric); Font.Draw(spriteBatch, labelPoint, distanceString, Color.White); firstLabelShown = true; } } return(newLabelPosition); }
// draw authority information void drawAuthority(SpriteBatch spriteBatch,Point offset,int startObjectArea,int endObjectArea,int zeroPoint,float maxDistance,float distanceFactor,int firstLabelPosition,bool forward,int lastLabelPosition,Train.TrainObjectItem thisItem,ref bool firstLabelShown) { var displayItem = new Rectangle(0, 0, 0, 0); var displayRequired = false; var offsetArray = new int[0]; if (thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_AUTHORITY || thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_PATH || thisItem.AuthorityType == Train.END_AUTHORITY.END_OF_TRACK || thisItem.AuthorityType == Train.END_AUTHORITY.RESERVED_SWITCH || thisItem.AuthorityType == Train.END_AUTHORITY.LOOP) { displayItem = endAuthoritySprite; offsetArray = endAuthorityPosition; displayRequired = true; } else if (thisItem.AuthorityType == Train.END_AUTHORITY.TRAIN_AHEAD) { displayItem = forward ? oppositeTrainForwardSprite : oppositeTrainBackwardSprite; offsetArray = otherTrainPosition; displayRequired = true; } if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor) && displayRequired) { var itemOffset = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor); var itemLocation = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset; spriteBatch.Draw(TrackMonitorImages,new Rectangle(offset.X + offsetArray[0],offset.Y + itemLocation + offsetArray[forward ? 1 : 2],offsetArray[3],offsetArray[4]), displayItem, Color.White); if (itemOffset < firstLabelPosition && !firstLabelShown) { var labelPoint = new Point(offset.X + distanceTextOffset, offset.Y + itemLocation + textOffset[forward ? 0 : 1]); var distanceString = FormatStrings.FormatDistanceDisplay(thisItem.DistanceToTrainM, metric); Font.Draw(spriteBatch, labelPoint, distanceString, Color.White); firstLabelShown = true; } } }
public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull) { base.PrepareFrame(elapsedTime, updateFull); if (updateFull) { CurrentTime.Text = FormatStrings.FormatTime(Owner.Viewer.Simulator.ClockTime); Activity act = Owner.Viewer.Simulator.ActivityRun; Train playerTrain = Owner.Viewer.Simulator.PlayerLocomotive.Train; if (playerTrain.Delay.HasValue) { CurrentDelay.Text = Viewer.Catalog.GetPluralStringFmt("Current Delay: {0} minute", "Current Delay: {0} minutes", (long)playerTrain.Delay.Value.TotalMinutes); } else { CurrentDelay.Text = ""; } bool metric = Owner.Viewer.MilepostUnitsMetric; bool InfoAvail = false; ActivityTaskPassengerStopAt at = null; ActivityTaskPassengerStopAt Current = null; // timetable information if (playerTrain.CheckStations) { TTTrain playerTimetableTrain = playerTrain as TTTrain; // train name StationPlatform.Text = String.Concat(playerTimetableTrain.Name.Substring(0, Math.Min(playerTimetableTrain.Name.Length, 20))); if (playerTimetableTrain.ControlMode == Train.TRAIN_CONTROL.INACTIVE || playerTimetableTrain.MovementState == Simulation.AIs.AITrain.AI_MOVEMENT_STATE.AI_STATIC) { // no info available StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; bool validMessage = false; if (playerTimetableTrain.NeedAttach != null && playerTimetableTrain.NeedAttach.ContainsKey(-1)) { List <int> attachTrains = playerTimetableTrain.NeedAttach[-1]; TTTrain otherTrain = playerTimetableTrain.GetOtherTTTrainByNumber(attachTrains[0]); if (otherTrain == null) { if (playerTimetableTrain.Simulator.AutoGenDictionary.ContainsKey(attachTrains[0])) { otherTrain = playerTimetableTrain.Simulator.AutoGenDictionary[attachTrains[0]] as TTTrain; } } if (otherTrain == null) { Message.Text = Viewer.Catalog.GetString("Waiting for train to attach"); Message.Color = Color.Orange; validMessage = true; } else { Message.Text = String.Concat(Viewer.Catalog.GetString("Waiting for train to attach : "), otherTrain.Name); Message.Color = Color.Orange; validMessage = true; } } if (!validMessage && playerTimetableTrain.NeedTrainTransfer.Count > 0) { foreach (TrackCircuitSection occSection in playerTimetableTrain.OccupiedTrack) { if (playerTimetableTrain.NeedTrainTransfer.ContainsKey(occSection.Index)) { Message.Text = Viewer.Catalog.GetString("Waiting for transfer"); Message.Color = Color.Orange; break; } } } if (!validMessage) { Message.Color = Color.White; if (playerTimetableTrain.ActivateTime.HasValue) { DateTime activateDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.ActivateTime.Value)); if (playerTimetableTrain.ControlMode == Train.TRAIN_CONTROL.INACTIVE) { Message.Text = Viewer.Catalog.GetString("Train inactive."); } else if (playerTimetableTrain.MovementState == Simulation.AIs.AITrain.AI_MOVEMENT_STATE.AI_STATIC) { Message.Text = Viewer.Catalog.GetString("Train static."); } else { Message.Text = Viewer.Catalog.GetString("Train not active."); } // set activation message or time if (playerTimetableTrain.TriggeredActivationRequired) { Message.Text = String.Concat(Message.Text, Viewer.Catalog.GetString(" Activated by other train.")); } else { Message.Text = String.Concat(Message.Text, Viewer.Catalog.GetString(" Activation time : "), activateDT.ToString("HH:mm:ss")); } } else { Message.Text = Viewer.Catalog.GetString("Train has terminated."); } } } else { // previous stop if (playerTimetableTrain.PreviousStop == null) { StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; } else { StationPreviousName.Text = playerTimetableTrain.PreviousStop.PlatformItem.Name; StationPreviousArriveScheduled.Text = playerTimetableTrain.PreviousStop.arrivalDT.ToString("HH:mm:ss"); if (playerTimetableTrain.PreviousStop.ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.PreviousStop.ActualArrival)); StationPreviousArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationPreviousArriveActual.Color = actArrDT < playerTimetableTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; DateTime actDepDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.PreviousStop.ActualDepart)); StationPreviousDepartActual.Text = actDepDT.ToString("HH:mm:ss"); StationPreviousDepartActual.Color = actDepDT > playerTimetableTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationPreviousArriveActual.Text = Viewer.Catalog.GetString("(missed)"); StationPreviousArriveActual.Color = Color.LightSalmon; StationPreviousDepartActual.Text = ""; } StationPreviousDepartScheduled.Text = playerTimetableTrain.PreviousStop.departureDT.ToString("HH:mm:ss"); StationPreviousDistance.Text = ""; } if (playerTimetableTrain.StationStops == null || playerTimetableTrain.StationStops.Count == 0) { StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; Message.Text = Viewer.Catalog.GetString("No more stations."); Message.Color = Color.White; } else { StationCurrentName.Text = playerTimetableTrain.StationStops[0].PlatformItem.Name; StationCurrentArriveScheduled.Text = playerTimetableTrain.StationStops[0].arrivalDT.ToString("HH:mm:ss"); if (playerTimetableTrain.StationStops[0].ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.StationStops[0].ActualArrival)); StationCurrentArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationCurrentArriveActual.Color = actArrDT < playerTimetableTrain.StationStops[0].arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationCurrentArriveActual.Text = ""; } StationCurrentDepartScheduled.Text = playerTimetableTrain.StationStops[0].departureDT.ToString("HH:mm:ss"); StationCurrentDistance.Text = FormatStrings.FormatDistanceDisplay(playerTimetableTrain.StationStops[0].DistanceToTrainM, metric); Message.Text = playerTimetableTrain.DisplayMessage; Message.Color = playerTimetableTrain.DisplayColor; if (playerTimetableTrain.StationStops.Count >= 2) { StationNextName.Text = playerTimetableTrain.StationStops[1].PlatformItem.Name; StationNextArriveScheduled.Text = playerTimetableTrain.StationStops[1].arrivalDT.ToString("HH:mm:ss"); StationNextDepartScheduled.Text = playerTimetableTrain.StationStops[1].departureDT.ToString("HH:mm:ss"); StationNextDistance.Text = ""; } else { StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; } } // check transfer details bool transferValid = false; string TransferMessage = String.Empty; if (playerTimetableTrain.TransferStationDetails != null && playerTimetableTrain.TransferStationDetails.Count > 0 && playerTimetableTrain.StationStops != null && playerTimetableTrain.StationStops.Count > 0) { if (playerTimetableTrain.TransferStationDetails.ContainsKey(playerTimetableTrain.StationStops[0].PlatformReference)) { TransferInfo thisTransfer = playerTimetableTrain.TransferStationDetails[playerTimetableTrain.StationStops[0].PlatformReference]; TransferMessage = Viewer.Catalog.GetString("Transfer units at next station with train "); TransferMessage = String.Concat(TransferMessage, thisTransfer.TransferTrainName); transferValid = true; } } else if (playerTimetableTrain.TransferTrainDetails != null && playerTimetableTrain.TransferTrainDetails.Count > 0) { foreach (KeyValuePair <int, List <TransferInfo> > transferDetails in playerTimetableTrain.TransferTrainDetails) { TransferInfo thisTransfer = transferDetails.Value[0]; TransferMessage = Viewer.Catalog.GetString("Transfer units with train "); TransferMessage = String.Concat(TransferMessage, thisTransfer.TransferTrainName); transferValid = true; break; // only show first } } // general details if (playerTimetableTrain.AttachDetails != null && playerTimetableTrain.AttachDetails.Valid) { Message.Text = Viewer.Catalog.GetString("Train is to attach to : "); Message.Text = String.Concat(Message.Text, playerTimetableTrain.AttachDetails.AttachTrainName); Message.Color = Color.Orange; } else if (playerTimetableTrain.AttachDetails != null) { Message.Text = Viewer.Catalog.GetString("Train is to attach to : "); Message.Text = String.Concat(Message.Text, playerTimetableTrain.AttachDetails.AttachTrainName); Message.Text = String.Concat(Message.Text, Viewer.Catalog.GetString(" ; other train not yet ready")); Message.Color = Color.Orange; } else if (playerTimetableTrain.PickUpStaticOnForms) { Message.Text = Viewer.Catalog.GetString("Train is to pickup train at end of path"); Message.Color = Color.Orange; } else if (playerTimetableTrain.NeedPickUp) { Message.Text = Viewer.Catalog.GetString("Pick up train ahead"); Message.Color = Color.Orange; } else if (transferValid) { Message.Text = String.Copy(TransferMessage); Message.Color = Color.Orange; } else if (playerTimetableTrain.NeedTransfer) { Message.Text = Viewer.Catalog.GetString("Transfer units with train ahead"); Message.Color = Color.Orange; } } } // activity mode - switched train else if (!Owner.Viewer.Simulator.TimetableMode && playerTrain != Owner.Viewer.Simulator.OriginalPlayerTrain) { // train name StationPlatform.Text = String.Concat(playerTrain.Name.Substring(0, Math.Min(playerTrain.Name.Length, 20))); if (playerTrain.ControlMode == Train.TRAIN_CONTROL.INACTIVE) { // no info available StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; Message.Text = Viewer.Catalog.GetString("Train not active."); Message.Color = Color.White; if (playerTrain.GetType() == typeof(TTTrain)) { TTTrain playerTimetableTrain = playerTrain as TTTrain; if (playerTimetableTrain.ActivateTime.HasValue) { DateTime activateDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.ActivateTime.Value)); Message.Text = String.Concat(Message.Text, Viewer.Catalog.GetString(" Activation time : "), activateDT.ToString("HH:mm:ss")); } } } else { // previous stop if (playerTrain.PreviousStop == null) { StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; } else { StationPreviousName.Text = playerTrain.PreviousStop.PlatformItem.Name; StationPreviousArriveScheduled.Text = playerTrain.PreviousStop.arrivalDT.ToString("HH:mm:ss"); if (playerTrain.PreviousStop.ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.PreviousStop.ActualArrival)); StationPreviousArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationPreviousArriveActual.Color = actArrDT < playerTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; DateTime actDepDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.PreviousStop.ActualDepart)); StationPreviousDepartActual.Text = actDepDT.ToString("HH:mm:ss"); StationPreviousDepartActual.Color = actDepDT > playerTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationPreviousArriveActual.Text = Viewer.Catalog.GetString("(missed)"); StationPreviousArriveActual.Color = Color.LightSalmon; StationPreviousDepartActual.Text = ""; } StationPreviousDepartScheduled.Text = playerTrain.PreviousStop.departureDT.ToString("HH:mm:ss"); StationPreviousDistance.Text = ""; } if (playerTrain.StationStops == null || playerTrain.StationStops.Count == 0) { StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; Message.Text = Viewer.Catalog.GetString("No more stations."); } else { StationCurrentName.Text = playerTrain.StationStops[0].PlatformItem.Name; StationCurrentArriveScheduled.Text = playerTrain.StationStops[0].arrivalDT.ToString("HH:mm:ss"); if (playerTrain.StationStops[0].ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.StationStops[0].ActualArrival)); StationCurrentArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationCurrentArriveActual.Color = actArrDT < playerTrain.StationStops[0].arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationCurrentArriveActual.Text = ""; } StationCurrentDepartScheduled.Text = playerTrain.StationStops[0].departureDT.ToString("HH:mm:ss"); StationCurrentDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); Message.Text = playerTrain.DisplayMessage; Message.Color = playerTrain.DisplayColor; if (playerTrain.StationStops.Count >= 2) { StationNextName.Text = playerTrain.StationStops[1].PlatformItem.Name; StationNextArriveScheduled.Text = playerTrain.StationStops[1].arrivalDT.ToString("HH:mm:ss"); StationNextDepartScheduled.Text = playerTrain.StationStops[1].departureDT.ToString("HH:mm:ss"); StationNextDistance.Text = ""; } else { StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; } } } } // activity information if (act != null && playerTrain == Owner.Viewer.Simulator.OriginalPlayerTrain) { Current = act.Current == null ? act.Last as ActivityTaskPassengerStopAt : act.Current as ActivityTaskPassengerStopAt; at = Current != null ? Current.PrevTask as ActivityTaskPassengerStopAt : null; InfoAvail = true; } if (InfoAvail) { if (at != null) { StationPreviousName.Text = at.PlatformEnd1.Station; StationPreviousArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationPreviousArriveActual.Text = at.ActArrive.HasValue ? at.ActArrive.Value.ToString("HH:mm:ss") : Viewer.Catalog.GetString("(missed)"); StationPreviousArriveActual.Color = GetArrivalColor(at.SchArrive, at.ActArrive); StationPreviousDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); StationPreviousDepartActual.Text = at.ActDepart.HasValue ? at.ActDepart.Value.ToString("HH:mm:ss") : Viewer.Catalog.GetString("(missed)"); StationPreviousDepartActual.Color = GetDepartColor(at.SchDepart, at.ActDepart); StationPreviousDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationPreviousName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationPreviousDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; } at = Current; if (at != null) { StationPlatform.Text = at.PlatformEnd1.ItemName; StationCurrentName.Text = at.PlatformEnd1.Station; StationCurrentArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationCurrentArriveActual.Text = at.ActArrive.HasValue ? at.ActArrive.Value.ToString("HH:mm:ss") : ""; StationCurrentArriveActual.Color = GetArrivalColor(at.SchArrive, at.ActArrive); StationCurrentDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); Message.Color = at.DisplayColor; Message.Text = at.DisplayMessage; StationCurrentDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationCurrentName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationCurrentDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationPlatform.Text = ""; StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; Message.Text = ""; } at = Current != null ? Current.NextTask as ActivityTaskPassengerStopAt : null; if (at != null) { StationNextName.Text = at.PlatformEnd1.Station; StationNextArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationNextDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); StationNextDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationNextName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationNextDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; } if (act != null && act.IsComplete) { Message.Text = Viewer.Catalog.GetString("Activity completed."); } } } }
public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull) { base.PrepareFrame(elapsedTime, updateFull); if (updateFull) { CurrentTime.Text = FormatStrings.FormatTime(Owner.Viewer.Simulator.ClockTime); Activity act = Owner.Viewer.Simulator.ActivityRun; Train playerTrain = Owner.Viewer.Simulator.PlayerLocomotive.Train; if (playerTrain.Delay.HasValue) { CurrentDelay.Text = Viewer.Catalog.GetPluralStringFmt("Current Delay: {0} minute", "Current Delay: {0} minutes", (long)playerTrain.Delay.Value.TotalMinutes); } else { CurrentDelay.Text = ""; } bool metric = Owner.Viewer.MilepostUnitsMetric; bool InfoAvail = false; ActivityTaskPassengerStopAt at = null; ActivityTaskPassengerStopAt Current = null; // timetable information if (playerTrain.CheckStations || (!Owner.Viewer.Simulator.TimetableMode && playerTrain != Owner.Viewer.Simulator.OriginalPlayerTrain)) { // train name StationPlatform.Text = String.Concat(playerTrain.Name.Substring(0, Math.Min(playerTrain.Name.Length, 20))); if (playerTrain.ControlMode == Train.TRAIN_CONTROL.INACTIVE) { // no info available StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; Message.Text = "Train not active."; Message.Color = Color.White; if (playerTrain.GetType() == typeof(TTTrain)) { TTTrain playerTimetableTrain = playerTrain as TTTrain; if (playerTimetableTrain.ActivateTime.HasValue) { DateTime activateDT = new DateTime((long)(Math.Pow(10, 7) * playerTimetableTrain.ActivateTime.Value)); Message.Text = String.Concat(Message.Text, " Activation time : ", activateDT.ToString("HH:mm:ss")); } } } else { // previous stop if (playerTrain.PreviousStop == null) { StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; } else { StationPreviousName.Text = playerTrain.PreviousStop.PlatformItem.Name; StationPreviousArriveScheduled.Text = playerTrain.PreviousStop.arrivalDT.ToString("HH:mm:ss"); if (playerTrain.PreviousStop.ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.PreviousStop.ActualArrival)); StationPreviousArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationPreviousArriveActual.Color = actArrDT < playerTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; DateTime actDepDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.PreviousStop.ActualDepart)); StationPreviousDepartActual.Text = actDepDT.ToString("HH:mm:ss"); StationPreviousDepartActual.Color = actDepDT > playerTrain.PreviousStop.arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationPreviousArriveActual.Text = Viewer.Catalog.GetString("(missed)"); StationPreviousArriveActual.Color = Color.LightSalmon; StationPreviousDepartActual.Text = ""; } StationPreviousDepartScheduled.Text = playerTrain.PreviousStop.departureDT.ToString("HH:mm:ss"); StationPreviousDistance.Text = ""; } if (playerTrain.StationStops == null || playerTrain.StationStops.Count == 0) { StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; Message.Text = Viewer.Catalog.GetString("No more stations."); } else { StationCurrentName.Text = playerTrain.StationStops[0].PlatformItem.Name; StationCurrentArriveScheduled.Text = playerTrain.StationStops[0].arrivalDT.ToString("HH:mm:ss"); if (playerTrain.StationStops[0].ActualArrival >= 0) { DateTime actArrDT = new DateTime((long)(Math.Pow(10, 7) * playerTrain.StationStops[0].ActualArrival)); StationCurrentArriveActual.Text = actArrDT.ToString("HH:mm:ss"); StationCurrentArriveActual.Color = actArrDT < playerTrain.StationStops[0].arrivalDT ? Color.LightGreen : Color.LightSalmon; } else { StationCurrentArriveActual.Text = ""; } StationCurrentDepartScheduled.Text = playerTrain.StationStops[0].departureDT.ToString("HH:mm:ss"); StationCurrentDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); Message.Text = playerTrain.DisplayMessage; Message.Color = playerTrain.DisplayColor; if (playerTrain.StationStops.Count >= 2) { StationNextName.Text = playerTrain.StationStops[1].PlatformItem.Name; StationNextArriveScheduled.Text = playerTrain.StationStops[1].arrivalDT.ToString("HH:mm:ss"); StationNextDepartScheduled.Text = playerTrain.StationStops[1].departureDT.ToString("HH:mm:ss"); StationNextDistance.Text = ""; } else { StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; } } } } // activity information if (act != null && playerTrain == Owner.Viewer.Simulator.OriginalPlayerTrain) { Current = act.Current == null ? act.Last as ActivityTaskPassengerStopAt : act.Current as ActivityTaskPassengerStopAt; at = Current != null ? Current.PrevTask as ActivityTaskPassengerStopAt : null; InfoAvail = true; } if (InfoAvail) { if (at != null) { StationPreviousName.Text = at.PlatformEnd1.Station; StationPreviousArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationPreviousArriveActual.Text = at.ActArrive.HasValue ? at.ActArrive.Value.ToString("HH:mm:ss") : Viewer.Catalog.GetString("(missed)"); StationPreviousArriveActual.Color = GetArrivalColor(at.SchArrive, at.ActArrive); StationPreviousDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); StationPreviousDepartActual.Text = at.ActDepart.HasValue ? at.ActDepart.Value.ToString("HH:mm:ss") : Viewer.Catalog.GetString("(missed)"); StationPreviousDepartActual.Color = GetDepartColor(at.SchDepart, at.ActDepart); StationPreviousDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationPreviousName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationPreviousDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationPreviousName.Text = ""; StationPreviousArriveScheduled.Text = ""; StationPreviousArriveActual.Text = ""; StationPreviousDepartScheduled.Text = ""; StationPreviousDepartActual.Text = ""; StationPreviousDistance.Text = ""; } at = Current; if (at != null) { StationPlatform.Text = at.PlatformEnd1.ItemName; StationCurrentName.Text = at.PlatformEnd1.Station; StationCurrentArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationCurrentArriveActual.Text = at.ActArrive.HasValue ? at.ActArrive.Value.ToString("HH:mm:ss") : ""; StationCurrentArriveActual.Color = GetArrivalColor(at.SchArrive, at.ActArrive); StationCurrentDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); Message.Color = at.DisplayColor; Message.Text = at.DisplayMessage; StationCurrentDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationCurrentName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationCurrentDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationPlatform.Text = ""; StationCurrentName.Text = ""; StationCurrentArriveScheduled.Text = ""; StationCurrentArriveActual.Text = ""; StationCurrentDepartScheduled.Text = ""; StationCurrentDistance.Text = ""; Message.Text = ""; } at = Current != null ? Current.NextTask as ActivityTaskPassengerStopAt : null; if (at != null) { StationNextName.Text = at.PlatformEnd1.Station; StationNextArriveScheduled.Text = at.SchArrive.ToString("HH:mm:ss"); StationNextDepartScheduled.Text = at.SchDepart.ToString("HH:mm:ss"); StationNextDistance.Text = ""; if (playerTrain.StationStops.Count > 0 && playerTrain.StationStops[0].PlatformItem != null && String.Compare(playerTrain.StationStops[0].PlatformItem.Name, StationNextName.Text) == 0 && playerTrain.StationStops[0].DistanceToTrainM > 0) { StationNextDistance.Text = FormatStrings.FormatDistanceDisplay(playerTrain.StationStops[0].DistanceToTrainM, metric); } } else { StationNextName.Text = ""; StationNextArriveScheduled.Text = ""; StationNextDepartScheduled.Text = ""; StationNextDistance.Text = ""; } if (act != null && act.IsComplete) { Message.Text = Viewer.Catalog.GetString("Activity completed."); } } } }