public void EnableAnimationSuite() { var vessel = FlightGlobals.ActiveVessel; if (vessel.evaController == null) { ScreenMessages.PostScreenMessage(new ScreenMessage("<color=" + Colors.DefaultMessageColor + ">Active vessel must be an EVA to use the Animation Suite</color>", 3f, ScreenMessageStyle.UPPER_CENTER)); //set the button back to false toolbarControl.SetFalse(false); return; } Kerbal = new SelectedKerbalEVA(vessel.evaController); AnimationClip = new EditableAnimationClip(Kerbal); if (!Kerbal.EnterAnimationMode()) { //wipe the state Kerbal = null; AnimationClip = null; CurrentBone = null; //set the button back to false if it failed toolbarControl.SetFalse(false); return; } MusicIsPlaying = true; }
void Update() { //Thanks bananashavings http://forum.kerbalspaceprogram.com/index.php?/profile/156147-bananashavings/ - https://gist.github.com/bananashavings/e698f4359e1628b5d6ef //Also thanks to Crzyrndm for the fix to that code! //(HighLogic.LoadedScene == GameScenes.TRACKSTATION || HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.EDITOR) if ((GameSettings.MODIFIER_KEY.GetKey()) && Input.GetKeyDown(KeyCode.Slash)) { windowEnabled = !windowEnabled; if (ApplicationLauncher.Ready) { if (toolbarControl != null) { if (windowEnabled) { toolbarControl.SetTrue(true); } else { toolbarControl.SetFalse(true); } } } } }
public void OnClick() { //figure out if mod+clicked _includeCrew = GameSettings.MODIFIER_KEY.GetKey(); //includeCrew = false; bool ctrlHeld = Input.GetKey(KeyCode.LeftControl); if (Input.GetKey(KeyCode.LeftShift)) { OpenConvertWindow(); //convert ships to craft files // _theButton.SetFalse(); toolbarControl.SetFalse(false); return; } //get the selected craft SpaceTracking trackingStation = (SpaceTracking)FindObjectOfType(typeof(SpaceTracking)); Vessel selectedVessel = trackingStation.SelectedVessel; if (ctrlHeld || _includeCrew) //ctrl or modifier held { OpenImportWindow(); } else if (selectedVessel != null) { ExportSelectedCraft(selectedVessel); } // _theButton.SetFalse(false); toolbarControl.SetFalse(); }
// We add this to our window as a callback // It tells us when the window is closed so we can keep the button in sync public void OnChecklistWindowClosed(object sender, EventArgs e) { // _logger.Trace( "OnChecklistWindowClosed" ); if (checklistToolbarControl != null) { checklistToolbarControl.SetFalse(false); } UpdateChecklistVisibility(false); }
void CloseWindow() { visible = false; abortValues.SetAllValues(abortValues); if (toolbarControl != null) { toolbarControl.SetFalse(false); } }
internal void Set(bool SetTrue, bool force = false) { if (toolbarControl != null) { if (SetTrue) { toolbarControl.SetTrue(force); } else { toolbarControl.SetFalse(force); } } QDebug.Log("QStock.Set", "QStockToolbar"); }
private void MakeButton() { if (toolbarControl == null) { toolbarControl = gameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(ProximityHide, ProximityShow, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, MODID, "proximityButton", GetTextureName(38), GetTextureName(24), MODNAME ); toolbarControl.AddLeftRightClickCallbacks(null, ToggleOnRightClick); } toolbarControl.buttonActive = true; if (!Proximity.ToolbarShowSettings) { toolbarControl.SetTrue(false); } else { toolbarControl.SetFalse(false); } }
void onPluginDisable(bool byUser) { if (byUser) { toolbarControl.SetFalse(false); } }
public void Update() { if (KartographSettings.Instance.AutoHide && _autoHideTime != 0.0f && Time.time > _autoHideTime && _active && !_windowPos.Contains(Event.current.mousePosition)) { toolbarControl.SetFalse(true); } }
public void OnGUI() { if (gamePaused || globalHidden || !active) { return; } if (FlightGlobals.ActiveVessel.situation != Vessel.Situations.LANDED) { #if false if (appLauncherButton != null) { appLauncherButton.SetFalse(); } else { onToggle(); } return; #endif toolbarControl.SetFalse(); } if (refresh) { windowRect.height = 0; refresh = false; } windowRect = Layout.Window( windowId, windowRect, DrawGUI, Localizer.Format("#SimpleLogistics_WindowTitle"), //"Logistics Network" GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) ); if (windowRect.Contains(Event.current.mousePosition)) { LockControls(); } else { UnlockControls(); } }
public void OnGUI() { if (gamePaused || GUIglobalHidden || !GUIactive) { return; } string IsEligible = InSituation.NetworkEligible(FlightGlobals.ActiveVessel); if (!String.IsNullOrEmpty(IsEligible)) { toolbarControl.SetFalse(); Logs.msg(IsEligible); } if (refreshGUI) { windowRect.height = 0; refreshGUI = false; } if (HighLogic.CurrentGame.Parameters.CustomParams <OptionsA>().useAlternateSkin) { GUI.skin = HighLogic.Skin; } GUI.backgroundColor = titleBackColor; GUI.contentColor = titleColor; windowRect = ClickThruBlocker.GUILayoutWindow( windowId, windowRect, DrawGUI, Localizer.Format("#SimpleLogistics_WindowTitle", Version.Text), //"Logistics Network v " GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) ); if (windowRect.Contains(Event.current.mousePosition)) { LockControls(); } else { UnlockControls(); } }
private void RenderMainWindow(int windowId) { GUILayout.BeginVertical(); if (availableExperiments.Count > 0) { mainWindowScrollPosition = GUILayout.BeginScrollView(mainWindowScrollPosition, GUILayout.Height(Screen.height / 2)); // foreach (var available in availableExperiments) for (var i = 0; i < availableExperiments.Count; i++) { if (availableExperiments[i].done) { GUI.enabled = false; } if (GUILayout.Button(availableExperiments[i].experiment.experimentTitle + " " + availableExperiments[i].possibleGain.ToString("0.00"), GUILayout.Height(25))) { var l = new List <ScienceExperiment>(); l.Add(availableExperiments[i].experiment); GainScience(l, false); availableExperiments[i].done = true; } if (!GUI.enabled) { GUI.enabled = true; } } GUILayout.EndScrollView(); GUILayout.Space(10); if (availableExperiments.Where(x => !x.done).Count() == 0) { GUI.enabled = false; } if (GUILayout.Button("Make me happy! " + availableExperiments.Where(x => !x.done).Select(x => x.possibleGain).Sum().ToString("0.00"), GUILayout.Height(25))) { availableExperiments.ForEach(x => x.done = true); GainScience(availableExperiments.Select(x => x.experiment).ToList(), false); } if (!GUI.enabled) { GUI.enabled = true; } } else { GUILayout.Label("Nothing to do here, go research something."); } if (GUILayout.Button("Close", GUILayout.Height(25))) { toolbarControl.SetFalse(); } // appLauncherButton.SetFalse(); GUILayout.EndVertical(); GUI.DragWindow(); }
public override void OnLoad(ConfigNode node) { Log.Info("OnLoad"); ConfigInfo.Instance.Load(node); _machine.StartFSM("Init"); //_button.SetFalse(); if (toolbarControl != null) { toolbarControl.SetFalse(true); } }
public static void setBtnState(bool state, bool click = false) { if (state) { toolbarControl.SetTrue(click); } else { toolbarControl.SetFalse(click); } }
public void Update() { if (showBurst) //Set sampling to one always whenver burst mode is on to prevent crashing. { superSampleValueInt = 1; superSampleValueString = "1"; } try { if (buttonsEnabled && Input.GetKey(takeScreenshotKey) && (modifier == KeyCode.None || Input.GetKey(modifier))) // Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))) //Input.GetKeyDown(screenshotKey)) { if (showBurst) { print("burst mode start"); fireBurstShot(); } else { print("Screenshot button pressed!"); takeScreenshot(); } } if (Input.GetKeyDown(showGUIKey)) { // = !showFullUI; //showUI = !showUI; if (!showFullUI) { toolbarControl.SetTrue(true); } else { toolbarControl.SetFalse(true); } #if false toolbarButton.Visible toolbarButton.TexturePath = showFullUI ? "BOSS/bon" : "BOSS/boff"; #endif saveSettings(); } } catch //(UnityException e) //Catches the unity exception for a keycode that isnt a valid key. Updating the UI to let the user know. { if (!invalidkey) { invalidkey = true; } } }
private void ChecklistButton_RightClick(object sender, EventArgs e) { if (Config.RighClickMutesMusic) { // Toggle the muted state Muted = !Muted; ScreenMessages.PostScreenMessage("[x] Science! - Music Mute"); } else { if (_active && UiActive()) { if (GameHelper.AllowStatusWindow()) { bool NewVisibility = !_statusWindow.IsVisible(); _statusWindow.SetVisible(NewVisibility); UpdateStatusVisibility(NewVisibility); _logger.Trace("ChecklistButton_RightClick, _statusWindow.IsVisible(): " + _statusWindow.IsVisible()); if (_statusWindow.IsVisible()) { if (statusToolbarControl != null) { statusToolbarControl.SetTrue(true); } ScienceEventHandler.ScheduleExperimentUpdate(seconds: 0.1f); } else { if (statusToolbarControl != null) { statusToolbarControl.SetFalse(true); } } } } } }
private void OnIconClickHandler() { if (_groupWindow == null) { _groupWindow = new GroupWindow <ILightArrayConfig>(LightConfig); _groupWindow.AllLightConfigSaved += (sender, e) => SaveConfig(e); _groupWindow.SetVisible(true); } else { _groupWindow.ToggleVisible(); } toolbarControl.SetFalse(false); }
internal void Set(bool SetTrue, bool force = false) { if (toolbarControl != null) { if (SetTrue) { toolbarControl.SetTrue(force); } else { toolbarControl.SetFalse(force); } } Log("Set: " + SetTrue + " " + force, "QStockToolbar"); }
internal void Set(bool SetTrue, bool force = false) { if (toolbarControl != null) { if (SetTrue) { //if (appLauncherButton.toggleButton.CurrentState == KSP.UI.UIRadioButton.State.False) { toolbarControl.SetTrue(force); //} } else { //if (appLauncherButton.toggleButton.CurrentState == KSP.UI.UIRadioButton.State.True) { toolbarControl.SetFalse(force); //} } } Log("Set " + SetTrue + " force: " + force, "QStockToolbar"); }
void HideWindow() { visible = false; //Button.SetFalse(); toolbarControl.SetFalse(true); }
private void WindowGUI(int windowID) { GUILayout.BeginHorizontal(); allActiveEngines = GUILayout.Toggle(allActiveEngines, "Apply to all active engines"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); allInactiveEngines = GUILayout.Toggle(allInactiveEngines, "Apply to all inactive engines"); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.BeginHorizontal(); allRCS = GUILayout.Toggle(allRCS, "Apply to all RCS"); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Apply to the following Engine Types:"); GUILayout.EndHorizontal(); foreach (var et in engineTypes) { GUILayout.BeginHorizontal(); GUILayout.Space(10); et.update = GUILayout.Toggle(et.update, et.engineType); GUILayout.EndHorizontal(); } GUILayout.Space(15); GUILayout.BeginHorizontal(); GUIStyle s; if (throttleLimit != origThrottleLimit && yellowLabel != null) { s = yellowLabel; } else { s = new GUIStyle(GUI.skin.label); } GUILayout.Label("Thrust Limit (" + throttleLimit.ToString("F1") + "): ", s); GUILayout.FlexibleSpace(); throttleLimit = GUILayout.HorizontalSlider(throttleLimit, 0, 100, GUILayout.Width(200)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Instant Presets", yellowLabel); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Set all to " + HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetOne + "% ")) { throttleLimit = HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetOne; apply = true; } if (GUILayout.Button("Set all to " + HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetTwo + "%")) { throttleLimit = HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetTwo; apply = true; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Set all to " + HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetThree + "%")) { throttleLimit = HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetThree; apply = true; } if (GUILayout.Button("Set all to " + HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetFour + "%")) { throttleLimit = HighLogic.CurrentGame.Parameters.CustomParams <TLE_Settings>().presetFour; apply = true; } GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (throttleLimit == origThrottleLimit) { GUI.enabled = false; } if (GUILayout.Button("Apply")) { apply = true; } if (apply) { apply = false; throttleLimit = (float)Math.Round(throttleLimit, 1); origThrottleLimit = throttleLimit; setThrustLimit(throttleLimit); } GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button("Close")) { toolbarControl.SetFalse(true); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUI.DragWindow(); }
private void fly(FlightCtrlState s) { if (!Launching) { Kill(); return; } DebugMessage = ""; Vessel vessel = getVessel; if (program != AscentProgram.InCoasting && vessel.orbit.ApA > DestinationHeight * 1000 && vessel.altitude < vessel.StableOrbitHeight()) { CalculateLosses(getVessel); // save launch, ignoring losses due to coasting losses, but so we get results earlier launchdb.RecordLaunch(); launchdb.Save(); program = AscentProgram.InCoasting; DebugMessage += "In Coasting program\n"; Throttle.force(0); Log("minorbit {0}, {1}", vessel.mainBody.minOrbitalDistance, vessel.StableOrbitHeight()); // time warp to speed up things (if enabled) ApplySpeedup(2); } else if (vessel.orbit.ApA > DestinationHeight * 1000 && vessel.altitude > vessel.StableOrbitHeight()) { Log("minorbit {0}, {1}", vessel.mainBody.minOrbitalDistance, vessel.StableOrbitHeight()); program = AscentProgram.InCircularisation; StopSpeedup(); GravityTurner.Log("Saving launchDB"); launchdb.RecordLaunch(); launchdb.Save(); Kill(); DebugMessage += "In Circularisation program\n"; if (mucore.Initialized) { program = AscentProgram.InCircularisation; mucore.CircularizeAtAP(); } //button.SetFalse(); toolbarControl.SetFalse(); } else { double minInsertionHeight = vessel.mainBody.atmosphere ? vessel.StableOrbitHeight() / 4 : Math.Max(DestinationHeight * 667, vessel.StableOrbitHeight() * 0.667); if (EnableStageManager && stage != null) { stage.Update(); } if (vessel.orbit.ApA < DestinationHeight * 1000) { s.mainThrottle = Calculations.APThrottle(vessel.orbit.timeToAp, this); } else { s.mainThrottle = 0; } if (program == AscentProgram.InInitialPitch && PitchSet) { if (vessel.ProgradePitch() + 90 >= TurnAngle - 0.1) { delayUT = double.NaN; // continue any previous timewarp RestoreTimeWarp(); ApplySpeedup(1); program = AscentProgram.InTurn; DebugMessage += "Turning now\n"; } } if (vessel.speed < StartSpeed) { DebugMessage += "In Launch program\n"; program = AscentProgram.InLaunch; if (vesselState.altitudeBottom > vesselState.vesselHeight) { attitude.attitudeTo(Quaternion.Euler(-90, LaunchHeading(vessel), 0) * RollRotation(), AttitudeReference.SURFACE_NORTH, this); } else { attitude.attitudeTo(Quaternion.Euler(-90, 0, vesselState.vesselHeading), AttitudeReference.SURFACE_NORTH, this); } } else if (program == AscentProgram.InLaunch || program == AscentProgram.InInitialPitch) { if (!PitchSet) { // remember and stop timewarp for pitching StoreTimeWarp(); StopSpeedup(); PitchSet = true; program = AscentProgram.InInitialPitch; delayUT = Planetarium.GetUniversalTime(); } DebugMessage += "In Pitch program\n"; double diffUT = Planetarium.GetUniversalTime() - delayUT; float newPitch = Mathf.Min((float)(((double)TurnAngle * diffUT) / 5.0d + 2.0d), TurnAngle); double pitch = (90d - vesselState.vesselPitch + vessel.ProgradePitch() + 90) / 2; attitude.attitudeTo(Quaternion.Euler(-90 + newPitch, LaunchHeading(vessel), 0) * RollRotation(), AttitudeReference.SURFACE_NORTH, this); DebugMessage += String.Format("TurnAngle: {0:0.00}\n", TurnAngle.value); DebugMessage += String.Format("Target pitch: {0:0.00}\n", newPitch); DebugMessage += String.Format("Current pitch: {0:0.00}\n", pitch); DebugMessage += String.Format("Prograde pitch: {0:0.00}\n", vessel.ProgradePitch() + 90); } else if (vesselState.dynamicPressure > vesselState.maxQ * 0.5 || vesselState.dynamicPressure > PressureCutoff || vessel.altitude < minInsertionHeight) { // Still ascending, or not yet below the cutoff pressure or below min insertion heigt DebugMessage += "In Turn program\n"; attitude.attitudeTo(Quaternion.Euler(vessel.ProgradePitch() - PitchAdjustment, LaunchHeading(vessel), 0) * RollRotation(), AttitudeReference.SURFACE_NORTH, this); } else { // did we reach the desired inclination? DebugMessage += String.Format("Insertion program\n"); Quaternion q = Quaternion.Euler(0 - PitchAdjustment, YawAdjustment, Roll); // smooth out change from surface to orbital prograde if (program != AscentProgram.InInsertion && program != AscentProgram.InCoasting) { // start timer if (Double.IsNaN(delayUT)) { // slow down timewarp delayUT = Planetarium.GetUniversalTime(); StoreTimeWarp(); StopSpeedup(); // switch NavBall UI FlightGlobals.SetSpeedMode(FlightGlobals.SpeedDisplayModes.Orbit); } double diffUT = Planetarium.GetUniversalTime() - delayUT; //attitude.attitudeTo(q, AttitudeReference.ORBIT, this); q.x = (attitude.lastAct.x * 8.0f + q.x) / 9.0f; if (diffUT > 10 || (attitude.lastAct.x > 0.02 && diffUT > 2.0)) { program = AscentProgram.InInsertion; delayUT = double.NaN; RestoreTimeWarp(); ApplySpeedup(2); } } attitude.attitudeTo(q, AttitudeReference.ORBIT, this); } attitude.enabled = true; attitude.Drive(s); CalculateLosses(getVessel); DebugMessage += "-"; } }
/// <summary> /// Force button to off state /// </summary> public void SetOff() { //_button.SetOff(); toolbarControl.SetFalse(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); } }
internal void drawWindow(int id) { GUI.skin = modStyle.skin; GUILayout.BeginVertical(); GUILayout.Label("EVA Enhancements - Settings", modStyle.guiStyles["titleLabel"]); GUILayout.EndVertical(); GUILayout.BeginVertical(); scrollPos = GUILayout.BeginScrollView(scrollPos); GUILayout.Label("Default Jetpack Power: " + settings.defaultJetPackPower.ToString("P0")); float newJetPackPower = GUILayout.HorizontalSlider(settings.defaultJetPackPower, 0f, 1f); if (newJetPackPower != settings.defaultJetPackPower) { settings.defaultJetPackPower = newJetPackPower; settings.Save(); } GUILayout.Space(10f); GUILayout.Label("Default Precision Jetpack Power: " + settings.defaultPrecisionModePower.ToString("P0")); float newPrecisionJetPackPower = GUILayout.HorizontalSlider(settings.defaultPrecisionModePower, 0f, 1f); if (newPrecisionJetPackPower != settings.defaultPrecisionModePower) { settings.defaultPrecisionModePower = newPrecisionJetPackPower; settings.Save(); } GUILayout.Space(10f); string str; GUILayout.BeginHorizontal(); GUILayout.Label("Pitch Down", GUILayout.ExpandWidth(true)); KeyCodeExtended c = null; if (Event.current.isKey) { c = new KeyCodeExtended(Event.current.keyCode); } if (settingPitchDown) { GUILayout.Label("<Press any key>"); if (Event.current.isKey && c.ToString() != GameSettings.MODIFIER_KEY.primary.ToString()) { Log.Info("keyodeExtended: " + c.ToString() + ", primary: " + GameSettings.MODIFIER_KEY.primary.ToString()); settings.pitchDown = new KeyCodeExtended(Event.current.keyCode); settings.modKeypitchDown = ExtendedInput.GetKey(GameSettings.MODIFIER_KEY.primary); settings.Save(); settingPitchDown = false; } } else { str = settings.pitchDown.ToString(); if (settings.modKeypitchDown) { str = "Alt-" + str; } if (GUILayout.Button(new GUIContent(str), GUILayout.Width(125))) { settingPitchDown = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Pitch Up", GUILayout.ExpandWidth(true)); if (settingPitchUp) { GUILayout.Label("<Press any key>"); if (Event.current.isKey && c.ToString() != GameSettings.MODIFIER_KEY.primary.ToString()) { settings.pitchUp = new KeyCodeExtended(Event.current.keyCode); settings.modKeypitchUp = ExtendedInput.GetKey(GameSettings.MODIFIER_KEY.primary); settings.Save(); settingPitchUp = false; } } else { str = settings.pitchUp.ToString(); if (settings.modKeypitchUp) { str = "Alt-" + str; } if (GUILayout.Button(new GUIContent(str), GUILayout.Width(125))) { settingPitchUp = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Roll Left", GUILayout.ExpandWidth(true)); if (settingRollLeft) { GUILayout.Label("<Press any key>"); if (Event.current.isKey && c.ToString() != GameSettings.MODIFIER_KEY.primary.ToString()) { settings.rollLeft = new KeyCodeExtended(Event.current.keyCode); settings.modKeyrollLeft = ExtendedInput.GetKey(GameSettings.MODIFIER_KEY.primary); settings.Save(); settingRollLeft = false; } } else { str = settings.rollLeft.ToString(); if (settings.modKeyrollLeft) { str = "Alt-" + str; } if (GUILayout.Button(new GUIContent(str), GUILayout.Width(125))) { settingRollLeft = true; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Roll Right", GUILayout.ExpandWidth(true)); if (settingRollRight) { GUILayout.Label("<Press any key>"); if (Event.current.isKey && c.ToString() != GameSettings.MODIFIER_KEY.primary.ToString()) { settings.rollRight = new KeyCodeExtended(Event.current.keyCode); settings.modKeyrollRight = ExtendedInput.GetKey(GameSettings.MODIFIER_KEY.primary); settings.Save(); settingRollRight = false; } } else { str = settings.rollRight.ToString(); if (settings.modKeyrollRight) { str = "Alt-" + str; } if (GUILayout.Button(new GUIContent(str), GUILayout.Width(125))) { settingRollRight = true; } } GUILayout.EndHorizontal(); GUILayout.Space(10); #if false GUILayout.BeginHorizontal(); newUseStockToolbar = GUILayout.Toggle(settings.useStockToolbar, "Use Stock Toolbar"); GUILayout.EndHorizontal(); if (newUseStockToolbar != settings.useStockToolbar) { settings.useStockToolbar = newUseStockToolbar; settings.Save(); } #endif GUILayout.BeginHorizontal(); // GUILayout.Label("NavBall follows Kerbal:"); settingsEvaNavballFollowsKerbal = GUILayout.Toggle(settings.evaNavballFollowsKerbal, "NavBall follows Kerbal"); if (settingsEvaNavballFollowsKerbal != settings.evaNavballFollowsKerbal) { settings.evaNavballFollowsKerbal = settingsEvaNavballFollowsKerbal; settings.Save(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); // GUILayout.Label("NavBall follows Kerbal:"); settingsEvaHideNavballMarkers = GUILayout.Toggle(settings.evaHideNavballMarkers, "Hide Navball markers on EVA"); if (settingsEvaHideNavballMarkers != settings.evaHideNavballMarkers) { settings.evaHideNavballMarkers = settingsEvaHideNavballMarkers; settings.Save(); } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.Space(25f); GUILayout.EndVertical(); if (GUI.Button(new Rect(windowRect.width - 18, 3f, 15f, 15f), new GUIContent("X"))) { showWindow = false; toolbarControl.SetFalse(false); } GUI.DragWindow(); }
public void GuiOff() { visible = false; toolbarControl.SetFalse(false); }
private void RenderWindow(int windowId) { Vessel vessel = FlightGlobals.ActiveVessel; GUILayout.BeginVertical(GUILayout.MinWidth(400)); if (vessel != null) { if (uiCoreActive) { UI.Layout.Label("Vessel:"); } else { GUILayout.Label("Vessel:"); } TargetFocusButton(vessel); if (uiCoreActive) { UI.Layout.Label("Current SOI:"); } else { GUILayout.Label("Current SOI:"); } TargetFocusButton(vessel.mainBody); if (vessel.targetObject != null) { if (uiCoreActive) { UI.Layout.Label("Target:"); } else { GUILayout.Label("Target:"); } TargetFocusButton(vessel.targetObject); } if (uiCoreActive) { UI.Layout.Label("Plan entries:", UI.Palette.Col("blue")); } else { GUILayout.Label("Plan entries:", guiBlueLabelStyle); } RenderFlightPlan(); } if (uiCoreActive) { UI.Layout.HR(5); showAsUT = UI.Layout.Toggle(showAsUT, "Universal Time"); uiCoreActive = UI.Layout.Toggle(uiCoreActive, "UI Core Active"); UI.Layout.HR(5); } else { GUILayout.Label("", GUILayout.Height(5)); showAsUT = GUILayout.Toggle(showAsUT, "Universal Time"); uiCoreActive = GUILayout.Toggle(uiCoreActive, "UI Core Active"); if (uiCoreActive != oldUiCoreActive) { oldUiCoreActive = uiCoreActive; if (uiCoreActive) { LoadUICore(); } SaveData(); } GUILayout.Label("", GUILayout.Height(5)); } // missing green for GUILayout.Button if ((uiCoreActive && UI.Layout.Button("Close", UI.Palette.Col("green"))) || (!uiCoreActive && GUILayout.Button("Close", guiGreenButtonStyle))) { toolbarControl.SetFalse(); } GUILayout.EndVertical(); GUI.DragWindow(); }
private void WindowGui(int windowId) { try { var mySty = new GUIStyle(GUI.skin.button); mySty.normal.textColor = mySty.focused.textColor = Color.white; mySty.hover.textColor = mySty.active.textColor = Color.yellow; mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green; mySty.padding = new RectOffset(8, 8, 8, 8); GUILayout.BeginVertical(); String generateButtonText = ""; if (languageSelected) { GUILayout.Label("Here are the KSC staff members' suggestions:", GUILayout.ExpandWidth(true)); foreach (String s in _generatedNames) { if (GUILayout.Button(s, mySty, GUILayout.ExpandWidth(true))) { EditorLogic.fetch.shipNameField.text = s; Part p = VesselNaming.FindPriorityNamePart(EditorLogic.fetch.ship); p.vesselNaming.vesselName = s; toolbarControl.SetFalse(true); } } generateButtonText = "Fire those guys!"; GUILayout.Space(16); } else { generateButtonText = "What should we call this?"; GUILayout.Label("Language: ", GUILayout.ExpandWidth(true)); String[] langOpts = { "English", "Kerbal", "Both" }; _lang = GUILayout.SelectionGrid(_lang, langOpts, 1, "toggle", GUILayout.ExpandWidth(true)); GUILayout.Space(16); } //GUILayout.Button is "true" when clicked if (GUILayout.Button(generateButtonText, mySty, GUILayout.ExpandWidth(true))) { for (int i = 0; i < _generatedNames.Length; i++) { _generatedNames[i] = GenerateName(); } if (!languageSelected) { languageSelected = true; } //else // _generated = true; } GUILayout.EndVertical(); GUI.DragWindow(); } catch (Exception ex) { Debug.LogError(ex.ToString()); } }