/// <summary>
 /// Parses the passed file (uses KSP.IO) and returns the parsed object
 /// </summary>
 /// <returns>The file.</returns>
 /// <param name="path">Path.</param>
 public object readFile(String path)
 {
     KSP.IO.TextReader reader = KSP.IO.TextReader.CreateForType <MissionController> (path);
     try {
         return(readObject(reader));
     } catch (Exception e) {
         Debug.LogError(e.Message);
         return(null);
     } finally {
         reader.Close();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Parses the passed file (uses KSP.IO) and returns the parsed object
 /// </summary>
 /// <returns>The file.</returns>
 /// <param name="path">Path.</param>
 public object readFile(String path)
 {
     KSP.IO.TextReader reader = KSP.IO.TextReader.CreateForType <KerbalStuffVersion_BOM>(path);
     try
     {
         return(readObject(reader));
     }
     catch (Exception e)
     {
         log.error(e.Message);
         return(null);
     }
     finally
     {
         reader.Close();
     }
 }
Beispiel #3
0
        private void LoadAlarms()
        {
            string AlarmsFileVersion = "2";

            Alarms = new KACAlarmList();
            KSP.IO.TextReader tr      = KSP.IO.TextReader.CreateForType <KerbalAlarmClock>(String.Format("Alarms-{0}.txt", HighLogic.CurrentGame.Title));
            String            strFile = tr.ReadToEnd();

            tr.Close();

            while (strFile.Contains("|<ENDLINE>"))
            {
                String strAlarm = strFile.Substring(0, strFile.IndexOf("|<ENDLINE>"));
                strFile = strFile.Substring(strAlarm.Length + "|<ENDLINE>".Length).TrimStart("\r\n".ToCharArray());

                if (strAlarm.StartsWith("AlarmsFileVersion|"))
                {
                    AlarmsFileVersion = strAlarm.Split("|".ToCharArray())[1];
                    KACWorker.DebugLogFormatted("AlarmsFileVersion:{0}", AlarmsFileVersion);
                }
                else if (!strAlarm.StartsWith("VesselID|"))
                {
                    KACAlarm tmpAlarm = new KACAlarm();

                    switch (AlarmsFileVersion)
                    {
                    case "3":
                        tmpAlarm.LoadFromString3(strAlarm, KACWorkerGameState.CurrentTime.UT);
                        break;

                    default:
                        tmpAlarm.LoadFromString2(strAlarm);
                        break;
                    }

                    Alarms.Add(tmpAlarm);
                }
            }
        }
Beispiel #4
0
        private static void LoadFile()
        {
            string fileName = String.Format("Evas-{0}.txt", HighLogic.CurrentGame.Title);

            if (FileExcist(fileName))
            {
                KSP.IO.TextReader tr = KSP.IO.TextReader.CreateForType <EvaSettings>(fileName);

                string file = tr.ReadToEnd();
                tr.Close();

                EvaTokenReader reader = new EvaTokenReader(file);

                EvaDebug.DebugLog("Size KeySize: " + collection.Count);

                //read every eva.
                while (!reader.EOF)
                {
                    //Load all the eva's in the list.
                    LoadEva(reader.NextToken('[', ']'));
                }
            }
        }