changeset 89:74e714637d6a

WorldStateProgress fade-in is called for all visibility check falses
author Nenue
date Fri, 21 Oct 2016 18:03:35 -0400
parents b107b4df7eb6
children 6e2cb847c3c6
files Modules/PaperDoll.lua Modules/WorldState.lua Modules/WorldState.xml Veneer.lua
diffstat 4 files changed, 167 insertions(+), 140 deletions(-) [+]
line wrap: on
line diff
--- a/Modules/PaperDoll.lua	Thu Oct 20 04:08:11 2016 -0400
+++ b/Modules/PaperDoll.lua	Fri Oct 21 18:03:35 2016 -0400
@@ -66,7 +66,9 @@
   end
 
   local numRelicSlots = C_ArtifactUI.GetNumRelicSlots() or 0;
+  for i = 1, numRelicSlots do
 
+  end
 
   local pointsAvailable = 0
   local nextRankCost = GetCostForPointAtRank(pointsSpent + pointsAvailable) or 0
--- a/Modules/WorldState.lua	Thu Oct 20 04:08:11 2016 -0400
+++ b/Modules/WorldState.lua	Fri Oct 21 18:03:35 2016 -0400
@@ -11,7 +11,7 @@
 VeneerWorldStateCurrencyMixin = {
 }
 VeneerWorldStateProgressMixin = {
-  keepOpen = true
+  keepOpen = true,
 }
 VeneerWorldStateMixin = {
   maxHeight = 0,
@@ -107,10 +107,18 @@
 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:IsVisible(), frame:GetHeight())
     if frame:IsShown() then
-      self.maxHeight = max(self.maxHeight, frame:GetHeight())
+      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 then
@@ -179,14 +187,12 @@
 end
 
 function VeneerWorldStateCurrencyMixin:OnLoad ()
-
   self:RegisterEvent("PLAYER_ENTERING_WORLD");
   self:RegisterEvent("ZONE_CHANGED");
   self:RegisterEvent("ZONE_CHANGED_INDOORS");
   self:RegisterEvent("ZONE_CHANGED_NEW_AREA");
   self:RegisterEvent('CURRENCY_DISPLAY_UPDATE')
   self:RegisterEvent('CHAT_MSG_CURRENCY')
-
 end
 
 function VeneerWorldStateCurrencyMixin:OnEvent (event, arg)
@@ -204,7 +210,6 @@
     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
@@ -292,28 +297,10 @@
 local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo
 local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank
 
-function VeneerWorldStateProgressMixin:AnimateProgress(progressChange)
 
-  local progressWidth = self:GetWidth() * progressChange
-
-  print('  Render change:', progressChange, progressWidth)
-  self.ProgressAdded:Show()
-  self.ProgressAdded:ClearAllPoints()
-  self.ProgressAdded:SetPoint('TOPRIGHT', self.ProgressBar, 'TOPRIGHT', 0, 0)
-  self.ProgressAdded:SetPoint('BOTTOMLEFT', self.ProgressBar, 'BOTTOMRIGHT', - (progressWidth), 0)
-
-
-  self.ProgressFlash.translation:SetOffset(progressWidth, 0)
-  self.ProgressFlash:Play()
-end
-
-function VeneerWorldStateProgressMixin:Update(isBatchUpdate)
-  local hasNewInfo = false
-  local progressChange = false
-  print('  current mode:', self.mode)
-
-
-  if self.mode == 'xp' then
+local progressHandlers = {
+  xp = function(self)
+    local hasNewInfo, showChange = false, false
     local xp = UnitXP('player')
     local xpMax = UnitXPMax('player')
     local bonusXP = GetXPExhaustion()
@@ -322,27 +309,29 @@
     end
     self.progressText = '|cFFFFCC00' .. UnitLevel('player') .. '|r ' .. 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)
+      self.progressOverflow = min(1,(bonusXP / xpMax))
+      self.OverflowBar:SetColorTexture(0.5, 0.5,0.5, 0.25)
+      self.OverflowBar:SetPoint('LEFT', self.ProgressBar, 'LEFT')
     else
-      self.ProgressBar:SetColorTexture(0.5,0,1)
+      self.progressOverflow = nil
     end
