Example #1
0
 public OldScrollBar(XNAControl parent,
                     Vector2 locationRelativeToParent,
                     Vector2 size,
                     ScrollBarColors palette)
     : this(parent, locationRelativeToParent, size, palette, EOGame.Instance.GFXManager)
 {
 }
Example #2
0
        private XNAControl CreateChildControl(XNAControl parent, string keyValue)
        {
            string[] parts = keyValue.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length != 2)
            {
                throw new INIConfigException("Invalid child control definition " + keyValue);
            }

            string childName = parts[0];

            if (string.IsNullOrEmpty(childName))
            {
                throw new INIConfigException("Empty name in child control definition for " + parent.Name);
            }

            var childControl = ClientGUICreator.Instance.CreateControl(WindowManager, parts[1]);

            if (Array.Exists(childName.ToCharArray(), c => !char.IsLetterOrDigit(c) && c != '_'))
            {
                throw new INIConfigException("Names of INItializableWindow child controls must consist of letters, digits and underscores only. Offending name: " + parts[0]);
            }

            childControl.Name = childName;
            parent.AddChildWithoutInitialize(childControl);
            return(childControl);
        }
Example #3
0
 public int GetExprValue(string input, XNAControl parsingControl)
 {
     this.parsingControl = parsingControl;
     Input      = input;
     tokenPlace = 0;
     return(GetExprValue());
 }
        public static void AddAndInitializeWithControl(WindowManager wm, XNAControl control)
        {
            var dp = new DarkeningPanel(wm);

            wm.AddAndInitializeControl(dp);
            dp.AddChild(control);
        }
Example #5
0
        private static XNAControl GetParentControl(XNAControl parent)
        {
            if (parent is XNAWindow parentWindow)
            {
                return(parentWindow);
            }

            return(parent.Parent == null ? parent : GetParentControl(parent.Parent));
        }
        /// <summary>
        /// Inserts a control into the WindowManager on the first place
        /// in the list of controls.
        /// </summary>
        /// <param name="control">The control to insert.</param>
        public void InsertAndInitializeControl(XNAControl control)
        {
            if (Controls.Contains(control))
            {
                throw new Exception("WindowManager.InsertAndInitializeControl: Control " + control.Name + " already exists!");
            }

            Controls.Insert(0, control);
        }
        /// <summary>
        /// Adds a control to the WindowManager, on the last place
        /// in the list of controls. Does not call the control's
        /// Initialize() method.
        /// </summary>
        /// <param name="control">The control to add.</param>
        public void AddControl(XNAControl control)
        {
            if (Controls.Contains(control))
            {
                throw new InvalidOperationException("WindowManager.AddControl: Control " + control.Name + " already exists!");
            }

            Controls.Add(control);
        }
Example #8
0
        private void ReadINIRecursive(XNAControl control)
        {
            ReadINIForControl(control);

            foreach (var child in control.Children)
            {
                ReadINIRecursive(child);
            }
        }
        /// <summary>
        /// Updates the WindowManager. Do not call manually; MonoGame will call
        /// this automatically on every game frame.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            HasFocus = gameWindowManager.HasFocus();

            lock (locker)
            {
                List <Callback> callbacks = Callbacks;
                Callbacks = new List <Callback>();

                foreach (Callback c in callbacks)
                {
                    c.Invoke();
                }
            }

            XNAControl activeControl = null;

            activeControlName = null;

            if (HasFocus)
            {
                Keyboard.Update(gameTime);
            }

            Cursor.Update(gameTime);

            SoundPlayer.Update(gameTime);

            for (int i = Controls.Count - 1; i > -1; i--)
            {
                XNAControl control = Controls[i];

                if (HasFocus && control.InputEnabled && control.Enabled &&
                    (activeControl == null &&
                     control.RenderRectangle().Contains(Cursor.Location)
                     ||
                     control.Focused))
                {
                    control.IsActive  = true;
                    activeControl     = control;
                    activeControlName = control.Name;
                }
                else
                {
                    control.IsActive = false;
                }

                if (control.Enabled)
                {
                    control.Update(gameTime);
                }
            }

            base.Update(gameTime);
        }
