コード例 #1
0
        /// <summary>
        /// Sets the selected chat channel to type in by default to the channel corresponding to the provided tab.
        /// </summary>
        /// <param name="tab">The tab to use for reference as to which channel we want to speak in.</param>
        private void SetChannelToTab(ChatboxTab tab)
        {
            switch (tab)
            {
            case ChatboxTab.System:
            case ChatboxTab.All:
                mChannelCombobox.SelectByUserData(mLastChatChannel[tab]);
                break;

            case ChatboxTab.Local:
                mChannelCombobox.SelectByUserData(0);
                break;

            case ChatboxTab.Global:
                mChannelCombobox.SelectByUserData(1);
                break;

            case ChatboxTab.Party:
                mChannelCombobox.SelectByUserData(2);
                break;

            default:
                // remain unchanged.
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the click event of a chat tab button.
        /// </summary>
        /// <param name="sender">The button that was clicked.</param>
        /// <param name="arguments">The arguments passed by the event.</param>
        private void TabButtonClicked(Base sender, ClickedEventArgs arguments)
        {
            // Enable all buttons again!
            EnableChatTabs();

            // Disable the clicked button to fake our tab being selected and set our selected chat tab.
            sender.Disable();
            var tab = (ChatboxTab)sender.UserData;

            mCurrentTab = tab;

            // Change the default channel we're trying to chat in based on the tab we've just selected.
            SetChannelToTab(tab);
        }
コード例 #3
0
        /// <summary>
        /// Retrieves all messages that should be displayed in the provided tab.
        /// </summary>
        /// <param name="tab">The tab for which to retrieve all messages.</param>
        /// <returns>Returns a list of chat messages.</returns>
        public static List <ChatboxMsg> GetMessages(ChatboxTab tab)
        {
            var output = new List <ChatboxMsg>();

            // Are we looking for all messages?
            if (tab == ChatboxTab.All)
            {
                output = GetMessages();
            }
            else
            {
                // No, sort them out! Select what we want to display in this tab.
                foreach (var message in sGameMessages)
                {
                    if (sTabMessageTypes[tab].Contains(message.Type))
                    {
                        output.Add(message);
                    }
                }
            }

            return(output);
        }
コード例 #4
0
        //Update
        public void Update()
        {
            // TODO: Find a cleaner way to do this logic, right now this will only start working properly (ie not resetting scroll height) after a few chat messages.
            // Can't seem to find a cleaner way yet. But works in longer chat convos.
            var scrollAmount   = mChatboxMessages.GetVerticalScrollBar().ScrollAmount;
            var scrollToBottom = mChatboxMessages.GetVerticalScrollBar().ScrollAmount == 1 || (mChatboxMessages.RowCount <= 10 && mChatboxMessages.GetVerticalScrollBar().ScrollAmount <= 1);

            // Did the tab change recently? If so, we need to reset a few things to make it work...
            if (mLastTab != mCurrentTab)
            {
                mChatboxMessages.Clear();
                mChatboxMessages.GetHorizontalScrollBar().SetScrollAmount(0);
                mMessageIndex    = 0;
                mReceivedMessage = true;

                mLastTab = mCurrentTab;
            }

            if (mReceivedMessage)
            {
                mChatboxMessages.ScrollToBottom();
                mReceivedMessage = false;
            }

            var msgs = ChatboxMsg.GetMessages(mCurrentTab);

            for (var i = mMessageIndex; i < msgs.Count; i++)
            {
                var msg    = msgs[i];
                var myText = Interface.WrapText(
                    msg.Message, mChatboxMessages.Width - mChatboxMessages.GetVerticalScrollBar().Width - 8,
                    mChatboxText.Font
                    );

                foreach (var t in myText)
                {
                    var rw = mChatboxMessages.AddRow(t.Trim());
                    rw.SetTextFont(mChatboxText.Font);
                    rw.SetTextColor(msg.Color);
                    rw.ShouldDrawBackground = false;
                    rw.UserData             = msg.Target;
                    rw.Clicked      += ChatboxRow_Clicked;
                    rw.RightClicked += ChatboxRow_RightClicked;
                    mReceivedMessage = true;

                    while (mChatboxMessages.RowCount > ClientConfiguration.Instance.ChatLines)
                    {
                        mChatboxMessages.RemoveRow(0);
                    }
                }

                mMessageIndex++;
            }

            if (!scrollToBottom)
            {
                mChatboxMessages.GetVerticalScrollBar().SetScrollAmount(scrollAmount);
            }
            else
            {
                mChatboxMessages.GetVerticalScrollBar().SetScrollAmount(1);
            }
        }