notification_util¶
Quelle: base/tealdef/game_mechanics/notifications/notification_util.d.tl
Hinweise
Hilfsfunktionen, die Ressourcen von Benachrichtigungstypen lesen und den Zustand des Benachrichtigungs-Game-Scripts lesen oder ändern.
NotificationUtil¶
record global base/tealdef/game_mechanics/notifications/notification_util.d.tl:3
global record NotificationUtil
Laden: local notification_util = ug_require "::/game_mechanics/notifications/notification_util.tl" as NotificationUtil
Hinweise
Hilfsfunktionen für Ressourcen von Benachrichtigungstypen und für den Zustand des Benachrichtigungs-Game-Scripts.
Details
Funktionen, die einen NotificationsState bekommen, ändern diese Tabelle. Das Game-Script
nutzt sie in seinem eigenen Update und Event-Handler. Skripte außerhalb davon sollten
stattdessen die Notifications-Events senden (siehe Notification).
Felder
| Name | Typ | Beschreibung |
|---|---|---|
defaultAutoDismissDurationMs |
integer |
Standardwert für autoDismissDuration einer Benachrichtigung, 60.000 ms Spielzeit. 19-mal im Basisspiel verwendet |
Funktionen
getGuiTypeFromNotificationType(name : string) : NotificationGuiData.Type base/tealdef/game_mechanics/notifications/notification_util.d.tl:6
Aufruf: notification_util.getGuiTypeFromNotificationType(…)
Hinweise
Liest die GUI-Kategorie eines Benachrichtigungstyps aus seiner .res-Datei.
| Parameter | Typ | Beschreibung |
|---|---|---|
name |
string |
Skript des Benachrichtigungstyps, wie in Notification.type. |
Rückgabe NotificationGuiData.Type: Der guiType der Ressource oder "Unknown", wenn es keine solche Benachrichtigungsressource gibt oder sie keinen guiType hat.
Im Basisspiel verwendet: 11-mal in 6 Dateien
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:33
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:64
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:129
base/content/gui/gui/entity_window/entity_window_util.tl:2071
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:71
base/content/gui/gui/statistics/statistics_react_util.tl:276
getInitiallyIgnoredTypes() : {string : boolean} base/tealdef/game_mechanics/notifications/notification_util.d.tl:7
Aufruf: notification_util.getInitiallyIgnoredTypes(…)
Hinweise
Liest initiallyIgnoredType aller Benachrichtigungsressourcen.
Rückgabe {string : boolean}: Zuordnung vom Skriptnamen des Benachrichtigungstyps dazu, ob der Typ in einem neuen Spiel ignoriert wird.
getNotificationType2Label() : {string : string} base/tealdef/game_mechanics/notifications/notification_util.d.tl:8
Aufruf: notification_util.getNotificationType2Label(…)
Hinweise
Liest die Beschriftungen aller Benachrichtigungsressourcen, wie sie im Protokollfilter stehen.
Rückgabe {string : string}: Zuordnung vom Skriptnamen des Benachrichtigungstyps zu seiner Beschriftung. Typen ohne Beschriftung fehlen.
getAllNotificationGuiTypes() : {NotificationGuiData.Type} base/tealdef/game_mechanics/notifications/notification_util.d.tl:9
Aufruf: notification_util.getAllNotificationGuiTypes(…)
Hinweise
Sammelt die GUI-Kategorien, die alle Benachrichtigungsressourcen verwenden.
Rückgabe {NotificationGuiData.Type}: Jede Kategorie einmal, in keiner festen Reihenfolge. "Unknown" steht für Ressourcen ohne guiType.
getAllNotificationTypesForGuiType(guiType : NotificationGuiData.Type) : {string} base/tealdef/game_mechanics/notifications/notification_util.d.tl:10
Aufruf: notification_util.getAllNotificationTypesForGuiType(…)
Hinweise
Listet alle Benachrichtigungstypen einer GUI-Kategorie.
| Parameter | Typ | Beschreibung |
|---|---|---|
guiType |
NotificationGuiData.Type |
Die Kategorie. |
Rückgabe {string}: Skriptnamen der Benachrichtigungstypen.
Im Basisspiel verwendet: 3-mal in 2 Dateien
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:217
base/content/game_mechanics/game_mechanics/notifications/notifications.script.tl:763
getNotificationSimUpdateScript(type : string) : string base/tealdef/game_mechanics/notifications/notification_util.d.tl:11
Aufruf: notification_util.getNotificationSimUpdateScript(…)
Hinweise
Liest das simUpdateScript eines Benachrichtigungstyps.
| Parameter | Typ | Beschreibung |
|---|---|---|
type |
string |
Skript des Benachrichtigungstyps, wie in Notification.type. |
Rückgabe string: Der Funktionspfad, z. B. "::/game_mechanics/notifications/types/overcrowding.sim.script@updateData", oder nil.
removeNotification(NotificationsState, integer) base/tealdef/game_mechanics/notifications/notification_util.d.tl:13
Aufruf: notification_util.removeNotification(…)
Hinweise
Löscht eine Benachrichtigung aus dem Zustand und aus der Historie.
| Parameter | Typ | Beschreibung |
|---|---|---|
#1 |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
#2 |
integer |
Id der Benachrichtigung. Unbekannte Ids werden ignoriert. |
addNotification(NotificationsState, Notification) : integer base/tealdef/game_mechanics/notifications/notification_util.d.tl:14
Aufruf: notification_util.addNotification(…)
Hinweise
Speichert eine neue Benachrichtigung, führt ihr Sim-Update-Skript aus und kürzt die Historie auf 100 Einträge.
| Parameter | Typ | Beschreibung |
|---|---|---|
#1 |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
#2 |
Notification |
Die Benachrichtigung. |
Rückgabe integer: Id der neuen Benachrichtigung. nil, wenn ihr Typ vollständig ignoriert wird, -1, wenn keine freie Id gefunden wurde.
Details
Die Funktion prüft paused nicht, das übernimmt der Handler des add-Events.
enlistNotification(state : NotificationsState, notificationId : integer) base/tealdef/game_mechanics/notifications/notification_util.d.tl:15
Aufruf: notification_util.enlistNotification(…)
Hinweise
Löscht das Flag dismissed, damit die Benachrichtigung wieder in den Pop-ups erscheint.
| Parameter | Typ | Beschreibung |
|---|---|---|
state |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
notificationId |
integer |
Id der Benachrichtigung. |
dismissNotification(state : NotificationsState, notificationId : integer) base/tealdef/game_mechanics/notifications/notification_util.d.tl:16
Aufruf: notification_util.dismissNotification(…)
Hinweise
Setzt das Flag dismissed. Die Benachrichtigung erscheint dann nicht mehr in den Pop-ups.
| Parameter | Typ | Beschreibung |
|---|---|---|
state |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
notificationId |
integer |
Id der Benachrichtigung. |
updatePersistentNotifications(NotificationsState, {string : {integer}}, PersistentNotifications) base/tealdef/game_mechanics/notifications/notification_util.d.tl:17
Aufruf: notification_util.updatePersistentNotifications(…)
Hinweise
Wendet ein PersistentNotifications-Update an. Das Event updatePersistent ruft die Funktion auf.
| Parameter | Typ | Beschreibung |
|---|---|---|
#1 |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
#2 |
{string : {integer}} |
Ids der dauerhaften Benachrichtigungen nach Typ, aus getPersistentHistoryByType. |
#3 |
PersistentNotifications |
Das Update. |
removePersistentNotifications(NotificationsState, {string : {integer}}, RemovePersistentNotifications) base/tealdef/game_mechanics/notifications/notification_util.d.tl:18
Aufruf: notification_util.removePersistentNotifications(…)
Hinweise
Lässt die dauerhaften Benachrichtigungen ablaufen, auf die ein RemovePersistentNotifications passt. Das Event removePersistent ruft die Funktion auf.
| Parameter | Typ | Beschreibung |
|---|---|---|
#1 |
NotificationsState |
Benachrichtigungszustand, der geändert wird. |
#2 |
{string : {integer}} |
Ids der dauerhaften Benachrichtigungen nach Typ, aus getPersistentHistoryByType. |
#3 |
RemovePersistentNotifications |
Typ und Entitäten, nach denen gesucht wird. |
externalGetNotificationsState() : NotificationsState base/tealdef/game_mechanics/notifications/notification_util.d.tl:19
Aufruf: notification_util.externalGetNotificationsState(…)
Hinweise
Liest den Zustand des Benachrichtigungs-Game-Scripts aus seiner GAME_SCRIPT-Komponente.
Rückgabe NotificationsState: Der Zustand als Lua-Tabelle.
getPersistentHistoryByType(state : NotificationsState) : {string : {integer}} base/tealdef/game_mechanics/notifications/notification_util.d.tl:20
Aufruf: notification_util.getPersistentHistoryByType(…)
Hinweise
Gruppiert die Ids der dauerhaften Benachrichtigungen in der Historie nach Typ.
| Parameter | Typ | Beschreibung |
|---|---|---|
state |
NotificationsState |
Benachrichtigungszustand. |
Rückgabe {string : {integer}}: Zuordnung vom Benachrichtigungstyp zu Ids, in der Reihenfolge der Historie.
externalGetNotificationsStateNative() : NativeLuaTable base/tealdef/game_mechanics/notifications/notification_util.d.tl:23
Aufruf: notification_util.externalGetNotificationsStateNative(…)
Hinweise
Liest den Zustand des Benachrichtigungs-Game-Scripts, ohne ihn in eine Lua-Tabelle umzuwandeln (state_native der GAME_SCRIPT-Komponente).
Rückgabe NativeLuaTable: Der native Zustand. Lies ihn mit den ...FromNative-Funktionen.
Im Basisspiel verwendet: 19-mal in 13 Dateien
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:333
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:94
local notificationStateNative : NativeLuaTable = notification_util.externalGetNotificationsStateNative()
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:91
local notificationRefNative : NativeLuaTable = notification_util.externalGetNotificationsStateNative()
base/content/gui/gui/entity_window/entity_window_util.tl:2134
local notificationStateNative : NativeLuaTable = notification_util.externalGetNotificationsStateNative()
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:109
local notificationStateNative : NativeLuaTable = notification_util.externalGetNotificationsStateNative()
base/content/gui/gui/main/game_tooltips.tl:172
… und 7 weitere Dateien.
getPersistingEntity2NotificationFromNative(nativeState : NativeLuaTable) : {Engine.Entity : {integer}} base/tealdef/game_mechanics/notifications/notification_util.d.tl:24
Aufruf: notification_util.getPersistingEntity2NotificationFromNative(…)
Hinweise
Ordnet jeder Entität die dauerhaften Benachrichtigungen zu, die an ihr hängen.
| Parameter | Typ | Beschreibung |
|---|---|---|
nativeState |
NativeLuaTable |
Zustand aus externalGetNotificationsStateNative. |
Rückgabe {Engine.Entity : {integer}}: Zuordnung von Entität zu Ids der Benachrichtigungen.
Im Basisspiel verwendet: 12-mal in 10 Dateien
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:92
local persistingEntity2Notification = notification_util.getPersistingEntity2NotificationFromNative(notificationRefNative)
base/content/gui/gui/entity_window/entity_window_util.tl:2135
local persistingEntity2Notification = notification_util.getPersistingEntity2NotificationFromNative(notificationStateNative)
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:110
local persistingEntity2Notification = notification_util.getPersistingEntity2NotificationFromNative(notificationStateNative)
base/content/gui/gui/main/game_tooltips.tl:173
local persistingEntity2Notification = notification_util.getPersistingEntity2NotificationFromNative(notificationStateNative)
base/content/gui/gui/statistics/statistic_industries.tl:395
notificationsState = notification_util.getPersistingEntity2NotificationFromNative(notification_util.externalGetNotificationsStateNative()),
base/content/gui/gui/statistics/statistic_lines.tl:384
… und 4 weitere Dateien.
getHistoryFromNative(nativeState : NativeLuaTable) : {integer} base/tealdef/game_mechanics/notifications/notification_util.d.tl:25
Aufruf: notification_util.getHistoryFromNative(…)
Hinweise
Kopiert die Historie aus dem nativen Zustand.
| Parameter | Typ | Beschreibung |
|---|---|---|
nativeState |
NativeLuaTable |
Zustand aus externalGetNotificationsStateNative. |
Rückgabe {integer}: Ids der Benachrichtigungen, die älteste zuerst.
Im Basisspiel verwendet: 2-mal in 2 Dateien
base/content/game_mechanics/game_mechanics/notifications/gui/notification_log.tl:335
base/content/game_mechanics/game_mechanics/notifications/gui/notification_popups.tl:251
getNotificationFromNative(nativeState : NativeLuaTable, notificationId : integer) : Notification base/tealdef/game_mechanics/notifications/notification_util.d.tl:26
Aufruf: notification_util.getNotificationFromNative(…)
Hinweise
Kopiert eine Benachrichtigung aus dem nativen Zustand.
| Parameter | Typ | Beschreibung |
|---|---|---|
nativeState |
NativeLuaTable |
Zustand aus externalGetNotificationsStateNative. |
notificationId |
integer |
Id der Benachrichtigung. |
Rückgabe Notification: Die Benachrichtigung als Lua-Tabelle.
Im Basisspiel verwendet: 5-mal in 5 Dateien
base/content/game_mechanics/game_mechanics/notifications/types/notification_react_util.tl:107
local notification = notification_util.getNotificationFromNative(notificationStateRef:get(), notificationId)
base/content/gui/gui/entity_window/entity_window_util.tl:2141
local notification = notification_util.getNotificationFromNative(notificationStateNative, notificationId)
base/content/gui/gui/line_vehicle_mgmt/line_react_util.tl:116
local notification = notification_util.getNotificationFromNative(notificationStateNative, notificationId)
base/content/gui/gui/main/game_tooltips.tl:178
local notification = notification_util.getNotificationFromNative(notificationStateNative, notificationId)
base/content/gui/gui/statistics/statistics_react_util.tl:360
getNotificationEntryFromNative(nativeState : NativeLuaTable, notificationId : integer) : NotificationsState.Entry base/tealdef/game_mechanics/notifications/notification_util.d.tl:27
Aufruf: notification_util.getNotificationEntryFromNative(…)
Hinweise
Kopiert einen Eintrag des Zustands (Benachrichtigung mit Anzeige-Flags) aus dem nativen Zustand.
| Parameter | Typ | Beschreibung |
|---|---|---|
nativeState |
NativeLuaTable |
Zustand aus externalGetNotificationsStateNative. |
notificationId |
integer |
Id der Benachrichtigung. |
Rückgabe NotificationsState.Entry: Der Eintrag als Lua-Tabelle.
makeDefaultWouldClick(entityAndRevision : {EntityUtil.EntityAndRevision}) : function() : boolean base/tealdef/game_mechanics/notifications/notification_util.d.tl:29
Aufruf: notification_util.makeDefaultWouldClick(…)
Hinweise
Erzeugt eine wouldClick-Funktion für NotificationGuiData.
| Parameter | Typ | Beschreibung |
|---|---|---|
entityAndRevision |
{EntityUtil.EntityAndRevision} |
Entitäten der Benachrichtigung. |
Rückgabe function() : boolean: Funktion, die true zurückgibt, wenn eine der Entitäten noch unverändert existiert.
Im Basisspiel verwendet: 20-mal in 20 Dateien
base/content/game_mechanics/game_mechanics/company/company_notification_greenify.script.tl:34
base/content/game_mechanics/game_mechanics/company/company_notification_marketing.script.tl:64
base/content/game_mechanics/game_mechanics/company/company_notification_prospection.script.tl:87
wouldClick = notification_util.makeDefaultWouldClick({notificationParams.resultEntity, notificationParams.townEntity}),
base/content/game_mechanics/game_mechanics/notifications/types/animaldespawn.script.tl:16
base/content/game_mechanics/game_mechanics/notifications/types/cargo_rtc_warning.script.tl:43
base/content/game_mechanics/game_mechanics/notifications/types/industry_close.script.tl:69
… und 14 weitere Dateien.
makeDefaultOnClick(entityAndRevision : {EntityUtil.EntityAndRevision}) : function(stack : boolean) : boolean base/tealdef/game_mechanics/notifications/notification_util.d.tl:30
Aufruf: notification_util.makeDefaultOnClick(…)
Hinweise
Erzeugt eine onClick-Funktion für NotificationGuiData. Sie bewegt die Kamera zur ersten Entität, die noch unverändert existiert, und wählt sie aus.
| Parameter | Typ | Beschreibung |
|---|---|---|
entityAndRevision |
{EntityUtil.EntityAndRevision} |
Entitäten der Benachrichtigung. |
Rückgabe function(stack : boolean) : boolean: Funktion, die stack bekommt (wird mit dem GUI-Event selectEntity weitergegeben) und true zurückgibt, wenn sie eine Entität gefunden hat.
Im Basisspiel verwendet: 20-mal in 20 Dateien
base/content/game_mechanics/game_mechanics/company/company_notification_greenify.script.tl:35
base/content/game_mechanics/game_mechanics/company/company_notification_marketing.script.tl:65
base/content/game_mechanics/game_mechanics/company/company_notification_prospection.script.tl:88
onClick = notification_util.makeDefaultOnClick({notificationParams.resultEntity, notificationParams.townEntity}),
base/content/game_mechanics/game_mechanics/notifications/types/animaldespawn.script.tl:17
base/content/game_mechanics/game_mechanics/notifications/types/cargo_rtc_warning.script.tl:44
base/content/game_mechanics/game_mechanics/notifications/types/industry_close.script.tl:70
… und 14 weitere Dateien.