コード例 #1
0
        private void InitializeTankType()
        {
            // Have to DIY to get the part options deserialized
            if (tankTypeOptionsSerialized != null)
            {
                ObjectSerializer.Deserialize(tankTypeOptionsSerialized, out tankTypeOptions);
            }

            Fields["tankVolume"].guiActiveEditor  = tankVolumeName != null;
            Fields["massDisplay"].guiActiveEditor = tankVolumeName != null;

            if (tankTypeOptions == null || tankTypeOptions.Count == 0)
            {
                Debug.LogError("*TCS* No part type options available");
                return;
            }

            BaseField       field   = Fields["tankType"];
            UI_ChooseOption options = (UI_ChooseOption)field.uiControlEditor;

            options.options = tankTypeOptions.ConvertAll(opt => opt.name).ToArray();

            field.guiActiveEditor = (tankTypeOptions.Count > 1);

            if (string.IsNullOrEmpty(tankType))
            {
                tankType = tankTypeOptions[0].name;
            }
        }
コード例 #2
0
        public override void OnStart(StartState state)
        {
            if (!AreConfigsRead)
            {
                ReadCustomConfigs();
                PopulateFuelNames();
                AreConfigsRead = true;
            }

            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                UI_Control c = this.Fields["fuelSelectorIndex"].uiControlEditor;

                c.onFieldChanged = updateFuelSetup;
                UI_ChooseOption o = (UI_ChooseOption)c;
                o.options = FuelNames;
                this.updateFuelSetup(this.fuelSelectorIndex);
            }
            this.updateUIOutput(this.fuelPep, this.efficiency);
            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                this.updateFuelSetup(this.fuelSelectorIndex);
                this.part.force_activate();
            }
        }
コード例 #3
0
        private void InitializeTankType()
        {
            // Have to DIY to get the part options deserialized
            if (tankTypeOptionsSerialized != null)
            {
                ObjectSerializer.Deserialize(tankTypeOptionsSerialized, out tankTypeOptions);
            }

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                tankTypeOptions = tankTypeOptions.Where(to => string.IsNullOrEmpty(to.techRequired) || ResearchAndDevelopment.GetTechnologyState(to.techRequired) == RDTech.State.Available).ToList();
            }

            Fields["volumeDisplay"].guiActiveEditor = tankVolumeName != null;
            Fields["massDisplay"].guiActiveEditor   = tankVolumeName != null;

            if (tankTypeOptions == null || tankTypeOptions.Count == 0)
            {
                Debug.LogError("*TCS* No part type options available");
                return;
            }

            BaseField       field   = Fields["tankType"];
            UI_ChooseOption options = (UI_ChooseOption)field.uiControlEditor;

            options.options = tankTypeOptions.ConvertAll(opt => opt.name).ToArray();

            field.guiActiveEditor = (tankTypeOptions.Count > 1);

            if (string.IsNullOrEmpty(tankType))
            {
                tankType = tankTypeOptions[0].name;
            }
        }
コード例 #4
0
        private void updateList()
        {
            //Create temporary string list to collect resources
            List <string> resourceList = new List <string>();
            //Instantiate monitoredResource options so we can access its option array
            UI_ChooseOption resourceOptions = (UI_ChooseOption)Fields["monitoredResource"].uiControlEditor;

            if (observedPart != null)
            {
                if (observedPart.Resources.Count > 0)
                {
                    //Iterate through resources and add them to the resourceList
                    foreach (PartResource resource in observedPart.Resources)
                    {
                        resourceList.Add(resource.resourceName);
                    }
                    //Convert resource list to array and assign it to the monitoredResource options
                    resourceOptions.options = resourceList.ToArray <String>();
                    //If we already have selected a resource, don't reassign it to the default
                    monitoredResource = (resourceList.Contains(monitoredResource) ? monitoredResource : resourceList[0]);
                }
                else
                {
                    //If there are no resources in the monitored part, set monitoredResource to "Empty"
                    resourceOptions.options = new string[] { "Empty" };
                    monitoredResource       = "Empty";
                }
            }
        }
