diff Modules/WorldState.lua @ 114:6748c98a6c6c

- Reworked OrderHallHandler triggers - OrderHallHandler minimializes hud info - WorldState currency headers have a unified font
author Nick@Zahhak
date Mon, 27 Mar 2017 00:39:29 -0400
parents 2105b6e5095f
children 8c94bee4fdfc
line wrap: on
line diff
--- a/Modules/WorldState.lua	Sun Mar 26 06:25:18 2017 -0400
+++ b/Modules/WorldState.lua	Mon Mar 27 00:39:29 2017 -0400
@@ -147,15 +147,56 @@
 function VeneerWorldStateMixin:OnMouseDown()
 end
 
+--- Order Hall mod
+local requiresUpdate
+local ocb
 function VeneerOrderHallMixin:Setup()
   print('|cFFFFFF00'..self:GetName()..':Setup()')
-  self:SetParent(OrderHallCommandBar)
-  self:RegisterEvent("UNIT_AURA");
-  self:RegisterEvent("GARRISON_FOLLOWER_CATEGORIES_UPDATED")
-  self:RegisterEvent("GARRISON_FOLLOWER_ADDED")
-  self:RegisterEvent("GARRISON_FOLLOWER_REMOVED")
+  ocb = OrderHallCommandBar
+  hooksecurefunc(ocb, 'RefreshCategories', function()
+    requiresUpdate = true
+  end)
+  hooksecurefunc(ocb, 'RefreshCurrency',
+    function()
+      requiresUpdate = true
+    end)
+  hooksecurefunc(ocb, 'SetShown', function(isShown)
+    self:SetShown(isShown)
+  end)
+  hooksecurefunc(ocb, 'RefreshAll', function()
+    self:Update()
+  end)
 
-  self:SetShown(true)
+  ocb:ClearAllPoints()
+  ocb:SetAllPoints(self)
+
+
+  ocb.WorldMapButton:Hide()
+  ocb.AreaName:Hide()
+
+  ocb.Currency:SetFontObject(VeneerHeaderFont)
+  ocb.Currency:ClearAllPoints()
+  ocb.Currency:SetPoint('BOTTOMLEFT', ocb.ClassIcon, 'BOTTOMRIGHT', 15, 0)
+
+  ocb.CurrencyIcon:ClearAllPoints()
+  ocb.CurrencyIcon:SetPoint('TOP', ocb.ClassIcon, 'TOPRIGHT')
+  
+  ocb.Background:SetColorTexture(0,0,0,0.5)
+
+  -- frame that calls up the resources tooltip
+  ocb.CurrencyHitTest:SetPoint('LEFT', ocb.CurrencyIcon, 'LEFT')
+  ocb.CurrencyHitTest:SetPoint('RIGHT', ocb.Currency, 'RIGHT')
+  
+  
+  self:SetSize(700, 23)
+  self:SetShown(ocb:IsShown())
+end
+
+function VeneerOrderHallMixin:OnUpdate()
+  if requiresUpdate then
+    self:Update()
+  end
+  
 end
 
 function VeneerOrderHallMixin:OnLoad()
@@ -163,54 +204,45 @@
   self:EnableMouse(false)
 end
 
-function VeneerOrderHallMixin:OnEvent(event, ...)
-
-  print('|cFF00AAFF'..self:GetName()..'|r:'.. event, ...)
-  self:Update()
-end
 
 function VeneerOrderHallMixin:OnShow()
-  if OrderHallCommandBar then
-    print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', OrderHallCommandBar:IsShown(), self:IsShown())
+  if ocb then
+    --self:Print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', ocb:IsShown(), self:IsShown())
     self:Update()
   end
-  Veneer:DynamicReanchor()
-end
-
-function VeneerOrderHallMixin:OnHide()
-  if OrderHallCommandBar then
-    print('|cFF00AAFF'..self:GetName()..'|r:OnHide()', OrderHallCommandBar:IsShown(), self:IsShown())
-  end
-  Veneer:Reanchor()
 end
 
 function VeneerOrderHallMixin:Update()
-  if not OrderHallCommandBar then
-    print('|cFFFF4400'..self:GetName()..' updater called without target')
-    return
-  end
-
-  OrderHallCommandBar:ClearAllPoints()
-  OrderHallCommandBar:SetAllPoints(self)
-
-  OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5)
-  OrderHallCommandBar.WorldMapButton:Hide()
-  OrderHallCommandBar:EnableMouse(false)
-  self:SetSize(700, 22)
-
+  self:SetShown(ocb:IsShown())
+  local lastFrame
+  local categoriesWidth = 0
   local troops = OrderHallCommandBar.TroopSummary
   if troops then
     for _, category in ipairs(troops) do
-      category.Count:SetFontObject(VeneerNumberFont)
+      category.Count:SetFontObject(VeneerHeaderFont)
+      category.Count:SetTextColor(1,1,1,1)
       category.Count:ClearAllPoints()
       category.Count:SetPoint('BOTTOMRIGHT', category.Icon, 'BOTTOMRIGHT', -1, 1)
+  
+      category:ClearAllPoints()
+      if lastFrame then
+        lastFrame:SetPoint('TOPRIGHT', category, 'TOPLEFT', 0, 0)
+      end
+      category:SetSize(category.TroopPortraitCover:GetSize())
+      
+      lastFrame = category
+      categoriesWidth = categoriesWidth + category:GetWidth()
+      end
+    
+    if lastFrame then
+      lastFrame:SetPoint('TOPRIGHT', ocb, 'TOPRIGHT', 0, 0)
     end
+    
   end
-  
-
-
-  print('|cFF00AAFF'..self:GetName()..'|r:Update()', OrderHallCommandBar:IsVisible(), self:IsShown())
-  print(debugstack(6))
+  self:SetWidth(ocb.ClassIcon:GetWidth() + 15 + ocb.Currency:GetWidth() + ocb.CurrencyIcon:GetWidth() + categoriesWidth)
+  requiresUpdate = nil
+  --print('|cFF00AAFF'..self:GetName()..'|r:Update()', OrderHallCommandBar:IsVisible(), self:IsShown())
+  --print(debugstack(6))
   Veneer:DynamicReanchor()
 end