Beispiel #1
0
        //parent x,y - 102,330
        public EOSettingsPanel(XNAPanel parent)
            : base(null, null, parent)
        {
            _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

            w = World.Instance;
            m_leftSide = new XNALabel[5];
            m_rightSide = new XNALabel[5];

            for (int i = 0; i < m_leftSide.Length; ++i)
            {
                m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_leftSide[i].SetParent(this);
                m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_rightSide[i].SetParent(this);
            }

            _setTextForLanguage();

            m_buttons = new XNAButton[10];
            for (int i = 0; i < m_buttons.Length; ++i)
            {
                m_buttons[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true),
                    new Vector2(i < 5 ? 215 : 454, 25 + (18*(i%5))),
                    new Rectangle(0, 0, 19, 15),
                    new Rectangle(19, 0, 19, 15));

                m_buttons[i].SetParent(this);
                m_buttons[i].OnClick += _settingChange;
                m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE);
            }
        }
Beispiel #2
0
        public override void Update(GameTime gameTime)
        {
            if (!Game.IsActive)
            {
                return;
            }

            //check for drag-drop here
            MouseState currentState = Mouse.GetState();

            if (!m_beingDragged && MouseOverPreviously && MouseOver && PreviousMouseState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Pressed)
            {
                //Conditions for starting are the mouse is over, the button is pressed, and no other items are being dragged
                if (((EOInventory)parent).NoItemsDragging())
                {
                    //start the drag operation and hide the item label
                    m_beingDragged      = true;
                    m_nameLabel.Visible = false;
                    m_preDragDrawOrder  = DrawOrder;
                    m_preDragParent     = parent;

                    //make sure the offsets are maintained!
                    //required to enable dragging past bounds of the inventory panel
                    m_oldOffX = xOff;
                    m_oldOffY = yOff;
                    SetParent(null);

                    m_alpha   = 128;
                    DrawOrder = 100;                     //arbitrarily large constant so drawn on top while dragging
                }
            }

            if (m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed &&
                currentState.LeftButton == ButtonState.Pressed)
            {
                //dragging has started. continue dragging until mouse is released, update position based on mouse location
                DrawLocation = new Vector2(currentState.X - (DrawArea.Width / 2), currentState.Y - (DrawArea.Height / 2));
            }
            else if (m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed &&
                     currentState.LeftButton == ButtonState.Released)
            {
                //need to check for: drop on map (drop action)
                //					 drop on button junk/drop
                //					 drop on grid (inventory move action)
                //					 drop on [x] dialog ([x] add action)

                m_alpha = 255;
                SetParent(m_preDragParent);

                if (((EOInventory)parent).IsOverDrop() || (World.Instance.ActiveMapRenderer.MouseOver &&
                                                           EOChestDialog.Instance == null && EOPaperdollDialog.Instance == null && EOLockerDialog.Instance == null &&
                                                           EOBankAccountDialog.Instance == null && EOTradeDialog.Instance == null))
                {
                    Microsoft.Xna.Framework.Point loc = World.Instance.ActiveMapRenderer.MouseOver ? World.Instance.ActiveMapRenderer.GridCoords:
                                                        new Microsoft.Xna.Framework.Point(World.Instance.MainPlayer.ActiveCharacter.X, World.Instance.MainPlayer.ActiveCharacter.Y);

                    //in range if maximum coordinate difference is <= 2 away
                    bool inRange = Math.Abs(Math.Max(World.Instance.MainPlayer.ActiveCharacter.X - loc.X, World.Instance.MainPlayer.ActiveCharacter.Y - loc.Y)) <= 2;

                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EODialog.Show(DATCONST1.ITEM_IS_LORE_ITEM, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                    }
                    else if (World.Instance.JailMap == World.Instance.MainPlayer.ActiveCharacter.CurrentMap)
                    {
                        EODialog.Show(World.GetString(DATCONST2.JAIL_WARNING_CANNOT_DROP_ITEMS),
                                      World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING),
                                      XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.amount > 1 && inRange)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.DropItems,
                                                                            m_inventory.amount);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK)
                            {
                                //note: not sure of the actual limit. 10000 is arbitrary here
                                if (dlg.SelectedAmount > 10000 && m_inventory.id == 1 && !safetyCommentHasBeenShown)
                                {
                                    EODialog.Show(DATCONST1.DROP_MANY_GOLD_ON_GROUND, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader,
                                                  (o, e) => { safetyCommentHasBeenShown = true; });
                                }
                                else if (!m_api.DropItem(m_inventory.id, dlg.SelectedAmount, (byte)loc.X, (byte)loc.Y))
                                {
                                    ((EOGame)Game).LostConnectionDialog();
                                }
                            }
                        };
                    }
                    else if (inRange)
                    {
                        if (!m_api.DropItem(m_inventory.id, 1, (byte)loc.X, (byte)loc.Y))
                        {
                            ((EOGame)Game).LostConnectionDialog();
                        }
                    }
                    else                     /*if (!inRange)*/
                    {
                        EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_ITEM_DROP_OUT_OF_RANGE);
                    }
                }
                else if (((EOInventory)parent).IsOverJunk())
                {
                    if (m_inventory.amount > 1)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.JunkItems,
                                                                            m_inventory.amount, DATCONST2.DIALOG_TRANSFER_JUNK);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK && !m_api.JunkItem(m_inventory.id, dlg.SelectedAmount))
                            {
                                ((EOGame)Game).LostConnectionDialog();
                            }
                        };
                    }
                    else if (!m_api.JunkItem(m_inventory.id, 1))
                    {
                        ((EOGame)Game).LostConnectionDialog();
                    }
                }
                else if (EOChestDialog.Instance != null && EOChestDialog.Instance.MouseOver && EOChestDialog.Instance.MouseOverPreviously)
                {
                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EODialog.Show(DATCONST1.ITEM_IS_LORE_ITEM, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.amount > 1)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.DropItems, m_inventory.amount);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK &&
                                !m_api.ChestAddItem(EOChestDialog.Instance.CurrentChestX, EOChestDialog.Instance.CurrentChestY,
                                                    m_inventory.id, dlg.SelectedAmount))
                            {
                                EOGame.Instance.LostConnectionDialog();
                            }
                        };
                    }
                    else
                    {
                        if (!m_api.ChestAddItem(EOChestDialog.Instance.CurrentChestX, EOChestDialog.Instance.CurrentChestY, m_inventory.id, 1))
                        {
                            EOGame.Instance.LostConnectionDialog();
                        }
                    }
                }
                else if (EOPaperdollDialog.Instance != null && EOPaperdollDialog.Instance.MouseOver && EOPaperdollDialog.Instance.MouseOverPreviously)
                {
                    //equipable items should be equipped
                    //other item types should do nothing
                    switch (m_itemData.Type)
                    {
                    case ItemType.Accessory:
                    case ItemType.Armlet:
                    case ItemType.Armor:
                    case ItemType.Belt:
                    case ItemType.Boots:
                    case ItemType.Bracer:
                    case ItemType.Gloves:
                    case ItemType.Hat:
                    case ItemType.Necklace:
                    case ItemType.Ring:
                    case ItemType.Shield:
                    case ItemType.Weapon:
                        _handleDoubleClick();
                        break;
                    }
                }
                else if (EOLockerDialog.Instance != null && EOLockerDialog.Instance.MouseOver && EOLockerDialog.Instance.MouseOverPreviously)
                {
                    byte x = EOLockerDialog.Instance.X;
                    byte y = EOLockerDialog.Instance.Y;
                    if (m_inventory.id == 1)
                    {
                        EODialog.Show(DATCONST1.LOCKER_DEPOSIT_GOLD_ERROR, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.amount > 1)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.ShopTransfer, m_inventory.amount, DATCONST2.DIALOG_TRANSFER_TRANSFER);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK)
                            {
                                if (EOLockerDialog.Instance.GetNewItemAmount(m_inventory.id, dlg.SelectedAmount) > Constants.LockerMaxSingleItemAmount)
                                {
                                    EODialog.Show(DATCONST1.LOCKER_FULL_SINGLE_ITEM_MAX, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                                }
                                else if (!m_api.LockerAddItem(x, y, m_inventory.id, dlg.SelectedAmount))
                                {
                                    EOGame.Instance.LostConnectionDialog();
                                }
                            }
                        };
                    }
                    else
                    {
                        if (EOLockerDialog.Instance.GetNewItemAmount(m_inventory.id, 1) > Constants.LockerMaxSingleItemAmount)
                        {
                            EODialog.Show(DATCONST1.LOCKER_FULL_SINGLE_ITEM_MAX, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                        }
                        else if (!m_api.LockerAddItem(x, y, m_inventory.id, 1))
                        {
                            EOGame.Instance.LostConnectionDialog();
                        }
                    }
                }
                else if (EOBankAccountDialog.Instance != null && EOBankAccountDialog.Instance.MouseOver && EOBankAccountDialog.Instance.MouseOverPreviously && m_inventory.id == 1)
                {
                    if (m_inventory.amount == 0)
                    {
                        EODialog.Show(DATCONST1.BANK_ACCOUNT_UNABLE_TO_DEPOSIT, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.amount > 1)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.BankTransfer,
                                                                            m_inventory.amount, DATCONST2.DIALOG_TRANSFER_DEPOSIT);
                        dlg.DialogClosing += (o, e) =>
                        {
                            if (e.Result == XNADialogResult.Cancel)
                            {
                                return;
                            }

                            if (!m_api.BankDeposit(dlg.SelectedAmount))
                            {
                                EOGame.Instance.LostConnectionDialog();
                            }
                        };
                    }
                    else
                    {
                        if (!m_api.BankDeposit(1))
                        {
                            EOGame.Instance.LostConnectionDialog();
                        }
                    }
                }
                else if (EOTradeDialog.Instance != null && EOTradeDialog.Instance.MouseOver && EOTradeDialog.Instance.MouseOverPreviously &&
                         !EOTradeDialog.Instance.MainPlayerAgrees)
                {
                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EODialog.Show(DATCONST1.ITEM_IS_LORE_ITEM);
                    }
                    else if (m_inventory.amount > 1)
                    {
                        EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.TradeItems,
                                                                            m_inventory.amount, DATCONST2.DIALOG_TRANSFER_OFFER);
                        dlg.DialogClosing += (o, e) =>
                        {
                            if (e.Result != XNADialogResult.OK)
                            {
                                return;
                            }

                            if (!m_api.TradeAddItem(m_inventory.id, dlg.SelectedAmount))
                            {
                                EOTradeDialog.Instance.Close(XNADialogResult.NO_BUTTON_PRESSED);
                                ((EOGame)Game).LostConnectionDialog();
                            }
                        };
                    }
                    else if (!m_api.TradeAddItem(m_inventory.id, 1))
                    {
                        EOTradeDialog.Instance.Close(XNADialogResult.NO_BUTTON_PRESSED);
                        ((EOGame)Game).LostConnectionDialog();
                    }
                }

                //update the location - if it isn't on the grid, the bounds check will set it back to where it used to be originally
                //Item amount will be updated or item will be removed in packet response to the drop operation
                UpdateItemLocation(ItemCurrentSlot());

                //mouse has been released. finish dragging.
                m_beingDragged      = false;
                m_nameLabel.Visible = true;
                DrawOrder           = m_preDragDrawOrder;
            }

            if (!m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed &&
                currentState.LeftButton == ButtonState.Released && MouseOver && MouseOverPreviously)
            {
                Interlocked.Increment(ref m_recentClickCount);
                if (m_recentClickCount == 2)
                {
                    _handleDoubleClick();
                }
            }

            if (!MouseOverPreviously && MouseOver && !m_beingDragged)
            {
                m_nameLabel.Visible = true;
                EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ITEM, m_nameLabel.Text);
            }
            else if (!MouseOver && !m_beingDragged && m_nameLabel != null && m_nameLabel.Visible)
            {
                m_nameLabel.Visible = false;
            }

            base.Update(gameTime);             //sets mouseoverpreviously = mouseover, among other things
        }
