Skip to content

Commit

Permalink
Add context menu renderer. Implement paperdoll, PM, friend, and ignor…
Browse files Browse the repository at this point in the history
…e actions for context menus.
  • Loading branch information
ethanmoffat committed Mar 23, 2022
1 parent 1adb207 commit cf4d279
Show file tree
Hide file tree
Showing 10 changed files with 333 additions and 229 deletions.
23 changes: 20 additions & 3 deletions EndlessClient/Controllers/MapInteractionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using EndlessClient.HUD.Inventory;
using EndlessClient.Rendering;
using EndlessClient.Rendering.Character;
using EndlessClient.Rendering.Factories;
using EOLib.Domain.Character;
using EOLib.Domain.Item;
using EOLib.Domain.Map;
Expand All @@ -29,7 +30,10 @@ public class MapInteractionController : IMapInteractionController
private readonly IStatusLabelSetter _statusLabelSetter;
private readonly IInventorySpaceValidator _inventorySpaceValidator;
private readonly IHudControlProvider _hudControlProvider;
private readonly ICharacterRendererProvider _characterRendererProvider;
private readonly IContextMenuRepository _contextMenuRepository;
private readonly IEOMessageBoxFactory _eoMessageBoxFactory;
private readonly IContextMenuRendererFactory _contextMenuRendererFactory;

public MapInteractionController(IMapActions mapActions,
ICharacterActions characterActions,
Expand All @@ -39,7 +43,10 @@ public MapInteractionController(IMapActions mapActions,
IStatusLabelSetter statusLabelSetter,
IInventorySpaceValidator inventorySpaceValidator,
IHudControlProvider hudControlProvider,
IEOMessageBoxFactory eoMessageBoxFactory)
ICharacterRendererProvider characterRendererProvider,
IContextMenuRepository contextMenuRepository,
IEOMessageBoxFactory eoMessageBoxFactory,
IContextMenuRendererFactory contextMenuRendererFactory)
{
_mapActions = mapActions;
_characterActions = characterActions;
Expand All @@ -49,7 +56,10 @@ public MapInteractionController(IMapActions mapActions,
_statusLabelSetter = statusLabelSetter;
_inventorySpaceValidator = inventorySpaceValidator;
_hudControlProvider = hudControlProvider;
_characterRendererProvider = characterRendererProvider;
_contextMenuRepository = contextMenuRepository;
_eoMessageBoxFactory = eoMessageBoxFactory;
_contextMenuRendererFactory = contextMenuRendererFactory;
}

public async Task LeftClickAsync(IMapCellState cellState, IMouseCursorRenderer mouseRenderer)
Expand Down Expand Up @@ -97,9 +107,16 @@ public void RightClick(IMapCellState cellState)
{
_inGameDialogActions.ShowPaperdollDialog(_characterProvider.MainCharacter, isMainCharacter: true);
}
else
else if (_characterRendererProvider.CharacterRenderers.ContainsKey(c.ID))
{
// todo: context menu
_contextMenuRepository.ContextMenu = _contextMenuRepository.ContextMenu.Match(
some: cmr =>
{
cmr.Dispose();
return Option.Some(_contextMenuRendererFactory.CreateContextMenuRenderer(_characterRendererProvider.CharacterRenderers[c.ID]));
},
none: () => Option.Some(_contextMenuRendererFactory.CreateContextMenuRenderer(_characterRendererProvider.CharacterRenderers[c.ID])));
_contextMenuRepository.ContextMenu.MatchSome(r => r.Initialize());
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions EndlessClient/Dialogs/PaperdollDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ private void UpdateDisplayedData(IPaperdollData paperdollData)
{
DrawArea = GetEquipLocationRectangle(equipLocation)
};
// todo: I thought making this event-driven would be cool but I think it would be better to encapsulate this in
// PaperdollDialogItem class after all...

paperdollItem.OnMouseEnter += (_, _) =>
{
// capture values
Expand Down Expand Up @@ -249,6 +248,7 @@ private void UpdateDisplayedData(IPaperdollData paperdollData)
var extra = r.Match(rec => $", {rec.Name}", () => string.Empty);
_statusLabelSetter.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_INFORMATION, msg, extra);
};

paperdollItem.RightClick += (_, rightClickedItem) =>
{
if (rightClickedItem.Special == ItemSpecial.Cursed)
Expand Down
Loading

0 comments on commit cf4d279

Please sign in to comment.