Esempio n. 1
0
            private static void DrawDataScreenVORSection(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData)
            {
                float PositionYFactor = 5f;
                float PosistionX      = Center.X + 12 * UnitX;

                if (CombinedData.VORData.Rotation == null)
                {
                    Frame.Add(new MySprite()
                    {
                        Type            = SpriteType.TEXT,
                        Data            = "No VOR\nConnection!",
                        Position        = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position,
                        RotationOrScale = DataScreenFontSize + 0.2f,
                        Color           = Color.Tomato,
                        Alignment       = TextAlignment.LEFT,
                        FontId          = "White"
                    });
                    return;
                }

                string[] _lines =
                {
                    "VOR: " + CombinedData.VORData.Name,
                    "DME: " + Math.Round(CombinedData.VORData.Distance / 1000, 1).ToString(),
                    "Radial: " + Math.Round(CombinedData.VORData.Radial,       0).ToString(),
                    "OBS: " + Math.Round(CombinedData.VORData.OBS,             0).ToString(),
                    "HDG: " + Math.Round(CombinedData.VORData.Heading,         0).ToString(),
                    "DEV: " + Math.Round(CombinedData.VORData.Deviation, 0).ToString()
                };

                List <string> Lines = new List <string>(_lines);

                foreach (string line in Lines)
                {
                    Frame.Add(new MySprite()
                    {
                        Type            = SpriteType.TEXT,
                        Data            = line,
                        Position        = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position,
                        RotationOrScale = DataScreenFontSize,
                        Color           = CockpitFGColor.Alpha(1f),
                        Alignment       = TextAlignment.LEFT,
                        FontId          = "White"
                    });

                    PositionYFactor += 35;
                }
            }
Esempio n. 2
0
            private static void DrawDataScreen(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData)
            {
                // ILS Data
                DrawDataScreenILSSection(ref Frame, Surface, CombinedData);

                // VOR
                DrawDataScreenVORSection(ref Frame, Surface, CombinedData);

                // Line between the two columns
                MySprite SeparationLine = MySprite.CreateSprite("SquareSimple", Center, new Vector2(3 * UnitX, 200 * UnitY));

                SeparationLine.Color = CockpitFGColor.Alpha(1f);
                Frame.Add(SeparationLine);
            }
Esempio n. 3
0
            private static void DrawDataScreenILSSection(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, CombinedDataSet CombinedData)
            {
                float PositionYFactor = 5f;
                float PosistionX      = 12 * UnitX;

                if (CombinedData.ILSData.Rotation == null)
                {
                    Frame.Add(new MySprite()
                    {
                        Type            = SpriteType.TEXT,
                        Data            = "No ILS\nConnection!",
                        Position        = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position,
                        RotationOrScale = DataScreenFontSize + 0.2f,
                        Color           = Color.Tomato,
                        Alignment       = TextAlignment.LEFT,
                        FontId          = "White"
                    });
                    return;
                }

                string[] _lines =
                {
                    "RWY: " + CombinedData.ILSData.RunwayNumber.ToString(),
                    "DME: " + Math.Round(CombinedData.ILSData.Distance / 1000,          1).ToString(),
                    "Bearing: " + Math.Round(CombinedData.ILSData.Bearing,              0).ToString(),
                    "Rel. Bearing: " + Math.Round(CombinedData.ILSData.RelativeBearing, 0).ToString(),
                    "Track: " + Math.Round(CombinedData.ILSData.Track,                  0).ToString(),
                };

                List <string> Lines = new List <string>(_lines);

                foreach (string line in Lines)
                {
                    Frame.Add(new MySprite()
                    {
                        Type            = SpriteType.TEXT,
                        Data            = line,
                        Position        = new Vector2(PosistionX, PositionYFactor * UnitY) + Viewport.Position,
                        RotationOrScale = DataScreenFontSize,
                        Color           = CockpitFGColor.Alpha(1f),
                        Alignment       = TextAlignment.LEFT,
                        FontId          = "White"
                    });

                    PositionYFactor += 35;
                }
            }
        public void DrawToSurfaces(ILSDataSet ILSData, VORDataSet VORData, NDBDataSet NDBData)
        {
            List <IMyTextSurfaceProvider> SurfaceProviders = GetScreens(CockpitTag);

            if (SurfaceProviders == null)
            {
                Echo("No screen found!");
                return;
            }

            CombinedDataSet CombinedData = new CombinedDataSet
            {
                ILSData = ILSData,
                VORData = VORData
            };

            foreach (IMyTextSurfaceProvider _sp in SurfaceProviders)
            {
                IMyTerminalBlock _spTerminal       = _sp as IMyTerminalBlock;
                string           _customDataString = _spTerminal.CustomData;
                MyIni            _customData       = new MyIni();

                MyIniParseResult iniResult;
                if (!_customData.TryParse(_customDataString, out iniResult))
                {
                    throw new Exception(iniResult.ToString());
                }


                if (_customData.Get("NavigationSurfaces", "0").ToString("none") == "none")
                {
                    for (int i = 0; i < _sp.SurfaceCount; i++)
                    {
                        switch (i)
                        {
                        case 1:
                            _customData.Set("NavigationSurfaces", i.ToString(), "ILS");
                            break;

                        case 2:
                            _customData.Set("NavigationSurfaces", i.ToString(), "VOR");
                            break;

                        case 3:
                            _customData.Set("NavigationSurfaces", i.ToString(), "Data");
                            break;

                        default:
                            _customData.Set("NavigationSurfaces", i.ToString(), "N/A");
                            break;
                        }
                    }

                    _spTerminal.CustomData = _customData.ToString();
                    continue;
                }

                string[] DrawSurfaces = new string[_sp.SurfaceCount];
                try
                {
                    for (var i = 0; i < _sp.SurfaceCount; i++)
                    {
                        string value = _customData.Get("NavigationSurfaces", i.ToString()).ToString();
                        DrawSurfaces[i] = value;
                    }
                }
                catch (Exception)
                {
                    Echo("Error in building DrawSurfaces Loop");
                }

                // ILS Screen
                try
                {
                    IMyTextSurface ILSSurface = _sp.GetSurface(Array.IndexOf(DrawSurfaces, "ILS"));
                    Draw.DrawSurface(ILSSurface, Surface.ILS, ILSData);
                }
                catch (Exception)
                {
                    Echo("No ILS Surface found in \"" + _spTerminal.CustomName.ToString() + "\".");
                }


                // VOR Screen
                try
                {
                    IMyTextSurface VORSurface = _sp.GetSurface(Array.IndexOf(DrawSurfaces, "VOR"));
                    Draw.DrawSurface(VORSurface, Surface.VOR, VORData);
                }
                catch (Exception)
                {
                    Echo("No VOR Surface found in \"" + _spTerminal.CustomName.ToString() + "\".");
                }


                // NDB Screen
                try
                {
                    IMyTextSurface VORSurface = _sp.GetSurface(Array.IndexOf(DrawSurfaces, "NDB"));
                    Draw.DrawSurface(VORSurface, Surface.NDB, NDBData);
                }
                catch (Exception)
                {
                    Echo("No NDB Surface found in \"" + _spTerminal.CustomName.ToString() + "\".");
                }


                // Data Screen
                try
                {
                    IMyTextSurface DataSurface = _sp.GetSurface(Array.IndexOf(DrawSurfaces, "Data"));
                    Draw.DrawSurface(DataSurface, Surface.Data, CombinedData);
                }
                catch (Exception)
                {
                    Echo("No Data Surface found in " + _spTerminal.CustomName.ToString());
                }
            }
        }