Exemplo n.º 1
0
        private void UpdateGUIState()
        {
            enabled = missile_module != null;
            EditorLogic editor = EditorLogic.fetch;

            if (!enabled && editor != null)
            {
                editor.Unlock("BD_MN_GUILock");
            }
        }
Exemplo n.º 2
0
 //Unity, called after Awake()
 public void Start()
 {
     Log.Debug("Start()");
     editor   = EditorLogic.fetch;
     Instance = this;
     InitConfig();
     InitializeGUI();
     GameEvents.onEditorPartEvent.Add(EditorPartEvent);
     GameEvents.onEditorSymmetryModeChange.Add(EditorSymmetryModeChange);
 }
        void UpdateGUIState()
        {
            enabled = tank_module != null;
            EditorLogic editor = EditorLogic.fetch;

            if (!enabled && editor != null)
            {
                editor.Unlock("MFTGUILock");
            }
        }
Exemplo n.º 4
0
        public void closeGUI()
        {
            guiEnabled = false;
            EditorLogic editor = EditorLogic.fetch;

            if (editor != null)
            {
                editor.Unlock("SSTUVolumeContainerLock");
            }
        }
        void UpdateGUIState()
        {
            enabled = container_module != null;
            EditorLogic editor = EditorLogic.fetch;

            if (!enabled && editor != null)
            {
                editor.Unlock("MSCGUILock");
            }
        }
Exemplo n.º 6
0
    public static void SaveLevel(EditorParams pu, EditorLogic lu, int slotNumber, string path)
    {
        string filepath = Application.streamingAssetsPath + path + "level_" + slotNumber.ToString() + ".json";

        LevelData ld = new LevelData(pu, lu);

        string jsonData = JsonUtility.ToJson(ld);

        File.WriteAllText(filepath, jsonData);
    }
        public void SetGlueProjectFile(string file, bool showError)
        {
            if (ConnectionFailed)
            {
                return;
            }

            EditorLogic.TakeSnapshot();
            ThreadPool.QueueUserWorkItem(SetGlueProjectAndSelectedObjectsThreadProc, showError);
        }
Exemplo n.º 8
0
        void drawWindow(int windowid)
        {
            bool draggable = true;

            GUILayout.BeginVertical();
            if (GUILayout.Button("Compute stages"))
            {
                ComputeStages();

                // reload the ship
                EditorLogic editor  = EditorLogic.fetch;
                ConfigNode  shipCfg = editor.ship.SaveShip();

                string filename = "saves/" + HighLogic.SaveFolder + "/Ships/VAB/SmartStage.craft.hidden";
                shipCfg.Save(filename);
                EditorLogic.LoadShipFromFile(filename);
                EditorLogic.fetch.SetBackup();
            }
            //autoUpdateStaging = GUILayout.Toggle(autoUpdateStaging, "Automatically recompute staging");

            bool newAdvancedSimulation = GUILayout.Toggle(advancedSimulation, "Advanced simulation");

            if (!newAdvancedSimulation && advancedSimulation)
            {
                windowPosition.width  = 0;
                windowPosition.height = 0;
            }
            advancedSimulation = newAdvancedSimulation;
            if (advancedSimulation)
            {
                int oldId = planetId;
                planetId = ComboBox.Box(planetId, planets, planets);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max acceleration: ");
                maxAcceleration.text = GUILayout.TextField(maxAcceleration.text);
                GUILayout.EndHorizontal();

                if (plot != null)
                {
                    draggable &= plot.draw();
                }

                if (oldId != planetId)
                {
                    ComputeStages();
                }
            }
            plugin.showInFlight = GUILayout.Toggle(plugin.showInFlight, "Show icon in flight");
            GUILayout.EndVertical();
            if (draggable)
            {
                GUI.DragWindow();
            }
        }
Exemplo n.º 9
0
        public void OnGUI()
        {
            if (!styleSetup)
            {
                styleSetup = true;
                Styles.InitStyles();
            }

            EditorLogic editor = EditorLogic.fetch;

            if (!HighLogic.LoadedSceneIsEditor || !editor)
            {
                return;
            }
            bool cursorInGUI = false;         // nicked the locking code from Ferram

            mousePos   = Input.mousePosition; //Mouse location; based on Kerbal Engineer Redux code
            mousePos.y = Screen.height - mousePos.y;

            int posMult = 0;

            if (offsetGUIPos != -1)
            {
                posMult = offsetGUIPos;
            }
            if (ActionGroupMode)
            {
                if (guiWindowRect.width == 0)
                {
                    guiWindowRect = new Rect(430 * posMult, 365, 438, 50);
                }
                new Rect(guiWindowRect.xMin + 440, mousePos.y - 5, 300, 20);
            }
            else
            {
                if (guiWindowRect.width == 0)
                {
                    //guiWindowRect = new Rect(Screen.width - 8 - 430 * (posMult + 1), 365, 438, (Screen.height - 365));
                    guiWindowRect = new Rect(Screen.width - 8 - 430 * (posMult + 1), 365, 438, 50);
                }
                new Rect(guiWindowRect.xMin - (230 - 8), mousePos.y - 5, 220, 20);
            }
            cursorInGUI = guiWindowRect.Contains(mousePos);
            if (cursorInGUI)
            {
                editor.Lock(false, false, false, "BD_MN_GUILock");
                //if (EditorTooltip.Instance != null)
                //    EditorTooltip.Instance.HideToolTip();
            }
            else
            {
                editor.Unlock("BD_MN_GUILock");
            }
            guiWindowRect = GUILayout.Window(GetInstanceID(), guiWindowRect, GUIWindow, "Weapon Name GUI", Styles.styleEditorPanel);
        }
        public void RefreshGlueProject(bool showError)
        {
            if (ConnectionFailed)
            {
                return;
            }

            EditorLogic.TakeSnapshot();

            ThreadPool.QueueUserWorkItem(RefreshGlueProjectThreadProc, showError);
        }
Exemplo n.º 11
0
        private Part GetPartUnderCursor()
        {
            Ray         ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
            EditorLogic editorLogic = EditorLogic.fetch;

            if (editorLogic && Physics.Raycast(ray, out RaycastHit rayCastHit))
            {
                return(editorLogic.ship.Parts.Find(p => p.gameObject == rayCastHit.transform.gameObject));
            }
            return(null);
        }
        public void UnloadProject(bool shouldShowWarning)
        {
            if (ConnectionFailed)
            {
                return;
            }

            EditorLogic.TakeSnapshot();

            ThreadPool.QueueUserWorkItem(UnloadProjectThreadProc, shouldShowWarning);
        }
Exemplo n.º 13
0
        public static Part GetPartUnderCursor()
        {
            var         ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit  hit;
            EditorLogic ed = EditorLogic.fetch;

            if (ed != null && Physics.Raycast(ray, out hit))
            {
                return(ed.ship.Parts.Find(p => p.gameObject == hit.transform.gameObject));
            }
            return(null);
        }
Exemplo n.º 14
0
        public void OnGUI()
        {
            EditorLogic editor = EditorLogic.fetch;

            if (!HighLogic.LoadedSceneIsEditor || !editor)
            {
                return;
            }

            //UpdateMixtures ();
            bool cursorInGUI = false;         // nicked the locking code from Ferram

            mousePos   = Input.mousePosition; //Mouse location; based on Kerbal Engineer Redux code
            mousePos.y = Screen.height - mousePos.y;

            Rect tooltipRect;
            int  posMult = 0;

            if (offsetGUIPos != -1)
            {
                posMult = offsetGUIPos;
            }
            if (ActionGroupMode)
            {
                if (guiWindowRect.width == 0)
                {
                    guiWindowRect = new Rect(430 * posMult, 365, 438, (Screen.height - 365));
                }
                tooltipRect = new Rect(guiWindowRect.xMin + 440, mousePos.y - 5, 300, 20);
            }
            else
            {
                if (guiWindowRect.width == 0)
                {
                    guiWindowRect = new Rect(Screen.width - 8 - 430 * (posMult + 1), 365, 438, (Screen.height - 365));
                }
                tooltipRect = new Rect(guiWindowRect.xMin - (230 - 8), mousePos.y - 5, 220, 20);
            }
            cursorInGUI = guiWindowRect.Contains(mousePos);
            if (cursorInGUI)
            {
                editor.Lock(false, false, false, "MFTGUILock");
                EditorTooltip.Instance.HideToolTip();
            }
            else
            {
                editor.Unlock("MFTGUILock");
            }

            GUI.Label(tooltipRect, myToolTip);
            guiWindowRect = GUILayout.Window(GetInstanceID(), guiWindowRect, GUIWindow, "Fuel Tanks for " + tank_module.part.partInfo.title);
        }
