diff --git a/README.md b/README.md index c701e45..5f9b4da 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,12 @@ For more information, please refer to QuickMods are very small plugins which add a small feature. Features: -* PrecisionControl: force precision control at flight loading -* Revert: disable revert when you pass the atmosphere -* Scroll: scroll the R&D view when click mouse -* StopWarp: stop warp when vessel situation change -* VesselNames: add a new vessel name when you create a new vessel in the VAB +* Pause: pause the game when you escape it. +* PrecisionControl: force precision control at flight loading, it also adds notification when you toggle precision control mode. +* Revert: disable revert when you pass the atmosphere. +* Scroll: scroll the R&D view when click mouse. +* StopWarp: stop warp when vessel situation change. +* VesselNames: add a new vessel name when you create a new vessel in the VAB. All the features are disabled by default. To enable them, go to Settings -> Mods -> QuickMods -> Choose what you want. diff --git a/plugin_template/localizations/localizations.csv b/plugin_template/localizations/localizations.csv index fd60dfc..41fd126 100644 --- a/plugin_template/localizations/localizations.csv +++ b/plugin_template/localizations/localizations.csv @@ -1,5 +1,6 @@ Key,Type,Description,English,French -QuickMods/StopWarp/Notifications/VesselSituationChange/Primary,Text,,[QuickStopWarp] Stop Warp,[QuickStopWarp] Stop Warp -QuickMods/StopWarp/Notifications/VesselSituationChange/FirstLine,Text,,The vessel's situation has changed from {0} to {1}.,La situation du vaisseau à changer de {0} à {1}. -QuickMods/QuickRevert/Notifications/LostRevert/Primary,Text,,[QuickRevert] Lost Revert,[QuickRevert] Lost Revert -QuickMods/QuickRevert/Notifications/LostRevert/FirstLine,Text,,Revert will no longer be possible.,Il ne sera plus possible de faire un Revert. \ No newline at end of file +QuickMods/StopWarp/Notifications/VesselSituationChange/Primary,Text,,Stop Warp, vessel's situation changed,Stop Warp, La situation du vaisseau à changé +QuickMods/QuickRevert/Notifications/LostRevert/Primary,Text,,Lost Revert,Revert perdu +QuickMods/PrecisionControl/Notifications/Primary,Text,,Precision control mode: {0},Mode précis des contrôles : {0} +QuickMods/PrecisionControl/Notifications/Primary/Activated,Text,,ACTIVATED,ACTIVÉ +QuickMods/PrecisionControl/Notifications/Primary/Deactivated,Text,,DEACTIVATED,DÉSACTIVÉ \ No newline at end of file diff --git a/src/QuickMods/quick/impl/PrecisionControl.cs b/src/QuickMods/quick/impl/PrecisionControl.cs index 6e25318..fd8b31a 100644 --- a/src/QuickMods/quick/impl/PrecisionControl.cs +++ b/src/QuickMods/quick/impl/PrecisionControl.cs @@ -1,5 +1,8 @@ +using I2.Loc; +using KSP.Game; using KSP.Messages; using QuickMods.configuration.impl; +using UnityEngine.InputSystem; namespace QuickMods.quick.impl; @@ -9,12 +12,14 @@ public override void Start() { base.Start(); MessageCenter.Subscribe(OnFlightViewEnteredMessage); + Game.Input.Flight.TogglePrecisionMode.performed += OnActivatePrecisionMode; } public override void OnDestroy() { base.OnDestroy(); MessageCenter.Unsubscribe(OnFlightViewEnteredMessage); + Game.Input.Flight.TogglePrecisionMode.performed -= OnActivatePrecisionMode; } private void OnFlightViewEnteredMessage(MessageCenterMessage msg) @@ -22,7 +27,26 @@ private void OnFlightViewEnteredMessage(MessageCenterMessage msg) if (!config.Enabled()) return; Game.ViewController.flightInputHandler._isPrecisionMode = true; + SendNotification(); Logger.LogDebug("Set PrecisionControl to true"); } + + private void OnActivatePrecisionMode(InputAction.CallbackContext context) + { + SendNotification(); + } + + private void SendNotification() + { + var isPrecisionMode = Game.ViewController.flightInputHandler.IsPrecisionMode; + var isPrecisionModeText = LocalizationManager.GetTranslation(isPrecisionMode ? "QuickMods/PrecisionControl/Notifications/Primary/Activated" : "QuickMods/PrecisionControl/Notifications/Primary/Deactivated"); + var notificationData = new NotificationData + { + Tier = NotificationTier.Passive, + Primary = new NotificationLineItemData { LocKey = "QuickMods/PrecisionControl/Notifications/Primary", ObjectParams = [isPrecisionModeText] }, + Importance = NotificationImportance.Low + }; + Game.Notifications.ProcessNotification(notificationData); + } } \ No newline at end of file diff --git a/src/QuickMods/quick/impl/Revert.cs b/src/QuickMods/quick/impl/Revert.cs index 96bd981..e421ea8 100644 --- a/src/QuickMods/quick/impl/Revert.cs +++ b/src/QuickMods/quick/impl/Revert.cs @@ -36,7 +36,6 @@ msg is not (VesselSituationChangedMessage { OldSituation: Flying, NewSituation: { Tier = NotificationTier.Passive, Primary = new NotificationLineItemData { LocKey = "QuickMods/QuickRevert/Notifications/LostRevert/Primary" }, - FirstLine = new NotificationLineItemData { LocKey = "QuickMods/QuickRevert/Notifications/LostRevert/FirstLine" }, Importance = NotificationImportance.Low }; Game.Notifications.ProcessNotification(notificationData); diff --git a/src/QuickMods/quick/impl/StopWarp.cs b/src/QuickMods/quick/impl/StopWarp.cs index d2189d7..6f09019 100644 --- a/src/QuickMods/quick/impl/StopWarp.cs +++ b/src/QuickMods/quick/impl/StopWarp.cs @@ -29,7 +29,6 @@ private void OnVesselSituationChange(MessageCenterMessage msg) { Tier = NotificationTier.Passive, Primary = new NotificationLineItemData { LocKey = "QuickMods/StopWarp/Notifications/VesselSituationChange/Primary" }, - FirstLine = new NotificationLineItemData { LocKey = "QuickMods/StopWarp/Notifications/VesselSituationChange/FirstLine", ObjectParams = [message.OldSituation, message.NewSituation] }, Importance = NotificationImportance.Low }; Game.Notifications.ProcessNotification(notificationData);