ad67f41 - Allow MoveAnything to change tooltip location
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Tue, 13 Feb 2018 22:14:31 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Tue, 13 Feb 2018 22:17:37 +0000
MoveAnything starts from PLAYER_ENTERING_WORLD, delay until that point
to set local tooltip variables

OmaRF/RaidFrame.lua
OmaUF/Auras.lua
OmaUF/BossFrames.lua
OmaUF/PetFrame.lua
OmaUF/PlayerFrame.lua
OmaUF/TargetFrame.lua
OmaUF/UnitFrames.lua

index 2adcdb9..5d94ff0 100644 (file)
@@ -5,9 +5,10 @@ local format = string.format;
 local UnitInRange = UnitInRange;
 local InCombatLockdown = InCombatLockdown;
 local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
+local CTimerAfter = C_Timer.After;
 local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
 
 local registerEvents = OmaRFEvents.RegisterEvents;
 local registerUnitEvents = OmaRFEvents.RegisterUnitEvents;
@@ -272,9 +273,6 @@ local function initializeFocus(parent)
 end
 
 local function initialize()
-    -- let other addons hook these to anchor tooltip elsewhere
-    GameTooltip = _G["GameTooltip"];
-    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
     _, class = UnitClass("player");
     anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY;
     attributes = Settings.Character.Clickheal;
@@ -333,16 +331,25 @@ local function hideBlizzardRaid()
     end
 end
 
+local function updateTooltipFuncs()
+    -- let MoveAnything hook these to anchor tooltip elsewhere
+    GameTooltip = _G["GameTooltip"];
+    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+end
+
 CFrame:RegisterEvent("PLAYER_LOGIN");
+CFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
 CFrame:RegisterEvent("PLAYER_REGEN_ENABLED");
 CFrame:SetScript("OnEvent", function(self, event, addon)
-    if event == "PLAYER_LOGIN" then
-        OmaRFLoadChar();
-        hideBlizzardRaid();
-        initialize();
-    elseif event == "PLAYER_REGEN_ENABLED" then
+    if event == "PLAYER_REGEN_ENABLED" then
         -- if CompactRaidFrameManager_UpdateOptionsFlowContainer was called in combat
         -- couldn't hide the button
         hideBlizzardRaidButton();
+    elseif event == "PLAYER_ENTERING_WORLD" then
+        CTimerAfter(0.01, updateTooltipFuncs);
+    elseif event == "PLAYER_LOGIN" then
+        OmaRFLoadChar();
+        hideBlizzardRaid();
+        initialize();
     end
 end);
index 90da28d..db3a7df 100644 (file)
@@ -2,7 +2,7 @@
 local _;
 local CreateFrame = CreateFrame;
 local UnitAura = UnitAura;
-local GameTooltip = nil;
+local GameTooltip = GameTooltip;
 
 local auraFilters = {"HELPFUL", "HARMFUL"};
 
@@ -29,11 +29,15 @@ local function hideTooltip(frame)
     frame:SetScript("OnUpdate", nil);
 end
 
+function M.UpdateAuraTooltips()
+    GameTooltip = _G["GameTooltip"];
+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:SetWidth(20);
+    aura:SetHeight(20);
     aura.icon = aura:CreateTexture(nil, "ARTWORK");
     aura.icon:SetAllPoints();
     aura.cd = CreateFrame("Cooldown", name.."CD", aura, "CooldownFrameTemplate");
@@ -48,7 +52,6 @@ local function createAura(parent, prev, anchor, name, unit)
 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);
index dd6b2aa..0f9841d 100644 (file)
@@ -2,8 +2,8 @@
 local _;
 local unpack, pairs = unpack, pairs;
 local format = string.format;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
 
 local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
 local registerCastEvents = OmaUFCastBar.RegisterCastEvents;
@@ -50,6 +50,11 @@ local function hideTooltip(secure)
     GameTooltip:FadeOut();
 end
 
+function OmaUnitFrames.UpdateBossTooltips()
+    GameTooltip = _G["GameTooltip"];
+    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+end
+
 local function createFrame(framename, securename, parent, unit, anchorX, anchorY)
     local secure = CreateFrame("Button", securename, parent, inheritedFrames);
     local frame = CreateFrame("Frame", framename, parent);
