Exemple #1
0
        /// <summary>Renders the ATS lamp overlay</summary>
        /// <param name="Element">The HUD element these are to be rendererd onto</param>
        /// <param name="TimeElapsed">The time elapsed</param>
        private static void RenderATSLamps(HUD.Element Element, double TimeElapsed)
        {
            // ats lamps
            if (CurrentLampCollection.Lamps == null)
            {
                InitializeLamps();
            }
            double lcrh, lw, rw;

            CalculateViewingPlaneSize(Element, out lw, out rw, out lcrh);
            // start

            // ReSharper disable once PossibleNullReferenceException
            int    n = CurrentLampCollection.Lamps.Length;
            double w = (double)CurrentLampCollection.Width + lw + rw;
            double h = Element.Value2 * n;
            double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X > 0 ? Screen.Width - w : 0.5 * (Screen.Width - w);
            double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y > 0 ? Screen.Height - h : 0.5 * (Screen.Height - h);

            x += Element.Position.X;
            y += Element.Position.Y;
            for (int j = 0; j < n; j++)
            {
                if (CurrentLampCollection.Lamps[j].Type != LampType.None)
                {
                    int o;
                    if (j == 0)
                    {
                        o = -1;
                    }
                    else if (CurrentLampCollection.Lamps[j - 1].Type == LampType.None)
                    {
                        o = -1;
                    }
                    else if (j < n - 1 && CurrentLampCollection.Lamps[j + 1].Type == LampType.None)
                    {
                        o = 1;
                    }
                    else if (j == n - 1)
                    {
                        o = 1;
                    }
                    else
                    {
                        o = 0;
                    }
                    HUD.Image    Left   = o < 0 ? Element.TopLeft : o == 0 ? Element.CenterLeft : Element.BottomLeft;
                    HUD.Image    Middle = o < 0 ? Element.TopMiddle : o == 0 ? Element.CenterMiddle : Element.BottomMiddle;
                    HUD.Image    Right  = o < 0 ? Element.TopRight : o == 0 ? Element.CenterRight : Element.BottomRight;
                    MessageColor sc     = MessageColor.Gray;
                    if (TrainManager.PlayerTrain.Plugin.Panel.Length >= 272)
                    {
                        switch (CurrentLampCollection.Lamps[j].Type)
                        {
                        case LampType.Ats:
                            if (TrainManager.PlayerTrain.Plugin.Panel[256] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtsOperation:
                            if (TrainManager.PlayerTrain.Plugin.Panel[258] != 0)
                            {
                                sc = MessageColor.Red;
                            }
                            break;

                        case LampType.AtsPPower:
                            if (TrainManager.PlayerTrain.Plugin.Panel[259] != 0)
                            {
                                sc = MessageColor.Green;
                            }
                            break;

                        case LampType.AtsPPattern:
                            if (TrainManager.PlayerTrain.Plugin.Panel[260] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtsPBrakeOverride:
                            if (TrainManager.PlayerTrain.Plugin.Panel[261] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtsPBrakeOperation:
                            if (TrainManager.PlayerTrain.Plugin.Panel[262] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtsP:
                            if (TrainManager.PlayerTrain.Plugin.Panel[263] != 0)
                            {
                                sc = MessageColor.Green;
                            }
                            break;

                        case LampType.AtsPFailure:
                            if (TrainManager.PlayerTrain.Plugin.Panel[264] != 0)
                            {
                                sc = MessageColor.Red;
                            }
                            break;

                        case LampType.Atc:
                            if (TrainManager.PlayerTrain.Plugin.Panel[265] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtcPower:
                            if (TrainManager.PlayerTrain.Plugin.Panel[266] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtcUse:
                            if (TrainManager.PlayerTrain.Plugin.Panel[267] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;

                        case LampType.AtcEmergency:
                            if (TrainManager.PlayerTrain.Plugin.Panel[268] != 0)
                            {
                                sc = MessageColor.Red;
                            }
                            break;

                        case LampType.Eb:
                            if (TrainManager.PlayerTrain.Plugin.Panel[270] != 0)
                            {
                                sc = MessageColor.Green;
                            }
                            break;

                        case LampType.ConstSpeed:
                            if (TrainManager.PlayerTrain.Plugin.Panel[269] != 0)
                            {
                                sc = MessageColor.Orange;
                            }
                            break;
                        }
                    }
                    // colors
                    float br, bg, bb, ba;
                    CreateBackColor(Element.BackgroundColor, sc, out br, out bg, out bb, out ba);
                    float tr, tg, tb, ta;
                    CreateTextColor(Element.TextColor, sc, out tr, out tg, out tb, out ta);
                    float or, og, ob, oa;
                    CreateBackColor(Element.OverlayColor, sc, out or, out og, out ob, out oa);
                    // left background
                    if (Left.BackgroundTexture != null)
                    {
                        if (Textures.LoadTexture(Left.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double u = (double)Left.BackgroundTexture.Width;
                            double v = (double)Left.BackgroundTexture.Height;
                            GL.Color4(br, bg, bb, ba);
                            RenderOverlayTexture(Left.BackgroundTexture, x, y, x + u, y + v);
                        }
                    }
                    // right background
                    if (Right.BackgroundTexture != null)
                    {
                        if (Textures.LoadTexture(Right.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double u = (double)Right.BackgroundTexture.Width;
                            double v = (double)Right.BackgroundTexture.Height;
                            GL.Color4(br, bg, bb, ba);
                            RenderOverlayTexture(Right.BackgroundTexture, x + w - u, y, x + w, y + v);
                        }
                    }
                    // middle background
                    if (Middle.BackgroundTexture != null)
                    {
                        if (Textures.LoadTexture(Middle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double v = (double)Middle.BackgroundTexture.Height;
                            GL.Color4(br, bg, bb, ba);
                            RenderOverlayTexture(Middle.BackgroundTexture, x + lw, y, x + w - rw, y + v);
                        }
                    }
                    {                     // text
                        string t = CurrentLampCollection.Lamps[j].Text;
                        double u = CurrentLampCollection.Lamps[j].Width;
                        double v = CurrentLampCollection.Lamps[j].Height;
                        double p = Math.Round(Element.TextAlignment.X < 0 ? x : Element.TextAlignment.X > 0 ? x + w - u : x + 0.5 * (w - u));
                        double q = Math.Round(Element.TextAlignment.Y < 0 ? y : Element.TextAlignment.Y > 0 ? y + lcrh - v : y + 0.5 * (lcrh - v));
                        p += Element.TextPosition.X;
                        q += Element.TextPosition.Y;
                        DrawString(Element.Font, t, new System.Drawing.Point((int)p, (int)q), TextAlignment.TopLeft, new Color128(tr, tg, tb, ta), Element.TextShadow);
                    }
                    // left overlay
                    if (Left.OverlayTexture != null)
                    {
                        if (Textures.LoadTexture(Left.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double u = (double)Left.OverlayTexture.Width;
                            double v = (double)Left.OverlayTexture.Height;
                            GL.Color4(or, og, ob, oa);
                            RenderOverlayTexture(Left.OverlayTexture, x, y, x + u, y + v);
                        }
                    }
                    // right overlay
                    if (Right.OverlayTexture != null)
                    {
                        if (Textures.LoadTexture(Right.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double u = (double)Right.OverlayTexture.Width;
                            double v = (double)Right.OverlayTexture.Height;
                            GL.Color4(or, og, ob, oa);
                            RenderOverlayTexture(Right.OverlayTexture, x + w - u, y, x + w, y + v);
                        }
                    }
                    // middle overlay
                    if (Middle.OverlayTexture != null)
                    {
                        if (Textures.LoadTexture(Middle.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                        {
                            double v = (double)Middle.OverlayTexture.Height;
                            GL.Color4(or, og, ob, oa);
                            RenderOverlayTexture(Middle.OverlayTexture, x + lw, y, x + w - rw, y + v);
                        }
                    }
                }
                y += (double)Element.Value2;
            }
        }
Exemple #2
0
        /// <summary>Renders the list of game (textual) messages</summary>
        /// <param name="Element">The HUD element these are to be rendered onto</param>
        /// <param name="TimeElapsed">The time elapsed</param>
        private static void RenderGameMessages(HUD.Element Element, double TimeElapsed)
        {
            //Calculate the size of the viewing plane
            int n = MessageManager.TextualMessages.Count;
            //Minimum initial width is 16px
            double totalwidth = 16.0f;

            for (int j = 0; j < n; j++)
            {
                //Update font size for the renderer
                System.Drawing.Size size = Renderer.MeasureString(Element.Font, (string)MessageManager.TextualMessages[j].MessageToDisplay);
                MessageManager.TextualMessages[j].Width  = size.Width;
                MessageManager.TextualMessages[j].Height = size.Height;
                //Run through the list of current messages
                double a = MessageManager.TextualMessages[j].Width - j * (double)Element.Value1;
                //If our width is wider than the old, use this as the NEW viewing plane width
                if (a > totalwidth)
                {
                    totalwidth = a;
                }
            }
            //Calculate the X-width of the viewing plane
            Game.MessagesRendererSize.X += 16.0 * TimeElapsed * ((double)totalwidth - Game.MessagesRendererSize.X);
            totalwidth = (float)Game.MessagesRendererSize.X;
            double lcrh, lw, rw;

            //Calculate final viewing plane size to pass to openGL
            CalculateViewingPlaneSize(Element, out lw, out rw, out lcrh);

            // start
            double w = totalwidth + lw + rw;
            double h = Element.Value2 * n;
            double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X > 0 ? Screen.Width - w : 0.5 * (Screen.Width - w);
            double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y > 0 ? Screen.Height - h : 0.5 * (Screen.Height - h);

            x += Element.Position.X;
            y += Element.Position.Y;
            int m = 0;

            for (int j = 0; j < n; j++)
            {
                var   mm = MessageManager.TextualMessages[j];
                float br, bg, bb, ba;
                CreateBackColor(Element.BackgroundColor, mm.Color, out br, out bg, out bb, out ba);
                float tr, tg, tb, ta;
                CreateTextColor(Element.TextColor, mm.Color, out tr, out tg, out tb, out ta);
                float or, og, ob, oa;
                CreateBackColor(Element.OverlayColor, mm.Color, out or, out og, out ob, out oa);
                double tx, ty;
                bool   preserve = false;
                if ((Element.Transition & HUD.Transition.Move) != 0)
                {
                    if (Game.SecondsSinceMidnight < mm.Timeout)
                    {
                        if (mm.RendererAlpha == 0.0)
                        {
                            mm.RendererPosition.X = x + Element.TransitionVector.X;
                            mm.RendererPosition.Y = y + Element.TransitionVector.Y;
                            mm.RendererAlpha      = 1.0;
                        }
                        tx       = x;
                        ty       = y + m * Element.Value2;
                        preserve = true;
                    }
                    else if (Element.Transition == HUD.Transition.MoveAndFade)
                    {
                        tx = x;
                        ty = y + m * Element.Value2;
                    }
                    else
                    {
                        tx = x + Element.TransitionVector.X;
                        ty = y + (j + 1) * Element.TransitionVector.Y;
                    }
                    const double speed = 2.0;
                    double       dx    = (speed * Math.Abs(tx - mm.RendererPosition.X) + 0.1) * TimeElapsed;
                    double       dy    = (speed * Math.Abs(ty - mm.RendererPosition.Y) + 0.1) * TimeElapsed;
                    if (Math.Abs(tx - mm.RendererPosition.X) < dx)
                    {
                        mm.RendererPosition.X = tx;
                    }
                    else
                    {
                        mm.RendererPosition.X += Math.Sign(tx - mm.RendererPosition.X) * dx;
                    }
                    if (Math.Abs(ty - mm.RendererPosition.Y) < dy)
                    {
                        mm.RendererPosition.Y = ty;
                    }
                    else
                    {
                        mm.RendererPosition.Y += Math.Sign(ty - mm.RendererPosition.Y) * dy;
                    }
                }
                else
                {
                    tx = x;
                    ty = y + m * Element.Value2;
                    mm.RendererPosition.X = 0.0;
                    const double speed = 12.0;
                    double       dy    = (speed * Math.Abs(ty - mm.RendererPosition.Y) + 0.1) * TimeElapsed;
                    mm.RendererPosition.X = x;
                    if (Math.Abs(ty - mm.RendererPosition.Y) < dy)
                    {
                        mm.RendererPosition.Y = ty;
                    }
                    else
                    {
                        mm.RendererPosition.Y += Math.Sign(ty - mm.RendererPosition.Y) * dy;
                    }
                }
                if ((Element.Transition & HUD.Transition.Fade) != 0)
                {
                    if (Game.SecondsSinceMidnight >= mm.Timeout)
                    {
                        mm.RendererAlpha -= TimeElapsed;
                        if (mm.RendererAlpha < 0.0)
                        {
                            mm.RendererAlpha = 0.0;
                        }
                    }
                    else
                    {
                        mm.RendererAlpha += TimeElapsed;
                        if (mm.RendererAlpha > 1.0)
                        {
                            mm.RendererAlpha = 1.0;
                        }
                        preserve = true;
                    }
                }
                else if (Game.SecondsSinceMidnight > mm.Timeout)
                {
                    if (Math.Abs(mm.RendererPosition.X - tx) < 0.1 & Math.Abs(mm.RendererPosition.Y - ty) < 0.1)
                    {
                        mm.RendererAlpha = 0.0;
                    }
                }
                if (preserve)
                {
                    m++;
                }
                double px    = mm.RendererPosition.X + (double)j * (double)Element.Value1;
                double py    = mm.RendererPosition.Y;
                float  alpha = (float)(mm.RendererAlpha * mm.RendererAlpha);
                // graphics
                HUD.Image Left = j == 0
                                        ? Element.TopLeft
                                        : j < n - 1
                                                ? Element.CenterLeft
                                                : Element.BottomLeft;
                HUD.Image Middle = j == 0
                                        ? Element.TopMiddle
                                        : j < n - 1
                                                ? Element.CenterMiddle
                                                : Element.BottomMiddle;
                HUD.Image Right = j == 0
                                        ? Element.TopRight
                                        : j < n - 1
                                                ? Element.CenterRight
                                                : Element.BottomRight;
                // left background
                if (Left.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Left.BackgroundTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Left.BackgroundTexture.Width;
                        double v = (double)Left.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Left.BackgroundTexture, px, py, px + u, py + v);
                    }
                }
                // right background
                if (Right.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Right.BackgroundTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Right.BackgroundTexture.Width;
                        double v = (double)Right.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Right.BackgroundTexture, px + w - u, py, px + w, py + v);
                    }
                }
                // middle background
                if (Middle.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Middle.BackgroundTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double v = (double)Middle.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Middle.BackgroundTexture, px + lw, py, px + w - rw, py + v);
                    }
                }
                {
                    // text
                    string t = (string)mm.MessageToDisplay;
                    double u = mm.Width;
                    double v = mm.Height;
                    double p =
                        Math.Round(
                            (Element.TextAlignment.X < 0
                                                                ? px
                                                                : Element.TextAlignment.X > 0
                                                                        ? px + w - u
                                                                        : px + 0.5 * (w - u)) - j * Element.Value1);
                    double q = Math.Round(Element.TextAlignment.Y < 0
                                                ? py
                                                : Element.TextAlignment.Y > 0
                                                        ? py + lcrh - v
                                                        : py + 0.5 * (lcrh - v));
                    p += Element.TextPosition.X;
                    q += Element.TextPosition.Y;
                    DrawString(Element.Font, t, new System.Drawing.Point((int)p, (int)q),
                               TextAlignment.TopLeft, new Color128(tr, tg, tb, ta * alpha), Element.TextShadow);
                }
                // left overlay
                if (Left.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Left.OverlayTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Left.OverlayTexture.Width;
                        double v = (double)Left.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Left.OverlayTexture, px, py, px + u, py + v);
                    }
                }
                // right overlay
                if (Right.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Right.OverlayTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Right.OverlayTexture.Width;
                        double v = (double)Right.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Right.OverlayTexture, px + w - u, py, px + w, py + v);
                    }
                }
                // middle overlay
                if (Middle.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Middle.OverlayTexture, Textures.OpenGlTextureWrapMode.ClampClamp))
                    {
                        double v = (double)Middle.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Middle.OverlayTexture, px + lw, py, px + w - rw, py + v);
                    }
                }
            }
        }
        /// <summary>Renders the list of score messages</summary>
        /// <param name="Element">The HUD element these are to be rendererd onto</param>
        /// <param name="TimeElapsed">The time elapsed</param>
        private static void RenderScoreMessages(HUD.Element Element, double TimeElapsed)
        {
            // score messages
            int   n          = Game.ScoreMessages.Length;
            float totalwidth = 16.0f;

            float[] widths  = new float[n];
            float[] heights = new float[n];
            for (int j = 0; j < n; j++)
            {
                System.Drawing.Size size = MeasureString(Element.Font, Game.ScoreMessages[j].Text);
                widths[j]  = size.Width;
                heights[j] = size.Height;
                float a = widths[j] - j * Element.Value1;
                if (a > totalwidth)
                {
                    totalwidth = a;
                }
            }
            Game.ScoreMessagesRendererSize.X += 16.0 * TimeElapsed * ((double)totalwidth - Game.ScoreMessagesRendererSize.X);
            totalwidth = (float)Game.ScoreMessagesRendererSize.X;
            double lcrh, lw, rw;

            CalculateViewingPlaneSize(Element, out lw, out rw, out lcrh);
            // start
            double w = Element.Alignment.X == 0 ? lw + rw + 128 : totalwidth + lw + rw;
            double h = Element.Value2 * n;
            double x = Element.Alignment.X < 0 ? 0.0 : Element.Alignment.X > 0 ? Screen.Width - w : 0.5 * (Screen.Width - w);
            double y = Element.Alignment.Y < 0 ? 0.0 : Element.Alignment.Y > 0 ? Screen.Height - h : 0.5 * (Screen.Height - h);

            x += Element.Position.X;
            y += Element.Position.Y;
            int m = 0;

            for (int j = 0; j < n; j++)
            {
                float br, bg, bb, ba;
                CreateBackColor(Element.BackgroundColor, Game.ScoreMessages[j].Color, out br, out bg, out bb, out ba);
                float tr, tg, tb, ta;
                CreateTextColor(Element.TextColor, Game.ScoreMessages[j].Color, out tr, out tg, out tb, out ta);
                float or, og, ob, oa;
                CreateBackColor(Element.OverlayColor, Game.ScoreMessages[j].Color, out or, out og, out ob, out oa);
                double tx, ty;
                bool   preserve = false;
                if ((Element.Transition & HUD.Transition.Move) != 0)
                {
                    if (Game.SecondsSinceMidnight < Game.ScoreMessages[j].Timeout)
                    {
                        if (Game.ScoreMessages[j].RendererAlpha == 0.0)
                        {
                            Game.ScoreMessages[j].RendererPosition.X = x + Element.TransitionVector.X;
                            Game.ScoreMessages[j].RendererPosition.Y = y + Element.TransitionVector.Y;
                            Game.ScoreMessages[j].RendererAlpha      = 1.0;
                        }
                        tx       = x;
                        ty       = y + m * Element.Value2;
                        preserve = true;
                    }
                    else if (Element.Transition == HUD.Transition.MoveAndFade)
                    {
                        tx = x;
                        ty = y + m * Element.Value2;
                    }
                    else
                    {
                        tx = x + Element.TransitionVector.X;
                        ty = y + (j + 1) * Element.TransitionVector.Y;
                    }
                    const double speed = 2.0;
                    double       dx    = (speed * Math.Abs(tx - Game.ScoreMessages[j].RendererPosition.X) + 0.1) * TimeElapsed;
                    double       dy    = (speed * Math.Abs(ty - Game.ScoreMessages[j].RendererPosition.Y) + 0.1) * TimeElapsed;
                    if (Math.Abs(tx - Game.ScoreMessages[j].RendererPosition.X) < dx)
                    {
                        Game.ScoreMessages[j].RendererPosition.X = tx;
                    }
                    else
                    {
                        Game.ScoreMessages[j].RendererPosition.X += Math.Sign(tx - Game.ScoreMessages[j].RendererPosition.X) * dx;
                    }
                    if (Math.Abs(ty - Game.ScoreMessages[j].RendererPosition.Y) < dy)
                    {
                        Game.ScoreMessages[j].RendererPosition.Y = ty;
                    }
                    else
                    {
                        Game.ScoreMessages[j].RendererPosition.Y += Math.Sign(ty - Game.ScoreMessages[j].RendererPosition.Y) * dy;
                    }
                }
                else
                {
                    tx = x;
                    ty = y + m * Element.Value2;
                    Game.ScoreMessages[j].RendererPosition.X = 0.0;
                    const double speed = 12.0;
                    double       dy    = (speed * Math.Abs(ty - Game.ScoreMessages[j].RendererPosition.Y) + 0.1) * TimeElapsed;
                    Game.ScoreMessages[j].RendererPosition.X = x;
                    if (Math.Abs(ty - Game.ScoreMessages[j].RendererPosition.Y) < dy)
                    {
                        Game.ScoreMessages[j].RendererPosition.Y = ty;
                    }
                    else
                    {
                        Game.ScoreMessages[j].RendererPosition.Y += Math.Sign(ty - Game.ScoreMessages[j].RendererPosition.Y) * dy;
                    }
                }
                if ((Element.Transition & HUD.Transition.Fade) != 0)
                {
                    if (Game.SecondsSinceMidnight >= Game.ScoreMessages[j].Timeout)
                    {
                        Game.ScoreMessages[j].RendererAlpha -= TimeElapsed;
                        if (Game.ScoreMessages[j].RendererAlpha < 0.0)
                        {
                            Game.ScoreMessages[j].RendererAlpha = 0.0;
                        }
                    }
                    else
                    {
                        Game.ScoreMessages[j].RendererAlpha += TimeElapsed;
                        if (Game.ScoreMessages[j].RendererAlpha > 1.0)
                        {
                            Game.ScoreMessages[j].RendererAlpha = 1.0;
                        }

                        preserve = true;
                    }
                }
                else if (Game.SecondsSinceMidnight > Game.ScoreMessages[j].Timeout)
                {
                    if (Math.Abs(Game.ScoreMessages[j].RendererPosition.X - tx) < 0.1 & Math.Abs(Game.ScoreMessages[j].RendererPosition.Y - ty) < 0.1)
                    {
                        Game.ScoreMessages[j].RendererAlpha = 0.0;
                    }
                }
                if (preserve)
                {
                    m++;
                }

                double px    = Game.ScoreMessages[j].RendererPosition.X + (double)j * (double)Element.Value1;
                double py    = Game.ScoreMessages[j].RendererPosition.Y;
                float  alpha = (float)(Game.ScoreMessages[j].RendererAlpha * Game.ScoreMessages[j].RendererAlpha);
                // graphics
                HUD.Image Left   = j == 0 ? Element.TopLeft : j < n - 1 ? Element.CenterLeft : Element.BottomLeft;
                HUD.Image Middle = j == 0 ? Element.TopMiddle : j < n - 1 ? Element.CenterMiddle : Element.BottomMiddle;
                HUD.Image Right  = j == 0 ? Element.TopRight : j < n - 1 ? Element.CenterRight : Element.BottomRight;
                // left background
                if (Left.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Left.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Left.BackgroundTexture.Width;
                        double v = (double)Left.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Left.BackgroundTexture, px, py, px + u, py + v);
                    }
                }
                // right background
                if (Right.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Right.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Right.BackgroundTexture.Width;
                        double v = (double)Right.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Right.BackgroundTexture, px + w - u, py, px + w, py + v);
                    }
                }
                // middle background
                if (Middle.BackgroundTexture != null)
                {
                    if (Textures.LoadTexture(Middle.BackgroundTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double v = (double)Middle.BackgroundTexture.Height;
                        GL.Color4(br, bg, bb, ba * alpha);
                        RenderOverlayTexture(Middle.BackgroundTexture, px + lw, py, px + w - rw, py + v);
                    }
                }
                {                 // text
                    string t = Game.ScoreMessages[j].Text;
                    double u = widths[j];
                    double v = heights[j];
                    double p = Math.Round((Element.TextAlignment.X < 0 ? px : Element.TextAlignment.X > 0 ? px + w - u : px + 0.5 * (w - u)) - j * Element.Value1);
                    double q = Math.Round(Element.TextAlignment.Y < 0 ? py : Element.TextAlignment.Y > 0 ? py + lcrh - v : py + 0.5 * (lcrh - v));
                    p += Element.TextPosition.X;
                    q += Element.TextPosition.Y;
                    DrawString(Element.Font, t, new System.Drawing.Point((int)p, (int)q), TextAlignment.TopLeft, new Color128(tr, tg, tb, ta * alpha), Element.TextShadow);
                }
                // left overlay
                if (Left.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Left.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Left.OverlayTexture.Width;
                        double v = (double)Left.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Left.OverlayTexture, px, py, px + u, py + v);
                    }
                }
                // right overlay
                if (Right.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Right.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double u = (double)Right.OverlayTexture.Width;
                        double v = (double)Right.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Right.OverlayTexture, px + w - u, py, px + w, py + v);
                    }
                }
                // middle overlay
                if (Middle.OverlayTexture != null)
                {
                    if (Textures.LoadTexture(Middle.OverlayTexture, OpenGlTextureWrapMode.ClampClamp))
                    {
                        double v = (double)Middle.OverlayTexture.Height;
                        GL.Color4(or, og, ob, oa * alpha);
                        RenderOverlayTexture(Middle.OverlayTexture, px + lw, py, px + w - rw, py + v);
                    }
                }
            }
        }