public override void AddMessage(double currentTime)
 {
     //HACK: No way of changing this at the minute....
     Font             = Fonts.SmallFont;
     QueueForRemoval  = false;
     MessageToDisplay = InternalText;
 }
 public override void AddMessage(double currentTime)
 {
     //HACK: No way of changing this at the minute....
     Font                  = Program.Renderer.Fonts.SmallFont;
     QueueForRemoval       = false;
     MessageToDisplay      = InternalText;
     ScreenReaderAnnounced = false;
 }
Exemplo n.º 3
0
 /// <summary>Creates a general textual message</summary>
 public GeneralMessage()
 {
     Timeout           = double.PositiveInfinity;
     TriggerOnce       = true;
     Direction         = MessageDirection.Forwards;
     MessageColor      = MessageColor.White;
     MessageEarlyColor = MessageColor.White;
     MessageLateColor  = MessageColor.White;
     Font = new OpenGlFont(FontFamily.GenericSansSerif, 12.0f);
 }
Exemplo n.º 4
0
 /// <summary>Creates a general textual message</summary>
 internal GeneralMessage()
 {
     this.Timeout           = double.PositiveInfinity;
     this.TriggerOnce       = true;
     this.Direction         = MessageDirection.Forwards;
     this.MessageColor      = MessageColor.White;
     this.MessageEarlyColor = MessageColor.White;
     this.MessageLateColor  = MessageColor.White;
     this.Font = Fonts.SmallFont;
 }
Exemplo n.º 5
0
 public Textbox(BaseRenderer Renderer, OpenGlFont Font, Color128 FontColor, Color128 backgroundColor)
 {
     renderer          = Renderer;
     myFont            = Font;
     myFontColor       = FontColor;
     Border            = 5;
     topLine           = 0;
     BackgroundTexture = null;
     BackgroundColor   = backgroundColor;
     myScrollbarColor  = new Color128(1.0f, 0.69f, 0.0f, 1.0f);
 }
Exemplo n.º 6
0
 internal Element()
 {
     this.Subject         = null;
     this.Position        = new Vector2();
     this.Alignment       = new Vector2(-1, -1);
     this.BackgroundColor = Color32.White;
     this.OverlayColor    = Color32.White;
     this.TextColor       = Color32.White;
     this.TextPosition    = new Vector2();
     this.TextAlignment   = new Vector2(-1, 0);
     this.Font            = Fonts.VerySmallFont;
     this.TextShadow      = true;
     this.Text            = null;
     this.Value1          = 0.0f;
     this.Value2          = 0.0f;
     this.Transition      = Transition.None;
     this.TransitionState = 1.0;
 }
Exemplo n.º 7
0
 /********************
  *      MENU SYSTEM METHODS
  *********************/
 //
 // INITIALIZE THE MENU SYSTEM
 //
 private void Init()
 {
     Reset();
     // choose the text font size according to screen height
     // the boundaries follow approximately the progression
     // of font sizes defined in Graphics/Fonts.cs
     if (LibRender.Screen.Height <= 512)
     {
         menuFont = Fonts.SmallFont;
     }
     else if (LibRender.Screen.Height <= 680)
     {
         menuFont = Fonts.NormalFont;
     }
     else if (LibRender.Screen.Height <= 890)
     {
         menuFont = Fonts.LargeFont;
     }
     else if (LibRender.Screen.Height <= 1150)
     {
         menuFont = Fonts.VeryLargeFont;
     }
     else
     {
         menuFont = Fonts.EvenLargerFont;
     }
     em         = (int)menuFont.FontSize;
     lineHeight = (int)(em * LineSpacing);
     for (int i = 0; i < Interface.CurrentControls.Length; i++)
     {
         //Find the current menu back key- It's unlikely that we want to set a new key to this
         if (Interface.CurrentControls[i].Command == Translations.Command.MenuBack)
         {
             MenuBackKey = Interface.CurrentControls[i].Key;
             break;
         }
     }
     isInitialized = true;
 }