@@ -132,21 +137,20 @@ local function createFrame(framename, securename, parent, unit, anchorX, anchorY
     secure:SetScript("OnLeave", hideTooltip);
     -- set attributes
     -- TODO other set of click cast on boss frames possibly
-    secure:RegisterForClicks("AnyDown");
-    for attr, val in pairs(attributes) do
-        secure:SetAttribute(attr, val);
-    end
+    --secure:RegisterForClicks("AnyDown");
+    --for attr, val in pairs(attributes) do
+    --    secure:SetAttribute(attr, val);
+    --end
     -- rest give target and menu
     secure:SetAttribute("*type1", "target");
     secure:SetAttribute("*type2", "togglemenu");
-    secure:SetAttribute("toggleForVehicle", false);
+    --secure:SetAttribute("toggleForVehicle", false); -- TODO run LFR to see if there's boss1pet or something
     RegisterUnitWatch(frame);
     RegisterUnitWatch(secure);
+    -- TODO try register visibility state driver with [boss1][boss2][boss3] etc.
 end
 
 function OmaUnitFrames.InitializeBoss(parent)
-    GameTooltip = _G["GameTooltip"];
-    GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
     attributes = Settings.Character.Clickheal;
 
     createFrame("OmaBoss1", "OmaBossSecure1", parent, "boss1", anchorX, anchorY);
index 5295804..4c2efef 100644 (file)
@@ -2,8 +2,8 @@
 local _;
 local unpack, pairs = unpack, pairs;
 local format = string.format;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
 
 local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
 local unitEvent = OmaUFEvents.UnitEvent;
@@ -54,9 +54,12 @@ local vehicletoggle = [=[
     end
 ]=]
 
-function OmaUnitFrames.InitializePet(parent)
+function OmaUnitFrames.UpdatePetTooltips()
     GameTooltip = _G["GameTooltip"];
     GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+end
+
+function OmaUnitFrames.InitializePet(parent)
     attributes = Settings.Character.Clickheal; -- TODO pet clickheal separate with Mend Pet etc.
 
     local secure = CreateFrame("Button", "OmaPetSecure", parent, inheritedFrames);
index be92842..76d5d6e 100644 (file)
@@ -2,8 +2,8 @@
 local _;
 local unpack, pairs = unpack, pairs;
 local format = string.format;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
 
 local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
 local registerCastEvents = OmaUFCastBar.RegisterCastEvents;
@@ -63,9 +63,12 @@ local vehicletoggle = [=[
     end
 ]=]
 
-function OmaUnitFrames.InitializePlayer(parent)
+function OmaUnitFrames.UpdatePlayerTooltips()
     GameTooltip = _G["GameTooltip"];
     GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+end
+
+function OmaUnitFrames.InitializePlayer(parent)
     attributes = Settings.Character.Clickheal;
 
     local secure = CreateFrame("Button", "OmaPlayerSecure", parent, inheritedFrames);
index 44316c0..350f98e 100644 (file)
@@ -2,8 +2,8 @@
 local _;
 local unpack, pairs = unpack, pairs;
 local format = string.format;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
 
 local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
 local registerCastEvents = OmaUFCastBar.RegisterCastEvents;
@@ -52,9 +52,12 @@ local function hideTooltip(secure)
     GameTooltip:FadeOut();
 end
 
-function OmaUnitFrames.InitializeTarget(parent)
+function OmaUnitFrames.UpdateTargetTooltips()
     GameTooltip = _G["GameTooltip"];
     GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
+end
+
+function OmaUnitFrames.InitializeTarget(parent)
     attributes = Settings.Character.Clickheal;
 
     local secure = CreateFrame("Button", "OmaTargetSecure", parent, inheritedFrames);
index 6f40e0d..f477e37 100644 (file)
@@ -2,6 +2,9 @@
 local _;
 local pairs = pairs;
 local InCombatLockdown = InCombatLockdown;
+local CTimerAfter = C_Timer.After;
+
+local updateAuraTooltips = OmaUFAuras.UpdateAuraTooltips;
 
 local UnitFrames = CreateFrame("Frame", "OmaUnitFrames", UIParent);
 
@@ -30,9 +33,9 @@ local function hideBlizzardFrames()
         WarlockPowerFrame, MonkHarmonyBarFrame, PaladinPowerBarFrame,
         MageArcaneChargesFrame, CastingBarFrame, PetCastingBarFrame};
     for i = 1,MAX_BOSS_FRAMES do
-        table.insert(frames, _G["Boss"..i.."TargetFrame"]);
-        table.insert(frames, _G["Boss"..i.."TargetFrameHealthBar"]);
-        table.insert(frames, _G["Boss"..i.."TargetFrameManaBar"]);
+        --table.insert(frames, _G["Boss"..i.."TargetFrame"]);
+        --table.insert(frames, _G["Boss"..i.."TargetFrameHealthBar"]);
+        --table.insert(frames, _G["Boss"..i.."TargetFrameManaBar"]);
     end
     for _, frame in pairs(frames) do
         frame:UnregisterAllEvents();
@@ -70,14 +73,26 @@ local function hideArenaFrames()
     end
 end
 
+local function updateTooltipFuncs()
+    -- let MoveAnything hook these to anchor tooltip elsewhere
+    M.UpdatePlayerTooltips();
+    M.UpdatePetTooltips();
+    M.UpdateTargetTooltips();
+    M.UpdateBossTooltips();
+    updateAuraTooltips();
+end
+
 UnitFrames:RegisterEvent("PLAYER_LOGIN");
+UnitFrames:RegisterEvent("PLAYER_ENTERING_WORLD");
 UnitFrames:RegisterEvent("ADDON_LOADED");
 UnitFrames:SetScript("OnEvent", function(self, event, addon)
-    if event == "PLAYER_LOGIN" then
+    if event == "PLAYER_ENTERING_WORLD" then
+        CTimerAfter(0.01, updateTooltipFuncs);
+    elseif event == "ADDON_LOADED" and addon == "Blizzard_ArenaUI" then
+        hideArenaFrames();
+    elseif event == "PLAYER_LOGIN" then
         OmaUFLoadChar();
         hideBlizzardFrames();
         initialize();
-    elseif event == "ADDON_LOADED" and addon == "Blizzard_ArenaUI" then
-        hideArenaFrames();
     end
 end);