diff Modules/ArtifactPower.lua @ 125:3f4794dca91b

template load order and Script handlers linkage
author Nenue
date Sun, 15 Oct 2017 16:47:22 -0400
parents b3c0258b419d
children 9f2cf5609420
line wrap: on
line diff
--- a/Modules/ArtifactPower.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/ArtifactPower.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -315,11 +315,11 @@
 
 function Module:TryToShow()
 
-  print('|cFFFFFF00TryToShow()')
+  --print('|cFFFFFF00TryToShow()')
 
   if not InCombatLockdown() then
     for _, name in ipairs(FRAME_LIST) do
-      print('test:', name, (_G[name] and _G[name]:IsShown()))
+      --print('test:', name, (_G[name] and _G[name]:IsShown()))
       if _G[name] and _G[name]:IsVisible() then
         if self:IsShown() then
           self:Update()
@@ -331,13 +331,13 @@
     end
   end
 
-  print('failed tests')
+  --print('failed tests')
   self:Hide()
 end
 
 
 function Module:OnEvent(event, ...)
-  print('|cFF00FF88OnEvent()', event, ...)
+  --print('|cFF00FF88OnEvent()', event, ...)
   if event == 'PLAYER_ENTERING_WORLD' then
     self:TryToShow()
   elseif event == 'BAG_UPDATE' then
@@ -376,10 +376,12 @@
       self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
       --self:ScanAllBags(self.bankAccess)
     end
+    self:UpdateArtifactButtons()
   elseif event == 'ARTIFACT_XP_UPDATE' then
     local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo()
     self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
     --self:ScanAllBags(self.bankAccess)
+    self:UpdateArtifactButtons()
   elseif event == 'PLAYER_REGEN_ENABLED' then
 
     if self.queuedScan then
@@ -559,8 +561,10 @@
     numButtons = numButtons + 1
     button = self.Artifact[numButtons]
     button.relativeFrame = self
+    button:SetItem(self.equippedID, equipped, numButtons, true, nil)
+
     if self.equippedID ~= button.itemID then
-      button:SetItem(self.equippedID, equipped, numButtons, true, nil)
+
       hasArtifacts = true
     end
     lastFrame = button
@@ -589,9 +593,7 @@
           numButtons = numButtons + 1
           button = self.Artifact[numButtons]
           button.relativeFrame = lastFrame
-          if button.itemID ~= itemID then
-            button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
-          end
+          button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
           lastFrame = button
           buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING
         end
@@ -791,7 +793,6 @@
   local artifacts = self.profile.artifacts
 
   if itemID then
-    self.currentEquipped = itemID
 
     artifacts[itemID] = artifacts[itemID] or {}
     table.wipe(artifacts[itemID])
@@ -807,14 +808,10 @@
     print('tier', artifact.tier)
     local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier)
     artifact.currentCost = cost
+  end
 
-    for index, frame in pairs(self.Artifact) do
-      if frame.itemID == itemID then
-        frame:SetItem(itemID, artifact, index, (itemID == self.equippedID), (itemID == UNDERLIGHT_ANGLER_ID))
-      end
-    end
-
-  end
+  local equippedID = C_ArtifactUI:GetEquippedArtifactInfo()
+  self.currentEquipped = equippedID
 end
 
 function Module:ScanBag(id)
@@ -920,6 +917,8 @@
     end
   end
 
+
+
   self.bankAP = 0
   self.bagAP = 0
   self.fishingAP = 0
@@ -1027,7 +1026,7 @@
   self.itemID = itemID
   self.isEquipped = equipped
   self:Update()
-  self:Show()
+  self:SetShown(true)
 
   return self
 end
@@ -1095,16 +1094,6 @@
 
 function Artifact:OnLoad()
   print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID())
-  self:RegisterEvent('ARTIFACT_UPDATE')
-  self:RegisterEvent('PLAYER_LOGIN')
-end
-
-function Artifact:OnEvent(event)
-  local itemID, _, _, nextCost = C_ArtifactUI.GetEquippedArtifactInfo()
-  print(self:GetID(), '|cFFFF4400OnEvent()|r', event, itemID, '=', self.itemID, (itemID == self.itemID))
-  if itemID == self.itemID then
-    self:Update()
-  end
 end
 
 function Artifact:Update()
@@ -1112,7 +1101,7 @@
     return
   end
 
-  print(self:GetName(), '|ff00FFFFUpdate()|r')
+  print(self:GetName(), '|cff00FFFFUpdate()|r')
   local r1, g1, b1 = 1, 1, 1  -- top text
   local r2, g2, b2 = 1, 1, 0  -- bottom text
   local levelText = self.level