Mercurial > wow > buffalo2
changeset 82:be813a9d99c0
- order of operations regarding frame visibility checking
- interaction with WorldPlan OrderHall module
- fancy shmancy transition fades resulting from above
author | Nenue |
---|---|
date | Mon, 17 Oct 2016 13:00:26 -0400 |
parents | 65ec88b30eb8 |
children | 4ec4fd89fced |
files | Modules/OrderHall.lua Veneer.xml |
diffstat | 2 files changed, 262 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/OrderHall.lua Mon Oct 17 04:57:32 2016 -0400 +++ b/Modules/OrderHall.lua Mon Oct 17 13:00:26 2016 -0400 @@ -7,12 +7,12 @@ VeneerWorldStateCurrencyMixin = {} VeneerWorldStateProgressMixin = {} VeneerWorldStateMixin = { + maxHeight = 0, detectedFrames = {} } local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop function VeneerWorldStateMixin:Setup() - self:Refresh() --DEFAULT_CHAT_FRAME:AddMessage('Loaded') print('All:Setup()') @@ -21,15 +21,44 @@ if frame.Setup then frame:Setup() end + + frame:SetScript('OnSizeChanged', function() + local h = frame:GetHeight() + if h > self.maxHeight then + self.maxHeight = h + self:SetHeight(h) + print('updating max height:', h) + elseif h < self.maxHeight then + self:UpdateSize() + end + end) + frame:SetScript('OnHide', function() + print('|cFF0088FF'..frame:GetName()..':OnHide()') + self:UpdateSize() + end) + frame:SetScript('OnShow', function() + frame.timeLived = 0 + print('|cFF0088FF'..frame:GetName()..':OnShow()') + self:UpdateSize() + end) + + function frame.ShowPanel(frame) + frame:SetShown(true) + self:Show() + end end + self:SetOrderHallUIMods() end -function VeneerWorldStateMixin:Refresh() +function VeneerWorldStateMixin:SetOrderHallUIMods() if OrderHallCommandBar then if not self.detectedFrames[OrderHallCommandBar] then self.detectedFrames[OrderHallCommandBar] = true hooksecurefunc(OrderHallCommandBar,'Show', function() - self:Refresh() + self:SetOrderHallUIMods() + end) + hooksecurefunc(OrderHallCommandBar,'Hide', function() + self:SetOrderHallUIMods() end) end @@ -40,8 +69,18 @@ OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5) OrderHallCommandBar.WorldMapButton:Hide() OrderHallCommandBar:EnableMouse(false) + + if OrderHallCommandBar:IsVisible() then + self:SetPoint('TOP', OrderHallCommandBar, 'BOTTOM') + print('anchoring to CommandBar') + else + self:SetPoint('TOP', UIParent, 'TOP') + print('anchoring to UIParent') + end + else + self:SetPoint('TOP', UIParent, 'TOP') + print('anchoring to UIParent') end - end local initialized function VeneerWorldStateMixin:OnEvent(event, arg) @@ -53,9 +92,11 @@ self:Setup() self:UnregisterEvent('PLAYER_LOGIN') end - end - - if event == 'PLAYER_ENTERING_WORLD' then + elseif event == 'ADDON_LOADED' then + if initialized and IsAddOnLoaded('Blizzard_OrderHallUI') then + self:SetOrderHallUIMods() + end + elseif event == 'PLAYER_ENTERING_WORLD' then self:Update() elseif event == 'PLAYER_REGEN_ENABLED' then self:Show() @@ -65,19 +106,38 @@ end function VeneerWorldStateMixin:Update() - self.modules = self.modules or {self:GetChildren()} + self.modules = {self:GetChildren()} print('|cFFFFFF00All:Update()|r') + print(self:GetChildren()) + for i, frame in ipairs(self.modules) do + if frame.Update then + print(' |cFFFF00FF'.. frame:GetName() .. ':Update()') + frame:Update() + end + end + self:SetOrderHallUIMods() +end + +function VeneerWorldStateMixin:UpdateSize() + print('|cFFFFFF00All:UpdateSize()|r') + print(self:GetChildren()) + self.modules = {self:GetChildren()} self.maxHeight = 0 for i, frame in ipairs(self.modules) do - if frame.Update then - print(frame:GetName()) - frame:Update() - if frame:IsVisible() then - self.maxHeight = max(self.maxHeight, frame.maxHeight) - end + print(' '..frame:GetName()..':',frame:IsShown(), frame:IsVisible(), frame:GetHeight()) + if frame:IsShown() then + self.maxHeight = max(self.maxHeight, frame:GetHeight()) end end - self:SetHeight(self.maxHeight) + if self.maxHeight == 0 then + print ('height zero') + self:Hide() + else + self:Show() + print ('height update:', self.maxHeight) + self:SetHeight(self.maxHeight) + end + end @@ -107,7 +167,7 @@ function VeneerWorldStateCurrencyMixin:Update() - print('currency refresh: zone =', mapID) + print(' Zone:', GetZoneText()) if GetZoneText() == 'Suramar' then local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(1155) @@ -115,75 +175,97 @@ self.Label:SetFormattedText("%d / %d", earned, totalMax) self:Show() self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6) + self:SetSize(200,16) else self:Hide() end - self.maxHeight = self:GetHeight() + end +function VeneerWorldStateProgressMixin:OnUpdate(sinceLast) + self.timeLived = (self.timeLived or 0) + sinceLast + if self.timeLived >= 3 and not self.TransitionFadeOut:IsPlaying() then + if not self.timeOut then + self.timeOut = true + self.TransitionFadeOut:Play() + end + end +end + + function VeneerWorldStateProgressMixin:OnLoad() - self:RegisterEvent('PLAYER_XP_UPDATE') - self:RegisterEvent('PLAYER_LEVEL_UP') - self:RegisterEvent('PLAYER_UPDATE_RESTING') - self:RegisterEvent('ENABLE_XP_GAIN') - self:RegisterEvent('DISABLE_XP_GAIN') - self:RegisterEvent('PLAYER_LOGIN') - self:RegisterEvent('ARTIFACT_UPDATE') - self:RegisterEvent('ARTIFACT_XP_UPDATE') + self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') + self:RegisterEvent("PLAYER_XP_UPDATE"); + self:RegisterEvent("UPDATE_EXHAUSTION"); + self:RegisterEvent("PLAYER_LEVEL_UP"); + self:RegisterEvent("PLAYER_UPDATE_RESTING"); + + self:RegisterEvent("ARTIFACT_UPDATE"); + self:RegisterEvent("ARTIFACT_XP_UPDATE"); + self:RegisterEvent("ARTIFACT_CLOSE"); + self:RegisterEvent("ARTIFACT_MAX_RANKS_UPDATE"); + + self.progressPercent = 0 + self.progressAmount = 0 + self.progressMax = 1 + self.progressOverflow = 0 end function VeneerWorldStateProgressMixin:Setup() self:UpdateXPGain() - if UnitLevel('player') < GetMaxPlayerLevel() then + + if self.canGainXP then self.mode = 'xp' else self.mode = 'artifact' end print('setup mode:', self.mode) - self:Update() end -function VeneerWorldStateProgressMixin:OnEvent(event) - if event == 'ENABLE_XP_GAIN' or event == 'DISABLE_XP_GAIN' then +function VeneerWorldStateProgressMixin:OnEvent(event, ...) + local lastMode = self.mode + if event == 'PLAYER_LEVEL_UP' or event == 'ENABLE_XP_GAIN' or event == 'DISABLE_XP_GAIN' then self:UpdateXPGain() elseif event == 'ARTIFACT_XP_UPDATE' or event == 'ARTIFACT_UPDATE' then self.mode = 'artifact' - elseif event == 'PLAYER_XP_UPDATE' or 'PLAYER_LEVEL_UP' then + + elseif event == 'PLAYER_EQUIPMENT_CHANGED' then + local slot, hasEquip = ... + if slot == 16 then + self.mode = 'artifact' + lastMode = nil + end + elseif event == 'PLAYER_XP_UPDATE' or event == 'PLAYER_LEVEL_UP' then + print('forcing to XP mode') self.mode = 'xp' end - - - self:Update() - + self.modeChanged = (lastMode ~= self.mode) + if self.modeChanged and self:IsVisible() then + print('|cFF88FF00'..self:GetName()..'.TransitionFadeOut:Play()', event, ...) + self.TransitionFadeIn:Stop() + self.TransitionFadeOut:Play() + else + print('|cFFFFFF00'..self:GetName()..':Update()', event, ...) + self:Update() + end end function VeneerWorldStateProgressMixin:UpdateXPGain() - if IsXPUserDisabled() then + self.canGainXP = (UnitLevel('player') < GetMaxPlayerLevel()) and (not IsXPUserDisabled()) + if not self.canGainXP then self.ProgressBar:SetColorTexture(0.75,0.75,0.75) - self.mode = nil - else - self.ProgressBar:SetColorTexture(1,1,1) end end local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank function VeneerWorldStateProgressMixin:Update() + local hasNewInfo = false + local progressChange = false + print(' current mode:', self.mode) - if not self.mode then - if UnitLevel('player') < GetMaxPlayerLevel() then - self.mode = 'xp' - else - self.mode = 'artifact' - end - end - - self.progressPercent = 0 - self.progressAmount = 0 - self.progressMax = 1 - self.progressOverflow = 0 if self.mode == 'xp' then local xp = UnitXP('player') local xpMax = UnitXPMax('player') @@ -191,45 +273,105 @@ if xp then self.progressPercent = xp / xpMax end + + self.progressText = 'Level ' .. UnitLevel('player') .. ': ' .. xp .. '/' .. xpMax + + if bonusXP then + self.ProgressBar:SetColorTexture(0, 0.5,1) + self.OverflowBar:Show() + self.OverflowBar:ClearAllPoints() + self.OverflowBar:SetPoint('BOTTOMLEFT', self.ProgressBar, 'BOTTOMRIGHT', 0, 0) + print(bonusXP, (xpMax - xp)) + if bonusXP < (xpMax - xp) then + + self.OverflowBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPRIGHT', (bonusXP / xpMax) * self:GetWidth(), 0) + else + self.OverflowBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPRIGHT', 0, 0) + end + else + self.OverflowBar:Hide() + self.ProgressBar:SetColorTexture(0.5,0,1) + end + hasNewInfo = (self.progressAmount ~= xp) + + progressChange = (hasNewInfo and not self.modeChanged) and (xp - self.progressAmount) / self:GetWidth() + + + self.progressAmount = xp + self.progressMax = xpMax elseif self.mode == 'artifact' then local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() - if not itemID then - self:Hide() - return + print(' C_AUI:', itemID, altItemID, name, icon, totalXP, pointsSpent) + + if itemID then + local nextRankCost = GetCostForPointAtRank(pointsSpent) or 0 + hasNewInfo = (self.progressAmount ~= totalXP) + progressChange = (hasNewInfo and not self.modeChanged) and (totalXP - self.progressAmount) / self:GetWidth() + + if totalXP > nextRankCost then + self.progressPercent = 1 + self.progressOverflow = totalXP - nextRankCost + else + self.progressPercent = totalXP / nextRankCost + end + + self.progressText = name .. ' ('..pointsSpent .. '): '.. totalXP .. ' / ' .. nextRankCost + + self.ProgressBar:SetColorTexture(1,0.5,0,1) + self.OverflowBar:Hide() + + + self.progressAmount = totalXP + self.progressMax = nextRankCost + else + self.progressAmount = 0 + self.progressMax = 1 + self.progressText = '' + end + end + + if self.mode then + self:SetSize(600,16) + if hasNewInfo then + self.timeOut = nil + self.timeLived = 0 + if self.TransitionFadeOut:IsPlaying() then + self.TransitionFadeOut:Stop() + self:SetAlpha(1) + end + if not self:IsVisible() then + self.TransitionFadeIn:Play() + else + self:ShowPanel() + end + end - local pointsAvailable = 0 + print(self.ProgressBG:GetWidth()) + print(' Percent:', floor(self.progressPercent*100)/100, 'BarLength:', floor(self:GetWidth()* self.progressPercent), 'NewInfo:', hasNewInfo, 'IsShown:', self:IsShown()) - local nextRankCost = GetCostForPointAtRank(pointsSpent) or 0 - self.progressAmount = totalXP - self.progressMax = nextRankCost - if totalXP > nextRankCost then - self.progressPercent = 1 - self.progressOverflow = totalXP - nextRankCost - else - self.progressPercent = totalXP / nextRankCost + if progressChange then + print(' Render change:', progressChange) + self.ProgressAdded:Show() + self.ProgressAdded:SetPoint('BOTTOMLEFT', self.ProgressBar, 'BOTTOMRIGHT', - (self:GetWidth() * progressChange), 0) + self.ProgressAdded:SetPoint('TOPRIGHT', self.ProgressBar, 'TOPRIGHT', 0, 0) + self.ProgressFlash:Play() end - self.progressText = name .. ' ('..pointsSpent .. '): '.. totalXP .. ' / ' .. nextRankCost + + if self.progressPercent > 0 then + self.ProgressBar:Show() + self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()* self.progressPercent , 0) + + self.Label:SetText(self.progressText) + else + self.ProgressBar:Hide() + end else self:Hide() - return end - print(self.progressPercent, floor(self.ProgressBG:GetWidth()* self.progressPercent)) - - if self.progressPercent > 0 then - self.ProgressBar:Show() - self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self.ProgressBG:GetWidth()* self.progressPercent , 0) - - self.Label:SetText(self.progressText) - else - self.ProgressBar:Hide() - end - - - - self.maxHeight = self:GetHeight() + self.modeChanged = nil end \ No newline at end of file
--- a/Veneer.xml Mon Oct 17 04:57:32 2016 -0400 +++ b/Veneer.xml Mon Oct 17 13:00:26 2016 -0400 @@ -163,7 +163,7 @@ <Scripts> <OnLoad method="OnLoad" /> <OnEvent method="OnEvent" /> - <OnShow method="OnShow" /> + <OnUpdate method="OnUpdate" /> </Scripts> </Frame> @@ -242,7 +242,6 @@ <Frames> <Frame name="$parentProgress" parentKey="Progress" mixin="VeneerWorldStateProgressMixin" inherits="VeneerMixinScripts"> - <Size x="600" y="12" /> <Anchors> <Anchor point="TOPLEFT" /> </Anchors> @@ -259,6 +258,16 @@ </Anchors> <Color r="1" g="1" b="1" a="0.8" /> </Texture> + <Texture parentKey="OverflowBar" hidden="true"> + <Anchors> + <Anchor point="BOTTOMLEFT" /> + </Anchors> + <Color a=".6" r="1" g="0" b=".5" /> + </Texture> + <Texture parentKey="ProgressAdded" hidden="true"> + + <Color a="1" r="1" g="1" b="1" /> + </Texture> </Layer> <Layer level="OVERLAY"> <FontString parentKey="Label" inherits="VeneerNumberFont"> @@ -268,13 +277,43 @@ </FontString> </Layer> </Layers> + <Animations> + <AnimationGroup parentKey="TransitionFadeOut" setToFinalAlpha="true"> + <Alpha fromAlpha="1" toAlpha="0" duration="0.15" order="1" /> + <Scripts> + <OnPlay> + print('VnWorldState','fade out') + </OnPlay> + <OnFinished> + self:GetParent():Hide() + self:GetParent():Update() + </OnFinished> + </Scripts> + </AnimationGroup> + <AnimationGroup parentKey="TransitionFadeIn" setToFinalAlpha="true"> + <Alpha fromAlpha="0" toAlpha="1" duration="0.15" order="1" /> + <Scripts> + <OnPlay> + self:GetParent():ShowPanel() + self:GetParent().timeLived = 0 + print('VnWorldState', 'fade in') + </OnPlay> + <OnFinished> + self:GetParent().timeLived = 0 + </OnFinished> + </Scripts> + </AnimationGroup> + <AnimationGroup parentKey="ProgressFlash" setToFinalAlpha="true"> + <Alpha fromAlpha="0" toAlpha="1" duration="0.15" order="1" childKey="ProgressAdded" /> + <Alpha fromAlpha="1" toAlpha="0" duration="0.45" order="2" childKey="ProgressAdded" /> + </AnimationGroup> + </Animations> </Frame> <Frame name="$parentZoneCurrency" parentKey="ZoneCurrency" mixin="VeneerWorldStateCurrencyMixin" hidden="true" inherits="VeneerMixinScripts"> <Anchors> <Anchor point="TOPRIGHT" /> </Anchors> - <Size x="200" y="24" /> <Layers> <Layer level="ARTWORK"> <Texture parentKey="Icon" >