Merge pull request #16104 from sheepishgoat/toast!

Ports over Toast
This commit is contained in:
SandPoot
2024-10-15 03:19:27 -03:00
committed by GitHub
5 changed files with 42 additions and 0 deletions

View File

@@ -347,3 +347,5 @@
/datum/config_entry/str_list/randomizing_station_name_message
default = list()
/datum/config_entry/flag/toast_notification_on_init

View File

@@ -223,6 +223,10 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
// Sort subsystems by display setting for easy access.
sortTim(subsystems, GLOBAL_PROC_REF(cmp_subsystem_display))
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

View File

@@ -515,3 +515,7 @@ RANDOMIZING_STATION_NAME_MESSAGE %NEW_STATION_NAME%? %NEW_STATION_NAME%! %NEW_ST
RANDOMIZING_STATION_NAME_MESSAGE A popular social network application had already claimed the trademark of %CURRENT_STATION_NAME%, the station has been renamed to %NEW_STATION_NAME%.
RANDOMIZING_STATION_NAME_MESSAGE We're pulling a prank on %RANDOM_CREWMEMBER%, so we've changed the station's name to %NEW_STATION_NAME%.
RANDOMIZING_STATION_NAME_MESSAGE %RANDOM_NAME% made us change the station name, which is now %NEW_STATION_NAME%.
## 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

View File

@@ -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(@"
<toast>
<visual>
<binding template="ToastGeneric">
<text>Initialization Complete</text>
</binding>
</visual>
<actions>
<action content="Launch Dream Seeker" activationType="protocol" arguments="byond://127.0.0.1:$port"/>
</actions>
</toast>
"@)
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
$notifier.Show($toast)