Example #1
0
        public void AddTab(ChatTabData tabData)
        {
            ChatTab chatTab = Instantiate(chatTabPrefab, tabRow);

            chatTab.Init(tabData, this);
            LoadTab(chatTab.Data);
        }
Example #2
0
        public void Init(ChatTabData tabData, ChatRegister chatRegister)
        {
            this.chatRegister = chatRegister;

            AddTab(tabData);
            LoadChannelSelector(tabData);
        }
Example #3
0
 public void Init(ChatTabData data, ChatWindow window)
 {
     Data       = data;
     chatWindow = window;
     Text.text  = data.Name;
     transform.SetAsFirstSibling();
     Data.Tab = this;
     StartCoroutine(FixTabWidth());
 }
Example #4
0
        public void Init(ChatTabData tabData, ChatRegister chatRegister)
        {
            this.chatRegister = chatRegister;

            AddTab(tabData);
            LoadChannelSelector(tabData);

            ToggleChatWindowUI(); // Hide window by default
        }
Example #5
0
        public ChatTab AddTab(ChatTabData tabData)
        {
            ChatTab chatTab = Instantiate(chatTabPrefab, tabRow);

            chatTab.Init(tabData, this);
            LoadTab(chatTab.Data);

            SelectTab(chatTab.gameObject);
            return(chatTab);
        }
Example #6
0
        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();
        }
Example #7
0
        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)
                        )
                    );
            }
        }
Example #8
0
        /// <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);
            }
        }
Example #9
0
 public void LoadTab(ChatTabData tabData)
 {
     currentTabData = tabData;
     LoadTabChatLog(tabData);
     LoadChannelSelector(tabData);
 }
Example #10
0
 public List <ChatMessage> GetRelevantMessages(ChatTabData tabData)
 {
     return(messages.Where(x => tabData.Channels.Any(y => x.Channel.Equals(y))).ToList());
 }