/// <summary>
        /// Create user interface renderer
        /// </summary>
        public UIRenderer()
        {
            background = new Texture("background");
            buttons    = new Texture("buttons");
            headers    = new Texture("headers");
#if XBOX360
            helpScreen    = new Texture("HelpScreenXbox360.png");
            optionsScreen = new Texture("OptionsScreenXbox360.png");
#else
            helpScreen    = new Texture("HelpScreenWindows");
            optionsScreen = new Texture("OptionsScreenWindows");
#endif
            mouseCursor = new Texture("MouseCursor");
            ingame      = new Texture("ingame");
            trophies[0] = new Texture("pokal1");
            trophies[1] = new Texture("pokal2");
            trophies[2] = new Texture("pokal3");
            font        = new TextureFont();

            // TODO postScreenMenuShader = new PostScreenMenu();
            // TODO postScreenGameShader = new PostScreenGlow();
            // TODO skyCube = new PreScreenSkyCubeMapping();
            lensFlare = new LensFlare(LensFlare.DefaultSunPos);
            BaseGame.LightDirection = LensFlare.DefaultLightPos;
        }
        /// <summary>
        /// Render all time fadeup effects, move them up and fade them out.
        /// </summary>
        public void RenderTimeFadeupEffects()
        {
            for (int num = 0; num < fadeupTexts.Count; num++)
            {
                TimeFadeupText fadeupText = fadeupTexts[num];
                fadeupText.showTimeMs -= BaseGame.ElapsedTimeThisFrameInMilliseconds;
                if (fadeupText.showTimeMs < 0)
                {
                    fadeupTexts.Remove(fadeupText);
                    num--;
                }
                else
                {
                    // Fade out
                    float alpha = 1.0f;
                    if (fadeupText.showTimeMs < 1500)
                    {
                        alpha = fadeupText.showTimeMs / 1500.0f;
                    }
                    // Move up
                    float moveUpAmount =
                        (TimeFadeupText.MaxShowTimeMs - fadeupText.showTimeMs) /
                        TimeFadeupText.MaxShowTimeMs;

                    // Calculate screen position
                    TextureFont.WriteTextCentered(BaseGame.Width / 2,
                                                  BaseGame.Height / 3 - (int)(moveUpAmount * BaseGame.Height / 3),
                                                  fadeupText.text,
                                                  ColorHelper.ApplyAlphaToColor(fadeupText.color, alpha),
                                                  2.25f);
                }
            }
        }
        /// <summary>
        /// Create user interface renderer
        /// </summary>
        public UIRenderer()
        {
            background = new Texture("background.png");
            buttons    = new Texture("buttons.png");
            headers    = new Texture("headers.png");
#if XBOX360
            helpScreen    = new Texture("HelpScreenXbox360.png");
            optionsScreen = new Texture("OptionsScreenXbox360.png");
#else
            helpScreen    = new Texture("HelpScreenWindows.png");
            optionsScreen = new Texture("OptionsScreenWindows.png");
#endif
            mouseCursor = new Texture("MouseCursor.png");
            ingame      = new Texture("Ingame.png");
            trophies[0] = new Texture("pokal1");
            trophies[1] = new Texture("pokal2");
            trophies[2] = new Texture("pokal3");
            font        = new TextureFont();

            postScreenMenuShader = new PostScreenMenu();
            postScreenGameShader = new PostScreenGlow();
            skyCube   = new PreScreenSkyCubeMapping();
            lensFlare = new LensFlare(LensFlare.DefaultSunPos);
            BaseGame.LightDirection = LensFlare.DefaultLightPos;

            nameBatch = new SpriteBatch(RacingGameManager.graphicsManager.GraphicsDevice);
            nameFont  = RacingGameManager.Content.Load <SpriteFont>("Content\\NameFont");
        }
        /// <summary>
        /// Write text centered with scale factor
        /// </summary>
        /// <param name="x">X</param>
        /// <param name="y">Y</param>
        /// <param name="text">Text</param>
        /// <param name="color">Color</param>
        public static void WriteTextCentered(int x, int y, string text,
                                             Color color, float scale)
        {
            int width = TextureFont.GetTextWidth(text);

            remTexts.Add(new FontToRender(
                             x - (int)Math.Round(width * scale / 2),
                             y - (int)Math.Round(TextureFont.Height * scale / 2),
                             text, color, scale));
        }
        /// <summary>
        /// Create user interface renderer
        /// </summary>
        public UIRenderer()
        {
            background = new Texture("background.png");
            buttons    = new Texture("buttons.png");
            headers    = new Texture("headers.png");

            helpScreen    = new Texture("HelpScreenWindows.png");
            optionsScreen = new Texture("OptionsScreenWindows.png");

            mouseCursor = new Texture("MouseCursor.png");
            ingame      = new Texture("Ingame.png");
            trophies[0] = new Texture("pokal1");
            trophies[1] = new Texture("pokal2");
            trophies[2] = new Texture("pokal3");
            font        = new TextureFont();

            postScreenMenuShader = new PostScreenMenu();
            postScreenGameShader = new PostScreenGlow();
            skyCube   = new PreScreenSkyCubeMapping();
            lensFlare = new LensFlare(LensFlare.DefaultSunPos);
            BaseGame.LightDirection = LensFlare.DefaultLightPos;
        }
        /// <summary>
        /// Create user interface renderer
        /// </summary>
        public UIRenderer()
        {
            background = new Texture("background.png");
            buttons = new Texture("buttons.png");
            headers = new Texture("headers.png");
#if XBOX360
            helpScreen = new Texture("HelpScreenXbox360.png");
            optionsScreen = new Texture("OptionsScreenXbox360.png");
#else
            helpScreen = new Texture("HelpScreenWindows.png");
            optionsScreen = new Texture("OptionsScreenWindows.png");
#endif
            mouseCursor = new Texture("MouseCursor.png");
            ingame = new Texture("Ingame.png");
            trophies[0] = new Texture("pokal1");
            trophies[1] = new Texture("pokal2");
            trophies[2] = new Texture("pokal3");
            font = new TextureFont();

            postScreenMenuShader = new PostScreenMenu();
            postScreenGameShader = new PostScreenGlow();
            skyCube = new PreScreenSkyCubeMapping();
            lensFlare = new LensFlare(LensFlare.DefaultSunPos);
            BaseGame.LightDirection = LensFlare.DefaultLightPos;
        }
        /// <summary>
        /// Render game user interface
        /// </summary>
        /// <param name="currentGameTime">Current game time</param>
        /// <param name="bestLapTime">Best lap time</param>
        /// <param name="lapNumber">Lap number</param>
        /// <param name="speed">Speed</param>
        /// <param name="gear">Gear</param>
        /// <param name="trackName">Track name</param>
        /// <param name="top5LapTimes">Top 5 lap times</param>
        public void RenderGameUI(int currentGameTime, int bestLapTime,
                                 int lapNumber, float speed, int gear, float acceleration,
                                 string trackName, int[] top5LapTimes)
        {
            if (top5LapTimes == null)
            {
                throw new ArgumentNullException("top5LapTimes");
            }

            Color baseUIColor = Color.White;//ColorHelper.HalfAlpha;

            // If game is over, set speed, gear and acceleration to 0
            if (RacingGameManager.Player.GameOver)
            {
                speed        = 0;
                gear         = 1;
                acceleration = 0;
            }

            // More distance to the screen borders on the Xbox 360 to fit better into
            // the save region. Calculate all rectangles for each platform,
            // then they will be used the same way on both platforms.
#if XBOX360
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                60, 46, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                60, 46, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                60, 46, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                60, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                60, 46, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#else
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                10, 10, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                10, 10, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                10, 10, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                10, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                10, 10, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#endif

            // Rest can stay the same because we use the rectangles from now on
            ingame.RenderOnScreen(tachoRect, TachoGfxRect, baseUIColor);

            // Ok, now add the numbers, text and speed values
            TextureFontBigNumbers.WriteNumber(
                lapsRect.X + BaseGame.XToRes1600(15),
                lapsRect.Y + BaseGame.YToRes1200(12),
                lapNumber);

            // Current and best game times
            Color highlightColor = new Color(255, 185, 80);
            int   blockHeight    = BaseGame.YToRes1200(74);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + blockHeight / 2 - TextureFont.Height / 2,
                currentGameTime,
                highlightColor);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + timesRect.Height / 2 + blockHeight / 2 -
                TextureFont.Height / 2,
                bestLapTime,
                Color.White);

            // Track name
            TextureFont.WriteTextCentered(
                trackNameRect.X + trackNameRect.Width / 2,
                trackNameRect.Y + blockHeight / 2,
                trackName);

            // Top 5
            // Possible improvement: Show currentRank here (insert us)
            Color rankColor =
                bestLapTime == top5LapTimes[0] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect1.X + BaseGame.XToRes(32) / 2,
                top5Rect1.Y + blockHeight / 2,
                "1.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect1.X + BaseGame.XToRes(35 + 15),
                top5Rect1.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[0], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[1] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect2.X + BaseGame.XToRes(32) / 2,
                top5Rect2.Y + blockHeight / 2,
                "2.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect2.X + BaseGame.XToRes(35 + 15),
                top5Rect2.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[1], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[2] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect3.X + BaseGame.XToRes(32) / 2,
                top5Rect3.Y + blockHeight / 2,
                "3.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect3.X + BaseGame.XToRes(35 + 15),
                top5Rect3.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[2], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[3] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect4.X + BaseGame.XToRes(32) / 2,
                top5Rect4.Y + blockHeight / 2,
                "4.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect4.X + BaseGame.XToRes(35 + 15),
                top5Rect4.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[3], rankColor);

            rankColor =
                bestLapTime == top5LapTimes[4] ?
                highlightColor : Color.White;
            TextureFont.WriteTextCentered(
                top5Rect5.X + BaseGame.XToRes(32) / 2,
                top5Rect5.Y + blockHeight / 2,
                "5.", rankColor, 1.0f);
            TextureFont.WriteGameTime(
                top5Rect5.X + BaseGame.XToRes(35 + 15),
                top5Rect5.Y + blockHeight / 2 - TextureFont.Height / 2,
                top5LapTimes[4], rankColor);

            // Acceleration
            Point tachoPoint = new Point(
                tachoRect.X +
                BaseGame.XToRes1600(194),
                tachoRect.Y +
                BaseGame.YToRes1200(194));
            //ingame.RenderOnScreenWithRotation(
            //    tachoPoint, TachoArrowGfxRect, -acceleration*2);
            if (acceleration < 0)
            {
                acceleration = 0;
            }
            if (acceleration > 1)
            {
                acceleration = 1;
            }
            float   rotation         = -2.33f + acceleration * 2.5f;
            int     tachoArrowWidth  = BaseGame.XToRes1600(TachoArrowGfxRect.Width);
            int     tachoArrowHeight = BaseGame.YToRes1200(TachoArrowGfxRect.Height);
            Vector2 rotationPoint    = new Vector2(
                TachoArrowGfxRect.Width / 2,
                TachoArrowGfxRect.Height - 13);
            ingame.RenderOnScreenWithRotation(
                new Rectangle(tachoPoint.X, tachoPoint.Y,
                              tachoArrowWidth, tachoArrowHeight),
                TachoArrowGfxRect,
                rotation, rotationPoint);

            // Speed in mph
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoMphGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoMphGfxRect.Y),
                TachoMphGfxRect.Height,
                (int)Math.Round(speed));

            // Gear
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoGearGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoGearGfxRect.Y),
                TachoGearGfxRect.Height,
                Math.Min(5, gear));
        }
