Differential D4385 Diff 19500 binaries/data/mods/public/gui/lobby/LobbyPage/Chat/ChatMessages/ChatMessageFormat.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/LobbyPage/Chat/ChatMessages/ChatMessageFormat.js
Show All 12 Lines | constructor() | ||||
this.chatMessagePrivateWrapper = new ChatMessagePrivateWrapper(); | this.chatMessagePrivateWrapper = new ChatMessagePrivateWrapper(); | ||||
} | } | ||||
/** | /** | ||||
* Message properties: from, text, historic, optionally private | * Message properties: from, text, historic, optionally private | ||||
*/ | */ | ||||
format(message) | format(message) | ||||
{ | { | ||||
let text = escapeText(message.text); | let text = setStringTags(escapeText(message.text), this.ColorTags.chatmessage); | ||||
if (g_Nickname != message.from) | if (g_Nickname != message.from) | ||||
{ | { | ||||
// Highlight nicknames, assume they do not contain escapaped characters | // Highlight nicknames, assume they do not contain escapaped characters | ||||
text = text.replace(g_Nickname, PlayerColor.ColorPlayerName(g_Nickname)); | text = text.replace(g_Nickname, setStringTags(g_Nickname, this.ColorTags.notification)); | ||||
// Notify local player | // Notify local player | ||||
if (!message.historic && text.toLowerCase().indexOf(g_Nickname.toLowerCase()) != -1) | if (!message.historic && text.toLowerCase().indexOf(g_Nickname.toLowerCase()) != -1) | ||||
soundNotification("nick"); | soundNotification("nick"); | ||||
} | } | ||||
// Append buddysymbol to playernames in the chat if buddy | |||||
let sender = (g_Buddies.indexOf(message.from) != -1) ? setStringTags(g_BuddySymbol, PlayerColor.ColorTags.buddyIcon) + setStringTags(message.from, PlayerColor.ColorTags.buddyUsername) : | |||||
setStringTags(message.from, PlayerColor.ColorTags.username); | |||||
let sender = PlayerColor.ColorPlayerName(message.from, undefined, Engine.LobbyGetPlayerRole(message.from)); | |||||
// Handle chat format commands | // Handle chat format commands | ||||
let formattedMessage; | let formattedMessage; | ||||
let index = text.indexOf(" "); | let index = text.indexOf(" "); | ||||
if (text.startsWith("/") && index != -1) | if (text.startsWith("/") && index != -1) | ||||
{ | { | ||||
let command = text.substr(1, index - 1); | let command = text.substr(1, index - 1); | ||||
let commandText = text.substr(index + 1); | let commandText = text.substr(index + 1); | ||||
Show All 21 Lines | else | ||||
formattedMessage = this.chatMessageFormatSay.format(sender, text); | formattedMessage = this.chatMessageFormatSay.format(sender, text); | ||||
if (message.level == "private-message") | if (message.level == "private-message") | ||||
formattedMessage = this.chatMessagePrivateWrapper.format(formattedMessage); | formattedMessage = this.chatMessagePrivateWrapper.format(formattedMessage); | ||||
return formattedMessage; | return formattedMessage; | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Can be customized in the game options -> lobby menu by the user. | |||||
*/ | |||||
ChatMessageFormat.prototype.ColorTags = { | |||||
"chatmessage": { | |||||
"color": (g_customColorSetting == "true") ? Engine.ConfigDB_GetValue("user", "lobby.colors.chat.message") : "lightgray" | |||||
}, | |||||
"notification": { | |||||
"color": (g_customColorSetting == "true") ? Engine.ConfigDB_GetValue("user", "lobby.colors.chat.notification") : "persiangreen" | |||||
}, | |||||
}; | |||||
Wildfire Games · Phabricator