Example #10
0
 public static void IgnoreDialogs(XNAControl control)
 {
     control.IgnoreDialog(typeof(EOPaperdollDialog));
     control.IgnoreDialog(typeof(EOChestDialog));
     control.IgnoreDialog(typeof(EOShopDialog));
     control.IgnoreDialog(typeof(EOBankAccountDialog));
     control.IgnoreDialog(typeof(EOLockerDialog));
     control.IgnoreDialog(typeof(EOTradeDialog));
     control.IgnoreDialog(typeof(EOFriendIgnoreListDialog));
     control.IgnoreDialog(typeof(EOSkillmasterDialog));
 }
Example #11
0
 private XNAWindow GetParentWindow(XNAControl parent)
 {
     if (parent is XNAWindow)
     {
         return(parent as XNAWindow);
     }
     else
     {
         return(GetParentWindow(parent.Parent));
     }
 }
Example #12
0
 /// <summary>
 /// Creates a new tool tip and attaches it to the given control.
 /// </summary>
 /// <param name="windowManager">The window manager.</param>
 /// <param name="masterControl">The control to attach the tool tip to.</param>
 public ToolTip(WindowManager windowManager, XNAControl masterControl) : base(windowManager)
 {
     this.masterControl            = masterControl ?? throw new ArgumentNullException("masterControl");
     masterControl.MouseEnter     += MasterControl_MouseEnter;
     masterControl.MouseLeave     += MasterControl_MouseLeave;
     masterControl.MouseMove      += MasterControl_MouseMove;
     masterControl.EnabledChanged += MasterControl_EnabledChanged;
     InputEnabled = false;
     DrawOrder    = int.MaxValue;
     GetParentControl(masterControl.Parent).AddChild(this);
     Visible = false;
 }
Example #13
0
 public static void IgnoreDialogs(XNAControl control)
 {
     control.IgnoreDialog(typeof(EOPaperdollDialog));
     control.IgnoreDialog(typeof(ChestDialog));
     control.IgnoreDialog(typeof(ShopDialog));
     control.IgnoreDialog(typeof(BankAccountDialog));
     control.IgnoreDialog(typeof(LockerDialog));
     control.IgnoreDialog(typeof(TradeDialog));
     control.IgnoreDialog(typeof(FriendIgnoreListDialog));
     control.IgnoreDialog(typeof(SkillmasterDialog));
     control.IgnoreDialog(typeof(QuestDialog));
     control.IgnoreDialog(typeof(QuestProgressDialog));
 }
Example #14
0
 /// <summary>
 /// Creates a new tool tip and attaches it to the given control.
 /// </summary>
 /// <param name="windowManager">The window manager.</param>
 /// <param name="masterControl">The control to attach the tool tip to.</param>
 public ToolTip(WindowManager windowManager, XNAControl masterControl) : base(windowManager)
 {
     this.masterControl            = masterControl ?? throw new ArgumentNullException("masterControl");
     masterControl.MouseEnter     += MasterControl_MouseEnter;
     masterControl.MouseLeave     += MasterControl_MouseLeave;
     masterControl.MouseMove      += MasterControl_MouseMove;
     masterControl.EnabledChanged += MasterControl_EnabledChanged;
     InputEnabled = false;
     DrawOrder    = int.MinValue;
     // TODO: adding tool tips as root-level controls might be CPU-intensive.
     // instead we could find out the root-level parent and only have the tooltip
     // in the window manager's list when the root-level parent is visible.
     WindowManager.AddControl(this);
     Visible = false;
 }
Example #15
0
 private XNAControl GetParentWindow(XNAControl parent)
 {
     if (parent is XNAWindow)
     {
         return(parent as XNAWindow);
     }
     else if (parent is INItializableWindow)
     {
         return(parent as INItializableWindow);
     }
     else
     {
         return(GetParentWindow(parent.Parent));
     }
 }
