public CircularSpeedGauge(int width, int height, int maxSpeed, bool unitMetric, bool unitVisible, bool dialQuarterLines, int maxVisibleScale,
                                  MSTSLocomotive locomotive, Viewer viewer, CabShader shader)
        {
            UnitVisible = unitVisible;
            SetUnit(unitMetric);

            DialQuarterLines = dialQuarterLines;
            MaxSpeed         = maxSpeed;
            MaxVisibleScale  = maxVisibleScale;
            Viewer           = viewer;
            Locomotive       = locomotive;
            cabShader        = shader;

            SizeTo(width, height);
            SetRange(MaxSpeed);

            CurrentSpeed = new TextPrimitive[3];
            for (var i = 0; i < CurrentSpeed.Length; i++)
            {
                CurrentSpeed[i] = new TextPrimitive(new Point(CurrentSpeedPosition[i], CurrentSpeedPosition[3]), Color.Black, "0", FontCurrentSpeed);
            }

            ReleaseSpeed = new TextPrimitive(ReleaseSpeedPosition, ColorGrey, String.Empty, FontReleaseSpeed);

            Shader = new DriverMachineInterfaceShader(Viewer.RenderProcess.GraphicsDevice);
            if (NeedleTextureData == null)
            {
                NeedleTextureData = new Color[128 * 16];

                // Needle texture is according to ETCS specification
                for (var v = 0; v < 128; v++)
                {
                    for (var u = 0; u < 16; u++)
                    {
                        NeedleTextureData[u + 16 * v] = (
                            v <= 15 && 5 < u && u < 9 ||
                            15 < v && v <= 23 && 5f - (float)(v - 15) / 8f * 3f < u && u < 9f + (float)(v - 15) / 8f * 3f ||
                            23 < v && v < 82 && 2 < u && u < 12
                            ) ? Color.White : Color.Transparent;
                    }
                }
            }
        }
Esempio n. 2
0
 public DriverMachineInterfaceRenderer(Viewer viewer, MSTSLocomotive locomotive, CVCScreen control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     Position.X = (float)Control.PositionX;
     Position.Y = (float)Control.PositionY;
     if ((int)Control.Height == 102 && (int)Control.Width == 136)
     {
         // Hack for ETR400 cab, which was built with a bugged size calculation of digital displays
         Control.Height *= 0.75f;
         Control.Width  *= 0.75f;
     }
     DMI = new DriverMachineInterface((int)Control.Height, (int)Control.Width, locomotive, viewer, control);
 }
Esempio n. 3
0
 public CircularSpeedGaugeRenderer(Viewer viewer, MSTSLocomotive locomotive, CVCDigital control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     // Height is adjusted to keep compatibility
     DMI = new DriverMachineInterface((int)Control.Width, (int)Control.Height, locomotive, viewer, control);
 }
 //[CallOnThread("Loader")]
 public CabViewCircularSpeedGaugeRenderer(Viewer viewer, MSTSLocomotive locomotive, CabViewDigitalControl control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     CircularSpeedGauge = new CircularSpeedGauge(
         control.Bounds.Width,
         Control.Bounds.Height,
         (int)Control.ScaleRangeMax,
         Control.ControlUnit == CabViewControlUnit.Km_Per_Hour,
         true,
         Control.ScaleRangeMax == 240 || Control.ScaleRangeMax == 260,
         (int)Control.ScaleRangeMin,
         Locomotive,
         Viewer,
         shader
         );
 }
 public DistributedPowerInterfaceRenderer(Viewer viewer, MSTSLocomotive locomotive, CVCScreen control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     Position.X = (float)Control.PositionX;
     Position.Y = (float)Control.PositionY;
     DPI        = new DistributedPowerInterface((int)Control.Height, (int)Control.Width, locomotive, viewer, control);
 }
 public CircularSpeedGaugeRenderer(Viewer viewer, MSTSLocomotive locomotive, CabViewDigitalControl control, CabShader shader)
     : base(viewer, locomotive, control, shader)
 {
     // Height is adjusted to keep compatibility
     driverMachineInterface = new DriverMachineInterface((int)(Control.Bounds.Width * 640 / 280), (int)(Control.Bounds.Height * 480 / 300), locomotive, viewer, control);
     viewer.UserCommandController.AddEvent(CommonUserCommand.AlternatePointerPressed, MouseRightButtonPressed);
     viewer.UserCommandController.AddEvent(CommonUserCommand.AlternatePointerReleased, MouseRightButtonReleased);
 }