public override void Draw() { if (PN == null || !VSL.OnPlanet) { return; } GUILayout.BeginHorizontal(); if (BJ != null) { BJ.Draw(); } if (VSL.HasTarget && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Go To", CFG.Nav[Navigation.GoToTarget], "Fly to current target", GUILayout.Width(50))) { CFG.Nav.XOn(Navigation.GoToTarget); if (CFG.Nav[Navigation.GoToTarget]) { follow_me(); } } if (Utils.ButtonSwitch("Follow", CFG.Nav[Navigation.FollowTarget], "Follow current target", GUILayout.Width(50))) { apply(tca => { if (TCA.vessel.targetObject as Vessel == tca.vessel) { return; } tca.vessel.targetObject = TCA.vessel.targetObject; tca.CFG.Nav.XOn(Navigation.FollowTarget); }); } } else { GUILayout.Label(new GUIContent("Go To", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.Width(50)); GUILayout.Label(new GUIContent("Follow", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.Width(50)); } if (SQD != null && SQD.SquadMode) { if (CFG.Nav.Paused) { GUILayout.Label(new GUIContent("Follow Me", "Make the squadron follow"), Styles.inactive_button, GUILayout.Width(75)); } else if (GUILayout.Button(new GUIContent("Follow Me", "Make the squadron follow"), Styles.active_button, GUILayout.Width(75))) { follow_me(); } } if (SelectingTarget) { SelectingTarget &= !GUILayout.Button("Cancel", Styles.close_button, GUILayout.Width(120)); } else if (VSL.HasTarget && !(VSL.Target is WayPoint) && (CFG.Waypoints.Count == 0 || VSL.Target != CFG.Waypoints.Peek().GetTarget())) { if (GUILayout.Button(new GUIContent("Add As Waypoint", "Add current target as a waypoint"), Styles.active_button, GUILayout.Width(120))) { CFG.Waypoints.Enqueue(new WayPoint(VSL.Target)); CFG.ShowWaypoints = true; } } else if (GUILayout.Button(new GUIContent("Add Waypoint", "Select a new waypoint"), Styles.active_button, GUILayout.Width(120))) { SelectingTarget = true; CFG.ShowWaypoints = true; } if (CFG.Waypoints.Count > 0 && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Follow Route", CFG.Nav[Navigation.FollowPath], "", GUILayout.Width(90))) { CFG.Nav.XToggle(Navigation.FollowPath); if (CFG.Nav[Navigation.FollowPath]) { follow_me(); } } } else { GUILayout.Label(new GUIContent("Follow Route", CFG.Nav.Paused? "Paused" : "Add some waypoints first"), Styles.inactive_button, GUILayout.Width(90)); } var max_nav_speed = Utils.FloatSlider("", CFG.MaxNavSpeed, CFG.HF[HFlight.CruiseControl]? GLB.CC.MaxRevSpeed : GLB.PN.MinSpeed, GLB.PN.MaxSpeed, "0.0 m/s", 60, "Maximum horizontal speed on autopilot"); if (Mathf.Abs(max_nav_speed - CFG.MaxNavSpeed) > 1e-5) { apply_cfg(cfg => cfg.MaxNavSpeed = max_nav_speed); } GUILayout.EndHorizontal(); }
void NavigationControls() { GUILayout.BeginHorizontal(); if (BJ != null) { BJ.Draw(); } if (PN != null) { if (VSL.HasTarget && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Go To", CFG.Nav[Navigation.GoToTarget], "Fly to current target", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => { CFG.Nav.XOn(Navigation.GoToTarget); if (CFG.Nav[Navigation.GoToTarget]) { follow_me(); } }); } if (Utils.ButtonSwitch("Follow", CFG.Nav[Navigation.FollowTarget], "Follow current target", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => TCA.SquadAction(tca => { if (TCA.vessel.targetObject as Vessel == tca.vessel) { return; } tca.vessel.targetObject = TCA.vessel.targetObject; tca.CFG.Nav.XOn(Navigation.FollowTarget); })); } } else { GUILayout.Label(new GUIContent("Go To", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.ExpandWidth(true)); GUILayout.Label(new GUIContent("Follow", CFG.Nav.Paused? "Paused" : "No target selected"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } } GUILayout.EndHorizontal(); if (BJ != null && BJ.ShowOptions) { BJ.DrawOptions(); } GUILayout.BeginHorizontal(); if (SQD != null && SQD.SquadMode) { if (CFG.Nav.Paused) { GUILayout.Label(new GUIContent("Follow Me", "Make the squadron follow"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } else if (GUILayout.Button(new GUIContent("Follow Me", "Make the squadron follow"), Styles.active_button, GUILayout.ExpandWidth(true))) { follow_me(); } } if (PN != null) { if (SelectingTarget) { SelectingTarget &= !GUILayout.Button("Cancel", Styles.close_button, GUILayout.Width(120)); } else if (!UI.RemoteControl && VSL.HasTarget && (VSL.TargetIsNavPoint || !VSL.TargetIsWayPoint && (CFG.Path.Count == 0 || VSL.Target != CFG.Path.Peek().GetTarget()))) { if (GUILayout.Button(new GUIContent("Add As Waypoint", "Add current target as a waypoint"), Styles.active_button, GUILayout.Width(120))) { var t = VSL.TargetAsWP; CFG.Path.Enqueue(t); CFG.ShowPath = true; } } else if (GUILayout.Button(new GUIContent("Add Waypoint", "Select a new waypoint"), Styles.active_button, GUILayout.Width(120))) { SelectingTarget = true; CFG.ShowPath = true; } if (CFG.Path.Count > 0 && !CFG.Nav.Paused) { if (Utils.ButtonSwitch("Follow Route", CFG.Nav[Navigation.FollowPath], "", GUILayout.ExpandWidth(true))) { VSL.Engines.ActivateEnginesAndRun(() => { CFG.Nav.XToggle(Navigation.FollowPath); if (CFG.Nav[Navigation.FollowPath]) { follow_me(); } }); } } else { GUILayout.Label(new GUIContent("Follow Route", CFG.Nav.Paused? "Paused" : "Add some waypoints first"), Styles.inactive_button, GUILayout.ExpandWidth(true)); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (PN != null || CC != null) { var max_nav_speed = Utils.FloatSlider("", CFG.MaxNavSpeed, CFG.HF[HFlight.CruiseControl]? CruiseControl.C.MaxRevSpeed : PointNavigator.C.MinSpeed, PointNavigator.C.MaxSpeed, "0.0 m/s", 60, "Maximum horizontal speed on autopilot"); if (Mathf.Abs(max_nav_speed - CFG.MaxNavSpeed) > 1e-5) { TCA.SquadConfigAction(cfg => cfg.MaxNavSpeed = max_nav_speed); } } GUILayout.EndHorizontal(); }