Example #1
0
        private void MainButtonPress(object sender, EventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

            if (sender == _backButton && State == GameStates.PlayingTheGame)
            {
                EOMessageBox.Show(DialogResourceID.EXIT_GAME_ARE_YOU_SURE, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                                  (ss, ee) =>
                {
                    if (ee.Result == XNADialogResult.OK)
                    {
                        _backButtonPressed    = true;
                        Dispatcher.Subscriber = null;
                        OldWorld.Instance.ResetGameElements();
                        if (OldWorld.Instance.Client.ConnectedAndInitialized)
                        {
                            OldWorld.Instance.Client.Disconnect();
                        }
                        doStateChange(GameStates.Initial);
                        _backButtonPressed = false;
                    }
                });
            }
        }
Example #2
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.Show("Do you want to train?", "Skill training", EODialogButtons.OkCancel,
                                  EOMessageBoxStyle.SmallDialogSmallHeader,
                                  (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();
            }
        }
        private void _statskillReset(StatResetData data)
        {
            OldCharacter c;

            (c = OldWorld.Instance.MainPlayer.ActiveCharacter).Spells.Clear();
            EOMessageBox.Show(DialogResourceID.SKILL_RESET_CHARACTER_COMPLETE, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
            c.Stats.StatPoints  = data.StatPoints;
            c.Stats.SkillPoints = data.SkillPoints;
            c.Stats.HP          = data.HP;
            c.Stats.MaxHP       = data.MaxHP;
            c.Stats.TP          = data.TP;
            c.Stats.MaxTP       = data.MaxTP;
            c.Stats.SP          = data.MaxSP;
            c.Stats.MaxSP       = data.MaxSP;
            c.Stats.Str         = data.Str;
            c.Stats.Int         = data.Int;
            c.Stats.Wis         = data.Wis;
            c.Stats.Agi         = data.Agi;
            c.Stats.Con         = data.Con;
            c.Stats.Cha         = data.Cha;
            c.Stats.MinDam      = data.MinDam;
            c.Stats.MaxDam      = data.MaxDam;
            c.Stats.Accuracy    = data.Accuracy;
            c.Stats.Evade       = data.Evade;
            c.Stats.Armor       = data.Armor;
            m_game.Hud.RefreshStats();
            m_game.Hud.RemoveAllSpells();
        }
        private void HandleChestClick()
        {
            var characterWithinOneUnitOfChest  = Math.Max(_mainCharacter.X - _gridX, _mainCharacter.Y - _gridY) <= 1;
            var characterInSameRowOrColAsChest = _gridX == _mainCharacter.X || _gridY == _mainCharacter.Y;

            if (characterWithinOneUnitOfChest && characterInSameRowOrColAsChest)
            {
                var chest = MapRef.Chests.Single(_mc => _mc.X == _gridX && _mc.Y == _gridY);
                if (chest == null)
                {
                    return;
                }

                string requiredKey;
                switch (_mainCharacter.CanOpenChest(chest))
                {
                case ChestKey.Normal: requiredKey = "Normal Key"; break;

                case ChestKey.Silver: requiredKey = "Silver Key"; break;

                case ChestKey.Crystal: requiredKey = "Crystal Key"; break;

                case ChestKey.Wraith: requiredKey = "Wraith Key"; break;

                default: ChestDialog.Show(_game.API, (byte)chest.X, (byte)chest.Y); return;
                }

                EOMessageBox.Show(DialogResourceID.CHEST_LOCKED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                _game.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING,
                                         EOResourceID.STATUS_LABEL_THE_CHEST_IS_LOCKED_EXCLAMATION,
                                         " - " + requiredKey);
            }
        }
        private void _statskillForgetSpell(short id)
        {
            OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.RemoveAll(_spell => _spell.ID == id);
            EOMessageBox.Show(DialogResourceID.SKILL_FORGET_SUCCESS, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);

            m_game.Hud.RemoveSpellFromActiveSpellsByID(id);
        }
Example #6
0
 public void ShowLostConnectionDialog()
 {
     if (_backButtonPressed)
     {
         return;
     }
     EOMessageBox.Show(State == GameStates.PlayingTheGame
         ? DialogResourceID.CONNECTION_LOST_IN_GAME
         : DialogResourceID.CONNECTION_LOST_CONNECTION);
 }
        private void _statskillLearnError(SkillMasterReply reply, short id)
        {
            switch (reply)
            {
            //not sure if this will ever actually be sent because client validates data before trying to learn a skill
            case SkillMasterReply.ErrorWrongClass:
                EOMessageBox.Show(DialogResourceID.SKILL_LEARN_WRONG_CLASS, " " + OldWorld.Instance.ECF.Data[id].Name + "!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                break;

            case SkillMasterReply.ErrorRemoveItems:
                EOMessageBox.Show(DialogResourceID.SKILL_RESET_CHARACTER_CLEAR_PAPERDOLL, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                break;
            }
        }
        private void _tradeRequested(short playerID, string name)
        {
            if (!OldWorld.Instance.Interaction)
            {
                return;
            }

            EOMessageBox.Show(char.ToUpper(name[0]) + name.Substring(1) + " ", DialogResourceID.TRADE_REQUEST, EODialogButtons.OkCancel,
                              EOMessageBoxStyle.SmallDialogSmallHeader, (o, e) =>
            {
                if (e.Result == XNADialogResult.OK && !m_packetAPI.TradeAcceptRequest(playerID))
                {
                    m_game.DoShowLostConnectionDialogAndReturnToMainMenu();
                }
            });
        }
        private void _partyRequest(PartyRequestType type, short id, string name)
        {
            if (!OldWorld.Instance.Interaction)
            {
                return;
            }

            EOMessageBox.Show(name + " ",
                              type == PartyRequestType.Join ? DialogResourceID.PARTY_GROUP_REQUEST_TO_JOIN : DialogResourceID.PARTY_GROUP_SEND_INVITATION,
                              EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                              (o, e) =>
            {
                if (e.Result == XNADialogResult.OK)
                {
                    if (!m_packetAPI.PartyAcceptRequest(type, id))
                    {
                        m_game.DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                }
            });
        }
Example #10
0
        public ChestKey CanOpenChest(ChestSpawnMapEntity chest)
        {
            ChestKey permission = chest.Key;

            EIFRecord rec;

            switch (permission) //note - it would be nice to be able to send the Item IDs of the keys in the welcome packet or something
            {
            case ChestKey.Normal:
                rec = OldWorld.Instance.EIF.Data.Single(_rec => _rec.Name != null && _rec.Name.ToLower() == "normal key");
                break;

            case ChestKey.Crystal:
                rec = OldWorld.Instance.EIF.Data.Single(_rec => _rec.Name != null && _rec.Name.ToLower() == "crystal key");
                break;

            case ChestKey.Silver:
                rec = OldWorld.Instance.EIF.Data.Single(_rec => _rec.Name != null && _rec.Name.ToLower() == "silver key");
                break;

            case ChestKey.Wraith:
                rec = OldWorld.Instance.EIF.Data.Single(_rec => _rec.Name != null && _rec.Name.ToLower() == "wraith key");
                break;

            default:
                return(permission);
            }

            if (rec != null && Inventory.FindIndex(_ii => _ii.ItemID == rec.ID) >= 0)
            {
                permission = ChestKey.None;
            }
            else if (rec == null) //show a warning saying that this chest is perma-locked. Non-standard pub files will cause this.
            {
                EOMessageBox.Show(
                    $"Unable to find key for {Enum.GetName(typeof(ChestKey), permission)} in EIF. This chest will never be opened!", "Warning", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
            }

            return(permission);
        }
 private void _eventTrade(object arg1, EventArgs arg2)
 {
     if (OldWorld.Instance.MainPlayer.ActiveCharacter.CurrentMap == OldWorld.Instance.JailMap)
     {
         EOMessageBox.Show(OldWorld.GetString(EOResourceID.JAIL_WARNING_CANNOT_TRADE),
                           OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                           EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
     }
     else
     {
         if (m_lastTradeRequestedTime != null && (DateTime.Now - m_lastTradeRequestedTime.Value).TotalSeconds < Constants.TradeRequestTimeoutSeconds)
         {
             ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_TRADE_RECENTLY_REQUESTED);
             return;
         }
         m_lastTradeRequestedTime = DateTime.Now;
         if (!m_api.TradeRequest((short)m_rend.Character.ID))
         {
             ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
         }
         //todo: is this correct text?
         ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_TRADE_REQUESTED_TO_TRADE);
     }
 }
Example #12
0
        public override void Update(GameTime gameTime)
        {
            if (!Game.IsActive || !Enabled)
            {
                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 (((OldEOInventory)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 = 200; //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 (((OldEOInventory)parent).IsOverDrop() || (OldWorld.Instance.ActiveMapRenderer.MouseOver &&
                                                              ChestDialog.Instance == null && EOPaperdollDialog.Instance == null && LockerDialog.Instance == null &&
                                                              BankAccountDialog.Instance == null && TradeDialog.Instance == null))
                {
                    Point loc = OldWorld.Instance.ActiveMapRenderer.MouseOver ? OldWorld.Instance.ActiveMapRenderer.GridCoords :
                                new Point(OldWorld.Instance.MainPlayer.ActiveCharacter.X, OldWorld.Instance.MainPlayer.ActiveCharacter.Y);

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

                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EOMessageBox.Show(DialogResourceID.ITEM_IS_LORE_ITEM, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (OldWorld.Instance.JailMap == OldWorld.Instance.MainPlayer.ActiveCharacter.CurrentMap)
                    {
                        EOMessageBox.Show(OldWorld.GetString(EOResourceID.JAIL_WARNING_CANNOT_DROP_ITEMS),
                                          OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                          EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.Amount > 1 && inRange)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.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.ItemID == 1 && !safetyCommentHasBeenShown)
                                {
                                    EOMessageBox.Show(DialogResourceID.DROP_MANY_GOLD_ON_GROUND, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader,
                                                      (o, e) => { safetyCommentHasBeenShown = true; });
                                }
                                else if (!m_api.DropItem(m_inventory.ItemID, dlg.SelectedAmount, (byte)loc.X, (byte)loc.Y))
                                {
                                    ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                                }
                            }
                        };
                    }
                    else if (inRange)
                    {
                        if (!m_api.DropItem(m_inventory.ItemID, 1, (byte)loc.X, (byte)loc.Y))
                        {
                            ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                        }
                    }
                    else /*if (!inRange)*/
                    {
                        EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_WARNING, EOResourceID.STATUS_LABEL_ITEM_DROP_OUT_OF_RANGE);
                    }
                }
                else if (((OldEOInventory)parent).IsOverJunk())
                {
                    if (m_inventory.Amount > 1)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.TransferType.JunkItems,
                                                                        m_inventory.Amount, EOResourceID.DIALOG_TRANSFER_JUNK);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK && !m_api.JunkItem(m_inventory.ItemID, dlg.SelectedAmount))
                            {
                                ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                            }
                        };
                    }
                    else if (!m_api.JunkItem(m_inventory.ItemID, 1))
                    {
                        ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                }
                else if (ChestDialog.Instance != null && ChestDialog.Instance.MouseOver && ChestDialog.Instance.MouseOverPreviously)
                {
                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EOMessageBox.Show(DialogResourceID.ITEM_IS_LORE_ITEM, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.Amount > 1)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.TransferType.DropItems, m_inventory.Amount);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK &&
                                !m_api.ChestAddItem(ChestDialog.Instance.CurrentChestX, ChestDialog.Instance.CurrentChestY,
                                                    m_inventory.ItemID, dlg.SelectedAmount))
                            {
                                EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                            }
                        };
                    }
                    else
                    {
                        if (!m_api.ChestAddItem(ChestDialog.Instance.CurrentChestX, ChestDialog.Instance.CurrentChestY, m_inventory.ItemID, 1))
                        {
                            EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                        }
                    }
                }
                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 (LockerDialog.Instance != null && LockerDialog.Instance.MouseOver && LockerDialog.Instance.MouseOverPreviously)
                {
                    byte x = LockerDialog.Instance.X;
                    byte y = LockerDialog.Instance.Y;
                    if (m_inventory.ItemID == 1)
                    {
                        EOMessageBox.Show(DialogResourceID.LOCKER_DEPOSIT_GOLD_ERROR, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.Amount > 1)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.TransferType.ShopTransfer, m_inventory.Amount, EOResourceID.DIALOG_TRANSFER_TRANSFER);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result == XNADialogResult.OK)
                            {
                                if (LockerDialog.Instance.GetNewItemAmount(m_inventory.ItemID, dlg.SelectedAmount) > Constants.LockerMaxSingleItemAmount)
                                {
                                    EOMessageBox.Show(DialogResourceID.LOCKER_FULL_SINGLE_ITEM_MAX, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                                }
                                else if (!m_api.LockerAddItem(x, y, m_inventory.ItemID, dlg.SelectedAmount))
                                {
                                    EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                                }
                            }
                        };
                    }
                    else
                    {
                        if (LockerDialog.Instance.GetNewItemAmount(m_inventory.ItemID, 1) > Constants.LockerMaxSingleItemAmount)
                        {
                            EOMessageBox.Show(DialogResourceID.LOCKER_FULL_SINGLE_ITEM_MAX, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        }
                        else if (!m_api.LockerAddItem(x, y, m_inventory.ItemID, 1))
                        {
                            EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                        }
                    }
                }
                else if (BankAccountDialog.Instance != null && BankAccountDialog.Instance.MouseOver && BankAccountDialog.Instance.MouseOverPreviously && m_inventory.ItemID == 1)
                {
                    if (m_inventory.Amount == 0)
                    {
                        EOMessageBox.Show(DialogResourceID.BANK_ACCOUNT_UNABLE_TO_DEPOSIT, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                    }
                    else if (m_inventory.Amount > 1)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.TransferType.BankTransfer,
                                                                        m_inventory.Amount, EOResourceID.DIALOG_TRANSFER_DEPOSIT);
                        dlg.DialogClosing += (o, e) =>
                        {
                            if (e.Result == XNADialogResult.Cancel)
                            {
                                return;
                            }

                            if (!m_api.BankDeposit(dlg.SelectedAmount))
                            {
                                EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                            }
                        };
                    }
                    else
                    {
                        if (!m_api.BankDeposit(1))
                        {
                            EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                        }
                    }
                }
                else if (TradeDialog.Instance != null && TradeDialog.Instance.MouseOver && TradeDialog.Instance.MouseOverPreviously &&
                         !TradeDialog.Instance.MainPlayerAgrees)
                {
                    if (m_itemData.Special == ItemSpecial.Lore)
                    {
                        EOMessageBox.Show(DialogResourceID.ITEM_IS_LORE_ITEM);
                    }
                    else if (m_inventory.Amount > 1)
                    {
                        ItemTransferDialog dlg = new ItemTransferDialog(m_itemData.Name, ItemTransferDialog.TransferType.TradeItems,
                                                                        m_inventory.Amount, EOResourceID.DIALOG_TRANSFER_OFFER);
                        dlg.DialogClosing += (o, e) =>
                        {
                            if (e.Result != XNADialogResult.OK)
                            {
                                return;
                            }

                            if (!m_api.TradeAddItem(m_inventory.ItemID, dlg.SelectedAmount))
                            {
                                TradeDialog.Instance.Close(XNADialogResult.NO_BUTTON_PRESSED);
                                ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                            }
                        };
                    }
                    else if (!m_api.TradeAddItem(m_inventory.ItemID, 1))
                    {
                        TradeDialog.Instance.Close(XNADialogResult.NO_BUTTON_PRESSED);
                        ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                }

                //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(EOResourceID.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
        }