Exemplo n.º 15
0
        void OnDestroy()
        {
            log.debug("OnDestroy");
            if (this.axis != null)
            {
                EditorLogic.DestroyObject(this.axis);
            }

            toolbarControl.OnDestroy();
            Destroy(toolbarControl);

            Resources.UnloadUnusedAssets();//fix memory leak?
        }
Exemplo n.º 16
0
        public MainForm(string[] commandLineArgs)
        {
            InitializeComponent();
            CustomLayout();

            logic             = new EditorLogic(videoShitbox, vidkaPreviewPlayer);
            fastPlayerWrapper = new VidkaFastPreviewPlayerWrapper(vidkaFastPreviewPlayer, vidkaPreviewPlayer, this);
            videoShitbox.setLogic(logic);
            videoShitbox.GuessWhoIsConsole(txtConsole);
            vidkaFastPreviewPlayer.SetFileMapping(logic.FileMapping);

            openFirstFile = commandLineArgs.FirstOrDefault();
        }
Exemplo n.º 17
0
        void OnDestroy()
        {
            GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
            if (this.axis != null)
            {
                EditorLogic.DestroyObject(this.axis);
            }

            if (KVVButton != null)
            {
                ApplicationLauncher.Instance.RemoveModApplication(KVVButton);
            }
        }
        public void RefreshFile(bool showError, string fileName)
        {
            if (ConnectionFailed)
            {
                return;
            }

            EditorLogic.TakeSnapshot();

            object[] args = new object[] { showError, fileName };

            ThreadPool.QueueUserWorkItem(RefreshFileThreadProc, args);
        }
Exemplo n.º 19
0
        public override void OnStart(PartModule.StartState state)
        {
            EditorLogic logic = EditorLogic.fetch;

            if (logic != null)
            {
                Debug.Log("found editor logic!");

                Debug.Log(logic.ship[0].scaleFactor);

                foreach (Part p in logic.ship.parts)
                {
                    var moduleList = p.FindModulesImplementing <StructuralIntegrityField>();
                    if (moduleList.Count != 0)
                    {
                        StructuralIntegrityField mod = moduleList[0];
                        if (mod.sizeState)
                        {
                            //don't rescale a strut.
                            if (this.part.FindModuleImplementing <CompoundParts.CModuleStrut>() == null)
                            {
                                this.part.rescaleFactor = .02f;
                            }
                            //this.part.partTransform.localScale = new Vector3(.02f, .02f, .02f);
                            this.part.srfAttachNode.position *= .02f;
                            foreach (AttachNode node in part.attachNodes)
                            {
                                // node.size = 1;
                                node.originalPosition /= 50.0f;
                                //node.position /= 50.0f;
                            }


                            var lightsOnModel = part.FindModelComponents <Light>();
                            if (lightsOnModel != null)
                            {
                                foreach (Light l in lightsOnModel)
                                {
                                    l.enabled = false;
                                }
                            }
                        }
                    }
                }



                //logic.ship;
            }
            base.OnStart(state);
        }
Exemplo n.º 20
0
        private void newReloadShip()
        {
            ASPConsoleStuff.AAprint("newReloadShip() starting...");
            EditorLogic editor  = EditorLogic.fetch;
            ConfigNode  shipCfg = editor.ship.SaveShip();

            string filename = "saves/" + HighLogic.SaveFolder + "/Ships/VAB/AutoAsparagus.craft.hidden";

            shipCfg.Save(filename);
            EditorLogic.LoadShipFromFile(filename);
            EditorLogic.fetch.SetBackup();

            ASPConsoleStuff.AAprint("newReloadShip() done!");
        }
