diff Devian.lua @ 60:59e047d6c5de v2.1.60

- Frame fading on movement re-implemented. - Fixed front console losing focus between reloads.
author Nenue
date Tue, 26 Jan 2016 16:43:03 -0500
parents 0a9a6740ea5d
children 516ceb31703d
line wrap: on
line diff
--- a/Devian.lua	Tue Jan 12 04:54:52 2016 -0500
+++ b/Devian.lua	Tue Jan 26 16:43:03 2016 -0500
@@ -85,6 +85,10 @@
 
   movement_fade = true,
   movement_fade_time = 0.15,
+  movement_fade_from = 1,
+  movement_fade_to  = 0,
+  movement_translation_x = 25,
+  movement_translation_y = 25,
 }
 
 local function ScanAddOnList(cmd, ...)
@@ -313,6 +317,8 @@
       var = '<funcref>'
     elseif type(var) == 'nil' then
       var = 'nil'
+    else
+      var = tostring(var)
     end
 
     insert(buffer, var)
@@ -343,6 +349,45 @@
   D:Print("|cFFFFFF00/cleandvn|r", "- Fully resets SavedVariables, profiles and all.")
 end
 
+local dot1, dot2 = CreateFrame('Frame', nil, UIParent), CreateFrame('Frame', nil, UIParent)
+dot1:SetSize(5,5)
+dot1:SetFrameStrata('TOOLTIP')
+local a = dot1:CreateTexture('fill', nil)
+a:SetAllPoints(dot1)
+a:SetTexture(1,0,0,1)
+dot2:SetSize(5,5)
+dot2:SetFrameStrata('TOOLTIP')
+a = dot2:CreateTexture('fill', nil)
+a:SetAllPoints(dot2)
+a:SetTexture(0,1,0,1)
+
+local OnStartedMoving = function()
+  for k, v in pairs(D.console) do
+    if v.enabled then
+      v.moveFade:Stop()
+      local F1 = v.moveFade.alphaOut
+      F1:SetFromAlpha(db.movement_fade_from)
+      F1:SetToAlpha(db.movement_fade_to)
+      F1:SetDuration(db.movement_fade_time)
+      v.moveFade:Play()
+      v:EnableMouse(false)
+    end
+  end
+end
+
+local OnStoppedMoving = function()
+  for k, v in pairs(D.console) do
+    if v.enabled then
+      v.moveFade:Stop()
+      local F1 = v.moveFade.alphaOut
+      F1:SetToAlpha(db.movement_fade_from)
+      F1:SetFromAlpha(db.movement_fade_to)
+      F1:SetDuration(db.movement_fade_time)
+      v.moveFade:Play()
+      v:EnableMouse(true)
+    end
+  end
+end
 
 
 function D:OnEnable()
@@ -358,23 +403,9 @@
     D:Print(L('Devian loaded in workspace', MAJOR, MINOR, db.workspace))
     -- movement fading
     if db.movement_fade then
-      self:RegisterEvent('PLAYER_STARTED_MOVING', function()
-        for k, v in pairs(self.console) do
-          if v.enabled then
-            v.preAlpha = v:GetAlpha()
-            v:SetAlpha(0)
-            v:EnableMouse(false)
-          end
-        end
-      end)
-      self:RegisterEvent('PLAYER_STOPPED_MOVING', function()
-        for k, v in pairs(self.console) do
-          if v.enabled then
-            v:SetAlpha(v.preAlpha)
-            v:EnableMouse(true)
-          end
-        end
-      end)
+
+      self:RegisterEvent('PLAYER_STARTED_MOVING', OnStartedMoving)
+      self:RegisterEvent('PLAYER_STOPPED_MOVING', OnStoppedMoving)
     end
   end
 
@@ -399,7 +430,7 @@
     }
     ReloadUI()
     end)
-  local blocked = {global = true, [PLAYER_REALM] = true}
+  local blocked = {global = true, channels = true, tags = true, [PLAYER_REALM] = true}
   self:RegisterChatCommand("resetdvn", function(args)
     for k,v in pairs(DevianDB) do
       if not blocked[k] then
@@ -471,6 +502,7 @@
   end
 
   if self.console[db.current_channel] then
+    print('bringing', self.console[db.current_channel].signature, 'to the front')
     self.console[db.current_channel]:ToFront()
     -- bring the current channel to the front
   end
@@ -536,9 +568,6 @@
 
     if c.enabled or (setAll and db.enabled) then
       c:Show()
-      if db.current_channel == c.index then
-        c:ToFront()
-      end
     elseif not (c.enabled and db.enabled) then
       c:Hide()
     end
@@ -548,6 +577,10 @@
   if setAll then
     if db.enabled then
       self:Print('toggled all consoles ON')
+      if D.console[db.current_channel] then
+        oldprint('push', D.console[db.current_channel].signature, 'to the front')
+        D.console[db.current_channel]:ToFront()
+      end
     else
       self:Print('toggled all consoles OFF')
     end