//Calculations GUI core internal void Calculations() { #region Calculations //Selection mode GUIUtils.CreateTwinToggle("Calculations mode:", ref this.calcSelect, 300, new string[] { "Automatic", "Manual" }); GUILayout.Space(5); //Calculations this.parachuteScroll = GUILayout.BeginScrollView(this.parachuteScroll, false, false, this.skins.horizontalScrollbar, this.skins.verticalScrollbar, this.skins.box, GUILayout.Height(160)); string label; float max, min; #region Automatic if (this.calcSelect) { this.typeID = GUILayout.SelectionGrid(this.typeID, EnumUtils.GetNames <ParachuteType>(), 3, this.skins.button); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Toggle(this.getMass, "Use current craft mass", this.skins.button, GUILayout.Width(150))) { this.getMass = true; } GUILayout.FlexibleSpace(); if (GUILayout.Toggle(!this.getMass, "Input craft mass", this.skins.button, GUILayout.Width(150))) { this.getMass = false; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (this.getMass) { GUILayout.Label("Currently using " + (this.useDry ? "dry mass" : "wet mass"), skins.label); if (GUILayout.Button("Switch to " + (this.useDry ? "wet mass" : "dry mass"), this.skins.button, GUILayout.Width(125))) { this.useDry = !this.useDry; } } else { GUIUtils.CreateEntryArea("Mass to use (t):", ref mass, 0.1f, 10000, 100); } max = 300; switch (this.type) { case ParachuteType.Main: label = "Wanted touchdown speed (m/s):"; break; case ParachuteType.Drogue: label = "Wanted speed at target alt (m/s):"; max = 5000; break; case ParachuteType.Drag: label = "Planned landing speed (m/s):"; break; default: label = string.Empty; break; } GUIUtils.CreateEntryArea(label, ref this.landingSpeed, 0.1f, max, 100); if (this.type == ParachuteType.Drogue) { GUIUtils.CreateEntryArea("Target altitude (m):", ref this.refDepAlt, 10, (float)body.GetMaxAtmosphereAltitude(), 100); } if (this.type == ParachuteType.Drag) { GUIUtils.CreateEntryArea("Wanted deceleration (m/s²):", ref this.deceleration, 0.1f, 100, 100); } GUIUtils.CreateEntryArea("Parachutes used (parachutes):", ref this.chuteCount, 1, 100, 100); } #endregion #region Manual else { float p, d; if (!float.TryParse(this.preDepDiam, out p)) { p = -1; } if (!float.TryParse(this.depDiam, out d)) { d = -1; } //Predeployed diameter GUIUtils.CreateEntryArea("Predeployed diameter (m):", ref this.preDepDiam, 0.5f, d, 100); if (p != -1) { GUILayout.Label("Resulting area: " + RCUtils.GetArea(p).ToString("0.00") + "m²", this.skins.label); } else { GUILayout.Label("Resulting predeployed area: --- m²", this.skins.label); } //Deployed diameter GUIUtils.CreateEntryArea("Deployed diameter (m):", ref this.depDiam, 1, (this.pChute.textures == null ? 70 : this.model.maxDiam), 100); if (d != 1) { GUILayout.Label("Resulting area: " + RCUtils.GetArea(d).ToString("0.00") + "m²", this.skins.label); } else { GUILayout.Label("Resulting deployed area: --- m²", this.skins.label); } } #endregion GUILayout.EndScrollView(); #endregion #region Specific //Pressure/alt toggle GUILayout.Space(5); GUILayout.BeginHorizontal(); if (GUILayout.Toggle(this.isPressure, "Pressure predeployment", this.skins.toggle)) { if (!this.isPressure) { this.isPressure = true; this.predepClause = this.parachute.minPressure.ToString(); } } GUILayout.FlexibleSpace(); if (GUILayout.Toggle(!this.isPressure, "Altitude predeployment", this.skins.toggle)) { if (this.isPressure) { this.isPressure = false; this.predepClause = this.parachute.minDeployment.ToString(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //Pressure/alt selection if (this.isPressure) { label = "Predeployment pressure (atm):"; min = 0.0001f; max = (float)this.body.GetPressureASL(); } else { label = "Predeployment altitude (m):"; min = 10; max = (float)body.GetMaxAtmosphereAltitude(); } GUIUtils.CreateEntryArea(label, ref this.predepClause, min, max); //Deployment altitude GUIUtils.CreateEntryArea("Deployment altitude", ref deploymentAlt, 10, (float)body.GetMaxAtmosphereAltitude()); //Cut altitude GUIUtils.CreateEmptyEntryArea("Autocut altitude (m):", ref this.cutAlt, -1, (float)this.body.GetMaxAtmosphereAltitude()); //Predeployment speed GUIUtils.CreateEntryArea("Pre deployment speed (s):", ref preDepSpeed, 0.5f, 5); //Deployment speed GUIUtils.CreateEntryArea("Deployment speed (s):", ref depSpeed, 1, 10); #endregion }
//Info window private void Window(int id) { //Header GUI.DragWindow(this.drag); GUILayout.BeginVertical(); //Top info labels StringBuilder builder = new StringBuilder("Part name: ").AppendLine(this.part.partInfo.title); builder.Append("Symmetry counterparts: ").AppendLine(this.part.symmetryCounterparts.Count.ToString()); builder.Append("Part mass: ").Append(this.part.TotalMass().ToString("0.###")).Append("t"); GUILayout.Label(builder.ToString(), this.skins.label); //Beggining scroll this.scroll = GUILayout.BeginScrollView(this.scroll, false, false, this.skins.horizontalScrollbar, this.skins.verticalScrollbar, this.skins.box); GUILayout.Space(5); GUILayout.Label("General:", GUIUtils.boldLabel, GUILayout.Width(120)); //General labels builder = new StringBuilder("Autocut speed: ").Append(cutSpeed).AppendLine("m/s"); if (this.timer >= 60) { builder.Append("Deployment timer: ").AppendLine(RCUtils.ToMinutesSeconds(this.timer)); } else if (this.timer > 0) { builder.Append("Deployment timer: ").Append(this.timer.ToString("0.#")).AppendLine("s"); } if (this.mustGoDown) { builder.AppendLine("Must go downwards to deploy"); } if (this.deployOnGround) { builder.AppendLine("Automatically deploys on ground contact"); } if (this.spareChutes >= 0) { builder.Append("Spare chutes: ").Append(chuteCount); } else { builder.Append("Spare chutes: inf"); } GUILayout.Label(builder.ToString(), this.skins.label); //Specific labels for (int i = 0; i < this.parachutes.Count; i++) { GUILayout.Label("___________________________________________", GUIUtils.boldLabel); GUILayout.Space(3); GUILayout.Label(RCUtils.ParachuteNumber(i) + ":", GUIUtils.boldLabel, GUILayout.Width(120)); this.parachutes[i].UpdateGUI(); } //End scroll GUILayout.EndScrollView(); //Copy button if in flight if (HighLogic.LoadedSceneIsFlight && this.part.symmetryCounterparts.Count > 0) { GUIUtils.CenteredButton("Copy to others chutes", CopyToCouterparts); } //Close button GUIUtils.CenteredButton("Close", () => this.visible = false); //Closer GUILayout.EndVertical(); }