private void onVariantApplied(Part variantPart, PartVariant variant)
        {
            if (variantPart != part)
            {
                return;
            }
            if (string.IsNullOrEmpty(resourceName))
            {
                return;
            }
            if (!part.Resources.Contains(resourceName))
            {
                return;
            }
            string amountString = variant.GetExtraInfoValue(resourceName);

            if (string.IsNullOrEmpty(amountString))
            {
                return;
            }

            double amount = 0;

            if (double.TryParse(amountString, out amount))
            {
                part.Resources[resourceName].maxAmount = amount;
                if (!updateMaxOnly)
                {
                    part.Resources[resourceName].amount = amount;
                }
                MonoUtilities.RefreshContextWindows(part);
                GameEvents.onPartResourceListChange.Fire(part);
            }
        }
Exemple #2
0
        private bool CheckRetractConditions()
        {
            var canRetract = true;

            if (inflatable)
            {
                if (part.protoModuleCrew.Count > 0)
                {
                    var msg = string.Format("Unable to deflate {0} as it still contains crew members.",
                                            part.partInfo.title);
                    ScreenMessages.PostScreenMessage(msg, 5f, ScreenMessageStyle.UPPER_CENTER);
                    canRetract = false;
                }
                if (canRetract)
                {
                    part.CrewCapacity = 0;
                    if (inflatedMultiplier > 0)
                    {
                        CompressResourceCapacity();
                    }
                    var modList = GetAffectedMods();
                    var count   = modList.Count;
                    for (int i = 0; i < count; ++i)
                    {
                        modList[i].DisableModule();
                    }
                    MonoUtilities.RefreshContextWindows(part);
                }
            }
            return(canRetract);
        }
        /// <summary>
        /// Sets up the thrust transforms.
        /// </summary>
        public void SetupThrustTransform()
        {
            if (engine == null)
            {
                return;
            }
            if (!canReverseThrust)
            {
                return;
            }
            Debug.Log("[WBIPropSpinner] - SetupThrustTransform called. reverseThrust: " + reverseThrust);

            //We have separate forward and reverse thrust transforms. Switch them out.
            engine.thrustTransforms.Clear();
            if (reverseThrust)
            {
                Events["ToggleThrustTransform"].guiName = Localizer.Format(forwardThrustActionName);
                for (int i = 0; i < revThrustTransform.Length; i++)
                {
                    engine.thrustTransforms.Add(revThrustTransform[i]);
                }
                engine.thrustVectorTransformName = reverseThrustTransform;
            }

            else
            {
                Events["ToggleThrustTransform"].guiName = Localizer.Format(reverseThrustActionName);
                for (int i = 0; i < fwdThrustTransform.Length; i++)
                {
                    engine.thrustTransforms.Add(fwdThrustTransform[i]);
                }
                engine.thrustVectorTransformName = thrustTransform;
            }
            MonoUtilities.RefreshContextWindows(this.part);
        }
Exemple #4
0
 private void ToggleArm(bool state)
 {
     armed = state;
     Events["Disarm"].active = state;
     Events["Arm"].active    = !state;
     if (!state)
     {
         var animationstate1 = armmodule.GetState();
         if (animationstate1.normalizedTime == 1f)
         {
             armmodule.Toggle();
         }
         dockingmodule.isEnabled = false;
     }
     if (state)
     {
         var animationstate1 = armmodule.GetState();
         if (animationstate1.normalizedTime == 0f)
         {
             armmodule.Toggle();
         }
         dockingmodule.isEnabled = true;
     }
     MonoUtilities.RefreshContextWindows(part);
 }
        protected override void RefreshPAW()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                base.RefreshPAW();
            }
            else
            {
                Actions[nameof(DeployAction)].active  = false;
                Actions[nameof(RetractAction)].active = false;
                Actions[nameof(ToggleAction)].active  = false;

                Events[nameof(DeployEvent)].guiActive        = false;
                Events[nameof(DeployEvent)].guiActiveEditor  = false;
                Events[nameof(RetractEvent)].guiActive       = false;
                Events[nameof(RetractEvent)].guiActiveEditor = false;

                if (PartialDeployPercentage >= 1d)
                {
                    Actions[nameof(PayAction)].active  = false;
                    Events[nameof(PayEvent)].guiActive = false;
                    Fields[nameof(PartialDeployPercentage)].guiActive = false;
                }

                MonoUtilities.RefreshContextWindows(part);
            }
        }
