diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 263201b6846..7bfbe268b6d 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -649,3 +649,5 @@ default = 50 /datum/config_entry/string/morgue_cadaver_override_species + +/datum/config_entry/flag/toast_notification_on_init diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 99060e9ae96..5000aa07e30 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -267,6 +267,9 @@ GLOBAL_REAL(Master, /datum/controller/master) = new log_world(msg) + if(world.system_type == MS_WINDOWS && CONFIG_GET(flag/toast_notification_on_init) && !length(GLOB.clients)) + world.shelleo("start /min powershell -ExecutionPolicy Bypass -File tools/initToast/initToast.ps1 -name \"[world.name]\" -icon %CD%\\icons\\ui_icons\\common\\tg_16.png -port [world.port]") + // Set world options. world.change_fps(CONFIG_GET(number/fps)) var/initialized_tod = REALTIMEOFDAY diff --git a/config/config.txt b/config/config.txt index 2f57ba97810..3ac807188ae 100644 --- a/config/config.txt +++ b/config/config.txt @@ -648,3 +648,7 @@ PR_ANNOUNCEMENTS_PER_ROUND 5 ## Uncomment to block granting profiling privileges to users with R_DEBUG, for performance purposes #FORBID_ADMIN_PROFILING + +## Comment to disable sending a toast notification on the host server when initializations complete. +## Even if this is enabled, a notification will only be sent if there are no clients connected. +TOAST_NOTIFICATION_ON_INIT diff --git a/icons/ui_icons/common/tg_16.png b/icons/ui_icons/common/tg_16.png new file mode 100644 index 00000000000..2b08bdd29cd Binary files /dev/null and b/icons/ui_icons/common/tg_16.png differ diff --git a/tools/initToast/initToast.ps1 b/tools/initToast/initToast.ps1 new file mode 100644 index 00000000000..9b7714f3a2c --- /dev/null +++ b/tools/initToast/initToast.ps1 @@ -0,0 +1,32 @@ +param([string]$name, [string]$icon, [Int32]$port=80) + +$hkcu = [Microsoft.Win32.RegistryKey]::OpenBaseKey('CurrentUser','default') + +$amuid_hkey = $hkcu.CreateSubKey('SOFTWARE\Classes\AppUserModelId\Tgstation.Tgstation', $true, [Microsoft.Win32.RegistryOptions]::Volatile) + +if ($name) { $amuid_hkey.SetValue('DisplayName', $name) } +if ($icon) { $amuid_hkey.SetValue('IconUri', $icon) } + +[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null +$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('Tgstation.Tgstation') + +[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom, ContentType = WindowsRuntime] > $null +$xml = New-Object Windows.Data.Xml.Dom.XmlDocument + +$xml.LoadXml(@" + + + + Initialization Complete + + + + + + +"@) + +[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null +$toast = New-Object Windows.UI.Notifications.ToastNotification $xml + +$notifier.Show($toast)