public static void LoadConfiguration() { if (FileExcist("Config.cfg")) { KSP.IO.TextReader tr = KSP.IO.TextReader.CreateForType <EvaSettings>("Config.cfg"); string[] lines = tr.ReadToEnd().Split('\n'); foreach (var line in lines) { string[] parts = line.Split('='); try { if (parts.Length > 1) { string name = parts[0].Trim(); string value = parts[1].Trim(); switch (name) { case "ShowDebugLines": { displayDebugLinesSetting = bool.Parse(value); } break; case "ShowLoadingKerbals": { displayLoadingKerbals = bool.Parse(value); } break; case "EnableHelmetToggle": { displayToggleHelmet = bool.Parse(value); } break; case "SelectMouseButton": { selectMouseButton = int.Parse(value); } break; case "DispatchMouseButton": { dispatchMouseButton = int.Parse(value); } break; case "SelectKey": { selectKeyButton = value; } break; case "DispatchKey": { dispatchKeyButton = value; } break; case "TargetVesselBySelection": { targetVesselBySelection = bool.Parse(value); } break; } } } catch { EvaDebug.DebugWarning("[EFX] Config loading error "); } } displayDebugLines = displayDebugLinesSetting; } }
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); } } }
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('[', ']')); } } }