Beispiel #8
0
		} // SkyCubeMapTexture
		#endregion

		#region Constructor
		/// <summary>
		/// Create user interface renderer
		/// </summary>
		public UIRenderer()
		{
			splashLogos[0] = new Texture("logoonly_xna");
			splashLogos[1] = new Texture("logoonly_exdream");
			splashLogos[2] = new Texture("logoonly_microsoft");

			background = new Texture("background.png");
			buttons = new Texture("buttons.png");
			logos = new Texture("logos.png");
			helpScreen = new Texture("HelpScreen.png");
			optionsScreen = new Texture("OptionsScreen.png");
			creditsScreen = new Texture("CreditsScreen.png");
			mouseCursor = new Texture("MouseCursor.png");
			ingame = new Texture("Ingame.png");
			trophies[0] = new Texture("pokal1");
			trophies[1] = new Texture("pokal2");
			trophies[2] = new Texture("pokal3");
			font = new TextureFont();

			postScreenMenuShader = new PostScreenMenu();
			postScreenGameShader = new PostScreenGlow();
			skyCube = new PreScreenSkyCubeMapping();
			lensFlare = new LensFlare(LensFlare.DefaultSunPos);
			BaseGame.LightDirection = LensFlare.DefaultLightPos;
		} // UIRenderer()
        /// <summary>
        /// Render game user interface
        /// </summary>
        /// <param name="currentGameTime">Current game time</param>
        /// <param name="bestLapTime">Best lap time</param>
        /// <param name="lapNumber">Lap number</param>
        /// <param name="speed">Speed</param>
        /// <param name="gear">Gear</param>
        /// <param name="trackName">Track name</param>
        /// <param name="top5LapTimes">Top 5 lap times</param>
        public void RenderGameUI(int currentGameTime, int bestLapTime,
                                 int lapNumber, float speed, int gear, float acceleration,
                                 string trackName, Dictionary <string, RemotePlayer> players)
        {
            Color baseUIColor = Color.White;//ColorHelper.HalfAlpha;

            // If game is over, set speed, gear and acceleration to 0
            if (RacingGameManager.Player.GameOver)
            {
                speed        = 0;
                gear         = 1;
                acceleration = 0;
            }

            // More distance to the screen borders on the Xbox 360 to fit better into
            // the save region. Calculate all rectangles for each platform,
            // then they will be used the same way on both platforms.
#if XBOX360
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                60, 46, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                60, 46, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                60, 46, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);
            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                60, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;
            ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);
            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);
            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);
            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);
            ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);

            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                60, 46, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#else
            // Draw all boxes and background stuff
            Rectangle lapsRect = BaseGame.CalcRectangle1600(
                10, 10, LapsGfxRect.Width, LapsGfxRect.Height);
            ingame.RenderOnScreen(lapsRect, LapsGfxRect, baseUIColor);

            Rectangle timesRect = BaseGame.CalcRectangle1600(
                10, 10, CurrentAndBestGfxRect.Width, CurrentAndBestGfxRect.Height);
            timesRect.Y = BaseGame.Height - timesRect.Bottom;
            ingame.RenderOnScreen(timesRect, CurrentAndBestGfxRect, baseUIColor);

            Rectangle trackNameRect = BaseGame.CalcRectangle1600(
                10, 10, TrackNameGfxRect.Width, TrackNameGfxRect.Height);
            trackNameRect.X = BaseGame.Width - trackNameRect.Right;
            ingame.RenderOnScreen(trackNameRect, TrackNameGfxRect, baseUIColor);


            Rectangle tachoRect = BaseGame.CalcRectangle1600(
                10, 10, TachoGfxRect.Width, TachoGfxRect.Height);
            tachoRect.X = BaseGame.Width - tachoRect.Right;
            tachoRect.Y = BaseGame.Height - tachoRect.Bottom;
