getDefaultModel() public method

public getDefaultModel ( string preferredVariant ) : string
preferredVariant string
return string
コード例 #1
0
        protected virtual void setTankSetFromEditor(String newTankSet, bool updateSymmetry)
        {
            TankSet newSet = Array.Find(tankSets, m => m.name == newTankSet);

            currentTankSetModule = newSet;
            string variant     = lastSelectedVariant;
            string newTankName = newSet.getDefaultModel(lastSelectedVariant);

            this.updateUIChooseOptionControl("currentTankType", newSet.getModelNames(), newSet.getTankDescriptions(), true, newTankName);
            setMainTankModuleFromEditor(newTankName, false);
            Fields["currentTankType"].guiActiveEditor = newSet.Length > 1;
            //re-seat this if it was changed in the 'setMainTankModuleFromEditor' method
            //will allow for user-initiated main-tank changes to still change the 'last variant' but will
            //persist the variant if the newly selected set did not contain the selected variant
            //so that it will persist to the next set selection, OR be reseated on the next user-tank selection within the current set
            if (!currentTankSetModule.hasVariant(variant))
            {
                lastSelectedVariant = variant;
            }
            if (updateSymmetry)
            {
                foreach (Part p in part.symmetryCounterparts)
                {
                    p.GetComponent <SSTUModularFuelTank>().setTankSetFromEditor(newTankSet, false);
                }
            }
        }
コード例 #2
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            initialize();

            string[] groupNames = TankSet.getSetNames(tankSets);
            this.updateUIChooseOptionControl(nameof(currentTankSet), groupNames, groupNames, true, currentTankSet);

            string[] names = currentTankSetModule.getModelNames();
            string[] descs = currentTankSetModule.getTankDescriptions();
            this.updateUIChooseOptionControl(nameof(currentTankType), names, descs, true, currentTankType);

            if (maxTankDiameter == minTankDiameter)
            {
                Fields[nameof(currentTankDiameter)].guiActiveEditor = false;
            }
            else
            {
                this.updateUIFloatEditControl(nameof(currentTankDiameter), minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter);
            }
            updateAvailableVariants(false);
            updateUIScaleControls();

            Fields[nameof(currentTankDiameter)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    SSTUAttachNodeUtils.updateSurfaceAttachedChildren(m.part, m.prevTankDiameter, m.currentTankDiameter);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankVerticalScale)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankSet)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                this.actionWithSymmetry(m =>
                {
                    TankSet newSet         = Array.Find(m.tankSets, s => s.name == m.currentTankSet);
                    m.currentTankSetModule = newSet;
                    string variant         = m.lastSelectedVariant;
                    m.currentTankType      = newSet.getDefaultModel(m.lastSelectedVariant);
                    m.tankModule.updateSelections();
                    m.tankModule.modelSelected(m.currentTankType);
                    m.Fields[nameof(m.currentTankType)].guiActiveEditor = newSet.Length > 1;
                    //re-seat this if it was changed in the 'setMainTankModuleFromEditor' method
                    //will allow for user-initiated main-tank changes to still change the 'last variant' but will
                    //persist the variant if the newly selected set did not contain the selected variant
                    //so that it will persist to the next set selection, OR be reseated on the next user-tank selection within the current set
                    if (!m.currentTankSetModule.hasVariant(variant))
                    {
                        m.lastSelectedVariant = variant;
                    }
                    if (m.variantData != null)
                    {
                        m.updateAvailableVariants(true);
                    }
                    m.updateEditorStats(true);
                    m.updateUIScaleControls();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNoseType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                noseModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    m.updateAnimationControl(m.noseAnimationID, m.noseModule.model, 1);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentTankType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                tankModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    if (variantData != null)
                    {
                        m.updateAvailableVariants(true);
                    }
                    m.updateEditorStats(true);
                    m.lastSelectedVariant = tankModule.model.variantName;
                    m.updateAnimationControl(m.bodyAnimationID, m.tankModule.model, 3);
                    m.updateUIScaleControls();
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentMountType)].uiControlEditor.onFieldChanged = delegate(BaseField a, object b)
            {
                mountModule.modelSelected(a, b);
                this.actionWithSymmetry(m =>
                {
                    m.updateEditorStats(true);
                    m.updateAnimationControl(m.mountAnimationID, m.mountModule.model, 5);
                    SSTUModInterop.onPartGeometryUpdate(m.part, true);
                });
                SSTUStockInterop.fireEditorUpdate();
            };

            Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged  = noseModule.textureSetSelected;
            Fields[nameof(currentTankTexture)].uiControlEditor.onFieldChanged  = tankModule.textureSetSelected;
            Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected;

            Fields[nameof(currentTankSet)].guiActiveEditor   = tankSets.Length > 1;
            Fields[nameof(currentTankType)].guiActiveEditor  = currentTankSetModule.Length > 1;
            Fields[nameof(currentNoseType)].guiActiveEditor  = noseModule.models.Count > 1;
            Fields[nameof(currentMountType)].guiActiveEditor = mountModule.models.Count > 1;

            SSTUStockInterop.fireEditorUpdate();
            SSTUModInterop.onPartGeometryUpdate(part, true);
            if (HighLogic.LoadedSceneIsEditor)
            {
                GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified));
            }
        }