Esempio n. 1
0
        //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
        }
Esempio n. 2
0
        //Main GUI window
        private void Window(int id)
        {
            GUILayout.BeginVertical();

            #region Info labels
            //Header labels
            StringBuilder builder = new StringBuilder();
            builder.Append("Selected part: ").AppendLine(this.part.partInfo.title);
            builder.Append("Symmetry counterparts: ").AppendLine(this.part.symmetryCounterparts.Count.ToString());
            builder.Append("Case mass: ").Append(this.rcModule.caseMass.ToString("0.000")).Append("t");
            if (this.sizes.Count > 0)
            {
                builder.Append("\t\t\t\t\tCase cost: ").Append(this.sizes[this.pChute.size].cost.ToString()).Append("F");
            }
            builder.Append("\nTotal part mass: ").Append(this.part.TotalMass().ToString("0.000")).Append("t");
            builder.Append("\t\t\tTotal part cost: ").Append(this.part.TotalCost().ToString("0.#")).Append("F");
            GUILayout.Label(builder.ToString(), this.skins.label);
            #endregion

            #region Presets
            //Presets buttons
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Select a preset", this.skins.button))
            {
                this.presetVisible = !this.presetVisible;
            }

            if (GUILayout.Button("Save as preset...", this.skins.button))
            {
                this.presetSaveVisible = !this.presetSaveVisible;
            }
            GUILayout.EndHorizontal();
            #endregion

            //Scroll being
            this.mainScroll = GUILayout.BeginScrollView(this.mainScroll, false, false, this.skins.horizontalScrollbar, this.skins.verticalScrollbar);

            #region Planet selector
            //Target planet selection
            GUILayout.Space(10);
            GUILayout.BeginHorizontal(GUILayout.Height(30));
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.Label("Target planet:", this.skins.label);
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            this.pChute.planets = GUILayout.SelectionGrid(this.pChute.planets, this.pChute.bodies.bodyNames, 4, this.skins.button, GUILayout.Width(250));
            GUILayout.EndHorizontal();
            this.pChute.body = this.pChute.bodies.GetBody(this.pChute.planets);
            #endregion

            #region Size cyclers
            //Size selection
            if (sizes.Count > 0)
            {
                GUILayout.BeginHorizontal(GUILayout.Height(20));
                GUILayout.BeginVertical();
                GUILayout.FlexibleSpace();
                GUILayout.Label("Cycle part size", this.skins.label);
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Previous size", this.skins.button, GUILayout.Width(125)))
                {
                    this.pChute.size--;
                    if (this.pChute.size < 0)
                    {
                        this.pChute.size = this.sizes.Count - 1;
                    }
                }
                if (GUILayout.Button("Next size", this.skins.button, GUILayout.Width(125)))
                {
                    this.pChute.size++;
                    if (this.pChute.size > this.sizes.Count - 1)
                    {
                        this.pChute.size = 0;
                    }
                }
                GUILayout.EndHorizontal();
            }
            #endregion

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();

            //Main chute texture selector
            GUILayout.Space(5);
            this.chutes[0].templateGUI.TextureSelector();

            #region General
            //Materials editor
            GUILayout.Space(5);
            chutes[0].templateGUI.MaterialsSelector();

            //MustGoDown
            GUIUtils.CreateTwinToggle("Must go down to deploy:", ref this.pChute.mustGoDown, this.window.width);

            //DeployOnGround
            GUIUtils.CreateTwinToggle("Deploy on ground contact:", ref this.pChute.deployOnGround, this.window.width);

            //Timer
            GUIUtils.CreateTimeEntryArea("Deployment timer:", ref this.pChute.timer, 0, 3600);

            //Spares
            GUIUtils.CreateEmptyEntryArea("Spare chutes:", ref this.pChute.spares, -1, 10);

            //CutSpeed
            GUIUtils.CreateEntryArea("Autocut speed (m/s):", ref this.pChute.cutSpeed, 0.01f, 100);

            //LandingAlt
            GUIUtils.CreateEntryArea("Landing alt (m):", ref this.pChute.landingAlt, 0, (float)this.pChute.body.GetMaxAtmosphereAltitude());
            #endregion

            #region Main
            //Indicator label
            GUILayout.Space(10);
            GUILayout.Label("________________________________________________", GUIUtils.boldLabel);
            GUILayout.Label("Main chute:", GUIUtils.boldLabel, GUILayout.Width(150));
            GUILayout.Label("‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾", GUIUtils.boldLabel);

            this.chutes[0].templateGUI.Calculations();
            #endregion

            #region Secondary
            if (this.pChute.secondaryChute)
            {
                for (int i = 1; i < this.chutes.Count; i++)
                {
                    ChuteTemplate chute = this.chutes[i];

                    //Indicator label
                    GUILayout.Space(10);
                    GUILayout.Label("________________________________________________", GUIUtils.boldLabel);
                    GUILayout.Label(RCUtils.ParachuteNumber(i) + ":", GUIUtils.boldLabel, GUILayout.Width(150));
                    GUILayout.Label("‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾", GUIUtils.boldLabel);

                    //Texture selector
                    GUILayout.Space(5);
                    chute.templateGUI.TextureSelector();

                    //Materials editor
                    GUILayout.Space(5);
                    chute.templateGUI.MaterialsSelector();

                    chute.templateGUI.Calculations();
                }
            }
            #endregion

            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
            //Scroll end

            #region Application
            GUILayout.Space(5);
            if (GUILayout.Button("Apply settings", this.skins.button))
            {
                this.pChute.Apply(false);
            }

            if (this.part.symmetryCounterparts.Count > 0)
            {
                if (GUILayout.Button("Apply to all symmetry counterparts", this.skins.button))
                {
                    this.pChute.Apply(true);
                }
            }
            #endregion

            GUILayout.EndVertical();
        }