diff Modules/Currency.lua @ 123:b3c0258b419d v7.3.0-1

ArtifactPower: - XP progress bar fixes Currency: - More argus stuff - Block dimensions are calculated more consistently TalkingHead - Aesthetic changes - Default right-click behaviour restored (hides the text box)
author Nenue
date Tue, 05 Sep 2017 02:56:33 -0400
parents ddfe19d70a34
children 3f4794dca91b
line wrap: on
line diff
--- a/Modules/Currency.lua	Mon Aug 21 22:15:46 2017 -0400
+++ b/Modules/Currency.lua	Tue Sep 05 02:56:33 2017 -0400
@@ -9,6 +9,11 @@
 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop
 local profileUpdate, needsUpdate
 
+
+local itemBlock =  {}
+local currencyBlock = {}
+
+
 local zoneEvents = {
   "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED"
 }
@@ -40,6 +45,12 @@
   },
   ["Nethershard"] = {
     currencyID = 1226,
+  },
+  ["Veiled Argunite"] = {
+    currencyID = 1508,
+  },
+  ["Argus Waystone"] = {
+    currencyID = 1506,
   }
 }
 local items, currencies = {}, {}
@@ -77,9 +88,11 @@
       frame[k] = v
     end
 
-    local debug = function(...)
+    frame.debug = function(...)
       print('|cFF0088FF<'..frame.name..'>|r', ...)
     end
+    frame.id = info.itemID or info.currencyID
+
 
     if info.itemID then
       local itemID = info.itemID
@@ -87,40 +100,22 @@
         count = 0,
         frame = frame
       }
-      frame.Update = function(block)
-        debug('Update [Item]')
-        if items[itemID].count >= 1 then
-          block.Icon:SetTexture(GetItemIcon(itemID))
-          block.Label:SetFormattedText("%d", items[itemID].count)
-          return true
-        end
-      end
+      frame.Update = itemBlock.Update
       RegisterEvents(self, itemEvents)
     elseif info.currencyID then
       local currencyID = info.currencyID
-      frame.Update = function (block)
-        debug('Update [Currency]')
-        local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(currencyID)
-        
-        block.Icon:SetTexture(texture)
-        if self.showMax then
-          block.Label:SetFormattedText("%d / %d", earned, totalMax)
-        else
-          block.Label:SetFormattedText("%d", earned)
-        end
-
-        block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth() + 6)
-        return true
-      end
-
+      frame.Update = currencyBlock.Update
       RegisterEvents(frame, currencyEvents)
     end
+
+
+
     if info.zones then
       RegisterEvents(frame, zoneEvents)
       local zones = info.zones
       local of = frame.Update
       frame.Update = function(block)
-        debug('Update [Zone]')
+        frame.debug('Update [Zone]')
         local zone = self.zoneText
         local canShow = (zone and block.zones[zone]) and true or false
         if of then
@@ -188,7 +183,7 @@
       lastBlock = block
 
       block:SetHeight(24)
-      block:SetWidth(block.Icon:GetWidth() + block.Label:GetWidth()+4)
+      block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth()+4)
       totalWidth = totalWidth + block:GetWidth()
     end
     print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize())
@@ -249,3 +244,26 @@
 function block:Setup()
 
 end
+function itemBlock:Update()
+  self.debug('Update [Item]')
+  if items[self.itemID].count >= 1 then
+    self.Icon:SetTexture(GetItemIcon(self.id))
+    self.Label:SetFormattedText("%d", items[self.id].count)
+    return true
+  end
+end
+
+function currencyBlock:Update()
+  self.debug('Update [Currency]')
+  local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(self.id)
+
+  self.Icon:SetTexture(texture)
+  if self.showMax then
+    self.Label:SetFormattedText("%d / %d", earned, totalMax)
+  else
+    self.Label:SetFormattedText("%d", earned)
+  end
+
+  --self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6)
+  return true
+end
\ No newline at end of file