public static IView View(HyperEditBehaviour hyperedit) { var orbitEditorView = OrbitEditorView.Create(); var planetEditorView = PlanetEditorView.Create(); var landerView = LanderView.Create(); var miscEditorView = MiscEditorView.Create(); var aboutView = AboutWindow.Create(); var closeAll = new ButtonView("Close all", "Closes all windows", Window.CloseAll); var orbitEditor = new ButtonView("Orbit Editor", "Opens the Orbit Editor window", orbitEditorView); var planetEditor = new ButtonView("Planet Editor", "Opens the Planet Editor window", planetEditorView); var shipLander = new ButtonView("Ship Lander", "Opens the Ship Lander window", landerView); var miscTools = new ButtonView("Misc Tools", "Opens the Misc Tools window", miscEditorView); var about = new ButtonView("About", "Opens the About window", aboutView); var appLauncher = new DynamicToggleView("H-Button", "Enables or disables the AppLauncher button (top right H button)", () => hyperedit.UseAppLauncherButton, () => true, v => hyperedit.UseAppLauncherButton = v); return(new VerticalView(new IView[] { closeAll, orbitEditor, planetEditor, shipLander, miscTools, about, appLauncher })); }
public static IView View() { // Load Auto Open status. ReloadConfig(); var setAutoOpen = new DynamicToggleView("Auto Open", "Open this view when entering the Flight or Tracking Center scenes.", () => AutoOpenLander, () => true, v => AutoOpenLander = v); var bodySelector = new ListSelectView <CelestialBody>("Body", () => FlightGlobals.fetch == null ? null : FlightGlobals.fetch.bodies, null, Extensions.CbToString); bodySelector.CurrentlySelected = FlightGlobals.fetch == null ? null : FlightGlobals.ActiveVessel == null ? Planetarium.fetch.Home : FlightGlobals.ActiveVessel.mainBody; var lat = new TextBoxView <double>("Lat", "Latitude (North/South). Between +90 (North) and -90 (South).", 0.001d, latTryParse); var lon = new TextBoxView <double>("Lon", "Longitude (East/West). Converts to less than 360 degrees.", 0.001d, myTryParse); var alt = new TextBoxView <double>("Alt", "Altitude (Up/Down). Distance above the surface.", 20, altTryParse); var setRot = new ToggleView("Force Rotation", "Rotates vessel such that up on the vessel is up when landing. Otherwise, the current orientation is kept relative to the body.", true); Func <bool> isValid = () => lat.Valid && lon.Valid && alt.Valid; Action <double, double, double, CelestialBody> load = (latVal, lonVal, altVal, body) => { lat.Object = latVal; lon.Object = lonVal; alt.Object = altVal; bodySelector.CurrentlySelected = body; }; // Load last entered values. Model.DoLander.LoadLast(load); return(new VerticalView(new IView[] { setAutoOpen, bodySelector, new ConditionalView(() => FlightGlobals.fetch != null && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.mainBody != bodySelector.CurrentlySelected, new LabelView("Landing on a different body is not recommended.", "This may destroy the vessel. Use the Orbit Editor to orbit the body first, then land on it.")), lat, new ConditionalView(() => !lat.Valid, new LabelView("Latitude must be a number from 0 to (+/-)89.9.", "Values too close to the poles ((+/-)90) can crash KSP, values beyond that are invalid for a latitude.")), lon, alt, new ConditionalView(() => alt.Object < 0, new LabelView("Altitude must be a positive number.", "This may destroy the vessel. Values less than 0 are sub-surface.")), setRot, new ConditionalView(() => !isValid(), new ButtonView("Cannot Land", "Entered location is invalid. Correct items in red.", null)), new ConditionalView(() => !Model.DoLander.IsLanding() && isValid(), new ButtonView("Land", "Teleport to entered location, then slowly lower to surface.", () => Model.DoLander.ToggleLanding(lat.Object, lon.Object, alt.Object, bodySelector.CurrentlySelected, setRot.Value, load))), new ConditionalView(() => Model.DoLander.IsLanding(), new ButtonView("Drop (CAUTION!)", "Release vessel to gravity.", () => Model.DoLander.ToggleLanding(lat.Object, lon.Object, alt.Object, bodySelector.CurrentlySelected, setRot.Value, load))), new ConditionalView(() => Model.DoLander.IsLanding(), new LabelView("LANDING IN PROGRESS.", "Vessel is being lowered to the surface.")), //Launch button here new ConditionalView(() => Model.DoLander.IsLanding(), new LabelView(changeHelpString(), "Change location slightly.")), new ConditionalView(() => !Model.DoLander.IsLanding(), new ButtonView("Land Here", "Stop at current location, then slowly lower to surface.", () => Model.DoLander.LandHere(load))), new ListSelectView <Vessel>("Set to vessel", Model.DoLander.LandedVessels, select => Model.DoLander.SetToLanded(load, select), Extensions.VesselToString), new ButtonView("Current", "Set to current location.", () => Model.DoLander.SetToCurrent(load)), new ConditionalView(isValid, new ButtonView("Save", "Save the entered location.", () => Model.DoLander.AddSavedCoords(lat.Object, lon.Object, alt.Object, bodySelector.CurrentlySelected))), new ButtonView("Load", "Load a saved location.", () => Model.DoLander.Load(load)), new ButtonView("Delete", "Delete a saved location.", Model.DoLander.Delete), })); }