Exemplo n.º 8
0
        /// <summary>Draws a key overlay to the screen</summary>
        /// <param name="Left">The left co-ordinate of the top key</param>
        /// <param name="Top">The top co-ordinate of the top key</param>
        /// <param name="Width">The width of the key overlay</param>
        /// <param name="Font">The font to draw</param>
        /// <param name="Keys">The key names</param>
        public void Render(int Left, int Top, int Width, OpenGlFont Font, string[][] Keys)
        {
            int py = Top;

            foreach (string[] key in Keys)
            {
                int px = Left;

                foreach (string text in key)
                {
                    if (text != null)
                    {
                        renderer.Rectangle.Draw(null, new Vector2(px - 1, py - 1), new Vector2(Width + 1, 17), new Color128(0.25f, 0.25f, 0.25f, 0.5f));
                        renderer.Rectangle.Draw(null, new Vector2(px - 1, py - 1), new Vector2(Width - 1, 15), new Color128(0.75f, 0.75f, 0.75f, 0.5f));
                        renderer.Rectangle.Draw(null, new Vector2(px, py), new Vector2(Width, 16), new Color128(0.5f, 0.5f, 0.5f, 0.5f));
                        renderer.OpenGlString.Draw(Font, text, new Point(px - 1 + Width / 2, py + 7), TextAlignment.CenterMiddle, Color128.White);
                    }

                    px += Width + 4;
                }

                py += 20;
            }
        }
Exemplo n.º 9
0
        /// <summary>Draws on OpenGL canvas the route/train loading screen</summary>
        public void DrawLoadingScreen(OpenGlFont Font, double RouteProgress, double TrainProgress = double.MaxValue)
        {
            renderer.SetBlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);             //FIXME: Remove when text switches between two renderer types
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            renderer.Rectangle.Draw(null, Vector2.Null, new Vector2(renderer.Screen.Width, renderer.Screen.Height), bkg);

            // BACKGROUND IMAGE
            int fontHeight = (int)Font.FontSize;
            int logoBottom;
            //int versionTop;
            int halfWidth = renderer.Screen.Width / 2;

            if (TextureLoadingBkg != null && renderer.currentHost.LoadTexture(TextureLoadingBkg, OpenGlTextureWrapMode.ClampClamp))
            {
                int bkgHeight, bkgWidth;

                // stretch the background image to fit at least one screen dimension
                double ratio = TextureLoadingBkg.Width / (double)TextureLoadingBkg.Height;

                if (renderer.Screen.Width / ratio > renderer.Screen.Height) // if screen ratio is shorter than bkg...
                {
                    bkgHeight = renderer.Screen.Height;                     // set height to screen height
                    bkgWidth  = (int)(renderer.Screen.Height * ratio);      // and scale width proprtionally
                }
                else                                                        // if screen ratio is wider than bkg...
                {
                    bkgWidth  = renderer.Screen.Width;                      // set width to screen width
                    bkgHeight = (int)(renderer.Screen.Width / ratio);       // and scale height accordingly
                }

                // draw the background image down from the top screen edge
                renderer.Rectangle.Draw(TextureLoadingBkg, new Vector2((renderer.Screen.Width - bkgWidth) / 2.0, 0), new Vector2(bkgWidth, bkgHeight), Color128.White);
            }

            // if the route has no custom loading image, add the openBVE logo
            // (the route custom image is loaded in OldParsers/CsvRwRouteParser.cs)
            if (!customLoadScreen)
            {
                if (showLogo && renderer.ProgramLogo != null)
                {
                    // place the centre of the logo at from the screen top
                    int logoTop = (int)(renderer.Screen.Height * logoCentreYFactor - renderer.ProgramLogo.Height / 2.0);
                    renderer.Rectangle.DrawAlpha(renderer.ProgramLogo, new Vector2((renderer.Screen.Width - renderer.ProgramLogo.Width) / 2.0, logoTop), new Vector2(renderer.ProgramLogo.Width, renderer.ProgramLogo.Height), Color128.White);
                }
            }
            // ReSharper disable once RedundantIfElseBlock
            else
            {
                // if custom route image, no logo and leave a conventional black area below the potential logo
            }

            if (showProgress)
            {
                logoBottom = renderer.Screen.Height / 2;

                // take the height remaining below the logo and divide in 3 horiz. parts
                int blankHeight = (renderer.Screen.Height - logoBottom) / 3;

                // VERSION NUMBER
                // place the version above the first division
                int versionTop = logoBottom + blankHeight - fontHeight;
                renderer.OpenGlString.Draw(Font, "Version " + ProgramVersion, new Vector2(halfWidth, versionTop), TextAlignment.TopMiddle, Color128.White);
                // for the moment, do not show any URL; would go right below the first division
                //			DrawString(Fonts.SmallFont, "https://openbve-project.net",
                //				new Point(halfWidth, versionTop + fontHeight+2),
                //				TextAlignment.TopMiddle, Color128.White);
                // PROGRESS MESSAGE AND BAR
                // place progress bar right below the second division
                int    progressTop   = renderer.Screen.Height - blankHeight;
                int    progressWidth = renderer.Screen.Width - progrMargin * 2;
                double routeProgress = Math.Max(0.0, Math.Min(1.0, RouteProgress));
                double trainProgress = Math.Max(0.0, Math.Min(1.0, TrainProgress));

                // draw progress message right above the second division
                string text = Translations.GetInterfaceString(routeProgress < 1.0 ? "loading_loading_route" : trainProgress < 1.0 ? "loading_loading_train" : "message_loading");
                renderer.OpenGlString.Draw(Font, text, new Vector2(halfWidth, progressTop - fontHeight - 6), TextAlignment.TopMiddle, Color128.White);

                // sum of route progress and train progress arrives up to 2.0:
                // => times 50.0 to convert to %
                double percent;
                if (TrainProgress != double.MaxValue)
                {
                    percent = 50.0 * (routeProgress + trainProgress);
                }
                else
                {
                    percent = 100.0 * routeProgress;
                }
                string percStr = percent.ToString("0") + "%";

                // progress frame
                renderer.Rectangle.Draw(null, new Vector2(progrMargin - progrBorder, progressTop - progrBorder), new Vector2(progressWidth + progrBorder * 2, fontHeight + 6), Color128.White);

                // progress bar
                renderer.Rectangle.Draw(null, new Vector2(progrMargin, progressTop), new Vector2(progressWidth * (int)percent / 100.0, fontHeight + 4), ColourProgressBar);

                // progress percent
                renderer.OpenGlString.Draw(Font, percStr, new Vector2(halfWidth, progressTop), TextAlignment.TopMiddle, Color128.Black);
            }
        }
