Skip to content

Commit

Permalink
Prevent clicks on map NPCs behind context menu items from triggering …
Browse files Browse the repository at this point in the history
…both context menu and NPC click handler
  • Loading branch information
ethanmoffat committed Apr 10, 2022
1 parent 43de64b commit 4fb9f5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion EndlessClient/Rendering/ContextMenuRenderer.cs
Expand Up @@ -4,6 +4,7 @@
using EndlessClient.Dialogs.Actions;
using EndlessClient.HUD;
using EndlessClient.HUD.Controls;
using EndlessClient.Input;
using EndlessClient.Rendering.Character;
using EndlessClient.Services;
using EndlessClient.UIControls;
Expand Down Expand Up @@ -44,6 +45,7 @@ private enum MenuAction
private readonly IFriendIgnoreListService _friendIgnoreListService;
private readonly IHudControlProvider _hudControlProvider;
private readonly IContextMenuRepository _contextMenuRepository;
private readonly IUserInputRepository _userInputRepository;
private readonly ICharacterRenderer _characterRenderer;

//private DateTime? m_lastPartyRequestedTime, m_lastTradeRequestedTime;
Expand All @@ -55,6 +57,7 @@ private enum MenuAction
IFriendIgnoreListService friendIgnoreListService,
IHudControlProvider hudControlProvider,
IContextMenuRepository contextMenuRepository,
IUserInputRepository userInputRepository,
ICharacterRenderer characterRenderer)
{
_menuActions = new Dictionary<Rectangle, Action>();
Expand All @@ -64,6 +67,7 @@ private enum MenuAction
_friendIgnoreListService = friendIgnoreListService;
_hudControlProvider = hudControlProvider;
_contextMenuRepository = contextMenuRepository;
_userInputRepository = userInputRepository;
_characterRenderer = characterRenderer;

//first, load up the images. split in half: the right half is the 'over' text
Expand All @@ -88,6 +92,9 @@ private enum MenuAction

SetPositionBasedOnCharacterRenderer(_characterRenderer);
SetSize(W, H);

// Update this before map renderer so that clicks are handled first
UpdateOrder = -20;
}

public override void Initialize()
Expand Down Expand Up @@ -152,8 +159,11 @@ protected override void OnUpdateControl(GameTime gameTime)
_overRect = Option.Some(sourceRect);
found = true;

if (leftClicked)
if (leftClicked && !_userInputRepository.ClickHandled)
{
menuAction();
_userInputRepository.ClickHandled = true;
}

break;
}
Expand Down
Expand Up @@ -2,6 +2,7 @@
using EndlessClient.ControlSets;
using EndlessClient.Dialogs.Actions;
using EndlessClient.HUD;
using EndlessClient.Input;
using EndlessClient.Rendering.Character;
using EndlessClient.Services;
using EOLib.Domain.Interact;
Expand All @@ -19,14 +20,16 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory
private readonly IFriendIgnoreListService _friendIgnoreListService;
private readonly IHudControlProvider _hudControlProvider;
private readonly IContextMenuRepository _contextMenuRepository;
private readonly IUserInputRepository _userInputRepository;

public ContextMenuRendererFactory(INativeGraphicsManager nativeGraphicsManager,
IInGameDialogActions inGameDialogActions,
IPaperdollActions paperdollActions,
IStatusLabelSetter statusLabelSetter,
IFriendIgnoreListService friendIgnoreListService,
IHudControlProvider hudControlProvider,
IContextMenuRepository contextMenuRepository)
IContextMenuRepository contextMenuRepository,
IUserInputRepository userInputRepository)
{
_nativeGraphicsManager = nativeGraphicsManager;
_inGameDialogActions = inGameDialogActions;
Expand All @@ -35,6 +38,7 @@ public class ContextMenuRendererFactory : IContextMenuRendererFactory
_friendIgnoreListService = friendIgnoreListService;
_hudControlProvider = hudControlProvider;
_contextMenuRepository = contextMenuRepository;
_userInputRepository = userInputRepository;
}

public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer characterRenderer)
Expand All @@ -46,6 +50,7 @@ public IContextMenuRenderer CreateContextMenuRenderer(ICharacterRenderer charact
_friendIgnoreListService,
_hudControlProvider,
_contextMenuRepository,
_userInputRepository,
characterRenderer);
}
}
Expand Down

0 comments on commit 4fb9f5c

Please sign in to comment.