mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-28 18:36:01 +00:00
nameplates: add rightlick emulation to mouselook
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
+34
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user