Example #16
0
        /// <summary>
        /// This constructor should be used for the news rendering
        /// </summary>
        public ChatTab(XNAControl parentControl)
            : base(null, null, parentControl)
        {
            WhichTab  = ChatTabs.None;
            _selected = true;
            tabLabel  = null;

            relativeTextPos = new Vector2(20, 23);
            //568 331
            scrollBar = new EOScrollBar(parent, new Vector2(467, 20), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed)
            {
                LinesToRender = 7,
                Visible       = true
            };
            World.IgnoreDialogs(scrollBar);
        }
Example #17
0
        /// <summary>
        /// Reads a second set of attributes for a control's child controls.
        /// Enables linking controls to controls that are defined after them.
        /// </summary>
        private void ReadLateAttributesForControl(XNAControl control)
        {
            var section = ConfigIni.GetSection(control.Name);

            if (section == null)
            {
                return;
            }

            var children = Children.ToList();

            foreach (var child in children)
            {
                // This logic should also be enabled for other types in the future,
                // but it requires changes in XNAUI
                if (!(child is XNATextBox))
                {
                    continue;
                }

                var childSection = ConfigIni.GetSection(child.Name);
                if (childSection == null)
                {
                    continue;
                }

                string nextControl = childSection.GetStringValue("NextControl", null);
                if (!string.IsNullOrWhiteSpace(nextControl))
                {
                    var otherChild = children.Find(c => c.Name == nextControl);
                    if (otherChild != null)
                    {
                        ((XNATextBox)child).NextControl = otherChild;
                    }
                }

                string previousControl = childSection.GetStringValue("PreviousControl", null);
                if (!string.IsNullOrWhiteSpace(previousControl))
                {
                    var otherChild = children.Find(c => c.Name == previousControl);
                    if (otherChild != null)
                    {
                        ((XNATextBox)child).PreviousControl = otherChild;
                    }
                }
            }
        }
Example #18
0
        private T FindChild <T>(IEnumerable <XNAControl> list, string controlName) where T : XNAControl
        {
            foreach (XNAControl child in list)
            {
                if (child.Name == controlName)
                {
                    return((T)child);
                }

                XNAControl childOfChild = FindChild <T>(child.Children, controlName);
                if (childOfChild != null)
                {
                    return((T)childOfChild);
                }
            }

            return(null);
        }
Example #19
0
        private XNAControl Find(IEnumerable <XNAControl> list, string controlName)
        {
            foreach (XNAControl child in list)
            {
                if (child.Name == controlName)
                {
                    return(child);
                }

                XNAControl childOfChild = Find(child.Children, controlName);
                if (childOfChild != null)
                {
                    return(childOfChild);
                }
            }

            return(null);
        }
        public override void Update(GameTime gameTime)
        {
            if (!Visible || !EOGame.Instance.IsActive)
            {
                return;
            }

            MouseState mouseState = Mouse.GetState();

            //this is our own button press handler
            if (MouseOver && mouseState.LeftButton == ButtonState.Released && PreviousMouseState.LeftButton == ButtonState.Pressed)
            {
                if (!Selected)
                {
                    ((EOChatRenderer)parent).SetSelectedTab(WhichTab);
                }

                //logic for handling the close button (not actually a button, was I high when I made this...?)
                if ((WhichTab == ChatTabs.Private1 || WhichTab == ChatTabs.Private2) && closeRect != null)
                {
                    Rectangle withOffset = new Rectangle(DrawAreaWithOffset.X + closeRect.Value.X, DrawAreaWithOffset.Y + closeRect.Value.Y, closeRect.Value.Width, closeRect.Value.Height);
                    if (withOffset.ContainsPoint(Mouse.GetState().X, Mouse.GetState().Y))
                    {
                        ClosePrivateChat();
                    }
                }
            }
            else if (Selected && mouseState.RightButton == ButtonState.Released && PreviousMouseState.RightButton == ButtonState.Pressed && WhichTab != ChatTabs.None)
            {
                XNAControl tmpParent = parent.GetParent();                 //get the panel containing this tab, the parent is the chatRenderer
                if (tmpParent.DrawAreaWithOffset.Contains(mouseState.X, mouseState.Y))
                {
                    int adjustedY = mouseState.Y - tmpParent.DrawAreaWithOffset.Y;
                    int level     = (int)Math.Round(adjustedY / 13.0) - 1;
                    if (level >= 0 && scrollBar.ScrollOffset + level < chatStrings.Count)
                    {
                        EOGame.Instance.Hud.SetChatText("!" + chatStrings.Keys[scrollBar.ScrollOffset + level].Who + " ");
                    }
                }
            }

            base.Update(gameTime);
        }
        public void Show(XNAControl control)
        {
            foreach (XNAControl child in Children)
            {
                child.Enabled = false;
                child.Visible = false;
            }

            Enabled = true;
            Visible = true;

            AlphaRate = DarkeningPanel.ALPHA_RATE;

            if (control != null)
            {
                control.Enabled            = true;
                control.Visible            = true;
                control.IgnoreInputOnFrame = true;
            }
        }
