Example #1
0
		public void SetLockerData(List<InventoryItem> lockerItems)
		{
			ClearItemList();
			items = lockerItems;
			Title = string.Format(TITLE_FMT, lockerItems.Count);

			List<ListDialogItem> listItems = new List<ListDialogItem>();
			foreach (InventoryItem item in lockerItems)
			{
				ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id);
				int amount = item.amount;
				ListDialogItem newItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
				{
					Text = rec.Name,
					SubText = string.Format("x{0}  {1}", item.amount,
						rec.Type == ItemType.Armor
							? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")"
							: ""),
					IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
					OffsetY = 45
				};
				newItem.OnRightClick += (o, e) => _removeItem(rec, amount);

				listItems.Add(newItem);
			}

			SetItemList(listItems);
		}
Example #2
0
        public void SetLockerData(List <InventoryItem> lockerItems)
        {
            ClearItemList();
            items = lockerItems;
            Title = string.Format(TITLE_FMT, lockerItems.Count);

            List <ListDialogItem> listItems = new List <ListDialogItem>();

            foreach (InventoryItem item in lockerItems)
            {
                var            rec     = OldWorld.Instance.EIF[item.ItemID];
                int            amount  = item.Amount;
                ListDialogItem newItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
                {
                    Text    = rec.Name,
                    SubText =
                        $"x{item.Amount}  {(rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "")}",
                    IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
                    OffsetY     = 45
                };
                newItem.OnRightClick += (o, e) => _removeItem(rec, amount);

                listItems.Add(newItem);
            }

            SetItemList(listItems);
        }
Example #3
0
        public void RemoveFromList(ListDialogItem item)
        {
            int ndx;

            lock (m_listItemLock)
                ndx = m_listItems.FindIndex(_item => _item == item);
            if (ndx < 0)
            {
                return;
            }

            item.Close();

            lock (m_listItemLock)
            {
                m_listItems.RemoveAt(ndx);

                m_scrollBar.UpdateDimensions(m_listItems.Count);
                if (m_listItems.Count <= m_scrollBar.LinesToRender)
                {
                    m_scrollBar.ScrollToTop();
                }

                for (int i = 0; i < m_listItems.Count; ++i)
                {
                    //adjust indices (determines drawing position)
                    m_listItems[i].Index = i;
                }
            }
        }
		private BankAccountDialog(PacketAPI api)
			: base(api)
		{
			//this uses EODialogListItems but does not inherit from ListDialog since it is a different size
			//offsety 50
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
			_setSize(bgTexture.Width, bgTexture.Height);

			m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
			{
				ForeColor = Constants.LightGrayText,
				Text = "",
				TextAlign = LabelAlignment.MiddleRight,
				AutoSize = false
			};
			m_accountBalance.SetParent(this);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			cancel.SetParent(this);
			cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

			ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_DEPOSIT),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TRANSFER),
					World.GetString(DATCONST2.DIALOG_BANK_TO_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankDeposit),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			deposit.OnLeftClick += (o, e) => _deposit();
			deposit.OnRightClick += (o, e) => _deposit();
			ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_WITHDRAW),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TAKE),
					World.GetString(DATCONST2.DIALOG_BANK_FROM_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankWithdraw),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			withdraw.OnLeftClick += (o, e) => _withdraw();
			withdraw.OnRightClick += (o, e) => _withdraw();
			ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_LOCKER_UPGRADE),
				SubText = World.GetString(DATCONST2.DIALOG_BANK_MORE_SPACE),
				IconGraphic = _getDlgIcon(ListIcon.BankLockerUpgrade),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			upgrade.OnLeftClick += (o, e) => _upgrade();
			upgrade.OnRightClick += (o, e) => _upgrade();

			DialogClosing += (o, e) => { Instance = null; };

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 50);
			endConstructor(false);
		}
Example #5
0
        public override void Update(GameTime gt)
        {
            //which items should we render?
            lock (m_listItemLock)
            {
                if (m_listItems.Count > m_scrollBar.LinesToRender)
                {
                    for (int i = 0; i < m_listItems.Count; ++i)
                    {
                        ListDialogItem curr = m_listItems[i];
                        if (i < m_scrollBar.ScrollOffset)
                        {
                            curr.Visible = false;
                            continue;
                        }

                        if (i < m_scrollBar.LinesToRender + m_scrollBar.ScrollOffset)
                        {
                            curr.Visible = true;
                            curr.Index   = i - m_scrollBar.ScrollOffset;
                        }
                        else
                        {
                            curr.Visible = false;
                        }
                    }
                }
                else if (m_listItems.Any(_item => !_item.Visible))
                {
                    m_listItems.ForEach(_item => _item.Visible = true); //all items visible if less than # lines to render
                }
            }

            base.Update(gt);
        }
Example #6
0
        public override void Update(GameTime gt)
        {
            if (EOGame.Instance.Hud.IsInventoryDragging())
            {
                shouldClickDrag = false;
                SuppressParentClickDrag(true);
            }
            else
            {
                shouldClickDrag = true;
                SuppressParentClickDrag(false);
            }

            //do the hiding logic for both sides
            List <OldScrollBar> scrollBars = new List <OldScrollBar> {
                m_leftScroll, m_rightScroll
            };
            List <List <ListDialogItem> > lists = new List <List <ListDialogItem> > {
                m_leftItems, m_rightItems
            };

            for (int ndx = 0; ndx < 2; ++ndx)
            {
                var list   = lists[ndx];
                var scroll = scrollBars[ndx];

                //which items should we render?
                if (list.Count > scroll.LinesToRender)
                {
                    for (int i = 0; i < list.Count; ++i)
                    {
                        ListDialogItem curr = list[i];
                        if (i < scroll.ScrollOffset)
                        {
                            curr.Visible = false;
                            continue;
                        }

                        if (i < scroll.LinesToRender + scroll.ScrollOffset)
                        {
                            curr.Visible = true;
                            curr.Index   = i - scroll.ScrollOffset;
                        }
                        else
                        {
                            curr.Visible = false;
                        }
                    }
                }
                else if (list.Any(_item => !_item.Visible))
                {
                    list.ForEach(_item => _item.Visible = true); //all items visible if less than # lines to render
                }
            }

            base.Update(gt);
        }
