protected override void InitializeControlsHelper(IControlSet currentControlSet) { base.InitializeControlsHelper(currentControlSet); _loginPanelBackground = GetControl(currentControlSet, GameControlIdentifier.LoginPanelBackground, GetLoginPanelBackground); _tbUsername = GetControl(currentControlSet, GameControlIdentifier.LoginAccountName, GetLoginUserNameTextBox); _tbPassword = GetControl(currentControlSet, GameControlIdentifier.LoginPassword, GetLoginPasswordTextBox); _btnLogin = GetControl(currentControlSet, GameControlIdentifier.LoginButton, GetLoginAccountButton); _btnCancel = GetControl(currentControlSet, GameControlIdentifier.LoginCancel, GetLoginCancelButton); _allComponents.Add(_loginPanelBackground); _allComponents.Add(_tbUsername); _allComponents.Add(_tbPassword); _allComponents.Add(_btnLogin); _allComponents.Add(_btnCancel); _clickHandler = new TextBoxClickEventHandler(_dispatcher, _allComponents.OfType <IXNATextBox>().ToArray()); _tabHandler = new TextBoxTabEventHandler(_dispatcher, _allComponents.OfType <IXNATextBox>().ToArray()); if (_dispatcher.Subscriber != null) { _dispatcher.Subscriber.Selected = false; } _dispatcher.Subscriber = _tbUsername; _dispatcher.Subscriber.Selected = true; }
private IXNAButton CreateStateChangeButton(InGameStates whichState) { if (whichState == InGameStates.News) { throw new ArgumentOutOfRangeException(nameof(whichState), "News state does not have a button associated with it"); } var buttonIndex = (int)whichState; var mainButtonTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 25); var widthDelta = mainButtonTexture.Width / 2; var heightDelta = mainButtonTexture.Height / 11; var xPosition = buttonIndex < 6 ? 62 : 590; var yPosition = (buttonIndex < 6 ? 330 : 350) + (buttonIndex < 6 ? buttonIndex : buttonIndex - 6) * 20; var retButton = new XNAButton( mainButtonTexture, new Vector2(xPosition, yPosition), new Rectangle(0, heightDelta * buttonIndex, widthDelta, heightDelta), new Rectangle(widthDelta, heightDelta * buttonIndex, widthDelta, heightDelta)) { DrawOrder = HUD_CONTROL_LAYER }; retButton.OnClick += (o, e) => DoHudStateChangeClick(whichState); retButton.OnMouseEnter += (o, e) => _statusLabelSetter.SetStatusLabel( EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + buttonIndex); return(retButton); }
private void AddYesNoButtons() { XNAButton btnYes = new XNAClientButton(WindowManager); btnYes.FontIndex = 1; btnYes.ClientRectangle = new Rectangle(0, 0, 92, 23); btnYes.Name = "btnYes"; btnYes.Text = "Yes"; btnYes.LeftClick += BtnYes_LeftClick; btnYes.HotKey = Keys.Y; this.btnYes = btnYes; AddChild(btnYes); btnYes.ClientRectangle = new Rectangle((Width - ((btnYes.Width + 5) * 2)) / 2, Height - 28, btnYes.Width, btnYes.Height); XNAButton btnNo = new XNAClientButton(WindowManager); btnNo.FontIndex = 1; btnNo.ClientRectangle = new Rectangle(0, 0, 92, 23); btnNo.Name = "btnNo"; btnNo.Text = "No"; btnNo.LeftClick += BtnNo_LeftClick; btnNo.HotKey = Keys.N; this.btnNo = btnNo; AddChild(btnNo); btnNo.ClientRectangle = new Rectangle(btnYes.X + btnYes.Width + 10, Height - 28, btnNo.Width, btnNo.Height); }
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(); }
public override void Initialize() { Name = "LANGameCreationWindow"; BackgroundTexture = AssetLoader.LoadTexture("gamecreationoptionsbg.png"); ClientRectangle = new Rectangle(0, 0, 447, 77); lblDescription = new XNALabel(WindowManager); lblDescription.Name = "lblDescription"; lblDescription.FontIndex = 1; lblDescription.Text = "SELECT SESSION TYPE"; AddChild(lblDescription); lblDescription.CenterOnParent(); lblDescription.ClientRectangle = new Rectangle( lblDescription.X, 12, lblDescription.Width, lblDescription.Height); btnNewGame = new XNAButton(WindowManager); btnNewGame.Name = "btnNewGame"; btnNewGame.ClientRectangle = new Rectangle(12, 42, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT); btnNewGame.IdleTexture = AssetLoader.LoadTexture("133pxbtn.png"); btnNewGame.HoverTexture = AssetLoader.LoadTexture("133pxbtn_c.png"); btnNewGame.FontIndex = 1; btnNewGame.Text = "New Game"; btnNewGame.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnNewGame.LeftClick += BtnNewGame_LeftClick; btnLoadGame = new XNAButton(WindowManager); btnLoadGame.Name = "btnLoadGame"; btnLoadGame.ClientRectangle = new Rectangle(btnNewGame.Right + 12, btnNewGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT); btnLoadGame.IdleTexture = btnNewGame.IdleTexture; btnLoadGame.HoverTexture = btnNewGame.HoverTexture; btnLoadGame.FontIndex = 1; btnLoadGame.Text = "Load Game"; btnLoadGame.HoverSoundEffect = btnNewGame.HoverSoundEffect; btnLoadGame.LeftClick += BtnLoadGame_LeftClick; btnCancel = new XNAButton(WindowManager); btnCancel.Name = "btnCancel"; btnCancel.ClientRectangle = new Rectangle(btnLoadGame.Right + 12, btnNewGame.Y, 133, 23); btnCancel.IdleTexture = btnNewGame.IdleTexture; btnCancel.HoverTexture = btnNewGame.HoverTexture; btnCancel.FontIndex = 1; btnCancel.Text = "Cancel"; btnCancel.HoverSoundEffect = btnNewGame.HoverSoundEffect; btnCancel.LeftClick += BtnCancel_LeftClick; AddChild(btnNewGame); AddChild(btnLoadGame); AddChild(btnCancel); base.Initialize(); CenterOnParent(); }
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); }
//top left - 334, 36 + ndx*124 protected CharacterInfoPanel(int characterIndex, INativeGraphicsManager gfxManager, IEODialogButtonService dialogButtonService) { _gfxManager = gfxManager; DrawPosition = new Vector2(334, 36 + characterIndex * 124); _loginButton = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(161, 57), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Login), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Login)); _loginButton.OnClick += async(o, e) => await LoginButtonClick(); _loginButton.SetParentControl(this); _deleteButton = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(161, 85), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Delete), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Delete)); _deleteButton.OnClick += async(o, e) => await DeleteButtonClick(); _deleteButton.SetParentControl(this); _backgroundImage = _gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 11); }
public ScrollingMessageDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IEODialogButtonService eoDialogButtonService) : base(gameStateProvider) { _font = Game.Content.Load <SpriteFont>(Constants.FontSize08); _textSplitter = new TextSplitter("", _font) { LineLength = 275 }; BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 40); var smallButtonSheet = eoDialogButtonService.SmallButtonSheet; _ok = new XNAButton(smallButtonSheet, new Vector2(138, 197), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); _scrollBar = new ScrollBar(new Vector2(320, 66), new Vector2(16, 119), ScrollBarColors.LightOnMed, nativeGraphicsManager); _scrollBar.SetParentControl(this); MessageText = ""; CenterInGameView(); }
public void Initialize() { this.bg = JavaLib.createImage("XNAMenu//trialover_sims3"); this.tm = this.ae.getTextManager(); this.btnStore = new XNAButton(340, 180, 170, 70, XNAButton.Type.UNLOCKFULL_STORE); this.btnMenu = new XNAButton(340, 250, 170, 60, XNAButton.Type.UNLOCKFULL_BACK); }
private XNAButton GetLoginCancelButton() { var button = new XNAButton(_smallButtonSheet, new Vector2(453, 389), new Rectangle(0, 29, 91, 29), new Rectangle(91, 29, 91, 29)) { DrawOrder = _personPicture.DrawOrder + 2 }; button.OnClick += (o, e) => _mainButtonController.GoToInitialState(); return(button); }
private XNAButton GetLoginAccountButton() { var button = new XNAButton(_smallButtonSheet, new Vector2(361, 389), new Rectangle(0, 0, 91, 29), new Rectangle(91, 0, 91, 29)) { DrawOrder = _personPicture.DrawOrder + 2 }; button.OnClick += DoLogin; return(button); }
private IXNAButton GetPasswordButton() { var button = new XNAButton(_secondaryButtonTexture, new Vector2(454, 417), new Rectangle(0, 120, 120, 40), new Rectangle(120, 120, 120, 40)); button.OnClick += DoChangePassword; return(button); }
private IXNAButton GetCreateAccountCancelButton() { var button = new XNAButton(_secondaryButtonTexture, new Vector2(481, 417), new Rectangle(0, 40, 120, 40), new Rectangle(120, 40, 120, 40)); button.OnClick += (o, e) => _mainButtonController.GoToInitialState(); return(button); }
protected virtual IXNAButton GetCreateButton() { var isCreateCharacterButton = GameState == GameStates.LoggedIn; var button = new XNAButton(_secondaryButtonTexture, new Vector2(isCreateCharacterButton ? 334 : 359, 417), new Rectangle(0, 0, 120, 40), new Rectangle(120, 0, 120, 40)); return(button); }
public ChangePasswordDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IContentManagerProvider contentManagerProvider, IEOMessageBoxFactory eoMessageBoxFactory, IKeyboardDispatcherProvider keyboardDispatcherProvider, IPlayerInfoProvider playerInfoProvider, IEODialogButtonService dialogButtonService) : base(gameStateProvider) { _eoMessageBoxFactory = eoMessageBoxFactory; _playerInfoProvider = playerInfoProvider; var dispatcher = keyboardDispatcherProvider.Dispatcher; BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 21); var cursorTexture = contentManagerProvider.Content.Load <Texture2D>("Cursor"); _inputBoxes = new IXNATextBox[4]; for (int i = 0; i < _inputBoxes.Length; ++i) { var tb = new XNATextBox(new Rectangle(198, 60 + i * 30, 137, 19), Constants.FontSize08, caretTexture: cursorTexture) { LeftPadding = 5, DefaultText = " ", MaxChars = i == 0 ? 16 : 12, PasswordBox = i > 1, TextColor = ColorConstants.LightBeigeText }; _inputBoxes[i] = tb; } _clickEventHandler = new TextBoxClickEventHandler(dispatcher, _inputBoxes); _tabEventHandler = new TextBoxTabEventHandler(dispatcher, _inputBoxes); dispatcher.Subscriber = _inputBoxes[0]; _ok = new XNAButton( dialogButtonService.SmallButtonSheet, new Vector2(157, 195), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); _ok.OnClick += OnButtonPressed; _cancel = new XNAButton( dialogButtonService.SmallButtonSheet, new Vector2(250, 195), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); CenterInGameView(); }
public ScrollBar(Vector2 locationRelativeToParent, Vector2 size, ScrollBarColors palette, INativeGraphicsManager nativeGraphicsManager) { scrollArea = new Rectangle(0, 15, 0, (int)size.Y - 15); DrawPosition = locationRelativeToParent; SetSize((int)size.X, (int)size.Y); ScrollOffset = 0; var scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29); var upArrows = new Rectangle[2]; var 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); var scrollBox = new Rectangle(0, vertOff, 16, 15); _upButton = new XNAButton(scrollSpriteSheet, Vector2.Zero, upArrows[0], upArrows[1]); _upButton.OnClick += arrowClicked; _upButton.SetParentControl(this); _downButton = new XNAButton(scrollSpriteSheet, new Vector2(0, size.Y - 15), downArrows[0], downArrows[1]); _downButton.OnClick += arrowClicked; _downButton.SetParentControl(this); _scrollButton = new XNAButton(scrollSpriteSheet, new Vector2(0, 15), scrollBox, scrollBox); _scrollButton.OnClickDrag += OnScrollButtonDragged; _scrollButton.OnMouseEnter += (o, e) => { SuppressParentClickDragEvent(true); }; _scrollButton.OnMouseLeave += (o, e) => { SuppressParentClickDragEvent(false); }; _scrollButton.SetParentControl(this); _totalHeight = DrawAreaWithParentOffset.Height; }
private XNAButton GetBackButton() { var button = new XNAButton( _backButtonTexture, new Vector2(589, 0), new Rectangle(0, 0, _backButtonTexture.Width, _backButtonTexture.Height / 2), new Rectangle(0, _backButtonTexture.Height / 2, _backButtonTexture.Width, _backButtonTexture.Height / 2)) { DrawOrder = 100, ClickArea = new Rectangle(4, 16, 16, 16) }; button.OnClick += DoBackButtonClick; return(button); }
public virtual void init() { this.FRAME_WIDTH = this.res.Frame.getWidth(); this.FRAME_HEIGHT = this.res.Frame.getHeight(); this.FRAME_X = this.ae.getWidth() - this.FRAME_WIDTH >> 1; this.FRAME_Y = this.ae.getHeight() - this.FRAME_HEIGHT >> 1; this.HEADER_TXT_X = this.FRAME_X + (this.FRAME_WIDTH >> 1); this.HEADER_TXT_Y = this.FRAME_Y + 37; this.LEADERBOARD_HEADER_X = this.FRAME_X + 57; this.LEADERBOARD_HEADER_Y = this.FRAME_Y + 56; if (this is LeaderboardsMenu) { this.LEADERBOARD_HEADER_WIDTH = this.res.LeaderboardHeader.getWidth(); this.LEADERBOARD_HEADER_HEIGHT = this.res.LeaderboardHeader.getHeight(); } this.TEXT_AREA_X = this.FRAME_X + 57; this.TEXT_AREA_Y = this.LEADERBOARD_HEADER_Y + this.LEADERBOARD_HEADER_HEIGHT; if (this is LeaderboardsMenu) { this.TEXT_AREA_WIDTH = this.res.ScrollFieldSM.getWidth(); this.TEXT_AREA_HEIGHT = this.res.ScrollFieldSM.getHeight(); } else { this.TEXT_AREA_WIDTH = this.res.ScrollFieldLG.getWidth(); this.TEXT_AREA_HEIGHT = this.res.ScrollFieldLG.getHeight(); } this.textAreaRect = new Rectangle(this.TEXT_AREA_X, this.TEXT_AREA_Y, this.TEXT_AREA_WIDTH, this.TEXT_AREA_HEIGHT); if (this is LeaderboardsMenu) { this.SCROLLBAR_Y = this.TEXT_AREA_Y + 6; this.SCROLLBAR_HEIGHT = 93; } else { this.SCROLLBAR_Y = this.TEXT_AREA_Y + 9; this.SCROLLBAR_HEIGHT = 142; } this.SCROLLBAR_X = this.TEXT_AREA_X + 282; this.SCROLLBAR_WIDTH = 7; this.BTN_BACK_X = this.FRAME_X + 6; this.BTN_BACK_Y = this.FRAME_Y + 6; this.BTN_BACK_WIDTH = 38; this.BTN_BACK_HEIGHT = 38; this.tm = this.ae.getTextManager(); this.btnBack = new XNAButton(this.BTN_BACK_X, this.BTN_BACK_Y, this.BTN_BACK_WIDTH, this.BTN_BACK_HEIGHT, XNAButton.Type.BACK_BTN); }
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(); }
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); }
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 void AddOKButton() { XNAButton btnOK = new XNAButton(WindowManager); btnOK.FontIndex = 1; btnOK.ClientRectangle = new Rectangle(0, 0, 75, 23); btnOK.IdleTexture = AssetLoader.LoadTexture("75pxbtn.png"); btnOK.HoverTexture = AssetLoader.LoadTexture("75pxbtn_c.png"); btnOK.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnOK.Name = "btnOK"; btnOK.Text = "OK"; btnOK.LeftClick += BtnOK_LeftClick; btnOK.HotKey = Keys.Enter; AddChild(btnOK); btnOK.CenterOnParent(); btnOK.ClientRectangle = new Rectangle(btnOK.X, Height - 28, btnOK.Width, btnOK.Height); }
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; }
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)); }
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); }
private KeyLayout m_keyboard = KeyLayout.English; //this is not stored or loaded //parent x,y - 102,330 public OldEOSettingsPanel(XNAPanel parent) : base(null, null, parent) { _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height); w = OldWorld.Instance; m_leftSide = new XNALabel[5]; m_rightSide = new XNALabel[5]; for (int i = 0; i < m_leftSide.Length; ++i) { m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18 * i), 100, 15), Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText }; m_leftSide[i].SetParent(this); m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18 * i), 100, 15), Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText }; m_rightSide[i].SetParent(this); } _setTextForLanguage(); m_buttons = new XNAButton[10]; for (int i = 0; i < m_buttons.Length; ++i) { m_buttons[i] = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(i < 5 ? 215 : 454, 25 + (18 * (i % 5))), new Rectangle(0, 0, 19, 15), new Rectangle(19, 0, 19, 15)); m_buttons[i].SetParent(this); m_buttons[i].OnClick += _settingChange; m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE); } }
private KeyLayout m_keyboard = KeyLayout.English; //this is not stored or loaded //parent x,y - 102,330 public EOSettingsPanel(XNAPanel parent) : base(null, null, parent) { _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height); w = World.Instance; m_leftSide = new XNALabel[5]; m_rightSide = new XNALabel[5]; for (int i = 0; i < m_leftSide.Length; ++i) { m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18 * i), 100, 15), "Microsoft Sans Serif", 8.5f) { ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8) }; m_leftSide[i].SetParent(this); m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18 * i), 100, 15), "Microsoft Sans Serif", 8.5f) { ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8) }; m_rightSide[i].SetParent(this); } _setTextForLanguage(); m_buttons = new XNAButton[10]; for (int i = 0; i < m_buttons.Length; ++i) { m_buttons[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(i < 5 ? 215 : 454, 25 + (18 * (i % 5))), new Rectangle(0, 0, 19, 15), new Rectangle(19, 0, 19, 15)); m_buttons[i].SetParent(this); m_buttons[i].OnClick += _settingChange; m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE); } }
//parent x,y - 102,330 public EOSettingsPanel(XNAPanel parent) : base(null, null, parent) { _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height); w = World.Instance; m_leftSide = new XNALabel[5]; m_rightSide = new XNALabel[5]; for (int i = 0; i < m_leftSide.Length; ++i) { m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f) { ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8) }; m_leftSide[i].SetParent(this); m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f) { ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8) }; m_rightSide[i].SetParent(this); } _setTextForLanguage(); m_buttons = new XNAButton[10]; for (int i = 0; i < m_buttons.Length; ++i) { m_buttons[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(i < 5 ? 215 : 454, 25 + (18*(i%5))), new Rectangle(0, 0, 19, 15), new Rectangle(19, 0, 19, 15)); m_buttons[i].SetParent(this); m_buttons[i].OnClick += _settingChange; m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE); } }
private void AddOKCancelButtons() { XNAButton btnOK = new XNAButton(WindowManager); btnOK.FontIndex = 1; btnOK.ClientRectangle = new Rectangle(0, 0, 75, 23); btnOK.IdleTexture = AssetLoader.LoadTexture("75pxbtn.png"); btnOK.HoverTexture = AssetLoader.LoadTexture("75pxbtn_c.png"); btnOK.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnOK.Name = "btnOK"; btnOK.Text = "OK"; btnOK.LeftClick += BtnYes_LeftClick; btnOK.HotKey = Keys.Enter; AddChild(btnOK); btnOK.ClientRectangle = new Rectangle((Width - ((btnOK.Width + 5) * 2)) / 2, Height - 28, btnOK.Width, btnOK.Height); XNAButton btnCancel = new XNAButton(WindowManager); btnCancel.FontIndex = 1; btnCancel.ClientRectangle = new Rectangle(0, 0, 75, 23); btnCancel.IdleTexture = AssetLoader.LoadTexture("75pxbtn.png"); btnCancel.HoverTexture = AssetLoader.LoadTexture("75pxbtn_c.png"); btnCancel.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnCancel.Name = "btnCancel"; btnCancel.Text = "Cancel"; btnCancel.LeftClick += BtnCancel_LeftClick; btnCancel.HotKey = Keys.C; AddChild(btnCancel); btnCancel.ClientRectangle = new Rectangle(btnOK.X + btnOK.Width + 10, Height - 28, btnCancel.Width, btnCancel.Height); }
private void AddYesNoButtons() { XNAButton btnYes = new XNAButton(WindowManager); btnYes.FontIndex = 1; btnYes.ClientRectangle = new Rectangle(0, 0, 75, 23); btnYes.IdleTexture = AssetLoader.LoadTexture("75pxbtn.png"); btnYes.HoverTexture = AssetLoader.LoadTexture("75pxbtn_c.png"); btnYes.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnYes.Name = "btnYes"; btnYes.Text = "Yes"; btnYes.LeftClick += BtnYes_LeftClick; btnYes.HotKey = Keys.Y; AddChild(btnYes); btnYes.ClientRectangle = new Rectangle((Width - ((btnYes.Width + 5) * 2)) / 2, Height - 28, btnYes.Width, btnYes.Height); XNAButton btnNo = new XNAButton(WindowManager); btnNo.FontIndex = 1; btnNo.ClientRectangle = new Rectangle(0, 0, 75, 23); btnNo.IdleTexture = AssetLoader.LoadTexture("75pxbtn.png"); btnNo.HoverTexture = AssetLoader.LoadTexture("75pxbtn_c.png"); btnNo.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnNo.Name = "btnNo"; btnNo.Text = "No"; btnNo.LeftClick += BtnNo_LeftClick; btnNo.HotKey = Keys.N; AddChild(btnNo); btnNo.ClientRectangle = new Rectangle(btnYes.X + btnYes.Width + 10, Height - 28, btnNo.Width, btnNo.Height); }
public override void Initialize() { base.Initialize(); //position for these: x=50, y = 8,26,44,... for (int i = 0; i < m_basicStats.Length; ++i) { m_basicStats[i] = new XNALabel(new Rectangle(50, 8 + i*18, 73, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false }; m_basicStats[i].SetParent(this); m_arrows[i] = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(106, 7 + i*18), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15)) { Visible = false, //for testing - this should only be visible when statpoints > 0 FlashSpeed = 500 }; m_arrows[i].SetParent(this); World.IgnoreDialogs(m_arrows[i]); m_arrows[i].OnClick += (s, e) => { if (!m_training) { //apparently this is NOT stored in the edf files... //NOTE: copy-pasted to ActiveSpells spell train button event handler. Should probably be in some shared function somewhere. EOMessageBox dlg = new EOMessageBox("Do you want to train?", "Character training", XNADialogButtons.OkCancel, EOMessageBoxStyle.SmallDialogSmallHeader); dlg.DialogClosing += (sender, args) => { if (args.Result != XNADialogResult.OK) return; m_training = true; }; } else { short index = (short)(m_arrows.ToList().FindIndex(_btn => _btn == s) + 1); //1-based index (server-side) if(!((EOGame)Game).API.LevelUpStat(index)) EOGame.Instance.DoShowLostConnectionDialogAndReturnToMainMenu(); } }; } //x=158, y = 8, 26, 44, ... for (int i = 0; i < m_characterStats.Length; ++i) { m_characterStats[i] = new XNALabel(new Rectangle(158, 8 + i * 18, 73, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false }; m_characterStats[i].SetParent(this); } for (int i = 0; i < m_otherInfo.Length; ++i) { m_otherInfo[i] = new XNALabel(new Rectangle(i < 4 ? 280 : 379 , 44 + (i%4)*18, i < 4 ? 60 : 94, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false }; m_otherInfo[i].SetParent(this); } //these labels have non-standard sizes so they're done individually //name= 280,8 144,13 m_charInfo[NAME] = new XNALabel(new Rectangle(280, 8, 144, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false, Text = c.Name }; //guild = 280,26 193,13 m_charInfo[GUILD] = new XNALabel(new Rectangle(280, 26, 193, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false, Text = c.GuildName }; //level = 453,8, 20,13 m_charInfo[LEVEL] = new XNALabel(new Rectangle(453, 8, 20, 13), Constants.FontSize08pt5) { Visible = true, ForeColor = Constants.LightGrayText, AutoSize = false }; foreach(XNALabel lbl in m_charInfo) lbl.SetParent(this); }
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); }
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); } }
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); }
public HUD(Game g, PacketAPI api) : base(g) { if(!api.Initialized) throw new ArgumentException("Need to initialize connection before the in-game stuff will work"); m_packetAPI = api; DrawOrder = 5; mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true); topLeft = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true); sidebar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true); topBar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true); filler = new Texture2D(g.GraphicsDevice, 1, 1); filler.SetData(new[] {Color.FromNonPremultiplied(8, 8, 8, 255)}); Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25); mainBtn = new XNAButton[NUM_BTN]; //set up panels Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44); pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height)) { BackgroundImage = invBG, Visible = false }; Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62); pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28); pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height)) { BackgroundImage = chatBG, Visible = false }; Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34); pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height)) { BackgroundImage = statsBG, Visible = false }; Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36); pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height)) { BackgroundImage = onlineBG, Visible = false }; Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42); pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height)) { BackgroundImage = partyBG, Visible = false }; Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47); pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height)) { BackgroundImage = settingsBG, Visible = false }; Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63); pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height)) { BackgroundImage = helpBG, Visible = false }; Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48); pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height)) {BackgroundImage = newsBG}; //for easy update of all panels via foreach List<XNAPanel> pnlCollection = new List<XNAPanel>(10) { pnlInventory, pnlActiveSpells, pnlPassiveSpells, pnlChat, pnlStats, pnlOnline, pnlParty, pnlSettings, pnlHelp, pnlNews }; //pnlCollection.Add(pnlMacro); //if this ever happens... pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl)); for (int i = 0; i < NUM_BTN; ++i) { Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height); Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height); Color[] _outBuf = new Color[_outRec.Width * _outRec.Height]; Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height]; mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length); _out.SetData(_outBuf); mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length); _ovr.SetData(_ovrBuf); //0-5: left side, starting at 59, 327 with increments of 20 //6-10: right side, starting at 587, 347 Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20)); mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc); World.IgnoreDialogs(mainBtn[i]); } //left button onclick events mainBtn[0].OnClick += (s,e) => _doStateChange(InGameStates.Inventory); mainBtn[1].OnClick += (s,e) => World.Instance.ActiveMapRenderer.ToggleMapView(); mainBtn[2].OnClick += (s,e) => _doStateChange(InGameStates.Active); mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive); mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat); mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats); //right button onclick events mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online); mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party); //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings); mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help); SpriteBatch = new SpriteBatch(g.GraphicsDevice); state = InGameStates.News; chatRenderer = new EOChatRenderer(); chatRenderer.SetParent(pnlChat); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1), ChatType.Note, ChatColor.Server); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2), ChatType.Note, ChatColor.Server); newsTab = new ChatTab(pnlNews); chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load<Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f) { Selected = true, Visible = true, MaxChars = 140 }; World.IgnoreDialogs(chatTextBox); chatTextBox.OnEnterPressed += _doTalk; chatTextBox.OnClicked += (s, e) => { //make sure clicking on the textarea selects it (this is an annoying problem in the original client) if (((EOGame)g).Dispatcher.Subscriber != null) ((XNATextBox) (g as EOGame).Dispatcher.Subscriber).Selected = false; (g as EOGame).Dispatcher.Subscriber = chatTextBox; chatTextBox.Selected = true; }; chatTextBox.OnTextChanged += (s, e) => { if (chatTextBox.Text.Length <= 0) { if (modeTextureLoaded && modeTexture != null) { modeTextureLoaded = false; modeTexture.Dispose(); modeTexture = null; currentChatMode = ChatMode.NoText; } return; } if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' && World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap) { chatTextBox.Text = ""; SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL); return; } switch (chatTextBox.Text[0]) { case '!': currentChatMode = ChatMode.Private; break; case '@': //should show global if admin, otherwise, public/normal chat if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) goto default; currentChatMode = ChatMode.Global; break; case '~': currentChatMode = ChatMode.Global; break; case '+': { if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) goto default; currentChatMode = ChatMode.Admin; } break; case '\'': currentChatMode = ChatMode.Group; break; case '&': { if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "") goto default; currentChatMode = ChatMode.Guild; } break; default: currentChatMode = ChatMode.Public; break; } }; ((EOGame)g).Dispatcher.Subscriber = chatTextBox; m_muteTimer = new Timer(s => { chatTextBox.IgnoreAllInput = false; currentChatMode = ChatMode.NoText; m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite); }, null, Timeout.Infinite, Timeout.Infinite); statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f); clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f); StatusBars[0] = new HudElementHP(); StatusBars[1] = new HudElementTP(); StatusBars[2] = new HudElementSP(); StatusBars[3] = new HudElementTNL(); m_whoIsOnline = new EOOnlineList(pnlOnline); m_party = new EOPartyPanel(pnlParty); m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(592, 312), new Rectangle(0, 260, 17, 15), new Rectangle(0, 276, 17, 15)) { Visible = true, Enabled = true }; m_friendList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false); m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST); m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(609, 312), new Rectangle(17, 260, 17, 15), new Rectangle(17, 276, 17, 15)) { Visible = true, Enabled = true }; m_ignoreList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true); m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST); m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(55, 0), new Rectangle(331, 30, 22, 14), new Rectangle(331, 30, 22, 14)); m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show(); m_questInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(77, 0), new Rectangle(353, 30, 22, 14), new Rectangle(353, 30, 22, 14)); //no need to make this a member variable //it does not have any resources to dispose and it is automatically disposed by the framework // ReSharper disable once UnusedVariable EOSettingsPanel settings = new EOSettingsPanel(pnlSettings); }
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 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 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(); }
/// <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 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)); }
public HUD(Game g, PacketAPI api) : base(g) { if (!api.Initialized) { throw new ArgumentException("Need to initialize connection before the in-game stuff will work"); } m_packetAPI = api; DrawOrder = 5; mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true); topLeft = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true); sidebar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true); topBar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true); filler = new Texture2D(g.GraphicsDevice, 1, 1); filler.SetData(new[] { Color.FromNonPremultiplied(8, 8, 8, 255) }); Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25); mainBtn = new XNAButton[NUM_BTN]; //set up panels Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44); pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height)) { BackgroundImage = invBG, Visible = false }; Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62); pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28); pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height)) { BackgroundImage = chatBG, Visible = false }; Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34); pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height)) { BackgroundImage = statsBG, Visible = false }; Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36); pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height)) { BackgroundImage = onlineBG, Visible = false }; Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42); pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height)) { BackgroundImage = partyBG, Visible = false }; Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47); pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height)) { BackgroundImage = settingsBG, Visible = false }; Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63); pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height)) { BackgroundImage = helpBG, Visible = false }; Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48); pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height)) { BackgroundImage = newsBG }; //for easy update of all panels via foreach List <XNAPanel> pnlCollection = new List <XNAPanel>(10) { pnlInventory, pnlActiveSpells, pnlPassiveSpells, pnlChat, pnlStats, pnlOnline, pnlParty, pnlSettings, pnlHelp, pnlNews }; //pnlCollection.Add(pnlMacro); //if this ever happens... pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl)); for (int i = 0; i < NUM_BTN; ++i) { Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height); Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height); Color[] _outBuf = new Color[_outRec.Width * _outRec.Height]; Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height]; mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length); _out.SetData(_outBuf); mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length); _ovr.SetData(_ovrBuf); //0-5: left side, starting at 59, 327 with increments of 20 //6-10: right side, starting at 587, 347 Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20)); mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc); World.IgnoreDialogs(mainBtn[i]); } //left button onclick events mainBtn[0].OnClick += (s, e) => _doStateChange(InGameStates.Inventory); mainBtn[1].OnClick += (s, e) => World.Instance.ActiveMapRenderer.ToggleMapView(); mainBtn[2].OnClick += (s, e) => _doStateChange(InGameStates.Active); mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive); mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat); mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats); //right button onclick events mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online); mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party); //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings); mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help); SpriteBatch = new SpriteBatch(g.GraphicsDevice); state = InGameStates.News; chatRenderer = new EOChatRenderer(); chatRenderer.SetParent(pnlChat); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1), ChatType.Note, ChatColor.Server); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2), ChatType.Note, ChatColor.Server); newsTab = new ChatTab(pnlNews); chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load <Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f) { Selected = true, Visible = true, MaxChars = 140 }; World.IgnoreDialogs(chatTextBox); chatTextBox.OnEnterPressed += _doTalk; chatTextBox.OnClicked += (s, e) => { //make sure clicking on the textarea selects it (this is an annoying problem in the original client) if (((EOGame)g).Dispatcher.Subscriber != null) { ((XNATextBox)(g as EOGame).Dispatcher.Subscriber).Selected = false; } (g as EOGame).Dispatcher.Subscriber = chatTextBox; chatTextBox.Selected = true; }; chatTextBox.OnTextChanged += (s, e) => { if (chatTextBox.Text.Length <= 0) { if (modeTextureLoaded && modeTexture != null) { modeTextureLoaded = false; modeTexture.Dispose(); modeTexture = null; currentChatMode = ChatMode.NoText; } return; } if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' && World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap) { chatTextBox.Text = ""; SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL); return; } switch (chatTextBox.Text[0]) { case '!': currentChatMode = ChatMode.Private; break; case '@': //should show global if admin, otherwise, public/normal chat if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) { goto default; } currentChatMode = ChatMode.Global; break; case '~': currentChatMode = ChatMode.Global; break; case '+': { if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) { goto default; } currentChatMode = ChatMode.Admin; } break; case '\'': currentChatMode = ChatMode.Group; break; case '&': { if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "") { goto default; } currentChatMode = ChatMode.Guild; } break; default: currentChatMode = ChatMode.Public; break; } }; ((EOGame)g).Dispatcher.Subscriber = chatTextBox; m_muteTimer = new Timer(s => { chatTextBox.IgnoreAllInput = false; currentChatMode = ChatMode.NoText; m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite); }, null, Timeout.Infinite, Timeout.Infinite); statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f); clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f); StatusBars[0] = new HudElementHP(); StatusBars[1] = new HudElementTP(); StatusBars[2] = new HudElementSP(); StatusBars[3] = new HudElementTNL(); m_whoIsOnline = new EOOnlineList(pnlOnline); m_party = new EOPartyPanel(pnlParty); m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(592, 312), new Rectangle(0, 260, 17, 15), new Rectangle(0, 276, 17, 15)) { Visible = true, Enabled = true }; m_friendList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false); m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST); m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(609, 312), new Rectangle(17, 260, 17, 15), new Rectangle(17, 276, 17, 15)) { Visible = true, Enabled = true }; m_ignoreList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true); m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST); m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(55, 0), new Rectangle(331, 30, 22, 14), new Rectangle(331, 30, 22, 14)); m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show(); m_questInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(77, 0), new Rectangle(353, 30, 22, 14), new Rectangle(353, 30, 22, 14)); //no need to make this a member variable //it does not have any resources to dispose and it is automatically disposed by the framework // ReSharper disable once UnusedVariable EOSettingsPanel settings = new EOSettingsPanel(pnlSettings); }
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(); }
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 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 void InitializeControls(bool reinit = false) { //set up text boxes for login _textBoxTextures[0] = Content.Load<Texture2D>("tbBack"); _textBoxTextures[1] = Content.Load<Texture2D>("tbLeft"); _textBoxTextures[2] = Content.Load<Texture2D>("tbRight"); _textBoxTextures[3] = Content.Load<Texture2D>("cursor"); _loginUsernameTextbox = new XNATextBox(new Rectangle(402, 322, 140, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08) { MaxChars = 16, DefaultText = "Username", LeftPadding = 4 }; _loginUsernameTextbox.OnTabPressed += OnTabPressed; _loginUsernameTextbox.OnClicked += OnTextClicked; _loginUsernameTextbox.OnEnterPressed += (s, e) => MainButtonPress(_loginButtons[0], e); Dispatcher.Subscriber = _loginUsernameTextbox; _loginPasswordTextbox = new XNATextBox(new Rectangle(402, 358, 140, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08) { MaxChars = 12, PasswordBox = true, LeftPadding = 4, DefaultText = "Password" }; _loginPasswordTextbox.OnTabPressed += OnTabPressed; _loginPasswordTextbox.OnClicked += OnTextClicked; _loginPasswordTextbox.OnEnterPressed += (s, e) => MainButtonPress(_loginButtons[0], e); //set up primary four login buttons Texture2D mainButtonSheet = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 13, true); for (int i = 0; i < _mainButtons.Length; ++i) { int widthFactor = mainButtonSheet.Width / 2; //2: mouseOut and mouseOver textures int heightFactor = mainButtonSheet.Height / _mainButtons.Length; //1 row per button Rectangle outSource = new Rectangle(0, i * heightFactor, widthFactor, heightFactor); Rectangle overSource = new Rectangle(widthFactor, i * heightFactor, widthFactor, heightFactor); _mainButtons[i] = new XNAButton(mainButtonSheet, new Vector2(26, 278 + i * 40), outSource, overSource); _mainButtons[i].OnClick += MainButtonPress; } //the button in the top-right for going back a screen Texture2D back = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 24, true); _backButton = new XNAButton(back, new Vector2(589, 0), new Rectangle(0, 0, back.Width, back.Height / 2), new Rectangle(0, back.Height / 2, back.Width, back.Height / 2)) { DrawOrder = 100 }; _backButton.OnClick += MainButtonPress; _backButton.ClickArea = new Rectangle(4, 16, 16, 16); //Login/Cancel buttons for logging in Texture2D smallButtonSheet = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true); _loginButtons[0] = new XNAButton(smallButtonSheet, new Vector2(361, 389), new Rectangle(0, 0, 91, 29), new Rectangle(91, 0, 91, 29)); _loginButtons[1] = new XNAButton(smallButtonSheet, new Vector2(453, 389), new Rectangle(0, 29, 91, 29), new Rectangle(91, 29, 91, 29)); _loginButtons[0].OnClick += MainButtonPress; _loginButtons[1].OnClick += MainButtonPress; //6 text boxes (by default) for creating a new account. for (int i = 0; i < _accountCreateTextBoxes.Length; ++i) { //holy f**k! magic numbers! //basically, set the first 3 Y coord to start at 69 and move up by 51 each time // set the second 3 Y coord to start at 260 and move up by 51 each time int txtYCoord = (i < 3 ? 69 : 260) + (i < 3 ? i * 51 : (i - 3) * 51); XNATextBox txt = new XNATextBox(new Rectangle(358, txtYCoord, 240, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08) { LeftPadding = 4 }; switch (i) { case 0: txt.MaxChars = 16; break; case 1: case 2: txt.PasswordBox = true; txt.MaxChars = 12; break; default: txt.MaxChars = 35; break; } txt.DefaultText = " "; txt.OnTabPressed += OnTabPressed; txt.OnClicked += OnTextClicked; _accountCreateTextBoxes[i] = txt; } //create account / cancel Texture2D secondaryButtons = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 14, true); _createButtons[0] = new XNAButton(secondaryButtons, new Vector2(359, 417), new Rectangle(0, 0, 120, 40), new Rectangle(120, 0, 120, 40)); _createButtons[1] = new XNAButton(secondaryButtons, new Vector2(481, 417), new Rectangle(0, 40, 120, 40), new Rectangle(120, 40, 120, 40)); _createButtons[0].OnClick += MainButtonPress; _createButtons[1].OnClick += MainButtonPress; _passwordChangeBtn = new XNAButton(secondaryButtons, new Vector2(454, 417), new Rectangle(0, 120, 120, 40), new Rectangle(120, 120, 120, 40)); _passwordChangeBtn.OnClick += MainButtonPress; _lblCredits = new XNALabel(new Rectangle(300, 260, 1, 1), Constants.FontSize10) { Text = @"Endless Online - C# Client Developed by Ethan Moffat Based on Endless Online -- Copyright Vult-R Thanks to : --Sausage for eoserv + C# EO libs --eoserv.net community --Hotdog for Eodev client" }; _lblVersionInfo = new XNALabel(new Rectangle(25, 453, 1, 1), Constants.FontSize07) { Text = string.Format("{0}.{1:000}.{2:000} - {3}:{4}", World.Instance.VersionMajor, World.Instance.VersionMinor, World.Instance.VersionClient, host, port), ForeColor = Constants.BeigeText }; //login/delete buttons for each character for (int i = 0; i < 3; ++i) { _loginCharButtons[i] = new XNAButton(smallButtonSheet, new Vector2(495, 93 + i * 124), new Rectangle(0, 58, 91, 29), new Rectangle(91, 58, 91, 29)); _loginCharButtons[i].OnClick += CharModButtonPress; _deleteCharButtons[i] = new XNAButton(smallButtonSheet, new Vector2(495, 121 + i * 124), new Rectangle(0, 87, 91, 29), new Rectangle(91, 87, 91, 29)); _deleteCharButtons[i].OnClick += CharModButtonPress; } //hide all the components to start with foreach (IGameComponent iGameComp in Components) { DrawableGameComponent component = iGameComp as DrawableGameComponent; //don't hide dialogs if reinitializing if (reinit && (XNAControl.Dialogs.Contains(component as XNAControl) || (component as XNAControl != null && XNAControl.Dialogs.Contains((component as XNAControl).TopParent)))) continue; //...except for the four main buttons if (component != null && !_mainButtons.Contains(component as XNAButton)) component.Visible = false; } _lblVersionInfo.Visible = true; #if DEBUG //testinggame will login as testuser and login as the first character XNAButton testingame = new XNAButton(new Vector2(5, 5), "in-game", Constants.FontSize10); testingame.OnClick += testInGame_click; testingame.Visible = ConfigurationManager.AppSettings["auto_login_user"] != null && ConfigurationManager.AppSettings["auto_login_pass"] != null; #endif }
public StatsPanel(INativeGraphicsManager nativeGraphicsManager, ICharacterProvider characterProvider, ICharacterInventoryProvider characterInventoryProvider, IExperienceTableProvider experienceTableProvider, IEOMessageBoxFactory messageBoxFactory, ITrainingController trainingController) { _characterProvider = characterProvider; _characterInventoryProvider = characterInventoryProvider; _experienceTableProvider = experienceTableProvider; _messageBoxFactory = messageBoxFactory; _trainingController = trainingController; BackgroundImage = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 34); DrawArea = new Rectangle(102, 330, BackgroundImage.Width, BackgroundImage.Height); _basicStats = new IXNALabel[6]; _arrowButtons = new IXNAButton[6]; _characterStats = new IXNALabel[6]; _characterInfo = new IXNALabel[3]; _otherInfo = new IXNALabel[8]; var buttonTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true); var outTextureArea = new Rectangle(215, 386, 19, 15); var overTextureArea = new Rectangle(234, 386, 19, 15); for (int i = 0; i < _basicStats.Length; ++i) { _basicStats[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(50, 8 + i * 18, 73, 13) }; _arrowButtons[i] = new XNAButton(buttonTexture, new Vector2(106, 7 + i * 18), outTextureArea, overTextureArea) { Visible = false, FlashSpeed = 500 }; } for (int i = 0; i < _characterStats.Length; ++i) { _characterStats[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(158, 8 + i * 18, 73, 13) }; } for (int i = 0; i < _otherInfo.Length; ++i) { var drawArea = i < 4 ? new Rectangle(280, 44 + i % 4 * 18, 60, 13) : new Rectangle(379, 44 + i % 4 * 18, 94, 13); _otherInfo[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = drawArea }; } _characterInfo[NAME] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(280, 8, 144, 13) }; _characterInfo[GUILD] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(280, 26, 193, 13) }; _characterInfo[LEVEL] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(453, 8, 20, 13) }; }
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); }
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); }
public HUD(Game g, PacketAPI api) : base(g) { if(!api.Initialized) throw new ArgumentException("Need to initialize connection before the in-game stuff will work"); m_packetAPI = api; DrawOrder = 100; mainFrame = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 1, true); topLeft = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 21, true); sidebar = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 22, true); topBar = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 23, true); filler = new Texture2D(g.GraphicsDevice, 1, 1); filler.SetData(new[] {Color.FromNonPremultiplied(8, 8, 8, 255)}); Texture2D mainButtonTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 25); mainBtn = new XNAButton[NUM_BTN]; CreatePanels(); CreateMainButtons(g, mainButtonTexture); SpriteBatch = new SpriteBatch(g.GraphicsDevice); state = InGameStates.News; chatRenderer = new EOChatRenderer(); chatRenderer.SetParent(pnlChat); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1), ChatType.Note, ChatColor.Server); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2), ChatType.Note, ChatColor.Server); newsTab = new ChatTab(pnlNews); CreateChatTextbox(); m_muteTimer = new Timer(s => { chatTextBox.ToggleTextInputIgnore(); currentChatMode = ChatMode.NoText; m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite); }, null, Timeout.Infinite, Timeout.Infinite); statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), Constants.FontSize07) { DrawOrder = HUD_CONTROL_DRAW_ORDER }; clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), Constants.FontSize07) { DrawOrder = HUD_CONTROL_DRAW_ORDER }; m_whoIsOnline = new EOOnlineList(pnlOnline); m_party = new EOPartyPanel(pnlParty); m_friendList = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(592, 312), new Rectangle(0, 260, 17, 15), new Rectangle(0, 276, 17, 15)) { Visible = true, Enabled = true, DrawOrder = HUD_CONTROL_DRAW_ORDER }; m_friendList.OnClick += (o, e) => FriendIgnoreListDialog.Show(isIgnoreList: false, apiHandle: m_packetAPI); m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST); m_ignoreList = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(609, 312), new Rectangle(17, 260, 17, 15), new Rectangle(17, 276, 17, 15)) { Visible = true, Enabled = true, DrawOrder = HUD_CONTROL_DRAW_ORDER }; m_ignoreList.OnClick += (o, e) => FriendIgnoreListDialog.Show(isIgnoreList: true, apiHandle: m_packetAPI); m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST); m_expInfo = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(55, 0), new Rectangle(331, 30, 22, 14), new Rectangle(331, 30, 22, 14)) {DrawOrder = HUD_CONTROL_DRAW_ORDER}; m_expInfo.OnClick += (o, e) => SessionExpDialog.Show(); m_questInfo = new XNAButton(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(77, 0), new Rectangle(353, 30, 22, 14), new Rectangle(353, 30, 22, 14)) {DrawOrder = HUD_CONTROL_DRAW_ORDER}; m_questInfo.OnClick += (o, e) => QuestProgressDialog.Show(m_packetAPI); //no need to make this a member variable //it does not have any resources to dispose and it is automatically disposed by the framework // ReSharper disable once UnusedVariable EOSettingsPanel settings = new EOSettingsPanel(pnlSettings); }
protected override void LoadContent() { // Load textures, map and sounds Tileset ts = new Tileset(); try { ts.LoadFromStream(typeof(Map).Assembly.GetManifestResourceStream("GameClassLibrary.game.tileset")); FXCollection.Textures = new List <Texture2D>(); for (int i = 0; i < ts.Images.Images.Count; i++) { using (MemoryStream ms = new MemoryStream()) { ts.Images.Images[i].Save(ms, System.Drawing.Imaging.ImageFormat.Png); FXCollection.Textures.Add(Texture2D.FromStream(GraphicsDevice, ms)); } } // Load sounds FXCollection.Songs = new List <LoopedSoundPlayer>(); FXCollection.SoundEffects = new List <SoundEffectInstance>(); FXCollection.Songs[Songs.PreGame = FXCollection.Load <SoundEffect>("Audio\\Music\\titleSong")].Overlap = new TimeSpan(0, 0, 0, 0, 1500); FXCollection.Songs[Songs.InGame = FXCollection.Load <SoundEffect>("Audio\\Music\\inGameBackground")].Overlap = new TimeSpan(0, 0, 0, 0, 2500); SoundEffects.Select = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\pop"); SoundEffects.Collect = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\boop"); SoundEffects.Blip = FXCollection.Load <SoundEffectInstance>("Audio\\SoundEffects\\blip"); } catch { throw new Exception("There was a problem loading a resource!"); } // Create audio zones for enemies for (int i = 1; i < World.Players.Count; i++) { Player e = World.Players[i]; if (e is Enemy) { // Temporary - just use the color red for enemies, rather than an actual texture Texture2D texture = new Texture2D(GraphicsDevice, 1, 1); texture.SetData(new[] { Color.Red }); FXCollection.Textures.Add(texture); World.Players[i].CurrentGraphicIndex = FXCollection.Textures.Count - 1; audioManager.AddZone(new EnemyAudioZone(e as Enemy, FXCollection.Load <SoundEffectInstance>("Audio\\Music\\tone"), 200)); } } World.LightsFX = new LightsFX( Content.Load <Effect>("Effects\\resolveShadowsEffect"), Content.Load <Effect>("Effects\\reductionEffect"), Content.Load <Effect>("Effects\\2xMultiBlend")); // Eventually, the lower four lines graphics will be pulled from the tileset World.MainPlayer.BackGraphicIndex = FXCollection.Load <Texture2D>("back_sprite"); World.MainPlayer.FrontGraphicIndex = FXCollection.Load <Texture2D>("front_sprite"); World.MainPlayer.LeftGraphicIndex = FXCollection.Load <Texture2D>("left_sprite"); World.MainPlayer.RightGraphicIndex = FXCollection.Load <Texture2D>("right_sprite"); World.MainPlayer.CurrentGraphicIndex = World.MainPlayer.FrontGraphicIndex; KeyboardDispatcher = new KeyboardDispatcher(Window); inGamePanel = new XNAComponentPanel(this); loginPanel = new XNAComponentPanel(this); registerPanel = new XNAComponentPanel(this); preGameMenuPanel = new XNAComponentPanel(this); howToPlayPanel = new XNAComponentPanel(this); backgroundPanel = new XNAComponentPanel(this); int screenWidth = GraphicsDevice.Viewport.Width; int screenHeight = GraphicsDevice.Viewport.Height; Texture2D[] textboxTextures = new Texture2D[4] { Content.Load <Texture2D>("textboxBack"), Content.Load <Texture2D>("textboxLeft"), Content.Load <Texture2D>("textboxRight"), Content.Load <Texture2D>("textboxCaret") }; // Background image with ripple effect background = new Background(this, Content.Load <Texture2D>("titleBackground")); RippleEffect rippleEffect = new RippleEffect(backgroundPanel); loginPanel.Components.Add(rippleEffect); registerPanel.Components.Add(rippleEffect); preGameMenuPanel.Components.Add(rippleEffect); howToPlayPanel.Components.Add(rippleEffect); PreGameMenu = new XNAMenu(this, new Rectangle(screenWidth / 2 - 150, screenHeight / 2 - 100, 300, 200)) { ForeColor = SD.Color.FromArgb(25, 50, 150), HighlightColor = SD.Color.FromArgb(4, 4, 99), Font = new SD.Font("Calibri", 36), RenderingHint = SD.Text.TextRenderingHint.SingleBitPerPixelGridFit, ItemHeight = 60 }; PreGameMenu.SelectionChanged += (o, e) => { FXCollection.SoundEffects[SoundEffects.Blip].Play(); }; PreGameMenu.AddMenuItem("Log In", (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.Login; }); PreGameMenu.AddMenuItem("Create Account", (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.Register; }); PreGameMenu.AddMenuItem("How to Play", (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.HowToPlay; }); PreGameMenu.AddMenuItem("Quit Game", (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); System.Threading.Tasks.Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(300); // Make sure the select sound plays Exit(); }); }); XNAPictureBox titlePicture = new XNAPictureBox(this, new Rectangle(100, screenHeight / 2 - 50, screenWidth - 200, 200)) { StretchMode = StretchMode.CenterInFrame, Texture = Content.Load <Texture2D>("logo") }; loginPanel.Components.Add(titlePicture); registerPanel.Components.Add(titlePicture); preGameMenuPanel.Components.Add(titlePicture); howToPlayPanel.Components.Add(titlePicture); //temporary action objects that are used to construct the member TextBoxEvent variables Action <object, EventArgs> loginEvent; Action <object, EventArgs> registerEvent; // Login event loginEvent = (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.LoggingIn; World.MainPlayer.SendToServer(ServerAction.ClientLogin, new LoginData(usernameTextbox.Text, passwordTextbox.Text)); }; loginTBEvent = new TextBoxEvent(loginEvent); // Register event registerEvent = (o, e) => { if (passwordTextbox.Text == confirmPasswordTextbox.Text) { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.Registering; World.MainPlayer.SendToServer(ServerAction.ClientCreateAcc, new LoginData(usernameTextbox.Text, passwordTextbox.Text)); } else { FXCollection.SoundEffects[SoundEffects.Select].Play(); XNADialog errDlg = new XNADialog(this, "Passwords do not match.", "Error creating account!"); errDlg.CloseAction = (param) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); }; } }; XNALabel howToPlayText = new XNALabel(this, new Rectangle(screenWidth / 4, screenHeight / 2 - 80, screenWidth / 2, 300)); howToPlayText.Text = Resources.HowToPlayText; howToPlayText.Font = new SD.Font("Calibri", 16); howToPlayPanel.Components.Add(howToPlayText); XNAHyperLink backHyperlink = new XNAHyperLink( this, new Rectangle(3 * screenWidth / 4 - 50, screenHeight / 2 + 75, 50, 30), "Arial", 12.0f, SD.FontStyle.Bold, SD.Text.TextRenderingHint.SingleBitPerPixelGridFit); backHyperlink.DrawOrder = (int)RenderOrder.UILayer; backHyperlink.ForeColor = SD.Color.FromArgb(139, 95, 71); backHyperlink.HighlightColor = SD.Color.FromArgb(150, 139, 95, 71); backHyperlink.Text = "Back"; backHyperlink.TextAlign = System.Drawing.ContentAlignment.MiddleRight; backHyperlink.OnClick += (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.PregameMenu; }; howToPlayPanel.Components.Add(backHyperlink); registerTBEvent = new TextBoxEvent(registerEvent); subscribeToUsernameBox = (object sender, EventArgs e) => { usernameTextbox.Selected = true; KeyboardDispatcher.Subscriber = usernameTextbox; }; subscribeToPasswordBox = (object sender, EventArgs e) => { passwordTextbox.Selected = true; KeyboardDispatcher.Subscriber = passwordTextbox; }; subscribeToConfirmBox = (object sender, EventArgs e) => { confirmPasswordTextbox.Selected = true; KeyboardDispatcher.Subscriber = confirmPasswordTextbox; }; // Update error message event World.MainPlayer.UpdateErrorMessage += (o, e) => { //close any open dialog XNADialog errMsg = new XNADialog(this, e.Message, e.Caption); if (!(o as ConnectedPlayer).Connected) { errMsg.CloseAction += (bool success) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); this.Exit(); } } ; }; World.MainPlayer.BacteriaCollect += (o, e) => { FXCollection.SoundEffects[SoundEffects.Collect].Play(); overlayRenderer.RenderBacteriaCount(); }; // Username field usernameTextbox = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 - 70, 200, 30), textboxTextures, "Arial", 12.0f); usernameTextbox.DrawOrder = (int)RenderOrder.UILayer; usernameTextbox.MaxChars = 30; usernameTextbox.DefaultText = "Username"; usernameTextbox.Clicked += subscribeToUsernameBox; subscribeToUsernameBox(usernameTextbox); usernameTextbox.OnTabPressed += subscribeToPasswordBox; loginPanel.Components.Add(usernameTextbox); registerPanel.Components.Add(usernameTextbox); // Password field passwordTextbox = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 - 20, 200, 30), textboxTextures, "Arial", 12.0f); passwordTextbox.DrawOrder = (int)RenderOrder.UILayer; passwordTextbox.MaxChars = 30; passwordTextbox.DefaultText = "Password"; passwordTextbox.PasswordBox = true; passwordTextbox.Clicked += subscribeToPasswordBox; loginPanel.Components.Add(passwordTextbox); registerPanel.Components.Add(passwordTextbox); // Confirm password field confirmPasswordTextbox = new XNATextBox(this, new Rectangle(screenWidth / 2 - 100, screenHeight / 2 + 30, 200, 30), textboxTextures, "Arial", 12.0f); confirmPasswordTextbox.DrawOrder = (int)RenderOrder.UILayer; confirmPasswordTextbox.MaxChars = 30; confirmPasswordTextbox.DefaultText = "Confirm Password"; confirmPasswordTextbox.PasswordBox = true; confirmPasswordTextbox.Clicked += subscribeToConfirmBox; confirmPasswordTextbox.OnTabPressed += subscribeToUsernameBox; confirmPasswordTextbox.OnEnterPressed += new TextBoxEvent(registerEvent); registerPanel.Components.Add(confirmPasswordTextbox); Texture2D[] loginButtonTextures = new Texture2D[2] { Content.Load <Texture2D>("button"), Content.Load <Texture2D>("buttonHover") }; XNAButton loginButton = new XNAButton(this, new Vector2(screenWidth / 2 + 20, screenHeight / 2 + 30), "Login"); loginButton.DrawOrder = (int)RenderOrder.UILayer; loginButton.OnClick += new XNAButton.ButtonClickEvent(loginEvent); loginPanel.Components.Add(loginButton); XNAButton registerButton = new XNAButton(this, new Vector2(screenWidth / 2 + 20, screenHeight / 2 + 80), "Register"); registerButton.DrawOrder = (int)RenderOrder.UILayer; registerButton.OnClick += new XNAButton.ButtonClickEvent(registerEvent); registerPanel.Components.Add(registerButton); cancelHyperlink = new XNAHyperLink( this, new Rectangle(screenWidth / 2 - 95, screenHeight / 2 + 80, 100, 30), "Arial", 12.0f, SD.FontStyle.Bold, SD.Text.TextRenderingHint.SingleBitPerPixelGridFit); cancelHyperlink.DrawOrder = (int)RenderOrder.UILayer; cancelHyperlink.ForeColor = SD.Color.FromArgb(139, 95, 71); cancelHyperlink.HighlightColor = SD.Color.FromArgb(150, 139, 95, 71); cancelHyperlink.Text = "Cancel"; cancelHyperlink.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; cancelHyperlink.OnClick += (o, e) => { FXCollection.SoundEffects[SoundEffects.Select].Play(); World.GameState = GameState.PregameMenu; }; registerPanel.Components.Add(cancelHyperlink); loginPanel.Components.Add(cancelHyperlink); // Map renderer MapRenderer mapRenderer = new MapRenderer(this, World.CurrentMap); inGamePanel.Components.Add(mapRenderer); // NPC rendering engine GraphicEngine npcEngine = new GraphicEngine(this, RenderOrder.NPCLayer); GraphicsEngineComponent.CreateAndAdd <MinorPlayerRenderer>(npcEngine); inGamePanel.Components.Add(npcEngine); // Overlay rendering engine GraphicEngine overlayEngine = new GraphicEngine(this, RenderOrder.OverlayLayer); overlayRenderer = GraphicsEngineComponent.CreateAndAdd <OverlayRenderer>(overlayEngine); inGamePanel.Components.Add(overlayEngine); // Audio manager inGamePanel.Components.Add(audioManager = new AudioManager(this)); // Input handler InputHandler = new InputHandler(this); inGamePanel.Components.Add(InputHandler); InputHandler.ChatBoxClosing += (o, e) => { if (ShowChatPrompt && chatRenderer.MessageBox.Text != "") { World.MainPlayer.SendToServer(ServerAction.ClientSay, new TalkData(chatRenderer.MessageBox.Text)); chatRenderer.MessageBox.Text = ""; } }; InputHandler.RemoveTilde += () => { chatRenderer.MessageBox.Text = chatRenderer.MessageBox.Text.TrimEnd('`'); }; // Main Player inGamePanel.Components.Add(MainPlayer = new PlayerComponent(this, World.MainPlayer)); // Pause menu GraphicEngine pauseMenuEngine = new GraphicEngine(this, RenderOrder.PauseMenuLayer); GraphicsEngineComponent.CreateAndAdd <PauseMenuRenderer>(pauseMenuEngine); inGamePanel.Components.Add(pauseMenuEngine); // Chat GraphicEngine chatEngine = new GraphicEngine(this, RenderOrder.ChatLayer); chatRenderer = GraphicsEngineComponent.CreateAndAdd <ChatRenderer>(chatEngine); inGamePanel.Components.Add(chatEngine); World.GameState = GameState.PregameMenu; }
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); }
public EOMessageBox(INativeGraphicsManager graphicsManager, IGameStateProvider gameStateProvider, IEODialogButtonService eoDialogButtonService, string message, string caption = "", EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogSmallHeader, EODialogButtons whichButtons = EODialogButtons.Ok) : base(gameStateProvider) { var useSmallHeader = style != EOMessageBoxStyle.SmallDialogLargeHeader; int graphic; switch (style) { case EOMessageBoxStyle.SmallDialogLargeHeader: graphic = 18; break; case EOMessageBoxStyle.SmallDialogSmallHeader: graphic = 23; break; case EOMessageBoxStyle.LargeDialogSmallHeader: graphic = 25; break; default: throw new ArgumentOutOfRangeException(nameof(style), "Unrecognized dialog style!"); } BackgroundTexture = graphicsManager.TextureFromResource(GFXTypes.PreLoginUI, graphic); _messageLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = message, TextWidth = 254, DrawPosition = new Vector2(18, useSmallHeader ? 40 : 57) }; _messageLabel.SetParentControl(this); _captionLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = caption, TextWidth = 254, DrawPosition = useSmallHeader ? new Vector2(18, 12) : new Vector2(59, 23) }; _captionLabel.SetParentControl(this); var smallButtonSheet = eoDialogButtonService.SmallButtonSheet; var okOut = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok); var okOver = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok); var cancelOut = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel); var cancelOver = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel); switch (whichButtons) { case EODialogButtons.Ok: _ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), okOut, okOver); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); break; case EODialogButtons.Cancel: _cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver); _cancel.OnClick += (sender, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); break; case EODialogButtons.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), okOut, okOver); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); _cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver); _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); break; } if (useSmallHeader) { if (_ok != null) { _ok.DrawPosition = new Vector2(_ok.DrawPosition.X, style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148); } if (_cancel != null) { _cancel.DrawPosition = new Vector2(_cancel.DrawPosition.X, style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148); } } CenterInGameView(); }
private void CreateMainButtons(Game g, Texture2D mainButtonTexture) { for (int i = 0; i < NUM_BTN; ++i) { Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height); Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height); Color[] _outBuf = new Color[_outRec.Width * _outRec.Height]; Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height]; mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length); _out.SetData(_outBuf); mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length); _ovr.SetData(_ovrBuf); //0-5: left side, starting at 59, 327 with increments of 20 //6-10: right side, starting at 587, 347 Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20)); mainBtn[i] = new XNAButton(new[] { _out, _ovr }, btnLoc) { DrawOrder = HUD_CONTROL_DRAW_ORDER }; World.IgnoreDialogs(mainBtn[i]); } //left button onclick events mainBtn[0].OnClick += (s, e) => _doStateChange(InGameStates.Inventory); mainBtn[1].OnClick += (s, e) => World.Instance.ActiveMapRenderer.ToggleMapView(); mainBtn[2].OnClick += (s, e) => _doStateChange(InGameStates.Active); mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive); mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat); mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats); //right button onclick events mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online); mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party); //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings); mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help); }