Nenue@80: -- Veneer Nenue@84: -- WorldState.lua Nenue@80: -- Created: 10/7/2016 10:55 PM Nenue@80: -- %file-revision% Nick@113: -- An extensible panel group for HUD values Nenue@80: Nenue@97: local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop Nenue@115: Nenue@87: VeneerOrderHallMixin = { Nenue@87: anchorPoint = 'TOP', Nenue@90: anchorFrom = 'TOP', Nick@113: anchorPriority = 1, Nenue@90: anchorX = 0, Nenue@90: anchorY = 0, Nenue@90: addonTrigger = 'Blizzard_OrderHallUI', Nenue@90: addonFrame = 'OrderHallCommandBar', Nenue@87: } Nick@114: --- Order Hall mod Nick@114: local requiresUpdate Nick@114: local ocb Nenue@87: function VeneerOrderHallMixin:Setup() Nenue@87: print('|cFFFFFF00'..self:GetName()..':Setup()') Nick@114: ocb = OrderHallCommandBar Nick@114: hooksecurefunc(ocb, 'RefreshCategories', function() Nick@114: requiresUpdate = true Nick@114: end) Nick@114: hooksecurefunc(ocb, 'RefreshCurrency', Nick@114: function() Nick@114: requiresUpdate = true Nick@114: end) Nenue@116: hooksecurefunc(ocb, 'SetShown', function(_, isShown) Nenue@116: if self:IsShown() ~= isShown then Nenue@116: self:SetShown(isShown) Nenue@116: Veneer:DynamicReanchor() Nenue@116: end Nick@114: end) Nick@114: hooksecurefunc(ocb, 'RefreshAll', function() Nick@114: self:Update() Nick@114: end) Nick@113: Nick@114: ocb:ClearAllPoints() Nick@114: ocb:SetAllPoints(self) Nick@114: Nick@114: Nick@114: ocb.WorldMapButton:Hide() Nick@114: ocb.AreaName:Hide() Nick@114: Nick@114: ocb.Currency:SetFontObject(VeneerHeaderFont) Nick@114: ocb.Currency:ClearAllPoints() Nick@114: ocb.Currency:SetPoint('BOTTOMLEFT', ocb.ClassIcon, 'BOTTOMRIGHT', 15, 0) Nick@114: Nick@114: ocb.CurrencyIcon:ClearAllPoints() Nick@114: ocb.CurrencyIcon:SetPoint('TOP', ocb.ClassIcon, 'TOPRIGHT') Nick@114: Nick@114: ocb.Background:SetColorTexture(0,0,0,0.5) Nick@114: Nick@114: -- frame that calls up the resources tooltip Nick@114: ocb.CurrencyHitTest:SetPoint('LEFT', ocb.CurrencyIcon, 'LEFT') Nick@114: ocb.CurrencyHitTest:SetPoint('RIGHT', ocb.Currency, 'RIGHT') Nick@114: Nick@114: Nick@114: self:SetSize(700, 23) Nenue@116: self:SetShown(C_Garrison.IsPlayerInGarrison(LE_GARRISON_TYPE_7_0)) Nick@114: end Nick@114: Nick@114: function VeneerOrderHallMixin:OnUpdate() Nick@114: if requiresUpdate then Nick@114: self:Update() Nick@114: end Nick@114: Nenue@88: end Nenue@88: Nenue@90: function VeneerOrderHallMixin:OnLoad() Nenue@115: Veneer:AddHandler(self) Nick@113: self:EnableMouse(false) Nenue@90: end Nenue@90: Nenue@88: Nenue@88: function VeneerOrderHallMixin:OnShow() Nick@114: if ocb then Nick@114: --self:Print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', ocb:IsShown(), self:IsShown()) Nenue@90: self:Update() Nenue@90: end Nenue@87: end Nenue@87: Nenue@87: function VeneerOrderHallMixin:Update() Nenue@116: self:SetShown(C_Garrison.IsPlayerInGarrison(LE_GARRISON_TYPE_7_0)) Nick@114: local lastFrame Nick@114: local categoriesWidth = 0 Nick@113: local troops = OrderHallCommandBar.TroopSummary Nick@113: if troops then Nick@113: for _, category in ipairs(troops) do Nick@114: category.Count:SetFontObject(VeneerHeaderFont) Nick@114: category.Count:SetTextColor(1,1,1,1) Nick@113: category.Count:ClearAllPoints() Nick@113: category.Count:SetPoint('BOTTOMRIGHT', category.Icon, 'BOTTOMRIGHT', -1, 1) Nick@114: Nick@114: category:ClearAllPoints() Nick@114: if lastFrame then Nick@114: lastFrame:SetPoint('TOPRIGHT', category, 'TOPLEFT', 0, 0) Nick@114: end Nick@114: category:SetSize(category.TroopPortraitCover:GetSize()) Nick@114: Nick@114: lastFrame = category Nick@114: categoriesWidth = categoriesWidth + category:GetWidth() Nick@114: end Nick@114: Nick@114: if lastFrame then Nick@114: lastFrame:SetPoint('TOPRIGHT', ocb, 'TOPRIGHT', 0, 0) Nick@113: end Nick@114: Nick@113: end Nick@114: self:SetWidth(ocb.ClassIcon:GetWidth() + 15 + ocb.Currency:GetWidth() + ocb.CurrencyIcon:GetWidth() + categoriesWidth) Nick@114: requiresUpdate = nil Nick@114: --print('|cFF00AAFF'..self:GetName()..'|r:Update()', OrderHallCommandBar:IsVisible(), self:IsShown()) Nick@114: --print(debugstack(6)) Nenue@98: Veneer:DynamicReanchor() Nenue@87: end Nenue@87: Nenue@80: Nenue@87: Nenue@87: