View Single Post
11/07/16, 04:41 PM   #13
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Sounds good. If you ever get to change the menu system, maybe you could also make it a bit easier for addons to change the behavior of an existing entry.

In the current system this is the simplest way I could come up with to change the primary action of the craft bag item actions for AGS' direct selling feature
Lua Code:
  1. local oAddSlotAction = ZO_InventorySlotActions.AddSlotAction
  2.  
  3. local currentInventorySlot
  4. ZO_PreHook("ZO_InventorySlot_DiscoverSlotActionsFromActionList", function(inventorySlot, slotActions) currentInventorySlot = inventorySlot end)
  5.  
  6. -- prepare AddSlotAction in order to redirect the action
  7. ZO_InventorySlotActions.AddSlotAction = function(slotActions, actionStringId, actionCallback, actionType, visibilityFunction, options)
  8.     if(actionStringId == SI_ITEM_ACTION_REMOVE_ITEMS_FROM_CRAFT_BAG and TRADING_HOUSE:IsAtTradingHouse()) then
  9.         if(self:IsItemAlreadyBeingPosted(currentInventorySlot)) then
  10.             actionStringId = SI_TRADING_HOUSE_REMOVE_PENDING_POST
  11.             actionCallback = function()
  12.                 self:ClearPendingItem()
  13.                 ZO_InventorySlot_OnMouseEnter(currentInventorySlot)
  14.             end
  15.         else
  16.             actionStringId = SI_TRADING_HOUSE_ADD_ITEM_TO_LISTING
  17.             actionCallback = function() TryInitiatingItemPost(currentInventorySlot) end
  18.         end
  19.         actionType = "primary"
  20.     end
  21.     oAddSlotAction(slotActions, actionStringId, actionCallback, actionType, visibilityFunction, options)
  22. end
  Reply With Quote