From e2cf2c1d6b44634a4027cb13de0204e351df414a Mon Sep 17 00:00:00 2001 From: Robert French Date: Sun, 7 Sep 2014 03:46:32 -0400 Subject: [PATCH] Added scaleNodes option to be used in configs under SCALETYPE --- Scale.cs | 17 ++++++++++++-- Scale.csproj | 23 +++++++++++-------- ScaleConfig.cs | 11 +++++++++ Scale_Editor/Scale_Editor.csproj | 23 +++++++++++-------- Scale_Redist/Scale_Redist.csproj | 10 ++++---- .../TweakScale_ModularFuelTanks.csproj | 20 +++++++++------- .../TweakScale_RealFuels.csproj | 19 +++++++++------ 7 files changed, 82 insertions(+), 41 deletions(-) diff --git a/Scale.cs b/Scale.cs index 3bb820de..ba03c103 100644 --- a/Scale.cs +++ b/Scale.cs @@ -70,6 +70,11 @@ public class TweakScale : PartModule, IPartCostModifier /// The scale exponentValue array. If isFreeScale is false, the part may only be one of these scales. /// protected float[] scaleFactors = { 0.625f, 1.25f, 2.5f, 3.75f, 5f }; + + /// + /// The node scale array. If node scales are defined the nodes will be resized to these values. + /// + protected int[] scaleNodes = { }; /// /// The unmodified prefab part. From this, default values are found. @@ -215,6 +220,7 @@ private void SetupFromConfig(ScaleConfig config) if (scaleFactors.Length > 0) { scaleFactors = config.scaleFactors; + scaleNodes = config.scaleNodes; options.options = config.scaleNames; } } @@ -316,8 +322,15 @@ private void rescaleNode(AttachNode node, AttachNode baseNode) } else { - var options = (UI_ChooseOption)this.Fields["tweakName"].uiControlEditor; - node.size = (int)(baseNode.size + (tweakName - Tools.ClosestIndex(defaultScale, config.allScaleFactors)) / (float)config.allScaleFactors.Length * 5); + var options = (UI_ChooseOption)this.Fields["tweakName"].uiControlEditor; + if (scaleNodes.Length > 0) + { + node.size = scaleNodes[tweakName]; + } + else + { + node.size = (int)(baseNode.size + (tweakName - Tools.ClosestIndex(defaultScale, config.allScaleFactors)) / (float)config.allScaleFactors.Length * 5); + } } if (node.size < 0) { diff --git a/Scale.csproj b/Scale.csproj index 351ad917..f1e5cb99 100644 --- a/Scale.csproj +++ b/Scale.csproj @@ -11,6 +11,8 @@ Scale v3.5 512 + 12.0.0 + 2.0 true @@ -31,18 +33,13 @@ - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp-firstpass.dll + ..\..\mainkerbaldir\KSP_Data\Managed\Assembly-CSharp-firstpass.dll - lib\KSPAPIExtensions.dll - False - - - False - lib\Scale_Redist.dll + ..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll @@ -51,7 +48,7 @@ - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll + ..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll @@ -78,4 +75,10 @@ copy "$(ProjectDir)lib\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\ --> - \ No newline at end of file + + + {2BE63D8B-350E-4EDD-959C-4B7397984364} + Scale_Redist + + + diff --git a/ScaleConfig.cs b/ScaleConfig.cs index bf350cbb..3459cd1f 100644 --- a/ScaleConfig.cs +++ b/ScaleConfig.cs @@ -83,6 +83,7 @@ public static ScaleConfig[] AllConfigs private static ScaleConfig defaultConfig = new ScaleConfig(); private float[] _scaleFactors = { 0.625f, 1.25f, 2.5f, 3.75f, 5f }; + private int[] _scaleNodes = { }; private string[] _scaleNames = { "62.5cm", "1.25m", "2.5m", "3.75m", "5m" }; public Dictionary exponents = new Dictionary(); @@ -119,6 +120,14 @@ public string[] scaleNames return result; } } + + public int[] scaleNodes + { + get + { + return _scaleNodes; + } + } private ScaleConfig() { @@ -139,6 +148,7 @@ public ScaleConfig(ConfigNode config) maxValue = Tools.ConfigValue(config, "maxScale", defaultValue: source.maxValue); suffix = Tools.ConfigValue(config, "suffix", defaultValue: source.suffix); _scaleFactors = Tools.ConfigValue(config, "scaleFactors", defaultValue: source._scaleFactors); + _scaleNodes = Tools.ConfigValue(config, "scaleNodes", defaultValue: source._scaleNodes); _scaleNames = Tools.ConfigValue(config, "scaleNames", defaultValue: source._scaleNames).Select(a => a.Trim()).ToArray(); techRequired = Tools.ConfigValue(config, "techRequired", defaultValue: source.techRequired).Select(a=>a.Trim()).ToArray(); name = Tools.ConfigValue(config, "name", defaultValue: "unnamed scaletype"); @@ -168,6 +178,7 @@ public override string ToString() string result = "ScaleConfig {\n"; result += " isFreeScale = " + isFreeScale.ToString() + "\n"; result += " scaleFactors = " + scaleFactors.ToString() + "\n"; + result += " scaleNodes = " + scaleNodes.ToString() + "\n"; result += " minValue = " + minValue.ToString() + "\n"; result += " maxValue = " + maxValue.ToString() + "\n"; return result + "}"; diff --git a/Scale_Editor/Scale_Editor.csproj b/Scale_Editor/Scale_Editor.csproj index bf84b150..e5a651d2 100644 --- a/Scale_Editor/Scale_Editor.csproj +++ b/Scale_Editor/Scale_Editor.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,6 +12,8 @@ v3.5 512 + 12.0.0 + 2.0 true @@ -32,13 +34,10 @@ - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll - ..\lib\KSPAPIExtensions.dll - - - ..\lib\Scale_Redist.dll + ..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll @@ -47,20 +46,24 @@ - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll - + - {70d38878-43db-4f6e-8002-45ada5391af7} + {70D38878-43DB-4F6E-8002-45ADA5391AF7} Scale + + {2BE63D8B-350E-4EDD-959C-4B7397984364} + Scale_Redist + @@ -73,4 +76,4 @@ --> - \ No newline at end of file + diff --git a/Scale_Redist/Scale_Redist.csproj b/Scale_Redist/Scale_Redist.csproj index 31d6b234..c40f4c7e 100644 --- a/Scale_Redist/Scale_Redist.csproj +++ b/Scale_Redist/Scale_Redist.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,6 +12,8 @@ v3.5 512 + 12.0.0 + 2.0 true @@ -32,7 +34,7 @@ - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll @@ -41,7 +43,7 @@ - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll @@ -60,4 +62,4 @@ --> - \ No newline at end of file + diff --git a/TweakScale_ModularFuelTanks/TweakScale_ModularFuelTanks.csproj b/TweakScale_ModularFuelTanks/TweakScale_ModularFuelTanks.csproj index 900775ac..c7d02ba2 100644 --- a/TweakScale_ModularFuelTanks/TweakScale_ModularFuelTanks.csproj +++ b/TweakScale_ModularFuelTanks/TweakScale_ModularFuelTanks.csproj @@ -11,6 +11,8 @@ TweakScale_ModularFuelTanks v3.5 512 + 12.0.0 + 2.0 true @@ -31,17 +33,13 @@ - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll - ..\lib\KSPAPIExtensions.dll + ..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll - ..\lib\modularFuelTanks.dll - - - False - ..\lib\Scale_Redist.dll + ..\..\..\KerbalMods\ModularFuelTanks\ModularFuelTanks\Plugins\modularFuelTanks.dll @@ -50,7 +48,7 @@ - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll @@ -68,4 +66,10 @@ --> + + + {2BE63D8B-350E-4EDD-959C-4B7397984364} + Scale_Redist + + \ No newline at end of file diff --git a/TweakScale_RealFuels/TweakScale_RealFuels.csproj b/TweakScale_RealFuels/TweakScale_RealFuels.csproj index 3379243c..bee21376 100644 --- a/TweakScale_RealFuels/TweakScale_RealFuels.csproj +++ b/TweakScale_RealFuels/TweakScale_RealFuels.csproj @@ -11,6 +11,8 @@ TweakScale_RealFuels v3.5 512 + 12.0.0 + 2.0 true @@ -31,16 +33,13 @@ - E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll - ..\lib\KSPAPIExtensions.dll + ..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll - ..\lib\RealFuels.dll - - - ..\lib\Scale_Redist.dll + ..\..\..\KerbalMods\RealFuels\RealFuels\Plugins\RealFuels.dll @@ -49,7 +48,7 @@ - E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll + ..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll @@ -67,4 +66,10 @@ --> + + + {2BE63D8B-350E-4EDD-959C-4B7397984364} + Scale_Redist + + \ No newline at end of file