private BankAccountDialog(PacketAPI api)
			: base(api)
		{
			//this uses EODialogListItems but does not inherit from ListDialog since it is a different size
			//offsety 50
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
			_setSize(bgTexture.Width, bgTexture.Height);

			m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
			{
				ForeColor = Constants.LightGrayText,
				Text = "",
				TextAlign = LabelAlignment.MiddleRight,
				AutoSize = false
			};
			m_accountBalance.SetParent(this);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			cancel.SetParent(this);
			cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

			ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_DEPOSIT),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TRANSFER),
					World.GetString(DATCONST2.DIALOG_BANK_TO_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankDeposit),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			deposit.OnLeftClick += (o, e) => _deposit();
			deposit.OnRightClick += (o, e) => _deposit();
			ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_WITHDRAW),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TAKE),
					World.GetString(DATCONST2.DIALOG_BANK_FROM_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankWithdraw),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			withdraw.OnLeftClick += (o, e) => _withdraw();
			withdraw.OnRightClick += (o, e) => _withdraw();
			ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_LOCKER_UPGRADE),
				SubText = World.GetString(DATCONST2.DIALOG_BANK_MORE_SPACE),
				IconGraphic = _getDlgIcon(ListIcon.BankLockerUpgrade),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			upgrade.OnLeftClick += (o, e) => _upgrade();
			upgrade.OnRightClick += (o, e) => _upgrade();

			DialogClosing += (o, e) => { Instance = null; };

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 50);
			endConstructor(false);
		}
		public ProgressDialog(string msgText, string captionText = "")
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 18);
			_setSize(bgTexture.Width, bgTexture.Height);

			message = new XNALabel(new Rectangle(18, 57, 1, 1), Constants.FontSize10)
			{
				ForeColor = Constants.LightYellowText,
				Text = msgText,
				TextWidth = 254
			};
			message.SetParent(this);

			caption = new XNALabel(new Rectangle(59, 23, 1, 1), Constants.FontSize10)
			{
				ForeColor = Constants.LightYellowText,
				Text = captionText
			};
			caption.SetParent(this);

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			ok.OnClick += (sender, e) => Close(ok, XNADialogResult.Cancel);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			pbBackText = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 19);

			pbForeText = new Texture2D(Game.GraphicsDevice, 1, pbBackText.Height - 2); //foreground texture is just a fill
			Color[] pbForeFill = new Color[pbForeText.Width * pbForeText.Height];
			for (int i = 0; i < pbForeFill.Length; ++i)
				pbForeFill[i] = Color.FromNonPremultiplied(0xb4, 0xdc, 0xe6, 0xff);
			pbForeText.SetData(pbForeFill);

			endConstructor();
		}
        private void _addRemoveButtonForMember(PartyMember member)
        {
            int       delta      = m_removeTexture.Height / 3;
            bool      enabled    = m_mainIsLeader || member.ID == OldWorld.Instance.MainPlayer.ActiveCharacter.ID;
            XNAButton nextButton = new XNAButton(m_removeTexture,
                                                 new Vector2(DrawAreaWithOffset.X + DRAW_REMOVE_X, DRAW_OFFSET_Y),
                                                 enabled ? new Rectangle(0, 0, m_removeTexture.Width, delta) : new Rectangle(0, delta, m_removeTexture.Width, delta),
                                                 enabled ? new Rectangle(0, delta * 2, m_removeTexture.Width, delta) : new Rectangle(0, delta, m_removeTexture.Width, delta));

            if (enabled)
            {
                PartyMember localMember = member;
                nextButton.OnClick += (sender, args) => RemoveMember(localMember.ID);
            }
            nextButton.SetParent(this);
            m_buttons.Add(nextButton);
        }
		public ScrollingMessageDialog(string msgText)
		{
			textSplitter = new TextSplitter("", EOGame.Instance.DBGFont) { LineLength = 275 };

			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 40);
			_setSize(bgTexture.Width, bgTexture.Height);

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(138, 197), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			ok.OnClick += (sender, e) => Close(ok, XNADialogResult.OK);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			scrollBar = new ScrollBar(this, new Vector2(320, 66), new Vector2(16, 119), ScrollBarColors.LightOnMed);
			MessageText = msgText;

			endConstructor();
		}
