Пример #1
0
        /// <summary>
        /// Handles the <see cref="InventoryForm.RequestDropItem"/> event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs{InventorySlot}"/> instance containing the event data.</param>
        void InventoryForm_RequestDropItem(InventoryForm sender, EventArgs <InventorySlot> e)
        {
            // Make sure the event came from the user's inventory
            if (sender.Inventory != UserInfo.Inventory)
            {
                return;
            }

            // Depending on what screens are open, see if it makes sense to not just drop the item onto the ground
            if (PeerTradeForm.IsTradeActive)
            {
                // If we are doing a peer trade, add the item into the trade instead
                var ptih = PeerTradeForm.PeerTradeInfoHandler;
                if (ptih != null)
                {
                    _peerTradeForm.AddToTrade(e.Item1);
                }
            }
            else if (ShopForm.IsVisible && ShopForm.ShopInfo != null)
            {
                // If we are currently shopping, try to sell the item instead
                if (ShopForm.ShopInfo.CanBuy)
                {
                    UserInfo.Inventory.SellToShop(e.Item1, GUIManager);
                }
            }
            else
            {
                // Drop the item onto the ground
                UserInfo.Inventory.Drop(e.Item1, GUIManager);
            }
        }
Пример #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="InventoryItemPB"/> class.
            /// </summary>
            /// <param name="parent">The parent.</param>
            /// <param name="pos">The relative position of the control.</param>
            /// <param name="slot">The <see cref="InventorySlot"/>.</param>
            /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception>
            public InventoryItemPB(InventoryForm parent, Vector2 pos, InventorySlot slot) : base(parent, pos, _itemSize)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException("parent");
                }

                _slot   = slot;
                Tooltip = _tooltipHandler;
            }
Пример #3
0
        /// <summary>
        /// Handles the <see cref="InventoryForm.RequestUseItem"/> event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs{InventorySlot}"/> instance containing the event data.</param>
        void InventoryForm_RequestUseItem(InventoryForm sender, EventArgs <InventorySlot> e)
        {
            // Make sure the event came from the user's inventory
            if (sender.Inventory != UserInfo.Inventory)
            {
                return;
            }

            // Send a request to use the item to the server
            UserInfo.Inventory.Use(e.Item1);
        }
Пример #4
0
            /// <summary>
            /// Initializes a new instance of the <see cref="InventoryItemPB"/> class.
            /// </summary>
            /// <param name="parent">The parent.</param>
            /// <param name="pos">The relative position of the control.</param>
            /// <param name="slot">The <see cref="InventorySlot"/>.</param>
            /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception>
            public InventoryItemPB(InventoryForm parent, Vector2 pos, InventorySlot slot) : base(parent, pos, _itemSize)
            {
                if (parent == null)
                    throw new ArgumentNullException("parent");

                _slot = slot;
                Tooltip = _tooltipHandler;
            }
Пример #5
0
        /// <summary>
        /// Handles the <see cref="InventoryForm.RequestUseItem"/> event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs{InventorySlot}"/> instance containing the event data.</param>
        void InventoryForm_RequestUseItem(InventoryForm sender, EventArgs<InventorySlot> e)
        {
            // Make sure the event came from the user's inventory
            if (sender.Inventory != UserInfo.Inventory)
                return;

            // Send a request to use the item to the server
            UserInfo.Inventory.Use(e.Item1);
        }
