private void SelectPreset(int index) { selectedPreset = IspPresetList[index]; workingEngineRatingIspCutoff = selectedPreset.ratingIspCutoff; workingEngineRatingThrustCutoff = selectedPreset.ratingThrustCutoff; if (workingEngineRatingIspCutoff == -1) { workingEngineIspCutoffActive = false; workingEngineRatingIspCutoff = 0; } else workingEngineIspCutoffActive = true; if (workingEngineRatingThrustCutoff == -1) { workingEngineThrustCutoffActive = false; workingEngineRatingThrustCutoff = 0; } else workingEngineThrustCutoffActive = true; workingExtendToZero = selectedPreset.extendToZero; workingThrustCorrection = selectedPreset.thrustCorrection; workingIspAtmMult = selectedPreset.atmIspMult.ToString(); workingIspVacMult = selectedPreset.vacIspMult.ToString(); workingPresetDescription = selectedPreset.presetDescription; workingPresetName = selectedPreset.presetName; }
private void LoadPresets() { config = KSP.IO.PluginConfiguration.CreateForType<IspAdjustmentGUIController>(); config.load(); int presetNum = 0; do { string tmpName; tmpName = config.GetValue("IspPreset" + presetNum + "Name", "NothingHere"); //IspPreset tmp = config.GetValue("IspPreset" + presetNum, new IspPreset("NothingHere", "", 1, 1, false)); if (tmpName == "NothingHere") break; IspPreset tmp = new IspPreset(); tmp.presetName = tmpName; tmp.presetDescription = config.GetValue<string>("IspPreset" + presetNum + "Description"); tmp.vacIspMult = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "Vac")); tmp.atmIspMult = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "Atm")); tmp.extendToZero = config.GetValue<bool>("IspPreset" + presetNum + "Extend"); tmp.thrustCorrection = config.GetValue<bool>("IspPreset" + presetNum + "ThrustCorrection"); tmp.ratingIspCutoff = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "RatingIspCutoff", "385")); tmp.ratingThrustCutoff = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "RatingThrustCutoff", "300")); presetNum++; IspPresetList.Add(tmp); } while (true); string gameName = HighLogic.CurrentGame.Title; int selectedPresetNum = Convert.ToInt32(config.GetValue("SelectedPreset" + gameName, "0")); selectedPreset = IspPresetList[selectedPresetNum]; print("Presets Loaded..."); }