d51d314 - Show auras, hide replaced blizzard frames
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 27 Jan 2018 14:35:55 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 27 Jan 2018 14:35:55 +0000
OmaUF/Auras.lua
OmaUF/Events.lua
OmaUF/Settings.lua
OmaUF/UnitFrames.lua

index deb62fa..95ef2c6 100644 (file)
 -- Auras.lua
 local _;
 local CreateFrame = CreateFrame;
+local UnitAura = UnitAura;
+local GameTooltip = nil;
+
+local auraFilters = {"HELPFUL", "HARMFUL"};
 
 local M = {};
 OmaUFAuras = M;
 
-function M.CreateAuraFrame(parent)
-    parent.auras = CreateFrame("Frame", nil, parent);
-    parent.auras:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -2);
+local function updateTooltip(frame)
+    if GameTooltip:IsOwned(frame) then
+        GameTooltip:SetUnitAura(frame.unit, frame.index, frame.filter);
+    else
+        frame:SetScript("OnUpdate", nil);
+    end
+end
+
+local function showTooltip(frame)
+    -- tooltip handling from TargetFrame.xml
+    GameTooltip:SetOwner(frame, "ANCHOR_BOTTOMRIGHT", 15, -25);
+    GameTooltip:SetUnitAura(frame.unit, frame.index, frame.filter);
+    frame:SetScript("OnUpdate", updateTooltip);
+end
+
+local function hideTooltip(frame)
+    GameTooltip:Hide();
+    frame:SetScript("OnUpdate", nil);
+end
+
+local function createAura(parent, prev, anchor, name, unit)
+    local aura = CreateFrame("Frame", name, parent);
+    aura:SetPoint("TOPLEFT", prev, anchor);
+    aura:SetWidth(16);
+    aura:SetHeight(16);
+    aura.icon = aura:CreateTexture(nil, "ARTWORK");
+    aura.icon:SetAllPoints();
+    aura.cd = CreateFrame("Cooldown", name.."CD", aura, "CooldownFrameTemplate");
+    aura.cd:SetReverse(true);
+    aura.cd:SetHideCountdownNumbers(true);
+    aura.cd:SetAllPoints();
+    aura.unit = unit;
+    aura:SetScript("OnEnter", showTooltip);
+    aura:SetScript("OnLeave", hideTooltip);
+    aura:Hide();
+    return aura;
+end
+
+function M.CreateAuraFrame(parent, unit)
+    GameTooltip = _G["GameTooltip"];
+    local name = parent:GetName().."Auras";
+    parent.auras = CreateFrame("Frame", name, parent);
+    parent.auras:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", 0, -8);
+    parent.auras:SetWidth(10);
+    parent.auras:SetHeight(10);
+    local i = 1;
+    -- max auras per row
+    for x=1,10 do
+        local auraName = name..i;
+        if i == 1 then
+            parent.auras[i] = createAura(parent.auras, parent.auras, "TOPLEFT", auraName, unit);
+        else
+            parent.auras[i] = createAura(parent.auras, parent.auras[i-1], "TOPRIGHT", auraName, unit);
+        end
+        i = i + 1;
+    end
+    -- max rows
+    for y=0,1 do
+        for x=1,10 do
+            local auraName = name..i;
+            parent.auras[i] = createAura(parent.auras, parent.auras[y*10+x], "BOTTOMLEFT", auraName, unit);
+            i = i + 1;
+        end
+    end
 end
 
 function M.UpdateAuras(frame, unit)
     local auras = frame.auras;
+    if not auras then return end
+    for _, aura in ipairs(auras) do
+        if not aura:IsShown() then break end
+        aura:Hide();
+    end
+    local icon, count, duration, expires, caster, id;
+    local pos = 1;
+    for _, filter in ipairs(auraFilters) do
+        local i = 1;
+        while true do
+            _, _, icon, count, _, duration, expires, caster, _, _, id = UnitAura(unit, i, filter);
+            if not id or not auras[pos] then break end
+            local aura = auras[pos];
+            aura.icon:SetTexture(icon);
+            aura.index = i;
+            aura.filter = filter;
+            if expires > 0 then
+                aura.cd:SetCooldown(expires - duration, duration);
+            else
+                aura.cd:Hide();
+            end
+            aura:Show();
+            pos = pos + 1;
+            i = i + 1;
+        end
+    end
 end
index cd8bd7f..1d3644d 100644 (file)
@@ -18,6 +18,8 @@ local UnitGroupRolesAssigned = UnitGroupRolesAssigned;
 local UnitLevel, UnitClassification = UnitLevel, UnitClassification;
 local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
 
+local updateAuraFrames = OmaUFAuras.UpdateAuras;
+
 local Settings = OmaUFSettings;
 local baseColor = Settings.BaseColor;
 local overlayColorDispel = Settings.OverlayColorDispel;
@@ -201,6 +203,7 @@ local function updateHealAbsorb(frame, unit)
 end
 
 local function updateAuras(frame, unit)
