private void ContextMenuOnOpenContextMenu(ContextMenuOpenArgs args)
    {
        if (args.ParentAddonName == null)
        {
            return;
        }
        var index = args.Items.FindIndex(i => i is NativeContextMenuItem ni && ni.Name.TextValue == defaultText);

        if (index >= 0)
        {
            args.Items.Add(new NormalContextMenuItem(Config.LockedWindows.Contains(args.ParentAddonName) ? unlockText : lockText, ToggleWindowPositionLock));
        }
    }
    private void OnContextMenu(ContextMenuOpenArgs args)
    {
        if (this.ShowEstateTeleportation == null || args.ParentAddonName is not("PartyMemberList" or "_PartyList"))
        {
            return;
        }

        switch (args.ParentAddonName)
        {
        case "PartyMemberList" when !this.Config.PartyMemberList:
        case "_PartyList" when !this.Config.PartyList:
            return;
        }

        var friends = this.Plugin.XivCommon.Functions.FriendList.List
                      .Where(friend => (friend.ContentId & 0xFFFFFFFF) == args.ContentIdLower && friend.HomeWorld == Service.ClientState.LocalPlayer?.CurrentWorld.Id)
                      .ToArray();

        FriendListEntry?friend = null;

        if (friends.Length == 1)
        {
            friend = friends[0];
        }
        else
        {
            var matched = friends.Where(friend => friend.Name == args.Text).ToArray();
            if (matched.Length > 0)
            {
                friend = matched[0];
            }
        }

        if (friend == null)
        {
            return;
        }

        var index = args.Items
                    .FindLastIndex(item => item is NativeContextMenuItem {
            InternalAction: 0x01 or 0x4E or 0x11
        });
예제 #3
0
        private void OnOpenContextMenu(ContextMenuOpenArgs args)
        {
            if (args.ParentAddonName is not "ChatLog")
            {
                return;
            }

            if (args.ActorWorld is ushort.MaxValue or 0 || args.Text?.Payloads.Count != 1 ||
                args.Text?.Payloads[0] is not TextPayload textPayload)
            {
                return;
            }

            args.Items.Add(Plugin.PluginConfiguration.VoidList.SingleOrDefault(x =>
                                                                               x.Name == textPayload.Text && x.HomeworldId == args.ActorWorld) == null
                                ? new NormalContextMenuItem("添加至黑名单", AddToVoidList)
                                : new NormalContextMenuItem("从黑名单移除", RemoveFromVoidList));

            args.Items.Add(Plugin.PluginConfiguration.Whitelist.SingleOrDefault(x =>
                                                                                x.Name == textPayload.Text && x.HomeworldId == args.ActorWorld) == null
                                ? new NormalContextMenuItem("添加至白名单", AddToWhitelist)
                                : new NormalContextMenuItem("从白名单移除", RemoveFromWhitelist));
        }