Example #7
0
        private void _showRequirements(Skill skill)
        {
            m_showingRequirements = true;
            ClearItemList();

            List <string> drawStrings = new List <string>(15)
            {
                OldWorld.Instance.ESF.Data[skill.ID].Name + (skill.ClassReq > 0 ? " [" + OldWorld.Instance.ECF.Data[skill.ClassReq].Name + "]" : ""),
                " "
            };

            if (skill.SkillReq.Any(x => x != 0))
            {
                drawStrings.AddRange(from req in skill.SkillReq where req != 0 select OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_SKILL) + ": " + OldWorld.Instance.ESF.Data[req].Name);
                drawStrings.Add(" ");
            }

            if (skill.StrReq > 0)
            {
                drawStrings.Add(skill.StrReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_STRENGTH));
            }
            if (skill.IntReq > 0)
            {
                drawStrings.Add(skill.IntReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_INTELLIGENCE));
            }
            if (skill.WisReq > 0)
            {
                drawStrings.Add(skill.WisReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_WISDOM));
            }
            if (skill.AgiReq > 0)
            {
                drawStrings.Add(skill.AgiReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_AGILITY));
            }
            if (skill.ConReq > 0)
            {
                drawStrings.Add(skill.ConReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CONSTITUTION));
            }
            if (skill.ChaReq > 0)
            {
                drawStrings.Add(skill.ChaReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_CHARISMA));
            }

            drawStrings.Add(" ");
            drawStrings.Add(skill.LevelReq + " " + OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEVEL));
            drawStrings.Add(skill.GoldReq + " " + OldWorld.Instance.EIF[1].Name);

            foreach (string s in drawStrings)
            {
                ListDialogItem nextLine = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small)
                {
                    Text = s
                };
                AddItemToList(nextLine, false);
            }
        }
Example #8
0
        private void _showForgetAllMessage(Action forgetAllAction)
        {
            List <string> drawStrings = new List <string>();

            string[] messages =
            {
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_1),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_2),
                OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL_MSG_3),
                OldWorld.GetString(EOResourceID.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL)
            };

            TextSplitter ts = new TextSplitter("", Game.Content.Load <SpriteFont>(Constants.FontSize08pt5))
            {
                LineLength = 200
            };

            foreach (string s in messages)
            {
                ts.Text = s;
                if (!ts.NeedsProcessing)
                {
                    //no text clipping needed
                    drawStrings.Add(s);
                    drawStrings.Add(" ");
                    continue;
                }

                drawStrings.AddRange(ts.SplitIntoLines());
                drawStrings.Add(" ");
            }

            //now need to take the processed draw strings and make an ListDialogItem for each one
            foreach (string s in drawStrings)
            {
                string next = s;
                bool   link = false;
                if (next.Length > 0 && next[0] == '*')
                {
                    next = next.Remove(0, 1);
                    link = true;
                }
                ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small)
                {
                    Text = next
                };
                if (link)
                {
                    nextItem.SetPrimaryTextLink(forgetAllAction);
                }
                AddItemToList(nextItem, false);
            }
        }
Example #9
0
        private void _setDialogText()
        {
            ClearItemList();

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

            TextSplitter ts = new TextSplitter(_pages[_pageIndex], Game.Content.Load <SpriteFont>(Constants.FontSize08pt5));

            if (!ts.NeedsProcessing)
            {
                rows.Add(_pages[_pageIndex]);
            }
            else
            {
                rows.AddRange(ts.SplitIntoLines());
            }

            int index = 0;

            foreach (var row in rows)
            {
                ListDialogItem rowItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
                {
                    Text = row
                };
                AddItemToList(rowItem, false);
            }

            if (_pageIndex < _pages.Count - 1)
            {
                return;
            }

            ListDialogItem item = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
            {
                Text = " "
            };

            AddItemToList(item, false);

            foreach (var link in _links)
            {
                ListDialogItem linkItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
                {
                    Text = link.Value
                };

                var linkIndex = (byte)link.Key;
                linkItem.SetPrimaryTextLink(() => _clickLink(linkIndex));
                AddItemToList(linkItem, false);
            }
        }
Example #10
0
        public void RemoveSkillByIDFromLearnList(short id)
        {
            if (Instance == null || this != Instance)
            {
                return;
            }

            ListDialogItem itemToRemove = children.OfType <ListDialogItem>().FirstOrDefault(_x => _x.ID == id);

            if (itemToRemove != null)
            {
                RemoveFromList(itemToRemove);
            }
        }
Example #11
0
 public void AddItemToList(ListDialogItem item, bool sortList)
 {
     if (m_listItems.Count == 0)
     {
         m_scrollBar.LinesToRender = item.Style == ListDialogItem.ListItemStyle.Large ? LargeItemStyleMaxItemDisplay : SmallItemStyleMaxItemDisplay;
     }
     lock (m_listItemLock)
     {
         m_listItems.Add(item);
         if (sortList)
         {
             m_listItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text));
         }
         for (int i = 0; i < m_listItems.Count; ++i)
         {
             m_listItems[i].Index = i;
         }
     }
     m_scrollBar.UpdateDimensions(m_listItems.Count);
 }