Пример #6
0
        /// <summary>
        /// Handles the <see cref="InventoryForm.RequestDropItem"/> event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs{InventorySlot}"/> instance containing the event data.</param>
        void InventoryForm_RequestDropItem(InventoryForm sender, EventArgs<InventorySlot> e)
        {
            // Make sure the event came from the user's inventory
            if (sender.Inventory != UserInfo.Inventory)
                return;

            // Depending on what screens are open, see if it makes sense to not just drop the item onto the ground
            if (PeerTradeForm.IsTradeActive)
            {
                // If we are doing a peer trade, add the item into the trade instead
                var ptih = PeerTradeForm.PeerTradeInfoHandler;
                if (ptih != null)
                    _peerTradeForm.AddToTrade(e.Item1);
            }
            else if (ShopForm.IsVisible && ShopForm.ShopInfo != null)
            {
                // If we are currently shopping, try to sell the item instead
                if (ShopForm.ShopInfo.CanBuy)
                    UserInfo.Inventory.SellToShop(e.Item1, GUIManager);
            }
            else
            {
                // Drop the item onto the ground
                UserInfo.Inventory.Drop(e.Item1, GUIManager);
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes the GUI components.
        /// </summary>
        void InitializeGUI()
        {
            // Set up the fonts
            _guiFont = GameScreenHelper.DefaultGameGUIFont;
            GUIManager.Font = _guiFont;
            GUIManager.Tooltip.Font = _guiFont;
            Character.NameFont = _guiFont;

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize) { CanFocus = true };

            // Set up all the forms used by this screen
            _statsForm = new StatsForm(UserInfo, _cScreen);
            _statsForm.RequestRaiseStat += StatsForm_RequestRaiseStat;

            _inventoryForm = new InventoryForm(_dragDropHandler, x => x == UserInfo.Inventory, InventoryInfoRequester,
                new Vector2(250, 0), _cScreen);
            _inventoryForm.RequestDropItem += InventoryForm_RequestDropItem;
            _inventoryForm.RequestUseItem += InventoryForm_RequestUseItem;

            _shopForm = new ShopForm(_dragDropHandler, new Vector2(250, 0), _cScreen);
            _shopForm.RequestPurchase += ShopForm_RequestPurchase;

            _skillsForm = new SkillsForm(SkillCooldownManager, new Vector2(100, 0), _cScreen, UserInfo.KnownSkills);
            _skillsForm.RequestUseSkill += SkillsForm_RequestUseSkill;

            _infoBox = new InfoBox(GameData.ScreenSize - new Vector2(5, 5), _guiFont);

            _equippedForm = new EquippedForm(_dragDropHandler, EquipmentInfoRequester, new Vector2(500, 0), _cScreen);
            _equippedForm.RequestUnequip += EquippedForm_RequestUnequip;

            _chatForm = new ChatForm(_cScreen, new Vector2(0, _cScreen.Size.Y));
            _chatForm.Say += ChatForm_Say;

            _chatDialogForm = new NPCChatDialogForm(new Vector2(50, 50), _cScreen);
            _chatDialogForm.SelectResponse += ChatDialogForm_SelectResponse;
            _chatDialogForm.RequestEndDialog += ChatDialogForm_RequestEndDialog;

            _statusEffectsForm = new StatusEffectsForm(_cScreen, new Vector2(_cScreen.Size.X, 0), this);

            _quickBarForm = new QuickBarForm(this, _cScreen, _cScreen.Position);

            _guildForm = new GuildForm(_cScreen, new Vector2(100, 100)) { GuildInfo = UserInfo.GuildInfo, IsVisible = false };
            _guildForm.JoinRequested += _guildForm_JoinRequested;
            _guildForm.LeaveRequested += _guildForm_LeaveRequested;

            _groupForm = new GroupForm(_cScreen, new Vector2(50, 350), new Vector2(150, 150)) { GroupInfo = UserInfo.GroupInfo };

            Func<QuestID, bool> questStartReqs = x => UserInfo.HasStartQuestRequirements.HasRequirements(x) ?? false;
            Func<QuestID, bool> questFinishReqs =
                x =>
                UserInfo.QuestInfo.ActiveQuests.Contains(x) && (UserInfo.HasFinishQuestRequirements.HasRequirements(x) ?? false);
            _availableQuestsForm = new AvailableQuestsForm(_cScreen, new Vector2(200), new Vector2(250, 350), questStartReqs,
                questFinishReqs);
            _availableQuestsForm.QuestAccepted += availableQuestsForm_QuestAccepted;

            _latencyLabel = new Label(_cScreen, new Vector2(_cScreen.ClientSize.X - 75, 5))
            { Text = string.Format(_latencyString, 0), ForeColor = Color.White };

            _skillCastProgressBar = new SkillCastProgressBar(_cScreen);

            var toolbar = new Toolbar(_cScreen, new Vector2(200, 200));
            toolbar.ItemClicked += Toolbar_ItemClicked;

            var gameMenu = new GameMenuForm(_cScreen);
            gameMenu.ClickedLogOut += GameMenuClickedLogOut;

            _peerTradeForm = new PeerTradeForm(_cScreen, new Vector2(200))
            { PeerTradeInfoHandler = Socket.PacketHandler.PeerTradeInfoHandler };

            // Add the forms to the GUI settings manager (which also restores any existing settings)
            _guiStatePersister = new GUIStatePersister("Default"); // FUTURE: Allow changing of the profile
            _guiStatePersister.Add("InventoryForm", _inventoryForm);
            _guiStatePersister.Add("EquippedForm", _equippedForm);
            _guiStatePersister.Add("StatsForm", _statsForm);
            _guiStatePersister.Add("ChatForm", _chatForm);
            _guiStatePersister.Add("ToolbarForm", toolbar);
            _guiStatePersister.Add("GuildForm", _guildForm);
            _guiStatePersister.Add("StatusEffectsForm", _statusEffectsForm);
            _guiStatePersister.Add("SkillsForm", _skillsForm);
            _guiStatePersister.Add("QuickBarForm", _quickBarForm);
            _guiStatePersister.Add("PeerTradeForm", _peerTradeForm);

            // Set the focus to the screen container
            _cScreen.SetFocus();
        }
Пример #8
0
        /// <summary>
        /// Initializes the GUI components.
        /// </summary>
        void InitializeGUI()
        {
            // Set up the fonts
            _guiFont                = GameScreenHelper.DefaultGameGUIFont;
            GUIManager.Font         = _guiFont;
            GUIManager.Tooltip.Font = _guiFont;
            Character.NameFont      = _guiFont;

            _cScreen = new Panel(GUIManager, Vector2.Zero, ScreenManager.ScreenSize)
            {
                CanFocus = true
            };

            // Set up all the forms used by this screen
            _statsForm = new StatsForm(UserInfo, _cScreen);
            _statsForm.RequestRaiseStat += StatsForm_RequestRaiseStat;

            _inventoryForm = new InventoryForm(_dragDropHandler, x => x == UserInfo.Inventory, InventoryInfoRequester,
                                               new Vector2(250, 0), _cScreen);
            _inventoryForm.RequestDropItem += InventoryForm_RequestDropItem;
            _inventoryForm.RequestUseItem  += InventoryForm_RequestUseItem;

            _shopForm = new ShopForm(_dragDropHandler, new Vector2(250, 0), _cScreen);
            _shopForm.RequestPurchase += ShopForm_RequestPurchase;

            _skillsForm = new SkillsForm(SkillCooldownManager, new Vector2(100, 0), _cScreen, UserInfo.KnownSkills);
            _skillsForm.RequestUseSkill += SkillsForm_RequestUseSkill;

            _infoBox = new InfoBox(GameData.ScreenSize - new Vector2(5, 5), _guiFont);

            _equippedForm = new EquippedForm(_dragDropHandler, EquipmentInfoRequester, new Vector2(500, 0), _cScreen);
            _equippedForm.RequestUnequip += EquippedForm_RequestUnequip;

            _chatForm      = new ChatForm(_cScreen, new Vector2(0, _cScreen.Size.Y));
            _chatForm.Say += ChatForm_Say;

            _chatDialogForm = new NPCChatDialogForm(new Vector2(50, 50), _cScreen);
            _chatDialogForm.SelectResponse   += ChatDialogForm_SelectResponse;
            _chatDialogForm.RequestEndDialog += ChatDialogForm_RequestEndDialog;

            _statusEffectsForm = new StatusEffectsForm(_cScreen, new Vector2(_cScreen.Size.X, 0), this);

            _quickBarForm = new QuickBarForm(this, _cScreen, _cScreen.Position);

            _guildForm = new GuildForm(_cScreen, new Vector2(100, 100))
            {
                GuildInfo = UserInfo.GuildInfo, IsVisible = false
            };
            _guildForm.JoinRequested  += _guildForm_JoinRequested;
            _guildForm.LeaveRequested += _guildForm_LeaveRequested;

            _groupForm = new GroupForm(_cScreen, new Vector2(50, 350), new Vector2(150, 150))
            {
                GroupInfo = UserInfo.GroupInfo
            };

            Func <QuestID, bool> questStartReqs  = x => UserInfo.HasStartQuestRequirements.HasRequirements(x) ?? false;
            Func <QuestID, bool> questFinishReqs =
                x =>
                UserInfo.QuestInfo.ActiveQuests.Contains(x) && (UserInfo.HasFinishQuestRequirements.HasRequirements(x) ?? false);

            _availableQuestsForm = new AvailableQuestsForm(_cScreen, new Vector2(200), new Vector2(250, 350), questStartReqs,
                                                           questFinishReqs);
            _availableQuestsForm.QuestAccepted += availableQuestsForm_QuestAccepted;

            _latencyLabel = new Label(_cScreen, new Vector2(_cScreen.ClientSize.X - 75, 5))
            {
                Text = string.Format(_latencyString, 0), ForeColor = Color.White
            };

            _skillCastProgressBar = new SkillCastProgressBar(_cScreen);

            var toolbar = new Toolbar(_cScreen, new Vector2(200, 200));

            toolbar.ItemClicked += Toolbar_ItemClicked;

            var gameMenu = new GameMenuForm(_cScreen);

            gameMenu.ClickedLogOut += GameMenuClickedLogOut;

            _peerTradeForm = new PeerTradeForm(_cScreen, new Vector2(200))
            {
                PeerTradeInfoHandler = Socket.PacketHandler.PeerTradeInfoHandler
            };

            // Add the forms to the GUI settings manager (which also restores any existing settings)
            _guiStatePersister = new GUIStatePersister("Default"); // FUTURE: Allow changing of the profile
            _guiStatePersister.Add("InventoryForm", _inventoryForm);
            _guiStatePersister.Add("EquippedForm", _equippedForm);
            _guiStatePersister.Add("StatsForm", _statsForm);
            _guiStatePersister.Add("ChatForm", _chatForm);
            _guiStatePersister.Add("ToolbarForm", toolbar);
            _guiStatePersister.Add("GuildForm", _guildForm);
            _guiStatePersister.Add("StatusEffectsForm", _statusEffectsForm);
            _guiStatePersister.Add("SkillsForm", _skillsForm);
            _guiStatePersister.Add("QuickBarForm", _quickBarForm);
            _guiStatePersister.Add("PeerTradeForm", _peerTradeForm);

            // Set the focus to the screen container
            _cScreen.SetFocus();
        }
Пример #9
0
            /// <summary>
            /// Handles when a mouse button has been raised on the <see cref="Control"/>.
            /// This is called immediately before <see cref="Control.OnMouseUp"/>.
            /// Override this method instead of using an event hook on <see cref="Control.MouseUp"/> when possible.
            /// </summary>
            /// <param name="e">The event args.</param>
            protected override void OnMouseUp(MouseButtonEventArgs e)
            {
                base.OnMouseUp(e);

                InventoryForm.InventoryItemPB_OnMouseUp(this, e);
            }