Exemple #6
0
        public void applyVariant(Part part, string meshSet)
        {
            Debug.Log("[SWVariant] -  Applying variant: " + name);
            if (!string.IsNullOrEmpty(meshSet))
            {
                Debug.Log("[SWVariant] -  For mesh set: " + meshSet);
            }

            // Mesh sets are applied before any other fields in the variant.
            if (!string.IsNullOrEmpty(meshSet) && meshSets != null && meshSets.ContainsKey(meshSet))
            {
                meshSets[meshSet].applyVariant(part, meshSet);
            }

            if (textureVariant != null)
            {
                textureVariant.applyVariant(part);
            }

            // Now apply any game object variants
            if (meshVariant != null)
            {
                meshVariant.applyVariant(part);
            }

            // Now apply any colliders.
            if (colliderVariant != null)
            {
                colliderVariant.applyVariant(part, false);
            }

            applyAnimationVariant(part);

            MonoUtilities.RefreshContextWindows(part);
        }
 private void ToggleTransfer(bool state)
 {
     transferEnabled = state;
     Events["DisableTransfer"].active = state;
     Events["EnableTransfer"].active  = !state;
     MonoUtilities.RefreshContextWindows(part);
 }
 private void EnableMenus(bool enable)
 {
     Events["NextSetup"].active = enable;
     Events["PrevSetup"].active = enable;
     Events["LoadSetup"].active = enable;
     MonoUtilities.RefreshContextWindows(part);
 }
Exemple #9
0
        protected virtual void RefreshPAW()
        {
            if (_resourceCosts != null &&
                _resourceCosts.Count > 0 &&
                PartialDeployPercentage < 1d)
            {
                Actions[nameof(DeployAction)].active  = false;
                Actions[nameof(RetractAction)].active = false;
                Actions[nameof(ToggleAction)].active  = false;

                Events[nameof(DeployEvent)].guiActive  = false;
                Events[nameof(RetractEvent)].guiActive = false;
            }
            else
            {
                Actions[nameof(PayAction)].active     = false;
                Actions[nameof(DeployAction)].active  = !StartDeployed;
                Actions[nameof(RetractAction)].active = StartDeployed;

                Events[nameof(PayEvent)].guiActive     = false;
                Events[nameof(DeployEvent)].guiActive  = !StartDeployed;
                Events[nameof(RetractEvent)].guiActive = StartDeployed;

                Fields[nameof(PartialDeployPercentage)].guiActive = false;
            }

            MonoUtilities.RefreshContextWindows(part);
        }
        private void onEditorVariantApplied(Part part, PartVariant variant)
        {
            // This should never be called in flight, but somehow it was, so just
            // have a check to be safe
            if (HighLogic.LoadedSceneIsFlight)
            {
                return;
            }
            if (part != base.part || part == null)
            {
                return;
            }

            if (variant == null || variant.DisplayName == null)
            {
                return;
            }
            ModSegSRBs.GetExtraInfo(variant, ref this.part.segmentHeight, ref this.part.segmentWidth);

            RecalculateFuelAndMass();
            var f = GetMaxThrust();

            if (baseEngine != null)
            {
                baseEngine.ScheduleSegmentUpdate("MSSRB_Fuel_Segment.onEditorVariantApplied", 5);
            }
#if true
            MonoUtilities.RefreshContextWindows(part);
#else
            MonoUtilities.RefreshPartContextWindow(part);
#endif
        }
 private void ToggleTarget(bool state)
 {
     targetOnly = state;
     Events["EnableTargeting"].guiActive  = !state;
     Events["DisableTargeting"].guiActive = state;
     MonoUtilities.RefreshContextWindows(part);
 }
 private void ToggleMagnet(bool state)
 {
     magnetIsEnabled = state;
     Events["EnableMagnet"].guiActive  = !state;
     Events["DisableMagnet"].guiActive = state;
     MonoUtilities.RefreshContextWindows(part);
 }
Exemple #13
0
        private void SetupLoadouts()
        {
            //Get our Module List
            Loadouts = new List <LoadoutInfo>();
            int id           = 0;
            var loadoutNames = new List <string>();
            var mods         = part.FindModulesImplementing <BaseConverter>();
            var count        = mods.Count;

            for (int i = 0; i < count; ++i)
            {
                var con     = mods[i];
                var loadout = new LoadoutInfo();
                loadout.LoadoutName = con.ConverterName;
                loadout.ModuleId    = id;
                loadoutNames.Add(con.ConverterName);
                Loadouts.Add(loadout);
                if (!con.IsActivated)
                {
                    con.DisableModule();
                }
                id++;
            }
            MonoUtilities.RefreshContextWindows(part);
        }