Beispiel #5
0
        protected void _setButtons(ScrollingListDialogButtons setButtons)
        {
            if (dlgButtons.Count > 0)
            {
                dlgButtons.ForEach(_btn =>
                {
                    _btn.SetParent(null);
                    _btn.Close();
                });

                dlgButtons.Clear();
            }

            _buttons = setButtons;
            switch (setButtons)
            {
            case ScrollingListDialogButtons.BackCancel:
            case ScrollingListDialogButtons.AddCancel:
            {
                SmallButton which = setButtons == ScrollingListDialogButtons.BackCancel ? SmallButton.Back : SmallButton.Add;
                XNAButton   add   = new XNAButton(smallButtonSheet, new Vector2(48, 252), _getSmallButtonOut(which), _getSmallButtonOver(which));
                add.SetParent(this);
                add.OnClick += (o, e) => Close(add, setButtons == ScrollingListDialogButtons.BackCancel ? XNADialogResult.Back : XNADialogResult.Add);
                XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(144, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
                cancel.SetParent(this);
                cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

                dlgButtons.Add(add);
                dlgButtons.Add(cancel);
            }
            break;

            case ScrollingListDialogButtons.Cancel:
            {
                XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(96, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
                cancel.SetParent(this);
                cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

                dlgButtons.Add(cancel);
            }
            break;
            }
        }
        private QuestProgressDialog(PacketAPI api)
            : base(api)
        {
            DialogClosing += (o, e) =>
            {
                Instance = null;
            };

            _setupBGTexture();

            m_history = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.History), _getSmallButtonOver(SmallButton.History));
            m_history.SetParent(this);
            m_history.OnClick += _historyClick;

            m_progress = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.Progress), _getSmallButtonOver(SmallButton.Progress))
            {
                Visible = false
            };
            m_progress.SetParent(this);
            m_progress.OnClick += _progressClick;

            var ok = new XNAButton(smallButtonSheet, new Vector2(380, 252), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));

            ok.SetParent(this);
            ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);

            dlgButtons.AddRange(new[] { m_history, ok });

            m_titleText = new XNALabel(new Rectangle(18, 14, 452, 19), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                ForeColor = ColorConstants.LightGrayText,
                Text      = " "
            };
            m_titleText.SetParent(this);

            m_scrollBar.DrawLocation     = new Vector2(449, 44);
            SmallItemStyleMaxItemDisplay = 10;
            ListItemType = ListDialogItem.ListItemStyle.Small;
        }
		private ChestDialog(PacketAPI api, byte chestX, byte chestY)
			: base(api)
		{
			CurrentChestX = chestX;
			CurrentChestY = chestY;

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 227), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			cancel.OnClick += (sender, e) => Close(cancel, XNADialogResult.Cancel);
			dlgButtons.Add(cancel);
			whichButtons = XNADialogButtons.Cancel;

			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 51);
			_setSize(bgTexture.Width, bgTexture.Height);

			endConstructor(false);
			DrawLocation = new Vector2((Game.GraphicsDevice.PresentationParameters.BackBufferWidth - DrawArea.Width) / 2f, 15);
			cancel.SetParent(this);

			EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_CHEST_YOU_OPENED,
				World.GetString(DATCONST2.STATUS_LABEL_DRAG_AND_DROP_ITEMS));
		}
		private QuestProgressDialog(PacketAPI api)
			: base(api)
		{
			DialogClosing += (o, e) =>
			{
				Instance = null;
			};

			_setupBGTexture();

			m_history = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.History), _getSmallButtonOver(SmallButton.History));
			m_history.SetParent(this);
			m_history.OnClick += _historyClick;

			m_progress = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.Progress), _getSmallButtonOver(SmallButton.Progress))
			{
				Visible = false
			};
			m_progress.SetParent(this);
			m_progress.OnClick += _progressClick;

			var ok = new XNAButton(smallButtonSheet, new Vector2(380, 252), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			ok.SetParent(this);
			ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);

			dlgButtons.AddRange(new[] { m_history, ok });

			m_titleText = new XNALabel(new Rectangle(18, 14, 452, 19), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText,
				Text = " "
			};
			m_titleText.SetParent(this);

			m_scrollBar.DrawLocation = new Vector2(449, 44);
			SmallItemStyleMaxItemDisplay = 10;
			ListItemType = ListDialogItem.ListItemStyle.Small;
		}
		public TextInputDialog(string prompt, int maxInputChars = 12)
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 54);
			_setSize(bgTexture.Width, bgTexture.Height);

			XNALabel lblPrompt = new XNALabel(new Rectangle(16, 20, 235, 49), Constants.FontSize10)
			{
				AutoSize = false,
				ForeColor = Constants.LightGrayDialogMessage,
				TextWidth = 230,
				RowSpacing = 3,
				Text = prompt
			};
			lblPrompt.SetParent(this);

			//set this back once the dialog is closed.
			previousSubscriber = ((EOGame)Game).Dispatcher.Subscriber;
			DialogClosing += (o, e) => ((EOGame)Game).Dispatcher.Subscriber = previousSubscriber;

			m_inputBox = new XNATextBox(new Rectangle(37, 74, 192, 19), EOGame.Instance.Content.Load<Texture2D>("cursor"), Constants.FontSize08)
			{
				MaxChars = maxInputChars,
				LeftPadding = 4,
				TextColor = Constants.LightBeigeText
			};
			m_inputBox.SetParent(this);
			EOGame.Instance.Dispatcher.Subscriber = m_inputBox;

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(41, 103), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)),
				cancel = new XNAButton(smallButtonSheet, new Vector2(134, 103), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);
			cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);
			ok.SetParent(this);
			cancel.SetParent(this);

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 107);
			endConstructor(false);
		}
Beispiel #10
0
        private ChestDialog(PacketAPI api, byte chestX, byte chestY)
            : base(api)
        {
            CurrentChestX = chestX;
            CurrentChestY = chestY;

            XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 227), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));

            cancel.OnClick += (sender, e) => Close(cancel, XNADialogResult.Cancel);
            dlgButtons.Add(cancel);
            whichButtons = XNADialogButtons.Cancel;

            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 51);
            _setSize(bgTexture.Width, bgTexture.Height);

            endConstructor(false);
            DrawLocation = new Vector2((Game.GraphicsDevice.PresentationParameters.BackBufferWidth - DrawArea.Width) / 2f, 15);
            cancel.SetParent(this);

            EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_CHEST_YOU_OPENED,
                                               OldWorld.GetString(EOResourceID.STATUS_LABEL_DRAG_AND_DROP_ITEMS));
        }
Beispiel #11
0
		private void _setDialogButtons()
		{
			dlgButtons.ForEach(btn =>
			{
				btn.SetParent(null);
				btn.Close();
			});
			dlgButtons.Clear();

			bool morePages = _pageIndex < _pages.Count - 1;
			bool firstPage = _pageIndex == 0;

			Vector2 firstLoc = new Vector2(89, 153), secondLoc = new Vector2(183, 153);

			if (firstPage && morePages)
			{
				//show cancel/next
				XNAButton cancel = new XNAButton(smallButtonSheet, firstLoc, _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
				cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);
				cancel.SetParent(this);
				dlgButtons.Add(cancel);

				XNAButton next = new XNAButton(smallButtonSheet, secondLoc, _getSmallButtonOut(SmallButton.Next), _getSmallButtonOver(SmallButton.Next));
				next.OnClick += (o, e) => _nextPage();
				next.SetParent(this);
				dlgButtons.Add(next);
			}
			else if (!firstPage && morePages)
			{
				//show back/next
				XNAButton back = new XNAButton(smallButtonSheet, firstLoc, _getSmallButtonOut(SmallButton.Back), _getSmallButtonOver(SmallButton.Back));
				back.OnClick += (o, e) => _prevPage();
				back.SetParent(this);
				dlgButtons.Add(back);

				XNAButton next = new XNAButton(smallButtonSheet, secondLoc, _getSmallButtonOut(SmallButton.Next), _getSmallButtonOver(SmallButton.Next));
				next.OnClick += (o, e) => _nextPage();
				next.SetParent(this);
				dlgButtons.Add(next);
			}
			else if (firstPage)
			{
				//show cancel/ok
				XNAButton cancel = new XNAButton(smallButtonSheet, firstLoc, _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
				cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);
				cancel.SetParent(this);
				dlgButtons.Add(cancel);

				XNAButton ok = new XNAButton(smallButtonSheet, secondLoc, _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
				ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);
				ok.SetParent(this);
				dlgButtons.Add(ok);
			}
			else
			{
				//show back/ok
				XNAButton back = new XNAButton(smallButtonSheet, firstLoc, _getSmallButtonOut(SmallButton.Back), _getSmallButtonOver(SmallButton.Back));
				back.OnClick += (o, e) => _prevPage();
				back.SetParent(this);
				dlgButtons.Add(back);

				XNAButton ok = new XNAButton(smallButtonSheet, secondLoc, _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
				ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);
				ok.SetParent(this);
				dlgButtons.Add(ok);
			}
		}
