View Single Post
04-25-17, 01:41 AM   #19
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
This should handle hiding/showing (admitedly untested), collapsing/expanding would still have to be handled:
Lua Code:
  1. --Beam Me Up Deja Initialization Frame
  2.    
  3. local Ecount
  4. local Rcount
  5. local Ucount
  6. local Tally
  7.  
  8. local BeamMeUpDejaInitFrame = CreateFrame("Frame", "BeamMeUpDejaInitFrame", BeamMeUpDejaDragFrame)
  9.     BeamMeUpDejaInitFrame.Beacons = ()
  10.     BeamMeUpDejaInitFrame:RegisterEvent("PLAYER_LOGIN")
  11.     BeamMeUpDejaInitFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
  12.     BeamMeUpDejaInitFrame:RegisterEvent("LOOT_OPENED")
  13.     BeamMeUpDejaInitFrame:RegisterEvent("BAG_UPDATE")
  14.    
  15.     BeamMeUpDejaInitFrame:SetScript("OnEvent", function(self, event, ...)
  16.         for k,v in pairs(self.Beacons) do
  17.             v:Hide()
  18.         end
  19.         Ecount = 0
  20.         Rcount = 0
  21.         Ucount = 0 
  22.         Tally = 0
  23.         for bag = 0, 4, 1 do
  24.             for slot=1, GetContainerNumSlots(bag), 1 do
  25.                 local name = GetContainerItemLink(bag,slot)
  26.                 if name and string.find(name,"Sentinax Beacon") then
  27. --              if name and string.find(name,"Hearthstone") then
  28.                     --ddebug()
  29.                     local _, itemCount = GetContainerItemInfo(bag, slot)
  30.                     Tally = Tally + itemCount
  31.                     local itemName, itemLink, itemRarity,_,_,_,_,itemStackCount,_,itemTexture,_ = GetItemInfo(name)
  32.                         --print(name, itemName,itemStackCount)--Debugging
  33.                     local texture = select(10,GetItemInfo(name))
  34.                     local w = 36
  35.                     local h = 36
  36.                     local x
  37.                     local y = 0
  38.                     if itemRarity == 4 then
  39.                         --print("Ecount is "..Ecount)--Debugging
  40.                         x = (Ecount*w)*1.1
  41.                         y = h*2.1
  42.                         Ecount = Ecount+1
  43.                     end
  44.                     if itemRarity == 3 then
  45.                         --print("Rcount is "..Rcount)--Debugging
  46.                         x = (Rcount*w)*1.1
  47.                         y = h*1.1
  48.                         Rcount = Rcount+1
  49.                     end
  50.                     if itemRarity == 2 then
  51.                         --print("Ucount is "..Ucount)--Debugging
  52.                         x = (Ucount*w)*1.1
  53.                         Ucount = Ucount+1
  54.                     end
  55.                     local BMUDButton
  56.                     if not _G["BMUDButton"..name] then -- Button does not exist so create it
  57.                         BMUDButton = CreateFrame("Button", "BMUDButton"..name, UIParent, "SecureActionButtonTemplate");
  58.                         self.Beacons["BMUDButton"..name] = BMUDButton
  59.                         BMUDButton.Label = BMUDButton:CreateFontString("$parent_FontString","OVERLAY")
  60.                         BMUDButton:RegisterForClicks("AnyUp", "AnyDown")
  61.                         BMUDButton:SetPoint("CENTER",x,y+32)
  62.                         BMUDButton:SetSize(w,h)
  63.                         BMUDButton.Label:SetPoint("BOTTOMRIGHT", BMUDButton)
  64.                         BMUDButton.Label:SetFont("Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE")
  65.                         BMUDButton.Label:SetTextColor(1, 1, 1);
  66.                         BMUDButton:SetAttribute("type","item")
  67.                         BMUDButton:SetAttribute("item",itemName)
  68.                         BMUDButton:HookScript("OnEnter", function(self)
  69.                                 GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  70.                                 GameTooltip:SetHyperlink(name)
  71.                                 GameTooltip:Show()
  72.                             end)
  73.                         BMUDButton:HookScript("OnLeave", function(self) GameTooltip:Hide() end)
  74.                     else -- Button exists so reset to default state
  75.                         BMUDButton = _G["BMUDButton"..name]
  76.                         BMUDButton:SetNormalTexture(nil,"ARTWORK")
  77.                         BMUDButton:SetPushedTexture(nil,"ARTWORK")
  78.                         BMUDButton:SetHighlightTexture(nil,"ARTWORK")
  79.                         BMUDButton.Label:SetFormattedText("")
  80.  
  81.                     end
  82.                     if event == "BAG_UPDATE" then -- only set textures and text for this event
  83.                         BMUDButton.Label:SetFormattedText("%.0f", Tally)
  84.                         BMUDButton:SetNormalTexture(itemTexture)
  85.                         BMUDButton:SetPushedTexture(itemTexture)
  86.                         BMUDButton:SetHighlightTexture(itemTexture)
  87.                         BMUDButton:Show()
  88.                         print("Bag Updated", name, BMUDButton.Label:GetText())
  89.                     else
  90.                         print("Other event", event, name)
  91.                     end
  92.                 end
  93.             end
  94.         end
  95.     end)

There is now code that is surplus to requirements
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-25-17 at 01:47 AM.
  Reply With Quote