View Single Post
10-20-16, 10:54 PM   #19
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
lua Code:
  1. local addon = CreateFrame("Frame");
  2. addon:RegisterEvent("PLAYER_LOGIN");
  3. addon:RegisterEvent("PLAYER_REGEN_DISABLED");
  4. addon:RegisterEvent("PLAYER_REGEN_ENABLED");
  5. addon:RegisterEvent("PLAYER_STARTED_MOVING");
  6. addon:RegisterEvent("PLAYER_STOPPED_MOVING");
  7.  
  8.  
  9. addon:SetScript("OnEvent", function(self, event, ...)
  10.  
  11.     if event == "PLAYER_LOGIN"
  12.     or event == "PLAYER_REGEN_DISABLED"
  13.     or event == "PLAYER_STOPPED_MOVING" then
  14.        
  15.         if not UnitAffectingCombat("player") then
  16.             UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0);
  17.         end;
  18.     else
  19.         UIParent:SetAlpha(1);
  20.     end;
  21.    
  22.     if UnitAffectingCombat("player") then
  23.         UIParent:SetAlpha(1);
  24.     end;
  25. end);
  26.  
  27. addon:SetScript("OnUpdate", function(self, elapsed)
  28.  
  29.     local speed = GetUnitSpeed("player");
  30.     if speed ~=0 then
  31.         UIParent:SetAlpha(1);
  32.     else
  33.         if GetMouseFocus() then
  34.             if GetMouseFocus():GetName() ~= "WorldFrame" then
  35.                 UIParent:SetAlpha(1);
  36.             else
  37.                 if not UnitAffectingCombat("player") then
  38.                     UIFrameFadeOut(UIParent, 3, UIParent:GetAlpha(), 0.1);
  39.                 end;
  40.             end;
  41.         end;
  42.     end;
  43.    
  44.     if UnitName("mouseover") then
  45.         UIParent:SetAlpha(1);
  46.     end;
  47. end);

I tried to workaround the fade-in problem by changing it to SetAlpha(1).

It let to lots of clunky interactions, with the UI fading down and then showing up and then disappearing again, only to be hard to make it appear again and such. Lots of suboptimal interactions.
  Reply With Quote