コード例 #1
0
        private void _upgrade()
        {
            if (LockerUpgrades == 7)
            {
                EOMessageBox.Show(DialogResourceID.LOCKER_UPGRADE_IMPOSSIBLE, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            int           requiredGold = (LockerUpgrades + 1) * 1000;
            InventoryItem item         = OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.Find(i => i.ItemID == 1);

            if (item.Amount < requiredGold)
            {
                EOMessageBox.Show(DialogResourceID.WARNING_YOU_HAVE_NOT_ENOUGH, "gold", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            EOMessageBox.Show(DialogResourceID.LOCKER_UPGRADE_UNIT, $"{requiredGold} gold?", EODialogButtons.OkCancel,
                              EOMessageBoxStyle.SmallDialogSmallHeader,
                              (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    return;
                }

                OldPacket pkt = new OldPacket(PacketFamily.Locker, PacketAction.Buy);
                OldWorld.Instance.Client.SendPacket(pkt);
            });
        }
コード例 #2
0
        private void _craftItem(CraftItem item)
        {
            if (m_state != ShopState.Crafting)
            {
                return;
            }

            var craftItemRec = OldWorld.Instance.EIF[item.ID];

            // ReSharper disable once LoopCanBeConvertedToQuery
            foreach (var ingredient in item.Ingredients)
            {
                if (OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.FindIndex(_item => _item.ItemID == ingredient.Item1 && _item.Amount >= ingredient.Item2) < 0)
                {
                    string _message = OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_MISSING_INGREDIENTS) + "\n\n";
                    foreach (var ingred in item.Ingredients)
                    {
                        var localRec = OldWorld.Instance.EIF[ingred.Item1];
                        _message += $"+  {ingred.Item2}  {localRec.Name}\n";
                    }
                    string _caption =
                        $"{OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_INGREDIENTS)} {OldWorld.GetString(EOResourceID.DIALOG_WORD_FOR)} {craftItemRec.Name}";
                    EOMessageBox.Show(_message, _caption, EODialogButtons.Cancel, EOMessageBoxStyle.LargeDialogSmallHeader);
                    return;
                }
            }

            if (!EOGame.Instance.Hud.InventoryFits((short)item.ID))
            {
                EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_SPACE),
                                  OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                  EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            string _message2 = OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_PUT_INGREDIENTS_TOGETHER) + "\n\n";

            foreach (var ingred in item.Ingredients)
            {
                var localRec = OldWorld.Instance.EIF[ingred.Item1];
                _message2 += $"+  {ingred.Item2}  {localRec.Name}\n";
            }
            string _caption2 =
                $"{OldWorld.GetString(EOResourceID.DIALOG_SHOP_CRAFT_INGREDIENTS)} {OldWorld.GetString(EOResourceID.DIALOG_WORD_FOR)} {craftItemRec.Name}";

            EOMessageBox.Show(_message2, _caption2, EODialogButtons.OkCancel, EOMessageBoxStyle.LargeDialogSmallHeader, (o, e) =>
            {
                if (e.Result == XNADialogResult.OK && !m_api.CraftItem((short)item.ID))
                {
                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            });
        }
コード例 #3
0
        private void _forgetAllAction()
        {
            EOMessageBox.Show(DialogResourceID.SKILL_RESET_CHARACTER_CONFIRMATION, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                              (sender, args) =>
            {
                if (args.Result == XNADialogResult.Cancel)
                {
                    return;
                }

                if (!m_api.ResetCharacterStatSkill())
                {
                    Close();
                    ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            });
        }
コード例 #4
0
        private void _learn(Skill skill)
        {
            OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter;

            bool skillReqsMet = true;

            foreach (short x in skill.SkillReq)
            {
                if (x != 0 && c.Spells.FindIndex(_sp => _sp.ID == x) < 0)
                {
                    skillReqsMet = false;
                }
            }

            //check the requirements
            if (c.Stats.Str < skill.StrReq || c.Stats.Int < skill.IntReq || c.Stats.Wis < skill.WisReq ||
                c.Stats.Agi < skill.AgiReq || c.Stats.Con < skill.ConReq || c.Stats.Cha < skill.ChaReq ||
                c.Stats.Level < skill.LevelReq || c.Inventory.Find(_ii => _ii.ItemID == 1).Amount < skill.GoldReq || !skillReqsMet)
            {
                EOMessageBox.Show(DialogResourceID.SKILL_LEARN_REQS_NOT_MET, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            if (skill.ClassReq > 0 && c.Class != skill.ClassReq)
            {
                EOMessageBox.Show(DialogResourceID.SKILL_LEARN_WRONG_CLASS, " " + OldWorld.Instance.ECF.Data[skill.ClassReq].Name + "!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            EOMessageBox.Show(DialogResourceID.SKILL_LEARN_CONFIRMATION, " " + OldWorld.Instance.ESF.Data[skill.ID].Name + "?", EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                              (o, e) =>
            {
                if (e.Result != XNADialogResult.OK)
                {
                    return;
                }

                if (!m_api.LearnSpell(skill.ID))
                {
                    Close();
                    ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            });
        }
コード例 #5
0
        private void _removeItem(EIFRecord item, int amount)
        {
            if (!EOGame.Instance.Hud.InventoryFits((short)item.ID))
            {
                EOMessageBox.Show(OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT),
                                  OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                  EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            if (OldWorld.Instance.MainPlayer.ActiveCharacter.Weight + item.Weight * amount > 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);
                return;
            }

            if (!m_api.LockerTakeItem(X, Y, (short)item.ID))
            {
                EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
            }
        }
コード例 #6
0
        public void CompleteTrade(short p1, List <InventoryItem> p1items, short p2, List <InventoryItem> p2items)
        {
            List <InventoryItem> mainCollection, otherCollection;

            if (p1 == m_main.ID)
            {
                mainCollection  = p1items;
                otherCollection = p2items;
            }
            else if (p2 == m_main.ID)
            {
                mainCollection  = p2items;
                otherCollection = p1items;
            }
            else
            {
                throw new ArgumentException("Invalid player ID for trade session!");
            }

            int weightDelta = 0;

            foreach (var item in mainCollection)
            {
                m_main.UpdateInventoryItem(item.ItemID, -item.Amount, true);
                weightDelta -= OldWorld.Instance.EIF[item.ItemID].Weight * item.Amount;
            }
            foreach (var item in otherCollection)
            {
                m_main.UpdateInventoryItem(item.ItemID, item.Amount, true);
                weightDelta += OldWorld.Instance.EIF[item.ItemID].Weight * item.Amount;
            }
            m_main.Weight += (byte)weightDelta;
            ((EOGame)Game).Hud.RefreshStats();

            Close(null, XNADialogResult.NO_BUTTON_PRESSED);
            EOMessageBox.Show(DialogResourceID.TRADE_SUCCESS, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
        }
コード例 #7
0
        private void _withdraw()
        {
            int balance = int.Parse(AccountBalance);

            if (balance == 0)
            {
                EOMessageBox.Show(DialogResourceID.BANK_ACCOUNT_UNABLE_TO_WITHDRAW, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }
            if (balance == 1)
            {
                if (!m_api.BankWithdraw(1))
                {
                    Close(null, XNADialogResult.NO_BUTTON_PRESSED);
                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
                return;
            }

            ItemTransferDialog dlg = new ItemTransferDialog(OldWorld.Instance.EIF[1].Name,
                                                            ItemTransferDialog.TransferType.BankTransfer, balance, EOResourceID.DIALOG_TRANSFER_WITHDRAW);

            dlg.DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    return;
                }

                if (!m_api.BankWithdraw(dlg.SelectedAmount))
                {
                    Close(null, XNADialogResult.NO_BUTTON_PRESSED);
                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            };
        }
コード例 #8
0
        private void _deposit()
        {
            InventoryItem item = OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.Find(i => i.ItemID == 1);

            if (item.Amount == 0)
            {
                EOMessageBox.Show(DialogResourceID.BANK_ACCOUNT_UNABLE_TO_DEPOSIT, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }
            if (item.Amount == 1)
            {
                if (!m_api.BankDeposit(1))
                {
                    Close(null, XNADialogResult.NO_BUTTON_PRESSED);
                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
                return;
            }

            ItemTransferDialog dlg = new ItemTransferDialog(OldWorld.Instance.EIF[1].Name,
                                                            ItemTransferDialog.TransferType.BankTransfer, item.Amount, EOResourceID.DIALOG_TRANSFER_DEPOSIT);

            dlg.DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    return;
                }

                if (!m_api.BankDeposit(dlg.SelectedAmount))
                {
                    Close(null, XNADialogResult.NO_BUTTON_PRESSED);
                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            };
        }
コード例 #9
0
        private void _buySellItem(ShopItem item)
        {
            if (m_state != ShopState.Buying && m_state != ShopState.Selling)
            {
                return;
            }
            bool isBuying = m_state == ShopState.Buying;

            InventoryItem ii  = OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory.Find(x => (isBuying ? x.ItemID == 1 : x.ItemID == item.ID));
            var           rec = OldWorld.Instance.EIF[item.ID];

            if (isBuying)
            {
                if (!EOGame.Instance.Hud.InventoryFits((short)item.ID))
                {
                    EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_SPACE),
                                      OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                      EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    return;
                }

                if (rec.Weight + OldWorld.Instance.MainPlayer.ActiveCharacter.Weight >
                    OldWorld.Instance.MainPlayer.ActiveCharacter.MaxWeight)
                {
                    EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_WEIGHT),
                                      OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                      EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    return;
                }

                if (ii.Amount < item.Buy)
                {
                    EOMessageBox.Show(DialogResourceID.WARNING_YOU_HAVE_NOT_ENOUGH, " gold.", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    return;
                }
            }
            else if (ii.Amount == 0)
            {
                return; //can't sell if amount of item is 0
            }
            //special case: no need for prompting if selling an item with count == 1 in inventory
            if (!isBuying && ii.Amount == 1)
            {
                string _message =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_WORD_SELL)} 1 {rec.Name} {OldWorld.GetString(EOResourceID.DIALOG_WORD_FOR)} {item.Sell} gold?";
                EOMessageBox.Show(_message, OldWorld.GetString(EOResourceID.DIALOG_SHOP_SELL_ITEMS), EODialogButtons.OkCancel,
                                  EOMessageBoxStyle.SmallDialogSmallHeader, (oo, ee) =>
                {
                    if (ee.Result == XNADialogResult.OK && !m_api.SellItem((short)item.ID, 1))
                    {
                        EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                });
            }
            else
            {
                ItemTransferDialog dlg = new ItemTransferDialog(rec.Name, ItemTransferDialog.TransferType.ShopTransfer,
                                                                isBuying ? item.MaxBuy : ii.Amount, isBuying ? EOResourceID.DIALOG_TRANSFER_BUY : EOResourceID.DIALOG_TRANSFER_SELL);
                dlg.DialogClosing += (o, e) =>
                {
                    if (e.Result == XNADialogResult.OK)
                    {
                        string _message =
                            $"{OldWorld.GetString(isBuying ? EOResourceID.DIALOG_WORD_BUY : EOResourceID.DIALOG_WORD_SELL)} {dlg.SelectedAmount} {rec.Name} {OldWorld.GetString(EOResourceID.DIALOG_WORD_FOR)} {(isBuying ? item.Buy : item.Sell)*dlg.SelectedAmount} gold?";

                        EOMessageBox.Show(_message,
                                          OldWorld.GetString(isBuying ? EOResourceID.DIALOG_SHOP_BUY_ITEMS : EOResourceID.DIALOG_SHOP_SELL_ITEMS),
                                          EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader, (oo, ee) =>
                        {
                            if (ee.Result == XNADialogResult.OK)
                            {
                                //only actually do the buy/sell if the user then clicks "OK" in the second prompt
                                if (isBuying && !m_api.BuyItem((short)item.ID, dlg.SelectedAmount) ||
                                    !isBuying && !m_api.SellItem((short)item.ID, dlg.SelectedAmount))
                                {
                                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                                }
                            }
                        });
                    }
                };
            }
        }
コード例 #10
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;
        }
コード例 #11
0
		public override void Initialize()
		{
			base.Initialize();

			//position for these: x=50, y = 8,26,44,...
			for (int i = 0; i < m_basicStats.Length; ++i)
			{
				m_basicStats[i] = new XNALabel(new Rectangle(50, 8 + i*18, 73, 13), Constants.FontSize08pt5)
				{
					Visible = true,
					ForeColor = Constants.LightGrayText,
					AutoSize = false
				};
				m_basicStats[i].SetParent(this);
				m_arrows[i] = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(106, 7 + i*18), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
				{
					Visible = false, //for testing - this should only be visible when statpoints > 0
					FlashSpeed = 500
				};
				m_arrows[i].SetParent(this);
				World.IgnoreDialogs(m_arrows[i]);
				m_arrows[i].OnClick += (s, e) =>
				{
					if (!m_training)
					{
						//apparently this is NOT stored in the edf files...
						//NOTE: copy-pasted to ActiveSpells spell train button event handler. Should probably be in some shared function somewhere.
						EOMessageBox dlg = new EOMessageBox("Do you want to train?", "Character training", XNADialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader);
						dlg.DialogClosing += (sender, args) =>
						{
							if (args.Result != XNADialogResult.OK) return;
							m_training = true;
						};
					}
					else
					{
						short index = (short)(m_arrows.ToList().FindIndex(_btn => _btn == s) + 1); //1-based index (server-side)
						if(!((EOGame)Game).API.LevelUpStat(index))
							EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
					}
				};
			}

			//x=158, y = 8, 26, 44, ...
			for (int i = 0; i < m_characterStats.Length; ++i)
			{
				m_characterStats[i] = new XNALabel(new Rectangle(158, 8 + i * 18, 73, 13), Constants.FontSize08pt5)
				{
					Visible = true,
					ForeColor = Constants.LightGrayText,
					AutoSize = false
				};
				m_characterStats[i].SetParent(this);
			}

			for (int i = 0; i < m_otherInfo.Length; ++i)
			{
				m_otherInfo[i] = new XNALabel(new Rectangle(i < 4 ? 280 : 379 , 44 + (i%4)*18, i < 4 ? 60 : 94, 13), Constants.FontSize08pt5)
				{
					Visible = true,
					ForeColor = Constants.LightGrayText,
					AutoSize = false
				};
				m_otherInfo[i].SetParent(this);
			}

			//these labels have non-standard sizes so they're done individually
			//name= 280,8 144,13
			m_charInfo[NAME] = new XNALabel(new Rectangle(280, 8, 144, 13), Constants.FontSize08pt5)
			{
				Visible = true,
				ForeColor = Constants.LightGrayText,
				AutoSize = false,
				Text = c.Name
			};
			//guild = 280,26 193,13
			m_charInfo[GUILD] = new XNALabel(new Rectangle(280, 26, 193, 13), Constants.FontSize08pt5)
			{
				Visible = true,
				ForeColor = Constants.LightGrayText,
				AutoSize = false,
				Text = c.GuildName
			};
			//level = 453,8, 20,13
			m_charInfo[LEVEL] = new XNALabel(new Rectangle(453, 8, 20, 13), Constants.FontSize08pt5)
			{
				Visible = true,
				ForeColor = Constants.LightGrayText,
				AutoSize = false
			};
			foreach(XNALabel lbl in m_charInfo) lbl.SetParent(this);
		}
コード例 #12
0
		private void LevelUp_Click(object sender, EventArgs args)
		{
			if (!_trainWarningShown)
			{
				//apparently this is NOT stored in the edf files...
				//NOTE: copy-pasted from EOCharacterStats button event handler. Should probably be in some shared function somewhere.
				EOMessageBox dlg = new EOMessageBox("Do you want to train?", "Skill training", XNADialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader);
				dlg.DialogClosing += (s, e) =>
				{
					if (e.Result != XNADialogResult.OK) return;
					_trainWarningShown = true;
				};

				return;
			}

			var selectedSpell = _childItems.Single(x => x.Selected);
			if (selectedSpell == null || !_api.LevelUpSpell((short) selectedSpell.SpellData.ID))
				((EOGame) Game).DoShowLostConnectionDialogAndReturnToMainMenu();
		}
コード例 #13
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
        }
コード例 #14
0
        public override void Update(GameTime gameTime)
        {
            if (!Game.IsActive)
            {
                return;
            }

            MouseState currentState = Mouse.GetState();

            if (MouseOver && !MouseOverPreviously)
            {
                EOResourceID msg;
                switch (EquipLoc)
                {
                case EquipLocation.Boots: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_BOOTS_EQUIPMENT; break;

                case EquipLocation.Accessory: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_MISC_EQUIPMENT; break;

                case EquipLocation.Gloves: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_GLOVES_EQUIPMENT; break;

                case EquipLocation.Belt: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_BELT_EQUIPMENT; break;

                case EquipLocation.Armor: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_ARMOR_EQUIPMENT; break;

                case EquipLocation.Necklace: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_NECKLACE_EQUIPMENT; break;

                case EquipLocation.Hat: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_HAT_EQUIPMENT; break;

                case EquipLocation.Shield: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_SHIELD_EQUIPMENT; break;

                case EquipLocation.Weapon: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_WEAPON_EQUIPMENT; break;

                case EquipLocation.Ring1:
                case EquipLocation.Ring2: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_RING_EQUIPMENT; break;

                case EquipLocation.Armlet1:
                case EquipLocation.Armlet2: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_ARMLET_EQUIPMENT; break;

                case EquipLocation.Bracer1:
                case EquipLocation.Bracer2: msg = EOResourceID.STATUS_LABEL_PAPERDOLL_BRACER_EQUIPMENT; break;

                default: throw new ArgumentOutOfRangeException();
                }

                if (m_info != null)
                {
                    EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, msg, ", " + m_info.Name);
                }
                else
                {
                    EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, msg);
                }
            }

            //unequipping an item via right-click
            if (m_info != null && MouseOver && currentState.RightButton == ButtonState.Released &&
                PreviousMouseState.RightButton == ButtonState.Pressed)
            {
                if (((EOPaperdollDialog)parent).CharRef == OldWorld.Instance.MainPlayer.ActiveCharacter)
                { //the parent dialog must show equipment for mainplayer
                    if (m_info.Special == ItemSpecial.Cursed)
                    {
                        EOMessageBox.Show(DialogResourceID.ITEM_IS_CURSED_ITEM, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (!((EOGame)Game).Hud.InventoryFits((short)m_info.ID))
                    {
                        ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_ITEM_UNEQUIP_NO_SPACE_LEFT);
                    }
                    else
                    {
                        _setSize(m_area.Width, m_area.Height);
                        DrawLocation = new Vector2(m_area.X + (m_area.Width / 2 - DrawArea.Width / 2),
                                                   m_area.Y + (m_area.Height / 2 - DrawArea.Height / 2));

                        //put back in the inventory by the packet handler response
                        string locName = Enum.GetName(typeof(EquipLocation), EquipLoc);
                        if (!string.IsNullOrEmpty(locName))
                        {
                            m_api.UnequipItem((short)m_info.ID, (byte)(locName.Contains("2") ? 1 : 0));
                        }

                        m_info = null;
                        m_gfx  = null;
                    }
                }
            }

            base.Update(gameTime);
        }
コード例 #15
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;
        }
コード例 #16
0
        private void _buttonOkClicked(object sender, EventArgs e)
        {
            if (m_leftPlayerID == m_main.ID)
            {
                if (m_leftAgrees)
                {
                    return;               //main already agrees
                }
            }
            else if (m_rightPlayerID == m_main.ID)
            {
                if (m_rightAgrees)
                {
                    return;                //main already agrees
                }
            }
            else
            {
                throw new InvalidOperationException("Invalid Player ID for trade session!");
            }

            if (m_leftItems.Count == 0 || m_rightItems.Count == 0)
            {
                EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRADE_BOTH_PLAYERS_OFFER_ONE_ITEM),
                                  OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok,
                                  EOMessageBoxStyle.SmallDialogSmallHeader);
                ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.DIALOG_TRADE_BOTH_PLAYERS_OFFER_ONE_ITEM);
                return;
            }

            List <ListDialogItem> mainCollection  = m_main.ID == m_leftPlayerID ? m_leftItems : m_rightItems;
            List <ListDialogItem> otherCollection = m_main.ID == m_leftPlayerID ? m_rightItems : m_leftItems;

            //make sure that the items will fit!
            if (!((EOGame)Game).Hud.ItemsFit(
                    otherCollection.Select(_item => new InventoryItem(_item.ID, _item.Amount)).ToList(),
                    mainCollection.Select(_item => new InventoryItem(_item.ID, _item.Amount)).ToList()))
            {
                EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_SPACE),
                                  OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            //make sure the change in weight + existing weight is not greater than the max weight!
            int weightDelta = otherCollection.Sum(itemRef => OldWorld.Instance.EIF[itemRef.ID].Weight * itemRef.Amount);

            weightDelta = mainCollection.Aggregate(weightDelta, (current, itemRef) => current - OldWorld.Instance.EIF[itemRef.ID].Weight * itemRef.Amount);
            if (weightDelta + m_main.Weight > m_main.MaxWeight)
            {
                EOMessageBox.Show(OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_NOT_ENOUGH_WEIGHT),
                                  OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING), EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            EOMessageBox.Show(DialogResourceID.TRADE_DO_YOU_AGREE, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                              (o, dlgArgs) =>
            {
                if (dlgArgs.Result == XNADialogResult.OK && !m_api.TradeAgree(true))
                {
                    Close(null, XNADialogResult.NO_BUTTON_PRESSED);
                    ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            });
        }
コード例 #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);
        }
コード例 #18
0
		public static void Show(string message, string caption = "", XNADialogButtons buttons = XNADialogButtons.Ok, EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader, OnDialogClose closingEvent = null)
		{
			EOMessageBox dlg = new EOMessageBox(message, caption, buttons, style);
			if (closingEvent != null)
				dlg.DialogClosing += closingEvent;
		}
コード例 #19
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;
                }
            }
        }