I would imagine everyone probably does about the same thing. I think the only options would be to hook the setupCallback of the inventory row controls or just change the datatype for the pool and use your own template
(which would be more work and unnecessary for just adding an icon & it would probably mess every other addon up).
Here is what I do if it helps any:
Hook into the inventories row control setupCallback (this is for: backpack, bank, guildBank, but not the quest inventory)
Warning: Spoiler
Lua Code:
local function SetInventoryRowCallbacks()
-- Loop through each inventory
for k,v in pairs(PLAYER_INVENTORY.inventories) do
-- as long as the dataType exists & the listView is not the quest inventory
if (v.listView.dataTypes[1] and (v.listView:GetName() ~= "ZO_PlayerInventoryQuest")) then
-- save the current setupCallback for the row controls
local origCallback = v.listView.dataTypes[1].setupCallback
-- Create a new setupCallback for the row controls
v.listView.dataTypes[1].setupCallback = function(invRowControl, ...)
-- call your function to create an icon for this row
CreateResearchIcon(invRowControl)
CreateDestroyButton(invRowControl)
-- call the original callback for the row control
origCallback(invRowControl, ...)
end
end
end
end
Create the icon
(actually a button in this example):
Warning: Spoiler
Lua Code:
local function CreateDestroyButton(_cInvRowControl)
if not (_cInvRowControl and _cInvRowControl.dataEntry and _cInvRowControl.dataEntry.data) then return end
-- "Try" to grab the icon control you are wanting, It may already exist or not
local cCntrlIcon = _cInvRowControl:GetNamedChild("JunkItDestroyBtn")
-- Grab whatever other info you need
local iIconSize = JunkIt.iconSize
local cCntrlName = _cInvRowControl:GetNamedChild("Name")
local iBagId = _cInvRowControl.dataEntry.data.bagId
local iSlotId = _cInvRowControl.dataEntry.data.slotIndex
-- If the icon doesn't exist, create it --
if(not cCntrlIcon) then
cCntrlIcon = WINDOW_MANAGER:CreateControl(_cInvRowControl:GetName() .. "JunkItDestroyBtn", _cInvRowControl, CT_BUTTON)
-- Setup the icon: size, anchor, dimensions, handlers, whatever
cCntrlIcon:SetDimensions(iIconSize, iIconSize)
cCntrlIcon:ClearAnchors()
cCntrlIcon:SetAnchor(TOPLEFT, cCntrlName, TOPRIGHT, JunkIt.SavedVariables["INFOBUTTONOFFSETX"], 0)
cCntrlIcon:SetDrawLevel(1)
cCntrlIcon:SetNormalTexture(JunkIt.iconDestroy)
cCntrlIcon:SetHandler("OnClicked", function() DestoyItem(_cInvRowControl) end)
cCntrlIcon:SetClickSound("Click")
end
-- Do whatever code you need to decide if it should be hidden or not
-- This one is actually a button, so it gets enabled/disabled as well
if (IsItemJunk(iBagId, iSlotId) and JunkIt.SavedVariables["JUNKDESTROYER"]) then
cCntrlIcon:SetHidden(false)
cCntrlIcon:SetEnabled(true)
else
cCntrlIcon:SetHidden(true)
cCntrlIcon:SetEnabled(false)
end
end