forked from mirrors/0ad
Acoustic notification when someone mentions the name of the player in the lobby or game chat. Patch and soundfile by andy5995.
This was SVN commit r18545.
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
Binary file not shown.
@@ -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!
|
||||
|
||||
@@ -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"},
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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" }
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user