From 233facdb7db2c07ec70e5e1104b553c5f5118fd3 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 15 Apr 2017 19:30:24 +0200 Subject: [PATCH] unitframes: add support for clickcast --- api/config.lua | 16 +++++++---- api/unitframes.lua | 70 +++++++++++++++++++--------------------------- modules/gui.lua | 40 +++++++++++++------------- 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/api/config.lua b/api/config.lua index c4325347..3b071a49 100644 --- a/api/config.lua +++ b/api/config.lua @@ -76,11 +76,10 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5") pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1") pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1") - - pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") -- TODO migrate, deprecated - pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") -- TODO migrate, deprecated pfUI:UpdateConfig("unitframes", nil, "layout", "default") - pfUI:UpdateConfig("unitframes", nil, "globalclick", "0") + +-- pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") -- TODO migrate, deprecated +-- pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") -- TODO migrate, deprecated pfUI:UpdateConfig("unitframes", nil, "show_hots", "0") pfUI:UpdateConfig("unitframes", nil, "all_hots", "0") @@ -105,6 +104,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "player", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "player", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "player", "clickcast", "0") pfUI:UpdateConfig("unitframes", "player", "txtleft", "unit") pfUI:UpdateConfig("unitframes", "player", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "player", "txtright", "healthdyn") @@ -125,6 +125,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "target", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "target", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "target", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "target", "clickcast", "0") pfUI:UpdateConfig("unitframes", "target", "txtleft", "unit") pfUI:UpdateConfig("unitframes", "target", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "target", "txtright", "healthdyn") @@ -142,11 +143,11 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "group", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "group", "buff_indicator", "1") pfUI:UpdateConfig("unitframes", "group", "debuff_indicator", "1") + pfUI:UpdateConfig("unitframes", "group", "clickcast", "0") pfUI:UpdateConfig("unitframes", "group", "txtleft", "unit") pfUI:UpdateConfig("unitframes", "group", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "group", "txtright", "healthmiss") pfUI:UpdateConfig("unitframes", "group", "hide_in_raid", "0") - pfUI:UpdateConfig("unitframes", "group", "clickcast", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "portrait", "off") pfUI:UpdateConfig("unitframes", "grouptarget", "width", "120") @@ -160,6 +161,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "grouptarget", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "grouptarget", "clickcast", "0") pfUI:UpdateConfig("unitframes", "grouptarget", "txtleft", "unit") pfUI:UpdateConfig("unitframes", "grouptarget", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "grouptarget", "txtright", "healthperc") @@ -176,6 +178,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "grouppet", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "grouppet", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "grouppet", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "grouppet", "clickcast", "0") pfUI:UpdateConfig("unitframes", "grouppet", "txtleft", "unit") pfUI:UpdateConfig("unitframes", "grouppet", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "grouppet", "txtright", "healthperc") @@ -192,6 +195,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "raid", "buff_indicator", "1") pfUI:UpdateConfig("unitframes", "raid", "debuff_indicator", "1") + pfUI:UpdateConfig("unitframes", "raid", "clickcast", "0") pfUI:UpdateConfig("unitframes", "raid", "txtleft", "name") pfUI:UpdateConfig("unitframes", "raid", "txtcenter", "none") pfUI:UpdateConfig("unitframes", "raid", "txtright", "healthmiss") @@ -208,6 +212,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "ttarget", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "ttarget", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "ttarget", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "ttarget", "clickcast", "0") pfUI:UpdateConfig("unitframes", "ttarget", "txtleft", "none") pfUI:UpdateConfig("unitframes", "ttarget", "txtcenter", "name") pfUI:UpdateConfig("unitframes", "ttarget", "txtright", "none") @@ -224,6 +229,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "pet", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "pet", "buff_indicator", "0") pfUI:UpdateConfig("unitframes", "pet", "debuff_indicator", "0") + pfUI:UpdateConfig("unitframes", "pet", "clickcast", "0") pfUI:UpdateConfig("unitframes", "pet", "txtleft", "none") pfUI:UpdateConfig("unitframes", "pet", "txtcenter", "name") pfUI:UpdateConfig("unitframes", "pet", "txtright", "none") diff --git a/api/unitframes.lua b/api/unitframes.lua index 776eedbb..81c442da 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -889,50 +889,38 @@ function pfUI.uf:ClickAction(button) -- default click TargetUnit(unitstr) - -- break here if party frame and no clickcast is activated - if label == "party" and pfUI_config.unitframes.group.clickcast == "0" and pfUI_config.unitframes.globalclick == "0" then - return - end + if this.config.clickcast == "1" then + -- clickcast: shift modifier + if IsShiftKeyDown() then + if pfUI_config.unitframes.clickcast_shift ~= "" then + CastSpellByName(pfUI_config.unitframes.clickcast_shift) + if not tswitch then TargetLastTarget() end + return + end - -- break here for non-party and non-raid frames without clickcast - if label ~= "raid" and label ~= "party" and pfUI_config.unitframes.globalclick == "0" then - return - end + -- clickcast: alt modifier + elseif IsAltKeyDown() then + if pfUI_config.unitframes.clickcast_alt ~= "" then + CastSpellByName(pfUI_config.unitframes.clickcast_alt) + if not tswitch then TargetLastTarget() end + return + end - -- clickcast: shift modifier - if IsShiftKeyDown() then - if pfUI_config.unitframes.raid.clickcast_shift ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast_shift) - pfUI.uf.target.noanim = "yes" - if not tswitch then TargetLastTarget() end - return - end + -- clickcast: ctrl modifier + elseif IsControlKeyDown() then + if pfUI_config.unitframes.clickcast_ctrl ~= "" then + CastSpellByName(pfUI_config.unitframes.clickcast_ctrl) + if not tswitch then TargetLastTarget() end + return + end - -- clickcast: alt modifier - elseif IsAltKeyDown() then - if pfUI_config.unitframes.raid.clickcast_alt ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast_alt) - pfUI.uf.target.noanim = "yes" - if not tswitch then TargetLastTarget() end - return - end - - -- clickcast: ctrl modifier - elseif IsControlKeyDown() then - if pfUI_config.unitframes.raid.clickcast_ctrl ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast_ctrl) - pfUI.uf.target.noanim = "yes" - if not tswitch then TargetLastTarget() end - return - end - - -- clickcast: default - else - if pfUI_config.unitframes.raid.clickcast ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast) - pfUI.uf.target.noanim = "yes" - if not tswitch then TargetLastTarget() end - return + -- clickcast: default + else + if pfUI_config.unitframes.clickcast ~= "" then + CastSpellByName(pfUI_config.unitframes.clickcast) + if not tswitch then TargetLastTarget() end + return + end end end end diff --git a/modules/gui.lua b/modules/gui.lua index 0c874fa7..892fd7d3 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -863,11 +863,20 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Healthbar Animation Speed", C.unitframes, "animation_speed") pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Alpha", C.unitframes, "portraitalpha") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable 2D Portraits As Fallback", C.unitframes, "portraittexture", "checkbox") - - pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes, "buff_size") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes, "debuff_size") pfUI.gui:CreateConfig(pfUI.gui.uf, "Unit Frame Layout", C.unitframes, "layout", "dropdown", { "default", "tukui" }) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes, "globalclick", "checkbox") + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff- And Debuff Indicators", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots as Buff Indicators", C.unitframes, "show_hots", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots of all Classes", C.unitframes, "all_hots", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Procs as Buff Indicators", C.unitframes, "show_procs", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Procs of all Classes", C.unitframes, "all_procs", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Only Show Indicators for Dispellable Debuffs", C.unitframes, "debuffs_class", "checkbox") + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast Spells", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Click Action", C.unitframes, "clickcast") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Shift-Click Action", C.unitframes, "clickcast_shift") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Alt-Click Action", C.unitframes, "clickcast_alt") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Ctrl-Click Action", C.unitframes, "clickcast_ctrl") pfUI.gui:CreateConfig(pfUI.gui.uf, "Player", nil, nil, "header") pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.player, "portrait", "dropdown", { "bar", "left", "right", "off" }) @@ -882,6 +891,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.player, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.player, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.player, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.player, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.player, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.player, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.player, "txtright", "dropdown", txtValues) @@ -904,6 +914,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.target, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.target, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.target, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.target, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.target, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.target, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.target, "txtright", "dropdown", txtValues) @@ -921,12 +932,11 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.group, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.group, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.group, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.group, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.group, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.group, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.group, "txtright", "dropdown", txtValues) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Hide Group Frames When In A Raid", C.unitframes.group, "hide_in_raid", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.group, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Group Target", nil, nil, "header") pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.grouptarget, "portrait", "dropdown", { "bar", "left", "right", "off" }) @@ -941,6 +951,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.grouptarget, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.grouptarget, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.grouptarget, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.grouptarget, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.grouptarget, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.grouptarget, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.grouptarget, "txtright", "dropdown", txtValues) @@ -958,6 +969,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.grouppet, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.grouppet, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.grouppet, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.grouppet, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.grouppet, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.grouppet, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.grouppet, "txtright", "dropdown", txtValues) @@ -975,6 +987,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.raid, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.raid, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.raid, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.raid, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.raid, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.raid, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.raid, "txtright", "dropdown", txtValues) @@ -992,6 +1005,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.ttarget, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.target, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.target, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.target, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.ttarget, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.ttarget, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.ttarget, "txtright", "dropdown", txtValues) @@ -1009,23 +1023,11 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.pet, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Buff Indicators", C.unitframes.pet, "buff_indicator", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Debuff Indicators", C.unitframes.pet, "debuff_indicator", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", C.unitframes.pet, "clickcast", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Left Text", C.unitframes.pet, "txtleft", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Center Text", C.unitframes.pet, "txtcenter", "dropdown", txtValues) pfUI.gui:CreateConfig(pfUI.gui.uf, "Right Text", C.unitframes.pet, "txtright", "dropdown", txtValues) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff- And Debuff Indicators", nil, nil, "header") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots on Buff Indicators", C.unitframes, "show_hots", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots of all Classes", C.unitframes, "all_hots", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Procs on Buff Indicators", C.unitframes, "show_procs", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Procs of all Classes", C.unitframes, "all_procs", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Only Show Indicators for Dispellable Debuffs", C.unitframes, "debuffs_class", "checkbox") - - pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast", nil, nil, "header") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast", C.unitframes, "clickcast") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast (Shift)", C.unitframes, "clickcast_shift") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast (Alt)", C.unitframes, "clickcast_alt") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast (Ctrl)", C.unitframes, "clickcast_ctrl") - -- action bar pfUI.gui.bar = pfUI.gui:CreateConfigTab("Action Bar") pfUI.gui:CreateConfig(pfUI.gui.bar, "Icon Size", C.bars, "icon_size")