Dalamud API10
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Dalamud.ContextMenu;
|
||||
using Dalamud.Game.Gui.ContextMenu;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Lumina.Excel.GeneratedSheets2;
|
||||
using MareSynchronos.API.Data;
|
||||
@@ -57,34 +57,38 @@ public class Pair
|
||||
|
||||
private PairHandler? CachedPlayer { get; set; }
|
||||
|
||||
public void AddContextMenu(GameObjectContextMenuOpenArgs args)
|
||||
public void AddContextMenu(IMenuOpenedArgs args)
|
||||
{
|
||||
if (CachedPlayer == null || args.ObjectId != CachedPlayer.PlayerCharacterId || IsPaused) return;
|
||||
if (CachedPlayer == null || true /* TODO: Check target */ || IsPaused) return;
|
||||
|
||||
SeStringBuilder seStringBuilder = new();
|
||||
SeStringBuilder seStringBuilder2 = new();
|
||||
SeStringBuilder seStringBuilder3 = new();
|
||||
SeStringBuilder seStringBuilder4 = new();
|
||||
var openProfileSeString = seStringBuilder.AddUiForeground(559).AddText(" ").AddUiForegroundOff().AddText("Open Profile").Build();
|
||||
var reapplyDataSeString = seStringBuilder2.AddUiForeground(559).AddText(" ").AddUiForegroundOff().AddText("Reapply last data").Build();
|
||||
var cyclePauseState = seStringBuilder3.AddUiForeground(559).AddText(" ").AddUiForegroundOff().AddText("Cycle pause state").Build();
|
||||
var changePermissions = seStringBuilder4.AddUiForeground(559).AddText(" ").AddUiForegroundOff().AddText("Change Permissions").Build();
|
||||
args.AddCustomItem(new GameObjectContextMenuItem(openProfileSeString, (a) =>
|
||||
args.AddMenuItem(new MenuItem()
|
||||
{
|
||||
_mediator.Publish(new ProfileOpenStandaloneMessage(this));
|
||||
}));
|
||||
args.AddCustomItem(new GameObjectContextMenuItem(reapplyDataSeString, (a) =>
|
||||
Name = "Open Profile",
|
||||
OnClicked = (a) => _mediator.Publish(new ProfileOpenStandaloneMessage(this)),
|
||||
PrefixColor = 559,
|
||||
PrefixChar = '',
|
||||
});
|
||||
args.AddMenuItem(new MenuItem()
|
||||
{
|
||||
ApplyLastReceivedData(forced: true);
|
||||
}, useDalamudIndicator: false));
|
||||
args.AddCustomItem(new GameObjectContextMenuItem(changePermissions, (a) =>
|
||||
Name = "Reapply last data",
|
||||
OnClicked = (a) => ApplyLastReceivedData(forced: true),
|
||||
PrefixColor = 559,
|
||||
PrefixChar = '',
|
||||
});
|
||||
args.AddMenuItem(new MenuItem()
|
||||
{
|
||||
_mediator.Publish(new OpenPermissionWindow(this));
|
||||
}, useDalamudIndicator: false));
|
||||
args.AddCustomItem(new GameObjectContextMenuItem(cyclePauseState, (a) =>
|
||||
Name = "Change Permissions",
|
||||
OnClicked = (a) => _mediator.Publish(new OpenPermissionWindow(this)),
|
||||
PrefixColor = 559,
|
||||
PrefixChar = '',
|
||||
});
|
||||
args.AddMenuItem(new MenuItem()
|
||||
{
|
||||
_mediator.Publish(new CyclePauseMessage(UserData));
|
||||
}, useDalamudIndicator: false));
|
||||
Name = "Cycle pause state",
|
||||
OnClicked = (a) => _mediator.Publish(new CyclePauseMessage(UserData)),
|
||||
PrefixColor = 559,
|
||||
PrefixChar = '',
|
||||
});
|
||||
}
|
||||
|
||||
public void ApplyData(OnlineUserCharaDataDto data)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dalamud.ContextMenu;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
using Dalamud.Game.Gui.ContextMenu;
|
||||
using Dalamud.Interface.ImGuiNotification;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.API.Data;
|
||||
using MareSynchronos.API.Data.Comparer;
|
||||
using MareSynchronos.API.Data.Extensions;
|
||||
@@ -18,14 +19,14 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
private readonly ConcurrentDictionary<UserData, Pair> _allClientPairs = new(UserDataComparer.Instance);
|
||||
private readonly ConcurrentDictionary<GroupData, GroupFullInfoDto> _allGroups = new(GroupDataComparer.Instance);
|
||||
private readonly MareConfigService _configurationService;
|
||||
private readonly DalamudContextMenu _dalamudContextMenu;
|
||||
private readonly IContextMenu _dalamudContextMenu;
|
||||
private readonly PairFactory _pairFactory;
|
||||
private Lazy<List<Pair>> _directPairsInternal;
|
||||
private Lazy<Dictionary<GroupFullInfoDto, List<Pair>>> _groupPairsInternal;
|
||||
|
||||
public PairManager(ILogger<PairManager> logger, PairFactory pairFactory,
|
||||
MareConfigService configurationService, MareMediator mediator,
|
||||
DalamudContextMenu dalamudContextMenu) : base(logger, mediator)
|
||||
IContextMenu dalamudContextMenu) : base(logger, mediator)
|
||||
{
|
||||
_pairFactory = pairFactory;
|
||||
_configurationService = configurationService;
|
||||
@@ -35,7 +36,7 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
_directPairsInternal = DirectPairsLazy();
|
||||
_groupPairsInternal = GroupPairsLazy();
|
||||
|
||||
_dalamudContextMenu.OnOpenGameObjectContextMenu += DalamudContextMenuOnOnOpenGameObjectContextMenu;
|
||||
_dalamudContextMenu.OnMenuOpened += DalamudContextMenuOnMenuOpened;
|
||||
}
|
||||
|
||||
public List<Pair> DirectPairs => _directPairsInternal.Value;
|
||||
@@ -329,14 +330,14 @@ public sealed class PairManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_dalamudContextMenu.OnOpenGameObjectContextMenu -= DalamudContextMenuOnOnOpenGameObjectContextMenu;
|
||||
_dalamudContextMenu.OnMenuOpened -= DalamudContextMenuOnMenuOpened;
|
||||
|
||||
DisposePairs();
|
||||
}
|
||||
|
||||
private void DalamudContextMenuOnOnOpenGameObjectContextMenu(GameObjectContextMenuOpenArgs args)
|
||||
private void DalamudContextMenuOnMenuOpened(IMenuOpenedArgs args)
|
||||
{
|
||||
if (args.ObjectId == 0xE000000) return;
|
||||
/* TODO: Check empty target */
|
||||
if (!_configurationService.Current.EnableRightClickMenus) return;
|
||||
|
||||
foreach (var pair in _allClientPairs.Where((p => p.Value.IsVisible)))
|
||||
|
||||
Reference in New Issue
Block a user