Exemplo n.º 1
0
        public void SetOnlinePlayerList(List <OnlineEntry> onlineList)
        {
            m_onlineList.Clear();
            m_onlineList =
                onlineList.Select(_oe => new ClientOnlineEntry(_oe.Name, _oe.Title, _oe.Guild, _oe.ClassID, _oe.Icon))
                .ToList();
// ReSharper disable once StringCompareToIsCultureSpecific
            m_onlineList.Sort((x, y) => x.Name.CompareTo(y.Name));
            m_totalNumPlayers.Text = onlineList.Count.ToString(CultureInfo.CurrentCulture);
            m_scrollBar.UpdateDimensions(onlineList.Count);
            m_friendList = InteractList.LoadAllFriend();
        }
Exemplo n.º 2
0
        public void SetData(List <PartyMember> memberList)
        {
            if (memberList.TrueForAll(_member => _member.IsFullData))
            {
                if (m_members == null || m_members.Count == 0)
                {
                    ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_PARTY_YOU_JOINED);
                    ((EOGame)Game).Hud.AddChat(ChatTabs.System, "", World.GetString(DATCONST2.STATUS_LABEL_PARTY_YOU_JOINED), ChatType.PlayerParty, ChatColor.PM);
                }

                Visible           = true;
                m_numMembers.Text = string.Format("{0}", memberList.Count);
                m_members         = memberList;

                m_mainIsLeader = m_members.FindIndex(_member => _member.IsLeader && _member.ID == World.Instance.MainPlayer.ActiveCharacter.ID) >= 0;
                m_scrollBar.UpdateDimensions(memberList.Count);

                m_buttons.Clear();

                foreach (PartyMember member in m_members)
                {
                    _addRemoveButtonForMember(member);
                }
            }
            else
            {
                //update HP only
// ReSharper disable once ForCanBeConvertedToForeach
                for (int i = 0; i < memberList.Count; ++i)
                {
                    int         ndx    = m_members.FindIndex(_member => _member.ID == memberList[i].ID);
                    PartyMember member = m_members[ndx];
                    member.SetPercentHealth(memberList[i].PercentHealth);
                    m_members[ndx] = member;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds text to the tab. For multi-line text strings, does text wrapping. For text length > 415 pixels, does text wrapping
        /// </summary>
        /// <param name="who">Person that spoke</param>
        /// <param name="text">Message that was spoken</param>
        /// <param name="icon">Icon to display next to the chat</param>
        /// <param name="col">Rendering color (enumerated value)</param>
        public void AddText(string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
        {
            const int LINE_LEN = 415;

            //special case: blank line, like in the news panel between news items
            if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text))
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), " ");
                scrollBar.UpdateDimensions(chatStrings.Count);
                if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = System.Drawing.Color.White;
                }
                if (!Visible)
                {
                    Visible = true;
                }
                return;
            }

            //don't do multi-line processing if we don't need to
            if (EOGame.Instance.DBGFont.MeasureString(text).X < LINE_LEN)
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text);
                scrollBar.UpdateDimensions(chatStrings.Count);
                if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = System.Drawing.Color.White;
                }
                if (!Visible)
                {
                    Visible = true;
                }
                return;
            }

            string buffer = text, newLine = "";
            string whoPadding = "";             //padding string for additional lines if it is a multi-line message

            if (!string.IsNullOrEmpty(who))
            {
                while (EOGame.Instance.DBGFont.MeasureString(whoPadding).X < EOGame.Instance.DBGFont.MeasureString(who).X)
                {
                    whoPadding += " ";
                }
            }

            List <string> chatStringsToAdd = new List <string>();

            char[] whiteSpace = { ' ', '\t', '\n' };
            string endOfLine  = WhichTab == ChatTabs.None ? "" : "-";
            string nextWord   = "";

            while (buffer.Length > 0)             //keep going until the buffer is empty
            {
                //get the next word
                bool endOfWord = true, lineOverFlow = true;                 //these are negative logic booleans: will be set to false when flagged
                while (buffer.Length > 0 && (endOfWord = !whiteSpace.Contains(buffer[0])) &&
                       (lineOverFlow = EOGame.Instance.DBGFont.MeasureString(whoPadding + newLine + nextWord + endOfLine).X < LINE_LEN))
                {
                    nextWord += buffer[0];
                    buffer    = buffer.Remove(0, 1);
                }

                //flip the bools so the program reads more logically
                endOfWord    = !endOfWord;
                lineOverFlow = !lineOverFlow;

                if (endOfWord)
                {
                    newLine += nextWord + buffer[0];
                    buffer   = buffer.Remove(0, 1);
                    nextWord = "";
                }
                else if (lineOverFlow)
                {
                    newLine += nextWord + endOfLine;
                    chatStringsToAdd.Add(newLine);
                    newLine = nextWord = "";
                }
                else
                {
                    newLine += nextWord;
                    chatStringsToAdd.Add(newLine);
                }
            }

            for (int i = 0; i < chatStringsToAdd.Count; ++i)
            {
                lock (ChatStringsLock)
                {
                    if (i == 0)
                    {
                        chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), chatStringsToAdd[0]);
                    }
                    else
                    {
                        chatStrings.Add(new ChatIndex(chatStrings.Count, ChatType.None, whoPadding), chatStringsToAdd[i]);
                    }
                }
            }

            scrollBar.UpdateDimensions(chatStrings.Count);
            if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
            {
                scrollBar.ScrollToEnd();
            }
            if (!Selected)
            {
                tabLabel.ForeColor = System.Drawing.Color.White;
            }
            if (!Visible)
            {
                Visible = true;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds text to the tab. For multi-line text strings, does text wrapping. For text length > 415 pixels, does text wrapping
        /// </summary>
        /// <param name="who">Person that spoke</param>
        /// <param name="text">Message that was spoken</param>
        /// <param name="icon">Icon to display next to the chat</param>
        /// <param name="col">Rendering color (enumerated value)</param>
        public void AddText(string who, string text, ChatType icon = ChatType.None, ChatColor col = ChatColor.Default)
        {
            const int LINE_LEN = 415;

            //special case: blank line, like in the news panel between news items
            if (string.IsNullOrWhiteSpace(who) && string.IsNullOrWhiteSpace(text))
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), " ");
                scrollBar.UpdateDimensions(chatStrings.Count);
                if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = System.Drawing.Color.White;
                }
                if (!Visible)
                {
                    Visible = true;
                }
                return;
            }

            string whoPadding = "";             //padding string for additional lines if it is a multi-line message

            if (!string.IsNullOrEmpty(who))
            {
                while (EOGame.Instance.DBGFont.MeasureString(whoPadding).X < EOGame.Instance.DBGFont.MeasureString(who).X)
                {
                    whoPadding += " ";
                }
            }

            TextSplitter ts = new TextSplitter(text, EOGame.Instance.DBGFont)
            {
                LineLength = LINE_LEN,
                LineEnd    = WhichTab == ChatTabs.None ? "" : "-",
                LineStart  = whoPadding
            };

            //don't do multi-line processing if we don't need to
            if (!ts.NeedsProcessing)
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text);
                scrollBar.UpdateDimensions(chatStrings.Count);
                if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = System.Drawing.Color.White;
                }
                if (!Visible)
                {
                    Visible = true;
                }
                return;
            }

            List <string> chatStringsToAdd = ts.SplitIntoLines();

            for (int i = 0; i < chatStringsToAdd.Count; ++i)
            {
                lock (ChatStringsLock)
                {
                    if (i == 0)
                    {
                        chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), chatStringsToAdd[0]);
                    }
                    else
                    {
                        chatStrings.Add(new ChatIndex(chatStrings.Count, ChatType.None, whoPadding), chatStringsToAdd[i]);
                    }
                }
            }

            scrollBar.UpdateDimensions(chatStrings.Count);
            if (chatStrings.Count > 7 && WhichTab != ChatTabs.None)
            {
                scrollBar.ScrollToEnd();
            }
            if (!Selected)
            {
                tabLabel.ForeColor = System.Drawing.Color.White;
            }
            if (!Visible)
            {
                Visible = true;
            }
        }