Differential D2412 Diff 10323 binaries/data/mods/public/gui/lobby/LobbyPage/Chat/ChatMessagesPanel.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/LobbyPage/Chat/ChatMessagesPanel.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
/** | |||||
* This class stores and displays the chat history since the login and | |||||
* displays timestamps if enabled. | |||||
*/ | |||||
class ChatMessagesPanel | |||||
{ | |||||
constructor(xmppMessages) | |||||
{ | |||||
this.chatText = Engine.GetGUIObjectByName("chatText"); | |||||
this.chatHistory = ""; | |||||
this.chatMessageFormat = new ChatMessageFormat(); | |||||
this.statusMessageFormat = new StatusMessageFormat(); | |||||
if (Engine.ConfigDB_GetValue("user", "chat.timestamp") == "true") | |||||
this.chatTimestamp = new TimestampWrapper(); | |||||
this.hasUpdate = false; | |||||
xmppMessages.registerMessageBatchProcessedHandler(this.flushMessages.bind(this)); | |||||
} | |||||
// TODO: Remove proxies | |||||
addChatStatusMessage(text, time) | |||||
{ | |||||
this.addText(time, this.statusMessageFormat.format(text)); | |||||
} | |||||
addChatMessage(message) | |||||
{ | |||||
this.addText(message.time || 0, this.chatMessageFormat.format(message)); | |||||
} | |||||
addText(timestamp, text) | |||||
{ | |||||
if (this.chatTimestamp) | |||||
text = this.chatTimestamp.format(timestamp, text); | |||||
this.chatHistory += this.chatHistory ? "\n" + text : text; | |||||
this.hasUpdate = true; | |||||
} | |||||
flushMessages() | |||||
{ | |||||
if (this.hasUpdate) | |||||
{ | |||||
this.chatText.caption = this.chatHistory; | |||||
this.hasUpdate = false; | |||||
} | |||||
} | |||||
clearChatMessages() | |||||
{ | |||||
this.chatHistory = ""; | |||||
this.chatText.caption = ""; | |||||
} | |||||
} |
Wildfire Games · Phabricator