Mercurial > wow > buffalo2
view 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 source
-- Veneer -- WorldState.lua -- Created: 10/7/2016 10:55 PM -- %file-revision% -- An extensible panel group for HUD values local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop local WorldStateBlockMixin = {} VeneerOrderHallMixin = { anchorPoint = 'TOP', anchorFrom = 'TOP', anchorPriority = 1, anchorX = 0, anchorY = 0, addonTrigger = 'Blizzard_OrderHallUI', addonFrame = 'OrderHallCommandBar', } VeneerWorldStateMixin = { maxHeight = 0, detectedFrames = {}, anchorPoint = 'TOP', modules = {} } function VeneerWorldStateMixin:Reset() for i, frame in ipairs(self.modules) do if frame.Reset then frame:Reset() end end self:Update() end function VeneerWorldStateMixin:Setup() --DEFAULT_CHAT_FRAME:AddMessage('Loaded') print('|cFFFFFF00'..self:GetName()..'|r:Setup()') for i, frame in ipairs(self.modules) do print('--'.. frame:GetName()..' exists') if frame.Setup then print('--'.. frame:GetName()..':Setup()') frame:Setup() end for k,v in pairs(WorldStateBlockMixin) do if not frame[k] then frame[k] = v if k:match('^On') then frame:SetScript(k, v) end end end end self:UnregisterEvent('PLAYER_LOGIN') end function VeneerWorldStateMixin:SetOrderHallUIMods() print('|cFFFF4400remove me', debugstack()) end function VeneerWorldStateMixin:OnLoad () self.modules = {self:GetChildren()} print('|cFFFFFF00'..self:GetName()..'|r!') self:RegisterEvent('PLAYER_ENTERING_WORLD') self:RegisterEvent('PLAYER_REGEN_ENABLED') self:RegisterEvent('PLAYER_REGEN_DISABLED') Veneer:AddHandler(self, self.anchorPoint, self.anchorPriority) SLASH_VENEERWORLDSTATE1 = "/vws" SLASH_VENEERWORLDSTATE2 = "/worldstate" SlashCmdList.VENEERWORLDSTATE = function() self:Reset() end end function VeneerWorldStateMixin:OnEvent(event, arg) print(event, arg) if event == 'PLAYER_ENTERING_WORLD' then self:Update() elseif event == 'PLAYER_REGEN_ENABLED' then self:Update(true) elseif event == 'PLAYER_REGEN_DISABLED' then self:Update(true) end end function VeneerWorldStateMixin:Update(isBatchUpdate) print('|cFFFFFF00All:Update()|r') local canShow = false for index, frame in ipairs(self.modules) do if frame.Update then print(' '..index..' |cFFFF00FFUpdate:|r '.. frame:GetName()) frame:Update(isBatchUpdate) print(' ', frame:IsVisible(), frame:IsShown()) if frame:IsShown() then canShow = true end end end self:SetShown(canShow) end function VeneerWorldStateMixin:OnShow() print('OnShow()', debugstack()) end function VeneerWorldStateMixin:Reanchor(isUpdate) print(' |cFF0088FF'..self:GetName()..':Reanchor()|r', #self.modules, 'blocks') self.maxHeight = 0 local lastFrame for i, frame in ipairs(self.modules) do print(' '..frame:GetName()..':',frame:IsShown(), frame:GetHeight()) if frame:IsShown() then if lastFrame then frame:SetPoint('TOP', lastFrame, 'BOTTOM') else frame:SetPoint('TOP', self, 'TOP') end self.maxHeight = self.maxHeight + frame:GetHeight() lastFrame = frame end end if (self.maxHeight == 0) or InCombatLockdown() then print (' hiding; combat =', InCombatLockdown()) self:SetShown(false) else print (' height update:', self.maxHeight) self:SetHeight(self.maxHeight) self:SetShown(true) end if not isUpdate then Veneer:InternalReanchor(self, print) end WorldStateAlwaysUpFrame:ClearAllPoints() WorldStateAlwaysUpFrame:SetPoint('TOP', self, 'BOTTOM', 0, 0) end function VeneerWorldStateMixin:OnMouseDown() end --- Order Hall mod local requiresUpdate local ocb function VeneerOrderHallMixin:Setup() print('|cFFFFFF00'..self:GetName()..':Setup()') 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) 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() Veneer:AddHandler(self, 'TOP', 1) self:EnableMouse(false) end function VeneerOrderHallMixin:OnShow() if ocb then --self:Print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', ocb:IsShown(), self:IsShown()) self:Update() end end function VeneerOrderHallMixin:Update() 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(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 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 do function WorldStateBlockMixin:ShowPanel() print('|cFF0088FF'..self:GetName()..':ShowPanel()') self:SetShown(true) self:SetAlpha(1) VeneerWorldState:Show() end function WorldStateBlockMixin:HidePanel() print('|cFF0088FF'..self:GetName()..':HidePanel()') self:SetShown(false) VeneerWorldState:Reanchor() end function WorldStateBlockMixin:OnSizeChanged () local h = self:GetHeight() if h > VeneerWorldState.maxHeight then VeneerWorldState.maxHeight = h VeneerWorldState:SetHeight(h) print('updating max height:', h) elseif h < VeneerWorldState.maxHeight then VeneerWorldState:Reanchor() end end function WorldStateBlockMixin:OnHide () print('|cFF0088FF'..self:GetName()..':OnHide()') VeneerWorldState:Reanchor() end function WorldStateBlockMixin:OnShow () self.timeLived = 0 print('|cFF0088FF'..self:GetName()..':OnShow()') VeneerWorldState:Reanchor() end function WorldStateBlockMixin:Setup() print('|cFF0088FF'..self:GetName()..':Setup()|r -- nop') self:Update() end function WorldStateBlockMixin:Reset() print('|cFF0088FF'..self:GetName()..':Reset()') self.keepOpen = true self:Setup() end end