-    hasNewInfo = (self.progressAmount ~= xp)
-    progressChange = (hasNewInfo and not self.modeChanged) and ((xp - self.progressAmount) / xpMax)
-    self.progressOverflow = bonusXP or 0
+    self.ProgressBar:SetColorTexture(0, 0.5,1,1)
+    self.OverflowAnchor = self.ProgressBar
+    self.hasNewInfo = (self.progressAmount ~= xp)
+    showChange = (hasNewInfo and not self.modeChanged) and ((xp - self.progressAmount) / xpMax)
+
     self.progressAmount = xp
     self.progressMax = xpMax
-
-  elseif self.mode == 'artifact' then
+    return hasNewInfo, showChange
+  end,
+  artifact = function(self)
+    local hasNewInfo, showChange = false, false
     local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo()
-
     if itemID then
       local nextRankCost = GetCostForPointAtRank(pointsSpent) or 0
       print('    API:', itemID, name, 'XP:', totalXP, 'Points:', pointsSpent, 'Next:', nextRankCost)
       hasNewInfo = (self.progressAmount ~= totalXP)
-      progressChange = (hasNewInfo and not self.modeChanged) and (((totalXP - self.progressAmount) / nextRankCost))
+      showChange = (hasNewInfo and not self.modeChanged) and (((totalXP - self.progressAmount) / nextRankCost))
 
       if totalXP > nextRankCost then
         self.progressPercent = 1
@@ -355,66 +344,103 @@
       self.ProgressBar:SetColorTexture(1,0.5,0,1)
       self.OverflowBar:Hide()
 
-      self.progressOverflow = 0
+      if totalXP > nextRankCost then
+        self.progressText = self.progressText .. ' Level Up!'
+        self.progressOverflow = (totalXP - nextRankCost) / nextRankCost
+        self.OverflowBar:SetPoint('LEFT', self.ProgressBG, 'LEFT')
+        self.OverflowAnchor = self.OverflawBar
+      else
+        self.progressOverflow = nil
+        self.OverflowAnchor = self.ProgressBar
+      end
+
       self.progressAmount = totalXP
       self.progressMax = nextRankCost
     else
-      self.progressOverflow = 0
+      self.progressOverflow = nil
       self.progressAmount = 0
       self.progressMax = 1
       self.progressText = ''
     end
+    return hasNewInfo, showChange
+  end
+}
+
+function VeneerWorldStateProgressMixin:Update(isBatchUpdate)
+
+  local progressChange = false
+  print('  current mode:', self.mode)
+  if (not self.mode) or (not progressHandlers[self.mode]) then
+    self:HidePanel()
+    return
   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
+  local hasNewInfo, showProgress = progressHandlers[self.mode](self)
+  self:SetSize(600,16)
+  if hasNewInfo then
+    self.timeOut = nil
+    self.timeLived = 0
+  end
 
+  if not self:IsVisible() then
+    self.TransitionFadeIn:Play()
+  else
+    self:ShowPanel()
+  end
+
+  print('    Percent:', floor(self.progressPercent*100)/100, 'BarLength:', floor(self:GetWidth()* self.progressPercent), 'new:', hasNewInfo, 'shown:', self:IsShown())
+  print('    Metrics:', self:IsVisible(), self:GetWidth(), self.ProgressBG:GetWidth())
+  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)
+
+    self.ProgressSpark:ClearAllPoints()
+    if self.progressOverflow then
+      print('    Overflow:', self.progressOverflow)
+      self.OverflowBar:Show()
+      self.OverflowBar:SetWidth(self.progressOverflow * self:GetWidth(), 0)
+    else
+      self.OverflowBar:Hide()
     end
+    self.ProgressSpark:SetPoint('CENTER', self.OverflowAnchor, 'RIGHT', 0, 0)
 
+  else
+    self.ProgressBar:Hide()
+  end
 
-    print('    Percent:', floor(self.progressPercent*100)/100, 'BarLength:', floor(self:GetWidth()* self.progressPercent), 'new:', hasNewInfo, 'shown:', self:IsShown())
-    print('    Metrics:', self:IsVisible(), self:GetWidth(), self.ProgressBG:GetWidth())
+  if self.progressOverflow and (self.progressOverflow >= self.progressPercent) then
+    self.OverflowBar:SetDrawLayer('ARTWORK', 1)
+    self.ProgressBar:SetDrawLayer('ARTWORK', 2)
+  else
+    self.OverflowBar:SetDrawLayer('ARTWORK', 2)
+    self.ProgressBar:SetDrawLayer('ARTWORK', 1)
+  end
 
     if progressChange then
