Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (Animation)
            {
                var currentLength = Owner.Viewer.RealTime - AnimationStart;
                if (currentLength > AnimationLength)
                {
                    currentLength = AnimationLength;
                }

                var fade = 1.0f;
                if (currentLength < AnimationFade)
                {
                    fade = (float)(currentLength / AnimationFade);
                }
                else if (currentLength > AnimationLength - AnimationFade)
                {
                    fade = (float)((currentLength - AnimationLength) / -AnimationFade);
                }

                var color     = new Color(Color.White.R / 255f, Color.White.G / 255f, Color.White.B / 255f, fade);
                var rectangle = new Rectangle((int)(Location.Width * LocationX), (int)(Location.Height * LocationY), 0, 0);
                rectangle.Inflate(NoticeSize.X / 2 + (int)(NoticeSize.Y * PaddingX), NoticeSize.Y / 2 + (int)(NoticeSize.Y * PaddingY));
                spriteBatch.Draw(WindowManager.NoticeTexture, rectangle, color);
                rectangle.Inflate(-(int)(NoticeSize.Y * PaddingX), -(int)(NoticeSize.Y * PaddingY));
                Font.Draw(spriteBatch, rectangle, Point.Zero, NoticeText, LabelAlignment.Center, color);
            }
        }
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (Visible)
     {
         spriteBatch.Draw(WindowManager.WhiteTexture, Position2D, null, Color, 0, Vector2.Zero, new Vector2(1, LabelOffset), SpriteEffects.None, 0);
         Font.Draw(spriteBatch, Position2DText, Text, Color);
     }
 }
Esempio n. 4
0
 internal override void Draw(SpriteBatch spriteBatch, Point offset)
 {
     DrawnLines = Lines.ToArray();
     foreach (var line in DrawnLines)
     {
         Font.Draw(spriteBatch, Position, offset, line, LabelAlignment.Left, Color);
         offset.Y += Font.Height;
     }
 }
Esempio n. 5
0
        internal override void Draw(SpriteBatch spriteBatch, Point offset)
        {
            if (CompassTexture == null)
            {
                CompassTexture = new Texture2D(spriteBatch.GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color);
                CompassTexture.SetData(new[] { Color.White });
            }
            if (HeadingHalfWidths == null)
            {
                HeadingHalfWidths = new int[12];
                for (var i = 0; i < 12; i++)
                {
                    HeadingHalfWidths[i] = Font.MeasureString((i * 30).ToString()) / 2;
                }
            }
            const int headingScale = 2;
            var       height       = (int)((Position.Height - Font.Height) / 3);

            for (float heading = 0; heading < 360; heading += 10)
            {
                var x = Position.Width / 2 + (int)(((heading - Heading + 360 + 180) % 360 - 180) * headingScale);
                if ((x >= 0) && (x < Position.Width))
                {
                    if (heading % 30 == 0)
                    {
                        var textHalfWidth = HeadingHalfWidths[(int)heading / 30];
                        if ((x - textHalfWidth >= 0) && (x + textHalfWidth < Position.Width))
                        {
                            Font.Draw(spriteBatch, new Point(offset.X + Position.X + x - textHalfWidth, offset.Y + Position.Y), heading.ToString(), Color.White);
                        }
                        spriteBatch.Draw(CompassTexture, new Rectangle(offset.X + Position.X + x, offset.Y + Position.Y + Font.Height, 1, height * 2), Color.White);
                    }
                    else
                    {
                        spriteBatch.Draw(CompassTexture, new Rectangle(offset.X + Position.X + x, offset.Y + Position.Y + Font.Height, 1, height), Color.White);
                    }
                }
            }
            spriteBatch.Draw(CompassTexture, new Rectangle(offset.X + Position.X + Position.Width / 2, offset.Y + Position.Bottom - height, 1, height), Color.White);
        }
Esempio n. 6
0
 internal override void Draw(SpriteBatch spriteBatch, Point offset)
 {
     Font.Draw(spriteBatch, Position, offset, Text, Align, Color);
 }