Example #22
0
        public void Show(XNAControl control)
        {
            foreach (XNAControl child in Children)
            {
                child.Enabled = false;
                child.Visible = false;
            }

            Enabled = true;
            Visible = true;

            bgAlphaRate = BG_ALPHA_APPEAR_RATE;

            if (control != null)
            {
                control.Enabled            = true;
                control.Visible            = true;
                control.IgnoreInputOnFrame = true;
            }
        }
Example #23
0
        public override void Initialize()
        {
            XNAControl parent = Parent;

            while (true)
            {
                if (parent == null)
                {
                    break;
                }

                // oh no, we have a circular class reference here!
                if (parent is GameLobbyBase gameLobby)
                {
                    gameLobby.CheckBoxes.Add(this);
                    break;
                }

                parent = parent.Parent;
            }

            base.Initialize();
        }
Example #24
0
		/// <summary>
		/// This constructor should be used for the news rendering
		/// </summary>
		public ChatTab(XNAControl parentControl)
			: base(null, null, parentControl)
		{
			WhichTab = ChatTabs.None;
			_selected = true;
			tabLabel = null;

			relativeTextPos = new Vector2(20, 23);
			//568 331
			scrollBar = new ScrollBar(parent, new Vector2(467, 20), new Vector2(16, 97), ScrollBarColors.LightOnMed)
			{
				LinesToRender = 7,
				Visible = true
			};
			World.IgnoreDialogs(scrollBar);
		}
