public static bool OverPartWindow(Part part, Vector2d mouse)
        {
            bool symmetry             = false;
            UIPartActionWindow window = UIPartActionController.Instance.GetItem(part, symmetry);

            return(window.Hover);
        }
        /// <summary>
        /// Refresh the resources of the tank
        /// </summary>
        /// <param name="manual">indicator whether this function is called manually</param>
        /// <param name="newResourceID">the id of the new resource</param>
        private void refreshResources(int newResourceID)
        {
            //switch reh resource in this part
            switchResources(part, newResourceID);

            //when we are in the editor, the symmetry parts need to be updated too!
            if (HighLogic.LoadedSceneIsEditor)
            {
                for (int s = 0; s < part.symmetryCounterparts.Count; s++)
                {
                    //switch the resource of the counterpart
                    switchResources(part.symmetryCounterparts[s], newResourceID);

                    ModuleKerbetrotterResourceSwitch symmetricSwitch = part.symmetryCounterparts[s].GetComponent <ModuleKerbetrotterResourceSwitch>();
                    if (symmetricSwitch != null)
                    {
                        symmetricSwitch.selectedResourceID = selectedResourceID;
                    }
                }
            }

            //update the texts in the gui
            updateGUIText(part);

            //Find and refresh the ui
            if (tweakableUI == null)
            {
                tweakableUI = part.FindActionWindow();
            }
            if (tweakableUI != null)
            {
                tweakableUI.displayDirty = true;
            }
        }
Beispiel #3
0
        private void RebuildResources(bool keepAmount = false)
        {
            List <PartResource> partResources = new List <PartResource>();

            // Purge the old resources
            foreach (PartResource res in part.Resources)
            {
                if (selectedTankType.resources.Any(tr => tr.name == res.resourceName))
                {
                    //always keep the resources because we need the flowState value
                    partResources.Add(res);
                    if (!keepAmount)
                    {
                        res.amount = -1;
                    }
                }
            }

            part.Resources.dict.Clear();

            // Build them afresh. This way we don't need to do all the messing around with reflection
            // The downside is the UIPartActionWindow gets maked dirty and rebuit, so you can't use
            // the sliders that affect part contents properly cos they get recreated underneith you and the drag dies.
            foreach (TankResource res in selectedTankType.resources)
            {
                //double maxAmount = Math.Round(res.unitsConst + tankVolume * res.unitsPerKL + part.mass * res.unitsPerT, 2);
                double maxAmount = CalculateMaxResourceAmount(res);

                ConfigNode node = new ConfigNode("RESOURCE");
                node.AddValue("name", res.name);
                node.AddValue("maxAmount", maxAmount);

                PartResource partResource = partResources.FirstOrDefault(r => r.resourceName == res.name);
                if (partResource != null)
                {
                    node.AddValue("flowState", partResource.flowState);
                }

                if (!res.forceEmpty && null != partResource && partResource.amount != -1)
                {
                    node.AddValue("amount", Math.Min(partResource.amount, maxAmount));
                }
                else
                {
                    node.AddValue("amount", res.forceEmpty ? 0 : maxAmount);
                }

                node.AddValue("isTweakable", res.isTweakable);
                part.AddResource(node);
            }

            UIPartActionWindow window = part.FindActionWindow();

            if (window != null)
            {
                window.displayDirty = true;
            }

            ResourceListChanged(part);
        }
Beispiel #4
0
 public static void updatePartResourceDisplay(Part part)
 {
     if (HighLogic.LoadedSceneIsEditor && EditorLogic.fetch == null)
     {
         return;
     }
     if (HighLogic.LoadedSceneIsFlight && FlightDriver.fetch == null)
     {
         return;
     }
     try
     {
         if (UIPartActionController.Instance != null)
         {
             UIPartActionWindow window = UIPartActionController.Instance.GetItem(part);
             if (window != null)
             {
                 window.displayDirty = true;
             }
         }
     }
     catch (Exception e)
     {
         MonoBehaviour.print("ERROR: Caught exception while updating part resource display: " + e.Message);
     }
 }
Beispiel #5
0
 // ReSharper disable ParameterHidesMember
 public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field)
 {
     base.Setup(window, part, partModule, scene, control, field);
     incDown.SetValueChangedDelegate(obj => IncrementValue(false));
     incUp.SetValueChangedDelegate(obj => IncrementValue(true));
     slider.SetValueChangedDelegate(OnValueChanged);
 }
        private void OnPartActionUICreate(Part part)
        {
            // Get the PAW window
            UIPartActionWindow paw = UIPartActionController.Instance.GetItem(part);

            // Prevent the button to be added once created
            if (paw.ListItems.Exists(p => p is UIPartActionButton && ((UIPartActionButton)p).Evt.name == "ConfigurePart"))
            {
                return;
            }

            BaseEventDelegate del = new BaseEventDelegate(delegate { OnPawConfigure(part); });

            string buttonTitle;

            if (part.Modules.Contains <ModuleB9PartSwitch>() || part.Modules.Contains <ModulePartVariants>())
            {
                buttonTitle = "Part info and configuration";
            }
            else
            {
                buttonTitle = "Part info";
            }

            BaseEvent baseEvent = new BaseEvent(null, "ConfigurePart", del, new KSPEvent());

            baseEvent.guiName         = buttonTitle;
            baseEvent.active          = true;
            baseEvent.guiActive       = true;
            baseEvent.guiActiveEditor = true;
            paw.AddEventControl(baseEvent, part, null);
        }
        private void assignResourcesToPart(bool calledByPlayer)
        {
            // destroying a resource messes up the gui in editor, but not in flight.
            setupTankInPart(part, calledByPlayer);
            if (HighLogic.LoadedSceneIsEditor)
            {
                for (int s = 0; s < part.symmetryCounterparts.Count; s++)
                {
                    setupTankInPart(part.symmetryCounterparts[s], calledByPlayer);
                    WSXFSfuelSwitch symSwitch = part.symmetryCounterparts[s].GetComponent <WSXFSfuelSwitch>();
                    if (symSwitch != null)
                    {
                        symSwitch.selectedTankSetup = selectedTankSetup;
                    }
                }
            }

            //Debug.Log("refreshing UI");

            if (tweakableUI == null)
            {
                tweakableUI = WSXFSFindActionWindow(part);
            }
            if (tweakableUI != null)
            {
                tweakableUI.displayDirty = true;
            }
            else
            {
                Debug.Log("no UI to refresh");
            }
        }
 public override void OnAwake()
 {
     base.OnAwake();
     this.window = part.PartActionWindow;
     //PartMessageService.Register(this);
     //this.RegisterOnUpdateEditor(OnUpdateEditor);
 }
Beispiel #9
0
        private void RebuildResources()
        {
            // Purge the old resources
            foreach (PartResource res in part.Resources)
            {
                Destroy(res);
            }
            part.Resources.list.Clear();

            // Build them afresh. This way we don't need to do all the messing around with reflection
            // The downside is the UIPartActionWindow gets maked dirty and rebuit, so you can't use
            // the sliders that affect part contents properly cos they get recreated underneith you and the drag dies.
            foreach (TankResource res in selectedTankType.resources)
            {
                double maxAmount = Math.Round(res.unitsConst + tankVolume * res.unitsPerKL + part.mass * res.unitsPerT, 2);

                ConfigNode node = new ConfigNode("RESOURCE");
                node.AddValue("name", res.name);
                node.AddValue("maxAmount", maxAmount);
                node.AddValue("amount", res.forceEmpty ? 0 : maxAmount);
                node.AddValue("isTweakable", res.isTweakable);
                part.AddResource(node);
            }

            UIPartActionWindow window = part.FindActionWindow();

            if (window != null)
            {
                window.displayDirty = true;
            }

            ResourceListChanged();
        }
Beispiel #10
0
 void onPartActionUIDismiss(Part actionPart)
 {
     if (actionPart != hostPart)
     {
         return;
     }
     actionWindow = null;
 }
Beispiel #11
0
 public static void SetPartActionWindowPin(this UIPartActionWindow paw, bool value)
 {
     if (paw == null)
     {
         return;
     }
     paw.togglePinned.isOn = value;
 }
        // ReSharper disable ParameterHidesMember
        public override void Setup(UIPartActionWindow window, Part part, UI_Scene scene, UI_Control control, PartResource resource)
        {
            double amount = resource.amount;
            base.Setup(window, part, scene, control, resource);
            this.resource.amount = amount;

            slider.SetValueChangedDelegate(OnSliderChanged);
        }
        /// <summary>
        /// Here when any PAW is shown, either in the editor or in flight.
        /// </summary>
        /// <param name="paw"></param>
        /// <param name="part"></param>
        internal static void OnPartActionUIShown(UIPartActionWindow paw, Part part)
        {
            ModuleRoboticSlave slave = TryGetSlaveModule(part);

            if (slave != null)
            {
                slave.ConfigureGui();
            }
        }
 private void OnPartActionUIShown(UIPartActionWindow window, Part p)
 {
     if (p == part && windowDirty)
     {
         windowDirty         = false; // Un-flag state
         window.displayDirty = true;  // Signal refresh
         //MonoUtilities.RefreshPartContextWindow(part);
     }
 }
Beispiel #15
0
        /// <summary>
        /// Here when any part's PAW is popped up.
        /// </summary>
        /// <param name="window"></param>
        /// <param name="part"></param>
        private void OnPartActionUIShown(UIPartActionWindow window, Part part)
        {
            ModuleSimpleFuelSwitch module = ModuleSimpleFuelSwitch.TryFind(part);

            if (module != null)
            {
                module.OnPartActionUIShown(window);
            }
        }
        // ReSharper disable ParameterHidesMember
        public override void Setup(UIPartActionWindow window, Part part, UI_Scene scene, UI_Control control, PartResource resource)
        {
            double amount = resource.amount;

            base.Setup(window, part, scene, control, resource);
            this.resource.amount = amount;

            slider.SetValueChangedDelegate(OnSliderChanged);
        }
        public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field)
        {
            base.Setup(window, part, partModule, scene, control, field);

            ModuleB9PartSwitch switcherModule = (ModuleB9PartSwitch)partModule;

            SwitcherSubtypeDescriptionGenerator subtypeDescriptionGenerator = new SwitcherSubtypeDescriptionGenerator(switcherModule);

            subtypeButtons = new List <UIPartActionSubtypeButton>(switcherModule.subtypes.Count);
            for (int i = 0; i < switcherModule.subtypes.Count; i++)
            {
                PartSubtype subtype = switcherModule.subtypes[i];
                if (!subtype.IsUnlocked())
                {
                    continue;
                }
                GameObject buttonGameObject             = Instantiate(prefabVariantButton, scrollMain.content);
                UIPartActionSubtypeButton subtypeButton = buttonGameObject.GetComponent <UIPartActionSubtypeButton>();

                // prevent capturing in closures
                int index = i;

                subtypeButton.Setup(
                    subtype.title,
                    subtypeDescriptionGenerator.GetFullSubtypeDescription(subtype),
                    subtype.PrimaryColor,
                    subtype.SecondaryColor,
                    () => SetSubtype(index)
                    );

                subtypeButtons.Add(subtypeButton);
            }

            subtypeButtons[0].previousItem = subtypeButtons[subtypeButtons.Count - 1];
            subtypeButtons[0].nextItem     = subtypeButtons[1];
            for (int i = 1; i < subtypeButtons.Count - 1; i++)
            {
                subtypeButtons[i].previousItem = subtypeButtons[i - 1];
                subtypeButtons[i].nextItem     = subtypeButtons[i + 1];
            }
            subtypeButtons[subtypeButtons.Count - 1].previousItem = subtypeButtons[subtypeButtons.Count - 2];
            subtypeButtons[subtypeButtons.Count - 1].nextItem     = subtypeButtons[0];

            switcherDescriptionText.text = switcherModule.switcherDescription;

            TooltipHelper.SetupSubtypeInfoTooltip(buttonPreviousTooltipController, "", "");
            TooltipHelper.SetupSubtypeInfoTooltip(buttonNextTooltipController, "", "");

            SetTooltips(switcherModule.currentSubtypeIndex);

            buttonPrevious.onClick.AddListener(PreviousSubtype);
            buttonNext.onClick.AddListener(NextSubtype);

            subtypeTitleText.text = switcherModule.CurrentSubtype.title;

            subtypeButtons[switcherModule.currentSubtypeIndex].Activate();
        }
        private void Start()
        {
            window = gameObject.GetComponentInParent <UIPartActionWindow>();

            if (window == null)
            {
                Destroy(gameObject);
            }

            SEP_Utilities.onWindowSpawn.Fire(window);
        }
Beispiel #19
0
        // ReSharper disable ParameterHidesMember
        public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field)
        {
            base.Setup(window, part, partModule, scene, control, field);
            incLargeDown.SetValueChangedDelegate(obj => buttons_ValueChanged(false));
            incLargeUp.SetValueChangedDelegate(obj => buttons_ValueChanged(true));
            slider.SetValueChangedDelegate(slider_OnValueChanged);

            // so update runs.
            value = GetFieldValue() + 0.1f;
            UpdateFieldInfo();
        }
Beispiel #20
0
        public void ForcePAWRefresh()
        {
            // Thanks to https://github.com/blowfishpro for finding this API call for me:
            UIPartActionWindow paw = UIPartActionController.Instance?.GetItem(part, false);

            if (paw != null)
            {
                paw.ClearList();
                paw.displayDirty = true;
            }
        }
Beispiel #21
0
        private void UpdatePartActionWindow()
        {
            UIPartActionWindow window = UIPartActionController.Instance?.GetItem(module.part, false);

            if (window is null)
            {
                return;
            }

            window.ClearList();
            window.displayDirty = true;
        }
Beispiel #22
0
        /// <summary>
        /// Starts the fishing program.
        /// </summary>
        public void StartFishing(Vessel v, ProtoCrewMember pcm)
        {
            evaVessel    = v;
            kerbalFisher = pcm;
            fishingData  = SportsScenario.Instance.GetFishingData(pcm);

            SetState(FishingState.StartFishing);

            // Get the kerbal EVA
            KerbalEVA eva = evaVessel.GetComponent <KerbalEVA>();

            // Create the fishing pole object
            GameObject poleObject = new GameObject("fishingPole");

            fishingPole = poleObject.AddComponent <FishingPole>();
            fishingPole.referenceTransform = eva.transform.FindDeepChild("bn_r_mid_a01");
            poleObject.SetActive(true);

            // Initialize animations
            animation = eva.GetComponent <Animation>();
            castingClip.Initialize(animation, eva.transform);
            reelingClip.Initialize(animation, eva.transform);
            hookedClip.Initialize(animation, eva.transform);
            caughtClip.Initialize(animation, eva.transform);

            // Close the window that caused us to open
            UIPartActionWindow paw = UnityEngine.Object.FindObjectOfType <UIPartActionWindow>();

            if (paw != null)
            {
                paw.isValid = false;
            }

            // Determine the body difficulty
            double gravityModifier = evaVessel.mainBody.gravParameter / (evaVessel.mainBody.Radius * evaVessel.mainBody.Radius) / 9.81;
            double scienceModifier = evaVessel.mainBody.scienceValues.SplashedDataValue / 10.0f;

            bodyDifficulty     = gravityModifier + scienceModifier;
            hookedReelingSpeed = defaultHookedReelingSpeed / (float)bodyDifficulty;
            Debug.Log("Body difficulty for " + evaVessel.mainBody.name + " = " + bodyDifficulty);

            // Pop up the tutorial dialog
            if (firstTimeDialog == null && !SportsScenario.Instance.tutorialDialogShown)
            {
                firstTimeDialog = gameObject.AddComponent <GenericDialog>();
                firstTimeDialog.instructorName = "Strategy_MechanicGuy";
                firstTimeDialog.text           = tutorialText;
                firstTimeDialog.animation      = GenericDialog.Animation.true_nodA;

                SportsScenario.Instance.tutorialDialogShown = true;
            }
        }
Beispiel #23
0
        public void OnResourcesModified(BaseEventData data)
        {
            if (HighLogic.LoadedSceneIsFlight || moduleFuelTanks == null)
            {
                return;
            }

            UIPartActionWindow window = part.FindActionWindow();

            if (window != null)
            {
                window.displayDirty = true;
            }
        }
Beispiel #24
0
        private void OnPartActionUIShown(UIPartActionWindow paw, Part part)
        {
            if (!part.Modules.Contains(nameof(ModuleProceduralAvionics)))
            {
                return;
            }

            var pm = (ModuleProceduralAvionics)part.Modules[nameof(ModuleProceduralAvionics)];

            if (pm != null)
            {
                pm.showGUI = true;
            }
        }
Beispiel #25
0
        private void OnPartActionUIShown(UIPartActionWindow paw, Part part)
        {
            if (!part.Modules.Contains(nameof(ModuleProceduralAvionics)))
            {
                return;
            }

            var pm = (ModuleProceduralAvionics)part.Modules[nameof(ModuleProceduralAvionics)];

            if (pm != null && !HighLogic.CurrentGame.Parameters.CustomParams <RP0Settings>().IsProcAvionicsAutoShown)
            {
                pm.showGUI = true;
            }
        }
Beispiel #26
0
        void onPartActionUIShown(UIPartActionWindow window, Part actionPart)
        {
            if (hostPart == null)
            {
                getHostPart();
            }
            if (actionPart != hostPart)
            {
                return;
            }

            // When changing a part's list of resources, the part action window may not be updated properly, so we need to manually refresh the window.
            // To do that we track the action window.
            actionWindow = window;
        }
        private void parseUIWindow()
        {
            UIPartActionWindow windowPrefab = UIPartActionController.Instance.windowPrefab;
            UIPartActionButton buttonPrefab = UIPartActionController.Instance.eventItemPrefab;

            if (windowPrefab == null || buttonPrefab == null)
            {
                return;
            }

            _lineColor        = windowPrefab.lineColor;
            _lineCornerRadius = windowPrefab.lineCornerRadius;
            _lineMaterial     = windowPrefab.lineMaterial;
            _lineWidth        = windowPrefab.lineWidth;

            Image Title = windowPrefab.titleBar.gameObject.GetComponent <Image>();

            TitleBackground = Title.sprite;
            TitleColor      = Title.color;

            UIMaterial = Title.material;

            Image Window = windowPrefab.GetComponentInChildren <Image>(true);

            WindowBackground = Window.sprite;
            WindowColor      = Window.color;

            Toggle pin = windowPrefab.togglePinned;

            Selectable pinSelect = pin.GetComponent <Selectable>();

            ToggleNormal     = pinSelect.image.sprite;
            ToggleHightlight = pinSelect.spriteState.highlightedSprite;
            ToggleActive     = pinSelect.spriteState.pressedSprite;
            ToggleInactive   = pinSelect.spriteState.disabledSprite;

            Image checkmark = pin.GetComponentsInChildren <Image>(true)[1];

            ToggleCheckmark = checkmark.sprite;

            Selectable button = buttonPrefab.button.GetComponent <Selectable>();

            ButtonNormal    = button.image.sprite;
            ButtonHighlight = button.spriteState.highlightedSprite;
            ButtonActive    = button.spriteState.pressedSprite;
            ButtonInactive  = button.spriteState.disabledSprite;
        }
        private void AssignResourcesToPart(bool calledByPlayer = false)
        {
            try
            {
                // destroying a resource messes up the gui in editor, but not in flight.
                currentResources = SetupTankInPart(part, calledByPlayer);

                // update GUI part
                ConfigureResourceMassGui(currentResources);
                UpdateTankName();

                if (HighLogic.LoadedSceneIsEditor)
                {
                    foreach (var symPart in part.symmetryCounterparts)
                    {
                        var symNewResources = SetupTankInPart(symPart, calledByPlayer);

                        InterstellarFuelSwitch symSwitch = symPart.GetComponent <InterstellarFuelSwitch>();
                        if (symSwitch != null)
                        {
                            symSwitch.selectedTankSetup    = selectedTankSetup;
                            symSwitch.selectedTankSetupTxt = selectedTankSetupTxt;
                            symSwitch.ConfigureResourceMassGui(symNewResources);
                            symSwitch.UpdateTankName();
                        }
                    }
                }

                if (tweakableUI == null)
                {
                    tweakableUI = part.FindActionWindow();
                }

                if (tweakableUI != null)
                {
                    tweakableUI.displayDirty = true;
                }
            }
            catch (Exception e)
            {
                Debug.LogError("InsterstellarFuelSwitch AssignResourcesToPart Error " + e.Message);
                throw;
            }
        }
Beispiel #29
0
        protected void LoadOptionResources(bool updateSymmetryParts = false)
        {
            ConfigNode[]           resourceConfigs;
            Part[]                 symmetryParts;
            SnacksResourceSwitcher switcher;

            //Clear our resources
            this.part.Resources.Clear();

            //Set the option name
            Events["ToggleOption"].guiName = resourceOptions[currentOptionIndex].name;

            //Get the resource configs
            resourceConfigs = resourceOptions[currentOptionIndex].resourceConfigs;

            //Now add the resources to the part.
            for (int index = 0; index < resourceConfigs.Length; index++)
            {
                this.part.AddResource(resourceConfigs[index]);
            }

            //Dirty the GUI
            if (UIPartActionController.Instance != null)
            {
                UIPartActionWindow window = UIPartActionController.Instance.GetItem(part);
                if (window != null)
                {
                    window.displayDirty = true;
                }
            }
            GameEvents.onPartResourceListChange.Fire(this.part);

            //Update symmetry parts
            if (updateSymmetryParts && this.part.symmetryCounterparts.Count > 0)
            {
                symmetryParts = this.part.symmetryCounterparts.ToArray();
                for (int index = 0; index < symmetryParts.Length; index++)
                {
                    switcher = symmetryParts[index].FindModuleImplementing <SnacksResourceSwitcher>();
                    switcher.currentOptionIndex = this.currentOptionIndex;
                    switcher.LoadOptionResources();
                }
            }
        }
        private void onWindowDestroy(UIPartActionWindow win)
        {
            if (win == null)
            {
                return;
            }

            if (win.part.flightID != part.flightID)
            {
                return;
            }

            if (window == null)
            {
                return;
            }

            window = null;
        }
        private void onWindowSpawn(UIPartActionWindow win)
        {
            if (win == null)
            {
                return;
            }

            if (win.part.flightID != part.flightID)
            {
                return;
            }

            if (FlightGlobals.ActiveVessel == vessel)
            {
                return;
            }

            window = win;
        }
        // ReSharper disable ParameterHidesMember
        public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field)
        {
            base.Setup(window, part, partModule, scene, control, field);
            incLargeDown.SetValueChangedDelegate(obj => buttons_ValueChanged(false));
            incLargeUp.SetValueChangedDelegate(obj => buttons_ValueChanged(true));
            slider.SetValueChangedDelegate(slider_OnValueChanged);

            // so update runs.
            value = GetFieldValue() + 0.1f;
            UpdateFieldInfo();
        }
