X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/d180f82975c6b13a3380bd8df5ab47df70112c49..9405379118ca9e6953dec8b54229f59d2d5788bc:/OmaRF/RaidFrame.lua diff --git a/OmaRF/RaidFrame.lua b/OmaRF/RaidFrame.lua index 31ef192..1f4bc87 100644 --- a/OmaRF/RaidFrame.lua +++ b/OmaRF/RaidFrame.lua @@ -6,14 +6,13 @@ local UnitHealthMax, UnitPowerMax = UnitHealthMax, UnitPowerMax; local UnitInRange = UnitInRange; local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch; local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT; +local GameTooltip = nil; +local GameTooltip_SetDefaultAnchor = nil; local registerEvents = OmaRFEvents.RegisterEvents; local unitEvent = OmaRFEvents.UnitEvent; local Settings = OmaRFSettings; -local positions = Settings.Positions; -local width, height = Settings.Character.Width, Settings.Character.Height; -local anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; local indSize = Settings.IndSize; local baseColor = Settings.BaseColor; local bgColor = Settings.BgColor; @@ -22,7 +21,11 @@ local shieldColor = Settings.ShieldColor; local shieldhlColor = Settings.ShieldhlColor; local healpredColor = Settings.HealpredColor; local healabsorbColor = Settings.HealabsorbColor; -local attributes = Settings.Character.Clickheal; +-- placeholders with visible values when error happens +local positions = {}; +local width, height = 10, 10; +local anchorX, anchorY = 10, 10; +local attributes = {}; local CFrame = CreateFrame("Frame", "OmaRFFrame", UIParent); local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate"; @@ -56,7 +59,7 @@ local function setupIndicators(frame) if i == 1 then frame.major[i]:SetPoint("TOPLEFT", frame.major, "TOPLEFT"); else - frame.major[i]:SetPoint("TOPLEFT", frame.major[i-1], "TOPLEFT"); + frame.major[i]:SetPoint("TOPLEFT", frame.major[i-1], "TOPRIGHT"); end frame.major[i]:SetWidth(indSize*2); frame.major[i]:SetHeight(indSize*2); @@ -89,6 +92,11 @@ local function frameShow(frame) frame:RegisterEvent("UNIT_PET"); frame:RegisterEvent("PLAYER_ROLES_ASSIGNED"); frame:RegisterEvent("GROUP_ROSTER_UPDATE"); + frame:RegisterEvent("PLAYER_ENTERING_WORLD"); + frame:RegisterEvent("READY_CHECK"); + frame:RegisterEvent("READY_CHECK_CONFIRM"); + frame:RegisterEvent("READY_CHECK_FINISHED"); + if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end registerEvents(frame); frame:SetScript("OnUpdate", unitUpdate); unitEvent(frame, "UPDATE_ALL_BARS", frame.displayed); @@ -99,6 +107,15 @@ local function frameHide(frame) frame:SetScript("OnUpdate", nil); end +local function showTooltip(frame) + GameTooltip_SetDefaultAnchor(GameTooltip, PlayerFrame); + GameTooltip:SetUnit(frame:GetAttribute("unit")); +end + +local function hideTooltip(frame) + GameTooltip:FadeOut(); +end + local function setupFrame(frame, secure, unit) secure:SetAttribute("unit", unit); frame:SetAttribute("unit", unit); @@ -179,12 +196,21 @@ local function setupFrame(frame, secure, unit) 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, 12); + frame.ready:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMLEFT", 12, 0); + frame.ready:Hide(); -- set up indicators setupIndicators(frame); -- set scripts frame:SetScript("OnShow", frameShow); frame:SetScript("OnHide", frameHide); frame:SetScript("OnEvent", unitEvent); + -- let other addons hook these to anchor tooltip elsewhere + GameTooltip = _G["GameTooltip"]; + GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; + secure:SetScript("OnEnter", showTooltip); + secure:SetScript("OnLeave", hideTooltip); -- set attributes secure:RegisterForClicks("AnyDown"); for attr, val in pairs(attributes) do @@ -281,17 +307,45 @@ local function initializeRaid(parent) end end +local function initializeFocus(parent) + local secure = CreateFrame("Button", "OmaFocusSecure", parent, inheritedFrames); + local frame = CreateFrame("Frame", "OmaFocus", parent); + local unit = "focus"; + secure:SetPoint("BOTTOMLEFT", parent, "TOPLEFT"); + frame:SetPoint("BOTTOMLEFT", parent, "TOPLEFT"); + setupFrame(frame, secure, unit); + RegisterUnitWatch(frame); + RegisterUnitWatch(secure); + local vehicle = format("[@%s,unithasvehicleui] vehicle; no", unit); + RegisterStateDriver(secure, "vehicleui", vehicle); + secure:SetAttribute("_onstate-vehicleui", vehicletoggle); +end + local function initialize() CFrame:SetPoint("CENTER", nil, "CENTER", anchorX, anchorY); CFrame:SetHeight((height+2)*8); CFrame:SetWidth((width+2)*5+1); initializeParty(CFrame); initializeRaid(CFrame); + initializeFocus(CFrame); +end + +local function loadCharSettings() + width, height = Settings.Character.Width, Settings.Character.Height; + anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; + attributes = Settings.Character.Clickheal; + positions = Settings.Character.Positions; end +CFrame:RegisterEvent("ADDON_LOADED"); CFrame:RegisterEvent("PLAYER_LOGIN"); CFrame:SetScript("OnEvent", function(self, event) if event == "PLAYER_LOGIN" then initialize(); + elseif event == "ADDON_LOADED" then + OmaRFLoadChar(); + loadCharSettings(); + OmaRFEvents.LoadChar(); + OmaRFIndicators.LoadChar(); end end);