pettarget: add pet target unitframe

This commit is contained in:
Road-block
2018-05-29 20:39:35 +02:00
committed by Shagu
parent ff9c5c4a19
commit 543dc86458
15 changed files with 138 additions and 43 deletions
+43 -3
View File
@@ -497,6 +497,46 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("unitframes", "pet", "hitindicatorsize", "15")
pfUI:UpdateConfig("unitframes", "pet", "hitindicatorfont", "Interface\\AddOns\\pfUI\\fonts\\Continuum.ttf")
pfUI:UpdateConfig("unitframes", "ptarget", "visible", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "portrait", "bar")
pfUI:UpdateConfig("unitframes", "ptarget", "bartexture", "Interface\\AddOns\\pfUI\\img\\bar")
pfUI:UpdateConfig("unitframes", "ptarget", "width", "100")
pfUI:UpdateConfig("unitframes", "ptarget", "height", "4")
pfUI:UpdateConfig("unitframes", "ptarget", "pheight", "-1")
pfUI:UpdateConfig("unitframes", "ptarget", "pwidth", "-1")
pfUI:UpdateConfig("unitframes", "ptarget", "panchor", "TOP")
pfUI:UpdateConfig("unitframes", "ptarget", "pspace", "-3")
pfUI:UpdateConfig("unitframes", "ptarget", "buffs", "off")
pfUI:UpdateConfig("unitframes", "ptarget", "buffsize", "16")
pfUI:UpdateConfig("unitframes", "ptarget", "bufflimit", "16")
pfUI:UpdateConfig("unitframes", "ptarget", "buffperrow", "8")
pfUI:UpdateConfig("unitframes", "ptarget", "debuffs", "off")
pfUI:UpdateConfig("unitframes", "ptarget", "debuffsize", "16")
pfUI:UpdateConfig("unitframes", "ptarget", "debufflimit", "16")
pfUI:UpdateConfig("unitframes", "ptarget", "debuffperrow", "8")
pfUI:UpdateConfig("unitframes", "ptarget", "invert_healthbar", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "verticalbar", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "buff_indicator", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "debuff_indicator", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "clickcast", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "faderange", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "glowaggro", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "glowcombat", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "showtooltip", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "healthcolor", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "powercolor", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "levelcolor", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "classcolor", "1")
pfUI:UpdateConfig("unitframes", "ptarget", "txthpleft", "none")
pfUI:UpdateConfig("unitframes", "ptarget", "txthpcenter", "name")
pfUI:UpdateConfig("unitframes", "ptarget", "txthpright", "none")
pfUI:UpdateConfig("unitframes", "ptarget", "txtpowerleft", "none")
pfUI:UpdateConfig("unitframes", "ptarget", "txtpowercenter", "none")
pfUI:UpdateConfig("unitframes", "ptarget", "txtpowerright", "none")
pfUI:UpdateConfig("unitframes", "ptarget", "hitindicator", "0")
pfUI:UpdateConfig("unitframes", "ptarget", "hitindicatorsize", "15")
pfUI:UpdateConfig("unitframes", "ptarget", "hitindicatorfont", "Interface\\AddOns\\pfUI\\fonts\\Continuum.ttf")
pfUI:UpdateConfig("unitframes", "fallback", "visible", "1")
pfUI:UpdateConfig("unitframes", "fallback", "portrait", "bar")
pfUI:UpdateConfig("unitframes", "fallback", "bartexture", "Interface\\AddOns\\pfUI\\img\\bar")
@@ -778,7 +818,7 @@ function pfUI:MigrateConfig()
-- migrating old to new unitframe texts (> 3.0.0)
if checkversion(3, 0, 0) then
local unitframes = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "fallback" }
local unitframes = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback" }
for _, unitframe in pairs(unitframes) do
if pfUI_config.unitframes[unitframe].txtleft then
@@ -824,7 +864,7 @@ function pfUI:MigrateConfig()
-- migrating legacy buff/debuff naming (> 3.5.0)
if checkversion(3, 5, 0) then
local unitframes = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "fallback" }
local unitframes = { "player", "target", "focus", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback" }
for _, unitframe in pairs(unitframes) do
local entry = pfUI_config.unitframes[unitframe]
@@ -835,7 +875,7 @@ function pfUI:MigrateConfig()
-- migrating glow settings (> 3.5.1)
if checkversion(3, 5, 0) then
local common = { "player", "target", "ttarget", "pet" }
local common = { "player", "target", "ttarget", "pet", "ptarget"}
for _, unitframe in pairs(common) do
if pfUI_config.appearance.infight.group == "1" then
pfUI_config.unitframes[unitframe].glowcombat = "1"
+42 -39
View File
@@ -93,9 +93,9 @@ end
function pfUI.uf:UpdateConfig()
local f = self
local C = pfUI_config
local default_border = pfUI_config.appearance.border.default
if pfUI_config.appearance.border.unitframes ~= "-1" then
default_border = pfUI_config.appearance.border.unitframes
local default_border = C.appearance.border.default
if C.appearance.border.unitframes ~= "-1" then
default_border = C.appearance.border.unitframes
end
local relative_point = "BOTTOM"
@@ -134,8 +134,8 @@ function pfUI.uf:UpdateConfig()
f.hp.bar:SetOrientation("HORIZONTAL")
end
if pfUI_config.unitframes.custombg == "1" then
local cr, cg, cb, ca = pfUI.api.strsplit(",", pfUI_config.unitframes.custombgcolor)
if C.unitframes.custombg == "1" then
local cr, cg, cb, ca = pfUI.api.strsplit(",", C.unitframes.custombgcolor)
cr, cg, cb, ca = tonumber(cr), tonumber(cg), tonumber(cb), tonumber(ca)
f.hp.bar.texture = f.hp.bar.texture or f.hp:CreateTexture(nil,"BACKGROUND")
f.hp.bar.texture:SetTexture(cr,cg,cb,ca)
@@ -173,7 +173,7 @@ function pfUI.uf:UpdateConfig()
f.portrait:SetParent(f.hp.bar)
f.portrait:SetAllPoints(f.hp.bar)
f.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha)
f.portrait:SetAlpha(C.unitframes.portraitalpha)
if f.portrait.backdrop then f.portrait.backdrop:Hide() end
-- place portrait below fonts
@@ -547,6 +547,7 @@ function pfUI.uf:EnableScripts()
f:RegisterEvent("UNIT_MODEL_CHANGED")
f:RegisterEvent("UNIT_AURA") -- frame=buff, frame=debuff
f:RegisterEvent("PLAYER_AURAS_CHANGED") -- label=player && frame=buff
f:RegisterEvent("UNIT_INVENTORY_CHANGED") -- label=player && frame=buff
f:RegisterEvent("PARTY_MEMBERS_CHANGED") -- label=party, frame=leaderIcon
f:RegisterEvent("PARTY_LEADER_CHANGED") -- frame=leaderIcon
f:RegisterEvent("RAID_ROSTER_UPDATE") -- label=raid
@@ -573,7 +574,7 @@ function pfUI.uf:EnableScripts()
pfUI.uf:RefreshUnit(this, "all")
elseif ( this.label == "raid" or this.label == "party" ) and event == "RAID_ROSTER_UPDATE" then
pfUI.uf:RefreshUnit(this, "all")
elseif this.label == "player" and event == "PLAYER_AURAS_CHANGED" then
elseif this.label == "player" and (event == "PLAYER_AURAS_CHANGED" or event == "UNIT_INVENTORY_CHANGED") then
pfUI.uf:RefreshUnit(this, "aura")
elseif event == "PLAYER_ENTERING_WORLD" then
pfUI.uf:RefreshUnit(this, "all")
@@ -693,6 +694,10 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick)
unit, id = "pet", ""
end
if unit == "pettarget" and id == "0" then
unit, id = "pettarget", ""
end
if unit == "party0target" then
unit, id = "target", ""
end
@@ -876,12 +881,13 @@ function pfUI.uf:RefreshUnit(unit, component)
local component = component or ""
-- don't update scanner activity
if unit.label == "target" or unit.label == "targettarget" then
if unit.label == "target" or unit.label == "targettarget" or unit.label == "pettarget" then
if pfScanActive == true then return end
end
local C = pfUI_config
-- show groupframes as raid
if pfUI_config["unitframes"]["raidforgroup"] == "1" then
if C["unitframes"]["raidforgroup"] == "1" then
if strsub(unit:GetName(),0,6) == "pfRaid" then
local id = tonumber(strsub(unit:GetName(),7,8))
@@ -900,9 +906,9 @@ function pfUI.uf:RefreshUnit(unit, component)
end
end
local default_border = pfUI_config.appearance.border.default
if pfUI_config.appearance.border.unitframes ~= "-1" then
default_border = pfUI_config.appearance.border.unitframes
local default_border = C.appearance.border.default
if C.appearance.border.unitframes ~= "-1" then
default_border = C.appearance.border.unitframes
end
-- hide and return early on unused frames
@@ -917,7 +923,7 @@ function pfUI.uf:RefreshUnit(unit, component)
elseif UnitName(unit.label .. unit.id) then
-- hide group while in raid and option is set
if pfUI_config["unitframes"]["group"]["hide_in_raid"] == "1" and strsub(unit.label,0,5) == "party" and UnitInRaid("player") then
if C["unitframes"]["group"]["hide_in_raid"] == "1" and strsub(unit.label,0,5) == "party" and UnitInRaid("player") then
unit:Hide()
return
@@ -928,9 +934,15 @@ function pfUI.uf:RefreshUnit(unit, component)
return
end
elseif unit.label == "pettarget" then
if not UnitIsVisible(unit.label .. unit.id) or not UnitExists("pet") then
unit:Hide()
return
end
-- hide self in group if solo or hide in raid is set
elseif unit.fname == "Group0" or unit.fname == "PartyPet0" or unit.fname == "Party0Target" then
if ( GetNumPartyMembers() <= 0 ) or ( pfUI_config["unitframes"]["group"]["hide_in_raid"] == "1" and UnitInRaid("player") ) then
if ( GetNumPartyMembers() <= 0 ) or ( C["unitframes"]["group"]["hide_in_raid"] == "1" and UnitInRaid("player") ) then
unit:Hide()
return
end
@@ -1061,17 +1073,11 @@ function pfUI.uf:RefreshUnit(unit, component)
if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end
end
if dtype == "Magic" then
unit.debuffs[i].backdrop:SetBackdropBorderColor(0,1,1,1)
elseif dtype == "Poison" then
unit.debuffs[i].backdrop:SetBackdropBorderColor(0,1,0,1)
elseif dtype == "Curse" then
unit.debuffs[i].backdrop:SetBackdropBorderColor(1,0,1,1)
elseif dtype == "Disease" then
unit.debuffs[i].backdrop:SetBackdropBorderColor(1,1,0,1)
else
unit.debuffs[i].backdrop:SetBackdropBorderColor(1,0,0,1)
local r,g,b = DebuffTypeColor.none.r,DebuffTypeColor.none.g,DebuffTypeColor.none.b
if dtype and DebuffTypeColor[dtype] then
r,g,b = DebuffTypeColor[dtype].r,DebuffTypeColor[dtype].g,DebuffTypeColor[dtype].b
end
unit.debuffs[i].backdrop:SetBackdropBorderColor(r,g,b,1)
if texture then
unit.debuffs[i]:Show()
@@ -1198,7 +1204,7 @@ function pfUI.uf:RefreshUnit(unit, component)
-- portrait
if unit.portrait and ( component == "all" or component == "portrait" ) then
if pfUI_config.unitframes.always2dportrait == "1" then
if C.unitframes.always2dportrait == "1" then
unit.portrait.tex:Show()
unit.portrait.model:Hide()
SetPortraitTexture(unit.portrait.tex, unit.label .. unit.id)
@@ -1207,7 +1213,7 @@ function pfUI.uf:RefreshUnit(unit, component)
if unit.config.portrait == "bar" then
unit.portrait.tex:Hide()
unit.portrait.model:Hide()
elseif pfUI_config.unitframes.portraittexture == "1" then
elseif C.unitframes.portraittexture == "1" then
unit.portrait.tex:Show()
unit.portrait.model:Hide()
SetPortraitTexture(unit.portrait.tex, unit.label .. unit.id)
@@ -1220,7 +1226,7 @@ function pfUI.uf:RefreshUnit(unit, component)
end
else
if unit.config.portrait == "bar" then
unit.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha)
unit.portrait:SetAlpha(C.unitframes.portraitalpha)
end
unit.portrait.tex:Hide()
unit.portrait.model:Show()
@@ -1257,7 +1263,7 @@ function pfUI.uf:RefreshUnit(unit, component)
end
if unit.cache.hpdisplay ~= unit.cache.hp then
if pfUI_config.unitframes.animation_speed == "1" then
if C.unitframes.animation_speed == "1" then
unit.hp.bar:SetValue(unit.cache.hp)
else
unit.cache.hpanimation = true
@@ -1265,7 +1271,7 @@ function pfUI.uf:RefreshUnit(unit, component)
end
if unit.cache.powerdisplay ~= unit.cache.power then
if pfUI_config.unitframes.animation_speed == "1" then
if C.unitframes.animation_speed == "1" then
unit.power.bar:SetValue(unit.cache.power)
else
unit.cache.poweranimation = true
@@ -1290,17 +1296,17 @@ function pfUI.uf:RefreshUnit(unit, component)
end
local r, g, b = .2, .2, .2
if pfUI_config.unitframes.custom == "1" then
local cr, cg, cb, ca = pfUI.api.strsplit(",", pfUI_config.unitframes.customcolor)
if C.unitframes.custom == "1" then
local cr, cg, cb, ca = pfUI.api.strsplit(",", C.unitframes.customcolor)
cr, cg, cb, ca = tonumber(cr), tonumber(cg), tonumber(cb), tonumber(ca)
unit.hp.bar:SetStatusBarColor(cr, cg, cb, ca)
if pfUI_config.unitframes.pastel == "1" then
if C.unitframes.pastel == "1" then
r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5
else
r, g, b = color.r, color.g, color.b
end
else
if pfUI_config.unitframes.pastel == "1" then
if C.unitframes.pastel == "1" then
r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5
else
r, g, b = color.r, color.g, color.b
@@ -1344,7 +1350,7 @@ function pfUI.uf:ClickAction(button)
DropItemOnUnit(unitstr)
end
-- dropdown menues
-- dropdown menus
if button == "RightButton" then
if label == "player" then
ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor")
@@ -1355,12 +1361,9 @@ function pfUI.uf:ClickAction(button)
elseif label == "party" then
ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame" .. this.id .. "DropDown"), "cursor")
elseif label == "raid" then
local name = this.lastname
local id = this.id
local unit = this.label .. this.id
local name = this.lastUnit
FriendsDropDown.displayMode = "MENU"
FriendsDropDown.initialize = function() UnitPopup_ShowMenu(getglobal(UIDROPDOWNMENU_OPEN_MENU), "PARTY", unit, name, id) end
FriendsDropDown.initialize = function() UnitPopup_ShowMenu(getglobal(UIDROPDOWNMENU_OPEN_MENU), "PARTY", unitstr, name, id) end
ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor")
end
else