Example #25
0
 public OptionsWindow(WindowManager windowManager, GameCollection gameCollection, XNAControl topBar) : base(windowManager)
 {
     this.gameCollection = gameCollection;
     this.topBar         = topBar;
 }
 public GameOptionsPanel(WindowManager windowManager, UserINISettings iniSettings, XNAControl topBar)
     : base(windowManager, iniSettings)
 {
     this.topBar = topBar;
 }
        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 chest dialog (chest add action)

                DrawOrder = m_preDragDrawOrder;
                m_alpha   = 255;
                SetParent(m_preDragParent);

                if (((EOInventory)parent).IsOverDrop() || (World.Instance.ActiveMapRenderer.MouseOver &&
                                                           EOChestDialog.Instance == null && EOPaperdollDialog.Instance == null && EOLockerDialog.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)
                {
                    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 (!Handlers.Locker.AddItem(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 (!Handlers.Locker.AddItem(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 (!Handlers.Bank.BankDeposit(dlg.SelectedAmount))
                            {
                                EOGame.Instance.LostConnectionDialog();
                            }
                        };
                    }
                    else
                    {
                        if (!Handlers.Bank.BankDeposit(1))
                        {
                            EOGame.Instance.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;
            }

            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
        }
Example #28
0
		public static void IgnoreDialogs(XNAControl control)
		{
			control.IgnoreDialog(typeof(EOPaperdollDialog));
			control.IgnoreDialog(typeof(ChestDialog));
			control.IgnoreDialog(typeof(ShopDialog));
			control.IgnoreDialog(typeof(BankAccountDialog));
			control.IgnoreDialog(typeof(LockerDialog));
			control.IgnoreDialog(typeof(TradeDialog));
			control.IgnoreDialog(typeof(FriendIgnoreListDialog));
			control.IgnoreDialog(typeof(SkillmasterDialog));
			control.IgnoreDialog(typeof(QuestDialog));
			control.IgnoreDialog(typeof(QuestProgressDialog));
		}
Example #29
0
		public ScrollBar(XNAControl parent, Vector2 relativeLoc, Vector2 size, ScrollBarColors palette)
			: base(relativeLoc, new Rectangle((int)relativeLoc.X, (int)relativeLoc.Y, (int)size.X, (int)size.Y))
		{
			SetParent(parent);
			scrollArea = new Rectangle(0, 15, 0, (int)size.Y - 15);
			DrawLocation = relativeLoc;
			ScrollOffset = 0;

			Texture2D scrollSpriteSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
			Rectangle[] upArrows = new Rectangle[2];
			Rectangle[] downArrows = new Rectangle[2];
			int vertOff;
			switch (palette)
			{
				case ScrollBarColors.LightOnLight: vertOff = 0; break;
				case ScrollBarColors.LightOnMed: vertOff = 105; break;
				case ScrollBarColors.LightOnDark: vertOff = 180; break;
				case ScrollBarColors.DarkOnDark: vertOff = 255; break;
				default:
					throw new ArgumentOutOfRangeException("palette");
			}

			//regions based on verticle offset (which is based on the chosen palette)
			upArrows[0] = new Rectangle(0, vertOff + 15 * 3, 16, 15);
			upArrows[1] = new Rectangle(0, vertOff + 15 * 4, 16, 15);
			downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
			downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
			Rectangle scrollBox = new Rectangle(0, vertOff, 16, 15);

			Texture2D[] upButton = new Texture2D[2];
			Texture2D[] downButton = new Texture2D[2];
			Texture2D[] scrollButton = new Texture2D[2];
			for (int i = 0; i < 2; ++i)
			{
				upButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, upArrows[i].Width, upArrows[i].Height);
				Color[] upData = new Color[upArrows[i].Width * upArrows[i].Height];
				scrollSpriteSheet.GetData(0, upArrows[i], upData, 0, upData.Length);
				upButton[i].SetData(upData);

				downButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, downArrows[i].Width, downArrows[i].Height);
				Color[] downData = new Color[downArrows[i].Width * downArrows[i].Height];
				scrollSpriteSheet.GetData(0, downArrows[i], downData, 0, downData.Length);
				downButton[i].SetData(downData);

				//same texture for hover, AFAIK
				scrollButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, scrollBox.Width, scrollBox.Height);
				Color[] scrollData = new Color[scrollBox.Width * scrollBox.Height];
				scrollSpriteSheet.GetData(0, scrollBox, scrollData, 0, scrollData.Length);
				scrollButton[i].SetData(scrollData);
			}

			up = new XNAButton(upButton, new Vector2(0, 0));
			up.OnClick += arrowClicked;
			up.SetParent(this);
			down = new XNAButton(downButton, new Vector2(0, size.Y - 15)); //update coordinates!!!!
			down.OnClick += arrowClicked;
			down.SetParent(this);
			scroll = new XNAButton(scrollButton, new Vector2(0, 15)); //update coordinates!!!!
			scroll.OnClickDrag += scrollDragged;
			scroll.OnMouseEnter += (o, e) => { SuppressParentClickDrag(true); };
			scroll.OnMouseLeave += (o, e) => { SuppressParentClickDrag(false); };
			scroll.SetParent(this);

			_totalHeight = DrawAreaWithOffset.Height;
		}
 /// <summary>
 /// Removes a control from the window manager.
 /// </summary>
 /// <param name="control">The control to remove.</param>
 public void RemoveControl(XNAControl control)
 {
     Controls.Remove(control);
 }
Example #31
0
 public static void IgnoreDialogs(XNAControl control)
 {
     control.IgnoreDialog(typeof(EOPaperdollDialog));
     control.IgnoreDialog(typeof(EOChestDialog));
     control.IgnoreDialog(typeof(EOShopDialog));
     control.IgnoreDialog(typeof(EOBankAccountDialog));
     control.IgnoreDialog(typeof(EOLockerDialog));
     control.IgnoreDialog(typeof(EOTradeDialog));
     control.IgnoreDialog(typeof(EOFriendIgnoreListDialog));
     control.IgnoreDialog(typeof(EOSkillmasterDialog));
 }
Example #32
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
        }
