Beispiel #1
0
        protected void onPartMouseDown(Part partClicked)
        {
            List <WBIExperimentManifest> manifests    = this.part.vessel.FindPartModulesImplementing <WBIExperimentManifest>();
            List <WBIExperimentLab>      labs         = this.part.vessel.FindPartModulesImplementing <WBIExperimentLab>();
            WBIExperimentLab             thisLab      = this.part.FindModuleImplementing <WBIExperimentLab>();
            WBIExperimentManifest        thisManifest = this.part.FindModuleImplementing <WBIExperimentManifest>();
            int index;
            int totalCount;
            WBIExperimentManifest manifest;
            WBIExperimentLab      lab;

            //Clear all the highlights
            totalCount = manifests.Count;
            for (index = 0; index < totalCount; index++)
            {
                manifest = manifests[index];

                //Highlighter off
                manifest.part.Highlight(false);

                //Remove mouse down handler
                if (manifest != thisManifest)
                {
                    manifest.part.RemoveOnMouseDown(onPartMouseDown);
                }

                //Transfer the experiment
                if (manifest.part == partClicked)
                {
                    manifest.TransferExperiment(experimentToTransfer);
                }
            }

            totalCount = labs.Count;
            for (index = 0; index < totalCount; index++)
            {
                lab = labs[index];

                //Highlighter off
                lab.part.Highlight(false);

                //Remove mouse down handler
                if (lab != thisLab)
                {
                    lab.part.RemoveOnMouseDown(onPartMouseDown);
                }

                //Transfer the experiment
                if (lab.part == partClicked)
                {
                    lab.TransferExperiment(experimentToTransfer);
                }
            }

            //Clear the xperiment to transfer
            experimentToTransfer = null;

            //Remove input lock
            InputLockManager.RemoveControlLock("ExperimentManifestLock");
        }
Beispiel #2
0
        public void EscapeKeyPressed()
        {
            //Check to see if user canceled the transfer
            if (experimentToTransfer != null)
            {
                List <WBIExperimentManifest> manifests    = this.part.vessel.FindPartModulesImplementing <WBIExperimentManifest>();
                List <WBIExperimentLab>      labs         = this.part.vessel.FindPartModulesImplementing <WBIExperimentLab>();
                WBIExperimentLab             thisLab      = this.part.FindModuleImplementing <WBIExperimentLab>();
                WBIExperimentManifest        thisManifest = this.part.FindModuleImplementing <WBIExperimentManifest>();
                int index;
                int totalCount;
                WBIExperimentManifest manifest;
                WBIExperimentLab      lab;

                //Clear all the highlights
                totalCount = manifests.Count;
                for (index = 0; index < totalCount; index++)
                {
                    manifest = manifests[index];

                    //Highlighter off
                    manifest.part.Highlight(false);

                    //Remove mouse down handler
                    if (manifest != thisManifest)
                    {
                        manifest.part.RemoveOnMouseDown(onPartMouseDown);
                    }
                }

                totalCount = labs.Count;
                for (index = 0; index < totalCount; index++)
                {
                    lab = labs[index];

                    //Highlighter off
                    lab.part.Highlight(false);

                    //Remove mouse down handler
                    if (lab != thisLab)
                    {
                        lab.part.RemoveOnMouseDown(onPartMouseDown);
                    }
                }

                //Clear the xperiment to transfer
                experimentToTransfer = null;

                //Remove input lock
                InputLockManager.RemoveControlLock("ExperimentManifestLock");
            }
        }
