private void OnExecClick(int modeIndex) { //FINE if (modeIndex == (int)RoverModes.FineMode && Speed != 0) { if (mSteering != 0 && Turn != 0) { EnqueueTurn(); } else if (Dist != 0) { EnqueueDist(); } else { if (!distDefault && mSteering != 0 && Turn != 0) { EnqueueTurn(); } else if (distDefault && Dist != 0) { EnqueueDist(); } } } //HDG else if (modeIndex == (int)RoverModes.HeadingMode) { mFlightComputer.Enqueue(DriveCommand.DistanceHeading(Dist, Heading, mSteerClamp, Speed)); } //TGT else if (modeIndex == (int)RoverModes.TargetMode) { mFlightComputer.Enqueue(DriveCommand.Coord(mSteerClamp, Latitude, Longitude, Speed)); } }
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); }