Ejemplo n.º 1
0
        private void OnContextMenuOpened(InventoryContextMenuOpenArgs args)
        {
            if (!this.config.ContextMenuIntegration)
            {
                return;
            }

            var i = (uint)(GameGui.HoveredItem % 500000);

            var item = Data.Excel.GetSheet <Item>()?.GetRow(i);

            if (item == null)
            {
                return;
            }

            if (item.IsUntradable)
            {
                return;
            }

            if (args.ItemId == 0)
            {
                return;
            }

            args.AddCustomItem(this.inventoryContextMenuItem);
        }
Ejemplo n.º 2
0
        private void OnOpenInventoryContextMenu(InventoryContextMenuOpenArgs args)
        {
            if (!this.plugin.Configuration.ShowContextMenu)
            {
                return;
            }

            // setup
            var index     = 0;
            var actionIds = args.Items.Select(baseContextMenuItem => ((NativeContextMenuItem)baseContextMenuItem).InternalAction).ToList();

            // default
            if (this.plugin.Configuration.ShowContextAboveThis.Count == 0 &&
                this.plugin.Configuration.ShowContextBelowThis.Count == 0)
            {
                args.Items.Add(this.contextMenuItem);
                return;
            }

            // get show above index
            var relativeAboveIndex = GetActionIndex(this.plugin.Configuration.ShowContextAboveThis, actionIds);

            if (relativeAboveIndex != null)
            {
                index = (int)relativeAboveIndex;
                actionIds.RemoveRange(index, actionIds.Count - index);
            }

            // get show below index
            var relativeBelowIndex = GetActionIndex(this.plugin.Configuration.ShowContextBelowThis, actionIds);

            if (relativeBelowIndex != null)
            {
                index = (int)relativeBelowIndex + 1;
            }

            // default to bottom if nothing found
            if (relativeAboveIndex == null && relativeBelowIndex == null)
            {
                index = args.Items.Count;
            }

            // insert price check menu item
            args.Items.Insert(index, this.contextMenuItem);
        }