コード例 #5
0
        //Gets textures from Textures folder and loads them into surfaceTextures list + set Field options
        void getTextureNames()
        {
            if (ShroudTexture.shroudTextures == null)
            {
                ShroudTexture.LoadTextures();
            }

            if (textureIndex >= ShroudTexture.shroudTextures.Count)
            {
                textureIndex = 0;
            }

            string[] options = new string[ShroudTexture.shroudTextures.Count];
            for (int i = 0; i < options.Length; i++)
            {
                options[i] = ShroudTexture.shroudTextures[i].name;

                //Sets textureindex to the saved texture
                if (options[i].Equals(textureName))
                {
                    textureIndex = i;
                }
            }

            BaseField       textureField   = Fields[nameof(textureIndex)];
            UI_ChooseOption textureOptions = (UI_ChooseOption)textureField.uiControlEditor;

            textureOptions.options = options;
        }
コード例 #6
0
        private void SetupWidgets(ScaleType scaleType)
        {
            ScaleFactors = scaleType.ScaleFactors;
            this.SetupWidgetsVisibility();
            if (ScaleFactors.Length <= 0)
            {
                return;
            }

            if (isFreeScale)
            {
                BaseField    field = Fields["tweakScale"];
                UI_ScaleEdit range = (UI_ScaleEdit)field.uiControlEditor;
                range.intervals      = scaleType.ScaleFactors;
                range.incrementSlide = scaleType.IncrementSlide;
                range.unit           = scaleType.Suffix;
                range.sigFigs        = 3;
                field.guiUnits       = scaleType.Suffix;
            }
            else
            {
                UI_ChooseOption options = (UI_ChooseOption)Fields["tweakName"].uiControlEditor;
                options.options = scaleType.ScaleNames;
            }
        }
コード例 #7
0
        void SetupUI()
        {
            BaseField       chooseField  = Fields["currentLoopID"];
            UI_ChooseOption chooseOption = HighLogic.LoadedSceneIsFlight ? chooseField.uiControlFlight as UI_ChooseOption : chooseField.uiControlEditor as UI_ChooseOption;

            chooseOption.options        = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            chooseOption.onFieldChanged = ChangeLoop;
        }
コード例 #8
0
        public override void OnStart(StartState state)
        {
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (mass <= 0)
                {
                    mass = 0.000001f;
                }
                part.mass = mass;
                MassChanged(mass);
                //Debug.Log("OnStart - mass: " + part.mass);

                //double skinThermalMassModifier = part.thermalMassModifier;
                //double skinThicknessFactor = 0.1;
                //Debug.Log(skinThermalMassModifier);
                //Debug.LogWarning((double)part.mass * PhysicsGlobals.StandardSpecificHeatCapacity * skinThermalMassModifier * skinThicknessFactor);
            }

            InitializeObjects();
            CopyNodeSizeAndStrength();
            //if (HighLogic.LoadedSceneIsFlight)
            //{
            //    PartResource resource = part.Resources["AblativeShielding"];
            //    UpdateDissipationAndLoss(resource.maxAmount);
            //}

            if (PPart != null)
            {
                //PPart.AddNodeOffset(topNodeId, GetNodeOffset);
                loadedTextureSets     = PPart.TextureSets.ToList();
                loadedTextureSetNames = loadedTextureSets.Select <ProceduralPart.TextureSet, string>(x => x.name).ToArray();

                BaseField       field = Fields["textureSet"];
                UI_ChooseOption range = (UI_ChooseOption)field.uiControlEditor;

                range.options = loadedTextureSetNames;
                if (textureSet == null || !loadedTextureSetNames.Contains(textureSet))
                {
                    textureSet = loadedTextureSetNames[0];
                }

                UpdateTexture();
                UpdateFairing();
            }
            else
            {
                Debug.LogError("Procedural Part not found");
            }

            UI_FloatEdit fairingThicknessEdit = (UI_FloatEdit)Fields["fairingThickness"].uiControlEditor;

            fairingThicknessEdit.maxValue       = this.fairingMaxThickness;
            fairingThicknessEdit.minValue       = this.fairingMinThickness;
            fairingThicknessEdit.incrementLarge = 0.1f;
            fairingThicknessEdit.incrementSmall = 0.01f;
            fairingThickness = Mathf.Clamp(fairingThickness, fairingMinThickness, fairingMaxThickness);
        }
