private static void OnWindow(int winID) { if (GUI.Button(new Rect(5, 15, 65, 20), "Previous")) { NavUtilLib.GlobalVariables.FlightData.rwyIdx--; NavUtilLib.GlobalVariables.FlightData.rwyIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.rwyIdx, NavUtilLib.GlobalVariables.FlightData.currentBodyRunways.Count() - 1, 0); } if (GUI.Button(new Rect(75, 15, 95, 20), "Runway list")) { RunwayListGUI.show(winPos); } if (GUI.Button(new Rect(175, 15, 65, 20), "Next")) { NavUtilLib.GlobalVariables.FlightData.rwyIdx++; NavUtilLib.GlobalVariables.FlightData.rwyIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.rwyIdx, NavUtilLib.GlobalVariables.FlightData.currentBodyRunways.Count() - 1, 0); } if (GUI.Button(new Rect(5, 40, 115, 20), "Previous G/S")) { NavUtilLib.GlobalVariables.FlightData.gsIdx--; NavUtilLib.GlobalVariables.FlightData.gsIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.gsIdx, NavUtilLib.GlobalVariables.FlightData.gsList.Count() - 1, 0); } if (GUI.Button(new Rect(130, 40, 115, 20), "Next G/S")) { NavUtilLib.GlobalVariables.FlightData.gsIdx++; NavUtilLib.GlobalVariables.FlightData.gsIdx = NavUtilLib.Utils.indexChecker(NavUtilLib.GlobalVariables.FlightData.gsIdx, NavUtilLib.GlobalVariables.FlightData.gsList.Count() - 1, 0); } GUI.Label(new Rect(5, 75, 115, 25), "HSI GUI scale"); if (GUI.Button(new Rect(130, 75, 100, 25), "Default Scale")) { NavUtilLib.GlobalVariables.Settings.hsiGUIscale = 0.5f; } if (GUI.Button(new Rect(5, 150, 115, 20), "Custom Rwys")) { NavUtilGUI.RunwaysEditor.startGUI(); } //GUI.Label(new Rect(125, 150, 90, 20), "Popup in IVA?"); GlobalVariables.Settings.hideNavBallWaypoint = GUI.Toggle(new Rect(30, 120, 240, 20), GlobalVariables.Settings.hideNavBallWaypoint, "Hide NavBall waypoint icon"); GlobalVariables.Settings.enableWindowsInIVA = GUI.Toggle(new Rect(125, 150, 120, 20), GlobalVariables.Settings.enableWindowsInIVA, "Popup in IVA"); NavUtilLib.GlobalVariables.Settings.hsiGUIscale = GUI.HorizontalSlider(new Rect(5, 105, 240, 30), NavUtilLib.GlobalVariables.Settings.hsiGUIscale, 0.1f, 1.0f); GUI.DragWindow(); }
/*************************************************************************************************************************/ public void MainGUI(int windowID) { List <string> save_files = new List <string>(); Vessel temp_vessel; string temp_string; Guid guid_delete_vessel = FlightGlobals.ActiveVessel.id; bool delete_vessel = false; float scrollbar_size; bool scrollbar_enable = false; float window_height, window_width, scrollbar_width_offset; window_height = 60; window_width = 280; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (!_SETTING_Minimize) { if (_SAVE_Has_Launched) { GUILayout.Box("Mission Time: " + get_time_string(Planetarium.GetUniversalTime() - _SAVE_Launched_At), text_main, GUILayout.Width(188)); } else { GUILayout.Box("Mission Time: " + "00:00", text_main, GUILayout.Width(137)); } } else { GUILayout.Space(5); } if (_SETTING_Armed) { temp_string = "Armed"; } else { temp_string = "Arm"; } if (!_SAVE_Has_Launched) { _SETTING_Armed = GUILayout.Toggle(_SETTING_Armed, temp_string, button_small, GUILayout.Width(50)); } else if (_SETTING_Minimize) { GUILayout.Box("Flight", text_main, GUILayout.Width(50)); } if (!_SETTING_Minimize) { show_setting = GUILayout.Toggle(show_setting, buttonContent, button_small, GUILayout.Width(25)); if (show_setting) { buttonContent = upContent; } else { buttonContent = downContent; } } _SETTING_Minimize = GUILayout.Toggle(_SETTING_Minimize, "_", button_small, GUILayout.Width(25)); if (really_close && _SETTING_Minimize) { _SETTING_Minimize = false; } if (!_SETTING_Minimize) { really_close = GUILayout.Toggle(really_close, "x", button_small, GUILayout.Width(25)); } else { window_width = 105; } GUILayout.EndHorizontal(); if (really_close) { if (_SAVE_Has_Launched) { GUILayout.Space(5); window_height += 5; GUILayout.Box("Plugin will be reset!", text_heading, GUILayout.Width(266)); window_height += 29; GUILayout.Box("Close?", text_heading, GUILayout.Width(266)); GUILayout.BeginHorizontal(); if (GUILayout.Button("YES", button_big, GUILayout.Width(132))) { close_FMRS(); } if (GUILayout.Button("NO", button_big, GUILayout.Width(133))) { really_close = false; } GUILayout.EndHorizontal(); window_height += 58; } else { close_FMRS(); } } if (really_close == false && _SETTING_Minimize == false && show_setting == true) { GUILayout.Space(5); window_height += 5; GUILayout.BeginVertical(/* area_style ,*/ GUILayout.Width(266)); GUILayout.Space((5 * 30) + 5); _SETTING_Messages = GUI.Toggle(new Rect(5, 35 + (30 * 1), 25, 25), _SETTING_Messages, "Messaging System"); window_height += 30; _SETTING_Auto_Cut_Off = GUI.Toggle(new Rect(5, 35 + (30 * 2), 25, 25), _SETTING_Auto_Cut_Off, "Auto Cut Off Engines"); window_height += 30; _SETTING_Auto_Recover = GUI.Toggle(new Rect(5, 35 + (30 * 3), 25, 25), _SETTING_Auto_Recover, "Auto Recover Landed Crafts"); window_height += 30; _SETTING_Throttle_Log = GUI.Toggle(new Rect(5, 35 + (30 * 4), 25, 25), _SETTING_Throttle_Log, "Throttle Logger WIP"); window_height += 30; Timer_Stage_Delay = GUI.HorizontalSlider(new Rect(45, 35 + (30 * 6) + 15, 205, 25), Timer_Stage_Delay, 0.2f, 5.0f); window_height += 45; GUI.Label(new Rect(20, 35 + (30 * 7), 225, 25), "Stage Save Delay: " + Timer_Stage_Delay.ToString("F1")); GUILayout.EndVertical(); window_height += 42; } if (really_close == false && _SETTING_Minimize == false && show_setting == false) { if (Vessels_dropped.Count > 0) { GUILayout.Space(5); window_height += 5; GUILayout.Box("Separated Stages:", text_heading, GUILayout.Width(266)); window_height += 33; foreach (KeyValuePair <Guid, string> temp_keyvalue in Vessels_dropped) { if (!save_files.Contains(temp_keyvalue.Value)) { save_files.Add(temp_keyvalue.Value); } } save_files.Sort(delegate(string x, string y) { return(get_save_value(save_cat.SAVEFILE, y).CompareTo(get_save_value(save_cat.SAVEFILE, x))); }); nr_save_files = save_files.Count; scrollbar_size = nr_save_files * 61; scrollbar_size += (Vessels_dropped.Count - nr_save_files) * 25; if (_SAVE_Switched_To_Dropped && can_q_save_load) { scrollbar_size += 43; } if (scrollbar_size > 225) { scrollbar_enable = true; scroll_Vector = GUILayout.BeginScrollView(scroll_Vector, scrollbar_stlye, GUILayout.Width(266), GUILayout.Height(225)); GUILayout.BeginVertical(); window_height += 220; scrollbar_width_offset = 0; } else { GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(266)); window_height += scrollbar_size; scrollbar_width_offset = 20; } while (save_files.Count != 0) { GUILayout.Space(5); GUILayout.BeginVertical(); // area_style); if (save_files.Last().Contains("separated_")) { GUILayout.Box("Separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset)); } else { GUILayout.Box("Stage " + save_files.Last().Substring(10) + " separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset)); } foreach (KeyValuePair <Guid, string> vessel_in_savefile in Vessels_dropped) { if (FMRS_SAVE_Util.Instance.jumpInProgress) { GUI.enabled = false; } if (vessel_in_savefile.Value == save_files.Last()) { GUILayout.BeginHorizontal(); if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.RECOVERED) { GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " recovered", text_cyan, GUILayout.Width(205 + scrollbar_width_offset)); } else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.LANDED) { GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(205 + scrollbar_width_offset)); } else if (vessel_in_savefile.Key == FlightGlobals.ActiveVessel.id || vessel_in_savefile.Key == anz_id) { float temp_float = 230 + scrollbar_width_offset; if (can_q_save_load) { GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(230)); temp_float = 222 + scrollbar_width_offset; } if (FlightGlobals.ActiveVessel.LandedOrSplashed) { GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(temp_float)); } else { GUILayout.Box("contr.: " + Vessels_dropped_names[vessel_in_savefile.Key], text_yellow, GUILayout.Width(temp_float)); } if (can_q_save_load) { if (GUILayout.Button("Jump back to Separation", button_main, GUILayout.Width(222 + scrollbar_width_offset))) { jump_to_vessel(vessel_in_savefile.Key, false); } GUILayout.EndVertical(); GUILayout.Space(5); GUILayout.BeginHorizontal(); } } else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.DESTROYED) { GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " destroyed", text_red, GUILayout.Width(205 + scrollbar_width_offset)); } else { temp_vessel = FlightGlobals.Vessels.Find(p => p.id == vessel_in_savefile.Key); if (temp_vessel == null) { if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset))) { jump_to_vessel(vessel_in_savefile.Key, true); } } else { if (loaded_vessels.Contains(temp_vessel.id) && _SAVE_Switched_To_Dropped) { if (temp_vessel.LandedOrSplashed) { if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", button_green, GUILayout.Width(205 + scrollbar_width_offset))) { FlightGlobals.ForceSetActiveVessel(temp_vessel); } } else { if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " is near", button_yellow, GUILayout.Width(205 + scrollbar_width_offset))) { FlightGlobals.ForceSetActiveVessel(temp_vessel); } } } else { if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset))) { jump_to_vessel(vessel_in_savefile.Key, true); } } } } if (vessel_in_savefile.Key != FlightGlobals.ActiveVessel.id && vessel_in_savefile.Key != anz_id) { if (GUILayout.Button("X", button_small_red, GUILayout.Width(25))) { guid_delete_vessel = vessel_in_savefile.Key; delete_vessel = true; } } GUILayout.EndHorizontal(); button_main.normal.textColor = button_main.focused.textColor = Color.white; } GUI.enabled = true; } GUILayout.EndVertical(); temp_string = save_files.Last(); save_files.Remove(temp_string); } if (scrollbar_enable) { GUILayout.EndVertical(); GUILayout.EndScrollView(); } else { GUILayout.EndVertical(); } } if (_SAVE_Switched_To_Dropped) { GUILayout.Space(5); window_height += 5; if (FMRS_SAVE_Util.Instance.jumpInProgress) { GUI.enabled = false; } if (GUILayout.Button("Jump back to Main Mission", button_big, GUILayout.Width(266))) { jump_to_vessel("Main"); } GUI.enabled = true; window_height += 31; } if (_SAVE_Has_Launched && can_restart) { GUILayout.Space(5); window_height += 5; if (FMRS_SAVE_Util.Instance.jumpInProgress) { GUI.enabled = false; } if (revert_to_launch) { GUILayout.Box("Revert Flight?", text_heading, GUILayout.Width(266)); GUILayout.BeginHorizontal(); if (GUILayout.Button("YES", button_big, GUILayout.Width(132))) { // _SETTING_Enabled = false; jump_to_vessel(_SAVE_Main_Vessel, "before_launch"); } if (GUILayout.Button("NO", button_big, GUILayout.Width(133))) { revert_to_launch = false; } GUILayout.EndHorizontal(); window_height += 58; } else { if (_SAVE_Flight_Reset) { revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Plugin Start", button_big, GUILayout.Width(266)); } else { revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Launch", button_big, GUILayout.Width(266)); } window_height += 31; } GUI.enabled = true; } } GUILayout.EndVertical(); if (delete_vessel && guid_delete_vessel != FlightGlobals.ActiveVessel.id) { delete_dropped_vessel(guid_delete_vessel); } windowPos.height = window_height; // windowPos.width = window_width; GUI.DragWindow(); }
private void ToolbarWindow(int windowID) { float line = 0; line += 1.25f; if (FlightGlobals.ActiveVessel && (FlightGlobals.ActiveVessel.LandedOrSplashed || VesselMove.Instance.IsMovingVessel)) { if (!VesselMove.Instance.IsMovingVessel) { if (GUI.Button(LineRect(ref line, 1.5f), "Move Vessel", HighLogic.Skin.button)) { VesselMove.Instance.StartMove(FlightGlobals.ActiveVessel, true); } line += 0.2f; Rect spawnVesselRect = LineRect(ref line); svRectScreenSpace = new Rect(spawnVesselRect); svRectScreenSpace.x += toolbarRect.x; svRectScreenSpace.y += toolbarRect.y; if (GUI.Button(spawnVesselRect, "Spawn Vessel", HighLogic.Skin.button)) { VesselSpawn.instance.StartVesselSpawn(); } line += .75f; Rect crewRect1 = LineRect(ref line); Rect crewRect2 = new Rect(crewRect1.x + crewRect1.width / 2 + 5f, crewRect1.y, crewRect1.width / 2, crewRect1.height); crewRect1.width = crewRect1.width / 2; svCrewScreenSpace = new Rect(crewRect1); svCrewScreenSpace.x += toolbarRect.x; svCrewScreenSpace.y += toolbarRect.y; addCrewMembers = GUI.Toggle(crewRect1, addCrewMembers, "Spawn Crew"); if (!addCrewMembers) { GUI.enabled = false; } selectCrewMembers = GUI.Toggle(crewRect2, selectCrewMembers, "Choose Crew"); GUI.enabled = true; showMoveHelp = false; } else { if (GUI.Button(LineRect(ref line, 2), "Place Vessel", HighLogic.Skin.button)) { VesselMove.Instance.EndMove(); } line += 0.3f; if (GUI.Button(LineRect(ref line, 2), "Drop Vessel", HighLogic.Skin.button)) { VesselMove.Instance.DropMove(); } line += 0.3f; if (GUI.Button(LineRect(ref line), "Help", HighLogic.Skin.button)) { showMoveHelp = !showMoveHelp; } } } else { GUIStyle centerLabelStyle = new GUIStyle(HighLogic.Skin.label); centerLabelStyle.alignment = TextAnchor.UpperCenter; GUI.Label(LineRect(ref line), "You need to be landed to use this!", centerLabelStyle); } toolbarRect.height = (line * toolbarLineHeight) + (toolbarMargin * 2); GUI.DragWindow(new Rect(0, 0, Screen.width, 30)); VMUtils.RepositionWindow(ref toolbarRect); }
private static void OnWindow(int winID) { rwyListLength = Rwy.customRunways.Count * 40; rwyListVector = GUI.BeginScrollView(new Rect(10, 20, 150, 270), rwyListVector, new Rect(0, 0, 135, rwyListLength + 35)); if (GUI.Button(new Rect(2, 0, 130, 30), "Create Runway")) { tempRwy = new NavUtilLib.Runway(); isNewRwy = true; } for (int i = 0; i < Rwy.customRunways.Count; i++) { if (i == Rwy.cRwyIdx && !isNewRwy) { if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), "* " + Rwy.customRunways[i].ident)) { Rwy.cRwyIdx = i; tempRwy = Rwy.customRunways[i]; isNewRwy = false; } } else { if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), Rwy.customRunways[i].ident)) { Rwy.cRwyIdx = i; tempRwy = Rwy.customRunways[i]; isNewRwy = false; } } } GUI.EndScrollView(); //begin runway info area GUI.Label(new Rect(170, 20, 200, 20), "Runway Ident"); GUI.Label(new Rect(170, 70, 150, 20), "Runway Heading"); GUI.Label(new Rect(170, 120, 150, 20), "Runway Elevation (m)"); GUI.Label(new Rect(170, 185, 240, 20), "Marker distance from current point (m)"); GUI.Label(new Rect(190, 200, 60, 20), " Inner"); GUI.Label(new Rect(260, 200, 60, 20), " Middle"); GUI.Label(new Rect(330, 200, 60, 20), " Outer"); //isNewRwy //only difference is textbox vs label if (isNewRwy) { GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?"); useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, ""); GUI.Label(new Rect(340, 120, 85, 20), "Auto Elevation?"); useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, ""); tempRwy.ident = GUI.TextField(new Rect(170, 40, 200, 20), tempRwy.ident); GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?"); useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, ""); if (useAutoHdg) { tempRwy.hdg = (float)Math.Round(FlightGlobals.ship_heading, 2); GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°"); } else { tempRwy.hdg = Convert.ToSingle(GUI.TextField(new Rect(170, 90, 150, 20), Convert.ToString(tempRwy.hdg))); } GUI.Label(new Rect(340, 120, 85, 20), "Auto Alt?"); useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, ""); if (useAutoElevation) { tempRwy.altMSL = (float)Math.Round(FlightGlobals.ActiveVessel.altitude, 1); GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m"); } else { tempRwy.altMSL = Convert.ToSingle(GUI.TextField(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL))); } GUI.Label(new Rect(170, 165, 120, 20), "Use Marker Becons?"); makeMarkers = GUI.Toggle(new Rect(350, 168, 20, 20), makeMarkers, ""); if (makeMarkers) { tempRwy.innerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(190, 220, 60, 20), Convert.ToString(tempRwy.innerMarkerDist))); tempRwy.middleMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(260, 220, 60, 20), Convert.ToString(tempRwy.middleMarkerDist))); tempRwy.outerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(330, 220, 60, 20), Convert.ToString(tempRwy.outerMarkerDist))); if (tempRwy.innerMarkerDist < -500) { tempRwy.innerMarkerDist = -500; } if (tempRwy.middleMarkerDist < -500) { tempRwy.middleMarkerDist = -500; } if (tempRwy.outerMarkerDist < -500) { tempRwy.outerMarkerDist = -500; } } } else { GUI.Label(new Rect(170, 40, 200, 20), tempRwy.ident); GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°"); GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m"); if (tempRwy.innerMarkerDist > -500) { GUI.Label(new Rect(190, 220, 60, 20), tempRwy.innerMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(190, 220, 60, 20), " N/A"); } if (tempRwy.middleMarkerDist > -500) { GUI.Label(new Rect(260, 220, 60, 20), tempRwy.middleMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(260, 220, 60, 20), " N/A"); } if (tempRwy.outerMarkerDist > -500) { GUI.Label(new Rect(330, 220, 60, 20), tempRwy.outerMarkerDist.ToString() + "m"); } else { GUI.Label(new Rect(330, 220, 60, 20), " N/A"); } } if (isNewRwy) { if (GUI.Button(new Rect(170, 250, 200, 20), "Create Runway")) { //create the runway and add to database tempRwy.body = FlightGlobals.currentMainBody.bodyName; tempRwy.gsLatitude = (float)FlightGlobals.ship_latitude; tempRwy.gsLongitude = (float)FlightGlobals.ship_longitude; Vector2d loc = NavUtilLib.Utils.CalcCoordinatesFromInitialPointBearingDistance(new Vector2d(tempRwy.gsLatitude, tempRwy.gsLongitude), tempRwy.hdg, 1000, FlightGlobals.currentMainBody.Radius); tempRwy.locLatitude = (float)loc.x; tempRwy.locLongitude = (float)loc.y; if (!makeMarkers) { tempRwy.innerMarkerDist = -1000; tempRwy.middleMarkerDist = -1000; tempRwy.outerMarkerDist = -1000; } Rwy.customRunways.Add(tempRwy); Rwy.currentBodyRunways.Add(tempRwy); Rwy.cRwyIdx = Rwy.customRunways.FindIndex(r => r.ident == tempRwy.ident); WriteCustomRwys(); isNewRwy = false; } } else { //show delete button if (GUI.Button(new Rect(170, 250, 200, 20), "Delete This Runway")) { Rwy.allRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); if (Rwy.currentBodyRunways.Contains(Rwy.customRunways[Rwy.cRwyIdx])) { Rwy.currentBodyRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); } Rwy.customRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]); WriteCustomRwys(); Rwy.cRwyIdx = 0; isNewRwy = true; tempRwy = new NavUtilLib.Runway(); } } GUI.DragWindow(); }