From ad67f41cf4019dca1e2ea587019fe825f92fdcf0 Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Wed, 14 Feb 2018 00:14:31 +0200 Subject: [PATCH] Allow MoveAnything to change tooltip location MoveAnything starts from PLAYER_ENTERING_WORLD, delay until that point to set local tooltip variables --- OmaRF/RaidFrame.lua | 27 +++++++++++++++++---------- OmaUF/Auras.lua | 11 +++++++---- OmaUF/BossFrames.lua | 22 +++++++++++++--------- OmaUF/PetFrame.lua | 9 ++++++--- OmaUF/PlayerFrame.lua | 9 ++++++--- OmaUF/TargetFrame.lua | 9 ++++++--- OmaUF/UnitFrames.lua | 27 +++++++++++++++++++++------ 7 files changed, 76 insertions(+), 38 deletions(-) diff --git a/OmaRF/RaidFrame.lua b/OmaRF/RaidFrame.lua index 2adcdb9..5d94ff0 100644 --- a/OmaRF/RaidFrame.lua +++ b/OmaRF/RaidFrame.lua @@ -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); diff --git a/OmaUF/Auras.lua b/OmaUF/Auras.lua index 90da28d..db3a7df 100644 --- a/OmaUF/Auras.lua +++ b/OmaUF/Auras.lua @@ -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); diff --git a/OmaUF/BossFrames.lua b/OmaUF/BossFrames.lua index dd6b2aa..0f9841d 100644 --- a/OmaUF/BossFrames.lua +++ b/OmaUF/BossFrames.lua @@ -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); diff --git a/OmaUF/PetFrame.lua b/OmaUF/PetFrame.lua index 5295804..4c2efef 100644 --- a/OmaUF/PetFrame.lua +++ b/OmaUF/PetFrame.lua @@ -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); diff --git a/OmaUF/PlayerFrame.lua b/OmaUF/PlayerFrame.lua index be92842..76d5d6e 100644 --- a/OmaUF/PlayerFrame.lua +++ b/OmaUF/PlayerFrame.lua @@ -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); diff --git a/OmaUF/TargetFrame.lua b/OmaUF/TargetFrame.lua index 44316c0..350f98e 100644 --- a/OmaUF/TargetFrame.lua +++ b/OmaUF/TargetFrame.lua @@ -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); diff --git a/OmaUF/UnitFrames.lua b/OmaUF/UnitFrames.lua index 6f40e0d..f477e37 100644 --- a/OmaUF/UnitFrames.lua +++ b/OmaUF/UnitFrames.lua @@ -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); -- 2.39.5