+    updateAuraFrames(frame, unit);
     if UnitIsFriend("player", unit) and UnitDebuff(unit, 1, "RAID") ~= nil then
         -- something dispellable
         if frame.overlay.color ~= overlayColorDispel then
index ce9441f..c2dca70 100644 (file)
@@ -44,7 +44,7 @@ local chars = {
         },
         ["Gedren"] = {
             Width = 160,
-            Height = 80,
+            Height = 50,
             AnchorX = 0,
             AnchorY = -330,
             Clickheal = {
index d5ec0b7..76c2c7e 100644 (file)
@@ -10,6 +10,7 @@ local GameTooltip_SetDefaultAnchor = nil;
 
 local registerEvents = OmaUFEvents.RegisterEvents;
 local unitEvent = OmaUFEvents.UnitEvent;
+local createAuraFrame = OmaUFAuras.CreateAuraFrame;
 
 local Settings = OmaUFSettings;
 local indSize = Settings.IndSize;
@@ -204,10 +205,10 @@ local function initializePlayer(parent)
     local secure = CreateFrame("Button", "OmaPlayerSecure", parent, inheritedFrames);
     local frame = CreateFrame("Frame", "OmaPlayer", parent);
     local unit = "player";
-    secure:SetPoint("CENTER", parent, "CENTER", -320, -100);
+    secure:SetPoint("CENTER", parent, "CENTER", -300, -175);
     secure:SetWidth(width+2);
     secure:SetHeight(height+2);
-    frame:SetPoint("CENTER", parent, "CENTER", -320, -100);
+    frame:SetPoint("CENTER", parent, "CENTER", -300, -175);
     frame:SetWidth(width+2);
     frame:SetHeight(height+2);
     setupFrame(frame, secure, unit);
@@ -221,14 +222,14 @@ local function initializeTarget(parent)
     local secure = CreateFrame("Button", "OmaTargetSecure", parent, inheritedFrames);
     local frame = CreateFrame("Frame", "OmaTarget", parent);
     local unit = "target";
-    secure:SetPoint("CENTER", parent, "CENTER", 320, -100);
+    secure:SetPoint("CENTER", parent, "CENTER", 300, -175);
     secure:SetWidth(width+2);
     secure:SetHeight(height+2);
-    frame:SetPoint("CENTER", parent, "CENTER", 320, -100);
+    frame:SetPoint("CENTER", parent, "CENTER", 300, -175);
     frame:SetWidth(width+2);
     frame:SetHeight(height+2);
     setupFrame(frame, secure, unit);
-    -- TODO target frame buffs/debuffs
+    createAuraFrame(frame, unit);
     RegisterUnitWatch(frame);
     RegisterUnitWatch(secure);
     RegisterStateDriver(secure, "vehicleui", "[vehicleui] vehicle; no");
@@ -238,6 +239,7 @@ end
 local function initialize()
     initializePlayer(UIParent);
     initializeTarget(UIParent);
+    -- TODO boss frames, pet frame, (arena frames)
 end
 
 local function loadCharSettings()
@@ -246,10 +248,44 @@ local function loadCharSettings()
     attributes = Settings.Character.Clickheal;
 end
 
+local hidden = false;
+local function hideBlizzardFrames()
+    if hidden then return end
+    hidden = true;
+
+    for _, frame in pairs({PlayerFrame, TargetFrame, TargetFrameToT}) do
+        frame:UnregisterAllEvents();
+        frame.healthbar:UnregisterAllEvents();
+        frame.manabar:UnregisterAllEvents();
+        if frame.spellbar then frame.spellbar:UnregisterAllEvents() end
+        if frame.powerBarAlt then frame.powerBarAlt:UnregisterAllEvents() end
+        frame:Hide();
+    end
+
+    -- TODO create frames for class powers, currently using Simple Holy Power
+    for _, frame in pairs({PlayerFrameAlternateManaBar, ComboFrame,
+            PriestBarFrame, RuneFrame, WarlockPowerFrame, MonkHarmonyBarFrame,
+            PaladinPowerBarFrame, MageArcaneChargesFrame}) do
+        frame:UnregisterAllEvents();
+        frame:Hide();
+    end
+
+    -- from ShadowedUF, re-register vehicle events for default auras
+    PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
+    PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE");
+    PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE");
+    PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE");
+    PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE");
+    PlayerFrame:SetMovable(true);
+    PlayerFrame:SetUserPlaced(true);
+    PlayerFrame:SetDontSavePosition(true);
+end
+
 UnitFrames:RegisterEvent("ADDON_LOADED");
 UnitFrames:RegisterEvent("PLAYER_LOGIN");
 UnitFrames:SetScript("OnEvent", function(self, event)
     if event == "PLAYER_LOGIN" then
+        hideBlizzardFrames();
         initialize();
     elseif event == "ADDON_LOADED" then
         OmaUFLoadChar();