-      self:AnimateProgress(progressChange)
-    end
-
-
-    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)
-
-      self.progressLeft = self.progressMax - self.progressAmount
-      if self.progressOverflow >= self.progressLeft then
-
-        self.OverflowBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPRIGHT', 0, 0)
-      else
-        self.OverflowBar:SetPoint('TOPRIGHT', self.ProgressBar, 'TOPRIGHT', (self.progressOverflow / self.progressMax) * self:GetWidth(), 0)
-      end
-
-    else
-      self.ProgressBar:Hide()
-    end
-  else
-    self:HidePanel()
+    self:AnimateProgress(progressChange)
   end
 
   self.modeChanged = nil
 end
 
+
+function VeneerWorldStateProgressMixin:AnimateProgress(progressChange)
+
+
+  local changeAnchor = (self.progressOverflow and self.OverflowBar) or self.ProgressBar
+  local progressWidth = self:GetWidth() * min(progressChange, changeAnchor:GetWidth())
+
+  self.ProgressAdded:Show()
+  self.ProgressAdded:ClearAllPoints()
+  self.ProgressAdded:SetPoint('TOPRIGHT', changeAnchor, 'TOPRIGHT', 0, 0)
+  self.ProgressAdded:SetPoint('BOTTOMLEFT', changeAnchor, 'BOTTOMRIGHT', - (progressWidth), 0)
+
+  print('  Render change:', progressWidth, changeAnchor)
+  self.ProgressFlash.translation:SetOffset(progressWidth, 0)
+  self.ProgressFlash:Play()
+end
+
 function VeneerWorldStateProgressMixin:OnMouseDown(button)
   if button == 'RightButton' then
     if self.keepOpen then
@@ -425,6 +451,7 @@
     end
     print('keepOpen =', self.keepOpen)
   else
+
     if self.mode == 'xp' then
       self.mode = 'artifact'
     else
@@ -433,6 +460,9 @@
       end
       self.mode = 'xp'
     end
+    print('|cFFFF4400Change mode:', self.mode)
+
+
     self:AnimateMode()
   end
 
--- a/Modules/WorldState.xml	Thu Oct 20 04:08:11 2016 -0400
+++ b/Modules/WorldState.xml	Fri Oct 21 18:03:35 2016 -0400
@@ -9,7 +9,7 @@
     </Anchors>
     <Size x="600" y="24" />
     <Frames>
-      <Frame name="$parentProgress" parentKey="Progress" mixin="VeneerWorldStateProgressMixin" inherits="VeneerMixinScripts" enableMouse="true">
+      <Frame name="$parentProgress" mixin="VeneerWorldStateProgressMixin" inherits="VeneerMixinScripts" enableMouse="true">
         <Anchors>
           <Anchor point="TOPLEFT" />
         </Anchors>
@@ -19,8 +19,14 @@
             <Scripts>
               <OnPlay>
                 --print('VnWorldState','fade out')
+                self:GetParent().faded = true
               </OnPlay>
+              <OnStop>
+                print('VnWorldState', '|cFF44FF00stopped fadeout')
+                self:GetParent():Update()
+              </OnStop>
               <OnFinished>
+                print('VnWorldState', '|cFFFFFF00end of fadeout')
                 self:GetParent():Hide()
                 self:GetParent():Update()
               </OnFinished>
@@ -34,21 +40,19 @@
                 self:GetParent().timeLived = 0
                 --print('VnWorldState', 'fade in')
               </OnPlay>
+              <OnStop>
+                self:GetParent():Update()
+              </OnStop>
               <OnFinished>
+                print('VnWorldState', '|cFFFFFF00end of fade IN')
+                self:GetParent().faded = nil
                 self:GetParent().timeLived = 0
               </OnFinished>
             </Scripts>
           </AnimationGroup>
           <AnimationGroup parentKey="TimedFadeOut" setToFinalAlpha="true">
-            <Alpha fromAlpha="1" toAlpha="0" duration="1.12" order="1" />
-            <Scripts>
-              <OnPlay>
-                --print('VnWorldState','fade out')
-              </OnPlay>
-              <OnFinished>
-                self:GetParent():HidePanel()
-              </OnFinished>
-            </Scripts>
+            <Alpha childKey="ProgressText" fromAlpha="1" toAlpha="0" duration="1.12" order="1" />
+            <Alpha childKey="Background" fromAlpha="1" toAlpha="0" duration="1.12" order="1" />
           </AnimationGroup>
 
           <AnimationGroup parentKey="ProgressFlash" setToFinalAlpha="true">