コード例 #9
0
        /// <summary>
        /// Find the light transforms and lights to dim with the animation
        /// </summary>
        /// <param name="state">The startstate of the partmodule</param>
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            modelBaseField         = Fields["numModel"];
            modelUIChooser         = (UI_ChooseOption)modelBaseField.uiControlEditor;
            modelBaseField.guiName = switchName;

            //find all the lights
            transformsData = new List <TransformData>();

            //Search in the named transforms for the lights
            if (transforms != string.Empty)
            {
                string[] transformNames = transforms.Split(',');

                //find all the transforms
                List <Transform> transformsList = new List <Transform>();

                for (int i = 0; i < transformNames.Length; i++)
                {
                    TransformData transSetting = new TransformData();
                    //get all the transforms
                    transSetting.transforms.AddRange(part.FindModelTransforms(transformNames[i].Trim()));

                    transformsData.Add(transSetting);
                }

                string[] visible = visibleNames.Split(',');
                for (int i = 0; i < visible.Length; i++)
                {
                    visible[i] = visible[i].Trim();
                }

                if (visible.Length == transformNames.Length)
                {
                    modelUIChooser.options = visible;
                }
                else
                {
                    //set the changes for the modelchooser
                    modelUIChooser.options = transformNames;
                }

                //when there is only one model, we do not need to show the controls
                if (transformNames.Length < 2)
                {
                    modelBaseField.guiActive       = false;
                    modelBaseField.guiActiveEditor = false;
                }
            }
            else
            {
                Debug.LogError("ModuleKerbetrotterMultiLight: No light transform defined!)");
            }
        }
コード例 #10
0
        private void InitializeShapes()
        {
            List <string> shapeNames = new List <string>();

            availableShapes.Clear();
            foreach (ProceduralAbstractShape compShape in GetComponents <ProceduralAbstractShape>())
            {
                if (!string.IsNullOrEmpty(compShape.techRequired) && ResearchAndDevelopment.GetTechnologyState(compShape.techRequired) != RDTech.State.Available)
                {
                    goto disableShape;
                }
                if (!string.IsNullOrEmpty(compShape.techObsolete) && ResearchAndDevelopment.GetTechnologyState(compShape.techObsolete) == RDTech.State.Available)
                {
                    goto disableShape;
                }

                availableShapes.Add(compShape.displayName, compShape);
                shapeNames.Add(compShape.displayName);

                if (string.IsNullOrEmpty(shapeName) ? (availableShapes.Count == 1) : compShape.displayName == shapeName)
                {
                    shape           = compShape;
                    oldShapeName    = shapeName = shape.displayName;
                    shape.isEnabled = shape.enabled = true;
                    continue;
                }

disableShape:
                compShape.isEnabled = compShape.enabled = false;
            }

            BaseField field = Fields["shapeName"];

            switch (availableShapes.Count)
            {
            case 0:
                throw new InvalidProgramException("No shapes available");

            case 1:
                field.guiActiveEditor = false;
                break;

            default:
                field.guiActiveEditor = true;
                UI_ChooseOption range = (UI_ChooseOption)field.uiControlEditor;
                range.options = shapeNames.ToArray();
                break;
            }

            if (string.IsNullOrEmpty(shapeName) || !availableShapes.ContainsKey(shapeName))
            {
                oldShapeName    = shapeName = shapeNames[0];
                shape           = availableShapes[shapeName];
                shape.isEnabled = shape.enabled = true;
            }
        }
