private void _tradeOpen(short p1, string p1name, short p2, string p2name)
		{
			TradeDialog dlg = new TradeDialog(m_packetAPI);
			dlg.InitPlayerInfo(p1, p1name, p2, p2name);

			string otherName;
			if (p1 == World.Instance.MainPlayer.ActiveCharacter.ID)
				otherName = p2name;
			else if (p2 == World.Instance.MainPlayer.ActiveCharacter.ID)
				otherName = p1name;
			else
				throw new ArgumentException("Invalid player ID for this trade session!", "p1");

			m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_TRADE_YOU_ARE_TRADING_WITH,
					otherName + " " + World.GetString(DATCONST2.STATUS_LABEL_DRAG_AND_DROP_ITEMS));
		}
示例#2
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);
        }