Esempio n. 1
0
        //Displays
        private void DisplayVehicles()
        {
            if (selectedRootPart == null)
            {
                GUILayout.Space(10);

                if (EditorLogic.RootPart == null)
                {
                    // If building is empty, allow select vehicle to edit
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Edit existing Launch Vehicle", klvGUIStyles.HeaderLabel);
                    GUILayout.EndHorizontal();
                    GUILayout.Label(String.IsNullOrEmpty(failedSubassembly) ? "" : "Could not find " + failedSubassembly, klvGUIStyles.WarningLabel);
                    LayoutGUIList(editVehicleList, 340, 350);
                }
                else
                {
                    // If building occupied only allow add new vehicle
                    // If we allow dropping parts, display here
                    dropZone.DoLayout(klvGUIStyles.HighlightBox, GlobalSettings.AllowVehicleDrop && EditorLogic.SelectedPart != null ?
                                      "DROP PART AS LAUNCH VEHICLE" : "ADD VESSEL AS LAUNCH VEHICLE");
                    GUILayout.Space(5);

                    isRootPartDecoupler = (GlobalSettings.AllowVehicleDrop && EditorLogic.SelectedPart != null ?
                                           EditorLogic.SelectedPart : EditorLogic.RootPart).partInfo == null;

                    //Coupling not available in ksp1.1 so we won't warn on this
#if !VERSION1_1
                    isRootPartDecoupler = isRootPartDecoupler || (GlobalSettings.AllowVehicleDrop && EditorLogic.SelectedPart != null ?
                                                                  EditorLogic.SelectedPart : EditorLogic.RootPart).partInfo.category == PartCategories.Coupling;
#else
                    isRootPartDecoupler = true;
#endif

                    GUILayout.Label(isRootPartDecoupler ? "" : "It is recommended to use a decoupler as the root part to detach the payload", klvGUIStyles.WarningLabel);
                    GUILayout.Space(10);

                    GUILayout.Label("To edit an existing vehicle, clear the building", klvGUIStyles.HeaderLabel);
                }
            }
            else
            {
                GUILayout.Label(editingVehicle == null ? "Add New Launch Vehicle" : "Edit Launch Vehicle", klvGUIStyles.HeaderLabel);
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                outputVehicleName = textVehicleName.DoLayout();
                comboFamily.DoLayout(editingVehicle == null ? null : klvGUIStyles.DisabledButton, editingVehicle == null ? true : false);
                GUILayout.EndHorizontal();

                outputVehicleNote = textVehicleNote.DoLayout();

                GUILayout.Label("Vehicle dry mass: " + vehicleDryMass.ToString("0.###") + "t", klvGUIStyles.StandardLabel);
                GUILayout.Label("Vehicle wet mass: " + vehicleWetMass.ToString("0.###") + "t", klvGUIStyles.StandardLabel);


                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
                buttonCancelVehicleEdit.DoLayout(klvGUIStyles.StandardButton);

                if (!string.IsNullOrEmpty(outputVehicleName.ToString()))
                {
                    if (string.IsNullOrEmpty(comboFamily.selectedItemName))
                    {
                        buttonSaveVehicle.DoLayout(klvGUIStyles.WarningButton, "Family missing!", null);
                    }
                    else if (!KLVCore.VehicleAvailable(comboFamily.selectedItemName, outputVehicleName.ToString(), editingVehicle))
                    {
                        buttonSaveVehicle.DoLayout(klvGUIStyles.WarningButton, "Vehicle exists!", null);
                    }
                    else if (isAddingConfig && !launchConfigsGood)
                    {
                        buttonSaveVehicle.DoLayout(klvGUIStyles.WarningButton, configErrorReason, null);
                    }
                    else
                    {
                        buttonSaveVehicle.DoLayout(klvGUIStyles.CorrectButton, "Save Vehicle", outputVehicleName.ToString());
                    }

                    if (maxNewConfigs > newConfigs.Count())
                    {
                        buttonAddLaunchConfig.DoLayout(klvGUIStyles.StandardButton, "Add Launch Config", true);
                    }
                    else
                    {
                        buttonAddLaunchConfig.DoLayout(klvGUIStyles.WarningButton, "Max new Configs", null);
                    }
                }
                GUILayout.EndHorizontal();

                launchConfigsGood = true;
                configErrorReason = "";
                for (int i = 0; i < newConfigs.Count(); i++)
                {
                    launchConfigsGood = LayoutLaunchConfigEdit(i) && launchConfigsGood;
                }
            }
        }