From 17ccda5db60c861ebf34f16999705e672ae29bcf Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 4 Jul 2017 22:56:02 +0200 Subject: [PATCH] focus: add /clearfocus command --- modules/focus.lua | 22 ++++++++++++++++++++++ pfUI.lua | 13 ------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/focus.lua b/modules/focus.lua index 941b0512..6dafd0fe 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -1,3 +1,25 @@ +SLASH_PFFOCUS1 = '/focus' +function SlashCmdList.PFFOCUS(msg) + if not pfUI.uf or not pfUI.uf.focus then return end + + if msg ~= "" then + pfUI.uf.focus:Show() + pfUI.uf.focus.unitname = strlower(msg) + elseif UnitName("target") then + pfUI.uf.focus:Show() + pfUI.uf.focus.unitname = strlower(UnitName("target")) + else + pfUI.uf.focus:Hide() + end +end + +SLASH_PFCLEARFOCUS1 = '/clearfocus' +function SlashCmdList.PFCLEARFOCUS(msg) + if pfUI.uf and pfUI.uf.focus then + pfUI.uf.focus:Hide() + end +end + pfUI:RegisterModule("focus", function () -- do not go further on disabled UFs if C.unitframes.disable == "1" then return end diff --git a/pfUI.lua b/pfUI.lua index a9eb73de..6849fb42 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -17,19 +17,6 @@ function SlashCmdList.GM(msg, editbox) ToggleHelpFrame(1) end -SLASH_PFFOCUS1 = '/focus' -function SlashCmdList.PFFOCUS(msg) - if msg ~= "" then - pfUI.uf.focus:Show() - pfUI.uf.focus.unitname = strlower(msg) - elseif UnitName("target") then - pfUI.uf.focus:Show() - pfUI.uf.focus.unitname = strlower(UnitName("target")) - else - pfUI.uf.focus:Hide() - end -end - pfUI = CreateFrame("Frame",nil,UIParent) pfUI:RegisterEvent("ADDON_LOADED")