unitframes

This commit is contained in:
Bunny67
2017-12-23 18:25:19 +03:00
parent e23cec738e
commit 2cfc3b0079
3 changed files with 8 additions and 109 deletions
@@ -43,9 +43,7 @@ function UF:Construct_PartyFrames()
return self;
end
function UF:Update_PartyHeader(header, db)
header.db = db
function UF:Update_PartyHeader(header)
if not header.positioned then
header:ClearAllPoints()
header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195)
@@ -42,9 +42,7 @@ function UF:Construct_RaidFrames()
return self
end
function UF:Update_RaidHeader(header, db)
header.db = db
function UF:Update_RaidHeader(header)
if not header.positioned then
header:ClearAllPoints()
header:SetPoint("BOTTOMLEFT", E.UIParent, "BOTTOMLEFT", 4, 195)
@@ -52,7 +50,6 @@ function UF:Update_RaidHeader(header, db)
E:CreateMover(header, header:GetName().."Mover", L["Raid Frames"], nil, nil, nil, "ALL,RAID")
header.positioned = true
end
end
function UF:Update_RaidFrames(frame, db)
@@ -28,13 +28,11 @@ ElvUF = ns.oUF
assert(ElvUF, "ElvUI was unable to locate oUF.")
UF["headerstoload"] = {}
UF["unitgroupstoload"] = {}
UF["unitstoload"] = {}
UF["groupPrototype"] = {}
UF["headerPrototype"] = {}
UF["headers"] = {}
UF["groupunits"] = {}
UF["units"] = {}
UF["statusbars"] = {}
@@ -194,6 +192,7 @@ function UF:ConvertGroupDB(group)
end
function UF:Construct_UF(frame, unit)
frame:SetFrameStrata("LOW")
frame:SetScript("OnEnter", UnitFrame_OnEnter)
frame:SetScript("OnLeave", UnitFrame_OnLeave)
@@ -208,22 +207,17 @@ function UF:Construct_UF(frame, unit)
frame.SHADOW_SPACING = 3
frame.CLASSBAR_YOFFSET = 0 --placeholder
frame.BOTTOM_OFFSET = 0 --placeholder
frame:SetFrameStrata("LOW")
frame.RaisedElementParent = CreateFrame("Frame", nil, frame)
frame.RaisedElementParent:SetFrameLevel(frame:GetFrameLevel() + 100)
frame.RaisedElementParent.TextureParent = CreateFrame("Frame", nil, frame.RaisedElementParent)
frame.RaisedElementParent.TextureParent:SetFrameLevel(frame.RaisedElementParent:GetFrameLevel() + 1)
if not self["groupunits"][unit] then
local stringTitle = E:StringTitle(unit)
if string.find(stringTitle, "target") then
stringTitle = gsub(stringTitle, "target", "Target")
end
self["Construct_"..stringTitle.."Frame"](self, frame, unit)
else
UF["Construct_"..E:StringTitle(self["groupunits"][unit]).."Frames"](self, frame, unit)
end
self:Update_StatusBars()
self:Update_FontStrings()
@@ -282,10 +276,6 @@ function UF:GetAuraAnchorFrame(frame, attachTo, isConflict)
if isConflict or attachTo == "FRAME" then
return frame
elseif attachTo == "TRINKET" then
if select(2, IsInInstance()) == "arena" then
return frame.Trinket
end
elseif attachTo == "BUFFS" then
return frame.Buffs
elseif attachTo == "DEBUFFS" then
@@ -299,13 +289,6 @@ function UF:GetAuraAnchorFrame(frame, attachTo, isConflict)
end
end
function UF:ClearChildPoints(...)
for i = 1, select("#", unpack(arg)) do
local child = select(i, unpack(arg))
child:ClearAllPoints()
end
end
function UF:UpdateColors()
local db = self.db.colors
@@ -391,53 +374,9 @@ function UF:Update_AllFrames()
end
end
for unit, group in pairs(self["groupunits"]) do
if self.db["units"][group].enable then
self[unit]:Enable()
self[unit]:Update()
E:EnableMover(self[unit].mover:GetName())
else
self[unit]:Disable()
E:DisableMover(self[unit].mover:GetName())
end
end
self:UpdateAllHeaders()
end
function UF:CreateAndUpdateUFGroup(group, numGroup)
for i = 1, numGroup do
local unit = group..i
local frameName = E:StringTitle(unit)
frameName = frameName:gsub("t(arget)", "T%1")
if not self[unit] then
self["groupunits"][unit] = group
self[unit] = ElvUF:Spawn(unit, "ElvUF_"..frameName)
self[unit].index = i
self[unit]:SetID(i)
end
local frameName = E:StringTitle(group)
frameName = frameName:gsub("t(arget)", "T%1")
self[unit].Update = function()
UF["Update_"..E:StringTitle(frameName).."Frames"](self, self[unit], self.db["units"][group])
end
if self.db["units"][group].enable then
self[unit]:Enable()
self[unit].Update()
if self[unit].isForced then
self:ForceShow(self[unit])
end
E:EnableMover(self[unit].mover:GetName())
else
self[unit]:Disable()
E:DisableMover(self[unit].mover:GetName())
end
end
end
function UF:HeaderUpdateSpecificElement(group, elementName)
assert(self[group], "Invalid group specified.")
for i = 1, self[group]:GetNumChildren() do
@@ -677,8 +616,6 @@ function UF:CreateHeader(parent, groupFilter, overrideName, template, groupName,
local db = UF.db["units"][group]
ElvUF:SetActiveStyle("ElvUF_"..E:StringTitle(group))
local header = ElvUF:SpawnHeader(overrideName, headerTemplate, nil,
"initial-width", db.width,
"initial-height", db.height,
"groupFilter", groupFilter,
"showParty", true,
"showRaid", true,
@@ -698,23 +635,7 @@ end
function UF:CreateAndUpdateHeaderGroup(group, groupFilter, template, headerUpdate, headerTemplate)
local db = self.db["units"][group]
local raidFilter = UF.db.smartRaidFilter
local numGroups = db.numGroups
if(raidFilter and numGroups and (self[group] and not self[group].blockVisibilityChanges)) then
local inInstance, instanceType = IsInInstance()
if(inInstance and (instanceType == "raid" or instanceType == "pvp")) then
local _, _, _, _, maxPlayers = GetInstanceInfo()
local mapID = GetCurrentMapAreaID()
if UF.mapIDs[mapID] then
maxPlayers = UF.mapIDs[mapID]
end
if maxPlayers > 0 then
numGroups = E:Round(maxPlayers/5)
end
end
end
if not self[group] then
local stringTitle = E:StringTitle(group)
@@ -768,6 +689,7 @@ function UF:CreateAndUpdateHeaderGroup(group, groupFilter, template, headerUpdat
end
if db.enable then
self[group]:Show()
if self[group].mover then
E:EnableMover(self[group].mover:GetName())
end
@@ -854,12 +776,6 @@ function UF:LoadUnits()
end
self["unitstoload"] = nil
for group, groupOptions in pairs(self["unitgroupstoload"]) do
local numGroup, template = unpack(groupOptions)
self:CreateAndUpdateUFGroup(group, numGroup, template)
end
self["unitgroupstoload"] = nil
for group, groupOptions in pairs(self["headerstoload"]) do
local groupFilter, template, headerTemplate
if type(groupOptions) == "table" then
@@ -888,24 +804,12 @@ function UF:UpdateAllHeaders(event)
ElvUF:DisableBlizzard("party")
end
local smartRaidFilterEnabled = self.db.smartRaidFilter
for group, header in pairs(self["headers"]) do
if header.numGroups then
UF["headerFunctions"][group]:UpdateHeader(header)
end
UF["headerFunctions"][group]:Update(header)
local shouldUpdateHeader
if header.numGroups == nil or smartRaidFilterEnabled then
shouldUpdateHeader = false
elseif header.numGroups ~= nil and not smartRaidFilterEnabled then
shouldUpdateHeader = true
end
self:CreateAndUpdateHeaderGroup(group, nil, nil, shouldUpdateHeader)
header:Hide()
header:Show()
if group == "party" or group == "raid" then
--Update BuffIndicators on profile change as they might be using profile specific data
--self:UpdateAuraWatchFromHeader(group)