From 79ab3ee0b30799af981e8b6744d4d891b91ad4f6 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 31 Dec 2016 18:08:02 +0100 Subject: [PATCH] target: add option to bypass initial animation --- modules/config.lua | 1 + modules/gui.lua | 1 + modules/target.lua | 16 +++++++++------- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/config.lua b/modules/config.lua index 5805f77e..44c41450 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -56,6 +56,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "buffs", "top") pfUI:UpdateConfig("unitframes", "player", "energy", "1") + pfUI:UpdateConfig("unitframes", "target", "animation", "0") pfUI:UpdateConfig("unitframes", "target", "width", "200") pfUI:UpdateConfig("unitframes", "target", "height", "50") pfUI:UpdateConfig("unitframes", "target", "pheight", "10") diff --git a/modules/gui.lua b/modules/gui.lua index 36eea99f..68db6d37 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -865,6 +865,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Show energy ticks", pfUI_config.unitframes.player, "energy", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Target", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable target switch animation", pfUI_config.unitframes.target, "animation") pfUI.gui:CreateConfig(pfUI.gui.uf, "Health width", pfUI_config.unitframes.target, "width") pfUI.gui:CreateConfig(pfUI.gui.uf, "Health height", pfUI_config.unitframes.target, "height") pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar height", pfUI_config.unitframes.target, "pheight") diff --git a/modules/target.lua b/modules/target.lua index bec49ad8..2f59aa56 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -232,6 +232,13 @@ pfUI:RegisterModule("target", function () pfUI.uf.target.hpReal = hp pfUI.uf.target.powerReal = power pfUI.uf.target.tapped = nil + + -- bypass animation + if event == "PLAYER_TARGET_CHANGED" and (pfUI.uf.target.noanim == "yes" or pfUI_config.unitframes.target.animation == "0") then + pfUI.uf.target.hp.bar:SetValue(hp) + pfUI.uf.target.power.bar:SetValue(power) + pfUI.uf.target.noanim = "no" + end end end) @@ -242,9 +249,7 @@ pfUI:RegisterModule("target", function () local hpReal = pfUI.uf.target.hpReal local hpDiff = abs(hpReal - hpDisplay) - if pfUI.uf.target.noanim == "yes" then - pfUI.uf.target.hp.bar:SetValue(hpReal) - elseif hpDisplay < hpReal then + if hpDisplay < hpReal then pfUI.uf.target.hp.bar:SetValue(hpDisplay + ceil(hpDiff / pfUI_config.unitframes.animation_speed)) elseif hpDisplay > hpReal then pfUI.uf.target.hp.bar:SetValue(hpDisplay - ceil(hpDiff / pfUI_config.unitframes.animation_speed)) @@ -254,15 +259,12 @@ pfUI:RegisterModule("target", function () local powerReal = pfUI.uf.target.powerReal local powerDiff = abs(powerReal - powerDisplay) - if pfUI.uf.target.noanim == "yes" then - pfUI.uf.target.power.bar:SetValue(powerReal) - elseif powerDisplay < powerReal then + if powerDisplay < powerReal then pfUI.uf.target.power.bar:SetValue(powerDisplay + ceil(powerDiff / pfUI_config.unitframes.animation_speed)) elseif powerDisplay > powerReal then pfUI.uf.target.power.bar:SetValue(powerDisplay - ceil(powerDiff / pfUI_config.unitframes.animation_speed)) end - pfUI.uf.target.noanim = "no" if not pfUI.uf.target.tapped and UnitIsTapped("target") and not UnitIsTappedByPlayer("target") then pfUI.uf.target.hp.bar:SetStatusBarColor(.5,.5,.5,.5)