Example #12
0
        private void _setState(ShopState newState)
        {
            ShopState old = m_state;

            if (old == newState)
            {
                return;
            }

            int buyNumInt  = m_tradeItems.FindAll(x => x.Buy > 0).Count;
            int sellNumInt = m_tradeItems.FindAll(x => OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(item => item.ItemID == x.ID) >= 0 && x.Sell > 0).Count;

            if (newState == ShopState.Buying && buyNumInt <= 0)
            {
                EOMessageBox.Show(DialogResourceID.SHOP_NOTHING_IS_FOR_SALE, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            if (newState == ShopState.Selling && sellNumInt <= 0)
            {
                EOMessageBox.Show(DialogResourceID.SHOP_NOT_BUYING_YOUR_ITEMS, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            ClearItemList();
            switch (newState)
            {
            case ShopState.Initial:
            {
                string buyNum =
                    $"{m_tradeItems.FindAll(x => x.Buy > 0).Count} {OldWorld.GetString(EOResourceID.DIALOG_SHOP_ITEMS_IN_STORE)}";
                string sellNum  = $"{sellNumInt} {OldWorld.GetString(EOResourceID.DIALOG_SHOP_ITEMS_ACCEPTED)}";
                string craftNum =
                    $"{m_craftItems.Count} {OldWorld.GetString(EOResourceID.DIALOG_SHOP_ITEMS_ACCEPTED)}";

                ListDialogItem buy = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
                {
                    Text        = OldWorld.GetString(EOResourceID.DIALOG_SHOP_BUY_ITEMS),
                    SubText     = buyNum,
                    IconGraphic = BuyIcon,
                    OffsetY     = 45
                };
                buy.OnLeftClick       += (o, e) => _setState(ShopState.Buying);
                buy.OnRightClick      += (o, e) => _setState(ShopState.Buying);
                buy.ShowItemBackGround = false;
                AddItemToList(buy, false);
                ListDialogItem sell = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
                {
                    Text        = OldWorld.GetString(EOResourceID.DIALOG_SHOP_SELL_ITEMS),
                    SubText     = sellNum,
                    IconGraphic = SellIcon,
                    OffsetY     = 45
                };
                sell.OnLeftClick       += (o, e) => _setState(ShopState.Selling);
                sell.OnRightClick      += (o, e) => _setState(ShopState.Selling);
                sell.ShowItemBackGround = false;
                AddItemToList(sell, false);
                if (m_craftItems.Count > 0)
                {
                    ListDialogItem craft = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
                    {
                        Text        = OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_ITEMS),
                        SubText     = craftNum,
                        IconGraphic = CraftIcon,
                        OffsetY     = 45
                    };
                    craft.OnLeftClick       += (o, e) => _setState(ShopState.Crafting);
                    craft.OnRightClick      += (o, e) => _setState(ShopState.Crafting);
                    craft.ShowItemBackGround = false;
                    AddItemToList(craft, false);
                }
                _setButtons(ScrollingListDialogButtons.Cancel);
            }
            break;

            case ShopState.Buying:
            case ShopState.Selling:
            {
                //re-use the logic for Buying/Selling: it is almost identical
                bool buying = newState == ShopState.Buying;

                List <ListDialogItem> itemList = new List <ListDialogItem>();
                foreach (ShopItem si in m_tradeItems)
                {
                    if (si.ID <= 0 || (buying && si.Buy <= 0) ||
                        (!buying && (si.Sell <= 0 || OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(inv => inv.ItemID == si.ID) < 0)))
                    {
                        continue;
                    }

                    ShopItem localItem = si;
                    var      rec       = OldWorld.Instance.EIF[si.ID];
                    string   secondary = string.Format("{2}: {0} {1}", buying ? si.Buy : si.Sell,
                                                       rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "",
                                                       OldWorld.GetString(EOResourceID.DIALOG_SHOP_PRICE));

                    ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
                    {
                        Text        = rec.Name,
                        SubText     = secondary,
                        IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
                        OffsetY     = 45
                    };
                    nextItem.OnLeftClick  += (o, e) => _buySellItem(localItem);
                    nextItem.OnRightClick += (o, e) => _buySellItem(localItem);

                    itemList.Add(nextItem);
                }
                SetItemList(itemList);
                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;

            case ShopState.Crafting:
            {
                List <ListDialogItem> itemList = new List <ListDialogItem>(m_craftItems.Count);
                foreach (CraftItem ci in m_craftItems)
                {
                    if (ci.Ingredients.Count <= 0)
                    {
                        continue;
                    }

                    CraftItem localItem = ci;
                    var       rec       = OldWorld.Instance.EIF[ci.ID];
                    string    secondary = string.Format("{2}: {0} {1}", ci.Ingredients.Count,
                                                        rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "",
                                                        OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_INGREDIENTS));

                    ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
                    {
                        Text        = rec.Name,
                        SubText     = secondary,
                        IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
                        OffsetY     = 45
                    };
                    nextItem.OnLeftClick  += (o, e) => _craftItem(localItem);
                    nextItem.OnRightClick += (o, e) => _craftItem(localItem);

                    itemList.Add(nextItem);
                }
                SetItemList(itemList);
                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;
            }

            m_state = newState;
        }
		public static void Show(PacketAPI apiHandle, bool isIgnoreList)
		{
			if (Instance != null)
				return;

			List<string> allLines = isIgnoreList ? InteractList.LoadAllIgnore() : InteractList.LoadAllFriend();

			string charName = World.Instance.MainPlayer.ActiveCharacter.Name;
			charName = char.ToUpper(charName[0]) + charName.Substring(1);
			string titleText = string.Format("{0}'s {2} [{1}]", charName, allLines.Count,
				World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));

			ScrollingListDialog dlg = new ScrollingListDialog
			{
				Title = titleText,
				Buttons = ScrollingListDialogButtons.AddCancel,
				ListItemType = ListDialogItem.ListItemStyle.Small
			};

			List<ListDialogItem> characters = allLines.Select(character => new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small) { Text = character }).ToList();
			characters.ForEach(character =>
			{
				character.OnLeftClick += (o, e) => EOGame.Instance.Hud.SetChatText("!" + character.Text + " ");
				character.OnRightClick += (o, e) =>
				{
					dlg.RemoveFromList(character);
					dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
						World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
				};
			});
			dlg.SetItemList(characters);

			dlg.DialogClosing += (o, e) =>
			{
				if (e.Result == XNADialogResult.Cancel)
				{
					Instance = null;
					if (isIgnoreList)
						InteractList.WriteIgnoreList(dlg.NamesList);
					else
						InteractList.WriteFriendList(dlg.NamesList);
				}
				else if (e.Result == XNADialogResult.Add)
				{
					e.CancelClose = true;
					string prompt = World.GetString(isIgnoreList ? DATCONST2.DIALOG_WHO_TO_MAKE_IGNORE : DATCONST2.DIALOG_WHO_TO_MAKE_FRIEND);
					TextInputDialog dlgInput = new TextInputDialog(prompt);
					dlgInput.DialogClosing += (_o, _e) =>
					{
						if (_e.Result == XNADialogResult.Cancel) return;

						if (dlgInput.ResponseText.Length < 4)
						{
							_e.CancelClose = true;
							EOMessageBox.Show(DATCONST1.CHARACTER_CREATE_NAME_TOO_SHORT);
							dlgInput.SetAsKeyboardSubscriber();
							return;
						}

						if (dlg.NamesList.FindIndex(name => name.ToLower() == dlgInput.ResponseText.ToLower()) >= 0)
						{
							_e.CancelClose = true;
							EOMessageBox.Show("You are already friends with that person!", "Invalid entry!", XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
							dlgInput.SetAsKeyboardSubscriber();
							return;
						}

						ListDialogItem newItem = new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
						{
							Text = dlgInput.ResponseText
						};
						newItem.OnLeftClick += (oo, ee) => EOGame.Instance.Hud.SetChatText("!" + newItem.Text + " ");
						newItem.OnRightClick += (oo, ee) =>
						{
							dlg.RemoveFromList(newItem);
							dlg.Title = string.Format("{0}'s {2} [{1}]",
								charName,
								dlg.NamesList.Count,
								World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
						};
						dlg.AddItemToList(newItem, true);
						dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
							World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
					};
				}
			};

			Instance = dlg;

			List<OnlineEntry> onlineList;
			apiHandle.RequestOnlinePlayers(false, out onlineList);
			Instance.SetActiveItemList(onlineList.Select(_oe => _oe.Name).ToList());

			EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST,
				World.GetString(DATCONST2.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE));
			//show the dialog
		}
		private void _showForgetAllMessage(Action forgetAllAction)
		{
			List<string> drawStrings = new List<string>();

			string[] messages =
			{
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_1),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_2),
				World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL_MSG_3),
				World.GetString(DATCONST2.SKILLMASTER_CLICK_HERE_TO_FORGET_ALL)
			};

			TextSplitter ts = new TextSplitter("", Game.Content.Load<SpriteFont>(Constants.FontSize08pt5)) { LineLength = 200 };
			foreach (string s in messages)
			{
				ts.Text = s;
				if (!ts.NeedsProcessing)
				{
					//no text clipping needed
					drawStrings.Add(s);
					drawStrings.Add(" ");
					continue;
				}

				drawStrings.AddRange(ts.SplitIntoLines());
				drawStrings.Add(" ");
			}

			//now need to take the processed draw strings and make an ListDialogItem for each one
			foreach (string s in drawStrings)
			{
				string next = s;
				bool link = false;
				if (next.Length > 0 && next[0] == '*')
				{
					next = next.Remove(0, 1);
					link = true;
				}
				ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small) { Text = next };
				if (link) nextItem.SetPrimaryTextLink(forgetAllAction);
				AddItemToList(nextItem, false);
			}
		}
		private void _showRequirements(Skill skill)
		{
			m_showingRequirements = true;
			ClearItemList();

			List<string> drawStrings = new List<string>(15)
			{
				((SpellRecord) World.Instance.ESF.Data[skill.ID]).Name + (skill.ClassReq > 0 ? " [" + ((ClassRecord) World.Instance.ECF.Data[skill.ClassReq]).Name + "]" : ""),
				" "
			};
			if (skill.SkillReq.Any(x => x != 0))
			{
				drawStrings.AddRange(from req in skill.SkillReq where req != 0 select World.GetString(DATCONST2.SKILLMASTER_WORD_SKILL) + ": " + ((SpellRecord) World.Instance.ESF.Data[req]).Name);
				drawStrings.Add(" ");
			}

			if(skill.StrReq > 0)
				drawStrings.Add(skill.StrReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_STRENGTH));
			if (skill.IntReq > 0)
				drawStrings.Add(skill.IntReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_INTELLIGENCE));
			if (skill.WisReq > 0)
				drawStrings.Add(skill.WisReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_WISDOM));
			if (skill.AgiReq > 0)
				drawStrings.Add(skill.AgiReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_AGILITY));
			if (skill.ConReq > 0)
				drawStrings.Add(skill.ConReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_CONSTITUTION));
			if (skill.ChaReq > 0)
				drawStrings.Add(skill.ChaReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_CHARISMA));

			drawStrings.Add(" ");
			drawStrings.Add(skill.LevelReq + " " + World.GetString(DATCONST2.SKILLMASTER_WORD_LEVEL));
			drawStrings.Add(skill.GoldReq + " " + World.Instance.EIF.GetItemRecordByID(1).Name);

			foreach (string s in drawStrings)
			{
				ListDialogItem nextLine = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small) { Text = s };
				AddItemToList(nextLine, false);
			}
		}
		private void _setState(SkillState newState)
		{
			SkillState old = m_state;

			if (old == newState) return;

			int numToLearn = m_skills.Count(_skill => !World.Instance.MainPlayer.ActiveCharacter.Spells.Exists(_spell => _spell.id == _skill.ID));
			int numToForget = World.Instance.MainPlayer.ActiveCharacter.Spells.Count;

			if (newState == SkillState.Learn && numToLearn == 0)
			{
				EOMessageBox.Show(DATCONST1.SKILL_NOTHING_MORE_TO_LEARN, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
				return;
			}

			ClearItemList();
			switch (newState)
			{
				case SkillState.Initial:
				{
					string learnNum = string.Format("{0}{1}", numToLearn, World.GetString(DATCONST2.SKILLMASTER_ITEMS_TO_LEARN));
					string forgetNum = string.Format("{0}{1}", numToForget, World.GetString(DATCONST2.SKILLMASTER_ITEMS_LEARNED));

					ListDialogItem learn = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_WORD_LEARN),
						SubText = learnNum,
						IconGraphic = LearnIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					learn.OnLeftClick += (o, e) => _setState(SkillState.Learn);
					learn.OnRightClick += (o, e) => _setState(SkillState.Learn);
					AddItemToList(learn, false);

					ListDialogItem forget = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_WORD_FORGET),
						SubText = forgetNum,
						IconGraphic = ForgetIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					forget.OnLeftClick += (o, e) => _setState(SkillState.Forget);
					forget.OnRightClick += (o, e) => _setState(SkillState.Forget);
					AddItemToList(forget, false);

					ListDialogItem forgetAll = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL),
						SubText = World.GetString(DATCONST2.SKILLMASTER_RESET_YOUR_CHARACTER),
						IconGraphic = ForgetIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					forgetAll.OnLeftClick += (o, e) => _setState(SkillState.ForgetAll);
					forgetAll.OnRightClick += (o, e) => _setState(SkillState.ForgetAll);
					AddItemToList(forgetAll, false);

					_setButtons(ScrollingListDialogButtons.Cancel);
				}
					break;
				case SkillState.Learn:
				{
					int index = 0;
					for (int i = 0; i < m_skills.Count; ++i)
					{
						if (World.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.id) >= 0)
							continue;
						int localI = i;

						SpellRecord spellData = (SpellRecord) World.Instance.ESF.Data[m_skills[localI].ID];

						ListDialogItem nextListItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
						{
							Visible = false,
							Text = spellData.Name,
							SubText = World.GetString(DATCONST2.SKILLMASTER_WORD_REQUIREMENTS),
							IconGraphic = World.GetSpellIcon(spellData.Icon, false),
							ShowItemBackGround = false,
							OffsetY = 45,
							ID = m_skills[localI].ID
						};
						nextListItem.OnLeftClick += (o, e) => _learn(m_skills[localI]);
						nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]);
						nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]);
						nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI]));
						AddItemToList(nextListItem, false);
					}

					_setButtons(ScrollingListDialogButtons.BackCancel);
				}
					break;
				case SkillState.Forget:
				{
					TextInputDialog input = new TextInputDialog(World.GetString(DATCONST1.SKILL_PROMPT_TO_FORGET, false), 32);
					input.SetAsKeyboardSubscriber();
					input.DialogClosing += (sender, args) =>
					{
						if (args.Result == XNADialogResult.Cancel) return;
						bool found =
							World.Instance.MainPlayer.ActiveCharacter.Spells.Any(
								_spell => ((SpellRecord) World.Instance.ESF.Data[_spell.id]).Name.ToLower() == input.ResponseText.ToLower());

						if (!found)
						{
							args.CancelClose = true;
							EOMessageBox.Show(DATCONST1.SKILL_FORGET_ERROR_NOT_LEARNED, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
							input.SetAsKeyboardSubscriber();
						}

						if (!m_api.ForgetSpell(
								World.Instance.MainPlayer.ActiveCharacter.Spells.Find(
									_spell => ((SpellRecord) World.Instance.ESF.Data[_spell.id]).Name.ToLower() == input.ResponseText.ToLower()).id))
						{
							Close();
							((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
						}
					};

					//should show initial info in the actual dialog since this uses a pop-up input box
					//	to select a skill to remove
					newState = SkillState.Initial;
					goto case SkillState.Initial;
				}
				case SkillState.ForgetAll:
				{
					_showForgetAllMessage(_forgetAllAction);
					_setButtons(ScrollingListDialogButtons.BackCancel);
				}
					break;
			}

			m_state = newState;
		}
Example #17
0
        public void SetPlayerItems(short playerID, List <InventoryItem> items)
        {
            int xOffset;
            List <ListDialogItem> collectionRef;
            OldScrollBar          scrollRef;

            if (playerID == m_leftPlayerID)
            {
                collectionRef         = m_leftItems;
                scrollRef             = m_leftScroll;
                xOffset               = -3;
                m_leftPlayerName.Text = $"{m_leftNameStr} {(items.Count > 0 ? "[" + items.Count + "]" : "")}";

                if (m_leftAgrees)
                {
                    m_leftAgrees            = false;
                    m_leftPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING);
                }

                //left player is NOT main, and right player (ie main) agrees, and the item count is different for left player
                //cancel the offer for the main player since the other player changed the offer
                if (m_main.ID != playerID && m_rightAgrees && collectionRef.Count != items.Count)
                {
                    m_rightAgrees            = false;
                    m_rightPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING);
                    EOMessageBox.Show(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER);
                }
            }
            else if (playerID == m_rightPlayerID)
            {
                collectionRef          = m_rightItems;
                scrollRef              = m_rightScroll;
                xOffset                = 263;
                m_rightPlayerName.Text = $"{m_rightNameStr} {(items.Count > 0 ? "[" + items.Count + "]" : "")}";

                if (m_rightAgrees)
                {
                    m_rightAgrees            = false;
                    m_rightPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING);
                }

                //right player is NOT main, and left player (ie main) agrees, and the item count is different for right player
                //cancel the offer for the main player since the other player changed the offer
                if (m_main.ID != playerID && m_leftAgrees && collectionRef.Count != items.Count)
                {
                    m_leftAgrees            = false;
                    m_leftPlayerStatus.Text = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING);
                    EOMessageBox.Show(DialogResourceID.TRADE_ABORTED_OFFER_CHANGED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER);
                }
            }
            else
            {
                throw new ArgumentException("Invalid Player ID for trade session!", nameof(playerID));
            }

            if (m_main.ID != playerID && collectionRef.Count > items.Count)
            {
                m_recentPartnerRemoves++;
            }
            if (m_recentPartnerRemoves == 3)
            {
                EOMessageBox.Show(DialogResourceID.TRADE_OTHER_PLAYER_TRICK_YOU, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                m_recentPartnerRemoves = -1000; //this will prevent the message from showing more than once (I'm too lazy to find something more elegant)
            }

            foreach (var oldItem in collectionRef)
            {
                oldItem.Close();
            }
            collectionRef.Clear();

            int index = 0;

            foreach (InventoryItem item in items)
            {
                int localID = item.ItemID;

                var    rec       = OldWorld.Instance.EIF[item.ItemID];
                string secondary =
                    $"x {item.Amount}  {(rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "")}";

                int gfxNum = item.ItemID == 1
                    ? 269 + 2 * (item.Amount >= 100000 ? 4 : (item.Amount >= 10000 ? 3 : (item.Amount >= 100 ? 2 : (item.Amount >= 2 ? 1 : 0))))
                    : 2 * rec.Graphic - 1;

                var nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
                {
                    Text        = rec.Name,
                    SubText     = secondary,
                    IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, gfxNum, true),
                    ID          = item.ItemID,
                    Amount      = item.Amount,
                    OffsetX     = xOffset,
                    OffsetY     = 46
                };
                if (playerID == m_main.ID)
                {
                    nextItem.OnRightClick += (sender, args) => _removeItem(localID);
                }
                collectionRef.Add(nextItem);
            }

            scrollRef.UpdateDimensions(collectionRef.Count);
        }
