private void AeroStressTab(GUIStyle buttonStyle, GUIStyle boxStyle)
        {
            int i           = 0;
            int removeIndex = -1;

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical(boxStyle);

            for (i = 0; i < FARAeroStress.StressTemplates.Count; i++)
            {
                GUILayout.BeginHorizontal();
                bool active = GUILayout.Toggle(i == aeroStressIndex, FARAeroStress.StressTemplates[i].name, buttonStyle, GUILayout.Width(150));
                if (GUILayout.Button("-", buttonStyle, GUILayout.Width(30), GUILayout.Height(30)))
                {
                    removeIndex = i;
                }
                GUILayout.EndHorizontal();
                if (active)
                {
                    aeroStressIndex = i;
                }
            }
            if (removeIndex >= 0)
            {
                FARAeroStress.StressTemplates.RemoveAt(removeIndex);
                if (aeroStressIndex == removeIndex)
                {
                    aeroStressIndex--;
                }

                removeIndex = -1;
            }
            if (GUILayout.Button("+", buttonStyle, GUILayout.Width(30), GUILayout.Height(30)))
            {
                FARPartStressTemplate newTemplate = new FARPartStressTemplate();
                newTemplate.XZmaxStress             = 500;
                newTemplate.YmaxStress              = 500;
                newTemplate.name                    = "default";
                newTemplate.isSpecialTemplate       = false;
                newTemplate.minNumResources         = 0;
                newTemplate.resources               = new List <string>();
                newTemplate.excludeResources        = new List <string>();
                newTemplate.rejectUnlistedResources = false;
                newTemplate.crewed                  = false;
                newTemplate.flowModeNeeded          = false;
                newTemplate.flowMode                = ResourceFlowMode.NO_FLOW;

                FARAeroStress.StressTemplates.Add(newTemplate);
            }

            GUILayout.EndVertical();
            GUILayout.BeginVertical(boxStyle);

            FARPartStressTemplate activeTemplate = FARAeroStress.StressTemplates[aeroStressIndex];

            string tmp;

            FARGUIUtils.TextEntryField("Name:", 80, ref activeTemplate.name);

            activeTemplate.YmaxStress  = FARGUIUtils.TextEntryForDouble("Axial (Y-axis) Max Stress:", 240, activeTemplate.YmaxStress);
            activeTemplate.XZmaxStress = FARGUIUtils.TextEntryForDouble("Lateral (X,Z-axis) Max Stress:", 240, activeTemplate.XZmaxStress);

            activeTemplate.crewed = GUILayout.Toggle(activeTemplate.crewed, "Requires Crew Compartment");

            tmp = activeTemplate.minNumResources.ToString();
            FARGUIUtils.TextEntryField("Min Num Resources:", 80, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d]", "");
            activeTemplate.minNumResources = Convert.ToInt32(tmp);

            GUILayout.Label("Req Resources:");
            StringListUpdateGUI(activeTemplate.resources, buttonStyle, boxStyle);

            GUILayout.Label("Exclude Resources:");
            StringListUpdateGUI(activeTemplate.excludeResources, buttonStyle, boxStyle);

            activeTemplate.rejectUnlistedResources = GUILayout.Toggle(activeTemplate.rejectUnlistedResources, "Reject Unlisted Res");

            activeTemplate.flowModeNeeded = GUILayout.Toggle(activeTemplate.flowModeNeeded, "Requires Specific Flow Mode");
            if (activeTemplate.flowModeNeeded)
            {
                activeTemplate.flowMode = (ResourceFlowMode)GUILayout.SelectionGrid((int)activeTemplate.flowMode, FlowMode_str, 1);
            }

            activeTemplate.isSpecialTemplate = GUILayout.Toggle(activeTemplate.isSpecialTemplate, "Special Hardcoded Usage");

            FARAeroStress.StressTemplates[aeroStressIndex] = activeTemplate;


            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 2
0
        private void AeroDataTab(GUIStyle buttonStyle, GUIStyle boxStyle)
        {
            int i = 0;

            GUILayout.BeginVertical(boxStyle);

            string tmp;

            tmp = FARAeroUtil.areaFactor.ToString();
            FARGUIUtils.TextEntryField("Area Factor:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARAeroUtil.areaFactor = Convert.ToDouble(tmp);

            tmp = (FARAeroUtil.attachNodeRadiusFactor * 2).ToString();
            FARGUIUtils.TextEntryField("Node Diameter Factor:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARAeroUtil.attachNodeRadiusFactor = Convert.ToDouble(tmp) * 0.5;

            tmp = FARAeroUtil.incompressibleRearAttachDrag.ToString();
            FARGUIUtils.TextEntryField("Rear Node Drag, Incomp:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARAeroUtil.incompressibleRearAttachDrag = Convert.ToDouble(tmp);

            tmp = FARAeroUtil.sonicRearAdditionalAttachDrag.ToString();
            FARGUIUtils.TextEntryField("Rear Node Drag, M = 1:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARAeroUtil.sonicRearAdditionalAttachDrag = Convert.ToDouble(tmp);

            tmp = FARControllableSurface.timeConstant.ToString();
            FARGUIUtils.TextEntryField("Ctrl Surf Time Constant:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARControllableSurface.timeConstant = Convert.ToDouble(tmp);

            tmp = FARControllableSurface.timeConstantFlap.ToString();
            FARGUIUtils.TextEntryField("Flap/Spoiler Time Constant:", 160, ref tmp);
            tmp = Regex.Replace(tmp, @"[^\d+-\.]", "");
            FARControllableSurface.timeConstantFlap = Convert.ToDouble(tmp);

            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label("Celestial Body Atmosperic Properties");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(boxStyle);

            GUILayout.BeginHorizontal();
            int j = 0;

            for (i = 0; i < FlightGlobals.Bodies.Count; i++)
            {
                CelestialBody body = FlightGlobals.Bodies[i];

                if (!body.atmosphere)
                {
                    continue;
                }

                bool active = GUILayout.Toggle(i == atmBodyIndex, body.GetName(), buttonStyle, GUILayout.Width(150), GUILayout.Height(40));
                if (active)
                {
                    atmBodyIndex = i;
                }
                if ((j + 1) % 4 == 0)
                {
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                }
                j++;
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.BeginVertical(boxStyle);

            int flightGlobalsIndex = FlightGlobals.Bodies[atmBodyIndex].flightGlobalsIndex;

            Vector3d atmProperties = FARAeroUtil.bodyAtmosphereConfiguration[flightGlobalsIndex];

            tmp = atmProperties.y.ToString();
            FARGUIUtils.TextEntryField("Ratio of Specific Heats:", 80, ref tmp);
            tmp             = Regex.Replace(tmp, @"[^\d+-\.]", "");
            atmProperties.y = Convert.ToDouble(tmp);


            double dTmp = 8314.5 / atmProperties.z;

            tmp = dTmp.ToString();
            FARGUIUtils.TextEntryField("Gas Molecular Mass:", 80, ref tmp);
            tmp             = Regex.Replace(tmp, @"[^\d+-\.]", "");
            atmProperties.z = 8314.5 / Convert.ToDouble(tmp);

            atmProperties.x = atmProperties.y * atmProperties.z;

            FARAeroUtil.bodyAtmosphereConfiguration[flightGlobalsIndex] = atmProperties;

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }