Skip to content

Commit

Permalink
Version 1.47
Browse files Browse the repository at this point in the history
  • Loading branch information
Biotronic committed Nov 17, 2014
1 parent 0a5a30c commit f059345
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 49 deletions.
36 changes: 1 addition & 35 deletions Gamedata/TweakScale/RealChute_TweakScale.cfg
Original file line number Diff line number Diff line change
@@ -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
}
}
TWEAKSCALE_DUMMY = IGNORE_THIS_FILE
4 changes: 2 additions & 2 deletions Gamedata/TweakScale/ScaleExponents.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TWEAKSCALEEXPONENTS
Resources
{
!amount = 3
maxAmount = 3
!maxAmount = 3
-ignore = ModuleFuelTanks
}

Expand All @@ -26,7 +26,7 @@ TWEAKSCALEEXPONENTS
TWEAKSCALEEXPONENTS
{
name = TweakScale
!dryCost = 3
!DryCost = 3
}

TWEAKSCALEEXPONENTS
Expand Down
Binary file modified Gamedata/TweakScale/plugins/Scale.dll
Binary file not shown.
38 changes: 30 additions & 8 deletions MemberUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand All @@ -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))
{
Expand All @@ -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;
}
}
}
}
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
1 change: 0 additions & 1 deletion Scale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ public void Update()
var ts = part.parent.Modules.OfType<TweakScale>().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;
}
Expand Down
10 changes: 9 additions & 1 deletion ScaleExponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down

0 comments on commit f059345

Please sign in to comment.