예제 #1
0
        // 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);
        }
예제 #2
0
        // 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);
        }
예제 #3
0
        // draw station stop information
        int drawStation(SpriteBatch spriteBatch, Point offset, int startObjectArea, int endObjectArea, int zeroPoint, float maxDistance, float distanceFactor, float firstLabelDistance, bool forward, int lastLabelPosition, Train.TrainObjectItem thisItem)
        {
            var displayItem      = stationSprite;
            var newLabelPosition = lastLabelPosition;

            if (thisItem.DistanceToTrainM < (maxDistance - textSpacing / distanceFactor))
            {
                var itemOffset      = Convert.ToInt32(thisItem.DistanceToTrainM * distanceFactor);
                var itemLocation    = forward ? zeroPoint - itemOffset : zeroPoint + itemOffset;
                var startOfPlatform = (int)Math.Max(stationPosition[4], thisItem.StationPlatformLength * distanceFactor);
                var markerPlacement = new Rectangle(offset.X + stationPosition[0], offset.Y + itemLocation + stationPosition[forward ? 1 : 2], stationPosition[3], startOfPlatform);
                spriteBatch.Draw(TrackMonitorImages, markerPlacement, displayItem, Color.White);
            }

            return(newLabelPosition);
        }
예제 #4
0
        // 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);
        }
예제 #5
0
        // 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);
        }
예제 #6
0
        // 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;
                }
            }
        }