Skip to content

Commit

Permalink
Version 1.45
Browse files Browse the repository at this point in the history
  • Loading branch information
Biotronic committed Nov 15, 2014
1 parent c349c42 commit e418c6d
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
/Scale_Editor/bin
/Scale_Editor/obj
/lib
/Releases
/Releases
/Gamedata/TweakScale/plugins/Scale_Editor.dll
56 changes: 47 additions & 9 deletions Gamedata/TweakScale/ScaleExponents.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ TWEAKSCALEEXPONENTS
effectSize2 = 1
}

TWEAKSCALEEXPONENTS
{
name = FNNozzleController
radius = 1
}

TWEAKSCALEEXPONENTS
{
name = AntimatterStorageTank
Expand Down Expand Up @@ -345,14 +339,12 @@ TWEAKSCALEEXPONENTS
{
name = FNNozzleController
radius = 1
engineMaxThrust = 2
}

TWEAKSCALEEXPONENTS
{
name = FNNozzleControllerFX
radius = 1
engineMaxThrust = 2
}

TWEAKSCALEEXPONENTS
Expand Down Expand Up @@ -439,4 +431,50 @@ TWEAKSCALEEXPONENTS
lockMinDist = 1
maxLenght = 1
powerDrain = 2
}
}

TWEAKSCALEEXPONENTS
{
name = ModuleTweakableDecouple
ejectionForce = 2
}

TWEAKSCALEEXPONENTS
{
name = ModuleTweakableDockingNode
acquireRange = 1
acquireForce = 2
acquireTorque = 2
undockEjectionForce = 2
minDistanceToReEngage = 1
}

TWEAKSCALEEXPONENTS
{
name = ModuleTweakableEVA
thrusterPowerThrottle = 1
}

TWEAKSCALEEXPONENTS
{
name = ModuleTweakableReactionWheel
RollTorque = 3
PitchTorque = 3
YawTorque = 3
}

TWEAKSCALEEXPONENTS
{
name = FSfuelSwitch
tankList
{
resources
{
!amount = 3
!maxAmount = 3
}
}
weightList = 3
tankCostList = 3
}

Binary file modified Gamedata/TweakScale/plugins/Scale.dll
Binary file not shown.
Binary file removed Gamedata/TweakScale/plugins/Scale_FAR.dll
Binary file not shown.
Binary file removed Gamedata/TweakScale/plugins/Scale_KAS.dll
Binary file not shown.
Binary file not shown.
Binary file removed Gamedata/TweakScale/plugins/TweakScale_FAR.dll
Binary file not shown.
Binary file not shown.
85 changes: 64 additions & 21 deletions MemberUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,51 @@ public class MemberUpdater
object _object = null;
FieldInfo _field = null;
PropertyInfo _property = null;
UI_FloatRange _floatRange = null;

public MemberUpdater(object obj, string name)
public static MemberUpdater Create(object obj, string name)
{
if (obj == null)
{
return;
return null;
}

var objectType = obj.GetType();
_object = obj;
_field = objectType.GetField(name, BindingFlags.Instance | BindingFlags.Public);
_property = objectType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
var field = objectType.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
var property = objectType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
UI_FloatRange floatRange = null;
if (obj is PartModule)
{
var fieldData = (obj as PartModule).Fields[name];
if ((object)fieldData != null)
{
var ctrl = fieldData.uiControlEditor;
if (ctrl is UI_FloatRange)
{
floatRange = ctrl as UI_FloatRange;
}
}
}

if (_property != null && _property.GetIndexParameters().Length > 0)
if (property != null && property.GetIndexParameters().Length > 0)
{
Tools.LogWf("Property {0} on {1} requires indices, which TweakScale currently does not support.", name, objectType.Name);
_property = null;
return null;
}
if (_field == null && _property == null)
if (field == null && property == null)
{
Tools.LogWf("No valid member found for {0} in {1}", name, objectType.Name);
return null;
}

return new MemberUpdater(obj, field, property, floatRange);
}

private MemberUpdater(object obj, FieldInfo field, PropertyInfo property, UI_FloatRange floatRange)
{
_object = obj;
_field = field;
_property = property;
_floatRange = floatRange;
}

public object Value
Expand All @@ -55,6 +78,22 @@ public object Value
}
}

public Type MemberType
{
get
{
if (_field != null)
{
return _field.FieldType;
}
else if (_property != null)
{
return _property.PropertyType;
}
return null;
}
}

public void Set(object value)
{
if (_field != null)
Expand All @@ -67,14 +106,6 @@ public void Set(object value)
}
}

public Type MemberType
{
get
{
return _field == null ? _field.FieldType : _property.PropertyType;
}
}

public void Scale(double scale, MemberUpdater source)
{
if (_field == null && _property == null)
Expand All @@ -85,17 +116,29 @@ public void Scale(double scale, MemberUpdater source)
object newValue = Value;
if (MemberType == typeof(float))
{
newValue = (float)newValue * (float)scale;
Set((float)newValue * (float)scale);
RescaleFloatRange((float)scale);
}
else if (MemberType == typeof(double))
{
newValue = (double)newValue * scale;
Set((double)newValue * scale);
RescaleFloatRange((float)scale);
}
else if (MemberType == typeof(Vector3))
{
newValue = (Vector3)newValue * (float)scale;
Set((Vector3)newValue * (float)scale);
}
}

private void RescaleFloatRange(float factor)
{
if ((object)_floatRange == null)
{
return;
}
Set(newValue);
_floatRange.maxValue *= factor;
_floatRange.minValue *= factor;
_floatRange.stepIncrement *= factor;
}
}
}
12 changes: 12 additions & 0 deletions Scale.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_Editor", "Scale_Edito
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_TweakableEverything", "Scale_TweakableEverything\Scale_TweakableEverything.csproj", "{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_FS", "Scale_FS\Scale_FS.csproj", "{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_FAR", "Scale_FAR\Scale_FAR.csproj", "{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +37,14 @@ Global
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Release|Any CPU.Build.0 = Release|Any CPU
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Release|Any CPU.Build.0 = Release|Any CPU
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit e418c6d

Please sign in to comment.