Beispiel #12
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;
        }
		private EOPaperdollDialog(PacketAPI api, Character character, PaperdollDisplayData data)
			: base(api)
		{
			if (Instance != null)
				throw new InvalidOperationException("Paperdoll is already open!");
			Instance = this;

			CharRef = character;

			Texture2D bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 49);
			_setSize(bgSprites.Width, bgSprites.Height / 2);

			Color[] dat = new Color[DrawArea.Width * DrawArea.Height];
			bgTexture = new Texture2D(Game.GraphicsDevice, DrawArea.Width, DrawArea.Height);
			bgSprites.GetData(0, DrawArea.WithPosition(new Vector2(0, CharRef.RenderData.gender * DrawArea.Height)), dat, 0, dat.Length);
			bgTexture.SetData(dat);

			//not using caption/message since we have other shit to take care of

			//ok button
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(276, 253), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)) { Visible = true };
			ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			//items
			for (int i = (int)EquipLocation.Boots; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
			{
				ItemRecord info = World.Instance.EIF.GetItemRecordByID(CharRef.PaperDoll[i]);

				Rectangle itemArea = _getEquipLocRectangle((EquipLocation)i);

				//create item using itemArea
				if (CharRef.PaperDoll[i] > 0)
				{
					// ReSharper disable once UnusedVariable
					PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, info, (EquipLocation)i); //auto-added as child of this dialog
				}
				else
				{
					// ReSharper disable once UnusedVariable
					PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, null, (EquipLocation)i);
				}
			}

			//labels next
			XNALabel[] labels =
			{
				new XNALabel(new Rectangle(228, 22, 1, 1), Constants.FontSize08pt5)
				{
					Text = CharRef.Name.Length > 0 ? char.ToUpper(CharRef.Name[0]) + CharRef.Name.Substring(1) : ""
				}, //name
				new XNALabel(new Rectangle(228, 52, 1, 1), Constants.FontSize08pt5)
				{
					Text = data.Home.Length > 0 ? char.ToUpper(data.Home[0]) + data.Home.Substring(1) : ""
				}, //home
				new XNALabel(new Rectangle(228, 82, 1, 1), Constants.FontSize08pt5)
				{
					Text = ((ClassRecord)(World.Instance.ECF.Data.Find(_dat => ((ClassRecord)_dat).ID == CharRef.Class) ?? new ClassRecord(0))).Name
				}, //class
				new XNALabel(new Rectangle(228, 112, 1, 1), Constants.FontSize08pt5)
				{
					Text = data.Partner.Length > 0 ? char.ToUpper(data.Partner[0]) + data.Partner.Substring(1) : ""
				}, //partner
				new XNALabel(new Rectangle(228, 142, 1, 1), Constants.FontSize08pt5)
				{
					Text = CharRef.Title.Length > 0 ? char.ToUpper(CharRef.Title[0]) + CharRef.Title.Substring(1) : ""
				}, //title
				new XNALabel(new Rectangle(228, 202, 1, 1), Constants.FontSize08pt5)
				{
					Text = data.Guild.Length > 0 ? char.ToUpper(data.Guild[0]) + data.Guild.Substring(1) : ""
				}, //guild
				new XNALabel(new Rectangle(228, 232, 1, 1), Constants.FontSize08pt5)
				{
					Text = data.Rank.Length > 0 ? char.ToUpper(data.Rank[0]) + data.Rank.Substring(1) : ""
				} //rank
			};

			labels.ToList().ForEach(_l => { _l.ForeColor = Constants.LightGrayText; _l.SetParent(this); });

			ChatType iconType = EOChatRenderer.GetChatTypeFromPaperdollIcon(data.Icon);
			m_characterIcon = ChatTab.GetChatIcon(iconType);

			//should not be centered vertically: only display in game window
			//first center in the game display window, then move it 15px from top, THEN call end constructor logic
			//if not done in this order some items DrawAreaWithOffset field does not get updated properly when setting DrawLocation
			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 15);
			endConstructor(false);
		}
		protected void _setButtons(ScrollingListDialogButtons setButtons)
		{
			if (dlgButtons.Count > 0)
			{
				dlgButtons.ForEach(_btn =>
				{
					_btn.SetParent(null);
					_btn.Close();
				});

				dlgButtons.Clear();
			}

			_buttons = setButtons;
			switch (setButtons)
			{
				case ScrollingListDialogButtons.BackCancel:
				case ScrollingListDialogButtons.AddCancel:
					{
						SmallButton which = setButtons == ScrollingListDialogButtons.BackCancel ? SmallButton.Back : SmallButton.Add;
						XNAButton add = new XNAButton(smallButtonSheet, new Vector2(48, 252), _getSmallButtonOut(which), _getSmallButtonOver(which));
						add.SetParent(this);
						add.OnClick += (o, e) => Close(add, setButtons == ScrollingListDialogButtons.BackCancel ? XNADialogResult.Back : XNADialogResult.Add);
						XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(144, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
						cancel.SetParent(this);
						cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

						dlgButtons.Add(add);
						dlgButtons.Add(cancel);
					}
					break;
				case ScrollingListDialogButtons.Cancel:
					{
						XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(96, 252), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
						cancel.SetParent(this);
						cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

						dlgButtons.Add(cancel);
					}
					break;
			}
		}
		public ChangePasswordDialog(Texture2D cursorTexture, KeyboardDispatcher dispatcher)
		{
			dispatch = dispatcher;

			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 21);
			_setSize(bgTexture.Width, bgTexture.Height);

			for (int i = 0; i < inputBoxes.Length; ++i)
			{
				XNATextBox tb = new XNATextBox(new Rectangle(198, 60 + i * 30, 137, 19), cursorTexture, Constants.FontSize08)
				{
					LeftPadding = 5,
					DefaultText = " ",
					MaxChars = i == 0 ? 16 : 12,
					PasswordBox = i > 1,
					Selected = i == 0,
					TextColor = Constants.LightBeigeText,
					Visible = true
				};

				tb.OnTabPressed += (s, e) =>
				{
					List<XNATextBox> list = inputBoxes.ToList();
					int tbIndex = list.FindIndex(txt => txt == s);

					int next = tbIndex + 1 > 3 ? 0 : tbIndex + 1;
					inputBoxes[tbIndex].Selected = false;
					inputBoxes[next].Selected = true;
					dispatch.Subscriber = inputBoxes[next];
				};

				tb.OnClicked += (s, e) =>
				{
					dispatch.Subscriber.Selected = false;
					dispatch.Subscriber = (s as XNATextBox);
					dispatcher.Subscriber.Selected = true;
				};

				tb.SetParent(this);
				inputBoxes[i] = tb;
			}

			dispatch.Subscriber = inputBoxes[0];

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(157, 195), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) =>
			{ //does some input validation before trying to call Close
				//check that all fields are filled in, otherwise: return
				if (inputBoxes.Any(tb => string.IsNullOrWhiteSpace(tb.Text))) return;

				if (Username != World.Instance.MainPlayer.AccountName)
				{
					EOMessageBox.Show(DATCONST1.CHANGE_PASSWORD_MISMATCH);
					return;
				}

				//check that passwords match, otherwise: return
				if (inputBoxes[2].Text.Length != inputBoxes[3].Text.Length || inputBoxes[2].Text != inputBoxes[3].Text)
				{
					EOMessageBox.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_MISMATCH);
					return;
				}

				//check that password is > 6 chars, otherwise: return
				if (inputBoxes[2].Text.Length < 6)
				{
					EOMessageBox.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_TOO_SHORT);
					return;
				}

				Close(ok, XNADialogResult.OK);
			};
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(250, 195), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			endConstructor();
		}
		public EOMessageBox(string msgText, string captionText = "", XNADialogButtons whichButtons = XNADialogButtons.Ok, EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader)
		{
			this.whichButtons = whichButtons;

			var useSmallHeader = true;
			switch (style)
			{
				case EOMessageBoxStyle.SmallDialogLargeHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 18);
					useSmallHeader = false;
					break;
				case EOMessageBoxStyle.SmallDialogSmallHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 23);
					break;
				case EOMessageBoxStyle.LargeDialogSmallHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 25);
					break;
				default:
					throw new ArgumentOutOfRangeException("style", "Unrecognized dialog style!");
			}
			_setSize(bgTexture.Width, bgTexture.Height);

			message = new XNALabel(new Rectangle(18, 57, 1, 1), Constants.FontSize10);
			if (useSmallHeader)
			{
				//179, 119
				//caption 197, 128
				//message 197, 156
				//ok: 270, 201
				//cancel: 363, 201
				message.DrawLocation = new Vector2(18, 40);
			}
			message.ForeColor = Constants.LightYellowText;
			message.Text = msgText;
			message.TextWidth = 254;
			message.SetParent(this);

			caption = new XNALabel(new Rectangle(59, 23, 1, 1), Constants.FontSize10);
			if (useSmallHeader)
			{
				caption.DrawLocation = new Vector2(18, 12);
			}
			caption.ForeColor = Constants.LightYellowText;
			caption.Text = captionText;
			caption.SetParent(this);

			XNAButton ok, cancel;
			switch (whichButtons)
			{
				case XNADialogButtons.Ok:
					ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
					ok.OnClick += (sender, e) => Close(ok, XNADialogResult.OK);
					ok.SetParent(this);
					dlgButtons.Add(ok);
					break;
				case XNADialogButtons.Cancel:
					cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
					cancel.OnClick += (sender, e) => Close(cancel, XNADialogResult.Cancel);
					cancel.SetParent(this);
					dlgButtons.Add(cancel);
					break;
				case XNADialogButtons.OkCancel:
					//implement this more fully when it is needed
					//update draw location of ok button to be on left?
					ok = new XNAButton(smallButtonSheet, new Vector2(89, 113), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
					ok.OnClick += (sender, e) => Close(ok, XNADialogResult.OK);
					ok.SetParent(this);

					cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
					cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
					cancel.SetParent(this);

					dlgButtons.Add(ok);
					dlgButtons.Add(cancel);
					break;
			}

			if (useSmallHeader)
			{
				if (style == EOMessageBoxStyle.SmallDialogSmallHeader)
					foreach (XNAButton btn in dlgButtons)
						btn.DrawLocation = new Vector2(btn.DrawLocation.X, 82);
				else
					foreach (XNAButton btn in dlgButtons)
						btn.DrawLocation = new Vector2(btn.DrawLocation.X, 148);
			}

			endConstructor();
		}
        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);
        }
