diff --git a/GameData/KSPWheel/Plugin/KSPWheel.dll b/GameData/KSPWheel/Plugin/KSPWheel.dll index 43625cd..967cdb7 100644 Binary files a/GameData/KSPWheel/Plugin/KSPWheel.dll and b/GameData/KSPWheel/Plugin/KSPWheel.dll differ diff --git a/VSProject/KSPWheel/KSPWheel.csproj b/VSProject/KSPWheel/KSPWheel.csproj index d98f848..eff3bd9 100644 --- a/VSProject/KSPWheel/KSPWheel.csproj +++ b/VSProject/KSPWheel/KSPWheel.csproj @@ -9,7 +9,7 @@ Properties KSPWheel KSPWheel - v4.0 + v4.8 512 @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -30,6 +31,7 @@ prompt 4 false + false diff --git a/VSProject/KSPWheel/PartModules/KSPWheelBase.cs b/VSProject/KSPWheel/PartModules/KSPWheelBase.cs index 6a9c213..c13c17f 100644 --- a/VSProject/KSPWheel/PartModules/KSPWheelBase.cs +++ b/VSProject/KSPWheel/PartModules/KSPWheelBase.cs @@ -124,6 +124,10 @@ public class KSPWheelBase : PartModule, IPartCostModifier, IPartMassModifier, IM UI_FloatEdit(suppressEditorShipModified = true, minValue = 0.1f, maxValue = 10f, incrementLarge = 1f, incrementSmall = 0.25f, incrementSlide = 0.01f, sigFigs = 2)] public float scale = 1f; + [KSPField(guiName = "Width", guiActive = false, guiActiveEditor = true, isPersistant = true, guiUnits = "x"), + UI_FloatEdit(suppressEditorShipModified = true, minValue = 0.1f, maxValue = 10f, incrementLarge = 1f, incrementSmall = 0.25f, incrementSlide = 0.01f, sigFigs = 2)] + public float width = 1f; + [KSPField] public string scalingTransform = string.Empty; @@ -248,6 +252,7 @@ public KSPWheelState wheelState //serialize in editor/etc, should fix cloned-parts starting with improperly offset nodes [SerializeField] private float prevScale = 1f; + private float prevWidth = 1f; private bool initializedWheels = false; @@ -293,23 +298,33 @@ public void onShowUIUpdated(BaseField field, object obj) Fields[nameof(wheelGroup)].guiActive = Fields[nameof(wheelGroup)].guiActiveEditor = showControls && showGUIWheelGroup; Fields[nameof(antiRoll)].guiActive = Fields[nameof(antiRoll)].guiActiveEditor = showControls && showGUIAntiRoll; Fields[nameof(scale)].guiActiveEditor = showControls && allowScaling && showGUIScale; + Fields[nameof(width)].guiActiveEditor = showControls && allowScaling && showGUIScale; } private void onScaleAdjusted(BaseField field, System.Object obj) { - setScale(scale, true); + setScale(scale, width, true); foreach (Part p in part.symmetryCounterparts) { - p.GetComponent().setScale(scale, true); + p.GetComponent().setScale(scale, width, true); + } + } + private void onWidthAdjusted(BaseField field, System.Object obj) + { + setScale(scale, width, true); + foreach (Part p in part.symmetryCounterparts) + { + p.GetComponent().setScale(scale, width, true); } } - private void setScale(float newScale, bool userInput) + private void setScale(float newScale, float newWidth, bool userInput) { scale = newScale; + width = newWidth; if (allowScaling) { - Vector3 scale = new Vector3(newScale, newScale, newScale); + Vector3 scale = new Vector3(newScale * newWidth, newScale, newScale); Transform modelRoot = part.transform.FindRecursive("model"); if (!string.IsNullOrEmpty(scalingTransform)) { @@ -333,6 +348,7 @@ private void setScale(float newScale, bool userInput) scale = newScale = 1f; } prevScale = newScale; + onScaleUpdated(); } @@ -450,6 +466,12 @@ public override void OnStart(StartState state) ufe.minValue = minScale; ufe.maxValue = maxScale; + Fields[nameof(width)].uiControlEditor.onFieldChanged = onWidthAdjusted; + Fields[nameof(width)].guiActiveEditor = allowScaling; + UI_FloatEdit ufe2 = (UI_FloatEdit)Fields[nameof(width)].uiControlEditor; + ufe2.minValue = minScale; + ufe2.maxValue = maxScale; + bool frictionControlEnabled = HighLogic.CurrentGame.Parameters.CustomParams().enableFrictionControl; Callback frictionAction = delegate (BaseField a, System.Object b) { @@ -774,7 +796,7 @@ private void initializeScaling() { if (initializedScaling) { return; } initializedScaling = true; - setScale(scale, false); + setScale(scale, width, false); } private void updateSuspension() @@ -900,14 +922,15 @@ private void onScaleUpdated() { KSPWheelScaleSettings scales = HighLogic.CurrentGame.Parameters.CustomParams(); float localScale = scale * part.rescaleFactor; - partMassScaleFactor = Mathf.Pow(localScale, scales.partMassScalingPower); - partCostScaleFactor = Mathf.Pow(localScale, scales.partCostScalingPower); - wheelMassScaleFactor = Mathf.Pow(localScale, scales.wheelMassScalingPower); - wheelMaxLoadScalingFactor = Mathf.Pow(localScale, scales.wheelMaxLoadScalingPower); + float localWidth = width; + partMassScaleFactor = Mathf.Pow(localScale, scales.partMassScalingPower) * localWidth; + partCostScaleFactor = Mathf.Pow(localScale, scales.partCostScalingPower) * localWidth; + wheelMassScaleFactor = Mathf.Pow(localScale, scales.wheelMassScalingPower) * localWidth; + wheelMaxLoadScalingFactor = Mathf.Pow(localScale, scales.wheelMaxLoadScalingPower) * localWidth; wheelMaxSpeedScalingFactor = Mathf.Pow(localScale, scales.wheelMaxSpeedScalingPower); motorMaxRPMScalingFactor = Mathf.Pow(localScale, scales.motorMaxRPMScalingPower); - motorPowerScalingFactor = Mathf.Pow(localScale, scales.motorPowerScalingPower); - motorTorqueScalingFactor = Mathf.Pow(localScale, scales.motorTorqueScalingPower); + motorPowerScalingFactor = Mathf.Pow(localScale, scales.motorPowerScalingPower) * localWidth; + motorTorqueScalingFactor = Mathf.Pow(localScale, scales.motorTorqueScalingPower) * localWidth; } if (wheelData != null) {