コード例 #11
0
        public override void OnStart(StartState state)
        {
            isInitialized = true;
            InitializeObjects();
            InitializeShapes();

            if (HighLogic.LoadedSceneIsEditor)
            {
                Debug.Log($"{ModTag} TechLimits: {part.name} diameter=({diameterMin:G3}, {diameterMax:G3}) length=({lengthMin:G3}, {lengthMax:G3}) volume=({volumeMin:G3}, {volumeMax:G3})");
                legacyTextureHandler.ValidateSelectedTexture();
                texturePickerGUI = new TUTexturePickerGUI(this);
                Fields[nameof(showTUPickerGUI)].guiActiveEditor = installedTU && !forceLegacyTextures;
            }

            if (shape is ProceduralAbstractShape)
            {
                shape.UpdateShape();
            }
            if (part.variants is ModulePartVariants)
            {
                part.variants.useMultipleDragCubes = false;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                if (!TUEnabled)
                {
                    forceLegacyTextures = true;
                }
                SetTextureFieldVisibility();

                Fields[nameof(forceLegacyTextures)].uiControlEditor.onFieldChanged = OnForceLegacyTextureChanged;

                BaseField       field = Fields[nameof(textureSet)];
                UI_ChooseOption opt   = field.uiControlEditor as UI_ChooseOption;
                opt.options = LegacyTextureHandler.textureSets.Keys.ToArray();
                opt.onSymmetryFieldChanged = opt.onFieldChanged = OnTextureChanged;

                BaseField capTextureField = Fields[nameof(capTextureIndex)];
                opt         = capTextureField.uiControlEditor as UI_ChooseOption;
                opt.options = Enum.GetNames(typeof(LegacyTextureHandler.CapTextureMode));
                opt.onSymmetryFieldChanged = opt.onFieldChanged = OnTextureChanged;

                Fields[nameof(shapeName)].guiActiveEditor = availableShapes.Count > 1;
                opt         = Fields[nameof(shapeName)].uiControlEditor as UI_ChooseOption;
                opt.options = availableShapes.Keys.ToArray();
                // The onSymmetryFieldChanged callbacks do not have the correct previous object assigned.
                // Since this matters, we need to handle it ourselves.
                opt.onFieldChanged = OnShapeSelectionChanged;

                Fields[nameof(costDisplay)].guiActiveEditor = displayCost;

                GameEvents.onVariantApplied.Add(OnVariantApplied);
                GameEvents.onGameSceneSwitchRequested.Add(OnEditorExit);
            }
        }
コード例 #12
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            BaseField field = Fields[nameof(selectedBody)];
            UI_ChooseOption choose = (UI_ChooseOption)field.uiControlEditor;
            choose.options = PlanetWalk();

            UIElements();
        }
コード例 #13
0
        public override void OnStart(StartState state)
        {
            Log.post(this.ClassName + " start-callback: " + state.ToString());

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                part.force_activate();

                Log.post("Searching for drainable resources");
                List <string> drainResourceNames = new List <string>();
                foreach (AirshipDrainResource dr in GetComponents <AirshipDrainResource>())
                {
                    if (dr.Resource != null)
                    {
                        drainResources.Add(dr);
                        drainResourceNames.Add(dr.displayName);
                        Log.post("Found drainable resource: " + dr.displayName, LogLevel.LOG_INFORMATION);
                    }
                    else
                    {
                        Log.post("Found drainable resource: " + dr.displayName + " but resource is not available on part", LogLevel.LOG_INFORMATION);
                    }
                }
                Log.post("Finished searching for drainable resources");

                Log.post("adding drainable resources to tweakable choose field");
                BaseField field = Fields["drainResource"];
                if (field != null)
                {
                    UI_ChooseOption options = (UI_ChooseOption)field.uiControlFlight;

                    if (options != null)
                    {
                        if (drainResourceNames.Count > 0)
                        {
                            options.options = drainResourceNames.ToArray();
                            drainResource   = drainResourceNames[0];
                        }
                        else
                        {
                            Log.post("No drainable resources. tweakable disabled.", LogLevel.LOG_INFORMATION);
                            options.controlEnabled = false;
                        }
                    }
                    else
                    {
                        Log.post("Field 'drainResource' does not have a UI_ChooseOption attribute", LogLevel.LOG_ERROR);
                    }
                }
                else
                {
                    Log.post("Field 'drainResource' does not exist", LogLevel.LOG_ERROR);
                }
            }
        }
コード例 #14
0
        public override void OnStart(StartState state)
        {
            InitializeSelectedShape();
            base.OnStart(state);

            Fields[nameof(selectedShape)].guiActiveEditor = PPart.allowCurveTweaking;
            UI_ChooseOption opt = Fields[nameof(selectedShape)].uiControlEditor as UI_ChooseOption;

            opt.options = shapePresets.Keys.ToArray();
            opt.onSymmetryFieldChanged = opt.onFieldChanged = new Callback <BaseField, object>(OnShapeSelectionChanged);
        }
