diff --git a/modules/config.lua b/modules/config.lua index 90360b66..ab773500 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -29,6 +29,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("appearance", "castbar", "castbarcolor", ".7,.7,.9,.8") pfUI:UpdateConfig("appearance", "castbar", "channelcolor", ".9,.9,.7,.8") pfUI:UpdateConfig("appearance", "loot", "autoresize", "1") + pfUI:UpdateConfig("unitframes", nil, "disable", "0") pfUI:UpdateConfig("unitframes", nil, "pastel", "1") pfUI:UpdateConfig("unitframes", nil, "dark", "0") @@ -38,6 +39,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") pfUI:UpdateConfig("unitframes", nil, "layout", "default") pfUI:UpdateConfig("unitframes", nil, "globalclick", "0") + pfUI:UpdateConfig("unitframes", "player", "width", "200") pfUI:UpdateConfig("unitframes", "player", "height", "50") pfUI:UpdateConfig("unitframes", "player", "pheight", "10") @@ -45,15 +47,19 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "showPVPMinimap", "0") pfUI:UpdateConfig("unitframes", "player", "showPVP", "0") pfUI:UpdateConfig("unitframes", "player", "buffs", "top") + pfUI:UpdateConfig("unitframes", "target", "width", "200") pfUI:UpdateConfig("unitframes", "target", "height", "50") pfUI:UpdateConfig("unitframes", "target", "pheight", "10") pfUI:UpdateConfig("unitframes", "target", "pspace", "-3") pfUI:UpdateConfig("unitframes", "target", "buffs", "top") - pfUI:UpdateConfig("unitframes", "ttarget", "pspace", "-3") - pfUI:UpdateConfig("unitframes", "pet", "pspace", "-3") - pfUI:UpdateConfig("unitframes", "group", "hide_in_raid", "0") + pfUI:UpdateConfig("unitframes", "group", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "group", "hide_in_raid", "0") + pfUI:UpdateConfig("unitframes", "group", "clickcast", "0") + pfUI:UpdateConfig("unitframes", "group", "raid_buffs", "0") + pfUI:UpdateConfig("unitframes", "group", "raid_debuffs", "0") + pfUI:UpdateConfig("unitframes", "raid", "invert_healthbar", "0") pfUI:UpdateConfig("unitframes", "raid", "pspace", "-3") pfUI:UpdateConfig("unitframes", "raid", "show_missing", "0") @@ -67,6 +73,10 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "buffs_classonly", "0") pfUI:UpdateConfig("unitframes", "raid", "debuffs_enable", "0") pfUI:UpdateConfig("unitframes", "raid", "debuffs_class", "0") + + pfUI:UpdateConfig("unitframes", "ttarget", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "pet", "pspace", "-3") + pfUI:UpdateConfig("bars", nil, "icon_size", "24") pfUI:UpdateConfig("bars", nil, "background", "1") pfUI:UpdateConfig("bars", nil, "glowrange", "0") diff --git a/modules/group.lua b/modules/group.lua index bf9a7ad7..f134f36b 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -89,6 +89,8 @@ pfUI:RegisterModule("group", function () pfUI.utils:UpdateMovable(pfUI.uf.group[i]) pfUI.uf.group[i]:Hide() pfUI.uf.group[i].id = i + pfUI.uf.group[i].label = "party" + pfUI.uf.group[i].hp = CreateFrame("Frame",nil, pfUI.uf.group[i]) pfUI.uf.group[i].hp:SetWidth(175) @@ -149,143 +151,6 @@ pfUI:RegisterModule("group", function () pfUI.uf.group[i]:RegisterForClicks('LeftButtonUp', 'RightButtonUp') - pfUI.uf.group[i]:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit("party" .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.group[i]:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.group[i]:SetScript("OnClick", function () - if ( SpellIsTargeting() and arg1 == "RightButton" ) then - SpellStopTargeting() - return - end - - if ( arg1 == "LeftButton" ) then - if ( SpellIsTargeting() ) then - SpellTargetUnit("party" .. this.id) - elseif ( CursorHasItem() ) then - DropItemOnUnit("party" .. this.id) - else - TargetUnit("party" .. this.id) - - if pfUI_config.unitframes.globalclick == "0" then 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" - TargetLastTarget() - 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" - TargetLastTarget() - 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" - TargetLastTarget() - return - end - -- clickcast: default - else - if pfUI_config.unitframes.raid.clickcast ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast) - pfUI.uf.target.noanim = "yes" - TargetLastTarget() - return - else - -- no clickcast: default action - TargetUnit("party" .. this.id) - end - end - end - else - local x, y = GetCursorPosition() - ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame" .. this.id .. "DropDown"), "cursor") - end - end) - - pfUI.uf.group[i]:SetScript("OnUpdate", function () - if CheckInteractDistance("party" .. this.id, 4) or not UnitName("party" .. this.id) then - this:SetAlpha(1) - else - this:SetAlpha(.5) - end - - if UnitIsConnected("party" .. this.id) then - this.hp.bar:SetMinMaxValues(0, UnitHealthMax("party"..this.id)) - this.power.bar:SetMinMaxValues(0, UnitManaMax("party"..this.id)) - - local hpDisplay = this.hp.bar:GetValue() - local hpReal = UnitHealth("party"..this.id) - local hpDiff = abs(hpReal - hpDisplay) - - if hpDisplay < hpReal then - this.hp.bar:SetValue(hpDisplay + ceil(hpDiff / pfUI_config.unitframes.animation_speed)) - elseif hpDisplay > hpReal then - this.hp.bar:SetValue(hpDisplay - ceil(hpDiff / pfUI_config.unitframes.animation_speed)) - end - - local powerDisplay = this.power.bar:GetValue() - local powerReal = UnitMana("party"..this.id) - local powerDiff = abs(powerReal - powerDisplay) - - if powerDisplay < powerReal then - this.power.bar:SetValue(powerDisplay + ceil(powerDiff / pfUI_config.unitframes.animation_speed)) - elseif powerDisplay > powerReal then - this.power.bar:SetValue(powerDisplay - ceil(powerDiff / pfUI_config.unitframes.animation_speed)) - end - - _, class = UnitClass("party"..this.id) - local color = RAID_CLASS_COLORS[class] - local r, g, b = .2, .2, .2 - if pfUI_config.unitframes.dark == "1" and color then - this.hp.bar:SetStatusBarColor(r, g, b) - if pfUI_config.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - this.caption:SetTextColor(r,g,b) - elseif color then - if pfUI_config.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - this.hp.bar:SetStatusBarColor(r, g, b) - this.caption:SetTextColor(1,1,1) - end - - local pcolor = ManaBarColor[UnitPowerType("party"..this.id)] - this.power.bar:SetStatusBarColor(pcolor.r + .5, pcolor.g +.5, pcolor.b +.5, 1) - - this.caption:SetText(UnitName("party"..this.id)) - - else - this.hp.bar:SetMinMaxValues(0, 100) - this.power.bar:SetMinMaxValues(0, 100) - this.hp.bar:SetValue(0) - this.power.bar:SetValue(0) - local name = UnitName("party"..this.id) - if name then - this.caption:SetText("[OFF]" .. name) - end - end - end) + pfUI.uf:CreateUnit(pfUI.uf.group[i]) end - end) diff --git a/modules/gui.lua b/modules/gui.lua index 12a84672..522af02d 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -456,6 +456,16 @@ pfUI:RegisterModule("gui", function () frame.caption:SetJustifyV("CENTER") end + if widget == "header" then + frame:SetBackdrop(nil) + frame:SetHeight(40) + parent.objectCount = parent.objectCount + 1 + frame.caption:SetJustifyH("LEFT") + frame.caption:SetJustifyV("BOTTOM") + frame.caption:SetTextColor(.2,1,.8,1) + frame.caption:SetAllPoints(frame) + end + -- use text widget (default) if not widget or widget == "text" then -- input field @@ -692,6 +702,7 @@ pfUI:RegisterModule("gui", function () -- unitframes pfUI.gui.uf = pfUI.gui:CreateConfigTab("UnitFrames") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Settings", nil, nil, "header") pfUI.gui:CreateConfig(pfUI.gui.uf, "Disable pfUI-UnitFrames", pfUI_config.unitframes, "disable", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Use pastel colors", pfUI_config.unitframes, "pastel", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Use dark shades for healthbars", pfUI_config.unitframes, "dark", "checkbox") @@ -700,37 +711,50 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff size", pfUI_config.unitframes, "buff_size") pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff size", pfUI_config.unitframes, "debuff_size") pfUI.gui:CreateConfig(pfUI.gui.uf, "Layout", pfUI_config.unitframes, "layout", "dropdown", { "default", "tukui" }) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast for all Frames", pfUI_config.unitframes, "globalclick", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Player width", pfUI_config.unitframes.player, "width") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Player height", pfUI_config.unitframes.player, "height") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Player powerbar height", pfUI_config.unitframes.player, "pheight") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Player powerbar spacing", pfUI_config.unitframes.player, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast for all frames", pfUI_config.unitframes, "globalclick", "checkbox") + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Player", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health width", pfUI_config.unitframes.player, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health height", pfUI_config.unitframes.player, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar height", pfUI_config.unitframes.player, "pheight") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar spacing", pfUI_config.unitframes.player, "pspace") pfUI.gui:CreateConfig(pfUI.gui.uf, "Show PvP Icon", pfUI_config.unitframes.player, "showPVP", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Align PvP Icon to Minimap", pfUI_config.unitframes.player, "showPVPMinimap", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Player buff position", pfUI_config.unitframes.player, "buffs", "dropdown", { "top", "bottom", "hide"}) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target width", pfUI_config.unitframes.target, "width") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target height", pfUI_config.unitframes.target, "height") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target powerbar height", pfUI_config.unitframes.target, "pheight") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target powerbar spacing", pfUI_config.unitframes.target, "pspace") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target buff position", pfUI_config.unitframes.target, "buffs", "dropdown", { "top", "bottom", "hide"}) - pfUI.gui:CreateConfig(pfUI.gui.uf, "TargetTarget powerbar spacing", pfUI_config.unitframes.ttarget, "pspace") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Pet powerbar spacing", pfUI_config.unitframes.pet, "pspace") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Group powerbar spacing", pfUI_config.unitframes.group, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff position", pfUI_config.unitframes.player, "buffs", "dropdown", { "top", "bottom", "hide"}) + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Target", nil, nil, "header") + 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") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar spacing", pfUI_config.unitframes.target, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff position", pfUI_config.unitframes.target, "buffs", "dropdown", { "top", "bottom", "hide"}) + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Group", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar spacing", pfUI_config.unitframes.group, "pspace") pfUI.gui:CreateConfig(pfUI.gui.uf, "Hide group while in raid", pfUI_config.unitframes.group, "hide_in_raid", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Raid powerbar spacing", pfUI_config.unitframes.raid, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Clickcast", pfUI_config.unitframes.group, "clickcast", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Raidframe's buff behaviour for Group", pfUI_config.unitframes.group, "raid_buffs", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Raidframe's debuff behaviour for Group", pfUI_config.unitframes.group, "raid_debuffs", "checkbox") + + pfUI.gui:CreateConfig(pfUI.gui.uf, "Raid", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Powerbar spacing", pfUI_config.unitframes.raid, "pspace") pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Raid-healthbar", pfUI_config.unitframes.raid, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Show missing HP on raidframes", pfUI_config.unitframes.raid, "show_missing", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe", pfUI_config.unitframes.raid, "clickcast") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Shift)", pfUI_config.unitframes.raid, "clickcast_shift") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Alt)", pfUI_config.unitframes.raid, "clickcast_alt") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Ctrl)", pfUI_config.unitframes.raid, "clickcast_ctrl") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Buffs on Raidframes", pfUI_config.unitframes.raid, "buffs_buffs", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots on Raidframes", pfUI_config.unitframes.raid, "buffs_hots", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Procs on Raidframes", pfUI_config.unitframes.raid, "buffs_procs", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Only display Hots of my class", pfUI_config.unitframes.raid, "buffs_classonly", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Debuff indicators on Raidframes", pfUI_config.unitframes.raid, "debuffs_enable", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast", pfUI_config.unitframes.raid, "clickcast") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast (Shift)", pfUI_config.unitframes.raid, "clickcast_shift") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast (Alt)", pfUI_config.unitframes.raid, "clickcast_alt") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast (Ctrl)", pfUI_config.unitframes.raid, "clickcast_ctrl") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show my buffs", pfUI_config.unitframes.raid, "buffs_buffs", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show hots", pfUI_config.unitframes.raid, "buffs_hots", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show my procs", pfUI_config.unitframes.raid, "buffs_procs", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Only display hots of my class", pfUI_config.unitframes.raid, "buffs_classonly", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Debuff indicators", pfUI_config.unitframes.raid, "debuffs_enable", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Only display Debuffs for my class", pfUI_config.unitframes.raid, "debuffs_class", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Other", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "TargetTarget powerbar spacing", pfUI_config.unitframes.ttarget, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Pet powerbar spacing", pfUI_config.unitframes.pet, "pspace") + -- actionbar pfUI.gui.bar = pfUI.gui:CreateConfigTab("ActionBar") pfUI.gui:CreateConfig(pfUI.gui.bar, "Icon Size", pfUI_config.bars, "icon_size") diff --git a/modules/raid.lua b/modules/raid.lua index 8e9571bb..eed70e46 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -10,299 +10,11 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid = CreateFrame("Button","pfRaid",UIParent) pfUI.uf.raid:Hide() - function pfUI.uf.raid:AddIcon(frame, pos, icon) - local iconsize = 10 - if not frame.hp then return end - local frame = frame.hp.bar - if pos > floor(frame:GetWidth() / iconsize) then return end - - if not frame.icon then frame.icon = {} end - - for i=1,6 do - if not frame.icon[i] then - frame.icon[i] = CreateFrame("Frame", frame) - frame.icon[i]:SetPoint("TOPLEFT", frame, "TOPLEFT", (i-1)*iconsize, 0) - frame.icon[i]:SetWidth(iconsize) - frame.icon[i]:SetHeight(iconsize) - frame.icon[i]:SetAlpha(.7) - frame.icon[i]:SetParent(frame) - frame.icon[i].tex = frame.icon[i]:CreateTexture("OVERLAY") - frame.icon[i].tex:SetAllPoints(frame.icon[i]) - frame.icon[i].tex:SetTexCoord(.08, .92, .08, .92) - end - end - frame.icon[pos].tex:SetTexture(icon) - pfUI.utils:CreateBackdrop(frame.icon[pos], nil, true) - frame.icon[pos]:Show() - end - - function pfUI.uf.raid:HideIcon(frame, pos) - if not frame or not frame.hp or not frame.hp.bar then return end - - local frame = frame.hp.bar - if frame.icon and frame.icon[pos] then - frame.icon[pos]:Hide() - end - end - - function pfUI.uf.raid:SetupDebuffFilter() - if pfUI.uf.raid.debuffs then return end - - local _, myclass = UnitClass("player") - pfUI.uf.raid.debuffs = {} - if pfUI_config.unitframes.raid.debuffs_enable == "1" then - if myclass == "PALADIN" or myclass == "PRIEST" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then - table.insert(pfUI.uf.raid.debuffs, "magic") - end - - if myclass == "DRUID" or myclass == "PALADIN" or myclass == "SHAMAN" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then - table.insert(pfUI.uf.raid.debuffs, "poison") - end - - if myclass == "PRIEST" or myclass == "PALADIN" or myclass == "SHAMAN" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then - table.insert(pfUI.uf.raid.debuffs, "disease") - end - - if myclass == "DRUID" or myclass == "MAGE" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then - table.insert(pfUI.uf.raid.debuffs, "curse") - end - end - end - - function pfUI.uf.raid:SetupBuffFilter() - if pfUI.uf.raid.buffs then return end - - local _, myclass = UnitClass("player") - - pfUI.uf.raid.buffs = {} - - -- [[ DRUID ]] - if myclass == "DRUID" and pfUI_config.unitframes.raid.buffs_buffs == "1" then - -- Gift of the Wild - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_regeneration") - - -- Thorns - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_thorns") - end - - if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "DRUID") and pfUI_config.unitframes.raid.buffs_hots == "1" then - -- Regrowth - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_resistnature") - - -- Rejuvenation - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_rejuvenation") - end - - - -- [[ PRIEST ]] - if myclass == "PRIEST" and pfUI_config.unitframes.raid.buffs_buffs == "1" then - -- Prayer Of Fortitude" - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_wordfortitude") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_prayeroffortitude") - - -- Prayer of Spirit - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_divinespirit") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_prayerofspirit") - end - - if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "PRIEST") and pfUI_config.unitframes.raid.buffs_hots == "1" then - -- Renew - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_renew") - end - - if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "PRIEST") and pfUI_config.unitframes.raid.buffs_procs == "1" then - -- Inspiration - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\inv_shield_06") - end - - - -- [[ PALADIN ]] - if myclass == "PALADIN" and pfUI_config.unitframes.raid.buffs_buffs == "1" then - -- Blessing of Salvation - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_greaterblessingofsalvation") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_sealofsalvation") - - -- Blessing of Wisdom - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_sealofwisdom") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_greaterblessingofwisdom") - - -- Blessing of Sanctuary - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_lightningshield") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_greaterblessingofsanctuary") - - -- Blessing of Kings - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_magic_magearmor") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_magic_greaterblessingofkings") - - -- Blessing of Might - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_fistofjustice") - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_holy_greaterblessingofkings") - end - - - -- [[ SHAMAN ]] - if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "SHAMAN") and pfUI_config.unitframes.raid.buffs_procs == "1" then - -- Ancestral Fortitude - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_undyingstrength") - - -- Healing Way - table.insert(pfUI.uf.raid.buffs, "interface\\icons\\spell_nature_healingway") - end - end - - - function pfUI.uf.raid:RefreshUnit(unit) - if not unit.cache then unit.cache = {} end - - unit.cache.hp = UnitHealth("raid"..unit.id) - unit.cache.hpmax = UnitHealthMax("raid"..unit.id) - unit.cache.power = UnitMana("raid" .. unit.id) - unit.cache.powermax = UnitManaMax("raid" .. unit.id) - - unit.hp.bar:SetMinMaxValues(0, unit.cache.hpmax) - unit.power.bar:SetMinMaxValues(0, unit.cache.powermax) - - pfUI.uf.raid:SetupDebuffFilter() - if table.getn(pfUI.uf.raid.debuffs) > 0 then - local infected = false - for i=1,32 do - local _,_,dtype = UnitDebuff("raid" .. unit.id, i) - if dtype then - for _, filter in pairs(pfUI.uf.raid.debuffs) do - if filter == string.lower(dtype) then - if dtype == "Magic" then - if not unit.hp.bar.magic then - unit.hp.bar.magic = CreateFrame("Frame", unit.hp.bar) - unit.hp.bar.magic:SetAllPoints(unit) - unit.hp.bar.magic:SetParent(unit.hp.bar) - unit.hp.bar.magic.tex = unit.hp.bar.magic:CreateTexture("OVERLAY") - unit.hp.bar.magic.tex:SetAllPoints(unit.hp.bar.magic) - unit.hp.bar.magic.tex:SetTexture(.2,.8,.8,.4) - end - unit.hp.bar.magic:Show() - infected = true - - elseif dtype == "Poison" then - if not unit.hp.bar.poison then - unit.hp.bar.poison = CreateFrame("Frame", unit.hp.bar) - unit.hp.bar.poison:SetAllPoints(unit) - unit.hp.bar.poison:SetParent(unit.hp.bar) - unit.hp.bar.poison.tex = unit.hp.bar.poison:CreateTexture("OVERLAY") - unit.hp.bar.poison.tex:SetAllPoints(unit.hp.bar.poison) - unit.hp.bar.poison.tex:SetTexture(.2,.8,.2,.4) - end - unit.hp.bar.poison:Show() - infected = true - - elseif dtype == "Curse" then - if not unit.hp.bar.curse then - unit.hp.bar.curse = CreateFrame("Frame", unit.hp.bar) - unit.hp.bar.curse:SetAllPoints(unit) - unit.hp.bar.curse:SetParent(unit.hp.bar) - unit.hp.bar.curse.tex = unit.hp.bar.curse:CreateTexture("OVERLAY") - unit.hp.bar.curse.tex:SetAllPoints(unit.hp.bar.curse) - unit.hp.bar.curse.tex:SetTexture(.8,.2,.8,.4) - end - unit.hp.bar.curse:Show() - infected = true - - elseif dtype == "Disease" then - if not unit.hp.bar.disease then - unit.hp.bar.disease = CreateFrame("Frame", unit.hp.bar) - unit.hp.bar.disease:SetAllPoints(unit) - unit.hp.bar.disease:SetParent(unit.hp.bar) - unit.hp.bar.disease.tex = unit.hp.bar.disease:CreateTexture("OVERLAY") - unit.hp.bar.disease.tex:SetAllPoints(unit.hp.bar.disease) - unit.hp.bar.disease.tex:SetTexture(.8,.8,.2,.4) - end - unit.hp.bar.disease:Show() - infected = true - end - end - end - end - end - if infected == false then - if unit.hp.bar.magic then unit.hp.bar.magic:Hide() end - if unit.hp.bar.poison then unit.hp.bar.poison:Hide() end - if unit.hp.bar.curse then unit.hp.bar.curse:Hide() end - if unit.hp.bar.disease then unit.hp.bar.disease:Hide() end - end - end - - pfUI.uf.raid:SetupBuffFilter() - if table.getn(pfUI.uf.raid.buffs) > 0 then - local active = {} - - for i=1,32 do - local texture = UnitBuff("raid" .. unit.id,i) - - if texture then - -- match filter - for _, filter in pairs(pfUI.uf.raid.buffs) do - if filter == string.lower(texture) then - table.insert(active, texture) - break - end - end - - -- add icons for every found buff - for pos, icon in pairs(active) do - pfUI.uf.raid:AddIcon(this, pos, icon) - end - end - end - - -- hide unued icon slots - for pos=table.getn(active)+1, 6 do - pfUI.uf.raid:HideIcon(this, pos) - end - end - - _, class = UnitClass("raid"..unit.id) - local color = RAID_CLASS_COLORS[class] - - local r, g, b = .2, .2, .2 - if pfUI_config.unitframes.dark == "1" and color then - unit.hp.bar:SetStatusBarColor(r, g, b) - if pfUI_config.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - elseif color then - if pfUI_config.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - r, g, b = color.r, color.g, color.b - end - unit.hp.bar:SetStatusBarColor(r, g, b) - end - unit.caption:SetTextColor(r,g,b) - - local p = ManaBarColor[UnitPowerType("raid"..unit.id)] - local pr, pg, pb = 0, 0, 0 - if p then pr, pg, pb = p.r + .5, p.g +.5, p.b +.5 end - unit.power.bar:SetStatusBarColor(pr, pg, pb) - - if UnitName("raid"..unit.id) then - if unit.cache.hpmax ~= unit.cache.hp and pfUI_config.unitframes.raid.show_missing == "1" then - unit.caption:SetText("-" .. unit.cache.hpmax - unit.cache.hp) - unit.caption:SetTextColor(1,.3,.3) - else - unit.caption:SetText(UnitName("raid"..unit.id)) - if pfUI_config.unitframes.dark ~= "1" then - unit.caption:SetTextColor(1,1,1) - end - end - unit.caption:SetAllPoints(unit.hp.bar) - end - end - pfUI.uf.raid:RegisterEvent("RAID_ROSTER_UPDATE") pfUI.uf.raid:RegisterEvent("VARIABLES_LOADED") pfUI.uf.raid:SetScript("OnEvent", function() for i=1, 40 do + pfUI.uf.raid[i].label = "raid" pfUI.uf.raid[i].id = 0 pfUI.uf.raid[i]:Hide() end @@ -316,7 +28,7 @@ pfUI:RegisterModule("raid", function () if pfUI.uf.raid[ids].id == 0 then pfUI.uf.raid[ids].id = i pfUI.uf.raid[ids]:Show() - pfUI.uf.raid:RefreshUnit(pfUI.uf.raid[ids]) + pfUI.uf:RefreshUnit(pfUI.uf.raid[ids]) break end end @@ -396,136 +108,7 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i]:RegisterForClicks('LeftButtonUp', 'RightButtonUp') - pfUI.uf.raid[i]:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit("raid" .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.raid[i]:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.raid[i]:SetScript("OnClick", function () - if ( SpellIsTargeting() and arg1 == "RightButton" ) then - SpellStopTargeting() - return - end - - if ( arg1 == "LeftButton" ) then - if ( SpellIsTargeting() ) then - SpellTargetUnit("raid" .. this.id) - elseif ( CursorHasItem() ) then - DropItemOnUnit("raid" .. this.id) - else - TargetUnit("raid" .. this.id) - -- 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" - TargetLastTarget() - 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" - TargetLastTarget() - 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" - TargetLastTarget() - return - end - -- clickcast: default - else - if pfUI_config.unitframes.raid.clickcast ~= "" then - CastSpellByName(pfUI_config.unitframes.raid.clickcast) - pfUI.uf.target.noanim = "yes" - TargetLastTarget() - return - else - -- no clickcast: default action - TargetUnit("raid" .. this.id) - end - end - end - else - ToggleDropDownMenu(1, nil, getglobal("RaidMemberFrame" .. this.id .. "DropDown"), "cursor") - FriendsDropDown.initialize = RaidFrameDropDown_Initialize - FriendsDropDown.displayMode = "MENU" - ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor") - end - end) - - pfUI.uf.raid[i]:RegisterEvent("UNIT_AURA") - pfUI.uf.raid[i]:RegisterEvent("UNIT_HEALTH") - pfUI.uf.raid[i]:RegisterEvent("UNIT_MAXHEALTH") - pfUI.uf.raid[i]:RegisterEvent("UNIT_MANA") - pfUI.uf.raid[i]:RegisterEvent("UNIT_MANAMAX") - pfUI.uf.raid[i]:RegisterEvent("RAID_ROSTER_UPDATE") - pfUI.uf.raid[i]:SetScript("OnShow", function () - pfUI.uf.raid:RefreshUnit(this) - end) - - pfUI.uf.raid[i]:SetScript("OnEvent", function () - if arg1 == "raid" .. this.id or event == "RAID_ROSTER_UPDATE" then - pfUI.uf.raid:RefreshUnit(this) - end - end) - - pfUI.uf.raid[i]:SetScript("OnUpdate", function () - if CheckInteractDistance("raid" .. this.id, 4) or not UnitName("raid" .. this.id) then - this:SetAlpha(1) - else - this:SetAlpha(.5) - end - - if UnitIsConnected("raid" .. this.id) then - if not this.cache then return end - - local hpDisplay = this.hp.bar:GetValue() - local hpReal = this.cache.hp - local hpDiff = abs(hpReal - hpDisplay) - - if pfUI_config.unitframes.raid.invert_healthbar == "1" then - hpDisplay = this.hp.bar:GetValue() - hpReal = this.cache.hpmax - this.cache.hp - hpDiff = abs(hpReal - hpDisplay) - end - - if hpDisplay < hpReal then - this.hp.bar:SetValue(hpDisplay + ceil(hpDiff / pfUI_config.unitframes.animation_speed)) - elseif hpDisplay > hpReal then - this.hp.bar:SetValue(hpDisplay - ceil(hpDiff / pfUI_config.unitframes.animation_speed)) - else - this.hp.bar:SetValue(hpReal) - end - - local powerDisplay = this.power.bar:GetValue() - local powerReal = this.cache.power - local powerDiff = abs(powerReal - powerDisplay) - - if powerDisplay < powerReal then - this.power.bar:SetValue(powerDisplay + ceil(powerDiff / pfUI_config.unitframes.animation_speed)) - elseif powerDisplay > powerReal then - this.power.bar:SetValue(powerDisplay - ceil(powerDiff / pfUI_config.unitframes.animation_speed)) - else - this.power.bar:SetValue(this.cache.power) - end - else - this.hp.bar:SetMinMaxValues(0, 100) - this.power.bar:SetMinMaxValues(0, 100) - this.hp.bar:SetValue(0) - this.power.bar:SetValue(0) - end - end) + pfUI.uf:CreateUnit(pfUI.uf.raid[i]) end end end) diff --git a/modules/unitframes.lua b/modules/unitframes.lua new file mode 100644 index 00000000..2174423e --- /dev/null +++ b/modules/unitframes.lua @@ -0,0 +1,464 @@ +pfUI.uf = CreateFrame("Frame",nil,UIParent) + +function pfUI.uf:AddIcon(frame, pos, icon) + local iconsize = 10 + if not frame.hp then return end + local frame = frame.hp.bar + if pos > floor(frame:GetWidth() / iconsize) then return end + + if not frame.icon then frame.icon = {} end + + for i=1,6 do + if not frame.icon[i] then + frame.icon[i] = CreateFrame("Frame", frame) + frame.icon[i]:SetPoint("TOPLEFT", frame, "TOPLEFT", (i-1)*iconsize, 0) + frame.icon[i]:SetWidth(iconsize) + frame.icon[i]:SetHeight(iconsize) + frame.icon[i]:SetAlpha(.7) + frame.icon[i]:SetParent(frame) + frame.icon[i].tex = frame.icon[i]:CreateTexture("OVERLAY") + frame.icon[i].tex:SetAllPoints(frame.icon[i]) + frame.icon[i].tex:SetTexCoord(.08, .92, .08, .92) + end + end + frame.icon[pos].tex:SetTexture(icon) + pfUI.utils:CreateBackdrop(frame.icon[pos], nil, true) + frame.icon[pos]:Show() +end + +function pfUI.uf:HideIcon(frame, pos) + if not frame or not frame.hp or not frame.hp.bar then return end + + local frame = frame.hp.bar + if frame.icon and frame.icon[pos] then + frame.icon[pos]:Hide() + end +end + +function pfUI.uf:SetupDebuffFilter() + if pfUI.uf.debuffs then return end + + local _, myclass = UnitClass("player") + pfUI.uf.debuffs = {} + if pfUI_config.unitframes.raid.debuffs_enable == "1" then + if myclass == "PALADIN" or myclass == "PRIEST" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then + table.insert(pfUI.uf.debuffs, "magic") + end + + if myclass == "DRUID" or myclass == "PALADIN" or myclass == "SHAMAN" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then + table.insert(pfUI.uf.debuffs, "poison") + end + + if myclass == "PRIEST" or myclass == "PALADIN" or myclass == "SHAMAN" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then + table.insert(pfUI.uf.debuffs, "disease") + end + + if myclass == "DRUID" or myclass == "MAGE" or pfUI_config.unitframes.raid.debuffs_class ~= "1" then + table.insert(pfUI.uf.debuffs, "curse") + end + end +end + +function pfUI.uf:SetupBuffFilter() + if pfUI.uf.buffs then return end + + local _, myclass = UnitClass("player") + + pfUI.uf.buffs = {} + + -- [[ DRUID ]] + if myclass == "DRUID" and pfUI_config.unitframes.raid.buffs_buffs == "1" then + -- Gift of the Wild + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_regeneration") + + -- Thorns + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_thorns") + end + + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "DRUID") and pfUI_config.unitframes.raid.buffs_hots == "1" then + -- Regrowth + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_resistnature") + + -- Rejuvenation + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_rejuvenation") + end + + + -- [[ PRIEST ]] + if myclass == "PRIEST" and pfUI_config.unitframes.raid.buffs_buffs == "1" then + -- Prayer Of Fortitude" + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_wordfortitude") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_prayeroffortitude") + + -- Prayer of Spirit + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_divinespirit") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_prayerofspirit") + end + + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "PRIEST") and pfUI_config.unitframes.raid.buffs_hots == "1" then + -- Renew + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_renew") + end + + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "PRIEST") and pfUI_config.unitframes.raid.buffs_procs == "1" then + -- Inspiration + table.insert(pfUI.uf.buffs, "interface\\icons\\inv_shield_06") + end + + + -- [[ PALADIN ]] + if myclass == "PALADIN" and pfUI_config.unitframes.raid.buffs_buffs == "1" then + -- Blessing of Salvation + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_greaterblessingofsalvation") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_sealofsalvation") + + -- Blessing of Wisdom + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_sealofwisdom") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_greaterblessingofwisdom") + + -- Blessing of Sanctuary + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_lightningshield") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_greaterblessingofsanctuary") + + -- Blessing of Kings + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_magic_magearmor") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_magic_greaterblessingofkings") + + -- Blessing of Might + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_fistofjustice") + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_holy_greaterblessingofkings") + end + + + -- [[ SHAMAN ]] + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "SHAMAN") and pfUI_config.unitframes.raid.buffs_procs == "1" then + -- Ancestral Fortitude + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_undyingstrength") + + -- Healing Way + table.insert(pfUI.uf.buffs, "interface\\icons\\spell_nature_healingway") + end +end + +function pfUI.uf:RefreshUnit(unit) + if not unit.cache then unit.cache = {} end + if not unit.id then unit.id = "" end + + unit.cache.hp = UnitHealth(unit.label..unit.id) + unit.cache.hpmax = UnitHealthMax(unit.label..unit.id) + unit.cache.power = UnitMana(unit.label .. unit.id) + unit.cache.powermax = UnitManaMax(unit.label .. unit.id) + + if this.label == "target" and MobHealth3 then + unit.cache.hp, unit.cache.hpmax = MobHealth3:GetUnitHealth(this.label) + end + + unit.hp.bar:SetMinMaxValues(0, unit.cache.hpmax) + unit.power.bar:SetMinMaxValues(0, unit.cache.powermax) + + pfUI.uf:SetupDebuffFilter() + if table.getn(pfUI.uf.debuffs) > 0 and + ((pfUI_config.unitframes.group.raid_debuffs == "1" and this.label == "party") or + this.label == "raid") + then + local infected = false + for i=1,32 do + local _,_,dtype = UnitDebuff(unit.label .. unit.id, i) + if dtype then + for _, filter in pairs(pfUI.uf.debuffs) do + if filter == string.lower(dtype) then + if dtype == "Magic" then + if not unit.hp.bar.magic then + unit.hp.bar.magic = CreateFrame("Frame", unit.hp.bar) + unit.hp.bar.magic:SetAllPoints(unit) + unit.hp.bar.magic:SetParent(unit.hp.bar) + unit.hp.bar.magic.tex = unit.hp.bar.magic:CreateTexture("OVERLAY") + unit.hp.bar.magic.tex:SetAllPoints(unit.hp.bar.magic) + unit.hp.bar.magic.tex:SetTexture(.2,.8,.8,.4) + end + unit.hp.bar.magic:Show() + infected = true + + elseif dtype == "Poison" then + if not unit.hp.bar.poison then + unit.hp.bar.poison = CreateFrame("Frame", unit.hp.bar) + unit.hp.bar.poison:SetAllPoints(unit) + unit.hp.bar.poison:SetParent(unit.hp.bar) + unit.hp.bar.poison.tex = unit.hp.bar.poison:CreateTexture("OVERLAY") + unit.hp.bar.poison.tex:SetAllPoints(unit.hp.bar.poison) + unit.hp.bar.poison.tex:SetTexture(.2,.8,.2,.4) + end + unit.hp.bar.poison:Show() + infected = true + + elseif dtype == "Curse" then + if not unit.hp.bar.curse then + unit.hp.bar.curse = CreateFrame("Frame", unit.hp.bar) + unit.hp.bar.curse:SetAllPoints(unit) + unit.hp.bar.curse:SetParent(unit.hp.bar) + unit.hp.bar.curse.tex = unit.hp.bar.curse:CreateTexture("OVERLAY") + unit.hp.bar.curse.tex:SetAllPoints(unit.hp.bar.curse) + unit.hp.bar.curse.tex:SetTexture(.8,.2,.8,.4) + end + unit.hp.bar.curse:Show() + infected = true + + elseif dtype == "Disease" then + if not unit.hp.bar.disease then + unit.hp.bar.disease = CreateFrame("Frame", unit.hp.bar) + unit.hp.bar.disease:SetAllPoints(unit) + unit.hp.bar.disease:SetParent(unit.hp.bar) + unit.hp.bar.disease.tex = unit.hp.bar.disease:CreateTexture("OVERLAY") + unit.hp.bar.disease.tex:SetAllPoints(unit.hp.bar.disease) + unit.hp.bar.disease.tex:SetTexture(.8,.8,.2,.4) + end + unit.hp.bar.disease:Show() + infected = true + end + end + end + end + end + if infected == false then + if unit.hp.bar.magic then unit.hp.bar.magic:Hide() end + if unit.hp.bar.poison then unit.hp.bar.poison:Hide() end + if unit.hp.bar.curse then unit.hp.bar.curse:Hide() end + if unit.hp.bar.disease then unit.hp.bar.disease:Hide() end + end + end + + pfUI.uf:SetupBuffFilter() + if table.getn(pfUI.uf.buffs) > 0 and + ((pfUI_config.unitframes.group.raid_buffs == "1" and this.label == "party") or + this.label == "raid") + then + local active = {} + + for i=1,32 do + local texture = UnitBuff(unit.label .. unit.id,i) + + if texture then + -- match filter + for _, filter in pairs(pfUI.uf.buffs) do + if filter == string.lower(texture) then + table.insert(active, texture) + break + end + end + + -- add icons for every found buff + for pos, icon in pairs(active) do + pfUI.uf:AddIcon(this, pos, icon) + end + end + end + + -- hide unued icon slots + for pos=table.getn(active)+1, 6 do + pfUI.uf:HideIcon(this, pos) + end + end + + _, class = UnitClass(unit.label..unit.id) + local color = RAID_CLASS_COLORS[class] + + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.dark == "1" and color then + unit.hp.bar:SetStatusBarColor(r, g, b) + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + elseif color then + if pfUI_config.unitframes.pastel == "1" then + r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 + else + r, g, b = color.r, color.g, color.b + end + unit.hp.bar:SetStatusBarColor(r, g, b) + end + unit.caption:SetTextColor(r,g,b) + + local p = ManaBarColor[UnitPowerType(unit.label..unit.id)] + local pr, pg, pb = 0, 0, 0 + if p then pr, pg, pb = p.r + .5, p.g +.5, p.b +.5 end + unit.power.bar:SetStatusBarColor(pr, pg, pb) + + if UnitName(unit.label..unit.id) then + if this.label == "raid" and unit.cache.hpmax ~= unit.cache.hp and pfUI_config.unitframes.raid.show_missing == "1" then + unit.caption:SetText("-" .. unit.cache.hpmax - unit.cache.hp) + unit.caption:SetTextColor(1,.3,.3) + else + unit.caption:SetText(UnitName(unit.label..unit.id)) + if pfUI_config.unitframes.dark ~= "1" then + unit.caption:SetTextColor(1,1,1) + end + end + unit.caption:SetAllPoints(unit.hp.bar) + end +end + +function pfUI.uf:CreateUnit(unit) + unit:RegisterEvent("UNIT_AURA") + unit:RegisterEvent("UNIT_HEALTH") + unit:RegisterEvent("UNIT_MAXHEALTH") + unit:RegisterEvent("UNIT_DISPLAYPOWER") + unit:RegisterEvent("UNIT_MANA") + unit:RegisterEvent("UNIT_MAXMANA") + unit:RegisterEvent("UNIT_RAGE") + unit:RegisterEvent("UNIT_MAXRAGE") + unit:RegisterEvent("UNIT_ENERGY") + unit:RegisterEvent("UNIT_MAXENERGY") + unit:RegisterEvent("UNIT_FOCUS") + + unit:RegisterEvent("RAID_ROSTER_UPDATE") + unit:SetScript("OnShow", function () + pfUI.uf:RefreshUnit(this) + end) + + unit:SetScript("OnEvent", function () + if this.label == "raid" and event == "RAID_ROSTER_UPDATE" then + pfUI.uf:RefreshUnit(this) + end + + if arg1 == this.label .. this.id then + pfUI.uf:RefreshUnit(this) + end + end) + + unit:SetScript("OnClick", function () + if ( SpellIsTargeting() and arg1 == "RightButton" ) then + SpellStopTargeting() + return + end + + if ( arg1 == "LeftButton" ) then + if ( SpellIsTargeting() ) then + SpellTargetUnit(this.label .. this.id) + elseif ( CursorHasItem() ) then + DropItemOnUnit(this.label .. this.id) + else + TargetUnit(this.label .. this.id) + + -- break here if party frame and no clickcast is activated + if this.label == "party" and + pfUI_config.unitframes.group.clickcast == "0" and + pfUI_config.unitframes.globalclick == "0" then + return + end + + -- break here for non-party and non-raid frames without clickcast + if this.label ~= "raid" and this.label ~= "party" and pfUI_config.unitframes.globalclick == "0" then + 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" + TargetLastTarget() + 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" + TargetLastTarget() + 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" + TargetLastTarget() + return + end + + -- clickcast: default + else + if pfUI_config.unitframes.raid.clickcast ~= "" then + CastSpellByName(pfUI_config.unitframes.raid.clickcast) + pfUI.uf.target.noanim = "yes" + TargetLastTarget() + return + else + -- no clickcast: default action + TargetUnit(this.label .. this.id) + end + end + end + else + if this.label == "party" then + ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame" .. this.id .. "DropDown"), "cursor") + elseif this.label == "raid" then + ToggleDropDownMenu(1, nil, getglobal("RaidMemberFrame" .. this.id .. "DropDown"), "cursor") + FriendsDropDown.initialize = RaidFrameDropDown_Initialize + FriendsDropDown.displayMode = "MENU" + ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor") + end + end + end) + + unit:SetScript("OnEnter", function() + GameTooltip_SetDefaultAnchor(GameTooltip, this) + GameTooltip:SetUnit(this.label .. this.id) + GameTooltip:Show() + end) + + unit:SetScript("OnLeave", function() + GameTooltip:FadeOut() + end) + + unit:SetScript("OnUpdate", function () + if CheckInteractDistance(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then + this:SetAlpha(1) + else + this:SetAlpha(.5) + end + + if UnitIsConnected(this.label .. this.id) then + if not this.cache then return end + + local hpDisplay = this.hp.bar:GetValue() + local hpReal = this.cache.hp + local hpDiff = abs(hpReal - hpDisplay) + + if this.label == "raid" and pfUI_config.unitframes.raid.invert_healthbar == "1" then + hpDisplay = this.hp.bar:GetValue() + hpReal = this.cache.hpmax - this.cache.hp + hpDiff = abs(hpReal - hpDisplay) + end + + if hpDisplay < hpReal then + this.hp.bar:SetValue(hpDisplay + ceil(hpDiff / pfUI_config.unitframes.animation_speed)) + elseif hpDisplay > hpReal then + this.hp.bar:SetValue(hpDisplay - ceil(hpDiff / pfUI_config.unitframes.animation_speed)) + else + this.hp.bar:SetValue(hpReal) + end + + local powerDisplay = this.power.bar:GetValue() + local powerReal = this.cache.power + local powerDiff = abs(powerReal - powerDisplay) + + if powerDisplay < powerReal then + this.power.bar:SetValue(powerDisplay + ceil(powerDiff / pfUI_config.unitframes.animation_speed)) + elseif powerDisplay > powerReal then + this.power.bar:SetValue(powerDisplay - ceil(powerDiff / pfUI_config.unitframes.animation_speed)) + else + this.power.bar:SetValue(this.cache.power) + end + else + this.hp.bar:SetMinMaxValues(0, 100) + this.power.bar:SetMinMaxValues(0, 100) + this.hp.bar:SetValue(0) + this.power.bar:SetValue(0) + end + end) +end diff --git a/pfUI.lua b/pfUI.lua index fa240a99..8cc392e5 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -182,8 +182,6 @@ ScriptErrors:SetScript("OnShow", function(msg) ScriptErrors:Hide() end) -pfUI.uf = CreateFrame("Frame",nil,UIParent) - pfUI.info = CreateFrame("Button", "pfInfoBox", UIParent) pfUI.info:Hide() diff --git a/pfUI.toc b/pfUI.toc index 22c9e98e..fda967b2 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -32,6 +32,7 @@ modules\font.lua modules\addons.lua modules\minimap.lua modules\panel.lua +modules\unitframes.lua modules\player.lua modules\target.lua modules\targettarget.lua