public void Draw() { GUILayout.BeginVertical(GUILayout.Width(156), GUILayout.Height(300)); { selected = GUILayout.Toolbar(selected, Tabs, GUI.skin.textField, GUILayout.Width(156 - GUI.skin.button.margin.right * 2.0f)); switch (selected) { case 0: Fine(); break; case 1: HDG(); break; case 2: Target(); break; } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); RTUtil.Button("Queue", mOnClickQueue); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public void Draw() { GUILayout.BeginVertical(GUI.skin.box, GUILayout.Width(300)); { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition); { Color pushColor = GUI.backgroundColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; // Depth-first tree traversal. Stack <Entry> dfs = new Stack <Entry>(); foreach (Entry child in mRootEntry.SubEntries) { dfs.Push(child); } while (dfs.Count > 0) { Entry current = dfs.Pop(); GUI.backgroundColor = current.Color; GUILayout.BeginHorizontal(); { GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 18)); if (current.SubEntries.Count > 0) { RTUtil.Button(current.Expanded ? "<" : ">", () => { current.Expanded = !current.Expanded; }, GUILayout.Width(18)); } RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1, (s) => { mSelection = current; mFocus.DishTarget = mSelection.Guid; }); } GUILayout.EndHorizontal(); if (current.Expanded) { foreach (Entry child in current.SubEntries) { dfs.Push(child); } } } GUI.skin.button.alignment = pushAlign; GUI.backgroundColor = pushColor; } GUILayout.EndScrollView(); } GUILayout.EndVertical(); }
public void Draw() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "xd") { mFlightComputer.TotalDelay = Delay; } 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(); RTUtil.Button("x", () => RTCore.Instance.StartCoroutine(OnClickCancel(c)), GUILayout.Width(21), GUILayout.Height(21)); } GUILayout.EndHorizontal(); } } } GUILayout.EndScrollView(); GUILayout.Label(Status); GUILayout.BeginHorizontal(); { GUILayout.Label(new GUIContent("Delay (+ signal): " + RTUtil.FormatDuration(mFlightComputer.TotalDelay), "Total delay including signal delay.")); GUILayout.FlexibleSpace(); GUI.SetNextControlName("xd"); RTUtil.TextField(ref mExtraDelay, GUILayout.Width(50)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public void Draw() { if (Satellite == null) { return; } GUILayout.BeginHorizontal(); { GUILayout.TextField(Satellite.Name.Truncate(25), GUILayout.ExpandWidth(true)); RTUtil.Button("Name", () => { var vessel = FlightGlobals.Vessels.First(v => v.id == Satellite.Guid); if (vessel) { vessel.RenameVessel(); } }, GUILayout.ExpandWidth(false), GUILayout.Height(24)); } GUILayout.EndHorizontal(); mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true)); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; foreach (var a in Satellite.Antennas.Where(a => a.CanTarget)) { GUI.contentColor = (a.Powered) ? XKCDColors.ElectricLime : XKCDColors.Scarlet; String text = a.Name.Truncate(25) + Environment.NewLine + "Target: " + RTUtil.TargetName(a.Target).Truncate(18); RTUtil.StateButton(text, Antenna, a, s => { Antenna = (s > 0) ? a : null; }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); }
public void Draw() { GUILayout.BeginVertical(GUILayout.Width(200), GUILayout.ExpandHeight(true)); { GUILayout.BeginHorizontal(); { GUILayout.Box(mFocus.Name); RTUtil.Button("Name", () => mFocus.Vessel.RenameVessel(), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); GUILayout.BeginVertical(GUI.skin.box); { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; for (int i = 0; i < mFocusAntennas.Count; i++) { GUI.contentColor = (mFocusAntennas[i].DishRange > 0) ? Color.green : Color.red; String text = mFocusAntennas[i].Name + '\n' + "Target: " + RTUtil.TargetName(mFocusAntennas[i].DishTarget); RTUtil.StateButton(text, mSelection, i, s => { mSelection = (s > 0) ? s : 0; mOnClick.Invoke(mFocusAntennas[mSelection]); }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); } GUILayout.EndVertical(); } GUILayout.EndVertical(); }
public void Draw() { if (Event.current.Equals(Event.KeyboardEvent("return")) && GUI.GetNameOfFocusedControl() == "xd") { mExtraDelay = Delay.ToString(); mFlightComputer.ExtraDelay = Delay; } GUILayout.BeginVertical(GUILayout.Width(250)); { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true)); { foreach (DelayedCommand dc in mFlightComputer) { GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.Label(Format(dc)); RTUtil.Button("x", () => { mFlightComputer.Enqueue(DelayedCommand.Cancel(dc)); }, GUILayout.Width(21)); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { GUILayout.Label("Artificial delay: "); GUI.SetNextControlName("xd"); GUILayout.Label(mFlightComputer.ExtraDelay.ToString("F2")); RTUtil.TextField(ref mExtraDelay, GUILayout.ExpandWidth(true)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
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(); }
public void Draw() { // Allow update for non-triggering changes (e.g., changing map view filters or changing a vessel's type) // This is the best way I could find to do periodic refreshes; // RTCore.Instance.InvokeRepeating() would require a search for instances // of AntennaFragment, and would keep running after all target windows // closed. Replace with something less clunky later! -- Starstrider42 if (++refreshCounter >= 100) { Refresh(); refreshCounter = 0; } mScrollPosition = GUILayout.BeginScrollView(mScrollPosition); { Color pushColor = GUI.backgroundColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; // Depth-first tree traversal. Stack<Entry> dfs = new Stack<Entry>(); foreach (Entry child in mRootEntry.SubEntries) { dfs.Push(child); } while (dfs.Count > 0) { Entry current = dfs.Pop(); GUI.backgroundColor = current.Color; GUILayout.BeginHorizontal(); { GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24)); if (current.SubEntries.Count > 0) { RTUtil.Button(current.Expanded ? " <" : " >", () => { current.Expanded = !current.Expanded; }, GUILayout.Width(24)); } RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1, (s) => { mSelection = current; Antenna.Target = mSelection.Guid; }); } GUILayout.EndHorizontal(); if (current.Expanded) { foreach (Entry child in current.SubEntries) { dfs.Push(child); } } } GUI.skin.button.alignment = pushAlign; GUI.backgroundColor = pushColor; } GUILayout.EndScrollView(); }
public void Draw() { if (mTextConsole == null) { mTextConsole = new GUIStyle(GUI.skin.box) { wordWrap = true, alignment = TextAnchor.LowerLeft }; } float width3 = 125 / 3 - GUI.skin.button.margin.right * 2.0f / 3.0f; float width4 = 125 / 4 - GUI.skin.button.margin.right * 3.0f / 4.0f; ProgcomIO io = mFlightComputer.Progcom.IO; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { Parse(mCommand); mCommand = ""; Event.current.Use(); } GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(GUILayout.Width(125)); { GUILayout.Label(io.Numpad.ToString(), GUI.skin.textField); GUILayout.BeginHorizontal(); { RTUtil.Button("7", () => io.Numpad = 7, GUILayout.Width(width4)); RTUtil.Button("8", () => io.Numpad = 8, GUILayout.Width(width4)); RTUtil.Button("9", () => io.Numpad = 9, GUILayout.Width(width4)); RTUtil.Button("R", () => io.Numpad = ProgcomIO.Reset, GUILayout.Width(width4)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.Button("4", () => io.Numpad = 4, GUILayout.Width(width4)); RTUtil.Button("5", () => io.Numpad = 5, GUILayout.Width(width4)); RTUtil.Button("6", () => io.Numpad = 6, GUILayout.Width(width4)); RTUtil.Button("C", () => io.Numpad = ProgcomIO.Clear, GUILayout.Width(width4)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.Button("1", () => io.Numpad = 1, GUILayout.Width(width4)); RTUtil.Button("2", () => io.Numpad = 2, GUILayout.Width(width4)); RTUtil.Button("3", () => io.Numpad = 3, GUILayout.Width(width4)); RTUtil.Button("-", () => io.Numpad = ProgcomIO.Minus, GUILayout.Width(width4)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { RTUtil.Button("0", () => io.Numpad = 0, GUILayout.Width(width4)); RTUtil.Button("ENTER", () => io.Numpad = ProgcomIO.Enter, GUILayout.ExpandWidth(true)); RTUtil.Button("+", () => io.Numpad = ProgcomIO.Plus, GUILayout.Width(width4)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(150)); { GUILayout.Label("M1: " + Output1, GUI.skin.textField); GUILayout.Label("M2: " + Output2, GUI.skin.textField); GUILayout.Label("M3: " + Output3, GUI.skin.textField); GUILayout.Label("M4: " + Output4, GUI.skin.textField); GUILayout.Label("MSG: " + OutputMsg, GUI.skin.textField); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.Height(100)); { GUILayout.Box(io.Console, mTextConsole, GUILayout.ExpandHeight(true)); } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); { RTUtil.TextField(ref mCommand); RTUtil.StateButton("MON", mEnableMonitor ? 1 : 0, 1, (s) => mEnableMonitor = (s > 0), GUILayout.Width(40)); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (Event.current.type == EventType.Repaint) { mMonitorDimension = GUILayoutUtility.GetLastRect().height - GUI.skin.box.padding.top - GUI.skin.box.padding.bottom; } GUILayout.BeginVertical(); { if (mEnableMonitor) { GUILayout.Box(io.Monitor, GUILayout.Width(mMonitorDimension), GUILayout.Height(mMonitorDimension)); } } GUILayout.EndVertical(); }
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(); }