untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 14 forks source link

Question (not - yet - a request) about Notifications #159

Closed PhilouDS closed 1 week ago

PhilouDS commented 2 months ago

This is a simple question that went through my mind. Can we interact with notifications?

image

Tbh, I'd like an entire mod that get rid of those notifications. They are annoying... But they are there and if we can use Kontrol System to sometimes display a notification, it could be fun.

untoldwind commented 2 months ago

This might be either pretty easy or extremely hard.

Internally there is a very nice NotificationManager, problem is that it is intertwined with the localization system ... i.e. internally the notifications are a localization-key + parameters (e.g. in your example above the location-key is "Science/Notifications/ResearchReportSubmitted" and the parameter is 50 ... which is then combined to something readable depending on the selected language). I am not entirely sure what happens if the localization-key is set to some arbitrary value ... or if there is a special localization-key that allows arbitrary text.

untoldwind commented 2 months ago

It actually was rather easy: When using anything as localization-key that is unknown to the LocalizationManager, that text is just used as is.

So in pre-release 0.5.8.0 (https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.5.8.0), this should be possible:

use { Vessel } from ksp::vessel
use { notification_alert, notification_passive, Importance } from ksp::game

pub fn main_flight(vessel: Vessel) -> Result<Unit> = {
  notification_alert("Alert title", "Alert message", Importance.Low, 10)
  notification_passive("Passive message")
}

Internally there are also "Admin" tier notification, but I did not managed to get them working correctly.

PhilouDS commented 2 months ago

Ooh! Thanks for that. More fun is coming :)

What's ksp::game::MESSAGE_BUS for?

Do you have the new vsix file please? I thought the file wasn't needed anymore but I have error from VSC.

PhilouDS commented 2 months ago

image

untoldwind commented 2 months ago

What's ksp::game::MESSAGE_BUS for?

I just added a comment about this to this issue: https://github.com/untoldwind/KontrolSystem2/issues/155

Do you have the new vsix file please? I thought the file wasn't needed anymore but I have error from VSC.

I created a fresh one: https://github.com/untoldwind/KontrolSystem2/releases/download/v0.5.8.0/to2-syntax-0.0.48.vsix ... but turns out there are some bugs that prevent the new stuff from being recognized correctly, have to analyze those in more detail.

PhilouDS commented 2 months ago

I created a fresh one: https://github.com/untoldwind/KontrolSystem2/releases/download/v0.5.8.0/to2-syntax-0.0.48.vsix .

I still have an error for the keyword Importance

untoldwind commented 2 months ago

There where some inconsistencies in the vscode extension. The version in 0.5.8.1 (https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.5.8.1) should work correctly.

There is now an additional setting for the path to the reference.json in the KontrolSystem2 addon, this will (hopefully :crossed_fingers: ) make it unnecessary to update the vscode extension with every extension to the API.

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 60 days with no activity.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale.