Quantcast
WoWInterface - View Single Post - Bag Help
Thread: Bag Help
View Single Post
07-24-16, 12:00 PM   #1
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Bag Help

Hi, so i've been trying to figure out what's causing the freeze when i open my bags it was my border AddOn.. Although i don't think it's that since its working fine on everything else.

If anyone have some idea what could cause it or how to make the border code run smoother or so, i would be very happy with that


Lua Code:
  1. BORDER ADDON ------------------------------------------------------------------------------------------
  2.  
  3. function CreateBorderLight(self, borderSize, R, G, B, ...)
  4.  
  5.     local uL1, uL2, uR1, uR2, bL1, bL2, bR1, bR2 = ...
  6.     if (uL1) then
  7.         if (not uL2 and not uR1 and not uR2 and not bL1 and not bL2 and not bR1 and not bR2) then
  8.             uL2, uR1, uR2, bL1, bL2, bR1, bR2 = uL1, uL1, uL1, uL1, uL1, uL1, uL1
  9.         end
  10.     end
  11.    
  12.     if (not self.HasBorder) then
  13.         self.Border = {}
  14.         for i = 1, 8 do
  15.             self.Border[i] = self:CreateTexture(nil, "OVERLAY")
  16.             self.Border[i]:SetParent(self)
  17.             self.Border[i]:SetTexture(AftermathhUI.media.borderlight)
  18.             self.Border[i]:SetSize(borderSize,borderSize)
  19.             self.Border[i]:SetVertexColor(R, G, B)
  20.         end
  21.        
  22.         self.Border[1]:SetTexCoord(0, 1/3, 0, 1/3)
  23.         self.Border[1]:SetPoint("TOPLEFT", self, -(uL1 or 0), uL2 or 0)
  24.  
  25.         self.Border[2]:SetTexCoord(2/3, 1, 0, 1/3)
  26.         self.Border[2]:SetPoint("TOPRIGHT", self, uR1 or 0, uR2 or 0)
  27.  
  28.         self.Border[3]:SetTexCoord(0, 1/3, 2/3, 1)
  29.         self.Border[3]:SetPoint("BOTTOMLEFT", self, -(bL1 or 0), -(bL2 or 0))
  30.  
  31.         self.Border[4]:SetTexCoord(2/3, 1, 2/3, 1)
  32.         self.Border[4]:SetPoint("BOTTOMRIGHT", self, bR1 or 0, -(bR2 or 0))
  33.  
  34.         self.Border[5]:SetTexCoord(1/3, 2/3, 0, 1/3)
  35.         self.Border[5]:SetPoint("TOPLEFT", self.Border[1], "TOPRIGHT")
  36.         self.Border[5]:SetPoint("TOPRIGHT", self.Border[2], "TOPLEFT")
  37.  
  38.         self.Border[6]:SetTexCoord(1/3, 2/3, 2/3, 1)
  39.         self.Border[6]:SetPoint("BOTTOMLEFT", self.Border[3], "BOTTOMRIGHT")
  40.         self.Border[6]:SetPoint("BOTTOMRIGHT", self.Border[4], "BOTTOMLEFT")
  41.  
  42.         self.Border[7]:SetTexCoord(0, 1/3, 1/3, 2/3)
  43.         self.Border[7]:SetPoint("TOPLEFT", self.Border[1], "BOTTOMLEFT")
  44.         self.Border[7]:SetPoint("BOTTOMLEFT", self.Border[3], "TOPLEFT")
  45.  
  46.         self.Border[8]:SetTexCoord(2/3, 1, 1/3, 2/3)
  47.         self.Border[8]:SetPoint("TOPRIGHT", self.Border[2], "BOTTOMRIGHT")
  48.         self.Border[8]:SetPoint("BOTTOMRIGHT", self.Border[4], "TOPRIGHT")
  49.        
  50.         local space
  51.         if (borderSize >= 10) then
  52.             space = 3
  53.         else
  54.             space = borderSize/3.5
  55.         end
  56.  
  57.         self.Shadow = {}      
  58.         for i = 1, 8 do
  59.             self.Shadow[i] = self:CreateTexture(nil, "BORDER")
  60.             self.Shadow[i]:SetParent(self)
  61.             self.Shadow[i]:SetTexture(AftermathhUI.media.shadow)
  62.             self.Shadow[i]:SetSize(borderSize, borderSize)  
  63.             self.Shadow[i]:SetVertexColor(0, 0, 0, 1)
  64.         end
  65.        
  66.         self.Shadow[1]:SetTexCoord(0, 1/3, 0, 1/3)
  67.         self.Shadow[1]:SetPoint("TOPLEFT", self, -(uL1 or 0)-space, (uL2 or 0)+space)
  68.  
  69.         self.Shadow[2]:SetTexCoord(2/3, 1, 0, 1/3)
  70.         self.Shadow[2]:SetPoint("TOPRIGHT", self, (uR1 or 0)+space, (uR2 or 0)+space)
  71.  
  72.         self.Shadow[3]:SetTexCoord(0, 1/3, 2/3, 1)
  73.         self.Shadow[3]:SetPoint("BOTTOMLEFT", self, -(bL1 or 0)-space, -(bL2 or 0)-space)
  74.  
  75.         self.Shadow[4]:SetTexCoord(2/3, 1, 2/3, 1)
  76.         self.Shadow[4]:SetPoint("BOTTOMRIGHT", self, (bR1 or 0)+space, -(bR2 or 0)-space)
  77.  
  78.         self.Shadow[5]:SetTexCoord(1/3, 2/3, 0, 1/3)
  79.         self.Shadow[5]:SetPoint("TOPLEFT", self.Shadow[1], "TOPRIGHT")
  80.         self.Shadow[5]:SetPoint("TOPRIGHT", self.Shadow[2], "TOPLEFT")
  81.  
  82.         self.Shadow[6]:SetTexCoord(1/3, 2/3, 2/3, 1)
  83.         self.Shadow[6]:SetPoint("BOTTOMLEFT", self.Shadow[3], "BOTTOMRIGHT")
  84.         self.Shadow[6]:SetPoint("BOTTOMRIGHT", self.Shadow[4], "BOTTOMLEFT")
  85.  
  86.         self.Shadow[7]:SetTexCoord(0, 1/3, 1/3, 2/3)
  87.         self.Shadow[7]:SetPoint("TOPLEFT", self.Shadow[1], "BOTTOMLEFT")
  88.         self.Shadow[7]:SetPoint("BOTTOMLEFT", self.Shadow[3], "TOPLEFT")
  89.  
  90.         self.Shadow[8]:SetTexCoord(2/3, 1, 1/3, 2/3)
  91.         self.Shadow[8]:SetPoint("TOPRIGHT", self.Shadow[2], "BOTTOMRIGHT")
  92.         self.Shadow[8]:SetPoint("BOTTOMRIGHT", self.Shadow[4], "TOPRIGHT")
  93.  
  94.         self.HasBorder = true
  95.     end
  96. end
  97.  
  98. function SetBorderLayer(self, layer)
  99.     if (self.Border) then
  100.         for i = 1, 8 do
  101.             self.Border[i]:SetDrawLayer(layer)
  102.         end
  103.     end
  104. end
  105.  
  106. function SetTexture(self, texture)
  107.     if (self.Border) then
  108.         for i = 1, 8 do
  109.             self.Border[i]:SetTexture(texture)
  110.         end
  111.     end
  112. end
  113.  
  114. function SetColorShadow(self, R, G, B, A)
  115.     if (self.Border) then
  116.         for i = 1, 8 do
  117.             self.Shadow[i]:SetVertexColor(R, G, B, A)
  118.         end        
  119.     end
  120. end
  121.    
  122. function ColorBorder(self, R, G, B)
  123.     if (self.Border) then
  124.         for i = 1, 8 do
  125.             self.Border[i]:SetVertexColor(R, G, B)
  126.         end        
  127.     end
  128. end
  129.  
  130. BAG ADDON ---------------------------------------------------------------
  131.  
  132. local _G = _G -- import globals for faster usage
  133.  
  134. for i = 1, 12 do
  135.     local AContainerFrameCloseButton = _G["ContainerFrame"..i.."CloseButton"]
  136.     AContainerFrameCloseButton:SetAlpha(0)
  137.    
  138.     for p = 1, 7 do
  139.         local AContainerFrame = _G["ContainerFrame"..i]
  140.         select(p, AContainerFrame:GetRegions()):SetAlpha(0)
  141.     end
  142. end
  143.  
  144. local AContainerFrameBackPack = CreateFrame("Frame", nil, _G["ContainerFrame1"])      
  145. AContainerFrameBackPack:SetPoint("TOPLEFT", 8, -9)
  146. AContainerFrameBackPack:SetPoint("BOTTOMRIGHT", -4, 3)
  147. AContainerFrameBackPack:SetFrameStrata("HIGH")
  148. AContainerFrameBackPack:SetFrameLevel(4)
  149. AContainerFrameBackPack:SetBackdrop({
  150.     bgFile = AftermathhUI.media.blank,
  151.     insets = {top = -1, left = 1, bottom = 1, right = 1},
  152. })
  153. AContainerFrameBackPack:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  154.  
  155. CreateBorderLight(AContainerFrameBackPack, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1, 1, 1, 1, 1, 1, 1, 1)
  156.  
  157. local AContainerFrameBagsRest = {"ContainerFrame2", "ContainerFrame3", "ContainerFrame4", "ContainerFrame5", "ContainerFrame6", "ContainerFrame7", "ContainerFrame8", "ContainerFrame9", "ContainerFrame10", "ContainerFrame11", "ContainerFrame12" }
  158. for i = 1, getn(AContainerFrameBagsRest) do
  159.    
  160.     local AContainerFrameBags = CreateFrame("Frame", nil, _G[AContainerFrameBagsRest[i]])
  161.     AContainerFrameBags:SetPoint("TOPLEFT", 8, -4)
  162.     AContainerFrameBags:SetPoint("BOTTOMRIGHT", -4, 3)
  163.     AContainerFrameBags:SetFrameStrata("HIGH")
  164.     AContainerFrameBags:SetFrameLevel(4)
  165.     AContainerFrameBags:SetBackdrop({
  166.         bgFile = AftermathhUI.media.blank,
  167.         insets = {top = -1, left = 1, bottom = 1, right = 1},
  168.     })
  169.     AContainerFrameBags:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  170.    
  171.     CreateBorderLight(AContainerFrameBags, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1, 1, 1, 1, 1, 2, 1, 2)
  172. end
  173.  
  174. hooksecurefunc("ContainerFrame_GenerateFrame", function(frame)
  175.     local name = frame:GetName();
  176.     for i = 1, MAX_CONTAINER_ITEMS do
  177.    
  178.         local AContainerItems = _G[name.."Item"..i]
  179.         AContainerItems:SetNormalTexture("")
  180.         AContainerItems:SetFrameStrata("HIGH")
  181.         AContainerItems:SetFrameLevel(5)
  182.         AContainerItems:SetBackdrop({
  183.             bgFile = AftermathhUI.media.backdrop,
  184.             insets = {top = -1, left = -1, bottom = -1, right = -1},
  185.         })
  186.        
  187.         --local AContainerIcon = _G[name.."Item"..i].icon
  188.         --AContainerIcon:SetTexCoord(.08, .92, .08, .92)
  189.        
  190.         local AContainerIconBorder = _G[name.."Item"..i].IconBorder
  191.         AContainerIconBorder:SetAlpha(0)
  192.         AContainerIconBorder:SetSize(0,0)
  193.        
  194.         local AContainerItemsIconQuest = _G[name.."Item"..i.."IconQuestTexture"]
  195.         AContainerItemsIconQuest:SetAlpha(0)
  196.        
  197.         local AContainerItemsCount = _G[name.."Item"..i.."Count"]
  198.         AContainerItemsCount:SetPoint("BOTTOMRIGHT", -3, 3)
  199.     end
  200. end)
  201.  
  202. for _, frame in pairs({
  203.     _G["ContainerFrame1MoneyFrameGoldButton"],_G["ContainerFrame1MoneyFrameSilverButton"],_G["ContainerFrame1MoneyFrameCopperButton"],_G["BankFrameMoneyFrameGoldButton"],_G["BankFrameMoneyFrameSilverButton"],_G["BankFrameMoneyFrameCopperButton"],
  204. }) do
  205.     frame:SetFrameStrata("HIGH")
  206.     frame:SetFrameLevel(5)
  207. end
  208.  
  209. for i = 1, 3 do
  210.     local ABackpackTokenFrameToken = _G["BackpackTokenFrameToken"..i]
  211.     ABackpackTokenFrameToken:SetFrameStrata("HIGH")
  212.     ABackpackTokenFrameToken:SetFrameLevel(5)
  213.    
  214.     local ABackpackTokenFrameTokenIcon = _G["BackpackTokenFrameToken"..i.."Icon"]
  215.     ABackpackTokenFrameTokenIcon:SetTexCoord(.08, .92, .08, .92)
  216. end
  217. _G["BackpackTokenFrame"]:GetRegions():SetAlpha(0)
  218. _G["BagItemAutoSortButton"]:SetAlpha(0)
  219.  
  220. local function UpdateGlow(button, id)
  221.     local quality, texture, _
  222.     if(id) then
  223.         quality, _, _, _, _, _, _, texture = select(3, GetItemInfo(id))
  224.     end
  225.    
  226.     local AGlow = button.glow
  227.     if(not AGlow) then
  228.         AGlow = CreateFrame("Frame", nil, button)
  229.         AGlow:SetPoint("TOPLEFT", button, "TOPLEFT")
  230.         AGlow:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT")
  231.         button.glow = AGlow
  232.     end
  233.    
  234.     CreateBorderLight(AGlow, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 1) -- what causes the freeze
  235.    
  236.     if(texture) then
  237.         local r, g, b = GetItemQualityColor(quality)
  238.         local AContainerIconQuest = _G[button:GetName().."IconQuestTexture"]
  239.         if AContainerIconQuest and AContainerIconQuest:IsShown() then
  240.             r, g, b = unpack(AftermathhUI.loot.questitemcolor)
  241.         end
  242.         ColorBorder(AGlow, r, g, b)
  243.     else
  244.         ColorBorder(AGlow, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor)
  245.     end
  246. end
  247.  
  248. hooksecurefunc("ContainerFrame_Update", function(self)
  249.     for i = 1, self.size do
  250.         local AContainerItemGlow = _G[self:GetName().."Item"..i]
  251.         UpdateGlow(AContainerItemGlow, GetContainerItemID(self:GetID(), AContainerItemGlow:GetID()))
  252.     end
  253.    
  254.     local ABagItemSearchBox = _G["BagItemSearchBox"]
  255.     ABagItemSearchBox:ClearAllPoints()
  256.     ABagItemSearchBox:SetWidth(165)
  257.     ABagItemSearchBox:SetHeight(22)
  258.     ABagItemSearchBox:SetPoint("TOPLEFT", _G["ContainerFrame1"], "BOTTOMLEFT", 18, 240)
  259.  
  260.     ABagItemSearchBox:SetFrameLevel(5)
  261.     ABagItemSearchBox:SetFrameStrata("HIGH")
  262.     ABagItemSearchBox:SetBackdrop({
  263.         bgFile = AftermathhUI.media.blank,
  264.         insets = {top = -1, left = -6, bottom = -1, right = -1},
  265.     })
  266.     ABagItemSearchBox:SetBackdropColor(.21, .21, .21, 0.7)
  267.  
  268.     CreateBorderLight(ABagItemSearchBox, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 6, 1, 1, 1, 6, 1, 1, 1)
  269.  
  270.     ABagItemSearchBox.Left:SetAlpha(0)
  271.     ABagItemSearchBox.Middle:SetAlpha(0)
  272.     ABagItemSearchBox.Right:SetAlpha(0)
  273. end)

Last edited by Aftermathhqt : 07-25-16 at 01:41 PM.
  Reply With Quote