Skip to content

Commit

Permalink
Added code to toggle no offset limit to settings window
Browse files Browse the repository at this point in the history
Fixed code for toggling the no offset Limit
Added automatic updating of AssemblyVersion, from the .version file,
displayed in the Settings window
Removed extra set of configs for the Reflection offsets
Fixed bug with local offset vs absolute offset;  Code was not using the
local setting, was always using the absolute setting
  • Loading branch information
linuxgurugamer committed Nov 6, 2016
1 parent 0f44ab0 commit 33411b8
Show file tree
Hide file tree
Showing 10 changed files with 247 additions and 87 deletions.
8 changes: 8 additions & 0 deletions EditorExtensionsRedux/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyVersion("3.3.7.0")]
81 changes: 81 additions & 0 deletions EditorExtensionsRedux/AssemblyFileVersion.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ import namespace="System.IO" #>
<#@ output extension=".cs" #>

<#@ assembly name="EnvDTE" #><# /* This assembly provides access to Visual Studio project properties. */ #>
<#

// Instructions
// 1. Add a new Text Template to the project
// 2. Copy this file into the new template
// 3. Update the string: versionfile with the complete path to the .version file
// 4. Remove the following line from the file AssemblyInfo.cs (usually located in the "Property" folder inside your C# project):
// [assembly: AssemblyFileVersion("1.0.0.0")]
// 5. Add the following to the PreBuild steps:
// set textTemplatingPath="%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
//
// if %textTemplatingPath%=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%CommonProgramFiles%\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"
//
// %textTemplatingPath% "$(ProjectDir)AssemblyFileVersion.tt"

int major = 0;
int minor = 0;
int build = 0;
int patch = 0;

int i = 0;
int i2 = 0;
string s;

string versionfile = @"D:\Users\jbb\github\EditorExtensionsRedux\EditorExtensionsRedux\EditorExtensionsRedux.version";
if (!File.Exists(versionfile))
{
Write("File: " + versionfile + " missing\n");
}

try
{
foreach (var line in File.ReadAllLines(versionfile))
{
if (line != null)
{

i = line.IndexOf(":");
i2 = line.IndexOf(",");
if (i >= 0 && i2 >= 0)
{
s = line.Substring(i + 1, i2 - i - 1);

if (major == 0 && line.Contains("MAJOR"))
Int32.TryParse(s, out major);

if (minor == 0 && line.Contains("MINOR"))
Int32.TryParse(s, out minor);

if (patch == 0 && line.Contains("PATCH"))
Int32.TryParse(s, out patch);

if (build == 0 && line.Contains("BUILD"))
Int32.TryParse(s, out build);
}
}
}

}
catch
{
major = 1;
minor = 0;
patch = 0;
build = 0;
}
//Write("File done");

#>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyVersion("<#= major #>.<#= minor #>.<#= patch #>.<#= build #>")]
5 changes: 4 additions & 1 deletion EditorExtensionsRedux/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public static ConfigData CreateDefaultConfig (string configFilePath, string vers
FileVersion = version,
OnScreenMessageTime = 1.5f,
ShowDebugInfo = true,
ReRootEnabled = true
ReRootEnabled = true,
NoOffsetLimitEnabled = true,
AnglesnapModIsToggle = true,
CycleSymmetryModeModIsToggle = true
};

KeyMaps defaultKeys = new KeyMaps () {
Expand Down
31 changes: 20 additions & 11 deletions EditorExtensionsRedux/EditorExtensionsRedux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Constants
public int ST_OFFSET_TWEAK = 73;
public int SYMUPDATEATTACHNODE = 108;
public int GIZMOOFFSET = 66;
public int GIZMOROTATE = 67;

public int UPDATESYMMETRY = 64;
public int ONOFFSETGIZMOUPDATED = 35;
Expand Down Expand Up @@ -203,6 +204,7 @@ 12 ssScaling
// NoOffsetLimits
ST_OFFSET_TWEAK = 75;
SYMUPDATEATTACHNODE = 110;
GIZMOROTATE = 67;
GIZMOOFFSET = 68;

UPDATESYMMETRY = 61;
Expand Down Expand Up @@ -430,6 +432,9 @@ public void Start()
GameEvents.onEditorPartEvent.Add(EditorPartEvent);
GameEvents.onEditorSymmetryModeChange.Add(EditorSymmetryModeChange);

EditorExtensionsRedux.NoOffsetBehaviour.FreeOffsetBehaviour fob = new NoOffsetBehaviour.FreeOffsetBehaviour();
fob.Start();
fob.OnDestroy();


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

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

ConstructionEventType lastEventType = ConstructionEventType.Unknown;
Expand Down Expand Up @@ -865,7 +871,7 @@ void Update()
}
}
// NoOffsetBehaviour.FreeOffsetBehaviour
if (cfg.ReRootEnabled)
if (cfg.NoOffsetLimitEnabled)
{
if (Input.GetKeyDown(cfg.KeyMap.ToggleNoOffsetLimit))
{
Expand Down Expand Up @@ -966,6 +972,7 @@ void Update()

}
MoveParts();
#if true
if (_fineAdjustWindow.isEnabled())
{
Vector3 axis;
Expand Down Expand Up @@ -1065,6 +1072,7 @@ public class Config
Refl.Invoke(GizmoEvents.gizmosOffset[0], EditorExtensions.c.GIZMOOFFSET_ONHANDLEMOVEEND, GizmoEvents.gizmoOffsetHandle, axis, 0.0f);

}

}
else
{
Expand Down Expand Up @@ -1159,7 +1167,7 @@ public class Config
}
}
}

