public void AddTab(ChatTabData tabData) { ChatTab chatTab = Instantiate(chatTabPrefab, tabRow); chatTab.Init(tabData, this); LoadTab(chatTab.Data); }
public void Init(ChatTabData tabData, ChatRegister chatRegister) { this.chatRegister = chatRegister; AddTab(tabData); LoadChannelSelector(tabData); }
public void Init(ChatTabData data, ChatWindow window) { Data = data; chatWindow = window; Text.text = data.Name; transform.SetAsFirstSibling(); Data.Tab = this; StartCoroutine(FixTabWidth()); }
public void Init(ChatTabData tabData, ChatRegister chatRegister) { this.chatRegister = chatRegister; AddTab(tabData); LoadChannelSelector(tabData); ToggleChatWindowUI(); // Hide window by default }
public ChatTab AddTab(ChatTabData tabData) { ChatTab chatTab = Instantiate(chatTabPrefab, tabRow); chatTab.Init(tabData, this); LoadTab(chatTab.Data); SelectTab(chatTab.gameObject); return(chatTab); }
private void LoadTabChatLog(ChatTabData tabData) { List <ChatMessage> relevantMessages = chatRegister.GetRelevantMessages(tabData); StringBuilder sb = new StringBuilder(); foreach (ChatMessage message in relevantMessages) { sb.AppendFormat( "<color=#{0}>[{1}] {2}: {3}\n", ColorUtility.ToHtmlStringRGBA(message.Channel.Color), message.Channel.Abbreviation, message.Sender, message.Text); } ChatText.text = sb.ToString(); }
private void LoadChannelSelector(ChatTabData tabData) { channelDropDown.options.Clear(); foreach (ChatChannel channel in tabData.Channels) { //Need a more robust way to do this. Not adding the option makes the index mismatch when sending messages. //if (chatRegister.restrictedChannels.Contains(channel.Name)) continue; channelDropDown.options.Add( new TMP_Dropdown.OptionData( string.Format("<color=#{0}>[{1}]</color>", ColorUtility.ToHtmlStringRGBA(channel.Color), channel.Abbreviation) ) ); } }
/// <summary> /// Creates a new chat window with the supplied tab data. /// Adds a tab to an existing window if an existing window is supplied. /// </summary> /// <param name="tabData">tab data that decides which channels the chat listens to</param> /// <param name="existingWindow">an existing windwo to add a chat tab to rather than create a new window</param> /// <param name="position">position for the new window (vector2.zero for default position)</param> public void CreateChatWindow(ChatTabData tabData, ChatWindow existingWindow, Vector2 position) { if (existingWindow) { existingWindow.AddTab(tabData); } else { chatWindows.Add(Instantiate(chatWindowPrefab)); if (position != Vector2.zero) { chatWindows[chatWindows.Count - 1].transform.position = position; } chatWindows[chatWindows.Count - 1].Init(tabData, this); } }
public void LoadTab(ChatTabData tabData) { currentTabData = tabData; LoadTabChatLog(tabData); LoadChannelSelector(tabData); }
public List <ChatMessage> GetRelevantMessages(ChatTabData tabData) { return(messages.Where(x => tabData.Channels.Any(y => x.Channel.Equals(y))).ToList()); }