Beispiel #18
0
		public TradeDialog(PacketAPI apiHandle)
			: base(apiHandle)
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 50);
			_setSize(bgTexture.Width, bgTexture.Height);

			Instance = this;
			DialogClosing += (sender, args) => Instance = null;
			m_main = World.Instance.MainPlayer.ActiveCharacter;

			m_leftItems = new List<ListDialogItem>();
			m_rightItems = new List<ListDialogItem>();

			m_leftPlayerID = 0;
			m_rightPlayerID = 0;

			m_leftPlayerName = new XNALabel(new Rectangle(20, 14, 166, 20), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText
			};
			m_leftPlayerName.SetParent(this);
			m_rightPlayerName = new XNALabel(new Rectangle(285, 14, 166, 20), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText
			};
			m_rightPlayerName.SetParent(this);
			m_leftPlayerStatus = new XNALabel(new Rectangle(195, 14, 79, 20), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING),
				ForeColor = Constants.LightGrayText
			};
			m_leftPlayerStatus.SetParent(this);
			m_rightPlayerStatus = new XNALabel(new Rectangle(462, 14, 79, 20), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				Text = World.GetString(DATCONST2.DIALOG_TRADE_WORD_TRADING),
				ForeColor = Constants.LightGrayText
			};
			m_rightPlayerStatus.SetParent(this);

			m_leftScroll = new ScrollBar(this, new Vector2(252, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 };
			m_rightScroll = new ScrollBar(this, new Vector2(518, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed) { LinesToRender = 5 };

			//BUTTONSSSS
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(356, 252), _getSmallButtonOut(SmallButton.Ok),
				_getSmallButtonOver(SmallButton.Ok));
			ok.OnClick += _buttonOkClicked;
			ok.SetParent(this);
			dlgButtons.Add(ok);
			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(449, 252), _getSmallButtonOut(SmallButton.Cancel),
				_getSmallButtonOver(SmallButton.Cancel));
			cancel.OnClick += _buttonCancelClicked;
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			Timer localTimer = new Timer(state =>
			{
				if (m_recentPartnerRemoves > 0)
					m_recentPartnerRemoves--;
			}, null, 0, 5000);

			DialogClosing += (o, e) =>
			{
				if (e.Result == XNADialogResult.Cancel)
				{
					if (!m_api.TradeClose())
						((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
					((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_TRADE_ABORTED);
				}

				localTimer.Dispose();
			};

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 30);
			endConstructor(false);
		}
        private SessionExpDialog()
            : base((PacketAPI)null)
        {
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 61);
            _setSize(bgTexture.Width, bgTexture.Height);

            m_icons  = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);
            m_signal = new Rectangle(0, 15, 15, 15);
            m_icon   = new Rectangle(0, 0, 15, 15);

            XNAButton okButton = new XNAButton(smallButtonSheet, new Vector2(98, 214), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));

            okButton.OnClick += (sender, args) => Close(okButton, XNADialogResult.OK);
            okButton.SetParent(this);

            XNALabel title = new XNALabel(new Rectangle(20, 17, 1, 1), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                Text      = OldWorld.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE),
                ForeColor = ColorConstants.LightGrayText
            };

            title.SetParent(this);

            XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8];
            for (int i = 48; i <= 160; i += 16)
            {
                leftSide[(i - 48) / 16] = new XNALabel(new Rectangle(38, i, 1, 1), Constants.FontSize08pt5)
                {
                    AutoSize  = false,
                    ForeColor = ColorConstants.LightGrayText
                };
                leftSide[(i - 48) / 16].SetParent(this);
                rightSide[(i - 48) / 16] = new XNALabel(new Rectangle(158, i, 1, 1), Constants.FontSize08pt5)
                {
                    AutoSize  = false,
                    ForeColor = ColorConstants.LightGrayText
                };
                rightSide[(i - 48) / 16].SetParent(this);
            }

            leftSide[0].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP);
            leftSide[1].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL);
            leftSide[2].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED);
            leftSide[3].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP);
            leftSide[4].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG);
            leftSide[5].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG);
            leftSide[6].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL);
            leftSide[7].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL);
            OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter;

            rightSide[0].Text = $"{c.Stats.Experience}";
            rightSide[1].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1]}";
            rightSide[2].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1] - c.Stats.Experience}";
            rightSide[3].Text = $"{c.TodayExp}";
            rightSide[4].Text = $"{(int) (c.Stats.Experience/(c.Stats.Usage/60.0))}";
            int sessionTime = (int)(DateTime.Now - EOGame.Instance.Hud.SessionStartTime).TotalMinutes;

            rightSide[5].Text = $"{(sessionTime > 0 ? (c.TodayExp/sessionTime) : 0)}";
            rightSide[6].Text = $"{c.TodayBestKill}";
            rightSide[7].Text = $"{c.TodayLastKill}";

            Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText());
            Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText());

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 15);
            endConstructor(false);
        }