#endif

}//end if(enableHotKeys)

Expand Down Expand Up @@ -1197,7 +1205,7 @@ bool IsPartNodeAttached(Part p)
return false;
}

#region Alignments
#region Alignments

void AlignToTopOfParent(Part p)
{
Expand Down Expand Up @@ -1595,9 +1603,9 @@ void AlignCompoundPart(CompoundPart part, bool snapHeights)
}
}

#endregion
#endregion

#region Editor Actions
#region Editor Actions

void AddUndo()
{
Expand Down Expand Up @@ -1876,9 +1884,9 @@ bool GizmoActive()
}
}

#endregion
#endregion

#region GUI
#region GUI

//private Rect _settingsWindowRect;
GUIStyle osdLabelStyle, symmetryLabelStyle;
Expand Down Expand Up @@ -2070,12 +2078,13 @@ void MenuContent(int WindowID)
_settingsWindow.Show(cfg, _configFilePath, pluginVersion);
this.Visible = true;
}
#if true
if (GUILayout.Button("Fine Adjust"))
{
_fineAdjustWindow.Show();

}

#endif
if (cfg.ShowDebugInfo)
{
if (GUILayout.Button("Position Debug"))
Expand Down Expand Up @@ -2272,7 +2281,7 @@ void OSDMessage(string message)
ScreenMessages.PostScreenMessage(message, cfg.OnScreenMessageTime, ScreenMessageStyle.LOWER_CENTER);
}

#region Snap labels
#region Snap labels

const int FONTSIZE = 14;

Expand Down Expand Up @@ -2456,8 +2465,8 @@ private void ShowSnapLabels()
}
}

#endregion
#endregion

#endregion
#endregion
}
}
26 changes: 26 additions & 0 deletions EditorExtensionsRedux/EditorExtensionsRedux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
<AssemblyName>EditorExtensionsRedux</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ReleaseVersion>2.0</ReleaseVersion>
<AssemblyInfoFilePath>Properties\AssemblyInfo.cs</AssemblyInfoFilePath>
<UpdateAssemblyVersion>False</UpdateAssemblyVersion>
<UpdateAssemblyFileVersion>False</UpdateAssemblyFileVersion>
<UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
<AssemblyVersionSettings>
</AssemblyVersionSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
Expand Down Expand Up @@ -41,6 +47,11 @@
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyFileVersion.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyFileVersion.tt</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="EditorExtensionsRedux.cs" />
<Compile Include="Logging.cs" />
Expand Down Expand Up @@ -69,6 +80,10 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Content Include="AssemblyFileVersion.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>AssemblyFileVersion.cs</LastGenOutput>
</Content>
<Content Include="License.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -124,6 +139,9 @@
<HintPath>R:\KSP_1.1.4_dev\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>start /D D:\Users\jbb\github\EditorExtensionsRedux\EditorExtensionsRedux /WAIT deploy.bat

Expand All @@ -132,4 +150,12 @@ start /D D:\Users\jbb\github\EditorExtensionsRedux\EditorExtensionsRedux /WAIT
)
</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>set textTemplatingPath="%25CommonProgramFiles(x86)%25\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"

if %25textTemplatingPath%25=="\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe" set textTemplatingPath="%25CommonProgramFiles%25\Microsoft Shared\TextTemplating\$(VisualStudioVersion)\texttransform.exe"

%25textTemplatingPath%25 "$(ProjectDir)AssemblyFileVersion.tt"
</PreBuildEvent>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions EditorExtensionsRedux/EditorExtensionsRedux.version
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"MAJOR":3,
"MINOR":3,
"PATCH":6,
"PATCH":7,
"BUILD":0
},
"KSP_VERSION":
Expand All @@ -27,4 +27,4 @@
"MINOR":2,
"PATCH":1
}
}
}
3 changes: 2 additions & 1 deletion EditorExtensionsRedux/FineAdjustWindow.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using UnityEngine;


#if true
namespace EditorExtensionsRedux
{
public class FineAdjustWindow : MonoBehaviour
Expand Down Expand Up @@ -311,3 +311,4 @@ public void Show ()

}

#endif
Loading

0 comments on commit 33411b8

Please sign in to comment.