Example #18
0
        private BankAccountDialog(PacketAPI api)
            : base(api)
        {
            //this uses EODialogListItems but does not inherit from ListDialog since it is a different size
            //offsety 50
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
            _setSize(bgTexture.Width, bgTexture.Height);

            m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
            {
                ForeColor = ColorConstants.LightGrayText,
                Text      = "",
                TextAlign = LabelAlignment.MiddleRight,
                AutoSize  = false
            };
            m_accountBalance.SetParent(this);

            XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));

            cancel.SetParent(this);
            cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

            ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_DEPOSIT),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TRANSFER)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_TO_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankDeposit),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            deposit.OnLeftClick  += (o, e) => _deposit();
            deposit.OnRightClick += (o, e) => _deposit();
            ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_WITHDRAW),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TAKE)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_FROM_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankWithdraw),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            withdraw.OnLeftClick  += (o, e) => _withdraw();
            withdraw.OnRightClick += (o, e) => _withdraw();
            ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
            {
                Text               = OldWorld.GetString(EOResourceID.DIALOG_BANK_LOCKER_UPGRADE),
                SubText            = OldWorld.GetString(EOResourceID.DIALOG_BANK_MORE_SPACE),
                IconGraphic        = _getDlgIcon(ListIcon.BankLockerUpgrade),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            upgrade.OnLeftClick  += (o, e) => _upgrade();
            upgrade.OnRightClick += (o, e) => _upgrade();

            DialogClosing += (o, e) => { Instance = null; };

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 50);
            endConstructor(false);
        }
Example #19
0
        public static void Show(PacketAPI apiHandle, bool isIgnoreList)
        {
            if (Instance != null)
            {
                return;
            }

            List <string> allLines = isIgnoreList ? InteractList.LoadAllIgnore() : InteractList.LoadAllFriend();

            string charName = OldWorld.Instance.MainPlayer.ActiveCharacter.Name;

            charName = char.ToUpper(charName[0]) + charName.Substring(1);
            string titleText = string.Format("{0}'s {2} [{1}]", charName, allLines.Count,
                                             OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));

            ScrollingListDialog dlg = new ScrollingListDialog
            {
                Title        = titleText,
                Buttons      = ScrollingListDialogButtons.AddCancel,
                ListItemType = ListDialogItem.ListItemStyle.Small
            };

            List <ListDialogItem> characters = allLines.Select(character => new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
            {
                Text = character
            }).ToList();

            characters.ForEach(character =>
            {
                character.OnLeftClick  += (o, e) => EOGame.Instance.Hud.SetChatText("!" + character.Text + " ");
                character.OnRightClick += (o, e) =>
                {
                    dlg.RemoveFromList(character);
                    dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                              OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                };
            });
            dlg.SetItemList(characters);

            dlg.DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    Instance = null;
                    if (isIgnoreList)
                    {
                        InteractList.WriteIgnoreList(dlg.NamesList);
                    }
                    else
                    {
                        InteractList.WriteFriendList(dlg.NamesList);
                    }
                }
                else if (e.Result == XNADialogResult.Add)
                {
                    e.CancelClose = true;
                    string          prompt   = OldWorld.GetString(isIgnoreList ? EOResourceID.DIALOG_WHO_TO_MAKE_IGNORE : EOResourceID.DIALOG_WHO_TO_MAKE_FRIEND);
                    TextInputDialog dlgInput = new TextInputDialog(prompt);
                    dlgInput.DialogClosing += (_o, _e) =>
                    {
                        if (_e.Result == XNADialogResult.Cancel)
                        {
                            return;
                        }

                        if (dlgInput.ResponseText.Length < 4)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show(DialogResourceID.CHARACTER_CREATE_NAME_TOO_SHORT);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        if (dlg.NamesList.FindIndex(name => name.ToLower() == dlgInput.ResponseText.ToLower()) >= 0)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show("You are already friends with that person!", "Invalid entry!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        ListDialogItem newItem = new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
                        {
                            Text = dlgInput.ResponseText
                        };
                        newItem.OnLeftClick  += (oo, ee) => EOGame.Instance.Hud.SetChatText("!" + newItem.Text + " ");
                        newItem.OnRightClick += (oo, ee) =>
                        {
                            dlg.RemoveFromList(newItem);
                            dlg.Title = string.Format("{0}'s {2} [{1}]",
                                                      charName,
                                                      dlg.NamesList.Count,
                                                      OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                        };
                        dlg.AddItemToList(newItem, true);
                        dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                                  OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                    };
                }
            };

            Instance = dlg;

            List <OnlineEntry> onlineList;

            apiHandle.RequestOnlinePlayers(false, out onlineList);
            Instance.SetActiveItemList(onlineList.Select(_oe => _oe.Name).ToList());

            EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST,
                                               OldWorld.GetString(EOResourceID.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE));
            //show the dialog
        }
