public void Draw() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "rt_xd") { RTCore.Instance.StartCoroutine(onClickAddExtraDelay()); } GUILayout.BeginVertical(); { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.Width(250)); { { GUILayout.BeginHorizontal(GUI.skin.box); { var s = new StringBuilder(); foreach (var c in mFlightComputer.ActiveCommands) { s.Append(c.Description); } GUILayout.Label(s.ToString().TrimEnd(Environment.NewLine.ToCharArray())); GUILayout.FlexibleSpace(); RTUtil.Button("x", () => RTCore.Instance.StartCoroutine(OnClickReset()), GUILayout.Width(21), GUILayout.Height(21)); } GUILayout.EndHorizontal(); foreach (var c in mFlightComputer.QueuedCommands) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.Label(c.Description); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); { RTUtil.Button("x", () => RTCore.Instance.StartCoroutine(OnClickCancel(c)), GUILayout.Width(21), GUILayout.Height(21)); RTUtil.Button(new GUIContent("v", Localizer.Format("#RT_QueueFragment_Setsignaldelay", RTUtil.FormatDuration(c.Delay + c.ExtraDelay + getBurnTime(c), false))), () => RTCore.Instance.StartCoroutine(onClickAddExtraDelayFromQueuedCommand(c)), GUILayout.Width(21), GUILayout.Height(21));//string.Format("Set the signal delay right after this - Current: {0}", ) } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.Label(Status); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_QueueFragment_Signaldelay", RTUtil.FormatDuration(mFlightComputer.TotalDelay)), Localizer.Format("#RT_QueueFragment_Signaldelay_desc")));//"Delay (+ signal): " "Total delay including signal delay." GUILayout.FlexibleSpace(); GUI.SetNextControlName("rt_xd"); RTUtil.TextField(ref mExtraDelay, GUILayout.Width(45)); RTUtil.Button(new GUIContent(">", Localizer.Format("#RT_QueueFragment_AddExtraDelay_desc")), () => RTCore.Instance.StartCoroutine(onClickAddExtraDelay()), GUILayout.Width(21), GUILayout.Height(21));//"Add extra signal delay - Example: 125, 125s, 5m20s, 1d6h20m10s" } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
private void HDG() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC")) { mFlightComputer.Enqueue(DriveCommand.DistanceHeading(Dist, Heading, mSteerClamp, Speed)); } GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Wheel: ", "How sharp to turn at max")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max")); GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Hdg.", "Heading to keep"), GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref Mheading, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Dist.", "Distance to drive"), GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Speed", "Speed to keep"), GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", "Speed to keep"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); Mheading = RTUtil.ConstrictNum(Mheading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void DrawHDGContent() { GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"How sharp to turn at max" GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40)); //"How sharp to turn at max" } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_mHdg"), Localizer.Format("#RT_RoverFragment_mHdg_desc")), GUILayout.Width(50));//"Hdg", "Heading to maintain" GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Dist"), Localizer.Format("#RT_RoverFragment_Dist_desc")), GUILayout.Width(50));//"Dist", "Distance to drive" GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain" GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain" } GUILayout.EndHorizontal(); mHeading = RTUtil.ConstrictNum(mHeading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void DrawHDGContent() { GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Steer: ", "How sharp to turn at max")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max")); GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Hdg", "Heading to maintain"), GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mHeading, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Dist", "Distance to drive"), GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Speed", "Speed to maintain"), GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", "Speed to maintain"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); mHeading = RTUtil.ConstrictNum(mHeading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void DrawTargetContent() { string targetTypeString = Localizer.Format("#RT_RoverFragment_coordinations"); //"Body coordinations" string tooltip = Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name); //"Hold " + + " and click on ground to input coordinates" ITargetable Target = mFlightComputer.Vessel.targetObject; if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick)) // on lookout for mouse click on body { MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1); Vector2 latlon; if (MouseClick && RTUtil.CBhit(mFlightComputer.Vessel.mainBody, out latlon)) { Latitude = latlon.x; Longitude = latlon.y; } } else if (Target != null) // only if target is vessel not world coord { if (Target.GetType().ToString().Equals("Vessel")) { Vessel TargetVessel = Target as Vessel; Latitude = (float)TargetVessel.latitude; Longitude = (float)TargetVessel.longitude; targetTypeString = Localizer.Format("#RT_RoverFragment_TargetVessel"); //"Designated Vessel" tooltip = Localizer.Format("#RT_RoverFragment_TargetVessel_desc"); //"Drive to this vessel" } } GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_HDGSteer"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"Steer: ", "How sharp to turn at max" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), Localizer.Format("#RT_RoverFragment_HDGSteer_desc"))); //"How sharp to turn at max" GUILayout.Label(new GUIContent("max", Localizer.Format("#RT_RoverFragment_HDGSteer_desc")), GUILayout.Width(40)); // "How sharp to turn at max" } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_ModeLabel", targetTypeString), tooltip));//"Mode: " GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LAT"), Localizer.Format("#RT_RoverFragment_LAT_desc")), GUILayout.Width(50));//"LAT", "Latitude to drive to" GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " + + " and click on ground to input coordinates" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_LON"), Localizer.Format("#RT_RoverFragment_LON_desc")), GUILayout.Width(50));//"LON", "Longitude to drive to" GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_coordinations_desc", GameSettings.MODIFIER_KEY.name)), GUI.skin.textField, GUILayout.Width(40));//"Hold " + + " and click on ground to input coordinates" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain" GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("#RT_RoverFragment_HDGSpeed_desc")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain" } GUILayout.EndHorizontal(); mLatitude = RTUtil.ConstrictNum(mLatitude); mLongditude = RTUtil.ConstrictNum(mLongditude); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void DrawFineContent() { GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_FINESteer"), Localizer.Format("#RT_RoverFragment_FINESteer_desc")));//"Steer: ", "How much to turn" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(Math.Abs(mSteering).ToString("P"), "")); if (mSteering != 0) { if (mSteering < 0) { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_right"), ""), GUILayout.Width(40));//"right" } else { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_left"), ""), GUILayout.Width(40)); //"left" } } else { GUILayout.Label(new GUIContent("", ""), GUILayout.Width(40)); } } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteering, 1, -1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Turn"), Localizer.Format("#RT_RoverFragment_Turn_desc")), GUILayout.Width(50));//"Turn", "How many degrees to turn" GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", Localizer.Format("#RT_RoverFragment_Turn_desc")), GUI.skin.textField, GUILayout.Width(40));//, "How many degrees to turn" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Dist"), Localizer.Format("#RT_RoverFragment_Dist_desc")), GUILayout.Width(50));//"Dist", "Distance to drive" GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m)", Localizer.Format("#RT_RoverFragment_Dist_desc")), GUI.skin.textField, GUILayout.Width(40));//"Distance to drive" } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_RoverFragment_Speed"), Localizer.Format("#RT_RoverFragment_Speed_desc")), GUILayout.Width(50));//"Speed", "Speed to maintain, negative for reverse" GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", Localizer.Format("#RT_RoverFragment_Speed_desc")), GUI.skin.textField, GUILayout.Width(40));//"Speed to maintain, negative for reverse" } GUILayout.EndHorizontal(); mTurn = RTUtil.ConstrictNum(mTurn, 90); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed); if (prevTurn != Turn) { distDefault = false; } else if (prevDist != Dist) { distDefault = true; } prevTurn = Turn; prevDist = Dist; }
private void Target() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl().StartsWith("RC")) { mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed)); } else if (GameSettings.MODIFIER_KEY.GetKey() && ((Input.GetMouseButton(0) || Input.GetMouseButton(1)) != MouseClick)) { MouseClick = Input.GetMouseButton(0) || Input.GetMouseButton(1); Vector2 latlon; if (MouseClick && RTUtil.CBhit(mFlightComputer.Vessel.mainBody, out latlon)) { Latitude = latlon.x; Longitude = latlon.y; if (Input.GetMouseButton(1)) { mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed)); } } } GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Wheel: ", "How sharp to turn at max")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mSteerClamp.ToString("P"), "How sharp to turn at max")); GUILayout.Label(new GUIContent("max", "How sharp to turn at max"), GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("LAT.", "Latitude to drive to"), GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", "Hold " + GameSettings.MODIFIER_KEY.name + " and click on ground to input coordinates"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("LON.", "Longitude to drive to"), GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", "Hold " + GameSettings.MODIFIER_KEY.name + " and click on ground to input coordinates"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Speed", "Speed to keep"), GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", "Speed to keep"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); mLatitude = RTUtil.ConstrictNum(mLatitude); mLongditude = RTUtil.ConstrictNum(mLongditude); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
private void Fine() { if (Event.current.Equals(Event.KeyboardEvent("return")) && Speed != 0) { if (GUI.GetNameOfFocusedControl() == "RC1" && mSteering != 0 && Turn != 0) { EnqueueTurn(); } else if (GUI.GetNameOfFocusedControl() == "RC2" && Dist != 0) { EnqueueDist(); } else if (GUI.GetNameOfFocusedControl() == "RC3") { if (!distDefault && mSteering != 0 && Turn != 0) { EnqueueTurn(); } else if (distDefault && Dist != 0) { EnqueueDist(); } } } GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Wheel: ", "how much to turn")); GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(Math.Abs(mSteering).ToString("P"), "How much to turn")); if (mSteering != 0) { if (mSteering < 0) { GUILayout.Label(new GUIContent("right", "how much to turn"), GUILayout.Width(40)); } else { GUILayout.Label(new GUIContent("left", "how much to turn"), GUILayout.Width(40)); } } else { GUILayout.Label(new GUIContent("", "how much to turn"), GUILayout.Width(40)); } } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteering, 1, -1); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Turn", "How many degrees to turn"), GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(°)", "How many degrees to turn"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Dist.", "Distance to drive"), GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mDist, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m)", "Distance to drive"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Speed", "Speed to keep, negative for reverse"), GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label(new GUIContent("(m/s)", "Speed to keep, negative for reverse"), GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); mTurn = RTUtil.ConstrictNum(mTurn, 90); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed); if (prevTurn != Turn) { distDefault = false; } else if (prevDist != Dist) { distDefault = true; } prevTurn = Turn; prevDist = Dist; }
public void Draw() { float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f; if (Event.current.Equals(Event.KeyboardEvent("return"))) { if (GUI.GetNameOfFocusedControl().StartsWith("rt_phr")) { mPitch = Pitch.ToString(); mHeading = Heading.ToString(); mRoll = Roll.ToString(); if (mFlightComputer.InputAllowed) { mMode = ComputerMode.Custom; Confirm(); } } else if (GUI.GetNameOfFocusedControl() == "rt_burn") { OnBurnClick(); } } GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_KILL"), Localizer.Format("#RT_AttitudeFragment_KILL_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Kill)), (int)mMode, (int)ComputerMode.Kill, GUILayout.Width(width3)); //"KILL", "Kill rotation." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NODE"), Localizer.Format("#RT_AttitudeFragment_NODE_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Node)), (int)mMode, (int)ComputerMode.Node, GUILayout.Width(width3)); //"NODE", "Prograde points in the direction of the first maneuver node." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RVEL"), Localizer.Format("#RT_AttitudeFragment_RVEL_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.TargetVel)), (int)mMode, (int)ComputerMode.TargetVel, GUILayout.Width(width3)); //"RVEL", "Prograde relative to target velocity." } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_ORB"), Localizer.Format("#RT_AttitudeFragment_ORB_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Orbital)), (int)mMode, (int)ComputerMode.Orbital, GUILayout.Width(width3)); //"ORB", "Prograde relative to orbital velocity." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_SRF"), Localizer.Format("#RT_AttitudeFragment_SRF_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Surface)), (int)mMode, (int)ComputerMode.Surface, GUILayout.Width(width3)); //"SRF", "Prograde relative to surface velocity." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_TGT"), Localizer.Format("#RT_AttitudeFragment_TGT_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.TargetPos)), (int)mMode, (int)ComputerMode.TargetPos, GUILayout.Width(width3)); //"TGT", "Prograde points directly at target." } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_OFF"), Localizer.Format("#RT_AttitudeFragment_OFF_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Off)), (int)mMode, (int)ComputerMode.Off, GUILayout.Width(width3)); //"OFF", "Set Attitude to Off." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_CUSTOM"), Localizer.Format("#RT_AttitudeFragment_CUSTOM_desc")), () => RTCore.Instance.StartCoroutine(OnModeClick(ComputerMode.Custom)), (int)mMode, (int)ComputerMode.Custom, GUILayout.ExpandWidth(true)); //"CUSTOM", "Prograde fixed as pitch, heading, roll relative to north pole." } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_Prograde"), Localizer.Format("#RT_AttitudeFragment_Prograde_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.Prograde)), (int)mAttitude, (int)FlightAttitude.Prograde, GUILayout.Width(width3)); //"GRD\n+", "Orient to Prograde." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RadialPlus"), Localizer.Format("#RT_AttitudeFragment_RadialPlus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.RadialPlus)), (int)mAttitude, (int)FlightAttitude.RadialPlus, GUILayout.Width(width3)); //"RAD\n+", "Orient to Radial." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NormalPlus"), Localizer.Format("#RT_AttitudeFragment_NormalPlus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.NormalPlus)), (int)mAttitude, (int)FlightAttitude.NormalPlus, GUILayout.Width(width3)); //"NRM\n+", "Orient to Normal." } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_Retrograde"), Localizer.Format("#RT_AttitudeFragment_Retrograde_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.Retrograde)), (int)mAttitude, (int)FlightAttitude.Retrograde, GUILayout.Width(width3)); //"GRD\n-", "Orient to Retrograde." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RadialMinus"), Localizer.Format("#RT_AttitudeFragment_RadialMinus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.RadialMinus)), (int)mAttitude, (int)FlightAttitude.RadialMinus, GUILayout.Width(width3)); //"RAD\n-", "Orient to Anti-radial." RTUtil.FakeStateButton(new GUIContent(Localizer.Format("#RT_AttitudeFragment_NormalMinus"), Localizer.Format("#RT_AttitudeFragment_NormalMinus_desc")), () => RTCore.Instance.StartCoroutine(OnAttitudeClick(FlightAttitude.NormalMinus)), (int)mAttitude, (int)FlightAttitude.NormalMinus, GUILayout.Width(width3)); //"NRM\n-", "Orient to Anti-normal." } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_PIT"), Localizer.Format("#RT_AttitudeFragment_PIT_desc")), GUILayout.Width(width3));//"PIT:", "Sets pitch." RTUtil.RepeatButton("+", () => { Pitch++; }); RTUtil.RepeatButton("-", () => { Pitch--; }); RTUtil.MouseWheelTriggerField(ref mPitch, "rt_phr1", () => { Pitch++; }, () => { Pitch--; }, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_HDG"), Localizer.Format("#RT_AttitudeFragment_HDG_desc")), GUILayout.Width(width3));//"HDG:", "Sets heading." RTUtil.RepeatButton("+", () => { Heading++; }); RTUtil.RepeatButton("-", () => { Heading--; }); RTUtil.MouseWheelTriggerField(ref mHeading, "rt_phr2", () => { Heading++; }, () => { Heading--; }, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_AttitudeFragment_RLL"), Localizer.Format("#RT_AttitudeFragment_RLL_desc")), GUILayout.Width(width3));//"RLL:", "Sets roll." RTUtil.RepeatButton("+", () => { Roll++; }); RTUtil.RepeatButton("-", () => { Roll--; }); RTUtil.MouseWheelTriggerField(ref mRoll, "rt_phr3", () => { Roll++; }, () => { Roll--; }, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(Localizer.Format("#RT_AttitudeFragment_Throttle"));//"Throttle: " GUILayout.FlexibleSpace(); GUILayout.Label(mThrottle.ToString("P")); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mThrottle, 0, 1); GUI.SetNextControlName("rt_burn"); RTUtil.TextField(ref mDuration); GUILayout.BeginHorizontal(); { RTUtil.Button(new GUIContent(Localizer.Format("#RT_AttitudeFragment_BURN"), Localizer.Format("#RT_AttitudeFragment_BURN_desc")), //"BURN", "Example: 125, 125s, 5m20s, 1d6h20m10s, 123m/s." OnBurnClick, GUILayout.Width(width3)); RTUtil.Button(new GUIContent(Localizer.Format("#RT_AttitudeFragment_EXEC"), Localizer.Format("#RT_AttitudeFragment_EXEC_desc")), //"EXEC", "Executes next and subsequent maneuver nodes." OnExecClick, GUILayout.Width(width3)); RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_AttitudeFragment_Queue_desc")), //"Toggles the queue and delay functionality." mOnClickQueue, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public void Draw() { float width3 = 156 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f; GUILayout.BeginVertical(); { Vector3 Torque = SteeringHelper.TorqueAvailable; var MoI = mFlightComputer.Vessel.MOI; //////////////// //PITCH INFO //////////////// GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Pitch") + "</b>"));//"Pitch" GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent((Torque[0] / MoI[0]).ToString("F3"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[0].ToString("F2"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.pitch.ToString("F2"))); } GUILayout.EndHorizontal(); //////////////// //ROLL INFO //////////////// GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Roll") + "</b>"));//"Roll" GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent((Torque[1] / MoI[1]).ToString("F3"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[1].ToString("F2"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.roll.ToString("F2"))); } GUILayout.EndHorizontal(); //////////////// //YAW INFO //////////////// GUILayout.Label(new GUIContent("<b>" + Localizer.Format("#RT_PIDControllerFragment_Yaw") + "</b>"));//"Yaw" GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_TorqueMoI"), Localizer.Format("#RT_PIDControllerFragment_TorqueMoI_desc")));//"Torque-MoI Rate: ", "Current rate of torque to mass of inertia" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent((Torque[2] / MoI[2]).ToString("F3"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_DeviationError"), Localizer.Format("#RT_PIDControllerFragment_DeviationError_desc")));//"Deviation Error: ", "Deviation from the target point" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.PIDController.getDeviationErrors()[2].ToString("F2"))); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Output"), Localizer.Format("#RT_PIDControllerFragment_Output_desc")));//"Output: ", "Output of Flight Control State" GUILayout.FlexibleSpace(); GUILayout.Label(new GUIContent(mFlightComputer.Vessel.ctrlState.yaw.ToString("F2"))); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_PIDHelp")));//"See ni.com/white-paper/3782/en" GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Kp"), Localizer.Format("#RT_PIDControllerFragment_Kp_desc")));//"Proportional gain", "(1) With I and D terms set to 0, increase until the output of the loop oscillates." RTUtil.TextField(ref kp, GUILayout.Width(50), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Ki"), Localizer.Format("#RT_PIDControllerFragment_Ki_desc")));//"Integral", "(2) Increase to stop the oscillations." RTUtil.TextField(ref ki, GUILayout.Width(50), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_Kd"), Localizer.Format("#RT_PIDControllerFragment_Kd_desc")));//"Derivative", "(3) Increase until the loop is acceptably quick to its target point." RTUtil.TextField(ref kd, GUILayout.Width(50), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { RTUtil.Button(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_button1"), Localizer.Format("#RT_PIDControllerFragment_button1_desc")), //"SAVE", "Save all values persistently." OnSaveClick, GUILayout.Width(width3)); RTUtil.Button(new GUIContent(Localizer.Format("#RT_PIDControllerFragment_button2"), Localizer.Format("#RT_PIDControllerFragment_button2_desc")), //"APLY", "Interface all values to Flight PID Controller." () => RTCore.Instance.StartCoroutine(OnApplyClick()), GUILayout.Width(width3)); RTUtil.Button(new GUIContent(">>", Localizer.Format("#RT_PIDControllerFragment_Queue_desc")), //"Toggles the queue and delay functionality." mOnClickQueue, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }