Esempio n. 1
0
        protected override bool canAffordReconfigure(string templateName, bool deflatedModulesAutoPass = true)
        {
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;
            bool   canAfford    = base.canAffordReconfigure(templateName, deflatedModulesAutoPass);
            string requiredName = templateManager[templateName].GetValue("requiredResource");

            //If the vessel can't afford to reconfigure the module, then maybe the distribution manager can help.
            if (canAfford == false)
            {
                ScreenMessages.PostScreenMessage("Checking distributors...", 10.0f);
                if (string.IsNullOrEmpty(requiredName))
                {
                    return(true);
                }

                double distributedAmount = WBIDistributionManager.Instance.GetDistributedAmount(requiredName);
                if (distributedAmount >= reconfigureCost)
                {
                    ScreenMessages.PostScreenMessage("Distributors have enough " + requiredName, 10.0f);
                    return(true);
                }
            }

            //Add first time for redecoration
            if (!canAfford && scenario.HasShownToolTip(kSettingsWindow) == false)
            {
                scenario.SetToolTipShown(kSettingsWindow);

                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kSettingsWindow, kPartsTip);
                toolTipWindow.SetVisible(true);
            }

            return(canAfford);
        }
Esempio n. 2
0
        protected void checkAndShowToolTip()
        {
            //Now we can check to see if the tooltip for the current template has been shown.
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;

            if (scenario.HasShownToolTip(CurrentTemplateName) && scenario.HasShownToolTip(getMyPartName()))
            {
                return;
            }
            if (!CurrentTemplate.HasValue("toolTipTitle") && !CurrentTemplate.HasValue("toolTip"))
            {
                return;
            }

            //Tooltip for the current template has never been shown. Show it now.
            string toolTipTitle = CurrentTemplate.GetValue("toolTipTitle");
            string toolTip      = CurrentTemplate.GetValue("toolTip");

            if (string.IsNullOrEmpty(toolTipTitle))
            {
                toolTipTitle = partToolTipTitle;
            }

            //Add the very first part's tool tip.
            if (scenario.HasShownToolTip(getMyPartName()) == false)
            {
                toolTip = partToolTip + "\r\n\r\n" + toolTip;

                scenario.SetToolTipShown(getMyPartName());
            }

            if (string.IsNullOrEmpty(toolTip) == false)
            {
                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(toolTipTitle, toolTip);
                toolTipWindow.SetVisible(true);

                //Cleanup
                scenario.SetToolTipShown(CurrentTemplateName);
            }
        }
Esempio n. 3
0
        public override void OnStart(StartState state)
        {
            ModuleResourceHarvester harvester;

            base.OnStart(state);

            //Get the drills
            groundDrills = this.part.FindModulesImplementing <ModuleResourceHarvester>();

            //Setup the drills with the new resource to drill for.
            if (drillResources != null)
            {
                for (int index = 0; index < drillResources.Length; index++)
                {
                    harvester = groundDrills[index];
                    harvester.ResourceName    = drillResources[index];
                    harvester.StartActionName = "Start " + drillResources[index] + " Drill";
                    harvester.StopActionName  = "Stop " + drillResources[index] + " Drill";
                    harvester.Fields["ResourceStatus"].guiName = drillResources[index] + " rate";
                }
            }

            //Setup the window
            drillSwitchWindow = new DrillSwitchWindow();
            drillSwitchWindow.groundDrills     = groundDrills;
            drillSwitchWindow.part             = this.part;
            drillSwitchWindow.reconfigureCost  = reconfigureCost;
            drillSwitchWindow.requiredResource = requiredResource;
            drillSwitchWindow.requiredSkill    = requiredSkill;

            //Setup GUI
            Events["ShowDrillSwitchWindow"].guiActiveUnfocused = Utils.HasResearchedNode(PathfinderSettings.drillTechNode);

            //Tooltip
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;

            if (scenario.HasShownToolTip(this.ClassName))
            {
                return;
            }
            scenario.SetToolTipShown(this.ClassName);

            WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kToolTipTitle, kDrillSwitchTooltip);

            toolTipWindow.SetVisible(true);
        }
