コード例 #1
0
            /*public static void loadNavAids_not_working() {
             *      FlightData.rwyList.Clear();
             *      ConfigNode[] nodes = GameDatabase.Instance.GetConfigNodes("Runway");
             *      KSPLog.print("^^^^ NODES: " + nodes.Length);
             *      foreach (ConfigNode node in nodes) {
             *              Runway runway = new Runway();
             *              ConfigNode.LoadObjectFromConfig(runway, node);
             *              KSPLog.print("^^^^ RUNWAY: " + runway);
             *              FlightData.rwyList.Add(runway);
             *      }
             *
             *      nodes = GameDatabase.Instance.GetConfigNodes("Glideslope");
             *      KSPLog.print("^^^^ GLIDE NODES: " + nodes.Length);
             *      foreach (ConfigNode node in nodes) {
             *              KSPLog.print("^^^^ GLIDE NODE: " + node);
             *              Glideslope glideslope = new Glideslope();
             *              KSPLog.print("^^^^ LOADED " + ConfigNode.LoadObjectFromConfig(glideslope, node));
             *              KSPLog.print("^^^^ GLIDESLOPE: " + glideslope);
             *              FlightData.gsList.Add(glideslope);
             *      }
             * }*/

            public static void loadNavAids()
            {
                Log.dbg("NavUtil: Loading NavAid database...");
                FlightData.allRunways.Clear();
                FlightData.allRunways = ConfigLoader.GetRunwayListFromConfig();
                FlightData.gsList.Clear();
                FlightData.gsList = ConfigLoader.GetGlideslopeListFromConfig();

                FlightData.customRunways.Clear();
                FlightData.allRunways.ForEach(runway => {
                    if (FlightGlobals.currentMainBody == null)
                    {
                        return;
                    }
                    if (FlightGlobals.currentMainBody.name == runway.body)
                    {
                        FlightData.currentBodyRunways.Add(runway);
                    }
                    if (runway.custom)
                    {
                        FlightData.customRunways.Add(runway);
                    }
                });

                /*DirectoryInfo folder = new DirectoryInfo(KSPUtil.ApplicationRootPath + "GameData/KerbalScienceFoundation/NavInstruments/Runways");
                 *
                 * if (folder.Exists)
                 * {
                 *  //FileInfo[] addlNavAidFiles = folder.GetFiles("*.rwy"); //this works great :D
                 *  FileInfo[] addlNavAidFiles = folder.GetFiles("*");
                 *
                 *
                 *  foreach (FileInfo f in addlNavAidFiles)
                 *  {
                 *      if ((f.Name.EndsWith("_rwy.cfg") && loadCustom_rwyCFG)|| f.Name.EndsWith(".rwy"))
                 *      {
                 *
                 *          if (enableDebugging)  Log.detail("NavUtil: found file " + f.Name.ToString());
                 *
                 *          if (f.Name == "custom.rwy" || (f.Name == "custom_rwy.cfg" && GlobalVariables.Settings.loadCustom_rwyCFG))
                 *          {
                 *              FlightData.customRunways.AddRange(NavUtilLib.ConfigLoader.GetRunwayListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                 *              if (enableDebugging)  Log.detail("NavUtil: Found " + f.Name + " with " + FlightData.customRunways.Count + " runway definitions");
                 *
                 *          }
                 *
                 *          if (enableDebugging) Log.detail("NavUtil: Found " + f.Name);
                 *
                 *          FlightData.rwyList.AddRange(NavUtilLib.ConfigLoader.GetRunwayListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                 *          //! FlightData.gsList.AddRange(NavUtilLib.ConfigLoader.GetGlideslopeListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                 *          //}
                 *      }
                 *  }
                 * }*/

                navAidsIsLoaded = true;
            }
コード例 #2
0
            public static void loadNavAids()
            {
                if (enableDebugging)
                {
                    Debug.Log("NavUtil: Loading NavAid database...");
                }
                FlightData.rwyList.Clear();
                FlightData.rwyList = ConfigLoader.GetRunwayListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/defaultRunways.cfg");
                FlightData.gsList.Clear();
                FlightData.gsList = ConfigLoader.GetGlideslopeListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/glideslopes.cfg");

                FlightData.customRunways.Clear();

                DirectoryInfo folder = new DirectoryInfo(KSPUtil.ApplicationRootPath + "GameData/KerbalScienceFoundation/NavInstruments/Runways");

                if (folder.Exists)
                {
                    //FileInfo[] addlNavAidFiles = folder.GetFiles("*.rwy"); //this works great :D
                    FileInfo[] addlNavAidFiles = folder.GetFiles("*");


                    foreach (FileInfo f in addlNavAidFiles)
                    {
                        if ((f.Name.EndsWith("_rwy.cfg") && loadCustom_rwyCFG) || f.Name.EndsWith(".rwy"))
                        {
                            if (enableDebugging)
                            {
                                Debug.Log("NavUtil: found file " + f.Name.ToString());
                            }

                            if (f.Name == "custom.rwy" || (f.Name == "custom_rwy.cfg" && GlobalVariables.Settings.loadCustom_rwyCFG))
                            {
                                FlightData.customRunways.AddRange(NavUtilLib.ConfigLoader.GetRunwayListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                                if (enableDebugging)
                                {
                                    Debug.Log("NavUtil: Found " + f.Name + " with " + FlightData.customRunways.Count + " runway definitions");
                                }
                            }

                            if (enableDebugging)
                            {
                                Debug.Log("NavUtil: Found " + f.Name);
                            }

                            FlightData.rwyList.AddRange(NavUtilLib.ConfigLoader.GetRunwayListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                            FlightData.gsList.AddRange(NavUtilLib.ConfigLoader.GetGlideslopeListFromConfig("GameData/KerbalScienceFoundation/NavInstruments/Runways/" + f.Name));
                            //}
                        }
                    }
                }

                navAidsIsLoaded = true;
            }