Skip to content

Commit ad96183

Browse files
committed
added notification when toggle precision control & fix notification text
1 parent 6e1ee4e commit ad96183

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ For more information, please refer to <http://unlicense.org/>
3232
QuickMods are very small plugins which add a small feature.
3333

3434
Features:
35-
* PrecisionControl: force precision control at flight loading
36-
* Revert: disable revert when you pass the atmosphere
37-
* Scroll: scroll the R&D view when click mouse
38-
* StopWarp: stop warp when vessel situation change
39-
* VesselNames: add a new vessel name when you create a new vessel in the VAB
35+
* Pause: pause the game when you escape it.
36+
* PrecisionControl: force precision control at flight loading, it also adds notification when you toggle precision control mode.
37+
* Revert: disable revert when you pass the atmosphere.
38+
* Scroll: scroll the R&D view when click mouse.
39+
* StopWarp: stop warp when vessel situation change.
40+
* VesselNames: add a new vessel name when you create a new vessel in the VAB.
4041

4142
All the features are disabled by default.
4243
To enable them, go to Settings -> Mods -> QuickMods -> Choose what you want.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Key,Type,Description,English,French
2-
QuickMods/StopWarp/Notifications/VesselSituationChange/Primary,Text,,[QuickStopWarp] Stop Warp,[QuickStopWarp] Stop Warp
3-
QuickMods/StopWarp/Notifications/VesselSituationChange/FirstLine,Text,,The vessel's situation has changed from {0} to {1}.,La situation du vaisseau à changer de {0} à {1}.
4-
QuickMods/QuickRevert/Notifications/LostRevert/Primary,Text,,[QuickRevert] Lost Revert,[QuickRevert] Lost Revert
5-
QuickMods/QuickRevert/Notifications/LostRevert/FirstLine,Text,,Revert will no longer be possible.,Il ne sera plus possible de faire un Revert.
2+
QuickMods/StopWarp/Notifications/VesselSituationChange/Primary,Text,,Stop Warp, vessel's situation changed,Stop Warp, La situation du vaisseau à changé
3+
QuickMods/QuickRevert/Notifications/LostRevert/Primary,Text,,Lost Revert,Revert perdu
4+
QuickMods/PrecisionControl/Notifications/Primary,Text,,Precision control mode: {0},Mode précis des contrôles : {0}
5+
QuickMods/PrecisionControl/Notifications/Primary/Activated,Text,,ACTIVATED,ACTIVÉ
6+
QuickMods/PrecisionControl/Notifications/Primary/Deactivated,Text,,DEACTIVATED,DÉSACTIVÉ

src/QuickMods/quick/impl/PrecisionControl.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
using I2.Loc;
2+
using KSP.Game;
13
using KSP.Messages;
24
using QuickMods.configuration.impl;
5+
using UnityEngine.InputSystem;
36

47
namespace QuickMods.quick.impl;
58

@@ -9,20 +12,41 @@ public override void Start()
912
{
1013
base.Start();
1114
MessageCenter.Subscribe<FlightViewEnteredMessage>(OnFlightViewEnteredMessage);
15+
Game.Input.Flight.TogglePrecisionMode.performed += OnActivatePrecisionMode;
1216
}
1317

1418
public override void OnDestroy()
1519
{
1620
base.OnDestroy();
1721
MessageCenter.Unsubscribe<FlightViewEnteredMessage>(OnFlightViewEnteredMessage);
22+
Game.Input.Flight.TogglePrecisionMode.performed -= OnActivatePrecisionMode;
1823
}
1924

2025
private void OnFlightViewEnteredMessage(MessageCenterMessage msg)
2126
{
2227
if (!config.Enabled()) return;
2328

2429
Game.ViewController.flightInputHandler._isPrecisionMode = true;
30+
SendNotification();
2531

2632
Logger.LogDebug("Set PrecisionControl to true");
2733
}
34+
35+
private void OnActivatePrecisionMode(InputAction.CallbackContext context)
36+
{
37+
SendNotification();
38+
}
39+
40+
private void SendNotification()
41+
{
42+
var isPrecisionMode = Game.ViewController.flightInputHandler.IsPrecisionMode;
43+
var isPrecisionModeText = LocalizationManager.GetTranslation(isPrecisionMode ? "QuickMods/PrecisionControl/Notifications/Primary/Activated" : "QuickMods/PrecisionControl/Notifications/Primary/Deactivated");
44+
var notificationData = new NotificationData
45+
{
46+
Tier = NotificationTier.Passive,
47+
Primary = new NotificationLineItemData { LocKey = "QuickMods/PrecisionControl/Notifications/Primary", ObjectParams = [isPrecisionModeText] },
48+
Importance = NotificationImportance.Low
49+
};
50+
Game.Notifications.ProcessNotification(notificationData);
51+
}
2852
}

src/QuickMods/quick/impl/Revert.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ msg is not (VesselSituationChangedMessage { OldSituation: Flying, NewSituation:
3636
{
3737
Tier = NotificationTier.Passive,
3838
Primary = new NotificationLineItemData { LocKey = "QuickMods/QuickRevert/Notifications/LostRevert/Primary" },
39-
FirstLine = new NotificationLineItemData { LocKey = "QuickMods/QuickRevert/Notifications/LostRevert/FirstLine" },
4039
Importance = NotificationImportance.Low
4140
};
4241
Game.Notifications.ProcessNotification(notificationData);

src/QuickMods/quick/impl/StopWarp.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ private void OnVesselSituationChange(MessageCenterMessage msg)
2929
{
3030
Tier = NotificationTier.Passive,
3131
Primary = new NotificationLineItemData { LocKey = "QuickMods/StopWarp/Notifications/VesselSituationChange/Primary" },
32-
FirstLine = new NotificationLineItemData { LocKey = "QuickMods/StopWarp/Notifications/VesselSituationChange/FirstLine", ObjectParams = [message.OldSituation, message.NewSituation] },
3332
Importance = NotificationImportance.Low
3433
};
3534
Game.Notifications.ProcessNotification(notificationData);

0 commit comments

Comments
 (0)