Ejemplo n.º 1
0
        public void SetItemList(List <ListDialogItem> itemList)
        {
            if (itemList.Count == 0)
            {
                return;
            }

            if (m_listItems.Count == 0)
            {
                m_scrollBar.LinesToRender = itemList[0].Style == ListDialogItem.ListItemStyle.Large ? 5 : 12;
            }

            m_scrollBar.UpdateDimensions(itemList.Count);

            ListDialogItem.ListItemStyle firstStyle = itemList[0].Style;
            lock (m_listItemLock)
                for (int i = 0; i < itemList.Count; ++i)
                {
                    m_listItems.Add(itemList[i]);
                    m_listItems[i].Style = firstStyle;
                    m_listItems[i].Index = i;
                    if (i > m_scrollBar.LinesToRender)
                    {
                        m_listItems[i].Visible = false;
                    }
                }
        }
Ejemplo 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(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_PARTY_YOU_JOINED);
                    ((EOGame)Game).Hud.AddChat(ChatTab.System, "", OldWorld.GetString(EOResourceID.STATUS_LABEL_PARTY_YOU_JOINED), ChatIcon.PlayerParty, ChatColor.PM);
                }

                Visible           = true;
                m_numMembers.Text = $"{memberList.Count}";
                m_members         = memberList;

                m_mainIsLeader = m_members.FindIndex(_member => _member.IsLeader && _member.ID == OldWorld.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;
                }
            }
        }
Ejemplo 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, ChatIcon icon = ChatIcon.None, ChatColor col = ChatColor.Default)
        {
            const int LINE_LEN = 380;

            //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)
                {
                    scrollBar.ScrollToEnd();
                }
                if (!Selected)
                {
                    tabLabel.ForeColor = 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    = "",
                LineIndent = whoPadding
            };

            if (!ts.NeedsProcessing)
            {
                lock (ChatStringsLock)
                    chatStrings.Add(new ChatIndex(chatStrings.Count, icon, who, col), text);
            }
            else
            {
                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, ChatIcon.None, "", col), chatStringsToAdd[i]);
                        }
                    }
                }
            }

            scrollBar.UpdateDimensions(chatStrings.Count);
            if (chatStrings.Count > 7)
            {
                scrollBar.ScrollToEnd();
            }
            if (!Selected)
            {
                tabLabel.ForeColor = Color.White;
            }
            if (!Visible)
            {
                Visible = true;
            }
        }
Ejemplo n.º 4
0
        public OldActiveSpells(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            _api = api;

            _childItems = new List <ISpellIcon>(SPELL_NUM_ROWS * SPELL_ROW_LENGTH);
            RemoveAllSpells();

            var localSpellSlotMap = new Dictionary <int, int>();

            _spellsKey = _tryGetCharacterRegKey();
            if (_spellsKey != null)
            {
                const string spellFmt = "item{0}";
                for (int i = 0; i < SPELL_ROW_LENGTH * 4; ++i)
                {
                    int id;
                    try
                    {
                        id = Convert.ToInt32(_spellsKey.GetValue(String.Format(spellFmt, i)));
                    }
                    catch { continue; }
                    localSpellSlotMap.Add(i, id);
                }
            }

            var localSpells = OldWorld.Instance.MainPlayer.ActiveCharacter.Spells;

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var spell in localSpells)
            {
                var rec  = OldWorld.Instance.ESF[spell.ID];
                int slot = localSpellSlotMap.ContainsValue(spell.ID)
                    ? localSpellSlotMap.First(_pair => _pair.Value == spell.ID).Key
                    : _getNextOpenSlot();

                if (slot < 0 || !_addNewSpellToSlot(slot, rec, spell.Level))
                {
                    EOMessageBox.Show("You have too many spells! They don't all fit.", "Warning", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    break;
                }

                if (slot >= SPELL_ROW_LENGTH * (SPELL_NUM_ROWS / 2))
                {
                    _childItems.Last().Visible = false;
                }
            }

            _setSize(parent.DrawArea.Width, parent.DrawArea.Height);

            _functionKeyGraphics       = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
            _functionKeyRow1SourceRect = new Rectangle(148, 51, 18, 13);
            _functionKeyRow2SourceRect = new Rectangle(148 + 18 * 8, 51, 18, 13);

            _selectedSpellName = new XNALabel(new Rectangle(9, 50, 81, 13), Constants.FontSize08pt5)
            {
                Visible   = false,
                Text      = "",
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleCenter,
                ForeColor = ColorConstants.LightGrayText
            };
            _selectedSpellName.SetParent(this);

            _selectedSpellLevel = new XNALabel(new Rectangle(32, 78, 42, 15), Constants.FontSize08pt5)
            {
                Visible   = true,
                Text      = "0",
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                ForeColor = ColorConstants.LightGrayText
            };
            _selectedSpellLevel.SetParent(this);

            var skillPoints = OldWorld.Instance.MainPlayer.ActiveCharacter.Stats.SkillPoints;

            _totalSkillPoints = new XNALabel(new Rectangle(32, 96, 42, 15), Constants.FontSize08pt5)
            {
                Visible   = true,
                Text      = skillPoints.ToString(),
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                ForeColor = ColorConstants.LightGrayText
            };
            _totalSkillPoints.SetParent(this);

            var buttonSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true);

            _levelUpButton1 = new XNAButton(buttonSheet, new Vector2(71, 77), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
            {
                FlashSpeed = 500,
                Visible    = false
            };
            _levelUpButton1.OnClick += LevelUp_Click;
            _levelUpButton1.SetParent(this);
            _levelUpButton2 = new XNAButton(buttonSheet, new Vector2(71, 95), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
            {
                FlashSpeed = 500,
                Visible    = false
            };
            _levelUpButton2.OnClick += LevelUp_Click;
            _levelUpButton2.SetParent(this);

            _scroll = new OldScrollBar(this, new Vector2(467, 2), new Vector2(16, 115), ScrollBarColors.LightOnMed)
            {
                LinesToRender = 2
            };
            _scroll.UpdateDimensions(4);

            foreach (var child in children.Where(x => !(x is EmptySpellIcon)))
            {
                OldWorld.IgnoreDialogs(child);
            }
        }