Beispiel #20
0
 private void _addRemoveButtonForMember(PartyMember member)
 {
     int delta = m_removeTexture.Height / 3;
     bool enabled = m_mainIsLeader || member.ID == World.Instance.MainPlayer.ActiveCharacter.ID;
     XNAButton nextButton = new XNAButton(m_removeTexture,
         new Vector2(DrawAreaWithOffset.X + DRAW_REMOVE_X, DRAW_OFFSET_Y),
         enabled ? new Rectangle(0, 0, m_removeTexture.Width, delta) : new Rectangle(0, delta, m_removeTexture.Width, delta),
         enabled ? new Rectangle(0, delta * 2, m_removeTexture.Width, delta) : new Rectangle(0, delta, m_removeTexture.Width, delta));
     if (enabled)
     {
         PartyMember localMember = member;
         nextButton.OnClick += (sender, args) => RemoveMember(localMember.ID);
     }
     nextButton.SetParent(this);
     m_buttons.Add(nextButton);
 }
Beispiel #21
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;
		}
		public EOCreateCharacterDialog(Texture2D cursorTexture, KeyboardDispatcher dispatcher)
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 20);
			_setSize(bgTexture.Width, bgTexture.Height);

			charCreateSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 22);

			inputBox = new XNATextBox(new Rectangle(80, 57, 138, 19), cursorTexture, Constants.FontSize08)
			{
				LeftPadding = 5,
				DefaultText = " ",
				MaxChars = 12,
				Selected = true,
				TextColor = Constants.LightBeigeText,
				Visible = true
			};
			inputBox.SetParent(this);
			dispatcher.Subscriber = inputBox;

			//four arrow buttons
			for (int i = 0; i < arrowButtons.Length; ++i)
			{
				XNAButton btn = new XNAButton(charCreateSheet, new Vector2(196, 85 + i * 26), new Rectangle(185, 38, 19, 19), new Rectangle(206, 38, 19, 19))
				{
					Visible = true
				};
				btn.OnClick += ArrowButtonClick;
				btn.SetParent(this);
				arrowButtons[i] = btn;
			}

			charRender = new CharacterRenderer(new Vector2(269, 83), new CharRenderData { gender = 0, hairstyle = 1, haircolor = 0, race = 0 });
			charRender.SetParent(this);
			srcRects[0] = new Rectangle(0, 38, 23, 19);
			srcRects[1] = new Rectangle(0, 19, 23, 19);
			srcRects[2] = new Rectangle(0, 0, 23, 19);
			srcRects[3] = new Rectangle(46, 38, 23, 19);

			//ok/cancel buttons
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(157, 195), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) =>
			{
				if (inputBox.Text.Length < 4)
				{
					EOMessageBox.Show(DATCONST1.CHARACTER_CREATE_NAME_TOO_SHORT);
					return;
				}

				Close(ok, XNADialogResult.OK);
			};
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(250, 195), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			endConstructor();
		}
