From 1c589d0188c57d4160efe33f29db52a48e2f1682 Mon Sep 17 00:00:00 2001 From: Jonathan Bayer Date: Thu, 19 May 2016 19:46:56 -0400 Subject: [PATCH] Fixed Fine Adjustments window (inability to close it or change the values) Now saves both angle snap value and whether it was on/off after exiting editor session Fixed issue with fine adjust translation wouldn't work if snap was on --- EditorExtensionsRedux.userprefs | 16 ++-- .../EditorExtensionsRedux.cs | 15 +++- EditorExtensionsRedux/FineAdjustWindow.cs | 75 ++++++++++--------- .../Properties/AssemblyInfo.cs | 2 +- EditorExtensionsRedux/SelectRoot2Behaviour.cs | 3 - README.md | 4 + 6 files changed, 68 insertions(+), 47 deletions(-) diff --git a/EditorExtensionsRedux.userprefs b/EditorExtensionsRedux.userprefs index 8b62eeb..78da0c7 100755 --- a/EditorExtensionsRedux.userprefs +++ b/EditorExtensionsRedux.userprefs @@ -1,13 +1,13 @@  - + - + @@ -15,11 +15,13 @@ - - - - - + + + + + + + diff --git a/EditorExtensionsRedux/EditorExtensionsRedux.cs b/EditorExtensionsRedux/EditorExtensionsRedux.cs index c5f8abc..6403231 100755 --- a/EditorExtensionsRedux/EditorExtensionsRedux.cs +++ b/EditorExtensionsRedux/EditorExtensionsRedux.cs @@ -161,6 +161,8 @@ public class EditorExtensions : MonoBehaviour float orgSphZoomSens = 0; // End Fwiffo + static float lastSrfAttachAngleSnap = 15.0f; + static bool last_VAB_USE_ANGLE_SNAP = true; #endregion // public EditorExtensions (){} @@ -265,8 +267,11 @@ public void Start () GameEvents.onEditorSymmetryModeChange.Add (EditorSymmetryModeChange); - editor.srfAttachAngleSnap = 0; +// editor.srfAttachAngleSnap = 0; + editor.srfAttachAngleSnap = lastSrfAttachAngleSnap; + GameSettings.VAB_USE_ANGLE_SNAP = last_VAB_USE_ANGLE_SNAP; Log.Info ("editor.srfAttachAngleSnap: " + editor.srfAttachAngleSnap.ToString ()); + } //Unity OnDestroy @@ -535,6 +540,9 @@ void Update () // if (gizmoOffsetHandle == null) // gizmoOffsetHandle = HighLogic.FindObjectOfType (); + if (GameSettings.VAB_USE_ANGLE_SNAP) + GameEvents.onEditorSnapModeChange.Fire (false); + float offset = FineAdjustWindow.Instance.offset; Log.Info ("\nmoving part: EditorLogic.SelectedPart.attPos: " + EditorLogic.SelectedPart.attPos); @@ -1106,6 +1114,7 @@ void AngleSnapCycle (bool modKeyDown, bool fineKeyDown) editor.srfAttachAngleSnap = 0; } + //at angle snap 0, turn off angle snap and show stock circle sprite if (editor.srfAttachAngleSnap == 0) { GameSettings.VAB_USE_ANGLE_SNAP = false; @@ -1118,6 +1127,9 @@ void AngleSnapCycle (bool modKeyDown, bool fineKeyDown) GameSettings.VAB_USE_ANGLE_SNAP = true; } + lastSrfAttachAngleSnap = editor.srfAttachAngleSnap; + last_VAB_USE_ANGLE_SNAP = GameSettings.VAB_USE_ANGLE_SNAP; + updateGizmoSnaps (); // Fwiffo // Fix offset gizmo if shown @@ -1397,6 +1409,7 @@ void AdjustSnapLocations () } else { // GameSettings.VAB_USE_ANGLE_SNAP = true; } + last_VAB_USE_ANGLE_SNAP = GameSettings.VAB_USE_ANGLE_SNAP; //symmetry & angle sprite/label size and position symmetryLabelStyle.fontSize = (int)Math.Round (FONTSIZE * GameSettings.UI_SCALE); diff --git a/EditorExtensionsRedux/FineAdjustWindow.cs b/EditorExtensionsRedux/FineAdjustWindow.cs index 697042c..adfb580 100755 --- a/EditorExtensionsRedux/FineAdjustWindow.cs +++ b/EditorExtensionsRedux/FineAdjustWindow.cs @@ -44,7 +44,7 @@ public bool isEnabled() void CloseWindow () { this.enabled = false; - + Log.Info ("CloseWindow enabled: " + this.enabled.ToString ()); } void OnDisable () @@ -54,7 +54,7 @@ void OnDisable () void OnGUI () { - if (this.enabled) { + if (isEnabled() ) { _windowTitle = string.Format ("Fine Adjustments"); var tstyle = new GUIStyle (GUI.skin.window); @@ -79,6 +79,7 @@ enum AdjustmentType AdjustmentType adjType = AdjustmentType.translation; + string adjTypeStr = "Translation"; public float offset = 0.01f; public float rotation = 1.0f; public int offsetDeltaIndex = 2; @@ -101,9 +102,10 @@ float getDelta(int i) { // private string[] _toolbarStrings = { "Translation", "Rotation" }; // int toolbarInt = 0; + void WindowContent (int windowID) { - string adjTypeStr = ""; + //GUI.skin = HighLogic.Skin; var lstyle = new GUIStyle (GUI.skin.label); //var errstyle = new GUIStyle (GUI.skin.label); @@ -117,8 +119,9 @@ void WindowContent (int windowID) puc = activePuc; else puc = EditorLogic.SelectedPart; //Utility.GetPartUnderCursor (); + // toolbarInt = GUILayout.Toolbar (toolbarInt, _toolbarStrings); - adjTypeStr = "None"; + //adjTypeStr = "None"; if (GizmoEvents.offsetGizmoActive) { adjType = AdjustmentType.translation; adjTypeStr = "Translation"; @@ -134,9 +137,9 @@ void WindowContent (int windowID) GUILayout.EndHorizontal (); - GUI.DragWindow (); - if (!GizmoEvents.offsetGizmoActive && !GizmoEvents.rotateGizmoActive) - return; + + // if (!GizmoEvents.offsetGizmoActive && !GizmoEvents.rotateGizmoActive) + // return; GUILayout.BeginHorizontal (); GUILayout.Label ("Current Part:", lstyle); @@ -196,54 +199,56 @@ void WindowContent (int windowID) GUILayout.BeginHorizontal (); - if (adjType != AdjustmentType.translation || puc != EditorLogic.RootPart) - GUILayout.Label (adjTypeStr + " amount:", lstyle, GUILayout.MinWidth (150)); - if (GUILayout.Button ("-", GUILayout.Width (20))) { - switch (adjType) { - case AdjustmentType.rotation: - rotation -= getDelta(rotationdeltaIndex); - if (rotation <= 0.0f) - rotation = getDelta(rotationdeltaIndex); + if (adjType != AdjustmentType.translation || puc != EditorLogic.RootPart) { + GUILayout.Label (adjTypeStr + " amount:", lstyle, GUILayout.MinWidth (150)); + if (GUILayout.Button ("-", GUILayout.Width (20))) { + switch (adjType) { + case AdjustmentType.rotation: + rotation -= getDelta (rotationdeltaIndex); + if (rotation <= 0.0f) + rotation = getDelta (rotationdeltaIndex); - break; - case AdjustmentType.translation: - offset -= getDelta(offsetDeltaIndex); - if (offset <= 0.0f) - offset = getDelta(offsetDeltaIndex); + break; + case AdjustmentType.translation: + offset -= getDelta (offsetDeltaIndex); + if (offset <= 0.0f) + offset = getDelta (offsetDeltaIndex); - break; + break; + } } - } - switch (adjType) { - case AdjustmentType.rotation: - GUILayout.Label (rotation.ToString (), "TextField"); - break; - case AdjustmentType.translation: - GUILayout.Label (offset.ToString (), "TextField"); - break; - } - - if (GUILayout.Button ("+", GUILayout.Width (20))) { switch (adjType) { case AdjustmentType.rotation: - rotation += getDelta(rotationdeltaIndex); + GUILayout.Label (rotation.ToString (), "TextField"); break; case AdjustmentType.translation: - offset += getDelta(offsetDeltaIndex); + GUILayout.Label (offset.ToString (), "TextField"); break; } + if (GUILayout.Button ("+", GUILayout.Width (20))) { + switch (adjType) { + case AdjustmentType.rotation: + rotation += getDelta (rotationdeltaIndex); + break; + case AdjustmentType.translation: + offset += getDelta (offsetDeltaIndex); + break; + } + + } } GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("Done")) { + Log.Info ("Done"); fineAdjustActive = false; InputLockManager.RemoveControlLock ("EEX_FA"); CloseWindow (); } GUILayout.EndHorizontal (); - + GUI.DragWindow (); } diff --git a/EditorExtensionsRedux/Properties/AssemblyInfo.cs b/EditorExtensionsRedux/Properties/AssemblyInfo.cs index bdd8521..55e1b77 100755 --- a/EditorExtensionsRedux/Properties/AssemblyInfo.cs +++ b/EditorExtensionsRedux/Properties/AssemblyInfo.cs @@ -10,5 +10,5 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("3.2.12.*")] +[assembly: AssemblyVersion("3.2.13.*")] diff --git a/EditorExtensionsRedux/SelectRoot2Behaviour.cs b/EditorExtensionsRedux/SelectRoot2Behaviour.cs index 01dfb11..1b95993 100755 --- a/EditorExtensionsRedux/SelectRoot2Behaviour.cs +++ b/EditorExtensionsRedux/SelectRoot2Behaviour.cs @@ -93,7 +93,6 @@ public void Start() { }; st_root_select.OnEnter += fixAlreadyHoveringPartFn; OnCleanup += () => { - Log.Info("SelectRoot OnCleanup 1"); st_root_select.OnEnter -= fixAlreadyHoveringPartFn; }; @@ -106,7 +105,6 @@ public void Start() { st_root_select.OnEnter += postNewMessageFn; OnCleanup += () => { - Log.Info("SelectRoot OnCleanup 2"); st_root_select.OnEnter -= postNewMessageFn; }; @@ -174,7 +172,6 @@ private void InjectEvent(KFSMState state, KFSMEvent injectedEvent) { state.AddEvent(injectedEvent); OnCleanup += () => { // ((List)Refl.GetValue(state, "stateEvents")).Remove(injectedEvent); - Log.Info("SelectRoot OnCleanup 3"); // List kfsmstatelist = (List)Refl.GetValue(state, GET_STATEEVENTS); #if false foreach(var kfsmstate in kfsmstatelist) diff --git a/README.md b/README.md index ef445bf..3323339 100755 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ ## ## +## Changes in 3.2.13 + Fixed Fine Adjustments window (inability to close it or change the values) + Now saves both angle snap value and whether it was on/off after exiting editor session + ## Changes in 3.2.12 Fixed rotation gizmo to not angle snap when anglesnap is off Replaced code which did FindObjectsOftype with GizmoEvents class for performance improvement