Example #20
0
		private void _setState(ShopState newState)
		{
			ShopState old = m_state;

			if (old == newState) return;

			int buyNumInt = m_tradeItems.FindAll(x => x.Buy > 0).Count;
			int sellNumInt = m_tradeItems.FindAll(x => World.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(item => item.id == x.ID) >= 0 && x.Sell > 0).Count;

			if (newState == ShopState.Buying && buyNumInt <= 0)
			{
				EOMessageBox.Show(DATCONST1.SHOP_NOTHING_IS_FOR_SALE, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
				return;
			}

			if (newState == ShopState.Selling && sellNumInt <= 0)
			{
				EOMessageBox.Show(DATCONST1.SHOP_NOT_BUYING_YOUR_ITEMS, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
				return;
			}

			ClearItemList();
			switch (newState)
			{
				case ShopState.Initial:
					{
						string buyNum = string.Format("{0} {1}", m_tradeItems.FindAll(x => x.Buy > 0).Count, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_IN_STORE));
						string sellNum = string.Format("{0} {1}", sellNumInt, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_ACCEPTED));
						string craftNum = string.Format("{0} {1}", m_craftItems.Count, World.GetString(DATCONST2.DIALOG_SHOP_ITEMS_ACCEPTED));

						ListDialogItem buy = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
						{
							Text = World.GetString(DATCONST2.DIALOG_SHOP_BUY_ITEMS),
							SubText = buyNum,
							IconGraphic = BuyIcon,
							OffsetY = 45
						};
						buy.OnLeftClick += (o, e) => _setState(ShopState.Buying);
						buy.OnRightClick += (o, e) => _setState(ShopState.Buying);
						buy.ShowItemBackGround = false;
						AddItemToList(buy, false);
						ListDialogItem sell = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
						{
							Text = World.GetString(DATCONST2.DIALOG_SHOP_SELL_ITEMS),
							SubText = sellNum,
							IconGraphic = SellIcon,
							OffsetY = 45
						};
						sell.OnLeftClick += (o, e) => _setState(ShopState.Selling);
						sell.OnRightClick += (o, e) => _setState(ShopState.Selling);
						sell.ShowItemBackGround = false;
						AddItemToList(sell, false);
						if (m_craftItems.Count > 0)
						{
							ListDialogItem craft = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
							{
								Text = World.GetString(DATCONST2.DIALOG_SHOP_CRAFT_ITEMS),
								SubText = craftNum,
								IconGraphic = CraftIcon,
								OffsetY = 45
							};
							craft.OnLeftClick += (o, e) => _setState(ShopState.Crafting);
							craft.OnRightClick += (o, e) => _setState(ShopState.Crafting);
							craft.ShowItemBackGround = false;
							AddItemToList(craft, false);
						}
						_setButtons(ScrollingListDialogButtons.Cancel);
					}
					break;
				case ShopState.Buying:
				case ShopState.Selling:
					{
						//re-use the logic for Buying/Selling: it is almost identical
						bool buying = newState == ShopState.Buying;

						List<ListDialogItem> itemList = new List<ListDialogItem>();
						foreach (ShopItem si in m_tradeItems)
						{
							if (si.ID <= 0 || (buying && si.Buy <= 0) ||
								(!buying && (si.Sell <= 0 || World.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(inv => inv.id == si.ID) < 0)))
								continue;

							ShopItem localItem = si;
							ItemRecord rec = World.Instance.EIF.GetItemRecordByID(si.ID);
							string secondary = string.Format("{2}: {0} {1}", buying ? si.Buy : si.Sell,
								rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")" : "",
								World.GetString(DATCONST2.DIALOG_SHOP_PRICE));

							ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
							{
								Text = rec.Name,
								SubText = secondary,
								IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
								OffsetY = 45
							};
							nextItem.OnLeftClick += (o, e) => _buySellItem(localItem);
							nextItem.OnRightClick += (o, e) => _buySellItem(localItem);

							itemList.Add(nextItem);
						}
						SetItemList(itemList);
						_setButtons(ScrollingListDialogButtons.BackCancel);
					}
					break;
				case ShopState.Crafting:
					{
						List<ListDialogItem> itemList = new List<ListDialogItem>(m_craftItems.Count);
						foreach (CraftItem ci in m_craftItems)
						{
							if (ci.Ingredients.Count <= 0) continue;

							CraftItem localItem = ci;
							ItemRecord rec = World.Instance.EIF.GetItemRecordByID(ci.ID);
							string secondary = string.Format("{2}: {0} {1}", ci.Ingredients.Count,
								rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")" : "",
								World.GetString(DATCONST2.DIALOG_SHOP_CRAFT_INGREDIENTS));

							ListDialogItem nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large)
							{
								Text = rec.Name,
								SubText = secondary,
								IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
								OffsetY = 45
							};
							nextItem.OnLeftClick += (o, e) => _craftItem(localItem);
							nextItem.OnRightClick += (o, e) => _craftItem(localItem);

							itemList.Add(nextItem);
						}
						SetItemList(itemList);
						_setButtons(ScrollingListDialogButtons.BackCancel);
					}
					break;
			}

			m_state = newState;
		}