Beispiel #23
0
        public TradeDialog(PacketAPI apiHandle)
            : base(apiHandle)
        {
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 50);
            _setSize(bgTexture.Width, bgTexture.Height);

            Instance       = this;
            DialogClosing += (sender, args) => Instance = null;
            m_main         = OldWorld.Instance.MainPlayer.ActiveCharacter;

            m_leftItems  = new List <ListDialogItem>();
            m_rightItems = new List <ListDialogItem>();

            m_leftPlayerID  = 0;
            m_rightPlayerID = 0;

            m_leftPlayerName = new XNALabel(new Rectangle(20, 14, 166, 20), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                ForeColor = ColorConstants.LightGrayText
            };
            m_leftPlayerName.SetParent(this);
            m_rightPlayerName = new XNALabel(new Rectangle(285, 14, 166, 20), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                ForeColor = ColorConstants.LightGrayText
            };
            m_rightPlayerName.SetParent(this);
            m_leftPlayerStatus = new XNALabel(new Rectangle(195, 14, 79, 20), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                Text      = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING),
                ForeColor = ColorConstants.LightGrayText
            };
            m_leftPlayerStatus.SetParent(this);
            m_rightPlayerStatus = new XNALabel(new Rectangle(462, 14, 79, 20), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleLeft,
                Text      = OldWorld.GetString(EOResourceID.DIALOG_TRADE_WORD_TRADING),
                ForeColor = ColorConstants.LightGrayText
            };
            m_rightPlayerStatus.SetParent(this);

            m_leftScroll = new OldScrollBar(this, new Vector2(252, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed)
            {
                LinesToRender = 5
            };
            m_rightScroll = new OldScrollBar(this, new Vector2(518, 44), new Vector2(16, 199), ScrollBarColors.LightOnMed)
            {
                LinesToRender = 5
            };

            //BUTTONSSSS
            XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(356, 252), _getSmallButtonOut(SmallButton.Ok),
                                         _getSmallButtonOver(SmallButton.Ok));

            ok.OnClick += _buttonOkClicked;
            ok.SetParent(this);
            dlgButtons.Add(ok);
            XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(449, 252), _getSmallButtonOut(SmallButton.Cancel),
                                             _getSmallButtonOver(SmallButton.Cancel));

            cancel.OnClick += _buttonCancelClicked;
            cancel.SetParent(this);
            dlgButtons.Add(cancel);

            Timer localTimer = new Timer(state =>
            {
                if (m_recentPartnerRemoves > 0)
                {
                    m_recentPartnerRemoves--;
                }
            }, null, 0, 5000);

            DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    if (!m_api.TradeClose())
                    {
                        ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                    ((EOGame)Game).Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, EOResourceID.STATUS_LABEL_TRADE_ABORTED);
                }

                localTimer.Dispose();
            };

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 30);
            endConstructor(false);
        }