コード例 #15
0
ファイル: Scale.cs プロジェクト: zer0Kerbal/TweakScale
        /// <summary>
        /// Loads settings from <paramref name="scaleType"/>.
        /// </summary>
        /// <param name="scaleType">The settings to use.</param>
        private void SetupFromConfig(ScaleType scaleType)
        {
            if (ScaleType == null)
            {
                Log.error("Scaletype==null! part={0}", part.name);
            }

            isFreeScale = scaleType.IsFreeScale;
            if (defaultScale == -1)
            {
                defaultScale = scaleType.DefaultScale;
            }

            if (currentScale == -1)
            {
                currentScale = defaultScale;
            }
            else if (defaultScale != scaleType.DefaultScale)
            {
                Log.warn("defaultScale has changed for part {0}: keeping relative scale.", part.name);
                currentScale *= scaleType.DefaultScale / defaultScale;
                defaultScale  = scaleType.DefaultScale;
            }

            if (tweakScale == -1)
            {
                tweakScale = currentScale;
            }
            Fields["tweakScale"].guiActiveEditor = false;
            Fields["tweakName"].guiActiveEditor  = false;
            ScaleFactors = scaleType.ScaleFactors;
            if (ScaleFactors.Length <= 0)
            {
                return;
            }

            if (isFreeScale)
            {
                Fields["tweakScale"].guiActiveEditor = true;
                UI_ScaleEdit range = (UI_ScaleEdit)Fields["tweakScale"].uiControlEditor;
                range.intervals               = scaleType.ScaleFactors;
                range.incrementSlide          = scaleType.IncrementSlide;
                range.unit                    = scaleType.Suffix;
                range.sigFigs                 = 3;
                Fields["tweakScale"].guiUnits = scaleType.Suffix;
            }
            else
            {
                Fields["tweakName"].guiActiveEditor = scaleType.ScaleFactors.Length > 1;
                UI_ChooseOption options = (UI_ChooseOption)Fields["tweakName"].uiControlEditor;
                ScaleNodes      = scaleType.ScaleNodes;
                options.options = scaleType.ScaleNames;
            }
        }
コード例 #16
0
        private void InitializeTextureSet()
        {
            BaseField       field = Fields["textureSet"];
            UI_ChooseOption range = (UI_ChooseOption)field.uiControlEditor;

            range.options = loadedTextureSetNames;
            if (textureSet == null || !loadedTextureSetNames.Contains(textureSet))
            {
                textureSet = loadedTextureSetNames[0];
            }
        }
コード例 #17
0
 public override void OnStart(StartState state)
 {
     InitializeSelectedShape();
     base.OnStart(state);
     if (HighLogic.LoadedSceneIsEditor)
     {
         Fields[nameof(selectedShape)].guiActiveEditor = PPart.allowCurveTweaking;
         UI_ChooseOption opt = Fields[nameof(selectedShape)].uiControlEditor as UI_ChooseOption;
         opt.options = shapePresets.Keys.ToArray();
         opt.onSymmetryFieldChanged = opt.onFieldChanged = OnShapeSelectionChanged;
     }
 }
コード例 #18
0
 static void setup_roles(UI_ChooseOption chooser)
 {
     if (chooser == null)
     {
         return;
     }
     chooser.options = new string[NumRoles];
     for (int i = 0; i < NumRoles; i++)
     {
         chooser.options[i] = RoleNames[i];
     }
 }
コード例 #19
0
 private static void setup_groups(UI_ChooseOption chooser)
 {
     if (chooser == null)
     {
         return;
     }
     chooser.options    = new string[Globals.Instance.MaxManualGroups];
     chooser.options[0] = "OFF";
     for (var i = 1; i < Globals.Instance.MaxManualGroups; i++)
     {
         chooser.options[i] = $"G{i:D}";
     }
 }
コード例 #20
0
 static void setup_groups(UI_ChooseOption chooser)
 {
     if (chooser == null)
     {
         return;
     }
     chooser.options    = new string[Globals.Instance.MaxManualGroups];
     chooser.options[0] = "OFF";
     for (int i = 1; i < Globals.Instance.MaxManualGroups; i++)
     {
         chooser.options[i] = string.Format("G{0:D}", i);
     }
 }
コード例 #21
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged);
            GameEvents.onVesselSituationChange.Add(OnVesselSituationChange);

            BaseField       field  = Fields[nameof(selectedBody)];
            UI_ChooseOption choose = (UI_ChooseOption)field.uiControlEditor;

            choose.options = PlanetWalk();

            UIElements();
        }
