From 543dc86458e13ea996a29382a758b80c94d0f5a0 Mon Sep 17 00:00:00 2001 From: Road-block Date: Tue, 29 May 2018 21:39:35 +0300 Subject: [PATCH] pettarget: add pet target unitframe --- api/config.lua | 46 ++++++++++++++++++++-- api/unitframes.lua | 81 ++++++++++++++++++++------------------- env/profiles.lua | 14 +++++++ env/translations_deDE.lua | 1 + env/translations_enUS.lua | 1 + env/translations_esES.lua | 1 + env/translations_frFR.lua | 1 + env/translations_koKR.lua | 1 + env/translations_ruRU.lua | 1 + env/translations_zhCN.lua | 1 + env/translations_zhTW.lua | 1 + modules/gui.lua | 4 +- modules/pettarget.lua | 26 +++++++++++++ modules/targettarget.lua | 1 + pfUI.toc | 1 + 15 files changed, 138 insertions(+), 43 deletions(-) create mode 100644 modules/pettarget.lua diff --git a/api/config.lua b/api/config.lua index b0f81022..52c7c47b 100644 --- a/api/config.lua +++ b/api/config.lua @@ -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" diff --git a/api/unitframes.lua b/api/unitframes.lua index 72876637..1c1e3829 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -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 diff --git a/env/profiles.lua b/env/profiles.lua index 7ae10028..42cda5f9 100644 --- a/env/profiles.lua +++ b/env/profiles.lua @@ -119,6 +119,13 @@ f:SetScript("OnEvent", function() ["pspace"] = "-1", ["width"] = "125", }, + ["ptarget"] = { + ["portrait"] = "off", + ["pheight"] = "-1", + ["height"] = "8", + ["pspace"] = "-1", + ["width"] = "125", + }, }, } @@ -173,6 +180,13 @@ f:SetScript("OnEvent", function() ["width"] = "125", ["pheight"] = "6", }, + ["ptarget"] = { + ["portrait"] = "off", + ["height"] = "8", + ["pspace"] = "-1", + ["width"] = "125", + ["pheight"] = "-1", + }, ["customcolor"] = "0.1,0.2,0.2,1", ["custombg"] = "1", ["custom"] = "1", diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index f6a3bd23..679f3b18 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -325,6 +325,7 @@ pfUI_translation["deDE"] = { ["Panel"] = nil, ["Pet Bar (BarPet)"] = nil, ["Pet"] = nil, + ["Pet-Target"] = nil, ["Player"] = nil, ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = nil, ["Portrait Alpha"] = nil, diff --git a/env/translations_enUS.lua b/env/translations_enUS.lua index a34ed8e6..d2578937 100644 --- a/env/translations_enUS.lua +++ b/env/translations_enUS.lua @@ -325,6 +325,7 @@ pfUI_translation["enUS"] = { ["Panel"] = nil, ["Pet Bar (BarPet)"] = nil, ["Pet"] = nil, + ["Pet-Target"] = nil, ["Player"] = nil, ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = nil, ["Portrait Alpha"] = nil, diff --git a/env/translations_esES.lua b/env/translations_esES.lua index cc8ebaf6..fb99dd6f 100644 --- a/env/translations_esES.lua +++ b/env/translations_esES.lua @@ -325,6 +325,7 @@ pfUI_translation["esES"] = { ["Panel"] = "Panel", ["Pet Bar (BarPet)"] = "Barra de Mascota", ["Pet"] = "Mascota", + ["Pet-Target"] = nil, ["Player"] = "Jugador", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "Por favor registrar un nombre para el nuevo perfil.\nPerfiles que ya existe con el mismo nombre serán sobrescribidos.", ["Portrait Alpha"] = "Alfa del Retrato", diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 337af16e..98e099a6 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -325,6 +325,7 @@ pfUI_translation["frFR"] = { ["Panel"] = "Panneau", ["Pet Bar (BarPet)"] = "Barre des familiers (BarPet)", ["Pet"] = "Familier", + ["Pet-Target"] = nil, ["Player"] = "Joueur", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "Entrez un nom pour le nouveau profil.\nUn profil existant du même nom sera écrasé.", ["Portrait Alpha"] = "Transparence du portrait", diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 0c1f13c1..3350608e 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -324,6 +324,7 @@ pfUI_translation["koKR"] = { ["Panel"] = "패널", ["Panel Border Size"] = "패널 테두리 크기", ["Pet"] = "팻", + ["Pet-Target"] = nil, ["Pet Bar (BarPet)"] = "팻바(BarPet)", ["Player"] = "플레이어", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "새 프로필의 이름을 입력하십시오.\n동일한 이름을 작성하면 기존 프로파일을 덮어 씁니다.", diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index a4b89f68..5b6f73f0 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -325,6 +325,7 @@ pfUI_translation["ruRU"] = { ["Panel"] = "Панель", ["Pet Bar (BarPet)"] = "Панель питомца (BarPet)", ["Pet"] = "Питомец", + ["Pet-Target"] = nil, ["Player"] = "Игрок", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "Пожалуйста введите имя для нового профиля. Существующие профили, имеющие одно и то же имя, будут перезаписаны.", ["Portrait Alpha"] = "Прозрачность портрета", diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index 62d13458..6ceafb2a 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -325,6 +325,7 @@ pfUI_translation["zhCN"] = { ["Panel"] = "面板", ["Pet Bar (BarPet)"] = "宠物动作条", ["Pet"] = "宠物", + ["Pet-Target"] = nil, ["Player"] = "玩家", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "请输入新配置文件的名称。\n如果你创建具有相同名称的配置文件将覆盖现有的配置文件。", ["Portrait Alpha"] = "人偶透明度", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index 3c8a8400..ba0fe7c1 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -325,6 +325,7 @@ pfUI_translation["zhTW"] = { ["Panel"] = "面板", ["Pet Bar (BarPet)"] = "寵物動作條", ["Pet"] = "寵物", + ["Pet-Target"] = nil, ["Player"] = "玩家", ["Please enter a name for the new profile.\nExisting profiles sharing the same name will be overwritten."] = "請輸入新設定檔的名稱。\n如果你創建具有相同名稱的設定檔將覆蓋現有的設定檔。", ["Portrait Alpha"] = "人偶透明度", diff --git a/modules/gui.lua b/modules/gui.lua index e4ef13a5..25cccdfc 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -827,7 +827,8 @@ pfUI:RegisterModule("gui", function () [2] = { "target", T["Target"] }, [3] = { "ttarget", T["Target-Target"]}, [4] = { "pet", T["Pet"] }, - [5] = { "focus", T["Focus"] }, + [5] = { "ptarget", T["Pet-Target"]}, + [6] = { "focus", T["Focus"] }, }, ["gf"] = { @@ -851,6 +852,7 @@ pfUI:RegisterModule("gui", function () if not this.setup then -- link update tables update.ttarget = update["targettarget"] + update.ptarget = update["pettarget"] update.grouptarget = update["group"] update.grouppet = update["group"] diff --git a/modules/pettarget.lua b/modules/pettarget.lua new file mode 100644 index 00000000..ec83bac6 --- /dev/null +++ b/modules/pettarget.lua @@ -0,0 +1,26 @@ +pfUI:RegisterModule("pettarget", function () + -- do not go further on disabled UFs + if C.unitframes.disable == "1" then return end + + local default_border = pfUI_config.appearance.border.default + if pfUI_config.appearance.border.unitframes ~= "-1" then + default_border = pfUI_config.appearance.border.unitframes + end + + pfUI.uf.pettargetScanner = CreateFrame("Button",nil,UIParent) + pfUI.uf.pettargetScanner:SetScript("OnUpdate", function() + if pfUI.uf.pettarget.config.visible == "0" then return end + if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + .2 end + if UnitExists("pettarget") or (pfUI.unlock and pfUI.unlock:IsShown()) then + pfUI.uf.pettarget:Show() + else + pfUI.uf.pettarget:Hide() + pfUI.uf.pettarget.lastUnit = nil + end + end) + + pfUI.uf.pettarget = pfUI.uf:CreateUnitFrame("PetTarget", nil, C.unitframes.ptarget, .2) + pfUI.uf.pettarget:UpdateFrameSize() + pfUI.uf.pettarget:SetPoint("TOP", pfUI.uf.pet, "BOTTOM", 0, -default_border) + UpdateMovable(pfUI.uf.pettarget) +end) diff --git a/modules/targettarget.lua b/modules/targettarget.lua index 87096999..68d9ae44 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -4,6 +4,7 @@ pfUI:RegisterModule("targettarget", function () pfUI.uf.targettargetScanner = CreateFrame("Button",nil,UIParent) pfUI.uf.targettargetScanner:SetScript("OnUpdate", function() + if pfUI.uf.targettarget.config.visible == "0" then return end if ( this.limit or 1) > GetTime() then return else this.limit = GetTime() + .2 end if UnitExists("targettarget") or (pfUI.unlock and pfUI.unlock:IsShown()) then pfUI.uf.targettarget:Show() diff --git a/pfUI.toc b/pfUI.toc index c2d51ac7..f1db8015 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -92,3 +92,4 @@ modules\share.lua modules\tracking.lua modules\easteregg.lua modules\farmmode.lua +modules\pettarget.lua