diff --git a/Gamedata/TweakScale/RealChute_TweakScale.cfg b/Gamedata/TweakScale/RealChute_TweakScale.cfg index e322607d..9d727ca2 100644 --- a/Gamedata/TweakScale/RealChute_TweakScale.cfg +++ b/Gamedata/TweakScale/RealChute_TweakScale.cfg @@ -1,35 +1 @@ -@PART[RC_cone] // RealChute Cone Chute -{ - MODULE - { - name = TweakScale - type = stack - defaultScale = 1.25 - } -} -@PART[RC_cone_double] // RealChute Cone Double Chute -{ - MODULE - { - name = TweakScale - type = stack - defaultScale = 1.25 - } -} -@PART[RC_radial] // RealChute Radial Chute -{ - MODULE - { - name = TweakScale - type = surface - } -} -@PART[RC_stack] // RealChute Stack Chute -{ - MODULE - { - name = TweakScale - type = stack - defaultScale = 1.25 - } -} \ No newline at end of file +TWEAKSCALE_DUMMY = IGNORE_THIS_FILE \ No newline at end of file diff --git a/Gamedata/TweakScale/ScaleExponents.cfg b/Gamedata/TweakScale/ScaleExponents.cfg index 63b17419..29d15853 100644 --- a/Gamedata/TweakScale/ScaleExponents.cfg +++ b/Gamedata/TweakScale/ScaleExponents.cfg @@ -12,7 +12,7 @@ TWEAKSCALEEXPONENTS Resources { !amount = 3 - maxAmount = 3 + !maxAmount = 3 -ignore = ModuleFuelTanks } @@ -26,7 +26,7 @@ TWEAKSCALEEXPONENTS TWEAKSCALEEXPONENTS { name = TweakScale - !dryCost = 3 + !DryCost = 3 } TWEAKSCALEEXPONENTS diff --git a/Gamedata/TweakScale/plugins/Scale.dll b/Gamedata/TweakScale/plugins/Scale.dll index 34840c8b..d875efd4 100644 Binary files a/Gamedata/TweakScale/plugins/Scale.dll and b/Gamedata/TweakScale/plugins/Scale.dll differ diff --git a/MemberUpdater.cs b/MemberUpdater.cs index eb6c6461..b3a5387f 100644 --- a/MemberUpdater.cs +++ b/MemberUpdater.cs @@ -6,10 +6,11 @@ namespace TweakScale { public class MemberUpdater { - readonly object _object; - readonly FieldInfo _field; - readonly PropertyInfo _property; - readonly UI_FloatRange _floatRange; + private readonly object _object; + private readonly FieldInfo _field; + private readonly PropertyInfo _property; + private readonly UI_FloatRange _floatRange; + private const BindingFlags LookupFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public static MemberUpdater Create(object obj, string name) { @@ -18,8 +19,8 @@ public static MemberUpdater Create(object obj, string name) return null; } var objectType = obj.GetType(); - var field = objectType.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - var property = objectType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + var field = objectType.GetField(name, LookupFlags); + var property = objectType.GetProperty(name, LookupFlags); UI_FloatRange floatRange = null; if (obj is PartModule) { @@ -90,6 +91,12 @@ public Type MemberType public void Set(object value) { + if (value.GetType() != MemberType && MemberType.GetInterface("IConvertible") != null && + value.GetType().GetInterface("IConvertible") != null) + { + value = Convert.ChangeType(value, MemberType); + } + if (_field != null) { _field.SetValue(_object, value); @@ -110,13 +117,13 @@ public void Scale(double scale, MemberUpdater source) var newValue = Value; if (MemberType == typeof(float)) { - Set((float)newValue * (float)scale); RescaleFloatRange((float)scale); + Set((float)newValue * (float)scale); } else if (MemberType == typeof(double)) { - Set((double)newValue * scale); RescaleFloatRange((float)scale); + Set((double)newValue * scale); } else if (MemberType == typeof(Vector3)) { @@ -134,5 +141,20 @@ private void RescaleFloatRange(float factor) _floatRange.minValue *= factor; _floatRange.stepIncrement *= factor; } + + public string Name { + get + { + if (_field != null) + { + return _field.Name; + } + if (_property != null) + { + return _property.Name; + } + return null; + } + } } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index cecaffcb..a53b1454 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.46.0.0")] -[assembly: AssemblyFileVersion("1.46.0.0")] +[assembly: AssemblyVersion("1.47.0.0")] +[assembly: AssemblyFileVersion("1.47.0.0")] diff --git a/Scale.cs b/Scale.cs index 20126d29..cf249944 100644 --- a/Scale.cs +++ b/Scale.cs @@ -501,7 +501,6 @@ public void Update() var ts = part.parent.Modules.OfType().FirstOrDefault(); if ((object)ts != null && ts.Config == Config) { - Tools.Logf("Changing size based on parent! ts: {0} this: {1}", ts.Config.Name, Config.Name); tweakName = ts.tweakName; tweakScale = ts.tweakScale; } diff --git a/ScaleExponents.cs b/ScaleExponents.cs index e58435c9..68ea4f84 100644 --- a/ScaleExponents.cs +++ b/ScaleExponents.cs @@ -231,7 +231,15 @@ static private void Rescale(MemberUpdater current, MemberUpdater baseValue, stri if (values != null) { - current.Set(values[factor.index]); + if (current.MemberType == typeof (float)) + { + current.Set((float)values[factor.index]); + } + else if (current.MemberType == typeof(float)) + { + current.Set(values[factor.index]); + } + } else if (!double.IsNaN(exponent)) {