コード例 #22
0
        //the part that is enabled and disabled
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            modelBaseField = Fields["numModel"];
            modelUIChooser = (UI_ChooseOption)modelBaseField.uiControlEditor;


            string[] transformGroupNames        = transformNames.Split(',');
            string[] transformGroupVisibleNames = transformVisibleNames.Split(',');
            models       = new List <ModelTransforms>();
            visibleNames = new List <string>();

            //----------------------------------------------------------
            //create the list of transforms to be made switchable
            //----------------------------------------------------------
            for (int k = 0; k < transformGroupNames.Length; k++)
            {
                name = transformGroupNames[k].Trim();

                List <Transform> transforms = new List <Transform>();
                transforms.AddRange(part.FindModelTransforms(name));

                ModelTransforms mt = new ModelTransforms();
                mt.transforms = new List <Transform>();
                mt.transforms.AddRange(transforms);

                models.Add(mt);
                if (transformGroupVisibleNames.Length == transformGroupNames.Length)
                {
                    visibleNames.Add(transformGroupVisibleNames[k]);
                }
                else
                {
                    visibleNames.Add(transformGroupNames[k]);
                }
            }

            //set the changes for the modelchooser
            modelUIChooser.options = visibleNames.ToArray();

            //when there is only one model, we do not need to show the controls
            if (models.Count < 2)
            {
                modelBaseField.guiActive       = false;
                modelBaseField.guiActiveEditor = false;
            }

            updateActiveModel();
        }
コード例 #23
0
        public override void OnStart(StartState state)
        {
            if (!HighLogic.LoadedSceneIsEditor)
                return;

            if (!PPart.allowCurveTweaking)
                Fields["selectedShape"].guiActiveEditor = false;
            else
            {
                UI_ChooseOption selectedShapeEdit = (UI_ChooseOption)Fields["selectedShape"].uiControlEditor;
                selectedShapeEdit.options = (from p in shapePresets select p.name).ToArray();
            }
            base.OnStart(state);
        }
コード例 #24
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            _scale     = this.Fields["tweakScale"];
            _name      = this.Fields["tweakName"];
            _type      = this.Fields["scaleTypeId"];
            _scaleEdit = (UI_FloatEdit)_scale.uiControlEditor;
            _nameEdit  = (UI_ChooseOption)_name.uiControlEditor;
            _typeEdit  = (UI_ChooseOption)_type.uiControlEditor;

            _typeEdit.options = ScaleConfig.AllConfigs.Select(a => a.name).ToArray();

            scaleInfo = ScaleDatabase.Lookup(part.partInfo.name);
        }
コード例 #25
0
ファイル: SmartTankPart.cs プロジェクト: Fitiales/SmartTank
 private void initializeBodies()
 {
     if (FlightGlobals.Bodies != null)
     {
         BaseField       field = Fields["BodyForTWR"];
         UI_ChooseOption range = (UI_ChooseOption)field.uiControlEditor;
         if (range != null)
         {
             getPlanetList();
             range.onFieldChanged = bodyChanged;
             range.options        = planetList;
         }
     }
 }
コード例 #26
0
        private void InitializeTankType()
        {
            if (typesAvailable == null || typesAvailable.Length <= 1)
            {
                Fields["type"].guiActiveEditor = false;
            }
            else
            {
                UI_ChooseOption typeOptions = (UI_ChooseOption)Fields["type"].uiControlEditor;
                typeOptions.options = typesAvailable;
            }

            UpdateTankType();
        }
コード例 #27
0
        /// <summary>
        /// The method called by KSP when the PartModule is started. Called on each part, every time.
        /// </summary>
        /// <param name="state">The StartState indicating the starting condition of the part (and the vessel it's on)</param>
        public override void OnStart(StartState state)
        {
            if (!(part.FindModelAnimators("glowAnim").FirstOrDefault() == null))
            {
                partAnim = part.FindModelAnimators("glowAnim").FirstOrDefault();
                if (!(partAnim["glowAnim"] == null))
                {
                    glowAnim = partAnim["glowAnim"];
                    if (!(glowAnim.clip == null))
                    {
                        glowAnimClip = glowAnim.clip;
                    }
                }
            }
            UI_ChooseOption tsOptions = (UI_ChooseOption)this.Fields["timeScale"].uiControlEditor;

            tsOptions.options = timeScaleOptions;

            updateSecondsOptions();

            seconds = (time + 1) * timeScales[timeScale];

            checkColorValues();
            checkTimeValues();
            updateCurves();

            if (pulsing)
            {
                partAnim.wrapMode = WrapMode.PingPong;
            }
            else
            {
                partAnim.wrapMode = WrapMode.Once;
            }

            if (glowing)
            {
                Events["toggleGlow"].guiName = "Stop Glowing";
                glowAnim.normalizedTime      = 1.0f;
                partAnim.Play("glowAnim");
            }
            else
            {
                Events["toggleGlow"].guiName = "Start Glowing";
                glowAnim.normalizedTime      = 0.0f;
                partAnim.Play("glowAnim");
                partAnim.Stop("glowAnim");
            }
        }
