annotate Modules/WorldState.lua @ 115:8c94bee4fdfc

- AddHandler simplified - Centralized combat start/stop hooks - WorldState removed
author Nenue
date Tue, 28 Mar 2017 07:02:26 -0400
parents 6748c98a6c6c
children ddfe19d70a34
rev   line source
Nenue@80 1 -- Veneer
Nenue@84 2 -- WorldState.lua
Nenue@80 3 -- Created: 10/7/2016 10:55 PM
Nenue@80 4 -- %file-revision%
Nick@113 5 -- An extensible panel group for HUD values
Nenue@80 6
Nenue@97 7 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop
Nenue@115 8
Nenue@87 9 VeneerOrderHallMixin = {
Nenue@87 10 anchorPoint = 'TOP',
Nenue@90 11 anchorFrom = 'TOP',
Nick@113 12 anchorPriority = 1,
Nenue@90 13 anchorX = 0,
Nenue@90 14 anchorY = 0,
Nenue@90 15 addonTrigger = 'Blizzard_OrderHallUI',
Nenue@90 16 addonFrame = 'OrderHallCommandBar',
Nenue@87 17 }
Nick@114 18 --- Order Hall mod
Nick@114 19 local requiresUpdate
Nick@114 20 local ocb
Nenue@87 21 function VeneerOrderHallMixin:Setup()
Nenue@87 22 print('|cFFFFFF00'..self:GetName()..':Setup()')
Nick@114 23 ocb = OrderHallCommandBar
Nick@114 24 hooksecurefunc(ocb, 'RefreshCategories', function()
Nick@114 25 requiresUpdate = true
Nick@114 26 end)
Nick@114 27 hooksecurefunc(ocb, 'RefreshCurrency',
Nick@114 28 function()
Nick@114 29 requiresUpdate = true
Nick@114 30 end)
Nick@114 31 hooksecurefunc(ocb, 'SetShown', function(isShown)
Nick@114 32 self:SetShown(isShown)
Nick@114 33 end)
Nick@114 34 hooksecurefunc(ocb, 'RefreshAll', function()
Nick@114 35 self:Update()
Nick@114 36 end)
Nick@113 37
Nick@114 38 ocb:ClearAllPoints()
Nick@114 39 ocb:SetAllPoints(self)
Nick@114 40
Nick@114 41
Nick@114 42 ocb.WorldMapButton:Hide()
Nick@114 43 ocb.AreaName:Hide()
Nick@114 44
Nick@114 45 ocb.Currency:SetFontObject(VeneerHeaderFont)
Nick@114 46 ocb.Currency:ClearAllPoints()
Nick@114 47 ocb.Currency:SetPoint('BOTTOMLEFT', ocb.ClassIcon, 'BOTTOMRIGHT', 15, 0)
Nick@114 48
Nick@114 49 ocb.CurrencyIcon:ClearAllPoints()
Nick@114 50 ocb.CurrencyIcon:SetPoint('TOP', ocb.ClassIcon, 'TOPRIGHT')
Nick@114 51
Nick@114 52 ocb.Background:SetColorTexture(0,0,0,0.5)
Nick@114 53
Nick@114 54 -- frame that calls up the resources tooltip
Nick@114 55 ocb.CurrencyHitTest:SetPoint('LEFT', ocb.CurrencyIcon, 'LEFT')
Nick@114 56 ocb.CurrencyHitTest:SetPoint('RIGHT', ocb.Currency, 'RIGHT')
Nick@114 57
Nick@114 58
Nick@114 59 self:SetSize(700, 23)
Nick@114 60 self:SetShown(ocb:IsShown())
Nick@114 61 end
Nick@114 62
Nick@114 63 function VeneerOrderHallMixin:OnUpdate()
Nick@114 64 if requiresUpdate then
Nick@114 65 self:Update()
Nick@114 66 end
Nick@114 67
Nenue@88 68 end
Nenue@88 69
Nenue@90 70 function VeneerOrderHallMixin:OnLoad()
Nenue@115 71 Veneer:AddHandler(self)
Nick@113 72 self:EnableMouse(false)
Nenue@90 73 end
Nenue@90 74
Nenue@88 75
Nenue@88 76 function VeneerOrderHallMixin:OnShow()
Nick@114 77 if ocb then
Nick@114 78 --self:Print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', ocb:IsShown(), self:IsShown())
Nenue@90 79 self:Update()
Nenue@90 80 end
Nenue@87 81 end
Nenue@87 82
Nenue@87 83 function VeneerOrderHallMixin:Update()
Nick@114 84 self:SetShown(ocb:IsShown())
Nick@114 85 local lastFrame
Nick@114 86 local categoriesWidth = 0
Nick@113 87 local troops = OrderHallCommandBar.TroopSummary
Nick@113 88 if troops then
Nick@113 89 for _, category in ipairs(troops) do
Nick@114 90 category.Count:SetFontObject(VeneerHeaderFont)
Nick@114 91 category.Count:SetTextColor(1,1,1,1)
Nick@113 92 category.Count:ClearAllPoints()
Nick@113 93 category.Count:SetPoint('BOTTOMRIGHT', category.Icon, 'BOTTOMRIGHT', -1, 1)
Nick@114 94
Nick@114 95 category:ClearAllPoints()
Nick@114 96 if lastFrame then
Nick@114 97 lastFrame:SetPoint('TOPRIGHT', category, 'TOPLEFT', 0, 0)
Nick@114 98 end
Nick@114 99 category:SetSize(category.TroopPortraitCover:GetSize())
Nick@114 100
Nick@114 101 lastFrame = category
Nick@114 102 categoriesWidth = categoriesWidth + category:GetWidth()
Nick@114 103 end
Nick@114 104
Nick@114 105 if lastFrame then
Nick@114 106 lastFrame:SetPoint('TOPRIGHT', ocb, 'TOPRIGHT', 0, 0)
Nick@113 107 end
Nick@114 108
Nick@113 109 end
Nick@114 110 self:SetWidth(ocb.ClassIcon:GetWidth() + 15 + ocb.Currency:GetWidth() + ocb.CurrencyIcon:GetWidth() + categoriesWidth)
Nick@114 111 requiresUpdate = nil
Nick@114 112 --print('|cFF00AAFF'..self:GetName()..'|r:Update()', OrderHallCommandBar:IsVisible(), self:IsShown())
Nick@114 113 --print(debugstack(6))
Nenue@98 114 Veneer:DynamicReanchor()
Nenue@87 115 end
Nenue@87 116
Nenue@80 117
Nenue@87 118
Nenue@87 119