Beispiel #33
0
        public void Update()
        {

            string errLine = "1";
            try
            {
            bool RootPartExists = new bool();
            errLine = "2";
            try
            {
                errLine = "3";
                if (FlightGlobals.ActiveVessel.parts.Count > 0)
                {
                    errLine = "4";
                }
                errLine = "5";
                RootPartExists = true;
            }
            catch
            {
                errLine = "6";
                RootPartExists = false;
            }
            errLine = "7";

            if (RootPartExists)
            {
                errLine = "8";
                if (AGXRoot != FlightGlobals.ActiveVessel.rootPart && flightNodeIsLoaded) //load keyset also
                {
                    print("Root part changed, AGX reloading");
                    //loadFinished = false;
                    if (AGXRoot != null)
                    {
                        errLine = "9";
                       // print("Root part changed, AGX reloadinga");
                        ConfigNode oldVsl = new ConfigNode(AGXRoot.vessel.id.ToString());
                        if(AGXFlightNode.HasNode(AGXRoot.vessel.id.ToString()))
                        {
                            errLine = "10";
                            //print("Root part changed, AGX reloadingb");
                            oldVsl = AGXFlightNode.GetNode(AGXRoot.vessel.id.ToString());
                            AGXFlightNode.RemoveNode(AGXRoot.vessel.id.ToString());
                        }
                        errLine = "11";
                        //print("Root part changed, AGX reloadingc");
                        if(oldVsl.HasValue("name"));
                        {
                            oldVsl.RemoveValue("name");
                        }
                        oldVsl.AddValue("name", AGXRoot.vessel.vesselName);
                        errLine = "12";
                       // errLine = "13";
                        if (oldVsl.HasValue("currentKeyset")) ;
                        {
                            oldVsl.RemoveValue("currentKeyset");
                        }
                        oldVsl.AddValue("currentKeyset", CurrentKeySet.ToString());
                        errLine = "13";
                        //errLine = "14";
                        if (oldVsl.HasValue("groupNames")) ;
                        {
                            oldVsl.RemoveValue("groupNames");
                        }
                        oldVsl.AddValue("groupNames", SaveGroupNames(""));
                        errLine = "14";
                        //errLine = "15";
                        if (oldVsl.HasValue("groupVisibility")) ;
                        {
                            oldVsl.RemoveValue("groupVisibility");
                        }
                        oldVsl.AddValue("groupVisibility", SaveGroupVisibility(""));
                        errLine = "15";
                        //errLine = "16";
                        if (oldVsl.HasValue("groupVisibilityNames")) ;
                        {
                            oldVsl.RemoveValue("groupVisibilityNames");
                        }
                        oldVsl.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
                        errLine = "16";
                        AGXFlightNode.AddNode(oldVsl);
                        //print("Root part changed, AGX reloadingd " + oldVsl.GetValue("groupNames"));
                    }
                    errLine = "17";
                    //print("Root part changed, AGX reloadinge");
                    if (flightNodeIsLoaded && AGXFlightNode.HasNode(FlightGlobals.ActiveVessel.id.ToString()))
                    {
                        errLine = "18";
                        //print("Root part changed, AGX reloadingf");
                        ConfigNode currentVessel = AGXFlightNode.GetNode(FlightGlobals.ActiveVessel.id.ToString());
                        CurrentKeySet = Convert.ToInt32(currentVessel.GetValue("currentKeyset"));
                        LoadGroupNames(currentVessel.GetValue("groupNames"));
                        LoadGroupVisibility(currentVessel.GetValue("groupVisibility"));
                        LoadGroupVisibilityNames(currentVessel.GetValue("groupVisibilityNames"));
                        //print("Root part changed, AGX reloadingg");
                        errLine = "19";
                    }
                        
                    else
                    {
                        errLine = "20";
                        CurrentKeySet = 1;
                        for (int i = 1; i <= 250; i = i + 1)
                        {
                            AGXguiNames[i] = "";
                        }
                        ShowGroupInFlightCurrent = 1;
                        for (int i = 1; i <= 250; i++)
                        {
                            IsGroupToggle[i] = false;
                            for (int i2 = 1; i2 <= 5; i2++)
                            {
                                ShowGroupInFlight[i2, i] = true;
                            }
                        }
                        ShowGroupInFlightNames[1] = "Group1";
                        ShowGroupInFlightNames[2] = "Group2";
                        ShowGroupInFlightNames[3] = "Group3";
                        ShowGroupInFlightNames[4] = "Group4";
                        ShowGroupInFlightNames[5] = "Group5";
                        errLine = "21";
                    }
                    
                   errLine = "22";


                    AGXRoot = FlightGlobals.ActiveVessel.rootPart;
                    AGEditorSelectedParts.Clear();
                    PartActionsList.Clear();
                    RefreshCurrentActions();
                    //loadFinished = true;
                    //print("sit " + FlightGlobals.ActiveVessel.situation.ToString());
                    errLine = "23";
                }
            }
            errLine = "24";
            if (LastPartCount != FlightGlobals.ActiveVessel.parts.Count) //parts count changed, remove any actions assigned to parts that have disconnected/been destroyed
            {
                print("Part count change, reload AGX");
                AGEditorSelectedParts.Clear();
                PartActionsList.Clear();
                //LoadActionGroups();
                RefreshCurrentActions();
                LastPartCount = FlightGlobals.ActiveVessel.parts.Count;
                errLine = "25";
                
            }
            errLine = "26";
            foreach (KeyCode KC in ActiveKeys)
            {
                errLine = "27";
                if(Input.GetKeyDown(KC))
                {
                for (int i = 1; i <= 250; i = i + 1)
                {
                    if (AGXguiKeys[i] == KC)
                    {
                        ActivateActionGroup(i);
                    }
                }
                }
            }
            errLine = "28";
            //if (!ActiveActionsCalculated)
            //{
            //    CalculateActiveActions();
                
            //}
            if(Input.GetKeyDown(KeyCode.Mouse0) && ShowSelectedWin)
        {
            errLine = "29";
                Part selPart = new Part();
            selPart = SelectPartUnderMouse();
            if(selPart != null)
            {
                AddSelectedPart(selPart);
        }
            errLine = "30";
        }
            errLine = "31";
            if (RightClickDelay < 3)
            {
                errLine = "32";
                if (RightClickDelay == 2)
                {
                    errLine = "33";
                    UIPartActionWindow UIPartsListThing = new UIPartActionWindow();
                    UIPartsListThing = (UIPartActionWindow)FindObjectOfType(typeof(UIPartActionWindow));
                    //UnityEngine.Object[] TempObj = FindObjectsOfType(typeof(UIPartActionWindow));
                    //print(TempObj.Length);
                    try
                    {
                        if (UIPartsListThing != null)
                        {
                            AddSelectedPart(UIPartsListThing.part);
                        }
                       // print(UIPartsListThing.part.name); //finds part right-clicked on
                        RightLickPartAdded = true;
                    }
                    catch
                    {
                       // print("nope!");
                        RightLickPartAdded = true;
                    }
                }
                
                    RightClickDelay = RightClickDelay + 1; 
                
                errLine = "34";
            }

            errLine = "35";
            
            if (Input.GetKeyUp(KeyCode.Mouse1) && ShowSelectedWin && RightLickPartAdded == true)
            {
                RightClickDelay = 0;
                RightLickPartAdded = false;

            }
            errLine = "36";

            //foreach (Part p in FlightGlobals.ActiveVessel.Parts)
            //{
            //    foreach (PartModule pm in p.Modules)
            //    {
            //        foreach (BaseAction ba in pm.Actions)
            //        {
            //            print(p.partName + " " + pm.moduleName + " " + ba.name + " " + ba.guiName);
            //        }
            //    }
            //}
            if (actionsCheckFrameCount >= 20)
            {
                CheckActionsActive();
                PartVesselChangeCheck();
                actionsCheckFrameCount = 0;
            }
            else
            {
                actionsCheckFrameCount = actionsCheckFrameCount + 1;
            }
            errLine = "37";
            //print("vessel " + FlightGlobals.ActiveVessel.id.ToString());
            //print("uid " + FlightGlobals.ActiveVssel.rootPart.uid.ToString());
            //foreach (Part p in FlightGlobals.ActiveVessel.Parts)
            //{
            //    print("PartLoc " + p.ConstructID + " " + p.orgPos);
            //}
        //    print("Vessel Id " +FlightGlobals.ActiveVessel.id);
        //    print("Part Flight Id " + FlightGlobals.ActiveVessel.rootPart.flightID);
        //    print("Part UID " + FlightGlobals.ActiveVessel.rootPart.uid);
        //    print("Part mission id " + FlightGlobals.ActiveVessel.rootPart.missionID);
            if (TimeWarp.CurrentRate != 1)
            {
                if (ShowSelectedWin || ShowKeySetWin)
                {

                    SaveEverything();
                    ShowSelectedWin = false;
                    ShowKeySetWin = false;
                }

            }
        }
            catch(Exception e)
            {
                print("AGX Update error: " + errLine + " " + e);
            }
        }
