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;
                    }
                }
            }

            Log.dbg("refreshing UI");

            if (tweakableUI == null)
            {
                tweakableUI = Tools.FindActionWindow(part);
            }
            if (tweakableUI != null)
            {
                tweakableUI.CreatePartList(true);
                tweakableUI.displayDirty = true;
            }
            else
            {
                Log.info("no UI to refresh");
            }
        }
Example #2
0
        /// <summary>
        /// Handles the Update event.
        /// </summary>
        public void Update()
        {
            if (!HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor)
            {
                return;
            }
            if (actionWindow == null || !updatePAW)
            {
                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.
            actionWindow.CreatePartList(true);
            updatePAW = false;
        }
Example #3
0
        /// <summary>
        /// Here when resources have been switched (either from clicking the button, or picking
        /// a linked variant).
        /// </summary>
        private void OnResourcesSwitched()
        {
            // Setting the part resources munges the PAW but doesn't flag it as
            // dirty, so we need to do that ourselves so that it'll redraw correctly
            // with the revised set of resources available.
            UIPartActionWindow window = UIPartActionController.Instance.GetItem(part);

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

            // We also need to fire off the "on ship modified" event, so that the engineer
            // report and any other relevant pieces of KSP UI will update as needed.
            if (EditorLogic.fetch != null)
            {
                GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
            }
        }