Beispiel #3
0
        protected void transferExperiment(WBIModuleScienceExperiment experimentSlot)
        {
            bool createNewExperiment = canCreateExperiments && experimentSlot.experimentID == experimentSlot.defaultExperiment && HighLogic.LoadedSceneIsFlight;

            //Inform user if we are trying to create a new experiment but we don't have the ability.
            if (createNewExperiment && !hasCreationAbility)
            {
                ScreenMessages.PostScreenMessage("You need a " + minimumCreationLevel + "-star " + experimentCreationSkill + " and a connection to KSC in order to create experiments.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //If we're in the editor or we are creating a new experiment then show the load experiment screen.
            else if (HighLogic.LoadedSceneIsEditor || (createNewExperiment && hasCreationAbility))
            {
                //If creating a new experiment then set the check resources flag and creation tags.
                loadExperimentView.creationTags = string.Empty;
                if (createNewExperiment && experimentLab != null)
                {
                    loadExperimentView.checkCreationResources  = experimentLab.checkCreationResources;
                    loadExperimentView.creationTags            = experimentLab.creationTags;
                    loadExperimentView.minimumCreationAmount   = experimentLab.minimumCreationAmount;
                    loadExperimentView.defaultCreationResource = experimentLab.defaultCreationResource;
                }

                loadExperimentView.defaultExperiment = experimentSlot.defaultExperiment;
                loadExperimentView.transferRecipient = experimentSlot;
                loadExperimentView.part                = this.part;
                loadExperimentView.windowPos           = this.windowPos;
                loadExperimentView.windowPos.position += new Vector2(40.0f, 40.0f);
                loadExperimentView.SetVisible(true);
            }

            //If we're in flight then highlight the available experiment containers.
            else if (HighLogic.LoadedSceneIsFlight)
            {
                //Make sure we have an experiment to transfer.
                if (experimentSlot.experimentID == experimentSlot.defaultExperiment)
                {
                    ScreenMessages.PostScreenMessage("No experiment to transfer, this slot is empty.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                    return;
                }

                List <WBIExperimentManifest> manifests    = this.part.vessel.FindPartModulesImplementing <WBIExperimentManifest>();
                List <WBIExperimentLab>      labs         = this.part.vessel.FindPartModulesImplementing <WBIExperimentLab>();
                WBIExperimentLab             thisLab      = this.part.FindModuleImplementing <WBIExperimentLab>();
                WBIExperimentManifest        thisManifest = this.part.FindModuleImplementing <WBIExperimentManifest>();
                Color sourceColor        = new Color(1, 1, 0);
                Color destinationColor   = new Color(0, 191, 243);
                bool  foundAvailableSlot = false;
                int   index;
                int   totalCount;
                WBIExperimentManifest manifest;
                WBIExperimentLab      lab;

                //Highlight the manifests
                totalCount = manifests.Count;
                for (index = 0; index < totalCount; index++)
                {
                    manifest = manifests[index];

                    //Part can accept the experiment if it is not full.
                    if (manifest != thisManifest && manifest.HasAvailableSlots())
                    {
                        foundAvailableSlot = true;
                        manifest.part.Highlight(destinationColor);
                        manifest.part.AddOnMouseDown(onPartMouseDown);
                    }

                    else
                    {
                        manifest.part.Highlight(sourceColor);
                    }
                }

                //Highlight labs
                totalCount = labs.Count;
                for (index = 0; index < totalCount; index++)
                {
                    lab = labs[index];

                    //Part can accept the experiment if it is not full.
                    if (lab != thisLab && lab.HasAvailableSlots())
                    {
                        foundAvailableSlot = true;
                        lab.part.Highlight(destinationColor);
                        lab.part.AddOnMouseDown(onPartMouseDown);
                    }

                    else
                    {
                        lab.part.Highlight(sourceColor);
                    }
                }

                //If we couldn't find an available slot then don't transfer the experiment.
                if (foundAvailableSlot)
                {
                    //Save the experiment to transfer
                    experimentToTransfer = experimentSlot;

                    //Tell user what to do
                    ScreenMessages.PostScreenMessage("Click a destination to receive the experiment. Press the ESCAPE key to cancel.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                    InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "ExperimentManifestLock");
                }

                else
                {
                    //Clear highlights
                    if (thisManifest != null)
                    {
                        thisManifest.part.Highlight(false);
                    }
                    if (thisLab != null)
                    {
                        thisLab.part.Highlight(false);
                    }
                    ScreenMessages.PostScreenMessage("You need more experiment space.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
            }
        }