diff --git a/src/RealAntennasProject/ModuleRealAntenna.cs b/src/RealAntennasProject/ModuleRealAntenna.cs index e4d286b..1cca000 100644 --- a/src/RealAntennasProject/ModuleRealAntenna.cs +++ b/src/RealAntennasProject/ModuleRealAntenna.cs @@ -257,6 +257,9 @@ private void SetFieldVisibility() Fields[nameof(sIdlePowerConsumed)].guiActiveEditor = Fields[nameof(sIdlePowerConsumed)].guiActive = showFields; Fields[nameof(sAntennaTarget)].guiActive = showFields; Fields[nameof(plannerActiveTxTime)].guiActiveEditor = Kerbalism.Kerbalism.KerbalismAssembly is System.Reflection.Assembly; + Actions[nameof(PermanentShutdownAction)].active = showFields; + Events[nameof(PermanentShutdownEvent)].guiActive = showFields; + Events[nameof(PermanentShutdownEvent)].active = showFields; Events[nameof(AntennaPlanningGUI)].active = showFields; Events[nameof(AntennaPlanningGUI)].guiActive = showFields; Events[nameof(DebugAntenna)].active = showFields; @@ -302,6 +305,29 @@ private void OnTechLevelChange(BaseField f, object obj) // obj is the OLD va private void OnTechLevelChangeSymmetry(BaseField f, object obj) => ConfigBandOptions(); + [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "Disable antenna permanently", groupName = PAWGroup)] + public void PermanentShutdownEvent() + { + var options = new DialogGUIBase[] { + new DialogGUIButton("Yes", () => PermanentShutdownAction(null)), + new DialogGUIButton("No", () => {}) + }; + var dialog = new MultiOptionDialog("ConfirmDisableAntenna", "Are you sure you want to permanently disable the antenna? Doing this will prevent it from consuming power but the operation is irreversible.", "Disable antenna", HighLogic.UISkin, 300, options); + PopupDialog.SpawnPopupDialog(dialog, true, HighLogic.UISkin); + } + + [KSPAction("Disable antenna permanently")] + public void PermanentShutdownAction(KSPActionParam _) + { + _enabled = false; + Condition = AntennaCondition.PermanentShutdown; + SetFieldVisibility(); + SetupIdlePower(); + GameEvents.onVesselWasModified.Fire(vessel); // Need to notify RACommNetVessel about disabling antennas + RACommNetScenario scen = RACommNetScenario.Instance as RACommNetScenario; + scen?.Network?.ResetNetwork(); + } + private void ApplyGameSettings() { StockRateModifier = HighLogic.CurrentGame.Parameters.CustomParams().StockRateModifier; diff --git a/src/RealAntennasProject/Properties/AssemblyInfo.cs b/src/RealAntennasProject/Properties/AssemblyInfo.cs index 6fb8778..b0ec8f3 100644 --- a/src/RealAntennasProject/Properties/AssemblyInfo.cs +++ b/src/RealAntennasProject/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.5.0.0")] +[assembly: AssemblyVersion("2.6.0.0")] #if CIBUILD [assembly: AssemblyFileVersion("@MAJOR@.@MINOR@.@PATCH@.@BUILD@")] [assembly: KSPAssembly("RealAntennas", @MAJOR@, @MINOR@)] diff --git a/src/RealAntennasProject/RealAntennas.csproj b/src/RealAntennasProject/RealAntennas.csproj index 516d454..e19f7cb 100644 --- a/src/RealAntennasProject/RealAntennas.csproj +++ b/src/RealAntennasProject/RealAntennas.csproj @@ -88,7 +88,7 @@ - + diff --git a/src/RealAntennasProject/UpgradeScripts/v2_5_AntennaState.cs b/src/RealAntennasProject/UpgradeScripts/v2_6_AntennaState.cs similarity index 80% rename from src/RealAntennasProject/UpgradeScripts/v2_5_AntennaState.cs rename to src/RealAntennasProject/UpgradeScripts/v2_6_AntennaState.cs index 6229a7c..de3e801 100644 --- a/src/RealAntennasProject/UpgradeScripts/v2_5_AntennaState.cs +++ b/src/RealAntennasProject/UpgradeScripts/v2_6_AntennaState.cs @@ -4,7 +4,7 @@ namespace RealAntennas.UpgradeScripts { [UpgradeModule(LoadContext.SFS | LoadContext.Craft, sfsNodeUrl = "GAME/FLIGHTSTATE/VESSEL/PART", craftNodeUrl = "PART")] - public class v2_5_AntennaState : UpgradeScript + public class v2_6_AntennaState : UpgradeScript { public override string Name => "RealAntennas Antenna Condition upgrader"; public override string Description => "Update crafts to use new condition enum"; @@ -29,7 +29,7 @@ public override void OnUpgrade(ConfigNode node, LoadContext loadContext, ConfigN } } - public class v2_5_AntennaState_KCTBase : v2_5_AntennaState + public class v2_6_AntennaState_KCTBase : v2_6_AntennaState { public override string Name { get => $"{base.Name} KCT-{nodeUrlSFS}"; } public override TestResult OnTest(ConfigNode node, LoadContext loadContext, ref string nodeName) => @@ -37,29 +37,29 @@ public override TestResult OnTest(ConfigNode node, LoadContext loadContext, ref } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/VABList/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT1 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT1 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/SPHList/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT2 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT2 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/VABWarehouse/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT3 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT3 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/SPHWarehouse/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT4 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT4 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/VABPlans/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT5 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT5 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/SPHPlans/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT6 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT6 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/LaunchComplex/BuildList/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT7 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT7 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/LaunchComplex/Warehouse/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT8 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT8 : v2_6_AntennaState_KCTBase { } [UpgradeModule(LoadContext.SFS, sfsNodeUrl = "GAME/SCENARIO/KSC/LaunchComplex/Plans/KCTVessel/ShipNode/PART")] - public class v2_5_AntennaState_KCT9 : v2_5_AntennaState_KCTBase { } + public class v2_6_AntennaState_KCT9 : v2_6_AntennaState_KCTBase { } }