Skip to content

Commit

Permalink
Fixed the no offset limit local/absolute change the correct way
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxgurugamer committed Nov 9, 2016
1 parent 0566ec9 commit 97269b9
Show file tree
Hide file tree
Showing 17 changed files with 3,076 additions and 339 deletions.
6 changes: 0 additions & 6 deletions EditorExtensionsRedux.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "BetaPackage", "Packagers\BetaPackage.mdproj", "{B4D5E5A2-8B35-4CF3-BDFF-0DF9A687AE20}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NoOffsetLimits", "NoOffsetLimits\NoOffsetLimits.csproj", "{3368802B-CBC6-4DEA-A68C-3B238C43AF4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,10 +25,6 @@ Global
{BCEB9124-390F-49D5-9022-49EBAB6446F7}.Release|Any CPU.Build.0 = Release|Any CPU
{B4D5E5A2-8B35-4CF3-BDFF-0DF9A687AE20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4D5E5A2-8B35-4CF3-BDFF-0DF9A687AE20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3368802B-CBC6-4DEA-A68C-3B238C43AF4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3368802B-CBC6-4DEA-A68C-3B238C43AF4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3368802B-CBC6-4DEA-A68C-3B238C43AF4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3368802B-CBC6-4DEA-A68C-3B238C43AF4A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion EditorExtensionsRedux/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

using System.Reflection;

[assembly: AssemblyVersion("3.3.8.0")]
[assembly: AssemblyVersion("3.3.9.0")]
41 changes: 24 additions & 17 deletions EditorExtensionsRedux/EditorExtensionsRedux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public class EditorExtensions : MonoBehaviour

public bool Visible { get; set; }

public NoOffsetBehaviour.FreeOffsetBehaviour fob;

#region member vars


Expand Down Expand Up @@ -424,12 +426,6 @@ public void Start()
#endif
editor = EditorLogic.fetch;
Instance = this;

// FreeOffsetBehaviour needs to be initialized before InitConfig
EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour fob = new NoOffsetBehaviour.FreeOffsetBehaviour();
// Following needed to get it in memory
fob.Start();
fob.OnDestroy();
InitConfig();

if (!validVersion)
Expand All @@ -439,7 +435,8 @@ public void Start()
GameEvents.onEditorPartEvent.Add(EditorPartEvent);
GameEvents.onEditorSymmetryModeChange.Add(EditorSymmetryModeChange);


if (cfg.NoOffsetLimitEnabled)
fob = gameObject.AddComponent<NoOffsetBehaviour.FreeOffsetBehaviour>();


// editor.srfAttachAngleSnap = 0;
Expand All @@ -466,6 +463,7 @@ void OnDestroy()

GameEvents.onEditorPartEvent.Remove(EditorPartEvent);
GameEvents.onEditorSymmetryModeChange.Remove(EditorSymmetryModeChange);
Destroy(fob);
NoOffsetBehaviour.FreeOffsetBehaviour.Instance = null;
}

Expand Down Expand Up @@ -592,12 +590,7 @@ void InitConfig()

ReRootActive = cfg.ReRootEnabled;
NoOffsetLimit = cfg.NoOffsetLimitEnabled;
if (cfg.NoOffsetLimitEnabled)
{
Log.Info("InitConfig NoOffsetLimitEnabled is true");
EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour.Instance.Start();
}


Log.Debug("Initializing version " + pluginVersion.ToString());
}
catch (Exception ex)
Expand Down Expand Up @@ -891,7 +884,8 @@ void Update()
if (NoOffsetLimit)
{
OSDMessage(string.Format("No Offset Limit is active"));
EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour.Instance.Start();
NoOffsetBehaviour.FreeOffsetBehaviour fob = gameObject.AddComponent<NoOffsetBehaviour.FreeOffsetBehaviour>();

}
else
{
Expand All @@ -900,7 +894,9 @@ void Update()
if (p != null)
OSDMessage(string.Format("Change will take effect after deselecting current part"));
// GameEvents.onEditorPartPlaced.Fire(p);
EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour.Instance.OnDestroy();
Destroy(fob);
NoOffsetBehaviour.FreeOffsetBehaviour.Instance = null;

// if (p != null)
// GameEvents.onEditorPartPicked.Fire(p);
}
Expand Down Expand Up @@ -2087,9 +2083,20 @@ void MenuContent(int WindowID)
if (_showMenu || _menuRect.Contains(Event.current.mousePosition))
lastTimeShown = Time.fixedTime;
GUILayout.BeginVertical();
if (GUILayout.Button("Show Angle Snaps"))
if (_showAngleSnaps.isVisible())
{
_showAngleSnaps.Show(cfg);
if (GUILayout.Button("Show Angle Snaps"))
{
_showAngleSnaps.Hide();
}

}
else
{
if (GUILayout.Button("Show Angle Snaps"))
{
_showAngleSnaps.Show(cfg);
}
}
GUILayout.EndVertical();

Expand Down
Loading

0 comments on commit 97269b9

Please sign in to comment.