Mercurial > wow > buffalo2
diff 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 |
line wrap: on
line diff
--- a/Modules/WorldState.lua Mon Mar 27 00:39:29 2017 -0400 +++ b/Modules/WorldState.lua Tue Mar 28 07:02:26 2017 -0400 @@ -5,7 +5,7 @@ -- 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', @@ -15,138 +15,6 @@ 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 @@ -200,7 +68,7 @@ end function VeneerOrderHallMixin:OnLoad() - Veneer:AddHandler(self, 'TOP', 1) + Veneer:AddHandler(self) self:EnableMouse(false) end @@ -248,47 +116,4 @@ -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 - -