Example #13
0
        private void _handleDoubleClick()
        {
            OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter;

            bool useItem = false;

            switch (m_itemData.Type)
            {
            //equippable items
            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:
                byte subLoc = 0;
                if (m_itemData.Type == ItemType.Armlet || m_itemData.Type == ItemType.Ring || m_itemData.Type == ItemType.Bracer)
                {
                    if (c.PaperDoll[(int)m_itemData.GetEquipLocation()] == 0)
                    {
                        subLoc = 0;
                    }
                    else if (c.PaperDoll[(int)m_itemData.GetEquipLocation() + 1] == 0)
                    {
                        subLoc = 1;
                    }
                    else
                    {
                        EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION,
                                                           EOResourceID.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED);
                        break;
                    }
                }
                else if (m_itemData.Type == ItemType.Armor &&
                         m_itemData.Gender != c.RenderData.gender)
                {
                    EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION,
                                                       EOResourceID.STATUS_LABEL_ITEM_EQUIP_DOES_NOT_FIT_GENDER);
                    break;
                }

                //check stat requirements
                int[]    reqs     = new int[6];
                string[] reqNames = { "STR", "INT", "WIS", "AGI", "CON", "CHA" };
                if ((reqs[0] = m_itemData.StrReq) > c.Stats.Str || (reqs[1] = m_itemData.IntReq) > c.Stats.Int ||
                    (reqs[2] = m_itemData.WisReq) > c.Stats.Wis || (reqs[3] = m_itemData.AgiReq) > c.Stats.Agi ||
                    (reqs[4] = m_itemData.ConReq) > c.Stats.Con || (reqs[5] = m_itemData.ChaReq) > c.Stats.Cha)
                {
                    int reqIndex = reqs.ToList().FindIndex(x => x > 0);

                    ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION,
                                                      EOResourceID.STATUS_LABEL_ITEM_EQUIP_THIS_ITEM_REQUIRES,
                                                      $" {reqs[reqIndex]} {reqNames[reqIndex]}");
                    break;
                }
                //check class requirement
                if (m_itemData.ClassReq > 0 && m_itemData.ClassReq != c.Class)
                {
                    ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION,
                                                      EOResourceID.STATUS_LABEL_ITEM_EQUIP_CAN_ONLY_BE_USED_BY,
                                                      OldWorld.Instance.ECF[m_itemData.ClassReq].Name);
                    break;
                }

                if (c.EquipItem(m_itemData.Type, (short)m_itemData.ID,
                                (short)m_itemData.DollGraphic))
                {
                    if (!m_api.EquipItem((short)m_itemData.ID, subLoc))
                    {
                        EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                }
                else
                {
                    EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION,
                                                       EOResourceID.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED);
                }

                break;

            //usable items
            case ItemType.Teleport:
                if (!OldWorld.Instance.ActiveMapRenderer.MapRef.Properties.CanScroll)
                {
                    EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_NOTHING_HAPPENED);
                    break;
                }
                if (m_itemData.ScrollMap == OldWorld.Instance.MainPlayer.ActiveCharacter.CurrentMap &&
                    m_itemData.ScrollX == OldWorld.Instance.MainPlayer.ActiveCharacter.X &&
                    m_itemData.ScrollY == OldWorld.Instance.MainPlayer.ActiveCharacter.Y)
                {
                    break;     //already there - no need to scroll!
                }
                useItem = true;
                break;

            case ItemType.Heal:
            case ItemType.HairDye:
            case ItemType.Beer:
                useItem = true;
                break;

            case ItemType.CureCurse:
                //note: don't actually set the useItem bool here. Call API.UseItem if the dialog result is OK.
                if (c.PaperDoll.Select(id => OldWorld.Instance.EIF[id])
                    .Any(rec => rec.Special == ItemSpecial.Cursed))
                {
                    EOMessageBox.Show(DialogResourceID.ITEM_CURSE_REMOVE_PROMPT, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                                      (o, e) =>
                    {
                        if (e.Result == XNADialogResult.OK && !m_api.UseItem((short)m_itemData.ID))
                        {
                            ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                        }
                    });
                }
                break;

            case ItemType.EXPReward:
                useItem = true;
                break;

            case ItemType.EffectPotion:
                useItem = true;
                break;
                //Not implemented server-side
                //case ItemType.SkillReward:
                //    break;
                //case ItemType.StatReward:
                //    break;
            }

            if (useItem && !m_api.UseItem((short)m_itemData.ID))
            {
                ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
            }

            m_recentClickCount = 0;
        }
