protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); bool wasEnabled = balancer.smartTranslation; GUILayout.BeginHorizontal(); balancer.smartTranslation = GUILayout.Toggle(balancer.smartTranslation, Localizer.Format("#MechJeb_RCSBalancer_checkbox1"), GUILayout.Width(130));//"Smart translation" GUILayout.EndHorizontal(); if (wasEnabled != balancer.smartTranslation) { balancer.ResetThrusterForces(); if (balancer.smartTranslation) { balancer.users.Add(this); } else { balancer.users.Remove(this); } } if (balancer.smartTranslation) { // Overdrive double oldOverdrive = balancer.overdrive; double oldOverdriveScale = balancer.overdriveScale; double oldFactorTorque = balancer.tuningParamFactorTorque; double oldFactorTranslate = balancer.tuningParamFactorTranslate; double oldFactorWaste = balancer.tuningParamFactorWaste; GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RCSBalancer_label1"), balancer.overdrive, "%");//"Overdrive" double sliderVal = GUILayout.HorizontalSlider((float)balancer.overdrive, 0.0F, 1.0F); const int sliderPrecision = 3; if (Math.Round(Math.Abs(sliderVal - oldOverdrive), sliderPrecision) > 0) { double rounded = Math.Round(sliderVal, sliderPrecision); balancer.overdrive = new EditableDoubleMult(rounded, 0.01); } GUILayout.Label(Localizer.Format("#MechJeb_RCSBalancer_label2"));//"Overdrive increases power when possible, at the cost of RCS fuel efficiency." // Advanced options balancer.advancedOptions = GUILayout.Toggle(balancer.advancedOptions, Localizer.Format("#MechJeb_RCSBalancer_checkbox2"));//"Advanced options" if (balancer.advancedOptions) { // This doesn't work properly, and it might not even be needed. //balancer.smartRotation = GUILayout.Toggle(balancer.smartRotation, "Smart rotation"); GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RCSBalancer_label3"), balancer.overdriveScale); //"Overdrive scale" GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RCSBalancer_label4"), balancer.tuningParamFactorTorque); //"torque factor" GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RCSBalancer_label5"), balancer.tuningParamFactorTranslate); //"Translate factor" GuiUtils.SimpleTextBox(Localizer.Format("#MechJeb_RCSBalancer_label6"), balancer.tuningParamFactorWaste); //"Waste factor" } // Apply tuning parameters. if (oldOverdrive != balancer.overdrive || oldOverdriveScale != balancer.overdriveScale || oldFactorTorque != balancer.tuningParamFactorTorque || oldFactorTranslate != balancer.tuningParamFactorTranslate || oldFactorWaste != balancer.tuningParamFactorWaste) { balancer.UpdateTuningParameters(); } } if (balancer.smartTranslation) { balancer.users.Add(this); } else { balancer.users.Remove(this); } GUILayout.EndVertical(); base.WindowGUI(windowID); }
protected override void WindowGUI(int windowID) { GUILayout.BeginVertical(); bool wasEnabled = balancer.smartTranslation; GUILayout.BeginHorizontal(); balancer.smartTranslation = GUILayout.Toggle(balancer.smartTranslation, "Smart translation", GUILayout.Width(130)); GUIStyle s = new GUIStyle(GUI.skin.label); s.normal.textColor = Color.yellow; GUILayout.Label("experimental", s); GUILayout.EndHorizontal(); if (wasEnabled != balancer.smartTranslation) { balancer.ResetThrusterForces(); if (balancer.smartTranslation) { balancer.users.Add(this); } else { balancer.users.Remove(this); } } if (balancer.smartTranslation) { // Overdrive double oldOverdrive = balancer.overdrive; double oldOverdriveScale = balancer.overdriveScale; double oldFactorTorque = balancer.tuningParamFactorTorque; double oldFactorTranslate = balancer.tuningParamFactorTranslate; double oldFactorWaste = balancer.tuningParamFactorWaste; GuiUtils.SimpleTextBox("Overdrive", balancer.overdrive, "%"); double sliderVal = GUILayout.HorizontalSlider((float)balancer.overdrive, 0.0F, 1.0F); int sliderPrecision = 3; if (Math.Round(Math.Abs(sliderVal - oldOverdrive), sliderPrecision) > 0) { double rounded = Math.Round(sliderVal, sliderPrecision); balancer.overdrive = new EditableDoubleMult(rounded, 0.01); } GUILayout.Label("Overdrive increases power when possible, at the cost of RCS fuel efficiency."); // Advanced options balancer.advancedOptions = GUILayout.Toggle(balancer.advancedOptions, "Advanced options"); if (balancer.advancedOptions) { // This doesn't work properly, and it might not even be needed. //balancer.smartRotation = GUILayout.Toggle(balancer.smartRotation, "Smart rotation"); GuiUtils.SimpleTextBox("Overdrive scale", balancer.overdriveScale); GuiUtils.SimpleTextBox("Torque factor", balancer.tuningParamFactorTorque); GuiUtils.SimpleTextBox("Translate factor", balancer.tuningParamFactorTranslate); GuiUtils.SimpleTextBox("Waste factor", balancer.tuningParamFactorWaste); } // Apply tuning parameters. if (oldOverdrive != balancer.overdrive || oldOverdriveScale != balancer.overdriveScale || oldFactorTorque != balancer.tuningParamFactorTorque || oldFactorTranslate != balancer.tuningParamFactorTranslate || oldFactorWaste != balancer.tuningParamFactorWaste) { balancer.UpdateTuningParameters(); } } if (balancer.smartTranslation) { balancer.users.Add(this); } else { balancer.users.Remove(this); } GUILayout.EndVertical(); base.WindowGUI(windowID); }