Exemple #14
0
        public void SetActive(bool isActive)
        {
            this.isActive = isActive;

            Events[nameof(ToggleDampenEvent)].guiName
                = $"Ground tether: {(isActive ? "On" : "Off")}";
            MonoUtilities.RefreshContextWindows(part);
        }
 private void SetDeployedState(int speed)
 {
     isDeployed = true;
     Events["DeployModule"].active  = false;
     Events["RetractModule"].active = true;
     PlayDeployAnimation(speed);
     EnableModules();
     MonoUtilities.RefreshContextWindows(part);
 }
Exemple #16
0
 protected void ExpandCrewCapacity()
 {
     if (CrewCapacity > 0)
     {
         part.CrewCapacity = CrewCapacity;
         part.CheckTransferDialog();
         MonoUtilities.RefreshContextWindows(part);
     }
 }
Exemple #17
0
 private void ApplyHarvesterChanges(ModuleResourceHarvester_USI harvester, ModuleSwapOption loadout)
 {
     harvester.Efficiency      = loadout.Efficiency;
     harvester.ResourceName    = loadout.ResourceName;
     harvester.ConverterName   = loadout.ConverterName;
     harvester.StartActionName = loadout.StartActionName;
     harvester.StopActionName  = loadout.StopActionName;
     MonoUtilities.RefreshContextWindows(part);
 }
 private void Setup()
 {
     Events["DeployModule"].guiName         = "Deploy " + moduleType;
     Events["RetractModule"].guiName        = "Retract " + moduleType;
     Actions["DeployModuleAction"].guiName  = "Deploy " + moduleType;
     Actions["RetractModuleAction"].guiName = "Retract " + moduleType;
     Actions["ToggleModuleAction"].guiName  = "Toggle " + moduleType;
     MonoUtilities.RefreshContextWindows(part);
 }
        protected void setManageOpsButtonVisible()
        {
            Events["ReconfigureStorage"].guiActive          = fieldReconfigurable || ShowGUI;
            Events["ReconfigureStorage"].guiActiveUnfocused = fieldReconfigurable || ShowGUI;
            Events["ReconfigureStorage"].guiActiveEditor    = fieldReconfigurable || ShowGUI;

            //Dirty the GUI
            MonoUtilities.RefreshContextWindows(this.part);
        }
Exemple #20
0
        public virtual void ApplyConverterChanges(T converter)
        {
            converter.ConverterName      = ConverterName;
            converter.StartActionName    = StartActionName;
            converter.StopActionName     = StopActionName;
            converter.UseSpecialistBonus = UseSpecialistBonus;
            converter.ExperienceEffect   = ExperienceEffect;

            MonoUtilities.RefreshContextWindows(part);
        }
Exemple #21
0
 private void EnableMenus(bool enable)
 {
     Events["NextSetup"].guiActiveEditor   = enable;
     Events["PrevSetup"].guiActiveEditor   = enable;
     Events["LoadSetup"].guiActiveEditor   = enable;
     Events["NextSetup"].externalToEVAOnly = !enable;
     Events["PrevSetup"].externalToEVAOnly = !enable;
     Events["LoadSetup"].externalToEVAOnly = !enable;
     MonoUtilities.RefreshContextWindows(part);
 }
        private void ClampControllableMass()
        {
            var maxControllableMass = GetMaximumControllableMass();

            if (controllableMass > maxControllableMass * FloatTolerance)
            {
                Log($"Resetting procedural mass limit to {maxControllableMass}, was {controllableMass}");
                controllableMass = maxControllableMass;
                MonoUtilities.RefreshContextWindows(part);
            }
        }
        public void ChangeMenu()
        {
            Events["NextSetup"].guiName   = (bayName + " Next " + _controller.typeName).Trim();
            Events["PrevSetup"].guiName   = (bayName + " Prev. " + _controller.typeName).Trim();
            Fields["curTemplate"].guiName = (bayName + " Active " + _controller.typeName).Trim();
            curTemplate = _controller.Loadouts[currentLoadout].ConverterName;
            Events["LoadSetup"].guiName =
                (bayName + " " + curTemplate + "=>" + _controller.Loadouts[displayLoadout].ConverterName).Trim();

            MonoUtilities.RefreshContextWindows(part);
        }
Exemple #24
0
 public override void OnStart(StartState state)
 {
     //_broker = new ResourceBroker();
     _bays = part.FindModulesImplementing <ModuleSwappableConverter>();
     if (autoActivate || HighLogic.LoadedSceneIsEditor)
     {
         SetModuleState(null, true);
     }
     GameEvents.OnAnimationGroupStateChanged.Add(SetModuleState);
     MonoUtilities.RefreshContextWindows(part);
 }