Exemplo n.º 21
0
        public static void HideGUI()
        {
            if (instance != null && instance.core != null)
            {
                instance.core = null;
                instance.UpdateGUIState();
            }
            EditorLogic editor = EditorLogic.fetch;

            if (editor != null)
            {
                editor.Unlock("BD_MN_GUILock");
            }
        }
            public Strut(Part part, string[] parms)
            {
                gameObject = part.gameObject;
                if (part is StrutConnector)
                {
                    maxLength = ((StrutConnector)part).maxLength;
                }
                else if (part is FuelLine)
                {
                    maxLength = ((FuelLine)part).maxLength;
                }
                else
                {
                    // not expected to happen, but...
                    maxLength = 10;
                }
                for (int i = 0; i < parms.Length; i++)
                {
                    string[] keyval = parms[i].Split(':');
                    string   Key    = keyval[0].Trim();
                    string   Value  = keyval[1].Trim();
                    if (Key == "tgt")
                    {
                        //targetName = Value.Split ('_')[0];
                    }
                    else if (Key == "pos")
                    {
                        pos = KSPUtil.ParseVector3(Value);
                    }
                    else if (Key == "dir")
                    {
                        dir = KSPUtil.ParseVector3(Value);
                    }
                }
                target = null;
                Transform  xform = gameObject.transform;
                RaycastHit hitInfo;
                Vector3    castPos = xform.TransformPoint(pos);
                Vector3    castDir = xform.TransformDirection(dir);

                if (Physics.Raycast(castPos, castDir, out hitInfo,
                                    maxLength))
                {
                    GameObject hit = hitInfo.collider.gameObject;
                    target = EditorLogic.GetComponentUpwards <Part>(hit);
                }
                //Debug.Log (String.Format ("[EL] {0} {1} {2} {3}", target,
                //						  targetName, xform.position,
                //						  xform.rotation));
            }
        private IEnumerator CheckActionGroupEditor()
        {
            while (EditorLogic.fetch == null)
            {
                yield return(null);
            }
            EditorLogic editor = EditorLogic.fetch;

            while (editor != null)
            {
                //FIXME check for events
                if (editor.editorScreen == EditorScreen.Actions)
                {
                    if (!ActionGroupMode)
                    {
                        HideGUI();
                        OnActionGroupEditorOpened.Fire();
                    }
                    var age = EditorActionGroups.Instance;
                    if (selected_part)
                    {
                        if (!age.SelectionContains(selected_part))
                        {
                            selected_part = null;
                            HideGUI();
                        }
                    }
                    else if (age.HasSelectedParts())
                    {
                        selected_part = age.GetSelectedParts()[0];
                        var container = selected_part.FindContainer();
                        if (container)
                        {
                            ShowGUI(container);
                        }
                    }
                    ActionGroupMode = true;
                }
                else
                {
                    if (ActionGroupMode)
                    {
                        HideGUI();
                        OnActionGroupEditorClosed.Fire();
                    }
                    ActionGroupMode = false;
                }
                yield return(null);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Deletes a part.
        /// </summary>
        /// <param name="part">The part to delete.</param>
        //public static
        public void Delete(Part part)
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                if (part == null)
                {
                    throw new ArgumentNullException("part");
                }

                if (part.children != null && part.children.Count > 0)
                {
                    throw new ArgumentException("Specified part has children and may not be deleted.", "part");
                }

                // First, get the parent part and delete the child part.
                Part parent = part.parent;

                parent.removeChild(part);

                // Second, do the creepy stalker way of forcing EditorLogic to change the selected part.
                EditorLogic.fetch.OnSubassemblyDialogDismiss(part);

                // Third, ask the editor to destroy the part, which requires the part to have been selected previously.
                EditorLogic.DeletePart(part);

                // Finally, poke the staging logic to sort out any changes due to deleting this part.
                Staging.SortIcons();
            }

            if (HighLogic.LoadedSceneIsFlight)
            {
                switch (part.name)
                {
                case "strutConnector":
                    badStruts.Remove(part);
                    part.Die();
                    GameEvents.onVesselWasModified.Fire(part.vessel);
                    break;

                case "fuelLine":
                    badFuelLines.Remove(part);
                    part.Die();
                    GameEvents.onVesselWasModified.Fire(part.vessel);
                    break;

                default:
                    break;
                }
            }
        }
        public override void OnStart(PartModule.StartState state)
        {
            EditorLogic logic = EditorLogic.fetch;

            if (logic != null)
            {
                Debug.Log("found editor logic!");

                Debug.Log(logic.ship[0].scaleFactor);

                //logic.ship;
            }
            base.OnStart(state);
        }
Exemplo n.º 26
0
        public static void HideGUI()
        {
            if (instance != null)
            {
                instance.tank_module = null;
                instance.UpdateGUIState();
            }
            EditorLogic editor = EditorLogic.fetch;

            if (editor != null)
            {
                editor.Unlock("MFTGUILock");
            }
        }