@@ -57,6 +61,9 @@
 
             <Alpha childKey="Spark" fromAlpha="0" toAlpha="1" duration="0.15" order="1" />
             <Alpha childKey="Spark" fromAlpha="1" toAlpha="0" duration="0.15" order="2" />
+
+
+            <Alpha childKey="ProgressSpark" fromAlpha="0" toAlpha="1" duration="0.15" order="1" startDelay=".45" />
             <Translation parentKey="translation" childKey="Spark" offsetX="600" offsetY="0" duration="0.30" order="1" />
             <Scripts>
               <OnPlay>
@@ -75,13 +82,24 @@
           </AnimationGroup>
         </Animations>
         <Layers>
+          <Layer level="BACKGROUND">
+            <Texture parentKey="Background" alphaMode="BLEND" file="Interface\LevelUp\BossBanner">
+              <Anchors>
+                <Anchor point="TOP" />
+                <Anchor point="BOTTOM" />
+                <Anchor point="LEFT" x="24" y="0" />
+                <Anchor point="RIGHT" x="-24" y="0" />
+              </Anchors>
+              <TexCoords left="0" right="0.8" top="0.45" bottom="0.55" />
+            </Texture>
+          </Layer>
           <Layer level="BORDER">
             <Texture parentKey="ProgressBG">
               <Anchors>
                 <Anchor point="TOPRIGHT" />
                 <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="0" y="12" />
               </Anchors>
-              <Color r="0" g="0" b="0" a="0.5" />
+              <Color r="0" g="0" b="0" a="0.75" />
             </Texture>
           </Layer>
           <Layer level="ARTWORK">
@@ -91,11 +109,15 @@
               </Anchors>
               <Color r="1" g="1" b="1" a="0.8" />
             </Texture>
+          </Layer>
+          <Layer level="ARTWORK" textureSubLevel="2">
+
             <Texture parentKey="OverflowBar" hidden="true">
               <Anchors>
-                <Anchor point="BOTTOMLEFT" />
+                <Anchor point="BOTTOM" relativeKey="$parent.ProgressBG" />
+                <Anchor point="TOP" relativeKey="$parent.ProgressBG" />
               </Anchors>
-              <Color a=".6" r="1" g="0" b=".5" />
+              <Color a="1" r="0.1" g=".35" b=".85" />
             </Texture>
           </Layer>
           <Layer level="OVERLAY">
@@ -109,6 +131,10 @@
                 <Anchor point="CENTER" relativePoint="LEFT" relativeKey="$parent.ProgressAdded" />
               </Anchors>
             </Texture>
+            <Texture parentKey="ProgressSpark" atlas="OBJFX_LineBurst">
+              <Size x="8" y="12" />
+            </Texture>
+
             <FontString parentKey="Label" inherits="VeneerNumberFont">
               <Anchors>
                 <Anchor point="CENTER" />
@@ -118,18 +144,18 @@
         </Layers>
       </Frame>
 
-      <Frame name="$parentZoneCurrency" parentKey="ZoneCurrency" mixin="VeneerWorldStateCurrencyMixin" hidden="true" inherits="VeneerMixinScripts, VeneerAnimations">
+      <Frame name="$parentZoneCurrency" mixin="VeneerWorldStateCurrencyMixin" hidden="true" inherits="VeneerMixinScripts, VeneerAnimations">
+        <Size x="240" y="24" />
         <Anchors>
-          <Anchor point="TOPRIGHT" />
+          <Anchor point="TOP" />
         </Anchors>
         <Layers>
           <Layer level="ARTWORK">
             <Texture parentKey="Icon" >
-              <Size x="24" y="24" />
+              <Size x="16" y="16" />
               <Anchors>
                 <Anchor point="LEFT" />
               </Anchors>
-              <TexCoords left="0.15" right="0.85" top="0.15" bottom="0.85" />
             </Texture>
           </Layer>
           <Layer level="OVERLAY">
--- a/Veneer.lua	Thu Oct 20 04:08:11 2016 -0400
+++ b/Veneer.lua	Fri Oct 21 18:03:35 2016 -0400
@@ -125,7 +125,6 @@
   self:StartMoving()
 end
 