Example #14
0
        public void UpdateInventoryItem(short id, int characterAmount, byte characterWeight, byte characterMaxWeight, bool addToExistingAmount = false)
        {
            InventoryItem rec;

            if ((rec = Inventory.Find(item => item.ItemID == id)).ItemID == id)
            {
                InventoryItem newRec = new InventoryItem
                                           (amount: addToExistingAmount ? characterAmount + rec.Amount : characterAmount,
                                           itemID: id);
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    //false when AddItem fails to find a good spot
                    if (!EOGame.Instance.Hud.UpdateInventory(newRec))
                    {
                        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 we can hold it, update local inventory and weight stats
                if (!Inventory.Remove(rec))
                {
                    throw new Exception("Unable to remove from inventory!");
                }
                if (newRec.Amount > 0)
                {
                    Inventory.Add(newRec);
                }
                Weight    = characterWeight;
                MaxWeight = characterMaxWeight;
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    EOGame.Instance.Hud.RefreshStats();
                }
            }
            else
            {
                //for item_get/chest_get packets, the item may not be in the inventory yet
                InventoryItem newRec = new InventoryItem(amount: characterAmount, itemID: id);
                if (newRec.Amount <= 0)
                {
                    return;
                }

                Inventory.Add(newRec);
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    //false when AddItem fails to find a good spot
                    if (!EOGame.Instance.Hud.UpdateInventory(newRec))
                    {
                        EOMessageBox.Show(OldWorld.GetString(EOResourceID.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT),
                                          OldWorld.GetString(EOResourceID.STATUS_LABEL_TYPE_WARNING),
                                          EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        return;
                    }
                }
                Weight    = characterWeight;
                MaxWeight = characterMaxWeight;
                if (this == OldWorld.Instance.MainPlayer.ActiveCharacter)
                {
                    EOGame.Instance.Hud.RefreshStats();
                }
            }
        }
