diff --git a/EOLib/Domain/Character/AttackValidationActions.cs b/EOLib/Domain/Character/AttackValidationActions.cs index 0c25b6fd1..cd7b56354 100644 --- a/EOLib/Domain/Character/AttackValidationActions.cs +++ b/EOLib/Domain/Character/AttackValidationActions.cs @@ -3,6 +3,8 @@ using EOLib.Domain.Extensions; using EOLib.Domain.Map; using EOLib.IO.Repositories; +using Optional; +using Optional.Collections; namespace EOLib.Domain.Character { @@ -39,12 +41,13 @@ public AttackValidationError ValidateCharacterStateBeforeAttacking() var rp = _characterProvider.MainCharacter.RenderProperties; - var isRangedWeapon = _eifFileProvider.EIFFile - .Where(x => x.Type == IO.ItemType.Weapon && x.SubType == IO.ItemSubType.Ranged) - .Any(x => x.DollGraphic == rp.WeaponGraphic); - var isArrows = _eifFileProvider.EIFFile - .Where(x => x.Type == IO.ItemType.Shield && x.SubType == IO.ItemSubType.Arrows) - .Any(x => x.DollGraphic == rp.ShieldGraphic); + var matchingWeapon = _eifFileProvider.EIFFile + .SingleOrNone(x => x.DollGraphic == rp.WeaponGraphic && x.Type == IO.ItemType.Weapon); + var matchingArrows = _eifFileProvider.EIFFile + .SingleOrNone(x => x.DollGraphic == rp.ShieldGraphic && x.Type == IO.ItemType.Shield); + + var isRangedWeapon = matchingWeapon.Map(x => x.SubType == IO.ItemSubType.Ranged).ValueOr(false); + var isArrows = matchingArrows.Map(x => x.SubType == IO.ItemSubType.Arrows).ValueOr(false); if (isRangedWeapon && (rp.ShieldGraphic == 0 || !isArrows)) return AttackValidationError.MissingArrows; diff --git a/EndlessClient/ControlSets/BackButtonControlSet.cs b/EndlessClient/ControlSets/BackButtonControlSet.cs index 640982d81..28a86d8c3 100644 --- a/EndlessClient/ControlSets/BackButtonControlSet.cs +++ b/EndlessClient/ControlSets/BackButtonControlSet.cs @@ -50,7 +50,7 @@ private XNAButton GetBackButton() DrawOrder = 100, ClickArea = new Rectangle(4, 16, 16, 16) }; - button.OnClick += DoBackButtonClick; + button.OnMouseDown += DoBackButtonClick; _clientWindowSizeRepository.GameWindowSizeChanged += (o, e) => { diff --git a/EndlessClient/ControlSets/CreateAccountControlSet.cs b/EndlessClient/ControlSets/CreateAccountControlSet.cs index 3c0022c83..e6ed30993 100644 --- a/EndlessClient/ControlSets/CreateAccountControlSet.cs +++ b/EndlessClient/ControlSets/CreateAccountControlSet.cs @@ -170,7 +170,7 @@ private IXNAButton GetCreateAccountCancelButton() new Vector2(481, 417), new Rectangle(0, 40, 120, 40), new Rectangle(120, 40, 120, 40)); - button.OnClick += (o, e) => _mainButtonController.GoToInitialState(); + button.OnMouseDown += (o, e) => _mainButtonController.GoToInitialState(); return button; } @@ -193,7 +193,7 @@ private IXNAPanel GetCreateAccountLabels() protected override IXNAButton GetCreateButton() { var button = base.GetCreateButton(); - button.OnClick += DoCreateAccount; + button.OnMouseDown += DoCreateAccount; return button; } diff --git a/EndlessClient/ControlSets/InitialControlSet.cs b/EndlessClient/ControlSets/InitialControlSet.cs index 8ee50a411..c04a99ad1 100644 --- a/EndlessClient/ControlSets/InitialControlSet.cs +++ b/EndlessClient/ControlSets/InitialControlSet.cs @@ -83,28 +83,28 @@ public override IGameComponent FindComponentByControlIdentifier(GameControlIdent private IXNAButton GetMainCreateAccountButton() { var button = MainButtonCreationHelper(GameControlIdentifier.InitialCreateAccount); - button.OnClick += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickCreateAccount); + button.OnMouseDown += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickCreateAccount); return button; } private IXNAButton GetMainLoginButton() { var button = MainButtonCreationHelper(GameControlIdentifier.InitialLogin); - button.OnClick += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickLogin); + button.OnMouseDown += (o, e) => AsyncMainButtonClick(_mainButtonController.ClickLogin); return button; } private IXNAButton GetViewCreditsButton() { var button = MainButtonCreationHelper(GameControlIdentifier.InitialViewCredits); - button.OnClick += (o, e) => _mainButtonController.ClickViewCredits(); + button.OnMouseDown += (o, e) => _mainButtonController.ClickViewCredits(); return button; } private IXNAButton GetExitButton() { var button = MainButtonCreationHelper(GameControlIdentifier.InitialExitGame); - button.OnClick += (o, e) => _mainButtonController.ClickExit(); + button.OnMouseDown += (o, e) => _mainButtonController.ClickExit(); return button; } diff --git a/EndlessClient/ControlSets/LoggedInControlSet.cs b/EndlessClient/ControlSets/LoggedInControlSet.cs index 39f3acbdb..33f7ef927 100644 --- a/EndlessClient/ControlSets/LoggedInControlSet.cs +++ b/EndlessClient/ControlSets/LoggedInControlSet.cs @@ -78,14 +78,14 @@ private IXNAButton GetPasswordButton() new Vector2(454, 417), new Rectangle(0, 120, 120, 40), new Rectangle(120, 120, 120, 40)); - button.OnClick += (o, e) => AsyncButtonAction(_accountController.ChangePassword); + button.OnMouseDown += (o, e) => AsyncButtonAction(_accountController.ChangePassword); return button; } protected override IXNAButton GetCreateButton() { var button = base.GetCreateButton(); - button.OnClick += (o, e) => AsyncButtonAction(_characterManagementController.CreateCharacter); + button.OnMouseDown += (o, e) => AsyncButtonAction(_characterManagementController.CreateCharacter); return button; } diff --git a/EndlessClient/ControlSets/LoginPromptControlSet.cs b/EndlessClient/ControlSets/LoginPromptControlSet.cs index bcff5176e..f9c5cb6f1 100644 --- a/EndlessClient/ControlSets/LoginPromptControlSet.cs +++ b/EndlessClient/ControlSets/LoginPromptControlSet.cs @@ -140,7 +140,7 @@ private XNAButton GetLoginAccountButton() { DrawOrder = _personPicture.DrawOrder + 2 }; - button.OnClick += DoLogin; + button.OnMouseDown += DoLogin; return button; } @@ -165,7 +165,7 @@ private XNAButton GetLoginCancelButton() { DrawOrder = _personPicture.DrawOrder + 2 }; - button.OnClick += (o, e) => _mainButtonController.GoToInitialState(); + button.OnMouseDown += (o, e) => _mainButtonController.GoToInitialState(); return button; } } diff --git a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs index 53709b3e4..7b2937ba6 100644 --- a/EndlessClient/Dialogs/Actions/InGameDialogActions.cs +++ b/EndlessClient/Dialogs/Actions/InGameDialogActions.cs @@ -491,7 +491,7 @@ private void UseDefaultDialogSounds(ScrollingListDialog dialog) UseDefaultDialogSounds((BaseEODialog)dialog); foreach (var button in dialog.ChildControls.OfType()) - button.OnClick += Handler; + button.OnMouseDown += Handler; void Handler(object sender, EventArgs e) => _sfxPlayer.PlaySfx(SoundEffectID.DialogButtonClick); } diff --git a/EndlessClient/Dialogs/BarberDialog.cs b/EndlessClient/Dialogs/BarberDialog.cs index 87f2d83ba..6c9ad3a8a 100644 --- a/EndlessClient/Dialogs/BarberDialog.cs +++ b/EndlessClient/Dialogs/BarberDialog.cs @@ -76,7 +76,7 @@ private void InitializeCharacterControl() private void InitializeDialogItems(IEODialogButtonService dialogButtonService) { var cancel = CreateButton(dialogButtonService, new Vector2(215, 151), SmallButton.Cancel); - cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel); + cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel); _changeHairItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0) { diff --git a/EndlessClient/Dialogs/BardDialog.cs b/EndlessClient/Dialogs/BardDialog.cs index cc569daa4..1db7dbf6e 100644 --- a/EndlessClient/Dialogs/BardDialog.cs +++ b/EndlessClient/Dialogs/BardDialog.cs @@ -37,7 +37,7 @@ public BardDialog(INativeGraphicsManager nativeGraphicsManager, dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); cancel.Initialize(); cancel.SetParentControl(this); - cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel); + cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel); CenterInGameView(); @@ -63,7 +63,7 @@ protected override void OnDrawControl(GameTime gameTime) }); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButton.Left && _currentTick > 8) { diff --git a/EndlessClient/Dialogs/BoardDialog.cs b/EndlessClient/Dialogs/BoardDialog.cs index 234047d9c..3e0f28e75 100644 --- a/EndlessClient/Dialogs/BoardDialog.cs +++ b/EndlessClient/Dialogs/BoardDialog.cs @@ -91,8 +91,8 @@ public BoardDialog(INativeGraphicsManager nativeGraphicsManager, _message.SetScrollWheelHandler(_scrollBar); _message.SetParentControl(this); - _add.OnClick += AddButton_Click; - _delete.OnClick += DeleteButton_Click; + _add.OnMouseDown += AddButton_Click; + _delete.OnMouseDown += DeleteButton_Click; } public override void Initialize() diff --git a/EndlessClient/Dialogs/ChangePasswordDialog.cs b/EndlessClient/Dialogs/ChangePasswordDialog.cs index 9bca5766a..485efc79e 100644 --- a/EndlessClient/Dialogs/ChangePasswordDialog.cs +++ b/EndlessClient/Dialogs/ChangePasswordDialog.cs @@ -70,14 +70,14 @@ public ChangePasswordDialog(INativeGraphicsManager nativeGraphicsManager, new Vector2(157, 195), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - _ok.OnClick += OnButtonPressed; + _ok.OnMouseDown += 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); + _cancel.OnMouseDown += (s, e) => Close(XNADialogResult.Cancel); CenterInGameView(); } diff --git a/EndlessClient/Dialogs/CreateCharacterDialog.cs b/EndlessClient/Dialogs/CreateCharacterDialog.cs index fd918ed8c..afe916867 100644 --- a/EndlessClient/Dialogs/CreateCharacterDialog.cs +++ b/EndlessClient/Dialogs/CreateCharacterDialog.cs @@ -74,7 +74,7 @@ public CreateCharacterDialog( new Vector2(196, 85 + i * 26), new Rectangle(185, 38, 19, 19), new Rectangle(206, 38, 19, 19)); - btn.OnClick += ArrowButtonClick; + btn.OnMouseDown += ArrowButtonClick; btn.SetParentControl(this); _arrowButtons[i] = btn; } @@ -94,14 +94,14 @@ public CreateCharacterDialog( new Vector2(157, 195), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - _ok.OnClick += (s, e) => ClickOk(); + _ok.OnMouseDown += (s, e) => ClickOk(); _ok.SetParentControl(this); _cancel = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(250, 195), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); - _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); + _cancel.OnMouseDown += (s, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); CenterInGameView(); diff --git a/EndlessClient/Dialogs/EOMessageBox.cs b/EndlessClient/Dialogs/EOMessageBox.cs index a0f824c34..e3f75986b 100644 --- a/EndlessClient/Dialogs/EOMessageBox.cs +++ b/EndlessClient/Dialogs/EOMessageBox.cs @@ -74,23 +74,23 @@ public EOMessageBox(INativeGraphicsManager graphicsManager, { case EODialogButtons.Ok: _ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), okOut, okOver); - _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); + _ok.OnMouseDown += (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.OnMouseDown += (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.OnMouseDown += (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.OnMouseDown += (s, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); break; } diff --git a/EndlessClient/Dialogs/ItemTransferDialog.cs b/EndlessClient/Dialogs/ItemTransferDialog.cs index 798237696..dc6048fdb 100644 --- a/EndlessClient/Dialogs/ItemTransferDialog.cs +++ b/EndlessClient/Dialogs/ItemTransferDialog.cs @@ -75,7 +75,7 @@ public ItemTransferDialog(INativeGraphicsManager nativeGraphicsManager, { Visible = true }; - _okButton.OnClick += (s, e) => Close(XNADialogResult.OK); + _okButton.OnMouseDown += (s, e) => Close(XNADialogResult.OK); _cancelButton = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(153, 125), @@ -84,7 +84,7 @@ public ItemTransferDialog(INativeGraphicsManager nativeGraphicsManager, { Visible = true }; - _cancelButton.OnClick += (s, e) => Close(XNADialogResult.Cancel); + _cancelButton.OnMouseDown += (s, e) => Close(XNADialogResult.Cancel); _descLabel = new XNALabel(Constants.FontSize10) { diff --git a/EndlessClient/Dialogs/ListDialogItem.cs b/EndlessClient/Dialogs/ListDialogItem.cs index 68a13e2e0..8e8841dc3 100644 --- a/EndlessClient/Dialogs/ListDialogItem.cs +++ b/EndlessClient/Dialogs/ListDialogItem.cs @@ -194,7 +194,7 @@ public void SetPrimaryClickAction(EventHandler onClickAction) Underline = UnderlineLinks }; - ((XNAHyperLink)_primaryText).OnClick += onClickAction; + ((XNAHyperLink)_primaryText).OnMouseDown += onClickAction; _primaryText.SetParentControl(this); _primaryText.Initialize(); @@ -223,7 +223,7 @@ public void SetSubtextClickAction(EventHandler onClickAction) Underline = UnderlineLinks }; - ((XNAHyperLink)_subText).OnClick += onClickAction; + ((XNAHyperLink)_subText).OnMouseDown += onClickAction; _subText.SetParentControl(this); _subText.Initialize(); @@ -270,7 +270,7 @@ protected override void OnDrawControl(GameTime gameTime) _spriteBatch.End(); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButton.Left) { diff --git a/EndlessClient/Dialogs/PaperdollDialogItem.cs b/EndlessClient/Dialogs/PaperdollDialogItem.cs index 11925cb94..5ebcad866 100644 --- a/EndlessClient/Dialogs/PaperdollDialogItem.cs +++ b/EndlessClient/Dialogs/PaperdollDialogItem.cs @@ -50,7 +50,7 @@ public PaperdollDialogItem(INativeGraphicsManager nativeGraphicsManager, StretchMode = StretchMode.CenterInFrame; } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (!_isMainCharacter || !_itemInfo.HasValue) return false; diff --git a/EndlessClient/Dialogs/PlayerInfoDialog.cs b/EndlessClient/Dialogs/PlayerInfoDialog.cs index 8d1ff2939..4af40afe1 100644 --- a/EndlessClient/Dialogs/PlayerInfoDialog.cs +++ b/EndlessClient/Dialogs/PlayerInfoDialog.cs @@ -79,7 +79,7 @@ public PlayerInfoDialog(INativeGraphicsManager graphicsManager, new Vector2(276, 253), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - okButton.OnClick += (_, _) => Close(XNADialogResult.OK); + okButton.OnMouseDown += (_, _) => Close(XNADialogResult.OK); okButton.Initialize(); okButton.SetParentControl(this); diff --git a/EndlessClient/Dialogs/ProgressDialog.cs b/EndlessClient/Dialogs/ProgressDialog.cs index 5a698f105..0186bb28d 100644 --- a/EndlessClient/Dialogs/ProgressDialog.cs +++ b/EndlessClient/Dialogs/ProgressDialog.cs @@ -57,7 +57,7 @@ public ProgressDialog(INativeGraphicsManager nativeGraphicsManager, new Vector2(181, 113), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); - _cancelButton.OnClick += DoCancel; + _cancelButton.OnMouseDown += DoCancel; _cancelButton.SetParentControl(this); _pbBackgroundTexture = GraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 19); diff --git a/EndlessClient/Dialogs/QuestDialog.cs b/EndlessClient/Dialogs/QuestDialog.cs index 3794a9715..c9f394972 100644 --- a/EndlessClient/Dialogs/QuestDialog.cs +++ b/EndlessClient/Dialogs/QuestDialog.cs @@ -71,8 +71,8 @@ public QuestDialog(INativeGraphicsManager nativeGraphicsManager, { Visible = false, }; - _questSwitcher.OnClick += (_, _) => ToggleSwitcherState(); - _questSwitcher.OnClick += (_, _) => ClickSoundEffect?.Invoke(this, EventArgs.Empty); + _questSwitcher.OnMouseDown += (_, _) => ToggleSwitcherState(); + _questSwitcher.OnMouseDown += (_, _) => ClickSoundEffect?.Invoke(this, EventArgs.Empty); _questSwitcher.SetParentControl(this); } diff --git a/EndlessClient/Dialogs/ScrollingListDialog.cs b/EndlessClient/Dialogs/ScrollingListDialog.cs index 67d92300d..0543be735 100644 --- a/EndlessClient/Dialogs/ScrollingListDialog.cs +++ b/EndlessClient/Dialogs/ScrollingListDialog.cs @@ -231,7 +231,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _add.SetParentControl(this); - _add.OnClick += (o, e) => AddAction?.Invoke(o, e); + _add.OnMouseDown += (o, e) => AddAction?.Invoke(o, e); _back = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Back), @@ -241,7 +241,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _back.SetParentControl(this); - _back.OnClick += (o, e) => BackAction?.Invoke(o, e); + _back.OnMouseDown += (o, e) => BackAction?.Invoke(o, e); _next = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Next), @@ -251,7 +251,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _next.SetParentControl(this); - _next.OnClick += (o, e) => NextAction?.Invoke(o, e); + _next.OnMouseDown += (o, e) => NextAction?.Invoke(o, e); _history = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.History), @@ -261,7 +261,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _history.SetParentControl(this); - _history.OnClick += (o, e) => HistoryAction?.Invoke(o, e); + _history.OnMouseDown += (o, e) => HistoryAction?.Invoke(o, e); _progress = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Progress), @@ -271,7 +271,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _progress.SetParentControl(this); - _progress.OnClick += (o, e) => ProgressAction?.Invoke(o, e); + _progress.OnMouseDown += (o, e) => ProgressAction?.Invoke(o, e); _delete = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Delete), @@ -281,7 +281,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 1, }; _delete.SetParentControl(this); - _delete.OnClick += (o, e) => ProgressAction?.Invoke(o, e); + _delete.OnMouseDown += (o, e) => ProgressAction?.Invoke(o, e); _ok = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), @@ -291,7 +291,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 2, }; _ok.SetParentControl(this); - _ok.OnClick += CloseButton_Click; + _ok.OnMouseDown += CloseButton_Click; _cancel = new XNAButton(dialogButtonService.SmallButtonSheet, Vector2.Zero, dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), @@ -301,7 +301,7 @@ public ScrollingListDialog(INativeGraphicsManager nativeGraphicsManager, UpdateOrder = 2, }; _cancel.SetParentControl(this); - _cancel.OnClick += CloseButton_Click; + _cancel.OnMouseDown += CloseButton_Click; _button1Position = GetButton1Position(DrawArea, _ok.DrawArea, DialogType); _button2Position = GetButton2Position(DrawArea, _ok.DrawArea, DialogType); diff --git a/EndlessClient/Dialogs/ScrollingMessageDialog.cs b/EndlessClient/Dialogs/ScrollingMessageDialog.cs index 0387095eb..fc9369cc9 100644 --- a/EndlessClient/Dialogs/ScrollingMessageDialog.cs +++ b/EndlessClient/Dialogs/ScrollingMessageDialog.cs @@ -73,7 +73,7 @@ public ScrollingMessageDialog(INativeGraphicsManager nativeGraphicsManager, new Vector2(138, 197), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); + _ok.OnMouseDown += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); _scrollBar = new ScrollBar(new Vector2(320, 66), new Vector2(16, 119), diff --git a/EndlessClient/Dialogs/SessionExpDialog.cs b/EndlessClient/Dialogs/SessionExpDialog.cs index 1ec9f8161..989a7ce13 100644 --- a/EndlessClient/Dialogs/SessionExpDialog.cs +++ b/EndlessClient/Dialogs/SessionExpDialog.cs @@ -39,7 +39,7 @@ public SessionExpDialog(INativeGraphicsManager nativeGraphicsManager, new Vector2(98, 214), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - okButton.OnClick += (_, _) => Close(XNADialogResult.OK); + okButton.OnMouseDown += (_, _) => Close(XNADialogResult.OK); okButton.SetParentControl(this); okButton.Initialize(); diff --git a/EndlessClient/Dialogs/TextInputDialog.cs b/EndlessClient/Dialogs/TextInputDialog.cs index a06ac7caa..7a757eba7 100644 --- a/EndlessClient/Dialogs/TextInputDialog.cs +++ b/EndlessClient/Dialogs/TextInputDialog.cs @@ -67,14 +67,14 @@ public TextInputDialog(INativeGraphicsManager nativeGraphicsManager, new Vector2(41, 103), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - ok.OnClick += (_, _) => Close(XNADialogResult.OK); + ok.OnMouseDown += (_, _) => Close(XNADialogResult.OK); ok.SetParentControl(this); var cancel = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(134, 103), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); - cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel); + cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel); cancel.SetParentControl(this); DialogClosed += (_, _) => chatTextBoxActions.FocusChatTextBox(); diff --git a/EndlessClient/Dialogs/TextMultiInputDialog.cs b/EndlessClient/Dialogs/TextMultiInputDialog.cs index e0df1b3a8..c0fa1b850 100644 --- a/EndlessClient/Dialogs/TextMultiInputDialog.cs +++ b/EndlessClient/Dialogs/TextMultiInputDialog.cs @@ -232,14 +232,14 @@ public TextMultiInputDialog(INativeGraphicsManager nativeGraphicsManager, okButtonPosition, eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - ok.OnClick += (_, _) => Close(XNADialogResult.OK); + ok.OnMouseDown += (_, _) => Close(XNADialogResult.OK); ok.SetParentControl(this); var cancel = new XNAButton(eoDialogButtonService.SmallButtonSheet, cancelButtonPosition, eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); - cancel.OnClick += (_, _) => Close(XNADialogResult.Cancel); + cancel.OnMouseDown += (_, _) => Close(XNADialogResult.Cancel); cancel.SetParentControl(this); DialogClosed += (_, _) => chatTextBoxActions.FocusChatTextBox(); diff --git a/EndlessClient/Dialogs/TradeDialog.cs b/EndlessClient/Dialogs/TradeDialog.cs index ba562d57e..5523d280d 100644 --- a/EndlessClient/Dialogs/TradeDialog.cs +++ b/EndlessClient/Dialogs/TradeDialog.cs @@ -140,13 +140,13 @@ public TradeDialog(INativeGraphicsManager nativeGraphicsManager, _ok = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(356, 252), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); - _ok.OnClick += OkButtonClicked; + _ok.OnMouseDown += OkButtonClicked; _ok.SetParentControl(this); _cancel = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(449, 252), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); - _cancel.OnClick += CancelButtonClicked; + _cancel.OnMouseDown += CancelButtonClicked; _cancel.SetParentControl(this); _leftItems = new List(); diff --git a/EndlessClient/HUD/Chat/ChatPanelTab.cs b/EndlessClient/HUD/Chat/ChatPanelTab.cs index 0face3d6e..af38f876b 100644 --- a/EndlessClient/HUD/Chat/ChatPanelTab.cs +++ b/EndlessClient/HUD/Chat/ChatPanelTab.cs @@ -85,19 +85,19 @@ public ChatPanelTab(IChatProvider chatProvider, DrawArea = GetTabClickableArea(); _tab = new ClickableArea(new Rectangle(0, 0, DrawArea.Width, DrawArea.Height)); - _tab.OnClick += (_, _) => SelectThisTab(); + _tab.OnMouseDown += (_, _) => SelectThisTab(); _tab.SetParentControl(this); if (Tab == ChatTab.Private1) { _closeButton = new ClickableArea(new Rectangle(3, 3, 11, 11)); - _closeButton.OnClick += (_, _) => CloseTab(); + _closeButton.OnMouseDown += (_, _) => CloseTab(); _closeButton.SetParentControl(this); } else if (Tab == ChatTab.Private2) { _closeButton = new ClickableArea(new Rectangle(3, 3, 11, 11)); - _closeButton.OnClick += (_, _) => CloseTab(); + _closeButton.OnMouseDown += (_, _) => CloseTab(); _closeButton.SetParentControl(this); } diff --git a/EndlessClient/HUD/Controls/DraggablePanelItem.cs b/EndlessClient/HUD/Controls/DraggablePanelItem.cs index 777eb975f..9a15bee4c 100644 --- a/EndlessClient/HUD/Controls/DraggablePanelItem.cs +++ b/EndlessClient/HUD/Controls/DraggablePanelItem.cs @@ -83,7 +83,7 @@ protected override bool HandleDragEnd(IXNAControl control, MouseEventArgs eventA return true; } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (_followMouse) { diff --git a/EndlessClient/HUD/Controls/HudControlsFactory.cs b/EndlessClient/HUD/Controls/HudControlsFactory.cs index 3d171b9ea..cefa34434 100644 --- a/EndlessClient/HUD/Controls/HudControlsFactory.cs +++ b/EndlessClient/HUD/Controls/HudControlsFactory.cs @@ -301,7 +301,7 @@ private IXNAButton CreateStateChangeButton(InGameStates whichState) }; } - retButton.OnClick += (_, _) => DoHudStateChangeClick(whichState); + retButton.OnMouseDown += (_, _) => DoHudStateChangeClick(whichState); retButton.OnMouseEnter += (_, _) => _statusLabelSetter.SetStatusLabel( EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + buttonIndex); @@ -319,8 +319,8 @@ private IXNAButton CreateFriendListButton() { DrawOrder = HUD_CONTROL_LAYER + 10 }; - button.OnClick += (_, _) => _hudButtonController.ClickFriendList(); - button.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.ButtonClick); + button.OnMouseDown += (_, _) => _hudButtonController.ClickFriendList(); + button.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.ButtonClick); button.OnMouseOver += (o, e) => _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_FRIEND_LIST); if (_clientWindowSizeRepository.Resizable) @@ -342,8 +342,8 @@ private IXNAButton CreateIgnoreListButton() { DrawOrder = HUD_CONTROL_LAYER + 10 }; - button.OnClick += (_, _) => _hudButtonController.ClickIgnoreList(); - button.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.ButtonClick); + button.OnMouseDown += (_, _) => _hudButtonController.ClickIgnoreList(); + button.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.ButtonClick); button.OnMouseOver += (o, e) => _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_IGNORE_LIST); if (_clientWindowSizeRepository.Resizable) @@ -471,8 +471,8 @@ private IGameComponent CreateSessionExpButton() { DrawOrder = HUD_CONTROL_LAYER }; - btn.OnClick += (_, _) => _hudButtonController.ClickSessionExp(); - btn.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.HudStatusBarClick); + btn.OnMouseDown += (_, _) => _hudButtonController.ClickSessionExp(); + btn.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.HudStatusBarClick); return btn; } @@ -486,8 +486,8 @@ private IGameComponent CreateQuestButton() { DrawOrder = HUD_CONTROL_LAYER }; - btn.OnClick += (_, _) => _hudButtonController.ClickQuestStatus(); - btn.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.HudStatusBarClick); + btn.OnMouseDown += (_, _) => _hudButtonController.ClickQuestStatus(); + btn.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.HudStatusBarClick); return btn; } diff --git a/EndlessClient/HUD/Inventory/InventoryPanelItem.cs b/EndlessClient/HUD/Inventory/InventoryPanelItem.cs index 67dc861e7..e4c2e7701 100644 --- a/EndlessClient/HUD/Inventory/InventoryPanelItem.cs +++ b/EndlessClient/HUD/Inventory/InventoryPanelItem.cs @@ -168,7 +168,7 @@ protected override bool HandleDoubleClick(IXNAControl control, MouseEventArgs ev if (IsDragging) { // roll back the first click in the double click - base.HandleClick(control, eventArgs); + base.HandleMouseDown(control, eventArgs); } DoubleClick?.Invoke(control, Data); diff --git a/EndlessClient/HUD/Panels/ActiveSpellsPanel.cs b/EndlessClient/HUD/Panels/ActiveSpellsPanel.cs index b6989fc93..228cea981 100644 --- a/EndlessClient/HUD/Panels/ActiveSpellsPanel.cs +++ b/EndlessClient/HUD/Panels/ActiveSpellsPanel.cs @@ -143,14 +143,14 @@ public ActiveSpellsPanel(INativeGraphicsManager nativeGraphicsManager, FlashSpeed = 500, Visible = false }; - _levelUpButton1.OnClick += LevelUp_Click; + _levelUpButton1.OnMouseDown += LevelUp_Click; _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.OnMouseDown += LevelUp_Click; _scrollBar = new ScrollBar(new Vector2(467, 2), new Vector2(16, 115), ScrollBarColors.LightOnMed, NativeGraphicsManager) { diff --git a/EndlessClient/HUD/Panels/ChatPanel.cs b/EndlessClient/HUD/Panels/ChatPanel.cs index 0293f6e09..f8452e61b 100644 --- a/EndlessClient/HUD/Panels/ChatPanel.cs +++ b/EndlessClient/HUD/Panels/ChatPanel.cs @@ -135,14 +135,14 @@ public void ClosePMTab(ChatTab whichTab) _tabs[whichTab].CloseTab(); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButton.Right) { _tabs[CurrentTab].HandleRightClick(eventArgs); } - return base.HandleClick(control, eventArgs); + return base.HandleMouseDown(control, eventArgs); } } } diff --git a/EndlessClient/HUD/Panels/DraggableHudPanel.cs b/EndlessClient/HUD/Panels/DraggableHudPanel.cs index f2c7e63a1..ec3e9671c 100644 --- a/EndlessClient/HUD/Panels/DraggableHudPanel.cs +++ b/EndlessClient/HUD/Panels/DraggableHudPanel.cs @@ -1,5 +1,4 @@ using System; -using EndlessClient.Rendering; using MonoGame.Extended.Input.InputListeners; using Optional; using XNAControls; @@ -21,7 +20,7 @@ public DraggableHudPanel(bool enableDragging) _enableDragging = enableDragging; } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { Activated?.Invoke(); return true; diff --git a/EndlessClient/HUD/Panels/InventoryPanel.cs b/EndlessClient/HUD/Panels/InventoryPanel.cs index 67e4b7784..0e58742fa 100644 --- a/EndlessClient/HUD/Panels/InventoryPanel.cs +++ b/EndlessClient/HUD/Panels/InventoryPanel.cs @@ -113,7 +113,7 @@ public InventoryPanel(INativeGraphicsManager nativeGraphicsManager, _paperdoll = new XNAButton(weirdOffsetSheet, new Vector2(385, 9), new Rectangle(39, 385, 88, 19), new Rectangle(126, 385, 88, 19)); _paperdoll.OnMouseEnter += MouseOverButton; - _paperdoll.OnClick += (_, _) => + _paperdoll.OnMouseDown += (_, _) => { _inventoryController.ShowPaperdollDialog(); _sfxPlayer.PlaySfx(SoundEffectID.ButtonClick); @@ -121,11 +121,11 @@ public InventoryPanel(INativeGraphicsManager nativeGraphicsManager, _drop = new XNAButton(weirdOffsetSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37)); _drop.OnMouseEnter += MouseOverButton; - _drop.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.InventoryPlace); + _drop.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.InventoryPlace); _junk = new XNAButton(weirdOffsetSheet, new Vector2(431, 68), new Rectangle(0, 89, 38, 37), new Rectangle(0, 126, 38, 37)); _junk.OnMouseEnter += MouseOverButton; - _junk.OnClick += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.InventoryPlace); + _junk.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(SoundEffectID.InventoryPlace); _cachedStats = Option.None(); _cachedInventory = new HashSet(); diff --git a/EndlessClient/HUD/Panels/OnlineListPanel.cs b/EndlessClient/HUD/Panels/OnlineListPanel.cs index c57d4f285..9f20a87d3 100644 --- a/EndlessClient/HUD/Panels/OnlineListPanel.cs +++ b/EndlessClient/HUD/Panels/OnlineListPanel.cs @@ -102,7 +102,7 @@ public OnlineListPanel(INativeGraphicsManager nativeGraphicsManager, _filterClickArea = new ClickableArea(new Rectangle(2, 2, 14, 14)); _filterClickArea.SetParentControl(this); - _filterClickArea.OnClick += FilterClickArea_Click; + _filterClickArea.OnMouseDown += FilterClickArea_Click; _weirdOffsetTextureSheet = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true); _chatIconsTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 32, true); @@ -182,7 +182,7 @@ protected override void OnDrawControl(GameTime gameTime) _spriteBatch.End(); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (eventArgs.Button != MouseButton.Right) return false; diff --git a/EndlessClient/HUD/Panels/SettingsPanel.cs b/EndlessClient/HUD/Panels/SettingsPanel.cs index c28c65c67..ce52bade7 100644 --- a/EndlessClient/HUD/Panels/SettingsPanel.cs +++ b/EndlessClient/HUD/Panels/SettingsPanel.cs @@ -115,7 +115,7 @@ public override void Initialize() foreach (var pair in _buttons) { var button = pair.Value; - button.OnClick += (_, _) => SettingChange(pair.Key); + button.OnMouseDown += (_, _) => SettingChange(pair.Key); button.OnMouseEnter += (_, _) => _statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE); button.SetParentControl(this); button.Initialize(); diff --git a/EndlessClient/HUD/Panels/StatsPanel.cs b/EndlessClient/HUD/Panels/StatsPanel.cs index 80156d2b9..0c63316ca 100644 --- a/EndlessClient/HUD/Panels/StatsPanel.cs +++ b/EndlessClient/HUD/Panels/StatsPanel.cs @@ -138,7 +138,7 @@ public StatsPanel(INativeGraphicsManager nativeGraphicsManager, public override void Initialize() { foreach (var control in _arrowButtons) - control.OnClick += HandleArrowButtonClick; + control.OnMouseDown += HandleArrowButtonClick; var controls = _basicStats.Concat(_characterStats) .Concat(_arrowButtons) diff --git a/EndlessClient/HUD/Party/PartyPanelMember.cs b/EndlessClient/HUD/Party/PartyPanelMember.cs index de7222bbd..1b8534288 100644 --- a/EndlessClient/HUD/Party/PartyPanelMember.cs +++ b/EndlessClient/HUD/Party/PartyPanelMember.cs @@ -71,7 +71,7 @@ public PartyPanelMember(INativeGraphicsManager nativeGraphicsManager, : new Rectangle(0, delta, removeTexture.Width, delta)); if (isRemovable) - _removeButton.OnClick += (o, e) => RemoveAction?.Invoke(o, e); + _removeButton.OnMouseDown += (o, e) => RemoveAction?.Invoke(o, e); _removeButton.SetParentControl(this); _nameLabel = new XNALabel(Constants.FontSize08) diff --git a/EndlessClient/HUD/Spells/SpellPanelItem.cs b/EndlessClient/HUD/Spells/SpellPanelItem.cs index 9e6e40b5f..34127b82d 100644 --- a/EndlessClient/HUD/Spells/SpellPanelItem.cs +++ b/EndlessClient/HUD/Spells/SpellPanelItem.cs @@ -97,13 +97,13 @@ protected override void OnDrawControl(GameTime gameTime) base.OnDrawControl(gameTime); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (_parentContainer.NoItemsDragging()) _sfxPlayer.PlaySfx(SoundEffectID.InventoryPickup); Click?.Invoke(control, eventArgs); - return base.HandleClick(control, eventArgs); + return base.HandleMouseDown(control, eventArgs); } protected override bool HandleDragStart(IXNAControl control, MouseEventArgs eventArgs) diff --git a/EndlessClient/HUD/StatusBars/StatusBarBase.cs b/EndlessClient/HUD/StatusBars/StatusBarBase.cs index 4ebbb977f..6555143c4 100644 --- a/EndlessClient/HUD/StatusBars/StatusBarBase.cs +++ b/EndlessClient/HUD/StatusBars/StatusBarBase.cs @@ -100,7 +100,7 @@ protected override void OnDrawControl(GameTime gameTime) base.OnDrawControl(gameTime); } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { _label.Visible = !_label.Visible; _labelShowTime = _label.SomeWhen(x => x.Visible).Map(_ => DateTime.Now); diff --git a/EndlessClient/Rendering/ContextMenuRenderer.cs b/EndlessClient/Rendering/ContextMenuRenderer.cs index d8d655d75..6a6051f2f 100644 --- a/EndlessClient/Rendering/ContextMenuRenderer.cs +++ b/EndlessClient/Rendering/ContextMenuRenderer.cs @@ -214,7 +214,7 @@ private void ContextMenuRenderer_OnMouseOver(object sender, MouseStateExtended e } } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { if (eventArgs.Button == MouseButton.Left) { diff --git a/EndlessClient/Rendering/Map/ClickDispatcher.cs b/EndlessClient/Rendering/Map/ClickDispatcher.cs index ed3551f52..3ae006549 100644 --- a/EndlessClient/Rendering/Map/ClickDispatcher.cs +++ b/EndlessClient/Rendering/Map/ClickDispatcher.cs @@ -75,7 +75,7 @@ public ClickDispatcher(IHudControlProvider hudControlProvider, _npcInteractionController = npcInteractionController; } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { _contextMenuRepository.ContextMenu.MatchSome(contextMenu => { diff --git a/EndlessClient/UIControls/CharacterInfoPanel.cs b/EndlessClient/UIControls/CharacterInfoPanel.cs index 05a8354f6..e18bfc981 100644 --- a/EndlessClient/UIControls/CharacterInfoPanel.cs +++ b/EndlessClient/UIControls/CharacterInfoPanel.cs @@ -53,14 +53,14 @@ protected CharacterInfoPanel(int characterIndex, new Vector2(161, 57), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Login), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Login)); - _loginButton.OnClick += (o, e) => AsyncButtonClick(() => _loginController.LoginToCharacter(_character)); + _loginButton.OnMouseDown += (o, e) => AsyncButtonClick(() => _loginController.LoginToCharacter(_character)); _loginButton.SetParentControl(this); _deleteButton = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(161, 85), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Delete), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Delete)); - _deleteButton.OnClick += (o, e) => AsyncButtonClick(() => _characterManagementController.DeleteCharacter(_character)); + _deleteButton.OnMouseDown += (o, e) => AsyncButtonClick(() => _characterManagementController.DeleteCharacter(_character)); _deleteButton.SetParentControl(this); _backgroundImage = _gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 11); diff --git a/EndlessClient/UIControls/ClickableArea.cs b/EndlessClient/UIControls/ClickableArea.cs index 7258019d3..115c82f23 100644 --- a/EndlessClient/UIControls/ClickableArea.cs +++ b/EndlessClient/UIControls/ClickableArea.cs @@ -19,6 +19,10 @@ public int? FlashSpeed set => throw new InvalidOperationException("Unable to get flash speed on clickable area"); } + public event EventHandler OnMouseDown; + + public event EventHandler OnMouseUp; + public event EventHandler OnClick; public event EventHandler OnClickDrag @@ -32,6 +36,18 @@ public ClickableArea(Rectangle area) ClickArea = area; } + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) + { + OnMouseDown?.Invoke(control, eventArgs); + return true; + } + + protected override bool HandleMouseUp(IXNAControl control, MouseEventArgs eventArgs) + { + OnMouseUp?.Invoke(control, eventArgs); + return true; + } + protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) { OnClick?.Invoke(control, eventArgs); diff --git a/EndlessClient/UIControls/CreateCharacterControl.cs b/EndlessClient/UIControls/CreateCharacterControl.cs index 783920b96..61b729ce4 100644 --- a/EndlessClient/UIControls/CreateCharacterControl.cs +++ b/EndlessClient/UIControls/CreateCharacterControl.cs @@ -43,7 +43,7 @@ protected override void OnUpdateControl(GameTime gameTime) _lastPosition = actualDrawPosition; } - protected override bool HandleClick(IXNAControl control, MouseEventArgs eventArgs) + protected override bool HandleMouseDown(IXNAControl control, MouseEventArgs eventArgs) { var nextDirectionInt = (int)RenderProperties.Direction + 1; var nextDirection = (EODirection)(nextDirectionInt % 4); diff --git a/EndlessClient/UIControls/ScrollBar.cs b/EndlessClient/UIControls/ScrollBar.cs index ef7b0a862..533d8493a 100644 --- a/EndlessClient/UIControls/ScrollBar.cs +++ b/EndlessClient/UIControls/ScrollBar.cs @@ -71,11 +71,11 @@ public ScrollBar(Vector2 locationRelativeToParent, var scrollBox = new Rectangle(0, vertOff, 16, 15); _upButton = new XNAButton(scrollSpriteSheet, Vector2.Zero, upArrows[0], upArrows[1]); - _upButton.OnClick += arrowClicked; + _upButton.OnMouseDown += arrowClicked; _upButton.SetParentControl(this); _downButton = new XNAButton(scrollSpriteSheet, new Vector2(0, size.Y - 15), downArrows[0], downArrows[1]); - _downButton.OnClick += arrowClicked; + _downButton.OnMouseDown += arrowClicked; _downButton.SetParentControl(this); _scrollButton = new XNAButton(scrollSpriteSheet, new Vector2(0, 15), scrollBox, scrollBox); diff --git a/EndlessClient/UIControls/XnaControlSoundMapper.cs b/EndlessClient/UIControls/XnaControlSoundMapper.cs index 9b81490d1..8515fefdf 100644 --- a/EndlessClient/UIControls/XnaControlSoundMapper.cs +++ b/EndlessClient/UIControls/XnaControlSoundMapper.cs @@ -27,7 +27,7 @@ public void BindSoundToControl(IGameComponent component, Option s } private void SetupSound(IXNAButton button) => SetupSpecificSound(button, SoundEffectID.ButtonClick); - private void SetupSpecificSound(IXNAButton button, SoundEffectID sound) => button.OnClick += (_, _) => _sfxPlayer.PlaySfx(sound); + private void SetupSpecificSound(IXNAButton button, SoundEffectID sound) => button.OnMouseDown += (_, _) => _sfxPlayer.PlaySfx(sound); private void SetupSound(IXNATextBox textBox) => SetupSpecificSound(textBox, SoundEffectID.TextBoxFocus); private void SetupSpecificSound(IXNATextBox textBox, SoundEffectID sound) => textBox.OnGotFocus += (_, _) => _sfxPlayer.PlaySfx(sound);