From 0dac5bc1e0b632163631e503f35b58aab2cbaf6f Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 13 Nov 2016 15:02:13 +0100 Subject: [PATCH] module: add option to disable pfUI-UnitFrames --- modules/castbar.lua | 180 +++++++++++++++++++++------------------ modules/config.lua | 1 + modules/group.lua | 2 + modules/gui.lua | 1 + modules/player.lua | 3 + modules/raid.lua | 3 + modules/target.lua | 3 + modules/targettarget.lua | 3 + modules/uf_tukui.lua | 3 + 9 files changed, 116 insertions(+), 83 deletions(-) diff --git a/modules/castbar.lua b/modules/castbar.lua index 32dde386..35dc23ea 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -193,7 +193,6 @@ pfUI:RegisterModule("castbar", function () end if pfUI.uf.target then - pfUI.castbar.target = CreateFrame("Frame") pfUI.castbar.target:SetBackdrop(pfUI.backdrop) pfUI.castbar.target:SetHeight(pfUI_config.global.font_size * 2) @@ -234,105 +233,120 @@ pfUI:RegisterModule("castbar", function () pfUI.castbar.target.bar.right:SetText("right") pfUI.castbar.target.bar.right:SetJustifyH("right") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PARTY_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PARTY_BUFF") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS") - pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE") - pfUI.castbar.target:RegisterEvent("PLAYER_TARGET_CHANGED") - - pfUI.castbar.target.casterDB = {} - - pfUI.castbar.target:SetScript("OnEvent", function() - if (arg1 ~= nil) then - for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_CAST']) do - pfUI.castbar.target:Action(mob, spell) - return - end - for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_PERFORM']) do - pfUI.castbar.target:Action(mob, spell) - return - end - for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do - pfUI.castbar.target:Action(mob, spell, true) - return - end - -- this part will be used for interruption of spells - --for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do - -- pfUI.castbar.target:Action(mob, spell, "afflicted") - -- return - --end - --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do - -- -- you hit mob with XX - -- -- pfUI.castbar.target:Action(mob, spell, "hit") - -- return - --end - --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do - -- -- someone hits mob with XX - -- -- pfUI.castbar.target:Action(mob, spell, "hit") - -- return - --end - end - + pfUI.castbar.target.bar:SetScript("OnUpdate", function() if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then + local spellname = pfUI.castbar.target.casterDB[UnitName("target")].cast or 0 local starttime = pfUI.castbar.target.casterDB[UnitName("target")].starttime or 0 local casttime = pfUI.castbar.target.casterDB[UnitName("target")].casttime or 0 + if starttime + casttime > GetTime() then - pfUI.castbar.target:Show() - else - pfUI.castbar.target.casterDB[UnitName("target")] = nil - pfUI.castbar.target:Hide() - end - end - end) + if pfUI_config.castbar.target.hide_pfui == "1" then + pfUI.castbar.target:Hide() + end - pfUI.castbar.target.bar:SetScript("OnUpdate", function() - if pfUI_config.castbar.target.hide_pfui == "1" then pfUI.castbar.target:Hide() return end - if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then - local spellname = pfUI.castbar.target.casterDB[UnitName("target")].cast or 0 - local starttime = pfUI.castbar.target.casterDB[UnitName("target")].starttime or 0 - local casttime = pfUI.castbar.target.casterDB[UnitName("target")].casttime or 0 - - if starttime + casttime > GetTime() then + if pfUI.castbar.target.bar then pfUI.castbar.target.bar:SetMinMaxValues(0, casttime) pfUI.castbar.target.bar:SetValue(GetTime() - starttime) pfUI.castbar.target.bar.left:SetText(spellname) pfUI.castbar.target.bar.right:SetText(round(GetTime() - starttime,1) .. " / " .. casttime) - else - pfUI.castbar.target.casterDB[UnitName("target")] = nil - pfUI.castbar.target:Hide() end else + pfUI.castbar.target.casterDB[UnitName("target")] = nil pfUI.castbar.target:Hide() end + else + pfUI.castbar.target:Hide() + end end) + else + pfUI.castbar.target = CreateFrame("Frame") + end - function pfUI.castbar.target:Action(mob, spell, gains) - if pfLocaleSpells[pfUI.cache["locale"]][spell] ~= nil then - if gains and pfUI.castbar.target.casterDB[mob] and pfUI.castbar.target.casterDB[mob]["cast"] == spell then - pfUI.castbar.target.casterDB[mob] = nil - return - end - casttime = pfLocaleSpells[pfUI.cache["locale"]][spell].t / 1000 - icon = pfLocaleSpells[pfUI.cache["locale"]][spell].icon - pfUI.castbar.target.casterDB[mob] = {cast = spell, starttime = GetTime(), casttime = casttime, icon = icon} - if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then - pfUI.castbar.target:Show() - else + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PARTY_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PARTY_BUFF") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS") + pfUI.castbar.target:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE") + pfUI.castbar.target:RegisterEvent("PLAYER_TARGET_CHANGED") + + pfUI.castbar.target.casterDB = {} + + pfUI.castbar.target:SetScript("OnEvent", function() + if (arg1 ~= nil) then + for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_CAST']) do + pfUI.castbar.target:Action(mob, spell) + return + end + for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_PERFORM']) do + pfUI.castbar.target:Action(mob, spell) + return + end + for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_GAINS']) do + pfUI.castbar.target:Action(mob, spell, true) + return + end + -- this part will be used for interruption of spells + --for mob, spell in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_AFFLICTED']) do + -- pfUI.castbar.target:Action(mob, spell, "afflicted") + -- return + --end + --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['SPELL_HIT']) do + -- -- you hit mob with XX + -- -- pfUI.castbar.target:Action(mob, spell, "hit") + -- return + --end + --for spell, mob in string.gfind(arg1, pfLocaleSpellEvents[pfUI.cache["locale"]]['OTHER_SPELL_HIT']) do + -- -- someone hits mob with XX + -- -- pfUI.castbar.target:Action(mob, spell, "hit") + -- return + --end + end + + if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then + local starttime = pfUI.castbar.target.casterDB[UnitName("target")].starttime or 0 + local casttime = pfUI.castbar.target.casterDB[UnitName("target")].casttime or 0 + if starttime + casttime > GetTime() then + if pfUI_config.castbar.target.hide_pfui == "1" then pfUI.castbar.target:Hide() + else + pfUI.castbar.target:Show() end + else + pfUI.castbar.target.casterDB[UnitName("target")] = nil + pfUI.castbar.target:Hide() + end + end + end) + + function pfUI.castbar.target:Action(mob, spell, gains) + if pfLocaleSpells[pfUI.cache["locale"]][spell] ~= nil then + if gains and pfUI.castbar.target.casterDB[mob] and pfUI.castbar.target.casterDB[mob]["cast"] == spell then + pfUI.castbar.target.casterDB[mob] = nil + return + end + casttime = pfLocaleSpells[pfUI.cache["locale"]][spell].t / 1000 + icon = pfLocaleSpells[pfUI.cache["locale"]][spell].icon + pfUI.castbar.target.casterDB[mob] = {cast = spell, starttime = GetTime(), casttime = casttime, icon = icon} + if UnitExists("target") and pfUI.castbar.target.casterDB[UnitName("target")] then + if pfUI_config.castbar.target.hide_pfui == "1" then + pfUI.castbar.target:Hide() + else + pfUI.castbar.target:Show() + end + else + pfUI.castbar.target:Hide() end end end diff --git a/modules/config.lua b/modules/config.lua index e2dadeff..02dedb78 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -8,6 +8,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("global", nil, "font_square", "homespun") pfUI:UpdateConfig("global", nil, "font_combat", "diediedie") pfUI:UpdateConfig("global", nil, "cooldown_min", "2") + pfUI:UpdateConfig("unitframes", nil, "disable", "0") pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5") pfUI:UpdateConfig("unitframes", nil, "portrait", "1") pfUI:UpdateConfig("unitframes", nil, "buff_size", "22") diff --git a/modules/group.lua b/modules/group.lua index edf1a5a9..2f11b91c 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -1,4 +1,6 @@ pfUI:RegisterModule("group", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end -- hide blizzard group frames for i=1, 5 do diff --git a/modules/gui.lua b/modules/gui.lua index 69e1cc46..a04a29fd 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -571,6 +571,7 @@ pfUI:RegisterModule("gui", function () -- unitframes pfUI.gui.uf = pfUI.gui:CreateConfigTab("UnitFrames") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Disable pfUI-UnitFrames", pfUI_config.unitframes, "disable", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Animation speed", pfUI_config.unitframes, "animation_speed") pfUI.gui:CreateConfig(pfUI.gui.uf, "Show portrait", pfUI_config.unitframes, "portrait", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff size", pfUI_config.unitframes, "buff_size") diff --git a/modules/player.lua b/modules/player.lua index a6338e3c..1be12877 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -1,4 +1,7 @@ pfUI:RegisterModule("player", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end + PlayerFrame:Hide() PlayerFrame:UnregisterAllEvents() diff --git a/modules/raid.lua b/modules/raid.lua index 01cedab3..9b81e693 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -1,4 +1,7 @@ pfUI:RegisterModule("raid", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end + pfUI.uf.raid = CreateFrame("Button","pfRaid",UIParent) pfUI.uf.raid:Hide() diff --git a/modules/target.lua b/modules/target.lua index f5be6556..f37370e8 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -1,4 +1,7 @@ pfUI:RegisterModule("target", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end + -- Hide Blizzard target frame and unregister all events to prevent it from popping up again TargetFrame:Hide() TargetFrame:UnregisterAllEvents() diff --git a/modules/targettarget.lua b/modules/targettarget.lua index 4ffb1244..e7610a0d 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -1,4 +1,7 @@ pfUI:RegisterModule("targettarget", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end + pfUI.uf.targettargetNotify = CreateFrame("Button",nil,UIParent) pfUI.uf.targettargetNotify:SetScript("OnUpdate", function() if UnitExists("targettarget") or (pfUI.gitter and pfUI.gitter:IsShown()) then diff --git a/modules/uf_tukui.lua b/modules/uf_tukui.lua index 2303b08e..58ea6bb8 100644 --- a/modules/uf_tukui.lua +++ b/modules/uf_tukui.lua @@ -1,4 +1,7 @@ pfUI:RegisterModule("uf_tukui", function () + -- do not go further on disabled UFs + if pfUI_config.unitframes.disable == "1" then return end + if pfUI_config.unitframes.layout == "tukui" then pfUI.uf.player.caption = CreateFrame("Frame",nil, pfUI.uf.player) pfUI.uf.player.caption:SetBackdrop(pfUI.backdrop)