Skip to content

Commit

Permalink
Added scaleNodes option to be used in configs under SCALETYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
frencrs committed Sep 7, 2014
1 parent 9154ffc commit e2cf2c1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 41 deletions.
17 changes: 15 additions & 2 deletions Scale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
protected float[] scaleFactors = { 0.625f, 1.25f, 2.5f, 3.75f, 5f };

/// <summary>
/// The node scale array. If node scales are defined the nodes will be resized to these values.
///</summary>
protected int[] scaleNodes = { };

/// <summary>
/// The unmodified prefab part. From this, default values are found.
Expand Down Expand Up @@ -215,6 +220,7 @@ private void SetupFromConfig(ScaleConfig config)
if (scaleFactors.Length > 0)
{
scaleFactors = config.scaleFactors;
scaleNodes = config.scaleNodes;
options.options = config.scaleNames;
}
}
Expand Down Expand Up @@ -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)
{
Expand Down
23 changes: 13 additions & 10 deletions Scale.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>Scale</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,18 +33,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<HintPath>..\..\mainkerbaldir\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>lib\KSPAPIExtensions.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Scale_Redist, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Scale_Redist.dll</HintPath>
<HintPath>..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -51,7 +48,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -78,4 +75,10 @@ copy "$(ProjectDir)lib\KSPAPIExtensions.dll" "$(ProjectDir)\Gamedata\TweakScale\
<Target Name="AfterBuild">
</Target>
-->
</Project>
<ItemGroup>
<ProjectReference Include="Scale_Redist\Scale_Redist.csproj">
<Project>{2BE63D8B-350E-4EDD-959C-4B7397984364}</Project>
<Name>Scale_Redist</Name>
</ProjectReference>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions ScaleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ScaleExponents> exponents = new Dictionary<string, ScaleExponents>();

Expand Down Expand Up @@ -119,6 +120,14 @@ public string[] scaleNames
return result;
}
}

public int[] scaleNodes
{
get
{
return _scaleNodes;
}
}

private ScaleConfig()
{
Expand All @@ -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");
Expand Down Expand Up @@ -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 + "}";
Expand Down
23 changes: 13 additions & 10 deletions Scale_Editor/Scale_Editor.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -12,6 +12,8 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,13 +34,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>..\lib\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="Scale_Redist">
<HintPath>..\lib\Scale_Redist.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -47,20 +46,24 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Editor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScaleDatabase.cs" />
<Compile Include="ScaleInfo.cs" />
<Compile Include="Scaleinfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Scale.csproj">
<Project>{70d38878-43db-4f6e-8002-45ada5391af7}</Project>
<Project>{70D38878-43DB-4F6E-8002-45ADA5391AF7}</Project>
<Name>Scale</Name>
</ProjectReference>
<ProjectReference Include="..\Scale_Redist\Scale_Redist.csproj">
<Project>{2BE63D8B-350E-4EDD-959C-4B7397984364}</Project>
<Name>Scale_Redist</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand All @@ -73,4 +76,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
10 changes: 6 additions & 4 deletions Scale_Redist/Scale_Redist.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -12,6 +12,8 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -32,7 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -41,7 +43,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -60,4 +62,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
20 changes: 12 additions & 8 deletions TweakScale_ModularFuelTanks/TweakScale_ModularFuelTanks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>TweakScale_ModularFuelTanks</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,17 +33,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>..\lib\KSPAPIExtensions.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="modularFuelTanks">
<HintPath>..\lib\modularFuelTanks.dll</HintPath>
</Reference>
<Reference Include="Scale_Redist, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\lib\Scale_Redist.dll</HintPath>
<HintPath>..\..\..\KerbalMods\ModularFuelTanks\ModularFuelTanks\Plugins\modularFuelTanks.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -50,7 +48,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -68,4 +66,10 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<ProjectReference Include="..\Scale_Redist\Scale_Redist.csproj">
<Project>{2BE63D8B-350E-4EDD-959C-4B7397984364}</Project>
<Name>Scale_Redist</Name>
</ProjectReference>
</ItemGroup>
</Project>
19 changes: 12 additions & 7 deletions TweakScale_RealFuels/TweakScale_RealFuels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>TweakScale_RealFuels</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,16 +33,13 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>E:\KSP_Test\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="KSPAPIExtensions">
<HintPath>..\lib\KSPAPIExtensions.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\GameData\MagicSmokeIndustries\Plugins\KSPAPIExtensions.dll</HintPath>
</Reference>
<Reference Include="RealFuels">
<HintPath>..\lib\RealFuels.dll</HintPath>
</Reference>
<Reference Include="Scale_Redist">
<HintPath>..\lib\Scale_Redist.dll</HintPath>
<HintPath>..\..\..\KerbalMods\RealFuels\RealFuels\Plugins\RealFuels.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -49,7 +48,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>E:\KSP_Test\KSP_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\KerbalRescalingInstall\KSP_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -67,4 +66,10 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<ProjectReference Include="..\Scale_Redist\Scale_Redist.csproj">
<Project>{2BE63D8B-350E-4EDD-959C-4B7397984364}</Project>
<Name>Scale_Redist</Name>
</ProjectReference>
</ItemGroup>
</Project>

0 comments on commit e2cf2c1

Please sign in to comment.