Example #15
0
        public OldActiveSpells(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            _api = api;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            foreach (var child in children.Where(x => !(x is EmptySpellIcon)))
            {
                OldWorld.IgnoreDialogs(child);
            }
        }
 private void _eventShowBook(object arg1, EventArgs arg2)
 {
     EOMessageBox.Show("TODO: Show quest info", "TODO ITEM", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
 }
        public OldEOInventory(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 = OldWorld.Instance.MainPlayer.ActiveCharacter.Inventory;

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

            foreach (var item in localInv)
            {
                var rec  = OldWorld.Instance.EIF[item.ItemID];
                int slot = localItemSlotMap.ContainsValue(item.ItemID)
                    ? localItemSlotMap.First(_pair => _pair.Value == item.ItemID).Key
                    : _getNextOpenSlot(rec.Size);

                List <Tuple <int, int> > points;
                if (!_fitsInSlot(slot, rec.Size, out points))
                {
                    slot = _getNextOpenSlot(rec.Size);
                }

                if (!_addItemToSlot(slot, rec, item.Amount) && !dialogShown)
                {
                    dialogShown = true;
                    EOMessageBox.Show("Something doesn't fit in the inventory. Rearrange items or get rid of them.", "Warning", EODialogButtons.Ok, EOMessageBoxStyle.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), Constants.FontSize08pt5)
            {
                ForeColor = ColorConstants.LightGrayText,
                TextAlign = LabelAlignment.MiddleCenter,
                Visible   = true,
                AutoSize  = false
            };
            m_lblWeight.SetParent(this);
            UpdateWeightLabel();

            Texture2D thatWeirdSheet = ((EOGame)Game).GFXManager.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)OldWorld.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);
            OldWorld.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);
            OldWorld.IgnoreDialogs(m_btnJunk);
        }
