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("Wheel: "); GUILayout.FlexibleSpace(); GUILayout.Label(mSteerClamp.ToString("P")); GUILayout.Label("Clamp", GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label("Hdg.", 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("Dist.", 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("Speed", GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m/s)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); Mheading = RTUtil.ConstrictNum(Mheading, 360); mDist = RTUtil.ConstrictNum(mDist, false); mSpeed = RTUtil.ConstrictNum(mSpeed, false); }
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("phr")) { mPitch = Pitch.ToString(); mHeading = Heading.ToString(); mRoll = Roll.ToString(); if (mFlightComputer.InputAllowed) { mMode = 7; Confirm(); } } else if (GUI.GetNameOfFocusedControl() == "burn") { OnBurnClick(); } } GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { RTUtil.StateButton(new GUIContent("KILL", "Kill rotation."), mMode, 1, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("NODE", "Prograde points in the direction of the first maneuver node."), mMode, 2, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("RVEL", "Prograde relative to target velocity."), mMode, 6, OnModeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.StateButton(new GUIContent("ORB", "Prograde relative to orbital velocity."), mMode, 4, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("SRF", "Prograde relative to surface velocity."), mMode, 5, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("TGT", "Prograde points directly at target."), mMode, 3, OnModeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); RTUtil.StateButton(new GUIContent("CUSTOM", "Prograde fixed as pitch, heading, roll relative to north pole."), mMode, 7, OnModeClick, GUILayout.ExpandWidth(true)); GUILayout.Space(5); GUILayout.BeginHorizontal(); { RTUtil.StateButton(new GUIContent("GRD\n+", "Orient to Prograde."), mAttitude, 1, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("RAD\n+", "Orient to Radial."), mAttitude, 2, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("NRM\n+", "Orient to Normal."), mAttitude, 3, OnAttitudeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.StateButton(new GUIContent("GRD\n-", "Orient to Retrograde."), mAttitude, 4, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("RAD\n-", "Orient to Anti-radial."), mAttitude, 5, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton(new GUIContent("NRM\n-", "Orient to Anti-normal."), mAttitude, 6, OnAttitudeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("PIT:", "Sets pitch."), GUILayout.Width(width3)); RTUtil.Button("+", () => Pitch++); RTUtil.Button("-", () => Pitch--); GUI.SetNextControlName("phr1"); RTUtil.TextField(ref mPitch, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("HDG:", "Sets heading."), GUILayout.Width(width3)); RTUtil.Button("+", () => Heading++); RTUtil.Button("-", () => Heading--); GUI.SetNextControlName("phr2"); RTUtil.TextField(ref mHeading, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("RLL:", "Sets roll."), GUILayout.Width(width3)); RTUtil.Button("+", () => Roll++); RTUtil.Button("-", () => Roll--); GUI.SetNextControlName("phr3"); RTUtil.TextField(ref mRoll, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Throttle: "); GUILayout.FlexibleSpace(); GUILayout.Label(mThrottle.ToString("P")); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mThrottle, 0, 1); GUI.SetNextControlName("burn"); RTUtil.TextField(ref mDuration); GUILayout.BeginHorizontal(); { RTUtil.Button(new GUIContent("BURN", "Example: 125, 125s, 5m20s, 1d6h20m10s, 123m/s."), OnBurnClick, GUILayout.Width(width3)); RTUtil.Button(new GUIContent("EXEC", "Executes next maneuver node."), OnExecClick, GUILayout.Width(width3)); RTUtil.Button(new GUIContent(">>", "Toggles the queue and delay functionality."), mOnClickQueue, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
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.mAttachedVessel.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("Wheel: "); GUILayout.FlexibleSpace(); GUILayout.Label(mSteerClamp.ToString("P")); GUILayout.Label("Clamp", GUILayout.Width(40)); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteerClamp, 0, 1); GUILayout.BeginHorizontal(); { GUILayout.Label("LAT.", GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mLatitude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("LON.", GUILayout.Width(50)); GUI.SetNextControlName("RC2"); RTUtil.TextField(ref mLongditude, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Speed", GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m/s)", 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("Wheel: "); GUILayout.FlexibleSpace(); GUILayout.Label(Math.Abs(mSteering).ToString("P")); if (mSteering != 0) { if (mSteering < 0) { GUILayout.Label("right", GUILayout.Width(40)); } else { GUILayout.Label("left", GUILayout.Width(40)); } } else { GUILayout.Label("", GUILayout.Width(40)); } } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mSteering, 1, -1); GUILayout.BeginHorizontal(); { GUILayout.Label("Turn", GUILayout.Width(50)); GUI.SetNextControlName("RC1"); RTUtil.TextField(ref mTurn, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(°)", GUI.skin.textField, GUILayout.Width(40)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Dist.", 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("Speed", GUILayout.Width(50)); GUI.SetNextControlName("RC3"); RTUtil.TextField(ref mSpeed, GUILayout.Width(50), GUILayout.ExpandWidth(false)); GUILayout.Label("(m/s)", 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("phr")) { mPitch = Pitch.ToString(); mHeading = Heading.ToString(); mRoll = Roll.ToString(); if (mFlightComputer.InputAllowed) { mMode = 3; Confirm(); } } else if (GUI.GetNameOfFocusedControl() == "burn") { OnBurnClick(); } } GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { RTUtil.StateButton("KILL", mMode, 1, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton("NODE", mMode, 2, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton("SURF", mMode, 3, OnModeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.StateButton("ORB", mMode, 4, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton("SRF", mMode, 5, OnModeClick, GUILayout.Width(width3)); RTUtil.StateButton("TGT", mMode, 6, OnModeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { RTUtil.StateButton("GRD\n+", mAttitude, 1, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton("RAD\n+", mAttitude, 2, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton("NRM\n+", mAttitude, 3, OnAttitudeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.StateButton("GRD\n-", mAttitude, 4, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton("RAD\n-", mAttitude, 5, OnAttitudeClick, GUILayout.Width(width3)); RTUtil.StateButton("NRM\n-", mAttitude, 6, OnAttitudeClick, GUILayout.Width(width3)); } GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginHorizontal(); { GUILayout.Label("PIT:", GUILayout.Width(50)); RTUtil.Button("+", () => Pitch++, GUILayout.Width(20)); RTUtil.Button("-", () => Pitch--, GUILayout.Width(20)); GUI.SetNextControlName("phr1"); RTUtil.TextField(ref mPitch, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("HDG:", GUILayout.Width(50)); RTUtil.Button("+", () => Heading++, GUILayout.Width(20)); RTUtil.Button("-", () => Heading--, GUILayout.Width(20)); GUI.SetNextControlName("phr2"); RTUtil.TextField(ref mHeading, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("RLL:", GUILayout.Width(40)); RTUtil.StateButton(" ", mRollEnabled ? 1 : 0, 1, (s) => mRollEnabled = (s == 1) ? true : false, GUILayout.Width(10)); RTUtil.Button("+", () => Roll++, GUILayout.Width(20)); RTUtil.Button("-", () => Roll--, GUILayout.Width(20)); GUI.SetNextControlName("phr3"); RTUtil.TextField(ref mRoll, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Throttle: "); GUILayout.FlexibleSpace(); GUILayout.Label(mThrottle.ToString("P")); } GUILayout.EndHorizontal(); RTUtil.HorizontalSlider(ref mThrottle, 0, 1); GUI.SetNextControlName("burn"); RTUtil.TextField(ref mDuration); GUILayout.BeginHorizontal(); { RTUtil.Button("Burn", OnBurnClick); GUILayout.FlexibleSpace(); RTUtil.Button("Queue", mOnClickQueue); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }