Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/lobby/LobbyPage/Chat/ChatInputPanel.js
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
class ChatInputPanel | |||||
{ | |||||
constructor(xmppMessages, chatMessagesPanel) | |||||
{ | |||||
this.chatCommandHandler = new ChatCommandHandler(chatMessagesPanel); | |||||
Engine.GetGUIObjectByName("chatSubmit").onPress = this.submitChatInput.bind(this); | |||||
this.chatInput = Engine.GetGUIObjectByName("chatInput"); | |||||
this.chatInput.onPress = this.submitChatInput.bind(this); | |||||
this.chatInput.onTab = this.autocomplete.bind(this); | |||||
this.chatInput.tooltip = colorizeAutocompleteHotkey(); | |||||
let onConnectionStatusChange = this.onConnectionStatusChange.bind(this); | |||||
xmppMessages.registerHandler("system", "connected", onConnectionStatusChange); | |||||
xmppMessages.registerHandler("system", "disconnected", onConnectionStatusChange); | |||||
} | |||||
onConnectionStatusChange() | |||||
{ | |||||
this.chatInput.hidden = !Engine.IsXmppClientConnected(); | |||||
} | |||||
onRoleChange() | |||||
{ | |||||
this.chatInput.hidden = Engine.LobbyGetPlayerRole(g_Username) == "visitor"; | |||||
} | |||||
/** | |||||
* Executes a lobby command or sends GUI input directly as chat. | |||||
*/ | |||||
submitChatInput() | |||||
{ | |||||
let text = this.chatInput.caption; | |||||
if (!text.length) | |||||
return; | |||||
if (!this.chatCommandHandler.handleChatCommand(text)) | |||||
Engine.LobbySendMessage(text); | |||||
this.chatInput.caption = ""; | |||||
} | |||||
autocomplete() | |||||
{ | |||||
autoCompleteText( | |||||
this.chatInput, | |||||
Engine.GetPlayerList().map(player => player.name)); | |||||
} | |||||
} |
Wildfire Games · Phabricator