コード例 #1
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);
        }
コード例 #2
0
        public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
        {
            base.PrepareFrame(elapsedTime, updateFull);

            // Always get train details to pass on to TrackMonitor.
            var thisInfo = Owner.Viewer.PlayerTrain.GetTrainInfo();

            Monitor.StoreInfo(thisInfo);

            // Update text fields on full update only.
            if (updateFull)
            {
                SpeedCurrent.Text   = FormatStrings.FormatSpeedDisplay(Math.Abs(thisInfo.speedMpS), Owner.Viewer.MilepostUnitsMetric);
                SpeedProjected.Text = FormatStrings.FormatSpeedDisplay(Math.Abs(thisInfo.projectedSpeedMpS), Owner.Viewer.MilepostUnitsMetric);
                SpeedAllowed.Text   = FormatStrings.FormatSpeedLimit(thisInfo.allowedSpeedMpS, Owner.Viewer.MilepostUnitsMetric);

                var ControlText = ControlModeLabels[thisInfo.ControlMode];
                if (thisInfo.ControlMode == Train.TRAIN_CONTROL.AUTO_NODE)
                {
                    ControlText = FindAuthorityInfo(thisInfo.ObjectInfoForward, ControlText);
                }
                else if (thisInfo.ControlMode == Train.TRAIN_CONTROL.OUT_OF_CONTROL)
                {
                    ControlText = String.Concat(ControlText, OutOfControlLabels[thisInfo.ObjectInfoForward[0].OutOfControlReason]);
                }
                ControlMode.Text = String.Copy(ControlText);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// Checks if on trough. If not, tell that the scoop is destroyed; else, starts refilling
        /// </summary>
        public void AttemptToRefillFromTrough()
        {
            if (!SteamLocomotive.HasWaterScoop)
            {
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.Warning, Viewer.Catalog.GetString("No scoop in this loco"));
                return;
            }
            if (SteamLocomotive.ScoopIsBroken)
            {
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.Error, Viewer.Catalog.GetString("Scoop is broken, can't refill"));
                return;
            }
            if (!SteamLocomotive.IsOverTrough())
            {
                // Bad thing, scoop gets broken!
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.Error, Viewer.Catalog.GetString("Scoop broken because activated outside through"));
                return;
            }
            if (SteamLocomotive.SpeedMpS < SteamLocomotive.ScoopMinPickupSpeedMpS)
            {
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Refill: Loco speed must exceed {0}.",
                                                                                                  FormatStrings.FormatSpeedLimit(SteamLocomotive.ScoopMinPickupSpeedMpS, Viewer.MilepostUnitsMetric)));
                return;
            }
            if (SteamLocomotive.SpeedMpS > SteamLocomotive.ScoopMaxPickupSpeedMpS)
            {
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Refill: Loco speed must not exceed {0}.",
                                                                                                  FormatStrings.FormatSpeedLimit(SteamLocomotive.ScoopMaxPickupSpeedMpS, Viewer.MilepostUnitsMetric)));
                return;
            }
            var fraction = SteamLocomotive.GetFilledFraction((uint)MSTSWagon.PickupType.FuelWater);

            if (fraction > 0.99)
            {
                Viewer.Simulator.Confirmer.Message(ConfirmLevel.None, Viewer.Catalog.GetStringFmt("Refill: {0} supply now replenished.",
                                                                                                  PickupTypeDictionary[(uint)MSTSWagon.PickupType.FuelWater]));
                return;
            }
            else
            {
                MSTSWagon.RefillProcess.OkToRefill            = true;
                MSTSWagon.RefillProcess.ActivePickupObjectUID = -1;
                SteamLocomotive.RefillingFromTrough           = true;
                SteamLocomotive.SignalEvent(Event.WaterScoopDown);
                StartRefilling((uint)MSTSWagon.PickupType.FuelWater, fraction);
            }
        }