コード例 #28
0
        private void UpdateConfigSliders()
        {
            BaseField avionicsConfigField = Fields["avionicsConfigName"];

            avionicsConfigField.guiActiveEditor = true;
            UI_ChooseOption range = (UI_ChooseOption)avionicsConfigField.uiControlEditor;

            range.options = proceduralAvionicsConfigs.Keys.ToArray();

            if (String.IsNullOrEmpty(avionicsConfigName))
            {
                avionicsConfigName = proceduralAvionicsConfigs.Keys.First();
                Log("Defaulted config to ", avionicsConfigName);
            }
        }
コード例 #29
0
        private void initializeGUI_2()
        {
            BaseField chooseField;

            string[] Options;
            string[] OptionsDisplay;

            chooseField                 = Fields[nameof(ChooseOption)];
            chooseField.guiName         = "Propulsion";
            chooseField.guiActiveEditor = availableInEditor;
            chooseField.guiActive       = availableInFlight;

            //Extract options from the propellantlist
            Options        = new string[propList.Count];
            OptionsDisplay = new string[propList.Count];
            for (int i = 0; (i < propList.Count); i++)
            {
                Options[i]        = propList[i].Propellants;
                OptionsDisplay[i] = iniGUIpropellantNamesEmpty ? propList[i].Propellants : propList[i].GUIpropellantNames;
            }
            //If there is only one engine available, then hide the selector menu --> It yields null ref errors if used in flight!!!
            Debug.Log("engineList.Count: " + propList.Count);
            if (propList.Count < 2)
            {
                chooseField.guiActive       = false;
                chooseField.guiActiveEditor = false;
            }

            //Configurate the ChooseOption menu
            UI_ChooseOption chooseOption = HighLogic.LoadedSceneIsFlight ? chooseField.uiControlFlight as UI_ChooseOption : chooseField.uiControlEditor as UI_ChooseOption;

            chooseOption.options        = Options;
            chooseOption.display        = OptionsDisplay;
            chooseOption.onFieldChanged = selectPropulsion;

            //Update Actions GUI texts and hide the ones not applicable
            for (int i = 1; i <= numberOfSpecificActions; i++)
            {
                if (propList.Count < i)
                {
                    this.Actions["ActionPropulsion_" + i].active = false;
                }
                if (!(propList.Count < i))
                {
                    this.Actions["ActionPropulsion_" + i].guiName = iniGUIpropellantNamesEmpty ? "Set " + propList[i - 1].Propellants : "Set " + propList[i - 1].GUIpropellantNames;
                }
            }
        }
コード例 #30
0
        private void UpdateConfigSliders()
        {
            Log("Updating Config Slider");
            BaseField avionicsConfigField = Fields["avionicsConfigName"];

            avionicsConfigField.guiActiveEditor = true;
            UI_ChooseOption range = (UI_ChooseOption)avionicsConfigField.uiControlEditor;

            range.options = ProceduralAvionicsTechManager.GetPurchasedConfigs().ToArray();

            if (String.IsNullOrEmpty(avionicsConfigName))
            {
                avionicsConfigName = range.options[0];
                Log("Defaulted config to ", avionicsConfigName);
            }
        }
コード例 #31
0
 static void setup_groups(UI_ChooseOption chooser)
 {
     if(chooser == null) return;
     chooser.options = new string[Globals.Instance.MaxManualGroups];
     chooser.options[0] = "OFF";
     for(int i = 1; i<Globals.Instance.MaxManualGroups; i++)
         chooser.options[i] = string.Format("G{0:D}", i);
 }
コード例 #32
0
 static void setup_roles(UI_ChooseOption chooser)
 {
     if(chooser == null) return;
     chooser.options = new string[NumRoles];
     for(int i = 0; i<NumRoles; i++) chooser.options[i] = RoleNames[i];
 }