Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/gamesetup/Chat/ChatPanel.js
- This file was added.
/** | |||||
* This class handles a relatively generic chat panel. | |||||
*/ | |||||
class ChatPanel | |||||
{ | |||||
constructor(useTimestampWrapper) | |||||
{ | |||||
this.statusMessageFormat = new StatusMessageFormat(); | |||||
this.chatMessagesPanel = new ChatMessagesPanel(useTimestampWrapper); | |||||
this.chatInputAutocomplete = new ChatInputAutocomplete(); | |||||
this.chatInputPanel = new ChatInputPanel(this.chatInputAutocomplete); | |||||
this.chatPanel = Engine.GetGUIObjectByName("chatPanel"); | |||||
this.chatPanel.onWindowResized = () => this.updateHidden; | |||||
this.hidden = false; | |||||
} | |||||
setAutocompleteGetter(getter) | |||||
{ | |||||
this.chatInputAutocomplete.setAutocompleteGetter(getter); | |||||
} | |||||
onAutocompleteChange() | |||||
{ | |||||
this.chatInputAutocomplete.onAutocompleteChange(); | |||||
} | |||||
addText(text) | |||||
{ | |||||
this.chatMessagesPanel.addText(text); | |||||
} | |||||
addStatusMessage(text) | |||||
{ | |||||
this.chatMessagesPanel.addStatusMessage(text); | |||||
} | |||||
clearChatMessages() | |||||
{ | |||||
this.chatMessagesPanel.clearChatMessages(); | |||||
} | |||||
setEnabledInput(enabled) | |||||
{ | |||||
this.chatInputPanel.setEnabled(enabled); | |||||
} | |||||
getSize() | |||||
{ | |||||
return this.chatPanel.size; | |||||
} | |||||
setSize(size) | |||||
{ | |||||
this.chatPanel.size = size; | |||||
this.updateHidden(); | |||||
} | |||||
setHidden(hidden) | |||||
{ | |||||
if (this.hidden !== hidden) | |||||
{ | |||||
this.hidden = hidden; | |||||
this.updateHidden(); | |||||
} | |||||
} | |||||
updateHidden() | |||||
{ | |||||
let size = this.chatPanel.getComputedSize(); | |||||
this.chatPanel.hidden = this.hidden || size.right - size.left < this.MinimumWidth; | |||||
} | |||||
} | |||||
/** | |||||
* Minimum amount of pixels required for the chat panel to be visible. | |||||
*/ | |||||
ChatPanel.prototype.MinimumWidth = 96; |
Wildfire Games · Phabricator