diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index fc2499e2cc..95a44ba787 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -237,7 +237,7 @@ add = Shift ; Add units to selection milonly = Alt ; Add only military units to selection idleonly = "I" ; Select only idle units remove = Ctrl ; Remove units from selection -cancel = Esc ; Un-select all units and cancel building placement +cancel = Esc ; Un-select all units and cancel building placement idleworker = Period ; Select next idle worker idlewarrior = ForwardSlash ; Select next idle warrior offscreen = Alt ; Include offscreen units in selection @@ -381,6 +381,9 @@ ambientgain = 0.6 actiongain = 0.7 uigain = 0.7 +[sound.notify] +nick = true ; Play a sound when someone mentions your name in the lobby or game + [tinygettext] debug = false ; Print error messages each time a translation for an English string is not found. diff --git a/binaries/data/mods/public/audio/interface/ui/chat_alert.ogg b/binaries/data/mods/public/audio/interface/ui/chat_alert.ogg new file mode 100644 index 0000000000..f695e2d694 --- /dev/null +++ b/binaries/data/mods/public/audio/interface/ui/chat_alert.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e89aa027532ab4e0744b815dcf3ffd029c659e19307c0ded5e765781caf30716 +size 24847 diff --git a/binaries/data/mods/public/gui/common/functions_utility.js b/binaries/data/mods/public/gui/common/functions_utility.js index 83990e264a..9984cb04cc 100644 --- a/binaries/data/mods/public/gui/common/functions_utility.js +++ b/binaries/data/mods/public/gui/common/functions_utility.js @@ -1,3 +1,8 @@ +/** + * Used by notifyUser() to limit the number of pings + */ +var g_LastNickNotification = -1; + function getRandom(randomMin, randomMax) { // Returns a random whole number in a min..max range. @@ -255,6 +260,23 @@ function clearChatMessages() } } +/** + * Plays a sound if user's nick is mentioned in chat + */ +function notifyUser(userName, msgText) +{ + if (Engine.ConfigDB_GetValue("user", "sound.notify.nick") != "true" || + msgText.toLowerCase().indexOf(userName.toLowerCase()) == -1) + return; + + let timeNow = new Date().getTime(); + + if (!g_LastNickNotification || timeNow > g_LastNickNotification + 3000) + Engine.PlayUISound("audio/interface/ui/chat_alert.ogg", false); + + g_LastNickNotification = timeNow; +} + /** * Returns a formatted string describing the player assignments. * Needs g_CivData to translate! diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json index 52c9de945e..c236750016 100644 --- a/binaries/data/mods/public/gui/credits/texts/programming.json +++ b/binaries/data/mods/public/gui/credits/texts/programming.json @@ -24,6 +24,7 @@ {"nick": "Alan", "name": "Alan Kemp"}, {"nick": "aBothe", "name": "Alexander Bothe"}, {"nick": "alpha123", "name": "Peter P. Cannici"}, + {"nick": "andy5995", "name": "Andy Alt"}, {"nick": "Aurium", "name": "Aurélio Heckert"}, {"nick": "badmadblacksad", "name": "Martin F"}, {"name": "Mikołaj \"Bajter\" Korcz"}, diff --git a/binaries/data/mods/public/gui/gamesetup/gamesetup.js b/binaries/data/mods/public/gui/gamesetup/gamesetup.js index 14d7491e44..8f3772e4a9 100644 --- a/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ b/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -1806,6 +1806,14 @@ function colorizePlayernameByGUID(guid, username = "") function addChatMessage(msg) { + if (msg.text) + { + let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name; + + if (userName != g_PlayerAssignments[msg.guid].name) + notifyUser(userName, msg.text); + } + if (!g_FormatChatMessage[msg.type]) return; diff --git a/binaries/data/mods/public/gui/lobby/lobby.js b/binaries/data/mods/public/gui/lobby/lobby.js index 5add8ac626..c76d03152c 100644 --- a/binaries/data/mods/public/gui/lobby/lobby.js +++ b/binaries/data/mods/public/gui/lobby/lobby.js @@ -821,7 +821,10 @@ function addChatMessage(msg) // Highlight local user's nick if (g_Username != msg.from) + { msg.text = msg.text.replace(g_Username, colorPlayerName(g_Username)); + notifyUser(g_Username, msg.text); + } // Run spam test if it's not a historical message if (!msg.datetime) diff --git a/binaries/data/mods/public/gui/options/options.json b/binaries/data/mods/public/gui/options/options.json index 51d58f0e3b..c95d59b4c7 100644 --- a/binaries/data/mods/public/gui/options/options.json +++ b/binaries/data/mods/public/gui/options/options.json @@ -165,7 +165,7 @@ { "type": "boolean", "label": "Water Refraction", - "tooltip": "Use a real water refraction map and not transparency", + "tooltip": "Use a real water refraction map and not transparency", "parameters": { "config": "waterrefraction", "renderer": "WaterRefraction" } }, { @@ -230,20 +230,26 @@ "label": "UI Gain", "tooltip": "UI sound gain", "parameters": { "config": "sound.uigain", "function": "SetUIGain", "min": "0" } + }, + { + "type": "boolean", + "label": "Nick Notification", + "tooltip": "Receive audio notification when someone types your nick", + "parameters": { "config": "sound.notify.nick" } } ], "lobbySetting": [ { "type": "number", - "label": "Chat Backlog", - "tooltip": "Number of backlogged messages to load when joining the lobby", + "label": "Chat Backlog", + "tooltip": "Number of backlogged messages to load when joining the lobby", "parameters": { "config": "lobby.history", "min": "0" } }, { "type": "boolean", "label": "Chat Timestamp", - "tooltip": "Show time that messages are posted in the lobby chat", + "tooltip": "Show time that messages are posted in the lobby chat", "parameters": { "config": "lobby.chattimestamp" } } ] diff --git a/binaries/data/mods/public/gui/session/messages.js b/binaries/data/mods/public/gui/session/messages.js index 13f2838d76..5cec0cab45 100644 --- a/binaries/data/mods/public/gui/session/messages.js +++ b/binaries/data/mods/public/gui/session/messages.js @@ -822,6 +822,7 @@ function formatChatCommand(msg) // Translate or escape text if (!msg.text) return ""; + if (msg.translate) { msg.text = translate(msg.text); @@ -833,8 +834,15 @@ function formatChatCommand(msg) } } else + { msg.text = escapeText(msg.text); + let userName = g_PlayerAssignments[Engine.GetPlayerGUID() || "local"].name; + + if (userName != g_PlayerAssignments[msg.guid].name) + notifyUser(userName, msg.text); + } + // GUID for players, playerID for AIs let coloredUsername = msg.guid != -1 ? colorizePlayernameByGUID(msg.guid) : colorizePlayernameByID(msg.player);