Example #33
0
        public OldScrollBar(XNAControl parent,
                            Vector2 locationRelaiveToParent,
                            Vector2 size,
                            ScrollBarColors palette,
                            INativeGraphicsManager nativeGraphicsManager)
            : base(locationRelaiveToParent,
                   new Rectangle((int)locationRelaiveToParent.X,
                                 (int)locationRelaiveToParent.Y,
                                 (int)size.X,
                                 (int)size.Y))
        {
            SetParent(parent);
            scrollArea   = new Rectangle(0, 15, 0, (int)size.Y - 15);
            DrawLocation = locationRelaiveToParent;
            ScrollOffset = 0;

            Texture2D scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29);

            Rectangle[] upArrows   = new Rectangle[2];
            Rectangle[] downArrows = new Rectangle[2];
            int         vertOff;

            switch (palette)
            {
            case ScrollBarColors.LightOnLight: vertOff = 0; break;

            case ScrollBarColors.LightOnMed: vertOff = 105; break;

            case ScrollBarColors.LightOnDark: vertOff = 180; break;

            case ScrollBarColors.DarkOnDark: vertOff = 255; break;

            default:
                throw new ArgumentOutOfRangeException(nameof(palette));
            }

            //regions based on verticle offset (which is based on the chosen palette)
            upArrows[0]   = new Rectangle(0, vertOff + 15 * 3, 16, 15);
            upArrows[1]   = new Rectangle(0, vertOff + 15 * 4, 16, 15);
            downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
            downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
            Rectangle scrollBox = new Rectangle(0, vertOff, 16, 15);

            Texture2D[] upButton     = new Texture2D[2];
            Texture2D[] downButton   = new Texture2D[2];
            Texture2D[] scrollButton = new Texture2D[2];
            for (int i = 0; i < 2; ++i)
            {
                upButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, upArrows[i].Width, upArrows[i].Height);
                Color[] upData = new Color[upArrows[i].Width * upArrows[i].Height];
                scrollSpriteSheet.GetData(0, upArrows[i], upData, 0, upData.Length);
                upButton[i].SetData(upData);

                downButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, downArrows[i].Width, downArrows[i].Height);
                Color[] downData = new Color[downArrows[i].Width * downArrows[i].Height];
                scrollSpriteSheet.GetData(0, downArrows[i], downData, 0, downData.Length);
                downButton[i].SetData(downData);

                //same texture for hover, AFAIK
                scrollButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, scrollBox.Width, scrollBox.Height);
                Color[] scrollData = new Color[scrollBox.Width * scrollBox.Height];
                scrollSpriteSheet.GetData(0, scrollBox, scrollData, 0, scrollData.Length);
                scrollButton[i].SetData(scrollData);
            }

            up          = new XNAButton(upButton, new Vector2(0, 0));
            up.OnClick += arrowClicked;
            up.SetParent(this);
            down          = new XNAButton(downButton, new Vector2(0, size.Y - 15)); //update coordinates!!!!
            down.OnClick += arrowClicked;
            down.SetParent(this);
            scroll               = new XNAButton(scrollButton, new Vector2(0, 15)); //update coordinates!!!!
            scroll.OnClickDrag  += scrollDragged;
            scroll.OnMouseEnter += (o, e) => { SuppressParentClickDrag(true); };
            scroll.OnMouseLeave += (o, e) => { SuppressParentClickDrag(false); };
            scroll.SetParent(this);

            _totalHeight = DrawAreaWithOffset.Height;
        }
Example #34
0
 public void SetPrimaryControl(XNAControl primaryControl)
 {
     this.primaryControl = primaryControl;
 }
        public override void AddChild(XNAControl child)
        {
            base.AddChild(child);

            child.VisibleChanged += Child_VisibleChanged;
        }