diff --git a/modules/config.lua b/modules/config.lua index 251b63ad..2923ccd2 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -144,6 +144,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("nameplates", nil, "showdebuffs", "0") pfUI:UpdateConfig("nameplates", nil, "clickthrough", "0") pfUI:UpdateConfig("nameplates", nil, "rightclick", "1") + pfUI:UpdateConfig("nameplates", nil, "clickthreshold", "0.5") pfUI:UpdateConfig("nameplates", nil, "raidiconsize", "16") pfUI:UpdateConfig("nameplates", nil, "players", "0") pfUI:UpdateConfig("nameplates", nil, "showhp", "0") diff --git a/modules/gui.lua b/modules/gui.lua index bab37988..cfd85593 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -990,6 +990,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Show debuffs:", pfUI_config.nameplates, "showdebuffs", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Enable Clickthrough:", pfUI_config.nameplates, "clickthrough", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Enable MouseLook on right-clicks:", pfUI_config.nameplates, "rightclick", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Rightclick threshold:", pfUI_config.nameplates, "clickthreshold") pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Raidicon size:", pfUI_config.nameplates, "raidiconsize") pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Show Players only:", pfUI_config.nameplates, "players", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.nameplates, "Show Healthpoints:", pfUI_config.nameplates, "showhp", "checkbox") diff --git a/modules/nameplates.lua b/modules/nameplates.lua index 22746697..511be566 100644 --- a/modules/nameplates.lua +++ b/modules/nameplates.lua @@ -33,6 +33,32 @@ pfUI:RegisterModule("nameplates", function () end end) + -- emulate a rightclick detection even if the mouselooking has been started + pfUI.nameplates.emulateRightClick = CreateFrame("Frame", nil, UIParent) + pfUI.nameplates.emulateRightClick.time = nil + pfUI.nameplates.emulateRightClick.frame = nil + pfUI.nameplates.emulateRightClick:SetScript("OnUpdate", function() + -- break here if nothing to do + if not pfUI.nameplates.emulateRightClick.time or not pfUI.nameplates.emulateRightClick.frame then + this:Hide() + return + end + + -- if threshold is reached (0.5 second) no click action will follow + if not IsMouselooking() and pfUI.nameplates.emulateRightClick.time + tonumber(pfUI_config.nameplates["clickthreshold"]) < GetTime() then + pfUI.nameplates.emulateRightClick:Hide() + return + end + + -- run a usual nameplate rightclick action + if not IsMouselooking() then + pfUI.nameplates.emulateRightClick.frame:Click("LeftButton") + if UnitCanAttack("player", "target") then AttackTarget() end + pfUI.nameplates.emulateRightClick:Hide() + return + end + end) + pfUI.nameplates:SetScript("OnUpdate", function() local frames = { WorldFrame:GetChildren() } for _, nameplate in ipairs(frames) do @@ -88,7 +114,14 @@ pfUI:RegisterModule("nameplates", function () nameplate:EnableMouse(true) if pfUI_config.nameplates["rightclick"] == "1" then nameplate:SetScript("OnMouseDown", function() - if arg1 and arg1 == "RightButton" then MouselookStart() end + if arg1 and arg1 == "RightButton" then + MouselookStart() + + -- start detection of the rightclick emulation + pfUI.nameplates.emulateRightClick.time = GetTime() + pfUI.nameplates.emulateRightClick.frame = this + pfUI.nameplates.emulateRightClick:Show() + end end) end else