Exemplo n.º 27
0
        public void Apply(ShipConstruct ship, int stage, FuelTypes.StageResDef stages, bool allStages = false)
        {
            if (ship == null || stages == null)
            {
                return;
            }
            if (Changed)
            {
                foreach (var part in stages.parts)
                {
                    foreach (var resource in part.Resources)
                    {
                        foreach (var fuelType in stages.resources)
                        {
                            if (resource.resourceName == fuelType.Second)
                            {
                                if (!FillItUp.Instance.ignoreLockedTanks || resource.flowState)
                                {
                                    float f;

                                    key = new Tuple <string, int>(fuelType.Second, stage);
                                    if (model.TryGetValue(key, out f))
                                    {
                                        resource.amount = resource.maxAmount * f;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }


                var resourceEditors = EditorLogic.FindObjectsOfType <UIPartActionResourceEditor>();

                foreach (var ed in resourceEditors)
                {
                    ed.resourceAmnt.text = ed.Resource.amount.ToString("F1");
                    ed.resourceMax.text  = ed.Resource.maxAmount.ToString("F1");
                    ed.slider.value      = (float)(ed.Resource.amount / ed.Resource.maxAmount);
                }

                GameEvents.onEditorShipModified.Fire(ship);
                if (!allStages)
                {
                    Changed = false;
                }
            }
        }
Exemplo n.º 28
0
        public void appOnFalse()
        {
            visible = false;
            EditorLogic   editor = EditorLogic.fetch;
            ShipConstruct ship   = editor.ship;

            if (ship != null)
            {
                List <Part> parts = ship.parts;
                if (parts.Count > 0)
                {
                    parts [0].SetHighlight(false, true);
                }
            }
        }
Exemplo n.º 29
0
        private static void closeInternal()
        {
            guiOpen               = false;
            shouldClose           = false;
            adapters              = null;
            modelSelectedCallback = null;

            EditorLogic editor = EditorLogic.fetch;

            if (editor != null)
            {
                editor.Unlock("SSTUModelSelectLock");
            }
            UIPartActionController.Instance.Activate();
        }
Exemplo n.º 30
0
        public static void HideGUI()
        {
            if (instance != null && instance.missile_module != null)
            {
                instance.missile_module.WeaponName = instance.missile_module.shortName;
                instance.missile_module            = null;
                instance.UpdateGUIState();
            }
            EditorLogic editor = EditorLogic.fetch;

            if (editor != null)
            {
                editor.Unlock("BD_MN_GUILock");
            }
        }
Exemplo n.º 31
0
        public void Start()
        {
            _material = new Material( global::IntakeBuildAid.Resource.OutlineShaderContents );
            _managedParts = new Dictionary<Part, List<SavedMaterial>>();
            _manualAssignedList = new List<Part>();
            GameEvents.onPartAttach.Add( OnPartAttach );
            _useCustomShader = false;
            LoadSettings();
            _editor = EditorLogic.fetch;

            // init GUI
            //GameEvents.onGUIApplicationLauncherReady.Add( OnGUIApplicationLauncherReady );
            OnGUIApplicationLauncherReady();
            _guiRect = new Rect( ( Screen.width ) / 4, Screen.height / 2, 300, 100 );
            _guiVisible = false;
            Utils.DebugLog( "IntakeBuildAid Start() finished" );
        }
Exemplo n.º 32
0
        public void Awake()
        {
            Trace("[PAD] EditorWindow.Awake");
            //Trace("ApplicationLauncher is " + (ApplicationLauncher.Ready ? "" : "not ") + "ready");

            editor = EditorLogic.fetch;

            CreateUIObjects();

            LayoutWindow();

            windowID = Guid.NewGuid().GetHashCode();

            LoadConfig();
            Log.Flush();
        }
Exemplo n.º 33
0
        public void Update()
        {
            if (useAppLaunch && buttonAppLaunch == null)
            {
                if (ApplicationLauncher.Ready)
                {
                    if (texAppLaunch == null)
                    {
                        texAppLaunch = new Texture2D(38, 38, TextureFormat.RGBA32, false);
                        texAppLaunch.LoadImage(System.IO.File.ReadAllBytes(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "applaunch.png")));
                    }

                    buttonAppLaunch = ApplicationLauncher.Instance.AddModApplication(
                        ToggleWindow,
                        ToggleWindow,
                        null,
                        null,
                        null,
                        null,
                        ApplicationLauncher.AppScenes.VAB | ApplicationLauncher.AppScenes.SPH,
                        texAppLaunch
                        );
                }
                else
                {
                    Trace("ApplicationLauncher is not ready in Update");
                }
            }

            SetAppLaunchState();
            SetToolbarState();

            // Main Update code starts here

            editor = EditorLogic.fetch;
            if (editor == null)
                return;

            if (editor.editorScreen != EditorScreen.Parts)
                return;

            Part part = EditorLogic.SelectedPart;

            // Remember the previous values
            Vector3 oldAngles = eulerAngles;

            // Get the current values and remember the part and current rotation for use in LateUpdate
            if (part != null)
            {
                selPartUpdate = part;
                attRotationUpdate = part.attRotation;

                // TODO: Get this from a different place in rotate mode and allow it to
                // show building relative angles in place mode
                eulerAngles = part.attRotation.eulerAngles;
            }
            else
            {
                // No part selected so show zeros
                selPartUpdate = null;
                eulerAngles = Vector3.zero;
            }

            // Only update the angle strings if the values have changed
            if (eulerAngles.x != oldAngles.x)
                sPitch = eulerAngles.x.ToString("0.00");
            if (eulerAngles.y != oldAngles.y)
                sRoll = eulerAngles.y.ToString("0.00");
            if (eulerAngles.z != oldAngles.z)
                sYaw = eulerAngles.z.ToString("0.00");

            // Key handling
            // Get the state of the shift key and the configured modifier keys
            bool fineTweakKeyPressed = GameSettings.Editor_fineTweak.GetKey();
            bool veryFineTweakKeyPressed = Input.GetKey(keyVeryFineMod);
            bool modKeyPressed = GameSettings.MODIFIER_KEY.GetKey();

            if (ShouldRotateKeysWork())
            {
                // G/Shift-G/Mod-G  decrease/increase/reset rotation angle
                HandleCycleKey(keyCycleRotate, fineTweakKeyPressed, modKeyPressed, ref sIncCoarse);

                // F/Shift-F/Mod-F  decrease/increase/reset shift-rotation angle
                HandleCycleKey(keyCycleFine, fineTweakKeyPressed, modKeyPressed, ref sIncFine);
            }

            // When no part is selected:
            // Mod-P            toggle the visible state of the window
            if (part == null)
            {
                if (modKeyPressed && Input.GetKeyDown(keyToggleWindow))
                {
                    // Toggle the visibility
                    ToggleWindow();
                }
            }
            else if (ShouldRotateKeysWork())
            {
                // Otherwise we apply the relevant angle increments depending on which key was pressed
                // Mod-P: Applies all 3 axes using Euler angles
                if (modKeyPressed && Input.GetKeyDown(keyApplyEuler))
                {
                    //Trace("Applying part rotation");
                    Vector3 incAngles;
                    incAngles.x = GetSingleOrZero(sIncPitch);
                    incAngles.y = GetSingleOrZero(sIncRoll);
                    incAngles.z = GetSingleOrZero(sIncYaw);
                    part.attRotation = Quaternion.Euler(eulerAngles + incAngles);
                }

                // Work out what rotation we want and store it for application in LateUpdate
                // WASDQE           Apply our rotation of sPlainRotate
                // Shift-WASDQE     Apply our rotation of sShiftRotate
                // Mod-WASDQE       Apply our rotation of sIncPitch/Yaw/Roll
                rotVal = 0f;
                rotAxis = Vector3.zero;
                if (GameSettings.Editor_yawLeft.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? GetSingleOrZero(sIncFine) : (veryFineTweakKeyPressed ? GetSingleOrZero(sIncYaw) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.forward : Vector3.forward;
                }
                else if (GameSettings.Editor_yawRight.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? -GetSingleOrZero(sIncFine) : -(veryFineTweakKeyPressed ? GetSingleOrZero(sIncYaw) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.forward : Vector3.forward;
                }
                else if (GameSettings.Editor_rollLeft.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? GetSingleOrZero(sIncFine) : (veryFineTweakKeyPressed ? GetSingleOrZero(sIncRoll) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.up : Vector3.up;
                }
                else if (GameSettings.Editor_rollRight.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? -GetSingleOrZero(sIncFine) : -(veryFineTweakKeyPressed ? GetSingleOrZero(sIncRoll) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.up : Vector3.up;
                }
                else if (GameSettings.Editor_pitchUp.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? -GetSingleOrZero(sIncFine) : -(veryFineTweakKeyPressed ? GetSingleOrZero(sIncPitch) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.right : Vector3.right;
                }
                else if (GameSettings.Editor_pitchDown.GetKeyDown())
                {
                    rotVal = fineTweakKeyPressed ? GetSingleOrZero(sIncFine) : (veryFineTweakKeyPressed ? GetSingleOrZero(sIncPitch) : GetSingleOrZero(sIncCoarse));
                    rotAxis = relativeRotate ? part.transform.right : Vector3.right;
                }
            }
            Log.Flush();
        }
Exemplo n.º 34
0
        //public void LoadDefaultActionGroups() //not used?
        //{
           
        //    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);

        //    foreach (Part p in EditorLogic.SortedShipList)
        //    {
        //        string AddGroup = "";
        //        foreach (PartModule pm in p.Modules)
        //        {
        //            foreach (BaseAction ba in pm.Actions)
        //            {
        //                foreach (KSPActionGroup agrp in CustomActions)
        //                {
                          
        //                    if ((ba.actionGroup & agrp) == agrp)
                            
        //                    {
                               
        //                        AddGroup = AddGroup + '\u2023' + (CustomActions.IndexOf(agrp) +1).ToString("000") + ba.guiName;
        //                    }
        //                }
        //            }
        //        }
        //        foreach (PartModule pm in p.Modules.OfType<ModuleAGExtData>())
        //        {
        //            pm.Fields.SetValue("AGXData", AddGroup);
        //        }
        //    }
        //}

        
        public void Update()
            
        {

            if (checkShipsExist)
            {
                if (checkShipsExistDelay >= 30)
                {
                    checkShipsExist = false;
                    checkShipsExistDelay = 0;
                    CheckExistingShips();
                }
                else
                {
                    checkShipsExistDelay = checkShipsExistDelay + 1;
                }
            }


            
            EditorLogic ELCur = new EditorLogic();
            ELCur = EditorLogic.fetch;//get current editor logic instance

           
            
            if (AGXDoLock && ELCur.editorScreen != EditorLogic.EditorScreen.Actions)
            {
                ELCur.Unlock("AGXLock");
                AGXDoLock = false;
            }
            else if(AGXDoLock && !TrapMouse)
            {
                ELCur.Unlock("AGXLock");
                AGXDoLock = false;
            }
            else if (!AGXDoLock && TrapMouse && ELCur.editorScreen == EditorLogic.EditorScreen.Actions)
            {
                ELCur.Lock(false,false,false,"AGXLock");
                AGXDoLock = true;
            }
          
            
            if (ELCur.editorScreen == EditorLogic.EditorScreen.Actions) //only show mod if on actions editor screen
            {
              
                ShowSelectedWin = true;
            }
            else
            {
                
                ShowSelectedWin = false;
                
               
                  
                
                AGEditorSelectedParts.Clear();//mod is hidden, clear list so parts don't get orphaned in it
              
                PartActionsList.Clear();
              
                ActionsListDirty = true;
            }

          
            if (ShowSelectedWin) 
            {

               

                if (EditorActionGroups.Instance.GetSelectedParts() != null) //on first run, list is null
                {

                    if (ActionsListDirty)
                    {
                        UpdateActionsListCheck();
                       
                    }
                    if (EditorActionGroups.Instance.GetSelectedParts().Count > 0) //are there parts selected?
                    {

                        
                        if (PreviousSelectedPart != EditorActionGroups.Instance.GetSelectedParts().First()) //has selected part changed?
                        {
                            
                            if(!AGEditorSelectedParts.Any(p => p.AGPart==EditorActionGroups.Instance.GetSelectedParts().First())) //make sure selected part is not already in AGEdSelParts
                            {

                                if (AGEditorSelectedParts.Count == 0) //no items in Selected Parts list, so just add selection
                                {
                                   AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
                                   

                                }
                                else if (AGEditorSelectedParts.First().AGPart.name == EditorActionGroups.Instance.GetSelectedParts().First().name) //selected part matches first part already in selected parts list, so just add selected part
                                {
                                    AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
                                   

                                }
                                else //part does not match first part in list, clear list before adding part
                                {
                                   
                                    AGEditorSelectedParts.Clear();
                                    AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(),SelPartsIncSym));
                                  


                                }
                            }
                            PreviousSelectedPart = EditorActionGroups.Instance.GetSelectedParts().First(); //remember selected part so logic does not run unitl another part selected
                        }
                        
                    }
                }
                
            }


            if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
            {
                MonitorDefaultActions();
            }

            //foreach (Part p in EditorLogic.SortedShipList)
            //{
            //    print("PartLoc " + p.ConstructID + " " + p.orgPos);
            //}

            }
Exemplo n.º 35
0
        //public void LoadDefaultActionGroups() //not used?
        //{
        //    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);
        //    foreach (Part p in EditorLogic.SortedShipList)
        //    {
        //        string AddGroup = "";
        //        foreach (PartModule pm in p.Modules)
        //        {
        //            foreach (BaseAction ba in pm.Actions)
        //            {
        //                foreach (KSPActionGroup agrp in CustomActions)
        //                {
        //                    if ((ba.actionGroup & agrp) == agrp)
        //                    {
        //                        AddGroup = AddGroup + '\u2023' + (CustomActions.IndexOf(agrp) +1).ToString("000") + ba.guiName;
        //                    }
        //                }
        //            }
        //        }
        //        foreach (PartModule pm in p.Modules.OfType<ModuleAGExtData>())
        //        {
        //            pm.Fields.SetValue("AGXData", AddGroup);
        //        }
        //    }
        //}
        public void Update()
        {
            //Debug.Log("AGX Editor Update" + StaticData.CurrentVesselActions.Count() + "||" + EditorLogic.fetch.FSMStarted);
            if (checkShipsExist)
            {
                if (checkShipsExistDelay >= 30)
                {
                    checkShipsExist = false;
                    checkShipsExistDelay = 0;
                    CheckExistingShips();
                }
                else
                {
                    checkShipsExistDelay = checkShipsExistDelay + 1;
                }
            }

            EditorLogic ELCur = new EditorLogic();
            ELCur = EditorLogic.fetch;//get current editor logic instance

            if (AGXDoLock && ELCur.editorScreen != EditorScreen.Actions)
            {
                ELCur.Unlock("AGXLock");
                AGXDoLock = false;
            }
            else if (AGXDoLock && !TrapMouse)
            {
                ELCur.Unlock("AGXLock");
                AGXDoLock = false;
            }
            else if (!AGXDoLock && TrapMouse && ELCur.editorScreen == EditorScreen.Actions)
            {
                ELCur.Lock(false, false, false, "AGXLock");
                AGXDoLock = true;
            }

            if (ELCur.editorScreen == EditorScreen.Actions) //only show mod if on actions editor screen
            {

                ShowSelectedWin = true;
            }
            else
            {

                ShowSelectedWin = false;

                AGEditorSelectedParts.Clear();//mod is hidden, clear list so parts don't get orphaned in it

                PartActionsList.Clear();

                ActionsListDirty = true;
            }

            if (ShowSelectedWin)
            {

                if (EditorActionGroups.Instance.GetSelectedParts() != null) //on first run, list is null
                {

                    if (ActionsListDirty)
                    {
                        UpdateActionsListCheck();

                    }
                    if (EditorActionGroups.Instance.GetSelectedParts().Count > 0) //are there parts selected?
                    {

                        if (PreviousSelectedPart != EditorActionGroups.Instance.GetSelectedParts().First()) //has selected part changed?
                        {

                            if (!AGEditorSelectedParts.Any(p => p.AGPart == EditorActionGroups.Instance.GetSelectedParts().First())) //make sure selected part is not already in AGEdSelParts
                            {

                                if (AGEditorSelectedParts.Count == 0) //no items in Selected Parts list, so just add selection
                                {
                                    AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));

                                }
                                else if (AGEditorSelectedParts.First().AGPart.name == EditorActionGroups.Instance.GetSelectedParts().First().name) //selected part matches first part already in selected parts list, so just add selected part
                                {
                                    AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));

                                }
                                else //part does not match first part in list, clear list before adding part
                                {

                                    AGEditorSelectedParts.Clear();
                                    AGEditorSelectedParts.AddRange(AGXAddSelectedPart(EditorActionGroups.Instance.GetSelectedParts().First(), SelPartsIncSym));

                                }
                            }
                            PreviousSelectedPart = EditorActionGroups.Instance.GetSelectedParts().First(); //remember selected part so logic does not run unitl another part selected
                        }

                    }
                }

            }

            if (EditorLogic.fetch.editorScreen == EditorScreen.Actions && !AGXShow)
            {
                MonitorDefaultActions();
            }

            if (AGXRoot != EditorLogic.RootPart)
            {
                // print("Root diff");
                EditorLoadFromNode();
            }
            //print("detach " + DetachedPartActions.Count);
            //foreach (Part p in EditorLogic.SortedShipList)
            //{
            //    print(p.name + " " + p.symmetryCounterparts.Count + " " + p.GetHashCode());
            //}
            //Debug.Log("AGX Editor Update end" + StaticData.CurrentVesselActions.Count());
            // print("test " + FindObjectsOfType<EditorSubassemblyItem>().Count());
        }