Exemplo n.º 10
0
            internal Lamp(LampType Type)
            {
                this.Type = Type;
                switch (Type)
                {
                case LampType.None:
                    this.Text = null;
                    break;

                case LampType.Ats:
                    this.Text = Translations.GetInterfaceString("lamps_ats");
                    break;

                case LampType.AtsOperation:
                    this.Text = Translations.GetInterfaceString("lamps_atsoperation");
                    break;

                case LampType.AtsPPower:
                    this.Text = Translations.GetInterfaceString("lamps_atsppower");
                    break;

                case LampType.AtsPPattern:
                    this.Text = Translations.GetInterfaceString("lamps_atsppattern");
                    break;

                case LampType.AtsPBrakeOverride:
                    this.Text = Translations.GetInterfaceString("lamps_atspbrakeoverride");
                    break;

                case LampType.AtsPBrakeOperation:
                    this.Text = Translations.GetInterfaceString("lamps_atspbrakeoperation");
                    break;

                case LampType.AtsP:
                    this.Text = Translations.GetInterfaceString("lamps_atsp");
                    break;

                case LampType.AtsPFailure:
                    this.Text = Translations.GetInterfaceString("lamps_atspfailure");
                    break;

                case LampType.Atc:
                    this.Text = Translations.GetInterfaceString("lamps_atc");
                    break;

                case LampType.AtcPower:
                    this.Text = Translations.GetInterfaceString("lamps_atcpower");
                    break;

                case LampType.AtcUse:
                    this.Text = Translations.GetInterfaceString("lamps_atcuse");
                    break;

                case LampType.AtcEmergency:
                    this.Text = Translations.GetInterfaceString("lamps_atcemergency");
                    break;

                case LampType.Eb:
                    this.Text = Translations.GetInterfaceString("lamps_eb");
                    break;

                case LampType.ConstSpeed:
                    this.Text = Translations.GetInterfaceString("lamps_constspeed");
                    break;

                default:
                    this.Text = "TEXT";
                    break;
                }
                OpenGlFont font = Fonts.NormalFont;

                for (int i = 0; i < HUD.CurrentHudElements.Length; i++)
                {
                    if (HUD.CurrentHudElements[i].Subject.Equals("ats", StringComparison.OrdinalIgnoreCase))
                    {
                        font = HUD.CurrentHudElements[i].Font;
                        break;
                    }
                }
                System.Drawing.Size size = font.MeasureString(this.Text);
                this.Width  = size.Width;
                this.Height = size.Height;
            }