diff --git a/src/RealAntennasProject/ModuleRealAntenna.cs b/src/RealAntennasProject/ModuleRealAntenna.cs index 83499ae..495f5bf 100644 --- a/src/RealAntennasProject/ModuleRealAntenna.cs +++ b/src/RealAntennasProject/ModuleRealAntenna.cs @@ -55,8 +55,8 @@ public class ModuleRealAntenna : ModuleDataTransmitter, IPartCostModifier, IPart [KSPField(guiActive = true, guiActiveEditor = true, guiName = "Peer", groupName = PAWGroupPlanner, groupDisplayName = PAWGroupPlanner)] public string plannerTargetString = string.Empty; - [KSPField(guiActive = true, guiActiveEditor = true, guiName = "Planning Altitude (Mm)", guiUnits = " Mm", guiFormat = "N0", groupName = PAWGroupPlanner), - UI_FloatRange(maxValue = 1000, minValue = 1, stepIncrement = 1, scene = UI_Scene.All)] + [KSPField(guiActive = true, guiActiveEditor = true, guiName = "Planning Altitude", guiUnits = "m", guiFormat = "N0", groupName = PAWGroupPlanner), + UI_ScaleEdit(incrementSlide = new float[] { 1e4f, 1e6f, 1e8f, 1e10f, 1e12f }, intervals = new float[] { 1e4f, 1e6f, 1e8f, 1e10f, 1e12f, 1e14f }, sigFigs = 3, suppressEditorShipModified = true, unit = "m", useSI = true)] public float plannerAltitude = 1; [KSPField(guiActive = true, guiActiveEditor = true, guiName = "Transmit", groupName = PAWGroupPlanner)] @@ -136,7 +136,7 @@ public override void OnStart(StartState state) if (fr.maxValue == fr.minValue) fr.maxValue += 0.001f; } - if (HighLogic.LoadedSceneIsEditor && TechLevel < 0) TechLevel = maxTechLevel; + if (TechLevel < 0) TechLevel = maxTechLevel; if (!RAAntenna.CanTarget) { @@ -235,19 +235,12 @@ private void SetupGUIs() private void SetupUICallbacks() { - UI_FloatRange t = Fields[nameof(TechLevel)].uiControlEditor as UI_FloatRange; - t.onFieldChanged = new Callback(OnTechLevelChange); - - UI_ChooseOption op = Fields[nameof(RFBand)].uiControlEditor as UI_ChooseOption; - op.onFieldChanged = new Callback(OnRFBandChange); - - UI_FloatRange fr = Fields[nameof(TxPower)].uiControlEditor as UI_FloatRange; - fr.onFieldChanged = new Callback(OnTxPowerChange); - - UI_FloatRange paE = Fields[nameof(plannerAltitude)].uiControlEditor as UI_FloatRange; - UI_FloatRange paF = Fields[nameof(plannerAltitude)].uiControlFlight as UI_FloatRange; - paE.onFieldChanged = paF.onFieldChanged = new Callback(planner.OnPlanningAltitudeChange); - + Fields[nameof(TechLevel)].uiControlEditor.onFieldChanged = OnTechLevelChange; + Fields[nameof(TechLevel)].uiControlEditor.onSymmetryFieldChanged = OnTechLevelChangeSymmetry; + Fields[nameof(RFBand)].uiControlEditor.onFieldChanged = OnRFBandChange; + Fields[nameof(TxPower)].uiControlEditor.onFieldChanged = OnTxPowerChange; + Fields[nameof(plannerAltitude)].uiControlEditor.onFieldChanged = planner.OnPlanningAltitudeChange; + Fields[nameof(plannerAltitude)].uiControlFlight.onFieldChanged = planner.OnPlanningAltitudeChange; Fields[nameof(plannerActiveTxTime)].uiControlEditor.onFieldChanged += OnPlannerActiveTxTimeChanged; } @@ -262,6 +255,7 @@ private void OnTechLevelChange(BaseField f, object obj) // obj is the OLD va RecalculateFields(); if (!oldBand.Equals(RFBand)) MonoUtilities.RefreshPartContextWindow(part); } + private void OnTechLevelChangeSymmetry(BaseField f, object obj) => ConfigBandOptions(); private void ApplyGameSettings() { diff --git a/src/RealAntennasProject/Planner.cs b/src/RealAntennasProject/Planner.cs index 1dc81a6..863b567 100644 --- a/src/RealAntennasProject/Planner.cs +++ b/src/RealAntennasProject/Planner.cs @@ -57,8 +57,8 @@ internal void RecalculatePlannerFields() RealAntenna selfAnt = new RealAntennaDigital(RAAntenna) { ParentNode = selfComm }; bool showAltitude = true; Vector3d dir = Vector3d.up; - double furthestDistance = PlannerAltitude * 1e6; - double closestDistance = PlannerAltitude * 1e6; + double furthestDistance = PlannerAltitude; + double closestDistance = PlannerAltitude; CelestialBody home = Planetarium.fetch.Home; if (PlannerTarget is CelestialBody b) @@ -66,7 +66,7 @@ internal void RecalculatePlannerFields() showAltitude = (b == home); if (RATools.HighestGainCompatibleDSNAntenna(net.Nodes, RAAntenna) is RealAntenna DSNAntenna) { - peerComm = new RACommNode(peerObj.transform) { ParentBody = home }; + peerComm = new RACommNode(peerObj.transform) { ParentBody = home, isHome = DSNAntenna.ParentNode?.isHome ?? true }; peerAnt = new RealAntennaDigital(DSNAntenna) { ParentNode = peerComm }; peerAnt.ParentNode.transform.SetPositionAndRotation(home.position + home.GetRelSurfacePosition(0, 0, 0), Quaternion.identity); peerAnt.ParentNode.precisePosition = peerAnt.ParentNode.position; @@ -85,7 +85,12 @@ internal void RecalculatePlannerFields() } } else if (PlannerTarget is RealAntenna ra) { - peerComm = new RACommNode(peerObj.transform) { ParentVessel = ra?.Parent?.vessel }; + peerComm = new RACommNode(peerObj.transform) + { + ParentVessel = (ra?.ParentNode as RACommNode)?.ParentVessel, + ParentBody = (ra?.ParentNode as RACommNode)?.ParentBody, + isHome = (ra?.ParentNode as RACommNode)?.isHome ?? false, + }; peerAnt = new RealAntennaDigital(ra) { ParentNode = peerComm }; peerAnt.ParentNode.transform.SetPositionAndRotation(home.position + (closestDistance / 2 * Vector3d.up), Quaternion.identity); peerAnt.ParentNode.precisePosition = peerAnt.ParentNode.position;