Example #21
0
        private void _setState(SkillState newState)
        {
            SkillState old = m_state;

            if (old == newState)
            {
                return;
            }

            int numToLearn  = m_skills.Count(_skill => !OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Exists(_spell => _spell.ID == _skill.ID));
            int numToForget = OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Count;

            if (newState == SkillState.Learn && numToLearn == 0)
            {
                EOMessageBox.Show(DialogResourceID.SKILL_NOTHING_MORE_TO_LEARN, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            ClearItemList();
            switch (newState)
            {
            case SkillState.Initial:
            {
                string learnNum  = $"{numToLearn}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_TO_LEARN)}";
                string forgetNum = $"{numToForget}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_LEARNED)}";

                ListDialogItem learn = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEARN),
                    SubText            = learnNum,
                    IconGraphic        = LearnIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                learn.OnLeftClick  += (o, e) => _setState(SkillState.Learn);
                learn.OnRightClick += (o, e) => _setState(SkillState.Learn);
                AddItemToList(learn, false);

                ListDialogItem forget = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_FORGET),
                    SubText            = forgetNum,
                    IconGraphic        = ForgetIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                forget.OnLeftClick  += (o, e) => _setState(SkillState.Forget);
                forget.OnRightClick += (o, e) => _setState(SkillState.Forget);
                AddItemToList(forget, false);

                ListDialogItem forgetAll = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL),
                    SubText            = OldWorld.GetString(EOResourceID.SKILLMASTER_RESET_YOUR_CHARACTER),
                    IconGraphic        = ForgetIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                forgetAll.OnLeftClick  += (o, e) => _setState(SkillState.ForgetAll);
                forgetAll.OnRightClick += (o, e) => _setState(SkillState.ForgetAll);
                AddItemToList(forgetAll, false);

                _setButtons(ScrollingListDialogButtons.Cancel);
            }
            break;

            case SkillState.Learn:
            {
                int index = 0;
                for (int i = 0; i < m_skills.Count; ++i)
                {
                    if (OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.ID) >= 0)
                    {
                        continue;
                    }
                    int localI = i;

                    var spellData = OldWorld.Instance.ESF.Data[m_skills[localI].ID];

                    ListDialogItem nextListItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
                    {
                        Visible            = false,
                        Text               = spellData.Name,
                        SubText            = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_REQUIREMENTS),
                        IconGraphic        = OldWorld.GetSpellIcon(spellData.Icon, false),
                        ShowItemBackGround = false,
                        OffsetY            = 45,
                        ID = m_skills[localI].ID
                    };
                    nextListItem.OnLeftClick  += (o, e) => _learn(m_skills[localI]);
                    nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]);
                    nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]);
                    nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI]));
                    AddItemToList(nextListItem, false);
                }

                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;

            case SkillState.Forget:
            {
                TextInputDialog input = new TextInputDialog(OldWorld.GetString(DialogResourceID.SKILL_PROMPT_TO_FORGET, false), 32);
                input.SetAsKeyboardSubscriber();
                input.DialogClosing += (sender, args) =>
                {
                    if (args.Result == XNADialogResult.Cancel)
                    {
                        return;
                    }
                    bool found =
                        OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Any(
                            _spell => OldWorld.Instance.ESF.Data[_spell.ID].Name.ToLower() == input.ResponseText.ToLower());

                    if (!found)
                    {
                        args.CancelClose = true;
                        EOMessageBox.Show(DialogResourceID.SKILL_FORGET_ERROR_NOT_LEARNED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        input.SetAsKeyboardSubscriber();
                    }

                    if (!m_api.ForgetSpell(
                            OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Find(
                                _spell => OldWorld.Instance.ESF.Data[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()).ID))
                    {
                        Close();
                        ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                };

                //should show initial info in the actual dialog since this uses a pop-up input box
                //    to select a skill to remove
                newState = SkillState.Initial;
                goto case SkillState.Initial;
            }

            case SkillState.ForgetAll:
            {
                _showForgetAllMessage(_forgetAllAction);
                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;
            }

            m_state = newState;
        }
Example #22
0
		public void SetPlayerItems(short playerID, List<InventoryItem> items)
		{
			int xOffset;
			List<ListDialogItem> collectionRef;
			ScrollBar scrollRef;

			if (playerID == m_leftPlayerID)
			{
				collectionRef = m_leftItems;
				scrollRef = m_leftScroll;
				xOffset = -3;
				m_leftPlayerName.Text = string.Format("{0} {1}", m_leftNameStr, items.Count > 0 ? "[" + items.Count + "]" : "");

				if (m_leftAgrees)
				{
					m_leftAgrees = false;
					m_leftPlayerStatus.Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING);
				}

				//left player is NOT main, and right player (ie main) agrees, and the item count is different for left player
				//cancel the offer for the main player since the other player changed the offer
				if (m_main.ID != playerID && m_rightAgrees && collectionRef.Count != items.Count)
				{
					m_rightAgrees = false;
					m_rightPlayerStatus.Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING);
					EOMessageBox.Show(DATCONST1.TRADE_ABORTED_OFFER_CHANGED, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
					((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER);
				}
			}
			else if (playerID == m_rightPlayerID)
			{
				collectionRef = m_rightItems;
				scrollRef = m_rightScroll;
				xOffset = 263;
				m_rightPlayerName.Text = string.Format("{0} {1}", m_rightNameStr, items.Count > 0 ? "[" + items.Count + "]" : "");

				if (m_rightAgrees)
				{
					m_rightAgrees = false;
					m_rightPlayerStatus.Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING);
				}

				//right player is NOT main, and left player (ie main) agrees, and the item count is different for right player
				//cancel the offer for the main player since the other player changed the offer
				if (m_main.ID != playerID && m_leftAgrees && collectionRef.Count != items.Count)
				{
					m_leftAgrees = false;
					m_leftPlayerStatus.Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING);
					EOMessageBox.Show(DATCONST1.TRADE_ABORTED_OFFER_CHANGED, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
					((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_TRADE_OTHER_PLAYER_CHANGED_OFFER);
				}
			}
			else
				throw new ArgumentException("Invalid Player ID for trade session!", "playerID");

			if (m_main.ID != playerID && collectionRef.Count > items.Count)
				m_recentPartnerRemoves++;
			if (m_recentPartnerRemoves == 3)
			{
				EOMessageBox.Show(DATCONST1.TRADE_OTHER_PLAYER_TRICK_YOU, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
				m_recentPartnerRemoves = -1000; //this will prevent the message from showing more than once (I'm too lazy to find something more elegant)
			}

			foreach (var oldItem in collectionRef) oldItem.Close();
			collectionRef.Clear();

			int index = 0;
			foreach (InventoryItem item in items)
			{
				int localID = item.id;

				ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id);
				string secondary = string.Format("x {0}  {1}", item.amount, rec.Type == ItemType.Armor
					? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")"
					: "");

				int gfxNum = item.id == 1
					? 269 + 2 * (item.amount >= 100000 ? 4 : (item.amount >= 10000 ? 3 : (item.amount >= 100 ? 2 : (item.amount >= 2 ? 1 : 0))))
					: 2 * rec.Graphic - 1;

				var nextItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
				{
					Text = rec.Name,
					SubText = secondary,
					IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, gfxNum, true),
					ID = item.id,
					Amount = item.amount,
					OffsetX = xOffset,
					OffsetY = 46
				};
				if (playerID == m_main.ID)
					nextItem.OnRightClick += (sender, args) => _removeItem(localID);
				collectionRef.Add(nextItem);
			}

			scrollRef.UpdateDimensions(collectionRef.Count);
		}
		public void AddItemToList(ListDialogItem item, bool sortList)
		{
			if (m_listItems.Count == 0)
				m_scrollBar.LinesToRender = item.Style == ListDialogItem.ListItemStyle.Large ? LargeItemStyleMaxItemDisplay : SmallItemStyleMaxItemDisplay;
			lock (m_listItemLock)
			{
				m_listItems.Add(item);
				if (sortList)
					m_listItems.Sort((item1, item2) => item1.Text.CompareTo(item2.Text));
				for (int i = 0; i < m_listItems.Count; ++i)
					m_listItems[i].Index = i;
			}
			m_scrollBar.UpdateDimensions(m_listItems.Count);
		}
		public void RemoveFromList(ListDialogItem item)
		{
			int ndx;
			lock (m_listItemLock)
				ndx = m_listItems.FindIndex(_item => _item == item);
			if (ndx < 0) return;

			item.Close();

			lock (m_listItemLock)
			{
				m_listItems.RemoveAt(ndx);

				m_scrollBar.UpdateDimensions(m_listItems.Count);
				if (m_listItems.Count <= m_scrollBar.LinesToRender)
					m_scrollBar.ScrollToTop();

				for (int i = 0; i < m_listItems.Count; ++i)
				{
					//adjust indices (determines drawing position)
					m_listItems[i].Index = i;
				}
			}
		}
Example #25
0
		public void InitializeItems(IList<Tuple<short, int>> initialItems)
		{
			if (m_items == null)
				m_items = new ListDialogItem[5];

			int i = 0;
			if (initialItems.Count > 0)
			{
				for (; i < initialItems.Count && i < 5; ++i)
				{
					Tuple<short, int> item = initialItems[i];
					if (m_items[i] != null)
					{
						m_items[i].Close();
						m_items[i] = null;
					}

					ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.Item1);
					string secondary = string.Format("x {0}  {1}", item.Item2, rec.Type == ItemType.Armor
						? "(" + (rec.Gender == 0 ? World.GetString(DATCONST2.FEMALE) : World.GetString(DATCONST2.MALE)) + ")"
						: "");

					m_items[i] = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, i)
					{
						Text = rec.Name,
						SubText = secondary,
						IconGraphic = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.Items, 2 * rec.Graphic - 1, true),
						ID = item.Item1
					};
					m_items[i].OnRightClick += (o, e) =>
					{
						ListDialogItem sender = o as ListDialogItem;
						if (sender == null) return;

						if (!EOGame.Instance.Hud.InventoryFits(sender.ID))
						{
							string _message = World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT);
							string _caption = World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING);
							EOMessageBox.Show(_message, _caption, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
							((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT);
						}
						else if (rec.Weight * item.Item2 + World.Instance.MainPlayer.ActiveCharacter.Weight >
								 World.Instance.MainPlayer.ActiveCharacter.MaxWeight)
						{
							EOMessageBox.Show(World.GetString(DATCONST2.DIALOG_ITS_TOO_HEAVY_WEIGHT),
								World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING),
								XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
						}
						else
						{
							if (!m_api.ChestTakeItem(CurrentChestX, CurrentChestY, sender.ID))
							{
								Close();
								EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
							}
						}
					};
				}
			}

			for (; i < m_items.Length; ++i)
			{
				if (m_items[i] != null)
				{
					m_items[i].Close();
					m_items[i] = null;
				}
			}
		}