Example #18
0
        private void _settingChange(object sender, EventArgs e)
        {
            if (sender == m_buttons[0])
            {
                if (!m_soundChanged && !w.SoundEnabled)
                {
                    EOMessageBox.Show(DialogResourceID.SETTINGS_SOUND_DISABLED, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                                      (o, args) =>
                    {
                        if (args.Result == XNADialogResult.OK)
                        {
                            m_soundChanged = true;
                            w.SoundEnabled = !w.SoundEnabled;
                            OldWorld.Instance.ActiveMapRenderer.PlayOrStopAmbientNoise();
                            m_leftSide[0].Text = OldWorld.GetString(w.SoundEnabled ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
                        }
                    });
                }
                else
                {
                    if (!m_soundChanged)
                    {
                        m_soundChanged = true;
                    }

                    w.SoundEnabled = !w.SoundEnabled;
                    OldWorld.Instance.ActiveMapRenderer.PlayOrStopAmbientNoise();
                    m_leftSide[0].Text = OldWorld.GetString(w.SoundEnabled ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
                }
            }
            else if (sender == m_buttons[1])
            {
                if (!m_musicChanged && !w.MusicEnabled)
                {
                    EOMessageBox.Show(DialogResourceID.SETTINGS_MUSIC_DISABLED, EODialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader,
                                      (o, args) =>
                    {
                        if (args.Result == XNADialogResult.OK)
                        {
                            m_musicChanged = true;
                            w.MusicEnabled = !w.MusicEnabled;
                            OldWorld.Instance.ActiveMapRenderer.PlayOrStopBackgroundMusic();
                            m_leftSide[1].Text = OldWorld.GetString(w.MusicEnabled ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
                        }
                    });
                }
                else
                {
                    if (!m_musicChanged)
                    {
                        m_musicChanged = true;
                    }

                    w.MusicEnabled = !w.MusicEnabled;
                    OldWorld.Instance.ActiveMapRenderer.PlayOrStopBackgroundMusic();
                    m_leftSide[1].Text = OldWorld.GetString(w.MusicEnabled ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
                }
            }
            else if (sender == m_buttons[2])
            {
                m_keyboard++;
                if (m_keyboard > KeyLayout.Azerty)
                {
                    m_keyboard = 0;
                }
                m_leftSide[2].Text = OldWorld.GetString(EOResourceID.SETTING_KEYBOARD_ENGLISH + (int)m_keyboard);
            }
            else if (sender == m_buttons[3])
            {
                if (w.Language != EOLanguage.Portuguese)
                {
                    w.Language++;
                }
                else
                {
                    w.Language = 0;
                }
                _setTextForLanguage(); //need to reset all strings when language changes
            }
            else if (sender == m_buttons[4])
            {
                w.HearWhispers     = !w.HearWhispers;
                m_leftSide[4].Text = OldWorld.GetString(w.HearWhispers ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
                OldPacket pkt = new OldPacket(PacketFamily.Global, w.HearWhispers ? PacketAction.Remove : PacketAction.Player);
                pkt.AddChar(w.HearWhispers ? (byte)'n' : (byte)'y');
                w.Client.SendPacket(pkt);
            }
            else if (sender == m_buttons[5])
            {
                w.ShowChatBubbles   = !w.ShowChatBubbles;
                m_rightSide[0].Text = OldWorld.GetString(w.ShowChatBubbles ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
            }
            else if (sender == m_buttons[6])
            {
                w.ShowShadows       = !w.ShowShadows;
                m_rightSide[1].Text = OldWorld.GetString(w.ShowShadows ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
            }
            else if (sender == m_buttons[7])
            {
                EOResourceID str;
                if (w.StrictFilterEnabled)
                {
                    w.StrictFilterEnabled = false;
                    str = EOResourceID.SETTING_DISABLED;
                }
                else if (w.CurseFilterEnabled)
                {
                    w.CurseFilterEnabled  = false;
                    w.StrictFilterEnabled = true;
                    str = EOResourceID.SETTING_EXCLUSIVE;
                }
                else
                {
                    w.CurseFilterEnabled = true;
                    str = EOResourceID.SETTING_NORMAL;
                }
                m_rightSide[2].Text = OldWorld.GetString(str);
            }
            else if (sender == m_buttons[8])
            {
                w.LogChatToFile     = !w.LogChatToFile;
                m_rightSide[3].Text = OldWorld.GetString(w.LogChatToFile ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
            }
            else if (sender == m_buttons[9])
            {
                w.Interaction       = !w.Interaction;
                m_rightSide[4].Text = OldWorld.GetString(w.Interaction ? EOResourceID.SETTING_ENABLED : EOResourceID.SETTING_DISABLED);
            }
        }