X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/e8f2d3b5f640506a32de9789501bd087f19f156a..d093a7f250aab703c69128ad4b54a31d6e0b1f83:/OmaRF/RaidFrame.lua diff --git a/OmaRF/RaidFrame.lua b/OmaRF/RaidFrame.lua index 3cde21c..ebadfef 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; @@ -33,6 +34,7 @@ local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist"; local class = nil; local party = {}; local raid = {}; +local updaters = {}; local M = {}; OmaRaidFrame = M; @@ -40,33 +42,40 @@ OmaRaidFrame = M; local function unitUpdate(frame) -- there's no in/out of range event, have to check each frame -- from FrameXML/CompactUnitFrame.lua - local inRange, checked = UnitInRange(frame.displayed); - if checked and not inRange then - frame:SetAlpha(0.55); - else - frame:SetAlpha(1); + if frame.updating then + local inRange, checked = UnitInRange(frame.displayed); + if checked and not inRange then + frame:SetAlpha(0.55); + else + frame:SetAlpha(1); + end + CTimerAfter(0.20, updaters[frame]); end end local function frameShow(frame) registerEvents(frame); registerUnitEvents(frame); - frame:SetScript("OnUpdate", unitUpdate); + frame.updating = true; + CTimerAfter(0.20, updaters[frame]); unitEvent(frame, "UPDATE_ALL_BARS"); end local function frameHide(frame) frame:UnregisterAllEvents(); - frame:SetScript("OnUpdate", nil); + frame.updating = nil; end local function showTooltip(secure) - GameTooltip_SetDefaultAnchor(GameTooltip, secure); - GameTooltip:SetUnit(secure:GetAttribute("unit")); + -- only show raid frame tooltips out of combat + if not InCombatLockdown() then + GameTooltip_SetDefaultAnchor(GameTooltip, secure); + GameTooltip:SetUnit(secure:GetAttribute("unit")); + end end local function hideTooltip(secure) - GameTooltip:FadeOut(); + if GameTooltip:IsOwned(secure) then GameTooltip:FadeOut() end end local function setupFrame(frame, secure, unit) @@ -122,27 +131,22 @@ local function setupFrame(frame, secure, unit) frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT"); frame.healabsorb:SetColorTexture(unpack(healabsorbColor)); frame.healabsorb:Hide(); - frame.role = frame:CreateTexture(nil, "ARTWORK"); - frame.role:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", -2, 2); - frame.role:SetPoint("TOPLEFT", frame.background, "BOTTOMRIGHT", -14, 14); - frame.role:SetTexture("Interface\\LFGFRAME\\LFGROLE"); - frame.role:Hide(); frame.overlay = frame:CreateTexture(nil, "ARTWORK", nil, 1); frame.overlay:SetPoint("TOPLEFT", frame.background, "TOPLEFT"); frame.overlay:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT"); frame.overlay:SetColorTexture(1, 1, 1); frame.overlay:Hide(); + frame.role = frame:CreateTexture(nil, "ARTWORK", nil, 2); + frame.role:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", -2, 2); + frame.role:SetPoint("TOPLEFT", frame.background, "BOTTOMRIGHT", -14, 14); + frame.role:SetTexture("Interface\\LFGFRAME\\LFGROLE"); + frame.role:Hide(); frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); frame.name:SetPoint("CENTER", frame.background, "CENTER", 0, 11); frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); frame.text:SetFont(STANDARD_TEXT_FONT, 13); frame.text:SetPoint("CENTER", frame.background, "CENTER", 0, -1); frame.text:Hide(); - frame.rez = frame:CreateTexture(nil, "OVERLAY"); - frame.rez:SetPoint("TOPLEFT", frame.background, "CENTER", -12, 12); - frame.rez:SetPoint("BOTTOMRIGHT", frame.background, "CENTER", 12, -12); - frame.rez:SetTexture("Interface\\RaidFrame\\Raid-Icon-Rez"); - frame.rez:Hide(); frame.ready = frame:CreateTexture(nil, "OVERLAY"); frame.ready:SetPoint("TOPLEFT", frame.background, "BOTTOMLEFT", 0, 14); frame.ready:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMLEFT", 14, 0); @@ -161,6 +165,8 @@ local function setupFrame(frame, secure, unit) frame:SetScript("OnEvent", unitEvent); secure:SetScript("OnEnter", showTooltip); secure:SetScript("OnLeave", hideTooltip); + -- set up periodic updates + updaters[frame] = function() return unitUpdate(frame) end -- set attributes secure:RegisterForClicks("AnyDown"); for attr, val in pairs(attributes) do @@ -272,9 +278,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 +336,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);