Example #26
0
		private void _setDialogText()
		{
			ClearItemList();

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

			TextSplitter ts = new TextSplitter(_pages[_pageIndex], Game.Content.Load<SpriteFont>(Constants.FontSize08pt5));
			if (!ts.NeedsProcessing)
				rows.Add(_pages[_pageIndex]);
			else
				rows.AddRange(ts.SplitIntoLines());

			int index = 0;
			foreach (var row in rows)
			{
				ListDialogItem rowItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
				{
					Text = row
				};
				AddItemToList(rowItem, false);
			}

			if (_pageIndex < _pages.Count - 1)
				return;

			ListDialogItem item = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++) { Text = " " };
			AddItemToList(item, false);

			foreach (var link in _links)
			{
				ListDialogItem linkItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Small, index++)
				{
					Text = link.Value
				};

				var linkIndex = (byte)link.Key;
				linkItem.SetPrimaryTextLink(() => _clickLink(linkIndex));
				AddItemToList(linkItem, false);
			}
		}
Example #27
0
        public void InitializeItems(IList <InventoryItem> initialItems)
        {
            if (m_items == null)
            {
                m_items = new ListDialogItem[5];
            }

            int i = 0;

            if (initialItems.Count > 0)
            {
                for (; i < initialItems.Count && i < 5; ++i)
                {
                    var item = initialItems[i];
                    if (m_items[i] != null)
                    {
                        m_items[i].Close();
                        m_items[i] = null;
                    }

                    var    rec       = OldWorld.Instance.EIF[item.ItemID];
                    string secondary =
                        $"x {item.Amount}  {(rec.Type == ItemType.Armor ? "(" + (rec.Gender == 0 ? OldWorld.GetString(EOResourceID.FEMALE) : OldWorld.GetString(EOResourceID.MALE)) + ")" : "")}";

                    m_items[i] = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, i)
                    {
                        Text        = rec.Name,
                        SubText     = secondary,
                        IconGraphic = GetItemGraphic(rec, item.Amount),
                        ID          = item.ItemID
                    };
                    m_items[i].OnRightClick += (o, e) =>
                    {
                        ListDialogItem sender = o as ListDialogItem;
                        if (sender == null)
                        {
                            return;
                        }

                        if (!EOGame.Instance.Hud.InventoryFits(sender.ID))
                        {
                            string _message = OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT);
                            string _caption = OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING);
                            EOMessageBox.Show(_message, _caption, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                            ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT);
                        }
                        else if (rec.Weight * item.Amount + OldWorld.Instance.MainPlayer.ActiveCharacter.Weight >
                                 OldWorld.Instance.MainPlayer.ActiveCharacter.MaxWeight)
                        {
                            EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_ITS_TOO_HEAVY_WEIGHT),
                                              OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                              EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        }
                        else
                        {
                            if (!m_api.ChestTakeItem(CurrentChestX, CurrentChestY, sender.ID))
                            {
                                Close();
                                EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                            }
                        }
                    };
                }
            }

            for (; i < m_items.Length; ++i)
            {
                if (m_items[i] != null)
                {
                    m_items[i].Close();
                    m_items[i] = null;
                }
            }
        }