X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/ac5ca8a9cb3cd9c2a6f5850ba5774bd81307fb51..52e517547bb85ea0705fbae13518a4c563abc77d:/OmaUF/UnitFrames.lua diff --git a/OmaUF/UnitFrames.lua b/OmaUF/UnitFrames.lua index d5ec0b7..f4b7521 100644 --- a/OmaUF/UnitFrames.lua +++ b/OmaUF/UnitFrames.lua @@ -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; @@ -20,8 +21,8 @@ local shieldColor = Settings.ShieldColor; local shieldhlColor = Settings.ShieldhlColor; local healpredColor = Settings.HealpredColor; local healabsorbColor = Settings.HealabsorbColor; +local width, height = Settings.Width, Settings.Height; -- placeholders with visible values when error happens -local width, height = 10, 10; local anchorX, anchorY = 10, 10; local attributes = {}; @@ -68,7 +69,7 @@ local function frameHide(frame) end local function showTooltip(frame) - GameTooltip_SetDefaultAnchor(GameTooltip, PlayerFrame); + GameTooltip_SetDefaultAnchor(GameTooltip, frame); GameTooltip:SetUnit(frame:GetAttribute("unit")); end @@ -143,11 +144,6 @@ local function setupFrame(frame, secure, unit) frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT"); frame.healabsorb:SetColorTexture(unpack(healabsorbColor)); frame.healabsorb:Hide(); - frame.overlay = frame:CreateTexture(nil, "ARTWORK", nil, 1); - frame.overlay:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT"); - frame.overlay:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT"); - frame.overlay:SetColorTexture(1, 1, 1); - frame.overlay:Hide(); frame.role = frame:CreateTexture(nil, "OVERLAY"); frame.role:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -8, 8); frame.role:SetPoint("BOTTOMRIGHT", frame.healthback, "TOPRIGHT", 8, -8); @@ -175,9 +171,6 @@ local function setupFrame(frame, secure, unit) 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 @@ -204,10 +197,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,39 +214,73 @@ 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"); secure:SetAttribute("_onstate-vehicleui", vehicletoggle); end +local function loadCharSettings() + anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; + attributes = Settings.Character.Clickheal; +end + local function initialize() + loadCharSettings(); + -- let other addons hook these to anchor tooltip elsewhere + GameTooltip = _G["GameTooltip"]; + GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; initializePlayer(UIParent); initializeTarget(UIParent); + -- TODO boss frames, pet frame, (arena frames) end -local function loadCharSettings() - width, height = Settings.Character.Width, Settings.Character.Height; - anchorX, anchorY = Settings.Character.AnchorX, Settings.Character.AnchorY; - attributes = Settings.Character.Clickheal; +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 - initialize(); - elseif event == "ADDON_LOADED" then OmaUFLoadChar(); - loadCharSettings(); - OmaUFEvents.LoadChar(); + hideBlizzardFrames(); + initialize(); end end);