Exemple #25
0
        public void SetCurrentDiameter(float f)
        {
            float oldDiameter = module.currentDiameter;

            module.currentDiameter = f;
            BaseField fld = module.Fields[nameof(module.currentDiameter)];

            fld.uiControlEditor.onFieldChanged.Invoke(fld, oldDiameter);

            MonoUtilities.RefreshContextWindows(module.part);
            ROLLog.log("ModuleROTank - Diameter set to: " + f);
        }
        public void AddData(float amount)
        {
            if (!accumulateData)
            {
                return;
            }

            prospectingDataAmount += amount;

            //Dirty the GUI
            MonoUtilities.RefreshContextWindows(this.part);
        }
Exemple #27
0
 protected void UpdateDropMenu()
 {
     if (dropEnabled)
     {
         Events["DropToggleEvent"].guiName = "Disable Auto-Drop";
     }
     else
     {
         Events["DropToggleEvent"].guiName = "Enable Auto-Drop";
     }
     MonoUtilities.RefreshContextWindows(part);
 }
        private void DrawAvionicsConfigSelector(ProceduralAvionicsConfig curCfg, ProceduralAvionicsTechNode techNode)
        {
            bool switchedConfig = false;
            int  unlockCost     = ProceduralAvionicsTechManager.GetUnlockCost(curCfg.name, techNode);

            _gc ??= new GUIContent();
            _gc.tooltip = GetTooltipTextForTechNode(techNode);

            bool isCurrent = techNode == CurrentProceduralAvionicsTechNode;

            if (isCurrent)
            {
                _gc.text = BuildTechName(techNode);
                GUILayout.BeginHorizontal();
                GUILayout.Toggle(true, _gc, HighLogic.Skin.button);
                DrawUnlockButton(curCfg.name, techNode, unlockCost);
                GUILayout.EndHorizontal();

                _gc.text    = $"Sample container: {BoolToYesNoString(techNode.hasScienceContainer)}";
                _gc.tooltip = "Whether samples can be transferred and stored in the avionics unit.";
                GUILayout.Label(_gc, HighLogic.Skin.label);

                _gc.text    = $"Can hibernate: {BoolToYesNoString(techNode.disabledPowerFactor > 0)}";
                _gc.tooltip = "Whether the avionics unit can enter hibernation mode that greatly reduces power consumption.";
                GUILayout.Label(_gc, HighLogic.Skin.label);

                _gc.text    = $"Axial control: {BoolToYesNoString(techNode.allowAxial)}";
                _gc.tooltip = "Whether fore-aft translation is allowed despite having insufficient controllable mass or being outside the max range of Near-Earth avionics.";
                GUILayout.Label(_gc, HighLogic.Skin.label);
            }
            else
            {
                _gc.text = $"Switch to {BuildTechName(techNode)}";
                GUILayout.BeginHorizontal();
                switchedConfig  = GUILayout.Button(_gc, HighLogic.Skin.button);
                switchedConfig |= DrawUnlockButton(curCfg.name, techNode, unlockCost);
                GUILayout.EndHorizontal();
            }

            if (switchedConfig)
            {
                Log("Configuration window changed, updating part window");
                _shouldResetUIHeight   = true;
                _showROTankSizeWarning = false;
                _showSizeWarning       = false;
                SetupConfigNameFields();
                avionicsTechLevel = techNode.name;
                CurrentProceduralAvionicsConfig = curCfg;
                avionicsConfigName = curCfg.name;
                AvionicsConfigChanged();
                MonoUtilities.RefreshContextWindows(part);
            }
        }
Exemple #29
0
        private void SetMenu()
        {
            if (FreezerEngaged)
            {
                Events["CryoFreeze"].guiName = "Unfreeze Kerbals";
            }
            else
            {
                Events["CryoFreeze"].guiName = "Freeze Kerbals";
            }

            MonoUtilities.RefreshContextWindows(part);
        }
Exemple #30
0
        private void ConfigureMenus()
        {
            bool evaRequired = USI_ConverterOptions.ConverterSwapRequiresEVAEnabled;

            Events["NextSetup"].externalToEVAOnly = evaRequired;
            Events["NextSetup"].guiActive         = !evaRequired;
            Events["PrevSetup"].externalToEVAOnly = evaRequired;
            Events["PrevSetup"].guiActive         = !evaRequired;
            Events["LoadSetup"].externalToEVAOnly = evaRequired;
            Events["LoadSetup"].guiActive         = !evaRequired;

            MonoUtilities.RefreshContextWindows(part);
        }