Beispiel #24
0
        public EOInventory(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            m_api = api;

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

            //add the inventory items that were retrieved from the server
            List<InventoryItem> localInv = World.Instance.MainPlayer.ActiveCharacter.Inventory;
            if (localInv.Find(_item => _item.id == 1).id != 1)
                localInv.Insert(0, new InventoryItem {amount = 0, id = 1}); //add 0 gold if there isn't any gold

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

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

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

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

            //(local variables, added to child controls)
            //'paperdoll' button
            m_btnPaperdoll = new XNAButton(thatWeirdSheet, new Vector2(385, 9), /*new Rectangle(39, 385, 88, 19)*/null, new Rectangle(126, 385, 88, 19));
            m_btnPaperdoll.SetParent(this);
            m_btnPaperdoll.OnClick += (s, e) => m_api.RequestPaperdoll((short)World.Instance.MainPlayer.ActiveCharacter.ID);
            //'drop' button
            //491, 398 -> 389, 68
            //0,15,38,37
            //0,52,38,37
            m_btnDrop = new XNAButton(thatWeirdSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37));
            m_btnDrop.SetParent(this);
            World.IgnoreDialogs(m_btnDrop);
            //'junk' button - 4 + 38 on the x away from drop
            m_btnJunk = new XNAButton(thatWeirdSheet, new Vector2(431, 68), new Rectangle(0, 89, 38, 37), new Rectangle(0, 126, 38, 37));
            m_btnJunk.SetParent(this);
            World.IgnoreDialogs(m_btnJunk);
        }
		/// <summary>
		/// Create a new item transfer dialog
		/// </summary>
		/// <param name="itemName">Name of the item to be displayed</param>
		/// <param name="transferType">Which transfer is being done (controls title)</param>
		/// <param name="totalAmount">Maximum amount that can be transferred</param>
		/// <param name="message">Resource ID of message to control displayed text</param>
		public ItemTransferDialog(string itemName, TransferType transferType, int totalAmount, DATCONST2 message = DATCONST2.DIALOG_TRANSFER_DROP)
		{
			_validateMessage(message);

			Texture2D weirdSpriteSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27);
			Rectangle sourceArea = new Rectangle(38, 0, 265, 170);

			//get bgTexture
			Color[] textureData = new Color[sourceArea.Width * sourceArea.Height];
			bgTexture = new Texture2D(Game.GraphicsDevice, sourceArea.Width, sourceArea.Height);
			weirdSpriteSheet.GetData(0, sourceArea, textureData, 0, textureData.Length);
			bgTexture.SetData(textureData);

			//get the title bar - for when it isn't drop items
			if (transferType != TransferType.DropItems)
			{
				Rectangle titleBarArea = new Rectangle(40, 172 + ((int)transferType - 1) * 24, 241, 22);
				Color[] titleBarData = new Color[titleBarArea.Width * titleBarArea.Height];
				m_titleBarGfx = new Texture2D(Game.GraphicsDevice, titleBarArea.Width, titleBarArea.Height);
				weirdSpriteSheet.GetData(0, titleBarArea, titleBarData, 0, titleBarData.Length);
				m_titleBarGfx.SetData(titleBarData);
			}

			//set the buttons here

			//ok/cancel buttons
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(60, 125), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(153, 125), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			XNALabel descLabel = new XNALabel(new Rectangle(20, 42, 231, 33), Constants.FontSize10)
			{
				ForeColor = Constants.LightGrayDialogMessage,
				TextWidth = 200,
				Text = string.Format("{0} {1} {2}", World.GetString(DATCONST2.DIALOG_TRANSFER_HOW_MUCH), itemName, World.GetString(message))
			};
			descLabel.SetParent(this);

			//set the text box here
			//starting coords are 163, 97
			m_amount = new XNATextBox(new Rectangle(163, 95, 77, 19), Game.Content.Load<Texture2D>("cursor"), Constants.FontSize08)
			{
				Visible = true,
				Enabled = true,
				MaxChars = 8, //max drop/junk at a time will be 99,999,999
				TextColor = Constants.LightBeigeText,
				Text = "1"
			};
			m_amount.SetParent(this);
			m_prevSubscriber = EOGame.Instance.Dispatcher.Subscriber;
			EOGame.Instance.Dispatcher.Subscriber = m_amount;
			DialogClosing += (o, e) => EOGame.Instance.Dispatcher.Subscriber = m_prevSubscriber;

			m_totalAmount = totalAmount;

			//slider control
			Texture2D src = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
			//5th index when 'out', 6th index when 'over'
			Rectangle outText = new Rectangle(0, 15 * 5, 16, 15);
			Rectangle ovrText = new Rectangle(0, 15 * 6, 16, 15);
			Color[] outData = new Color[16 * 15];
			Color[] ovrData = new Color[16 * 15];
			Texture2D[] sliderTextures = new Texture2D[2];

			src.GetData(0, outText, outData, 0, outData.Length);
			src.GetData(0, ovrText, ovrData, 0, ovrData.Length);
			(sliderTextures[0] = new Texture2D(Game.GraphicsDevice, 16, 15)).SetData(outData);
			(sliderTextures[1] = new Texture2D(Game.GraphicsDevice, 16, 15)).SetData(ovrData);

			//starting coords are 25, 96; range rectangle is 122, 15
			XNAButton slider = new XNAButton(sliderTextures, new Vector2(25, 96));
			slider.OnClickDrag += (o, e) =>
			{
				s_sliderDragging = true; //ignores updates to slider location during text change
				MouseState st = Mouse.GetState();
				Rectangle sliderArea = new Rectangle(25, 96, 122 - slider.DrawArea.Width, 15);
				int newX = (st.X - PreviousMouseState.X) + (int)slider.DrawLocation.X;
				if (newX < sliderArea.X) newX = sliderArea.X;
				else if (newX > sliderArea.Width + sliderArea.X) newX = sliderArea.Width + sliderArea.X;
				slider.DrawLocation = new Vector2(newX, slider.DrawLocation.Y); //unchanged y coordinate, slides along x-axis

				float ratio = (newX - sliderArea.X) / (float)sliderArea.Width;
				m_amount.Text = ((int)Math.Round(ratio * m_totalAmount) + 1).ToString();
				s_sliderDragging = false;
			};
			slider.SetParent(this);

			m_amount.OnTextChanged += (sender, args) =>
			{
				int amt = 0;
				if (m_amount.Text != "" && (!int.TryParse(m_amount.Text, out amt) || amt > m_totalAmount))
				{
					amt = m_totalAmount;
					m_amount.Text = string.Format("{0}", m_totalAmount);
				}
				else if (m_amount.Text != "" && amt < 0)
				{
					amt = 1;
					m_amount.Text = string.Format("{0}", amt);
				}

				if (s_sliderDragging) return; //slider is being dragged - don't move its position

				//adjust the slider (created after m_amount) when the text changes
				if (amt <= 1) //NOT WORKING
				{
					slider.DrawLocation = new Vector2(25, 96);
				}
				else
				{
					int xCoord = (int)Math.Round((amt / (double)m_totalAmount) * (122 - slider.DrawArea.Width));
					slider.DrawLocation = new Vector2(25 + xCoord, 96);
				}
			};

			_setSize(bgTexture.Width, bgTexture.Height);
			DrawLocation = new Vector2(Game.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - bgTexture.Width / 2, 40); //only centered horizontally
			endConstructor(false);
		}
		public ActiveSpells(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 = World.Instance.MainPlayer.ActiveCharacter.Spells;
			// ReSharper disable once LoopCanBeConvertedToQuery
			foreach (var spell in localSpells)
			{
				SpellRecord rec = World.Instance.ESF.GetSpellRecordByID(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", XNADialogButtons.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 = Constants.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 = Constants.LightGrayText
			};
			_selectedSpellLevel.SetParent(this);

			var skillPoints = World.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 = Constants.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 ScrollBar(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)))
				World.IgnoreDialogs(child);
		}
		private SessionExpDialog()
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 61);
			_setSize(bgTexture.Width, bgTexture.Height);

			m_icons = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);
			m_signal = new Rectangle(0, 15, 15, 15);
			m_icon = new Rectangle(0, 0, 15, 15);

			XNAButton okButton = new XNAButton(smallButtonSheet, new Vector2(98, 214), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			okButton.OnClick += (sender, args) => Close(okButton, XNADialogResult.OK);
			okButton.SetParent(this);

			XNALabel title = new XNALabel(new Rectangle(20, 17, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = false,
				Text = World.GetString(DATCONST2.DIALOG_TITLE_PERFORMANCE),
				ForeColor = Constants.LightGrayText
			};
			title.SetParent(this);

			XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8];
			for (int i = 48; i <= 160; i += 16)
			{
				leftSide[(i - 48) / 16] = new XNALabel(new Rectangle(38, i, 1, 1), Constants.FontSize08pt5)
				{
					AutoSize = false,
					ForeColor = Constants.LightGrayText
				};
				leftSide[(i - 48) / 16].SetParent(this);
				rightSide[(i - 48) / 16] = new XNALabel(new Rectangle(158, i, 1, 1), Constants.FontSize08pt5)
				{
					AutoSize = false,
					ForeColor = Constants.LightGrayText
				};
				rightSide[(i - 48) / 16].SetParent(this);
			}

			leftSide[0].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_TOTALEXP);
			leftSide[1].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_NEXT_LEVEL);
			leftSide[2].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_EXP_NEEDED);
			leftSide[3].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_TODAY_EXP);
			leftSide[4].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_TOTAL_AVG);
			leftSide[5].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_TODAY_AVG);
			leftSide[6].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_BEST_KILL);
			leftSide[7].Text = World.GetString(DATCONST2.DIALOG_PERFORMANCE_LAST_KILL);
			Character c = World.Instance.MainPlayer.ActiveCharacter;
			rightSide[0].Text = string.Format("{0}", c.Stats.Experience);
			rightSide[1].Text = string.Format("{0}", World.Instance.exp_table[c.Stats.Level + 1]);
			rightSide[2].Text = string.Format("{0}", World.Instance.exp_table[c.Stats.Level + 1] - c.Stats.Experience);
			rightSide[3].Text = string.Format("{0}", c.TodayExp);
			rightSide[4].Text = string.Format("{0}", (int)(c.Stats.Experience / (c.Stats.Usage / 60.0)));
			int sessionTime = (int)(DateTime.Now - EOGame.Instance.Hud.SessionStartTime).TotalMinutes;
			rightSide[5].Text = string.Format("{0}", sessionTime > 0 ? (c.TodayExp / sessionTime) : 0);
			rightSide[6].Text = string.Format("{0}", c.TodayBestKill);
			rightSide[7].Text = string.Format("{0}", c.TodayLastKill);

			Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText());
			Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText());

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 15);
			endConstructor(false);
		}
