Advertisement
Urtgard

CIMI_ArkInventory

Apr 19th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.17 KB | None | 0 0
  1. if IsAddOnLoaded("ArkInventory") then
  2.     function ArkInventoryItemButton_CIMIUpdateIcon(self)
  3.         if not self or not self:GetParent() then return end
  4.         if not CIMI_CheckOverlayIconEnabled(self) then
  5.             self.CIMIIconTexture:SetShown(false)
  6.             self:SetScript("OnUpdate", nil)
  7.             return
  8.         end
  9.         self = self:GetParent()
  10.         if ArkInventory.Frame_Item_GetDB(self) then
  11.             CIMI_SetIcon(self.CanIMogItOverlay, ArkInventoryItemButton_CIMIUpdateIcon, CanIMogIt:GetTooltipText(ArkInventory.Frame_Item_GetDB(self).h))
  12.         end
  13.     end
  14.  
  15.     function CIMI_ArkInventoryAddFrame(self, event, addonName)
  16.         if event ~= "PLAYER_LOGIN" and event ~= "BANKFRAME_OPENED" and not CIMIEvents[event] then return end
  17.         -- Add to frames
  18.         -- Bags
  19.         for i=1,NUM_CONTAINER_FRAMES do
  20.             for j=1,MAX_CONTAINER_ITEMS do
  21.                 local frame = _G["ARKINV_Frame1ScrollContainerBag"..i.."Item"..j]
  22.                 CIMI_AddToFrame(frame, ArkInventoryItemButton_CIMIUpdateIcon)
  23.             end
  24.         end
  25.         -- Bank
  26.         C_Timer.After(.5, function() CIMI_ArkInventoryAddBankFrame() end)
  27.     end
  28.     hooksecurefunc(CanIMogIt.frame, "HookItemOverlay", CIMI_ArkInventoryAddFrame)
  29.  
  30.     function CIMI_ArkInventoryEvents(self, event, ...)
  31.         if not CIMIEvents[event] then return end
  32.         -- Update event
  33.         CIMI_ArkInventoryUpdate()
  34.     end
  35.     hooksecurefunc(CanIMogIt.frame, "ItemOverlayEvents", CIMI_ArkInventoryEvents)
  36.  
  37.     function CIMI_ArkInventoryUpdate()
  38.         for i=1,NUM_CONTAINER_FRAMES do
  39.             for j=1,MAX_CONTAINER_ITEMS do
  40.                 local frame = _G["ARKINV_Frame1ScrollContainerBag"..i.."Item"..j]
  41.                 if frame then
  42.                     C_Timer.After(.5, function() ArkInventoryItemButton_CIMIUpdateIcon(frame.CanIMogItOverlay) end)
  43.                 end
  44.             end
  45.         end
  46.         for i=1,8 do
  47.             for j=1,MAX_CONTAINER_ITEMS do
  48.                 local frame = _G["ARKINV_Frame3ScrollContainerBag"..i.."Item"..j]
  49.                 if frame then
  50.                     C_Timer.After(.5, function() ArkInventoryItemButton_CIMIUpdateIcon(frame.CanIMogItOverlay) end)
  51.                 end
  52.             end
  53.         end
  54.     end
  55.  
  56.     -- If you change characters or open the bank/bags with ArkInventory
  57.     local ArkInventoryChange_IsHooked = nil
  58.     local function CIMI_ArkInventoryHook()
  59.         if ArkInventoryChange_IsHooked == nil then
  60.             ArkDewdrop30102Level0:HookScript("OnHide", function() CIMI_ArkInventoryUpdate(); C_Timer.After(.5, function() CIMI_ArkInventoryAddBankFrame() end) end)
  61.             ArkInventoryChange_IsHooked = true
  62.         end
  63.     end
  64.     ARKINV_Frame1TitleActionButton5:HookScript("OnClick", CIMI_ArkInventoryHook)
  65.     ARKINV_Frame1TitleActionButton6:HookScript("OnClick", CIMI_ArkInventoryHook)
  66.  
  67.     function CIMI_ArkInventoryAddBankFrame()
  68.         for i=1,8 do
  69.             for j=1,MAX_CONTAINER_ITEMS do
  70.                 local frame = _G["ARKINV_Frame3ScrollContainerBag"..i.."Item"..j]
  71.                 CIMI_AddToFrame(frame, ArkInventoryItemButton_CIMIUpdateIcon)
  72.             end
  73.         end
  74.     end      
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement