void DeactivateModule(ModulePWBFuelBalancer m) { m.balanceStatus = BalanceStatus.Deactivated; m.Status = "Deactivated"; m.Events["Disable"].active = false; m.Events["BalanceFuel"].active = true; m.Events["Maintain"].active = true; }
private void OnWindow(int windowId) { try { Rect rect = new Rect(_currentWindowPosition.width - 20, 4, 16, 16); if (GUI.Button(rect, "x", WhiteButton)) { toolbarControl.SetFalse(true); } GUILayout.BeginVertical(); if (HighLogic.LoadedSceneIsFlight) { if (_listFuelBalancers.Count > 1) { selStrings = selStringsLong; } else { selStrings = selStringsShort; } int selGridInt = GUILayout.SelectionGrid((int)editMode, selStrings.ToArray(), 3);; editMode = (EditMode)selGridInt; if (_listFuelBalancers.Count == 1 && editMode == EditMode.select) { editMode = EditMode.full; } } else { editMode = EditMode.full; } strings.Clear(); List <ModulePWBFuelBalancer> .Enumerator balancers = _listFuelBalancers.GetEnumerator(); if (_listFuelBalancers.Count > 0) { if (editMode >= EditMode.select) { while (balancers.MoveNext()) { if (balancers.Current == null) { continue; } if (balancers.Current.isPWBFuelBalancerPart) { strings.Add(balancers.Current.BalancerName); } else { strings.Add(balancers.Current.part.partInfo.title); } } selectedBalancer = GuiUtils.ComboBox.Box(selectedBalancer, strings.ToArray(), this); if (selectedBalancer != oldSelectedBalancer) { oldEditMode = EditMode.none; if (oldSelectedBalancer != -1 && _listFuelBalancers[oldSelectedBalancer].SavedCoMMarkerVisible) { _listFuelBalancers[oldSelectedBalancer].ToggleSavedMarker(); } oldSelectedBalancer = selectedBalancer; activeSavedCoM = -1; } } selBal = _listFuelBalancers[selectedBalancer]; // Provide a facility to change the name of the balancer GUILayout.BeginHorizontal(); GUILayout.Label("Name: "); string newName = GUILayout.TextField(selBal.BalancerName, GUILayout.Width(120)); if (HighLogic.LoadedSceneIsFlight && selBal.balanceStatus >= ModulePWBFuelBalancer.BalanceStatus.Maintaining) { GUILayout.Label("Active Balancer", YellowLabel); } if (HighLogic.LoadedSceneIsFlight && selBal.balanceStatus == ModulePWBFuelBalancer.BalanceStatus.Balance_not_possible) { GUILayout.Label("Balance Not Possible", YellowLabel); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (selBal.BalancerName != newName && newName != "") { selBal.BalancerName = newName; } if (editMode == EditMode.full) { GetSliderInfo("▼ Max Slider Value ▼", ref selBal.maxVal, 20, true); GUILayout.Space(10); GetSliderInfo("Low/High:", ref selBal.VecFuelBalancerCoMTarget.y, selBal.maxVal); if ((HighLogic.LoadedSceneIsEditor && EditorDriver.editorFacility == EditorFacility.SPH) || (HighLogic.LoadedSceneIsFlight && selBal.vessel.vesselType == VesselType.Plane)) { GetSliderInfo("Fore/Aft:", ref selBal.VecFuelBalancerCoMTarget.z, -selBal.maxVal); GetSliderInfo("Left/Right:", ref selBal.VecFuelBalancerCoMTarget.x, selBal.maxVal); // } else { GetSliderInfo("Fore/Aft:", ref selBal.VecFuelBalancerCoMTarget.x, -selBal.maxVal); GetSliderInfo("Left/Right:", ref selBal.VecFuelBalancerCoMTarget.z, -selBal.maxVal); } } GUILayout.EndVertical(); // GUILayout.EndHorizontal(); string toggleText; if (HighLogic.LoadedSceneIsFlight) { GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("Keep Balanced", selBal.balanceStatus == ModulePWBFuelBalancer.BalanceStatus.Maintaining ? YellowButton : NormalButton, GUILayout.Width(120))) { selBal.Maintain(); } if (GUILayout.Button("Balance (one time)", selBal.balanceStatus == ModulePWBFuelBalancer.BalanceStatus.Balancing ? YellowButton : NormalButton, GUILayout.Width(120))) { selBal.BalanceFuel(); } if (GUILayout.Button("Deactivate", GUILayout.Width(120))) { selBal.Disable(); } GUILayout.EndHorizontal(); GUILayout.Space(10); } //if (HighLogic.LoadedSceneIsFlight) // && selBal.isPWBFuelBalancerPart) { GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(120)); GUI.enabled = selBal.isPWBFuelBalancerPart || selBal.savedMarkers.Count > 0; if (GUILayout.Button("Set CoM", GUILayout.Width(120))) { selBal.SetCoM(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUI.enabled = selBal.VecFuelBalancerCoMTarget != ModulePWBFuelBalancer.NegVector; toggleText = selBal.MarkerVisible ? "Hide Markers" : "Show Markers"; if (GUILayout.Button(toggleText, GUILayout.Width(120))) { selBal.ToggleAllMarkers(); } GUI.enabled = selBal.VecFuelBalancerCoMTarget != ModulePWBFuelBalancer.NegVector; // && selBal.SavedCoMMarker; toggleText = selBal.SavedCoMMarkerVisible ? "Hide Saved CoM" : "Show Saved CoM"; if (GUILayout.Button(toggleText, GUILayout.Width(120))) { selBal.ToggleSavedMarker(); } GUI.enabled = true; if (HighLogic.LoadedSceneIsFlight) { toggleText = selBal.ActualCoMMarkerVisible ? "Hide Actual CoM" : "Show Actual CoM"; if (GUILayout.Button(toggleText, GUILayout.Width(120))) { Log.Info("Balancer: " + selBal.BalancerName + " Toggle CoM Marker"); selBal.ToggleActualMarker(); } } GUILayout.EndHorizontal(); if (selBal.isPWBFuelBalancerPart) { // Save slot 1 GUILayout.BeginHorizontal(); selBal.Save1Name = GUILayout.TextField(selBal.Save1Name, activeSavedCoM == 0 ? YellowTextField : NormalTextField, GUILayout.Width(120)); GUI.enabled = selBal.VecSave1CoMTarget != ModulePWBFuelBalancer.NegVector; if (GUILayout.Button("Load", GUILayout.Width(120))) { selBal.VecFuelBalancerCoMTarget = selBal.VecSave1CoMTarget; activeSavedCoM = 0; } if (GUILayout.Button("Save", GUILayout.Width(120))) { selBal.VecSave1CoMTarget = selBal.VecFuelBalancerCoMTarget; activeSavedCoM = 0; } GUILayout.EndHorizontal(); GUI.enabled = true; // Save slot 2 GUILayout.BeginHorizontal(); selBal.Save2Name = GUILayout.TextField(selBal.Save2Name, activeSavedCoM == 1 ? YellowTextField : NormalTextField, GUILayout.Width(120)); GUI.enabled = selBal.VecSave2CoMTarget != ModulePWBFuelBalancer.NegVector; if (GUILayout.Button("Load", GUILayout.Width(120))) { selBal.VecFuelBalancerCoMTarget = selBal.VecSave2CoMTarget; activeSavedCoM = 1; } if (GUILayout.Button("Save", GUILayout.Width(120))) { selBal.VecSave2CoMTarget = selBal.VecFuelBalancerCoMTarget; activeSavedCoM = 1; } GUI.enabled = true; GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); if (GUILayout.Button("Add Marker", GUILayout.Width(120))) { selBal.savedMarkers.Add(new SavedMarker("", new Vector3(0, 0, 0))); selBal.SetCoM(); } #if false GUI.enabled = selBal.VecFuelBalancerCoMTarget != ModulePWBFuelBalancer.NegVector;; toggleText = selBal.MarkerVisible ? "Hide Markers" : "Show Markers"; if (GUILayout.Button(toggleText, GUILayout.Width(120))) { selBal.ToggleAllMarkers(); } GUI.enabled = true; #else GUILayout.Label(" ", GUILayout.Width(120)); #endif toggleText = selBal.ActualCoLMarkerVisible ? "Hide CoL" : "Show CoL"; if (GUILayout.Button(toggleText, GUILayout.Width(120))) { Log.Info("Balancer: " + selBal.BalancerName + " Toggle CoL Marker"); selBal.ToggleCoLMarker(); } GUILayout.EndHorizontal(); if (selBal.savedMarkers == null) { Log.Error("savedMarkers is null"); } for (int i = 0; i < selBal.savedMarkers.Count; i++) { GUILayout.BeginHorizontal(); selBal.savedMarkers[i].name = GUILayout.TextField(selBal.savedMarkers[i].name, activeSavedCoM == i ? YellowTextField : NormalTextField, GUILayout.Width(120)); GUI.enabled = selBal.savedMarkers[i].marker != ModulePWBFuelBalancer.NegVector && selBal.savedMarkers[i].name != ""; if (GUILayout.Button("Load", GUILayout.Width(120))) { selBal.VecFuelBalancerCoMTarget = selBal.savedMarkers[i].marker; activeSavedCoM = i; } if (GUILayout.Button("Save", GUILayout.Width(120))) { selBal.savedMarkers[i].marker = selBal.VecFuelBalancerCoMTarget; activeSavedCoM = i; } GUI.enabled = true; if (GUILayout.Button("X", GUILayout.Width(25))) { selBal.savedMarkers.Remove(selBal.savedMarkers[i]); } GUILayout.EndHorizontal(); } } } else { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("No Fuel Balancers mounted"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); } GUI.DragWindow(); } catch (Exception ex) { Debug.LogException(ex); } }
private void OnWindow(int windowId) { try { Rect rect = new Rect(_currentWindowPosition.width - 20, 4, 16, 16); if (GUI.Button(rect, "")) { OnAppLaunchToggle(); } GUILayout.BeginVertical(); List <string> strings = new List <string>(); if (_listFuelBalancers.Count > 0) { List <ModulePWBFuelBalancer> .Enumerator balancers = _listFuelBalancers.GetEnumerator(); while (balancers.MoveNext()) { if (balancers.Current == null) { continue; } strings.Add(balancers.Current.BalancerName); // + " position:" + balancer.vecFuelBalancerCoMTarget.ToString()); // GUILayout.Label(balancer.name + " position:" + balancer.vecFuelBalancerCoMTarget.ToString()); } _selectedBalancer = GuiUtils.ComboBox.Box(_selectedBalancer, strings.ToArray(), this); // It will be useful to have a reference to the selected balancer ModulePWBFuelBalancer selBal = _listFuelBalancers[_selectedBalancer]; // Provide a facility to change the name of the balancer { string oldName = selBal.BalancerName; string newName = GUILayout.TextField(oldName); if (oldName != newName) { selBal.BalancerName = newName; } } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); if (GUILayout.Button("up")) { selBal.VecFuelBalancerCoMTarget.y += 0.05f; } if (GUILayout.Button("down")) { selBal.VecFuelBalancerCoMTarget.y -= 0.05f; } GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button("forward")) { selBal.VecFuelBalancerCoMTarget.x += 0.05f; } if (GUILayout.Button("back")) { selBal.VecFuelBalancerCoMTarget.x -= 0.05f; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("left")) { selBal.VecFuelBalancerCoMTarget.z += 0.05f; } if (GUILayout.Button("right")) { selBal.VecFuelBalancerCoMTarget.z -= 0.05f; } GUILayout.EndHorizontal(); { string toggleText = selBal.MarkerVisible ? "Hide Marker" : "Show Marker"; if (GUILayout.Button(toggleText)) { selBal.ToggleMarker(); } } // Save slot 1 GUILayout.BeginHorizontal(); selBal.Save1Name = GUILayout.TextField(selBal.Save1Name); if (GUILayout.Button("Load")) { selBal.VecFuelBalancerCoMTarget = selBal.VecSave1CoMTarget; } if (GUILayout.Button("Save")) { selBal.VecSave1CoMTarget = selBal.VecFuelBalancerCoMTarget; } GUILayout.EndHorizontal(); // Save slot 2 GUILayout.BeginHorizontal(); selBal.Save2Name = GUILayout.TextField(selBal.Save2Name); if (GUILayout.Button("Load")) { selBal.VecFuelBalancerCoMTarget = selBal.VecSave2CoMTarget; } if (GUILayout.Button("Save")) { selBal.VecSave2CoMTarget = selBal.VecFuelBalancerCoMTarget; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUI.DragWindow(); } catch (Exception ex) { Debug.LogException(ex); } }
public void LinkPart(ModulePWBFuelBalancer newPart) { //print("Linking part"); _linkedPart = newPart; }