Beispiel #28
0
        private EOPaperdollDialog(PacketAPI api, OldCharacter character, PaperdollDisplayData data)
            : base(api)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Paperdoll is already open!");
            }
            Instance = this;

            CharRef = character;

            Texture2D bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 49);

            _setSize(bgSprites.Width, bgSprites.Height / 2);

            Color[] dat = new Color[DrawArea.Width * DrawArea.Height];
            bgTexture = new Texture2D(Game.GraphicsDevice, DrawArea.Width, DrawArea.Height);
            bgSprites.GetData(0, DrawArea.WithPosition(new Vector2(0, CharRef.RenderData.gender * DrawArea.Height)), dat, 0, dat.Length);
            bgTexture.SetData(dat);

            //not using caption/message since we have other shit to take care of

            //ok button
            XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(276, 253), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
            {
                Visible = true
            };

            ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK);
            ok.SetParent(this);
            dlgButtons.Add(ok);

            //items
            for (int i = (int)EquipLocation.Boots; i < (int)EquipLocation.PAPERDOLL_MAX; ++i)
            {
                var info = OldWorld.Instance.EIF[CharRef.PaperDoll[i]];

                Rectangle itemArea = _getEquipLocRectangle((EquipLocation)i);

                //create item using itemArea
                if (CharRef.PaperDoll[i] > 0)
                {
                    // ReSharper disable once UnusedVariable
                    PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, info, (EquipLocation)i); //auto-added as child of this dialog
                }
                else
                {
                    // ReSharper disable once UnusedVariable
                    PaperdollDialogItem nextItem = new PaperdollDialogItem(m_api, itemArea, this, null, (EquipLocation)i);
                }
            }

            //labels next
            XNALabel[] labels =
            {
                new XNALabel(new Rectangle(228,  22, 1, 1), Constants.FontSize08pt5)
                {
                    Text = CharRef.Name.Length > 0 ? char.ToUpper(CharRef.Name[0]) + CharRef.Name.Substring(1) : ""
                },                              //name
                new XNALabel(new Rectangle(228,  52, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Home.Length > 0 ? char.ToUpper(data.Home[0]) + data.Home.Substring(1) : ""
                },                              //home
                new XNALabel(new Rectangle(228,  82, 1, 1), Constants.FontSize08pt5)
                {
                    Text = (OldWorld.Instance.ECF[CharRef.Class] ?? new ECFRecord()).Name ?? ""
                },                              //class
                new XNALabel(new Rectangle(228, 112, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Partner.Length > 0 ? char.ToUpper(data.Partner[0]) + data.Partner.Substring(1) : ""
                },                              //partner
                new XNALabel(new Rectangle(228, 142, 1, 1), Constants.FontSize08pt5)
                {
                    Text = CharRef.Title.Length > 0 ? char.ToUpper(CharRef.Title[0]) + CharRef.Title.Substring(1) : ""
                },                              //title
                new XNALabel(new Rectangle(228, 202, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Guild.Length > 0 ? char.ToUpper(data.Guild[0]) + data.Guild.Substring(1) : ""
                },                              //guild
                new XNALabel(new Rectangle(228, 232, 1, 1), Constants.FontSize08pt5)
                {
                    Text = data.Rank.Length > 0 ? char.ToUpper(data.Rank[0]) + data.Rank.Substring(1) : ""
                } //rank
            };

            labels.ToList().ForEach(_l => { _l.ForeColor = ColorConstants.LightGrayText; _l.SetParent(this); });

            ChatIcon icon = OldChatRenderer.GetChatTypeFromPaperdollIcon(data.Icon);

            m_characterIcon = OldChatTab.GetChatIcon(icon);

            //should not be centered vertically: only display in game window
            //first center in the game display window, then move it 15px from top, THEN call end constructor logic
            //if not done in this order some items DrawAreaWithOffset field does not get updated properly when setting DrawLocation
            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 15);
            endConstructor(false);
        }
Beispiel #29
0
        private BankAccountDialog(PacketAPI api)
            : base(api)
        {
            //this uses EODialogListItems but does not inherit from ListDialog since it is a different size
            //offsety 50
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
            _setSize(bgTexture.Width, bgTexture.Height);

            m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
            {
                ForeColor = ColorConstants.LightGrayText,
                Text      = "",
                TextAlign = LabelAlignment.MiddleRight,
                AutoSize  = false
            };
            m_accountBalance.SetParent(this);

            XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));

            cancel.SetParent(this);
            cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

            ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_DEPOSIT),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TRANSFER)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_TO_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankDeposit),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            deposit.OnLeftClick  += (o, e) => _deposit();
            deposit.OnRightClick += (o, e) => _deposit();
            ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_WITHDRAW),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TAKE)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_FROM_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankWithdraw),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            withdraw.OnLeftClick  += (o, e) => _withdraw();
            withdraw.OnRightClick += (o, e) => _withdraw();
            ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
            {
                Text               = OldWorld.GetString(EOResourceID.DIALOG_BANK_LOCKER_UPGRADE),
                SubText            = OldWorld.GetString(EOResourceID.DIALOG_BANK_MORE_SPACE),
                IconGraphic        = _getDlgIcon(ListIcon.BankLockerUpgrade),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            upgrade.OnLeftClick  += (o, e) => _upgrade();
            upgrade.OnRightClick += (o, e) => _upgrade();

            DialogClosing += (o, e) => { Instance = null; };

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 50);
            endConstructor(false);
        }
        public EOInventory(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            m_api = api;

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

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

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

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

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

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

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

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

            //(local variables, added to child controls)
            //'paperdoll' button
            m_btnPaperdoll = new XNAButton(thatWeirdSheet, new Vector2(385, 9), /*new Rectangle(39, 385, 88, 19)*/ null, new Rectangle(126, 385, 88, 19));
            m_btnPaperdoll.SetParent(this);
            m_btnPaperdoll.OnClick += (s, e) => m_api.RequestPaperdoll((short)World.Instance.MainPlayer.ActiveCharacter.ID);
            //'drop' button
            //491, 398 -> 389, 68
            //0,15,38,37
            //0,52,38,37
            m_btnDrop = new XNAButton(thatWeirdSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37));
            m_btnDrop.SetParent(this);
            m_btnDrop.IgnoreDialog(typeof(EOPaperdollDialog));
            m_btnDrop.IgnoreDialog(typeof(EOChestDialog));
            //'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);
            m_btnJunk.IgnoreDialog(typeof(EOPaperdollDialog));
            m_btnJunk.IgnoreDialog(typeof(EOChestDialog));
        }
Beispiel #31
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);
            }
        }