From 7e489f84c1043badda13fb851ab94034d68a8710 Mon Sep 17 00:00:00 2001 From: DRVeyl Date: Sun, 16 Jan 2022 17:49:34 -0500 Subject: [PATCH] Per-Part Configurable Max TxPower Implements #63 --- src/RealAntennasProject/ModuleRealAntenna.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/RealAntennasProject/ModuleRealAntenna.cs b/src/RealAntennasProject/ModuleRealAntenna.cs index 1f71cdd..c160b46 100644 --- a/src/RealAntennasProject/ModuleRealAntenna.cs +++ b/src/RealAntennasProject/ModuleRealAntenna.cs @@ -18,8 +18,10 @@ public class ModuleRealAntenna : ModuleDataTransmitter, IPartCostModifier, IPart public float Gain; // Physical directionality, measured in dBi [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Transmit Power (dBm)", guiUnits = " dBm", guiFormat = "F1", groupName = PAWGroup), - UI_FloatRange(maxValue = 60f, minValue = 0f, stepIncrement = 1f, scene = UI_Scene.Editor)] - public float TxPower = 30f; // Transmit Power in dBm (milliwatts) + UI_FloatRange(maxValue = 60, minValue = 0, stepIncrement = 1, scene = UI_Scene.Editor)] + public float TxPower = 30; // Transmit Power in dBm (milliwatts) + + [KSPField] protected float MaxTxPower = 60; // Per-part max setting for TxPower [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Tech Level", guiFormat = "N0", groupName = PAWGroup), UI_FloatRange(minValue = 0f, stepIncrement = 1f, scene = UI_Scene.Editor)] @@ -124,6 +126,7 @@ public override void OnStart(StartState state) base.OnStart(state); SetupBaseFields(); Fields[nameof(_enabled)].uiControlEditor.onFieldChanged = OnAntennaEnableChange; + (Fields[nameof(TxPower)].uiControlEditor as UI_FloatRange).maxValue = MaxTxPower; if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) maxTechLevel = HighLogic.CurrentGame.Parameters.CustomParams().MaxTechLevel; if (Fields[nameof(TechLevel)].uiControlEditor is UI_FloatRange fr)