Beispiel #34
0
 public override void OnStart(StartState state)
 {
     //get other tanks in this part
     other_tanks.AddRange(from t in part.Modules.OfType<HangarSwitchableTank>()
                          where t != this select t);
     //get part menu
     part_menu = part.FindActionWindow();
     //initialize tank type chooser
     HangarGUI.EnableField(Fields["TankType"], false);
     if(state == StartState.Editor) init_type_control();
     init_tank_volume();
     init_tank_type();
     StartCoroutine(slow_update());
 }
 internal void MarkWindowDirty()
 {
     if (_myWindow == null) {
         _myWindow = part.FindActionWindow ();
     }
     if (_myWindow == null) {
         return;
     }
     _myWindow.displayDirty = true;
 }
Beispiel #36
0
 void update_part_menu()
 {
     part_menu = part.FindActionWindow();
     if(part_menu != null)
         part_menu.displayDirty = true;
     Utils.UpdateEditorGUI();
 }
        public virtual IEnumerator UpdateSymmetricGeometry()
        {
            if (!isStarted || geometryUpdateLock)
                yield break;
            geometryUpdateLock = true;
            yield return null;

            UpdateGeometry();
            if (partWindow == null)
            {
                partWindow = part.GetComponent<UIPartActionWindow>();
            }
            if (partWindow != null)
            {
                partWindow.displayDirty = true;
            }

            for (int i = part.symmetryCounterparts.Count - 1; i >= 0; --i)
            {
                part.symmetryCounterparts[i].Modules.GetModule<Base_ProceduralWing>().UpdateGeometry();
            }
            geometryUpdateLock = false;
        }
Beispiel #38
0
        private void assignResourcesToPart(bool calledByPlayer)
        {            
            // destroying a resource messes up the gui in editor, but not in flight.
            setupTankInPart(part, calledByPlayer);
            if (HighLogic.LoadedSceneIsEditor)
            {
                for (int s = 0; s < part.symmetryCounterparts.Count; s++)
                {
                    setupTankInPart(part.symmetryCounterparts[s], calledByPlayer);
                    FSfuelSwitch symSwitch = part.symmetryCounterparts[s].GetComponent<FSfuelSwitch>();
                    if (symSwitch != null)
                    {
                        symSwitch.selectedTankSetup = selectedTankSetup;
                    }
                }
            }

            //Debug.Log("refreshing UI");

            if (tweakableUI == null)
            {
                tweakableUI = Tools.FindActionWindow(part);
            }
            if (tweakableUI != null)
            {
                tweakableUI.displayDirty = true;
            }
            else
            {
                Debug.Log("no UI to refresh");
            }
        }
 // ReSharper disable ParameterHidesMember
 public override void Setup(UIPartActionWindow window, Part part, PartModule partModule, UI_Scene scene, UI_Control control, BaseField field)
 {
     base.Setup(window, part, partModule, scene, control, field);
     incDown.SetValueChangedDelegate(obj => IncrementValue(false));
     incUp.SetValueChangedDelegate(obj => IncrementValue(true));
     slider.SetValueChangedDelegate(OnValueChanged);
 }
