Skip to content

Commit e418c6d

Browse files
committed
Version 1.45
1 parent c349c42 commit e418c6d

11 files changed

Lines changed: 188 additions & 62 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
/Scale_Editor/bin
1515
/Scale_Editor/obj
1616
/lib
17-
/Releases
17+
/Releases
18+
/Gamedata/TweakScale/plugins/Scale_Editor.dll

Gamedata/TweakScale/ScaleExponents.cfg

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,6 @@ TWEAKSCALEEXPONENTS
265265
effectSize2 = 1
266266
}
267267

268-
TWEAKSCALEEXPONENTS
269-
{
270-
name = FNNozzleController
271-
radius = 1
272-
}
273-
274268
TWEAKSCALEEXPONENTS
275269
{
276270
name = AntimatterStorageTank
@@ -345,14 +339,12 @@ TWEAKSCALEEXPONENTS
345339
{
346340
name = FNNozzleController
347341
radius = 1
348-
engineMaxThrust = 2
349342
}
350343

351344
TWEAKSCALEEXPONENTS
352345
{
353346
name = FNNozzleControllerFX
354347
radius = 1
355-
engineMaxThrust = 2
356348
}
357349

358350
TWEAKSCALEEXPONENTS
@@ -439,4 +431,50 @@ TWEAKSCALEEXPONENTS
439431
lockMinDist = 1
440432
maxLenght = 1
441433
powerDrain = 2
442-
}
434+
}
435+
436+
TWEAKSCALEEXPONENTS
437+
{
438+
name = ModuleTweakableDecouple
439+
ejectionForce = 2
440+
}
441+
442+
TWEAKSCALEEXPONENTS
443+
{
444+
name = ModuleTweakableDockingNode
445+
acquireRange = 1
446+
acquireForce = 2
447+
acquireTorque = 2
448+
undockEjectionForce = 2
449+
minDistanceToReEngage = 1
450+
}
451+
452+
TWEAKSCALEEXPONENTS
453+
{
454+
name = ModuleTweakableEVA
455+
thrusterPowerThrottle = 1
456+
}
457+
458+
TWEAKSCALEEXPONENTS
459+
{
460+
name = ModuleTweakableReactionWheel
461+
RollTorque = 3
462+
PitchTorque = 3
463+
YawTorque = 3
464+
}
465+
466+
TWEAKSCALEEXPONENTS
467+
{
468+
name = FSfuelSwitch
469+
tankList
470+
{
471+
resources
472+
{
473+
!amount = 3
474+
!maxAmount = 3
475+
}
476+
}
477+
weightList = 3
478+
tankCostList = 3
479+
}
480+
1 KB
Binary file not shown.
-4.5 KB
Binary file not shown.
-4.5 KB
Binary file not shown.
-6.5 KB
Binary file not shown.
-4 KB
Binary file not shown.
Binary file not shown.

MemberUpdater.cs

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,51 @@ public class MemberUpdater
1212
object _object = null;
1313
FieldInfo _field = null;
1414
PropertyInfo _property = null;
15+
UI_FloatRange _floatRange = null;
1516

16-
public MemberUpdater(object obj, string name)
17+
public static MemberUpdater Create(object obj, string name)
1718
{
1819
if (obj == null)
1920
{
20-
return;
21+
return null;
2122
}
22-
2323
var objectType = obj.GetType();
24-
_object = obj;
25-
_field = objectType.GetField(name, BindingFlags.Instance | BindingFlags.Public);
26-
_property = objectType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public);
24+
var field = objectType.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
25+
var property = objectType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
26+
UI_FloatRange floatRange = null;
27+
if (obj is PartModule)
28+
{
29+
var fieldData = (obj as PartModule).Fields[name];
30+
if ((object)fieldData != null)
31+
{
32+
var ctrl = fieldData.uiControlEditor;
33+
if (ctrl is UI_FloatRange)
34+
{
35+
floatRange = ctrl as UI_FloatRange;
36+
}
37+
}
38+
}
2739