Beispiel #3
0
        public EOInventory(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            m_api = api;

            //load info from registry
            Dictionary <int, int> localItemSlotMap = new Dictionary <int, int>();

            m_inventoryKey = _tryGetCharacterRegKey();
            if (m_inventoryKey != null)
            {
                const string itemFmt = "item{0}";
                for (int i = 0; i < INVENTORY_ROW_LENGTH * 4; ++i)
                {
                    int id;
                    try
                    {
                        id = Convert.ToInt32(m_inventoryKey.GetValue(string.Format(itemFmt, i)));
                    }
                    catch { continue; }
                    localItemSlotMap.Add(i, id);
                }
            }

            //add the inventory items that were retrieved from the server
            List <InventoryItem> localInv = World.Instance.MainPlayer.ActiveCharacter.Inventory;

            if (localInv.Find(_item => _item.id == 1).id != 1)
            {
                localInv.Insert(0, new InventoryItem {
                    amount = 0, id = 1
                });                                                                         //add 0 gold if there isn't any gold
            }
            bool dialogShown = false;

            foreach (InventoryItem item in localInv)
            {
                ItemRecord rec  = World.Instance.EIF.GetItemRecordByID(item.id);
                int        slot = localItemSlotMap.ContainsValue(item.id)
                                        ? localItemSlotMap.First(_pair => _pair.Value == item.id).Key
                                        : _getNextOpenSlot(rec.Size);
                if (!dialogShown && !_addItemToSlot(slot, rec, item.amount))
                {
                    dialogShown = true;
                    EODialog.Show("Something doesn't fit in the inventory. Rearrange items or get rid of them.", "Warning", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                }
            }

            //coordinates for parent of EOInventory: 102, 330 (pnlInventory in InGameHud)
            //extra in photoshop right now: 8, 31

            //current weight label (member variable, needs to have text updated when item amounts change)
            m_lblWeight = new XNALabel(new Rectangle(385, 37, 88, 18), "Microsoft Sans MS", 8f)
            {
                ForeColor = System.Drawing.Color.FromArgb(255, 0xc8, 0xc8, 0xc8),
                TextAlign = ContentAlignment.MiddleCenter,
                Visible   = true,
                AutoSize  = false
            };
            m_lblWeight.SetParent(this);
            UpdateWeightLabel();

            Texture2D thatWeirdSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27);             //oh my gawd the offsets on this bish

            //(local variables, added to child controls)
            //'paperdoll' button
            m_btnPaperdoll = new XNAButton(thatWeirdSheet, new Vector2(385, 9), /*new Rectangle(39, 385, 88, 19)*/ null, new Rectangle(126, 385, 88, 19));
            m_btnPaperdoll.SetParent(this);
            m_btnPaperdoll.OnClick += (s, e) => m_api.RequestPaperdoll((short)World.Instance.MainPlayer.ActiveCharacter.ID);
            //'drop' button
            //491, 398 -> 389, 68
            //0,15,38,37
            //0,52,38,37
            m_btnDrop = new XNAButton(thatWeirdSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37));
            m_btnDrop.SetParent(this);
            World.IgnoreDialogs(m_btnDrop);
            //'junk' button - 4 + 38 on the x away from drop
            m_btnJunk = new XNAButton(thatWeirdSheet, new Vector2(431, 68), new Rectangle(0, 89, 38, 37), new Rectangle(0, 126, 38, 37));
            m_btnJunk.SetParent(this);
            World.IgnoreDialogs(m_btnJunk);
        }