Beispiel #40
0
        public void Update()
        {
            //Debug.Log("Start update!");//print("lock " + InputLockManager.IsLocked(ControlTypes.ALL_SHIP_CONTROLS));
            //if ((ControlTypes.ALL_SHIP_CONTROLS & (ControlTypes)InputLockManager.lockMask) == 0)
            //{
            //    print("not Locked");
            //}
            //else
            //{
            //    print("locked");
            //}
            //print("AGXLock state " + AGXLockSet);
            string errLine = "1";
            try
            {
                bool RootPartExists = new bool();
                errLine = "2";
                try
                {
                    errLine = "3";
                    if (FlightGlobals.ActiveVessel.parts.Count > 0) //we are actually checking null here on teh try-catch block, the if statement is a dummy
                    {
                        errLine = "4";
                    }
                    errLine = "5";
                    RootPartExists = true;
                }
                catch
                {
                    errLine = "6";
                    RootPartExists = false;
                }
                errLine = "7";

                if (flightNodeIsLoaded)
                {
                    if (RootPartExists)
                    {

                        errLine = "8";
                        if (AGXRoot != FlightGlobals.ActiveVessel.rootPart) //root part change, refresh stuff
                        {
                            // print("AGX Root change");
                            bool isDocking = false;
                            bool isUndocking = false;
                            try
                            {
                                if (FlightGlobals.ActiveVessel.parts.Contains(AGXRoot))
                                {
                                    isDocking = true;
                                    // print("AGX: Is a dock ");// + AGXRoot.ConstructID + " " + FlightGlobals.ActiveVessel.rootPart.ConstructID);
                                }
                                else if (oldShipParts.Contains(FlightGlobals.ActiveVessel.rootPart))
                                {
                                    isUndocking = true;
                                    //print("AGX: is an undock");
                                    //only clear actions if not a docking event
                                }
                                else
                                {
                                    //print("AGX: vessel switch");
                                    //CurrentVesselActions.Clear();
                                }
                            }
                            catch
                            {
                                //print("AGX: something was null in docking check");
                            }
                            errLine = "8a";
                            //print("Root part changed, AGX reloading");
                            //print("Root prt ch");
                            //if(!overrideRootChange) //no longer using DockingEvent
                            //{
                            errLine = "8b";
                            //print("Root part changed, AGX reloading B");
                            //loadFinished = false;

                            //CurrentVesselActions.Clear(); //we have saved old ship so clear actions
                            //if (!isDocking && !isUndocking)
                            //{
                            //    CurrentVesselActions.Clear();
                            //}
                            errLine = "24";
                            if (isDocking) //is a docking maneuver
                            {
                                DockingEvent();
                                RefreshCurrentActions();
                            }
                            if (isUndocking)
                            {
                                CheckListForMultipleVessels();
                                //RefreshCurrentActions();
                            }
                            //else //not a docking or undocking, load single node //this else closed at line 3792
                            //{
                            if (!isUndocking && !isDocking)
                            {
                                ConfigNode oldVsl = new ConfigNode();
                                errLine = "8c";
                                if (AGXRoot != null)
                                {
                                    errLine = "9";
                                    // print("Root part changed, AGX reloadinga");
                                    oldVsl = new ConfigNode(AGXRoot.vessel.rootPart.flightID.ToString());
                                    if (AGXFlightNode.HasNode(AGXRoot.vessel.rootPart.flightID.ToString()))
                                    {
                                        errLine = "10";
                                        //print("Root part changed, AGX reloadingb");
                                        oldVsl = AGXFlightNode.GetNode(AGXRoot.vessel.rootPart.flightID.ToString());
                                        AGXFlightNode.RemoveNode(AGXRoot.vessel.rootPart.flightID.ToString());
                                    }
                                    else if (AGXFlightNode.HasNode(AGXRoot.vessel.id.ToString()))
                                    {
                                        errLine = "10";
                                        //print("Root part changed, AGX reloadingb");
                                        oldVsl = AGXFlightNode.GetNode(AGXRoot.vessel.id.ToString());
                                        AGXFlightNode.RemoveNode(AGXRoot.vessel.id.ToString());
                                    }
                                    errLine = "11";
                                    //print("Root part changed, AGX reloadingc");
                                    if (oldVsl.HasValue("name"))
                                    {
                                        oldVsl.RemoveValue("name");
                                    }
                                    oldVsl.AddValue("name", AGXRoot.vessel.vesselName);
                                    errLine = "12";
                                    // errLine = "13";
                                    if (oldVsl.HasValue("currentKeyset"))
                                    {
                                        oldVsl.RemoveValue("currentKeyset");
                                    }
                                    oldVsl.AddValue("currentKeyset", CurrentKeySetFlight.ToString());
                                    errLine = "13";
                                    //errLine = "14";
                                    if (oldVsl.HasValue("groupNames"))
                                    {
                                        oldVsl.RemoveValue("groupNames");
                                    }
                                    oldVsl.AddValue("groupNames", SaveGroupNames(""));
                                    errLine = "14";
                                    //errLine = "15";
                                    if (oldVsl.HasValue("groupVisibility"))
                                    {
                                        oldVsl.RemoveValue("groupVisibility");
                                    }
                                    oldVsl.AddValue("groupVisibility", SaveGroupVisibility(""));
                                    errLine = "15";
                                    //errLine = "16";
                                    if (oldVsl.HasValue("groupVisibilityNames"))
                                    {
                                        errLine = "15b";
                                        oldVsl.RemoveValue("groupVisibilityNames");
                                        errLine = "15c";
                                    }
                                    errLine = "15d";

                                    oldVsl.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
                                    errLine = "16";
                                    if (oldVsl.HasValue("DirectActionState"))
                                    {
                                        errLine = "16b";
                                        oldVsl.RemoveValue("DirectActionState");
                                        errLine = "16c";
                                    }
                                    errLine = "16d";

                                    oldVsl.AddValue("DirectActionState", SaveDirectActionState(""));

                                    oldVsl.RemoveNodes("PART");

                                    foreach (Part p in AGXRoot.vessel.Parts)
                                    {
                                        errLine = "17";
                                        List<AGXAction> thisPartsActions = new List<AGXAction>();
                                        errLine = "18 ";
                                        //print("part 18a" + p.ConstructID + " " + CurrentVesselActions);
                                        thisPartsActions.AddRange(StaticData.CurrentVesselActions.FindAll(p2 => p2.ba.listParent.part == p));
                                        errLine = "18a";

                                        //errLine = "18";
                                        if (thisPartsActions.Count > 0)
                                        {
                                            errLine = "18b";
                                            ConfigNode partTemp = new ConfigNode("PART");
                                            errLine = "19";
                                            partTemp.AddValue("name", p.vessel.vesselName);
                                            partTemp.AddValue("vesselID", p.vessel.id);
                                            //partTemp.AddValue("relLocX", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).x);
                                            //partTemp.AddValue("relLocY", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).y);
                                            //partTemp.AddValue("relLocZ", AGXRoot.vessel.rootPart.transform.InverseTransformPoint(p.transform.position).z);
                                            partTemp.AddValue("flightID", p.flightID.ToString());
                                            errLine = "20";
                                            foreach (AGXAction agxAct in thisPartsActions)
                                            {
                                                errLine = "21";
                                                partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
                                            }
                                            errLine = "22";

                                            oldVsl.AddNode(partTemp);
                                            errLine = "23";
                                        }
                                        errLine = "24";
                                    }

                                    //print("AGX Save old vessel "+ oldVsl);
                                    AGXFlightNode.AddNode(oldVsl);
                                    //print("Root part changed, AGX reloadingd " + oldVsl.GetValue("groupNames"));
                                }
                                errLine = "24a";

                                StaticData.CurrentVesselActions.Clear();
                                errLine = "24b";
                            }
                            errLine = "24c";
                            if (!isDocking)
                            {

                                errLine = "24d";
                                bool checkIsVab = true;
                                ConfigNode vslNode = new ConfigNode();
                                try
                                {
                                    if (FlightGlobals.ActiveVessel.landedAt == "Runway")
                                    {
                                        //print("Runway found");
                                        checkIsVab = false;
                                    }
                                    else
                                    {
                                        //print("runway not found");
                                        checkIsVab = true;
                                    }

                                }
                                catch
                                {
                                    //print("runway iffy");
                                    checkIsVab = true;
                                }
                                errLine = "24e";
                                if (AGXFlightNode.HasNode(FlightGlobals.ActiveVessel.id.ToString()))
                                {
                                    //print("AGX flight node found");
                                    vslNode = AGXFlightNode.GetNode(FlightGlobals.ActiveVessel.id.ToString());

                                }
                                else if (AGXFlightNode.HasNode(FlightGlobals.ActiveVessel.rootPart.flightID.ToString()))
                                {
                                    // print("AGX flightID found");
                                    vslNode = AGXFlightNode.GetNode(FlightGlobals.ActiveVessel.rootPart.flightID.ToString());

                                }
                                //else if(RootParts.HasNode(FlightGlobals.ActiveVessel.rootPart.flightID.ToString()) && AGXRoot != null)  //replace with previously docked ship check, in other parts of code
                                //{
                                //    print("AGX root part found");
                                //    vslNode = oldVsl;
                                //    ConfigNode FoundRootPart = RootParts.GetNode(FlightGlobals.ActiveVessel.rootPart.flightID.ToString());
                                //    vslNode.RemoveValue("currentKeyset");
                                //    vslNode.AddValue("currentKeyset", FoundRootPart.GetValue("currentKeyset"));
                                //    vslNode.RemoveValue("groupVisibility");
                                //    vslNode.AddValue("groupVisibility", FoundRootPart.GetValue("groupVisibility"));
                                //    vslNode.RemoveValue("groupVisibilityNames");
                                //    vslNode.AddValue("groupVisibilityNames", FoundRootPart.GetValue("groupVisibilityNames"));
                                //    ShowAmbiguousMessage = false;
                                //}

                                else if (AGXEditorNodeFlight.HasNode(AGextScenario.EditorHashShipName(FlightGlobals.ActiveVessel.vesselName, checkIsVab)))
                                {
                                    // print("AGX VAB1 ");// + FlightGlobals.ActiveVessel.vesselName + " " + FlightGlobals.ActiveVessel.rootPart.ConstructID);
                                    vslNode = AGXEditorNodeFlight.GetNode(AGextScenario.EditorHashShipName(FlightGlobals.ActiveVessel.vesselName, checkIsVab));
                                    vslNode.name = FlightGlobals.ActiveVessel.rootPart.flightID.ToString();
                                    AGXFlightNode.AddNode(vslNode);
                                    // print("node check " + vslNode.ToString());
                                }
                                else if (AGXEditorNodeFlight.HasNode(AGextScenario.EditorHashShipName(FlightGlobals.ActiveVessel.vesselName, !checkIsVab)))
                                {
                                    //print("AGX vab2");
                                    vslNode = AGXEditorNodeFlight.GetNode(AGextScenario.EditorHashShipName(FlightGlobals.ActiveVessel.vesselName, !checkIsVab));
                                    vslNode.name = FlightGlobals.ActiveVessel.rootPart.flightID.ToString();
                                    AGXFlightNode.AddNode(vslNode);
                                }
                                else
                                {
                                    //print("AGX notfound");
                                    vslNode = new ConfigNode(FlightGlobals.ActiveVessel.rootPart.flightID.ToString());
                                    vslNode.AddValue("name", FlightGlobals.ActiveVessel.vesselName);
                                    vslNode.AddValue("currentKeyset", "1");
                                    vslNode.AddValue("groupNames", "");
                                    vslNode.AddValue("groupVisibility", "1011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111011111");
                                    vslNode.AddValue("groupVisibilityNames", "Group 1‣Group 2‣Group 3‣Group 4‣Group 5");
                                    vslNode.AddValue("DirectActionState", "");
                                    AGXFlightNode.AddNode(vslNode);
                                }
                                errLine = "24f";
                                CurrentKeySetFlight = Convert.ToInt32((string)vslNode.GetValue("currentKeyset"));
                                //LoadCurrentKeyBindings();
                                try
                                {
                                    if (CurrentKeySetFlight < 1 || CurrentKeySetFlight > 5)
                                    {
                                        CurrentKeySetFlight = 1;
                                    }
                                }
                                catch
                                {
                                    CurrentKeySetFlight = 1;
                                }
                                CurrentKeySetNameFlight = KeySetNamesFlight[CurrentKeySetFlight - 1];
                                LoadGroupNames(vslNode.GetValue("groupNames"));
                                LoadGroupVisibility(vslNode.GetValue("groupVisibility"));
                                LoadGroupVisibilityNames(vslNode.GetValue("groupVisibilityNames"));
                                //Debug.Log(vslNode);
                                if (vslNode.HasValue("DirectActionState"))
                                {
                                    //Debug.Log("has state");
                                    LoadDirectActionState(vslNode.GetValue("DirectActionState"));
                                }
                                else
                                {
                                    //Debug.Log("no state");
                                    LoadDirectActionState("");
                                }
                                errLine = "24fg";
                                foreach (ConfigNode prtNode in vslNode.nodes)
                                {

                                    float partDist = 100f;
                                    Part gamePart = new Part();
                                    if (prtNode.HasValue("flightID"))
                                    {
                                        errLine = "24h";
                                        try
                                        {
                                            uint flightIDFromFile = Convert.ToUInt32(prtNode.GetValue("flightID"));
                                            gamePart = FlightGlobals.ActiveVessel.parts.First(prt => prt.flightID == flightIDFromFile);
                                            partDist = 0f;
                                        }
                                        catch
                                        {
                                            continue; //bad FLightID in file, skip this action
                                        }
                                    }

                                    else
                                    {
                                        errLine = "24i";
                                        foreach (Part p in FlightGlobals.ActiveVessel.parts) //do a distance compare check, floats do not guarantee perfect decimal accuray so use part with least distance, should be zero distance in most cases
                                        {
                                            Vector3 partLoc = new Vector3((float)Convert.ToDouble(prtNode.GetValue("relLocX")), (float)Convert.ToDouble(prtNode.GetValue("relLocY")), (float)Convert.ToDouble(prtNode.GetValue("relLocZ")));
                                            float thisPartDist = Vector3.Distance(partLoc, FlightGlobals.ActiveVessel.rootPart.transform.InverseTransformPoint(p.transform.position));
                                            if (thisPartDist < partDist)
                                            {
                                                gamePart = p;
                                                partDist = thisPartDist;
                                            }
                                        }
                                    }
                                    bool ShowAmbiguousMessage2 = true; //show actions ambiguous message?
                                    errLine = "24j";
                                    //if (ShowAmbiguousMessage && partDist < 0.3f)
                                    if (partDist < 0.3f)//do not show it if part found is more then 0.3meters off
                                    {
                                        ShowAmbiguousMessage2 = true;
                                    }
                                    else
                                    {
                                        ShowAmbiguousMessage2 = false;
                                    }
                                    errLine = "24k";
                                    //print("gamepart " + gamePart.ConstructID + " " + partDist);
                                    foreach (ConfigNode actNode in prtNode.nodes)
                                    {
                                        //print("node " + actNode + " " + gamePart.ConstructID);
                                        AGXAction actToAdd = AGextScenario.LoadAGXActionVer2(actNode, gamePart, ShowAmbiguousMessage2);
                                        //print("act to add " + actToAdd.ba);
                                        if (actToAdd.ba != null && !StaticData.CurrentVesselActions.Contains(actToAdd))
                                        {
                                            StaticData.CurrentVesselActions.Add(actToAdd);
                                        }
                                    }
                                }
                                errLine = "24l";
                                List<KSPActionGroup> CustomActions = new List<KSPActionGroup>();
                                CustomActions.Add(KSPActionGroup.Custom01); //how do you add a range from enum?
                                CustomActions.Add(KSPActionGroup.Custom02);
                                CustomActions.Add(KSPActionGroup.Custom03);
                                CustomActions.Add(KSPActionGroup.Custom04);
                                CustomActions.Add(KSPActionGroup.Custom05);
                                CustomActions.Add(KSPActionGroup.Custom06);
                                CustomActions.Add(KSPActionGroup.Custom07);
                                CustomActions.Add(KSPActionGroup.Custom08);
                                CustomActions.Add(KSPActionGroup.Custom09);
                                CustomActions.Add(KSPActionGroup.Custom10);

                                //errLine = "16";
                                // string AddGroup = "";
                                List<BaseAction> partAllActions = new List<BaseAction>(); //is all vessel actions, copy pasting code
                                foreach (Part p in FlightGlobals.ActiveVessel.parts)
                                {
                                    partAllActions.AddRange(p.Actions);
                                    foreach (PartModule pm in p.Modules)
                                    {
                                        partAllActions.AddRange(pm.Actions);
                                    }

                                    //foreach (BaseAction ba in partAllActions)
                                    //{
                                    //    print(ba.listParent.part + " " + ba.listParent.module.moduleName + " " + ba.name + " " + ba.guiName);
                                    //}
                                    // print("part orgpos " + p.ConstructID+ " "  + p.orgPos + " " + p.orgRot);
                                }
                                errLine = "24m";
                                foreach (BaseAction baLoad in partAllActions)
                                {
                                    foreach (KSPActionGroup agrp in CustomActions)
                                    {

                                        if ((baLoad.actionGroup & agrp) == agrp)
                                        {
                                            // errLine = "17";
                                            ////AddGroup = AddGroup + '\u2023' + (CustomActions.IndexOf(agrp) + 1).ToString("000") + baLoad.guiName;
                                            //partAGActions2.Add(new AGXAction() { group = CustomActions.IndexOf(agrp) + 1, prt = this.part, ba = baLoad, activated = false });
                                            AGXAction ToAdd = new AGXAction() { prt = baLoad.listParent.part, ba = baLoad, group = CustomActions.IndexOf(agrp) + 1, activated = false };
                                            List<AGXAction> Checking = new List<AGXAction>();
                                            Checking.AddRange(StaticData.CurrentVesselActions);
                                            Checking.RemoveAll(p => p.group != ToAdd.group);

                                            Checking.RemoveAll(p => p.prt != ToAdd.prt);

                                            Checking.RemoveAll(p => p.ba != ToAdd.ba);

                                            if (Checking.Count == 0)
                                            {

                                                StaticData.CurrentVesselActions.Add(ToAdd);

                                            }
                                        }
                                    }
                                    // errLine = "18";
                                }
                            }
                            //} //close backet on else statment that this is not dock/undock

                            errLine = "32";

                            AGXRoot = FlightGlobals.ActiveVessel.rootPart;
                            oldShipParts = new List<Part>(FlightGlobals.ActiveVessel.parts);

                            errLine = "32a";

                            overrideRootChange = false;
                            LastPartCount = FlightGlobals.ActiveVessel.parts.Count;
                            AGEditorSelectedParts.Clear();
                            PartActionsList.Clear();
                            RefreshCurrentActions();
                            loadFinished = true;
                            //print("sit " + FlightGlobals.ActiveVessel.situation.ToString());
                            errLine = "33";
                            CurrentKeySetNameFlight = KeySetNamesFlight[CurrentKeySetFlight - 1];
                            LoadCurrentKeyBindings();
                            errLine = "33a";
                            FlightSaveToFile(AGXFlightNode);//add save current vessel here
                            errLine = "33b";
                        }
                    }
                    errLine = "34";
                    if (LastPartCount != FlightGlobals.ActiveVessel.parts.Count) //parts count changed, remove any actions assigned to parts that have disconnected/been destroyed
                    {
                        print("Part count change, reload AGX");
                        if (FlightGlobals.ActiveVessel.parts.Count > LastPartCount)
                        {
                            DockingEvent();
                        }
                        else if (LastPartCount > FlightGlobals.ActiveVessel.parts.Count) //new count is larger was a docking op, see the dock gameevent to handle that //chaged again
                        {
                            CheckListForMultipleVessels();
                        }
                        AGEditorSelectedParts.Clear();
                        PartActionsList.Clear();
                        //LoadActionGroups();
                        RefreshCurrentActions();
                        LastPartCount = FlightGlobals.ActiveVessel.parts.Count;
                        oldShipParts = new List<Part>(FlightGlobals.ActiveVessel.parts);
                        errLine = "35";

                    }
                }
                errLine = "36";

                if (InputLockManager.GetControlLock("kOSTerminal") == ControlTypes.None && (ControlTypes.KSC_ALL & (ControlTypes)InputLockManager.lockMask) == 0)// && InputLockManager.IsLocked(ControlTypes.All))//&& !InputLockManager.IsLocked(ControlTypes.All))
                {

                    foreach (KeyCode KC in ActiveKeys)
                    {

                        errLine = "37";
                        if (Input.GetKeyDown(KC))
                        {
                            //print("keydown " + KC);
                            for (int i = 1; i <= 250; i = i + 1)
                            {
                                if (AGXguiKeys[i] == KC)
                                {
                                    //print("Key act for some reason " + i);
                                    ActivateActionGroupCheckModKeys(i);
                                }
                            }
                        }
                    }

                    foreach (KeyValuePair<int, KeyCode> kcPair in ActiveKeysDirect)
                    {
                        if (Input.GetKey(kcPair.Value) && !DirectKeysState[kcPair.Key])
                        {
                            ActivateActionGroupCheckModKeys(kcPair.Key, true, true);
                            DirectKeysState[kcPair.Key] = true;
                            //Debug.Log("turn on");
                        }
                        else if (!Input.GetKey(kcPair.Value) && DirectKeysState[kcPair.Key])
                        {
                            ActivateActionGroupCheckModKeys(kcPair.Key, true, false);
                            DirectKeysState[kcPair.Key] = false;
                            //Debug.Log("turn off");
                        }
                    }
                    foreach (KeyValuePair<int, KeyCode> kcPair2 in DefaultTen) //toggle groups if no actions are assigned
                    {
                        if (Input.GetKeyDown(kcPair2.Value))
                        {
                            if (AGXguiMod1Groups[kcPair2.Key] == Input.GetKey(AGXguiMod1Key) && AGXguiMod2Groups[kcPair2.Key] == Input.GetKey(AGXguiMod2Key))
                            {
                                if (kcPair2.Key <= 10)
                                {
                                    Dictionary<int, KSPActionGroup> CustomActions = new Dictionary<int, KSPActionGroup>();
                                    CustomActions.Add(1, KSPActionGroup.Custom01); //how do you add a range from enum?
                                    CustomActions.Add(2, KSPActionGroup.Custom02);
                                    CustomActions.Add(3, KSPActionGroup.Custom03);
                                    CustomActions.Add(4, KSPActionGroup.Custom04);
                                    CustomActions.Add(5, KSPActionGroup.Custom05);
                                    CustomActions.Add(6, KSPActionGroup.Custom06);
                                    CustomActions.Add(7, KSPActionGroup.Custom07);
                                    CustomActions.Add(8, KSPActionGroup.Custom08);
                                    CustomActions.Add(9, KSPActionGroup.Custom09);
                                    CustomActions.Add(10, KSPActionGroup.Custom10);
                                    FlightGlobals.ActiveVessel.ActionGroups.ToggleGroup(CustomActions[kcPair2.Key]);
                                    groupActivatedState[kcPair2.Key] = FlightGlobals.ActiveVessel.ActionGroups[CustomActions[kcPair2.Key]];
                                }
                                else
                                {
                                    groupActivatedState[kcPair2.Key] = !groupActivatedState[kcPair2.Key];
                                }
                            }
                        }
                    }
                }
                errLine = "38";
                //if (!ActiveActionsCalculated)
                //{
                //    CalculateActiveActions();
                // Debug.Log("AGX update middel A");
                //}
                if (Input.GetKeyDown(KeyCode.Mouse0) && ShowSelectedWin)
                {
                    errLine = "39";
                    Part selPart = new Part();
                    selPart = SelectPartUnderMouse();
                    if (selPart != null)
                    {
                        AddSelectedPart(selPart);
                    }
                    errLine = "40";
                }
                //Debug.Log("AGX update middel b");
                errLine = "41";
                if (RightClickDelay < 3)
                {
                    errLine = "42";
                    if (RightClickDelay == 2)
                    {
                        errLine = "43";
                        UIPartActionWindow UIPartsListThing = new UIPartActionWindow();
                        UIPartsListThing = (UIPartActionWindow)FindObjectOfType(typeof(UIPartActionWindow));
                        //UnityEngine.Object[] TempObj = FindObjectsOfType(typeof(UIPartActionWindow));
                        //print(TempObj.Length);
                        try
                        {
                            if (UIPartsListThing != null)
                            {
                                AddSelectedPart(UIPartsListThing.part);
                            }
                            // print(UIPartsListThing.part.name); //finds part right-clicked on
                            RightLickPartAdded = true;
                        }
                        catch
                        {
                            // print("nope!");
                            RightLickPartAdded = true;
                        }
                    }

                    RightClickDelay = RightClickDelay + 1;

                    errLine = "44";
                }
                //Debug.Log("AGX update middel c");
                errLine = "45";

                if (Input.GetKeyUp(KeyCode.Mouse1) && ShowSelectedWin && RightLickPartAdded == true)
                {
                    RightClickDelay = 0;
                    RightLickPartAdded = false;

                }
                errLine = "46";
                // Debug.Log("AGX update middel d");
                //foreach (Part p in FlightGlobals.ActiveVessel.Parts)
                //{
                //    foreach (PartModule pm in p.Modules)
                //    {
                //        foreach (BaseAction ba in pm.Actions)
                //        {
                //            print(p.partName + " " + pm.moduleName + " " + ba.name + " " + ba.guiName);
                //        }
                //    }
                //}
                if (ShowAGXMod)
                {
                    if (actionsCheckFrameCount >= 15) //this increments in the FixedUpdate frame now
                    {
                        CheckActionsActive();
                        //PartVesselChangeCheck();
                        actionsCheckFrameCount = 0;
                    }
                }
                //else
                //{
                //    actionsCheckFrameCount = actionsCheckFrameCount + (int)(Time.deltaTime * 1000f);
                //}
                //print("delta time " + actionsCheckFrameCount);
                errLine = "47";
                //Debug.Log("AGX update middel e2");
                //count down action cool downs
                groupCooldowns.RemoveAll(cd => cd.delayLeft > activationCoolDown); //remove actions from list that are finished cooldown, cooldown is in Update frame passes, pulled from .cfg
                foreach (AGXCooldown agCD in groupCooldowns)
                {
                    agCD.delayLeft = agCD.delayLeft + 1;

                }
                //Debug.Log("AGX update middel e");
                errLine = "48";
                if (RTFound)
                {
                    CheckRTQueue();
                }
                //Debug.Log("AGX update middel f");
                errLine = "49";
                //PrintPartActs();
                //print("landed " + FlightGlobals.ActiveVessel.landedAt);

                //if (test == null)
                //{
                //    Debug.Log("NULL");
                //}
                //else
                //{
                //    Debug.Log("found " + test.nodes.Count + " " + test.values.Count);
                //}
                //Debug.Log("btn font " + HighLogic.Skin.font +);// AGXBtnStyle.font + AGXBtnStyle.fontSize + AGXBtnStyle.fontStyle);
                //Debug.Log("End update!");
            }
            catch (Exception e)
            {
                print("AGX Update error: " + errLine + " " + e);
            }
        }