28-
if (_property != null && _property.GetIndexParameters().Length > 0)
40+
if (property != null && property.GetIndexParameters().Length > 0)
2941
{
3042
Tools.LogWf("Property {0} on {1} requires indices, which TweakScale currently does not support.", name, objectType.Name);
31-
_property = null;
43+
return null;
3244
}
33-
if (_field == null && _property == null)
45+
if (field == null && property == null)
3446
{
3547
Tools.LogWf("No valid member found for {0} in {1}", name, objectType.Name);
48+
return null;
3649
}
50+
51+
return new MemberUpdater(obj, field, property, floatRange);
52+
}
53+
54+
private MemberUpdater(object obj, FieldInfo field, PropertyInfo property, UI_FloatRange floatRange)
55+
{
56+
_object = obj;
57+
_field = field;
58+
_property = property;
59+
_floatRange = floatRange;
3760
}
3861

3962
public object Value
@@ -55,6 +78,22 @@ public object Value
5578
}
5679
}
5780

81+
public Type MemberType
82+
{
83+
get
84+
{
85+
if (_field != null)
86+
{
87+
return _field.FieldType;
88+
}
89+
else if (_property != null)
90+
{
91+
return _property.PropertyType;
92+
}
93+
return null;
94+
}
95+
}
96+
5897
public void Set(object value)
5998
{
6099
if (_field != null)
@@ -67,14 +106,6 @@ public void Set(object value)
67106
}
68107
}
69108

70-
public Type MemberType
71-
{
72-
get
73-
{
74-
return _field == null ? _field.FieldType : _property.PropertyType;
75-
}
76-
}
77-
78109
public void Scale(double scale, MemberUpdater source)
79110
{
80111
if (_field == null && _property == null)
@@ -85,17 +116,29 @@ public void Scale(double scale, MemberUpdater source)
85116
object newValue = Value;
86117
if (MemberType == typeof(float))
87118
{
88-
newValue = (float)newValue * (float)scale;
119+
Set((float)newValue * (float)scale);
120+
RescaleFloatRange((float)scale);
89121
}
90122
else if (MemberType == typeof(double))
91123
{
92-
newValue = (double)newValue * scale;
124+
Set((double)newValue * scale);
125+
RescaleFloatRange((float)scale);
93126
}
94127
else if (MemberType == typeof(Vector3))
95128
{
96-
newValue = (Vector3)newValue * (float)scale;
129+
Set((Vector3)newValue * (float)scale);
130+
}
131+
}
132+
133+
private void RescaleFloatRange(float factor)
134+
{
135+
if ((object)_floatRange == null)
136+
{
137+
return;
97138
}
98-
Set(newValue);
139+
_floatRange.maxValue *= factor;
140+
_floatRange.minValue *= factor;
141+
_floatRange.stepIncrement *= factor;
99142
}
100143
}
101144
}

Scale.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_Editor", "Scale_Edito
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_TweakableEverything", "Scale_TweakableEverything\Scale_TweakableEverything.csproj", "{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}"
1313
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_FS", "Scale_FS\Scale_FS.csproj", "{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scale_FAR", "Scale_FAR\Scale_FAR.csproj", "{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}"
17+
EndProject
1418
Global
1519
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1620
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +37,14 @@ Global
3337
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
3438
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
3539
{5CFCCBB6-528C-4E96-93BB-829AC621DC2A}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{FC9D7E8E-9C06-4F09-8647-967C7355AA9A}.Release|Any CPU.Build.0 = Release|Any CPU
44+
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
45+
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
46+
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
47+
{AC68606D-F655-4524-8A1B-EFFDFC87F2C6}.Release|Any CPU.Build.0 = Release|Any CPU
3648
EndGlobalSection
3749
GlobalSection(SolutionProperties) = preSolution
3850
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)