/// <summary> /// This Constructor should be used for all values in ChatTabs /// </summary> public OldChatTab(ChatTab tab, OldChatRenderer parentRenderer, bool selected = false) : base(null, null, parentRenderer) { WhichTab = tab; tabLabel = new XNALabel(new Rectangle(14, 2, 1, 1), Constants.FontSize08); tabLabel.SetParent(this); switch (WhichTab) { case ChatTab.Local: tabLabel.Text = "scr"; break; case ChatTab.Global: tabLabel.Text = "glb"; break; case ChatTab.Group: tabLabel.Text = "grp"; break; case ChatTab.System: tabLabel.Text = "sys"; break; case ChatTab.Private1: case ChatTab.Private2: tabLabel.Text = "[priv " + ((int)WhichTab + 1) + "]"; break; } Selected = selected; relativeTextPos = new Vector2(20, 3); //568 331 scrollBar = new OldScrollBar(parent, new Vector2(467, 2), new Vector2(16, 97), ScrollBarColors.LightOnMed) { Visible = selected, LinesToRender = 7 }; OldWorld.IgnoreDialogs(scrollBar); }
public TextInputDialog(string prompt, int maxInputChars = 12) : base((PacketAPI)null) { 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 = ColorConstants.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 = ColorConstants.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); }
private QuestDialog(PacketAPI api) : base(api) { DialogClosing += (o, e) => { if (e.Result == XNADialogResult.OK) { if (!m_api.RespondToQuestDialog(_stateInfo, DialogReply.Ok)) { ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu(); } } Instance = null; }; _dialogNames = new Dictionary <short, string>(); _links = new Dictionary <short, string>(); _pages = new List <string>(); _setBackgroundTexture(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 67)); caption = new XNALabel(new Rectangle(16, 16, 255, 18), Constants.FontSize08pt5) { AutoSize = false, TextAlign = LabelAlignment.MiddleLeft, ForeColor = ColorConstants.LightGrayText }; caption.SetParent(this); m_scrollBar.SetParent(null); m_scrollBar.Close(); m_scrollBar = new OldScrollBar(this, new Vector2(252, 44), new Vector2(16, 99), ScrollBarColors.LightOnMed); m_scrollBar.SetParent(this); SmallItemStyleMaxItemDisplay = 6; }
/// <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, EOResourceID message = EOResourceID.DIALOG_TRANSFER_DROP) : base((PacketAPI)null) { _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 = ColorConstants.LightGrayDialogMessage, TextWidth = 200, Text = $"{OldWorld.GetString(EOResourceID.DIALOG_TRANSFER_HOW_MUCH)} {itemName} {OldWorld.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 = ColorConstants.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 = $"{m_totalAmount}"; } else if (m_amount.Text != "" && amt < 0) { amt = 1; m_amount.Text = $"{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); }