private void OnCloseChannelButtonClicked() { if (!m_ActiveChannelButton || !m_ActiveChannel.Closable) { return; } if (m_ChannelsHistory.ContainsKey(m_ActiveChannel.ID)) { Core.Utility.RingBuffer <ChannelMessageLabel> history = m_ChannelsHistory[m_ActiveChannel.ID]; foreach (ChannelMessageLabel message in history.ToArray()) { Destroy(message.gameObject); } history.RemoveAll(); m_ChannelsHistory.Remove(m_ActiveChannel.ID); } m_ChannelButtons.Remove(m_ActiveChannel.ID); var rectTransform = m_ActiveChannelButton.transform as RectTransform; var index = rectTransform.GetSiblingIndex(); int relativeIndex; if (index == 0) { relativeIndex = 1; } else { relativeIndex = index - 1; } var otherChannelButton = rectTransform.parent.GetChild(relativeIndex).GetComponent <ChannelButton>(); m_ActiveChannel = null; m_ActiveChannelButton = null; SelectChannelButton(otherChannelButton); }
private ChannelMessageLabel CreateChannelMessageLabel(Channel channel, ChannelMessage channelMessage) { Core.Utility.RingBuffer <ChannelMessageLabel> history; if (!m_ChannelsHistory.TryGetValue(channel.ID, out history)) { history = new Core.Utility.RingBuffer <ChannelMessageLabel>(1000); m_ChannelsHistory.Add(channel.ID, history); } var channelMessageLabel = Instantiate(OpenTibiaUnity.GameManager.ChannelMessageLabelPrefab, m_ConsoleMessagesContent); channelMessageLabel.Channel = channel; channelMessageLabel.ChannelMessage = channelMessage; channelMessageLabel.SetText(channelMessage.RichText); var removedMessage = history.AddItem(channelMessageLabel); if (removedMessage != null) { Destroy(removedMessage.gameObject); } return(channelMessageLabel); }
internal ChannelInformation(Channel channel) { this.channel = channel; talkHistory = new Core.Utility.RingBuffer <ChannelMessage>(Constants.MaxTalkHistory); }