-
 function VeneerCore:OnDragStop()
   self:StopMovingOrSizing()
 end
@@ -164,8 +163,6 @@
   if not insertPosition then
     insertPosition = #clusterTable + 1
   end
-
-
   return primaryAnchor, clusterTable, insertPosition
 end
 
@@ -181,7 +178,6 @@
   tinsert(clusterTable, clusterIndex, handler)
   print('cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex)
 
-
   handler.anchorCluster = clusterTable
   handler.anchorIndex = clusterIndex
   for k,v in pairs(VeneerHandlerMixin) do
@@ -197,7 +193,6 @@
       handler.initialized = true
     end
     self:InternalReanchor(handler)
-
   end
 end
 
@@ -227,8 +222,6 @@
       print('  |cFF00FF00'..index, frame:GetName(), frame:IsVisible())
       if frame:IsVisible() then
         anchorPoint = frame.anchorPoint
-
-
         frame:ClearAllPoints()
         if lastFrame then
           frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0)
@@ -250,7 +243,6 @@
   local subPoint, subTo
   local nextFrame
   for index, frame in ipairs(handler.anchorCluster) do
-
     print('  |cFF00FF00'..index, frame:GetName(), frame:IsVisible())
     if frame:IsVisible() then
       if frame ~= handler then
@@ -288,44 +280,19 @@
 end
 
 function VeneerCore:SlideBlock(frame, ...)
+  local aX, aY = frame:GetLeft(), frame:GetTop()
 
-  local anchorPoint, parent, anchorTo, pX,pY = ...
-  print('  |cFF0088FFSlide:|r', frame, 'to', parent, pX,pY)
-  local qX, qY = pX, pY
-  local bX, bY
-  local dX, dY = 0, 0
-  local aX, aY = frame:GetLeft(), frame:GetTop()
-  local str = ''
-  if not aX then
-    dY = ((anchorPoint == 'TOP') and frame:GetHeight()) or (((anchorPoint == 'BOTTOM') and -frame:GetHeight()) or 0)
-    dX = ((anchorPoint == 'LEFT') and -frame:GetWidth()) or (((anchorPoint == 'RIGHT') and frame:GetWidth()) or 0)
-    qX = pX + dX
-    qY = pY + dY
-    aX, aY = qX, qY
-    bX, bY = pX, pY
-    str = '|cFFFFFF00relative|r'
-  else
-    frame:ClearAllPoints()
+  frame:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', aX, aY)
+  frame.animation = frame.animation or {}
+  frame.animation.startX = aX
+  frame.animation.startY = aY
 
-    bX, bY = frame:GetLeft(), frame:GetTop()
-    dX, dY = (bX-aX), (bY-aY)
+  local targetPoint, targetParent, targetAnchor, offsetX, offsetY = ...
+  frame.BlockSlide:SetScript('OnFinished', function()
+    frame:SetPoint(targetPoint, targetParent, targetAnchor, offsetX, offsetY)
+    VeneerAnimationMixin.OnFinished(frame)
+  end)
 
-    str = '|cFFFFFF00existing|r'
-  end
-
-  if ((dX ~= 0) or (dY ~= 0)) and frame.BlockSlide then
-    print('  |cFF00FF88Slide result:|r',str, dX, dY)
-
-    frame:ClearAllPoints()
-    frame:SetPoint(anchorPoint, parent, anchorTo, qX, qY)
-    frame.BlockSlide.dX = dX
-    frame.BlockSlide.dY = dY
-    frame.BlockSlide.sourcePoint = {anchorPoint, parent, anchorTo, qX, qY}
-    frame.BlockSlide.destPoint = {anchorPoint, parent, anchorTo, pX,pY}
-    frame.BlockSlide.translation:SetOffset(dX, dY)
-    frame.BlockSlide:Play()
-    return
-  end
 end
 
 
@@ -500,14 +467,16 @@
 
 function VeneerAnimationMixin:OnPlay()
   PlaySoundKitID(229)
+  self.animating = true
   print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint))
 end
 function VeneerAnimationMixin:OnStop()
   PlaySoundKitID(229)
+  self.animating = nil
+  print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint))
 end
 function VeneerAnimationMixin:OnFinished()
   PlaySoundKitID(229)
+  self.animating = nil
   print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint))
-  self:GetParent():ClearAllPoints()
-  self:GetParent():SetPoint(unpack(self.destPoint))
 end
\ No newline at end of file