Skip to content

Commit

Permalink
Per-Part Configurable Max TxPower
Browse files Browse the repository at this point in the history
Implements #63
  • Loading branch information
DRVeyl committed Jan 16, 2022
1 parent 1710de5 commit 7e489f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/RealAntennasProject/ModuleRealAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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<RAParameters>().MaxTechLevel;
if (Fields[nameof(TechLevel)].uiControlEditor is UI_FloatRange fr)
Expand Down

0 comments on commit 7e489f8

Please sign in to comment.