예제 #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");
        }
예제 #2
0
        protected override void setupPartModules()
        {
            base.setupPartModules();

            //Get the experiment lab
            experimentLab = this.part.FindModuleImplementing <WBIExperimentLab>();
            if (experimentLab == null)
            {
                return;
            }
            experimentLab.unavailableMessage = kUnavailableMessage;

            //Setup the science container
            if (scienceContainer == null)
            {
                scienceContainer = this.part.FindModuleImplementing <ModuleScienceContainer>();
                scienceContainer.Events["ReviewDataEvent"].guiActiveUnfocused = false;
                scienceContainer.Events["ReviewDataEvent"].guiActive          = false;

                //Terrain uplink
                terrainUplinkView.part             = this.part;
                terrainUplinkView.scienceContainer = scienceContainer;
            }

            //Kerbnet access
            kerbNetAccess = this.part.FindModuleImplementing <ModuleKerbNetAccess>();
            if (kerbNetAccess != null)
            {
            }
        }
예제 #3
0
        public override void OnStart(StartState state)
        {
            terrainUplinkView = new TerainUplinkView();
            base.OnStart(state);
            this.geoLabView.drawView = this.drawView;

            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            //Get the experiment lab
            experimentLab = this.part.FindModuleImplementing <WBIExperimentLab>();
            if (experimentLab == null)
            {
                return;
            }
            experimentLab.unavailableMessage = kUnavailableMessage;

            //Hide the experiment lab if the
            if (Utils.IsBiomeUnlocked(this.part.vessel) == false)
            {
                experimentLab.isAvailable = false;
            }
        }
예제 #4
0
        public void SetupView(Part parentPart, bool showExperimentStatus, bool showLabGUI, WBIExperimentLab lab = null)
        {
            setupIcons();

            experimentStatusVisible = showExperimentStatus;
            labGUIVisible           = showLabGUI;
            part          = parentPart;
            experimentLab = lab;
            WindowTitle   = this.part.partInfo.title + ": Experiment Manifest";
        }
예제 #5
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");
            }
        }
예제 #6
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);
                }
            }
        }