Esempio n. 4
0
        protected override void notEnoughParts()
        {
            base.notEnoughParts();

            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;

            //Add first time for redecoration
            if (scenario.HasShownToolTip(kSettingsWindow) == false)
            {
                scenario.SetToolTipShown(kSettingsWindow);

                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kSettingsWindow, kPartsTip);
                toolTipWindow.SetVisible(true);
            }
        }
Esempio n. 5
0
        protected override bool canAffordReconfigure(string templateName)
        {
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;
            bool canAfford = base.canAffordReconfigure(templateName);

            //Add first time for redecoration
            if (!canAfford && scenario.HasShownToolTip(kSettingsWindow) == false)
            {
                scenario.SetToolTipShown(kSettingsWindow);

                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kSettingsWindow, kPartsTip);
                toolTipWindow.SetVisible(true);
            }

            return(canAfford);
        }
Esempio n. 6
0
        protected void checkAndShowToolTip()
        {
            //Now we can check to see if the tooltip for the current template has been shown.
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;

            if (scenario.HasShownToolTip(this.part.partInfo.title))
            {
                return;
            }

            string           toolTip       = kToolTipSend;
            WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(this.part.partInfo.title, toolTip);

            toolTipWindow.SetVisible(true);

            //Cleanup
            scenario.SetToolTipShown(this.part.partInfo.title);
        }
Esempio n. 7
0
        protected override bool canAffordReconfigure(string templateName, bool deflatedModulesAutoPass = true)
        {
            showInsufficientResourcesMsg = false;
            bool canAfford = base.canAffordReconfigure(templateName, deflatedModulesAutoPass);

            //If the vessel can't afford to reconfigure the module, then maybe the distribution manager can help.
            if (canAfford == false)
            {
                canAfford = true;

                string[] keys = inputList.Keys.ToArray();
                string   resourceName;
                double   distributedAmount;
                for (int index = 0; index < keys.Length; index++)
                {
                    resourceName      = keys[index];
                    distributedAmount = WBIDistributionManager.Instance.GetDistributedAmount(resourceName);
                    Log("Distributors have " + distributedAmount + " units of " + resourceName);

                    if (distributedAmount < inputList[resourceName])
                    {
                        string notEnoughPartsMsg = string.Format(kInsufficientParts, inputList[resourceName], resourceName);
                        ScreenMessages.PostScreenMessage(notEnoughPartsMsg, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                        ScreenMessages.PostScreenMessage("No active distributors have " + resourceName + " to share. Make sure resource distribution is turned on, and a distributor is sharing " + resourceName + ".", 10.0f);
                        canAfford = false;
                        break;
                    }
                }
            }

            //Add first time for redecoration
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;

            if (!canAfford && scenario.HasShownToolTip(kSettingsWindow) == false)
            {
                scenario.SetToolTipShown(kSettingsWindow);

                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kSettingsWindow, kPartsTip);
                toolTipWindow.SetVisible(true);
            }

            return(canAfford);
        }
Esempio n. 8
0
        protected void checkAndShowToolTip()
        {
            //Check tooltips
            WBIPathfinderScenario scenario = WBIPathfinderScenario.Instance;
            string experimentName          = getExperimentName(currentExperiment);
            string experimentTip;

            //Add first time for redecoration
            if (scenario.HasShownToolTip(experimentName) == false)
            {
                scenario.SetToolTipShown(experimentName);

                switch (currentExperiment)
                {
                default:
                case GeologyLabExperiments.SoilAnalysis:
                    experimentTip = kTTSoilAnalysis;
                    break;

                case GeologyLabExperiments.MetallurgyAnalysis:
                    experimentTip = kTTMetalAnalysis;
                    break;

                case GeologyLabExperiments.ChemicalAnalysis:
                    experimentTip = kTTChemAnalysis;
                    break;

                case GeologyLabExperiments.BiomeAnalysis:
                    experimentTip = kTTBiomeAnalysis;
                    break;
                }

                WBIToolTipWindow toolTipWindow = new WBIToolTipWindow(kTTTitle + experimentName, experimentTip);
                toolTipWindow.SetVisible(true);
            }
        }