#endif

            // Rest can stay the same because we use the rectangles from now on
            ingame.RenderOnScreen(tachoRect, TachoGfxRect, baseUIColor);

            // Ok, now add the numbers, text and speed values
            TextureFontBigNumbers.WriteNumber(
                lapsRect.X + BaseGame.XToRes1600(15),
                lapsRect.Y + BaseGame.YToRes1200(12),
                lapNumber);

            // Current and best game times
            Color highlightColor = new Color(255, 185, 80);
            int   blockHeight    = BaseGame.YToRes1200(74);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + blockHeight / 2 - TextureFont.Height / 2,
                currentGameTime,
                highlightColor);
            TextureFont.WriteGameTime(
                timesRect.X + BaseGame.XToRes1600(154),
                timesRect.Y + timesRect.Height / 2 + blockHeight / 2 -
                TextureFont.Height / 2,
                bestLapTime,
                Color.White);

            // Track name
            TextureFont.WriteTextCentered(
                trackNameRect.X + trackNameRect.Width / 2,
                trackNameRect.Y + blockHeight / 2,
                trackName);

            Rectangle top5Rect1 = BaseGame.CalcRectangle1600(
                10, 4, Best5GfxRect.Width, Best5GfxRect.Height);
            top5Rect1.X = trackNameRect.X;
            int top5Distance = top5Rect1.Y;
            top5Rect1.Y += trackNameRect.Bottom;

            Rectangle top5Rect2 = new Rectangle(top5Rect1.X,
                                                top5Rect1.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect3 = new Rectangle(top5Rect1.X,
                                                top5Rect2.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect4 = new Rectangle(top5Rect1.X,
                                                top5Rect3.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);

            Rectangle top5Rect5 = new Rectangle(top5Rect1.X,
                                                top5Rect4.Bottom + top5Distance, top5Rect1.Width, top5Rect1.Height);


            int         index = 0;
            RankEntry[] ents  = new RankEntry[players.Count + 1];
            foreach (var e in players)
            {
                ents[index].Progress = e.Value.CompletionProgress;
                ents[index].ID       = e.Value.ID;
                ents[index++].Name   = e.Value.Name;
            }
            ents[index].Progress = RacingGameManager.Player.GetCompletionProgress();
            ents[index].ID       = RacingGameManager.LocalUID;
            ents[index].Name     = RacingGameManager.LocalPlayerName;
            Array.Sort(ents, RankComparision);

            if (ents.Length > 0)
            {
                // Top 5

                ingame.RenderOnScreen(top5Rect1, Best5GfxRect, baseUIColor);
                Color rankColor =
                    ents[0].ID == RacingGameManager.LocalUID ?
                    highlightColor : Color.White;
                TextureFont.WriteTextCentered(
                    top5Rect1.X + BaseGame.XToRes(32) / 2,
                    top5Rect1.Y + blockHeight / 2,
                    "1.", rankColor, 1.0f);
                TextureFont.WriteText(
                    top5Rect1.X + BaseGame.XToRes(35 + 15),
                    top5Rect1.Y + blockHeight / 2 - TextureFont.Height / 2,
                    ents[0].Name, rankColor);

                if (ents.Length > 1)
                {
                    rankColor =
                        ents[1].ID == RacingGameManager.LocalUID ?
                        highlightColor : Color.White;
                    TextureFont.WriteTextCentered(
                        top5Rect2.X + BaseGame.XToRes(32) / 2,
                        top5Rect2.Y + blockHeight / 2,
                        "2.", rankColor, 1.0f);
                    TextureFont.WriteText(
                        top5Rect2.X + BaseGame.XToRes(35 + 15),
                        top5Rect2.Y + blockHeight / 2 - TextureFont.Height / 2,
                        ents[1].Name, rankColor);
                    ingame.RenderOnScreen(top5Rect2, Best5GfxRect, baseUIColor);

                    if (ents.Length > 2)
                    {
                        rankColor =
                            ents[2].ID == RacingGameManager.LocalUID ?
                            highlightColor : Color.White;
                        TextureFont.WriteTextCentered(
                            top5Rect3.X + BaseGame.XToRes(32) / 2,
                            top5Rect3.Y + blockHeight / 2,
                            "3.", rankColor, 1.0f);
                        TextureFont.WriteText(
                            top5Rect3.X + BaseGame.XToRes(35 + 15),
                            top5Rect3.Y + blockHeight / 2 - TextureFont.Height / 2,
                            ents[2].Name, rankColor);
                        ingame.RenderOnScreen(top5Rect3, Best5GfxRect, baseUIColor);

                        if (ents.Length > 3)
                        {
                            rankColor =
                                ents[3].ID == RacingGameManager.LocalUID ?
                                highlightColor : Color.White;
                            TextureFont.WriteTextCentered(
                                top5Rect4.X + BaseGame.XToRes(32) / 2,
                                top5Rect4.Y + blockHeight / 2,
                                "4.", rankColor, 1.0f);
                            TextureFont.WriteText(
                                top5Rect4.X + BaseGame.XToRes(35 + 15),
                                top5Rect4.Y + blockHeight / 2 - TextureFont.Height / 2,
                                ents[3].Name, rankColor);
                            ingame.RenderOnScreen(top5Rect4, Best5GfxRect, baseUIColor);

                            if (ents.Length > 4)
                            {
                                rankColor =
                                    ents[4].ID == RacingGameManager.LocalUID ?
                                    highlightColor : Color.White;
                                TextureFont.WriteTextCentered(
                                    top5Rect5.X + BaseGame.XToRes(32) / 2,
                                    top5Rect5.Y + blockHeight / 2,
                                    "5.", rankColor, 1.0f);
                                TextureFont.WriteText(
                                    top5Rect5.X + BaseGame.XToRes(35 + 15),
                                    top5Rect5.Y + blockHeight / 2 - TextureFont.Height / 2,
                                    ents[4].Name, rankColor);
                                ingame.RenderOnScreen(top5Rect5, Best5GfxRect, baseUIColor);
                            }
                        }
                    }
                }
            }

            Viewport vp = RacingGameManager.graphicsManager.GraphicsDevice.Viewport;
            var      rp = RacingGameManager.RemotePlayers;
            foreach (var e in rp)
            {
                Matrix  trans = e.Value.Transform;
                Vector3 pos   = trans.Translation + trans.Up * 2.8f;

                Vector3 screnPos = vp.Project(pos, BaseGame.ProjectionMatrix, BaseGame.ViewMatrix, Matrix.Identity);
                if (screnPos.Z > 0 && screnPos.Z < 0.985f)
                {
                    Vector2 size = nameFont.MeasureString(e.Value.Name);
                    screnPos.X -= size.X * 0.5f;
                    screnPos.Y -= size.Y * 0.5f;
                    TextureFont.WriteText((int)screnPos.X, (int)screnPos.Y, e.Value.Name);
                    //nameBatch.DrawString(nameFont, e.Value.Name, new Vector2(pos.X, pos.Y), Color.White);
                }
            }

            //// Acceleration
            //Point tachoPoint = new Point(
            //    tachoRect.X +
            //    BaseGame.XToRes1600(194),
            //    tachoRect.Y +
            //    BaseGame.YToRes1200(194));
            ////ingame.RenderOnScreenWithRotation(
            ////    tachoPoint, TachoArrowGfxRect, -acceleration*2);
            //if (acceleration < 0)
            //    acceleration = 0;
            //if (acceleration > 1)
            //    acceleration = 1;
            //float rotation = -2.33f + acceleration * 2.5f;
            //int tachoArrowWidth = BaseGame.XToRes1600(TachoArrowGfxRect.Width);
            //int tachoArrowHeight = BaseGame.YToRes1200(TachoArrowGfxRect.Height);
            //Vector2 rotationPoint = new Vector2(
            //    TachoArrowGfxRect.Width / 2,
            //    TachoArrowGfxRect.Height - 13);
            //ingame.RenderOnScreenWithRotation(
            //    new Rectangle(tachoPoint.X, tachoPoint.Y,
            //    tachoArrowWidth, tachoArrowHeight),
            //    TachoArrowGfxRect,
            //    rotation, rotationPoint);

            // Speed in mph
            TextureFontBigNumbers.WriteNumber(
                tachoRect.X + BaseGame.XToRes1600(TachoMphGfxRect.X),
                tachoRect.Y + BaseGame.YToRes1200(TachoMphGfxRect.Y),
                TachoMphGfxRect.Height,
                (int)Math.Round(speed * 0.8f));

            //// Gear
            //TextureFontBigNumbers.WriteNumber(
            //    tachoRect.X + BaseGame.XToRes1600(TachoGearGfxRect.X),
            //    tachoRect.Y + BaseGame.YToRes1200(TachoGearGfxRect.Y),
            //    TachoGearGfxRect.Height,
            //    Math.Min(5, gear));
        }