diff --git a/api/config.lua b/api/config.lua index 713b529d..28918919 100644 --- a/api/config.lua +++ b/api/config.lua @@ -1,3 +1,5 @@ +pfUI.gui = CreateFrame("Frame",nil,UIParent) + function pfUI:UpdateConfig(group, subgroup, entry, value) -- check for missing config groups if not pfUI_config[group] then @@ -75,8 +77,8 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "portraitalpha", "0.1") pfUI:UpdateConfig("unitframes", nil, "portraittexture", "1") - pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") - pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") + pfUI:UpdateConfig("unitframes", nil, "buff_size", "20") -- TODO deprecated + pfUI:UpdateConfig("unitframes", nil, "debuff_size", "20") -- TODO deprecated pfUI:UpdateConfig("unitframes", nil, "layout", "default") pfUI:UpdateConfig("unitframes", nil, "globalclick", "0") @@ -85,28 +87,76 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "height", "50") pfUI:UpdateConfig("unitframes", "player", "pheight", "10") pfUI:UpdateConfig("unitframes", "player", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "player", "buffs", "top") + pfUI:UpdateConfig("unitframes", "player", "buffsize", "20") -- TODO migrate uf.buffsize + pfUI:UpdateConfig("unitframes", "player", "debuffs", "top") + pfUI:UpdateConfig("unitframes", "player", "debuffsize", "20") -- TODO migrate uf.debuffsize + pfUI:UpdateConfig("unitframes", "player", "txtleft", "power") + pfUI:UpdateConfig("unitframes", "player", "txtcenter", "none") + pfUI:UpdateConfig("unitframes", "player", "txtright", "healthdyn") + pfUI:UpdateConfig("unitframes", "player", "showPVPMinimap", "0") pfUI:UpdateConfig("unitframes", "player", "showPVP", "0") - pfUI:UpdateConfig("unitframes", "player", "buffs", "top") pfUI:UpdateConfig("unitframes", "player", "energy", "1") pfUI:UpdateConfig("unitframes", "target", "portrait", "bar") - pfUI:UpdateConfig("unitframes", "target", "animation", "0") 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", "target", "buffsize", "20") -- TODO migrate uf.buffsize + pfUI:UpdateConfig("unitframes", "target", "debuffs", "top") + pfUI:UpdateConfig("unitframes", "target", "debuffsize", "20") -- TODO migrate uf.debuffsize + pfUI:UpdateConfig("unitframes", "target", "txtleft", "power") + pfUI:UpdateConfig("unitframes", "target", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "target", "txtright", "healthmiss") + pfUI:UpdateConfig("unitframes", "target", "animation", "0") pfUI:UpdateConfig("unitframes", "group", "portrait", "off") + pfUI:UpdateConfig("unitframes", "group", "width", "164") + pfUI:UpdateConfig("unitframes", "group", "height", "32") + pfUI:UpdateConfig("unitframes", "group", "pheight", "4") pfUI:UpdateConfig("unitframes", "group", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "group", "buffs", "bottom") + pfUI:UpdateConfig("unitframes", "group", "buffsize", "16") + pfUI:UpdateConfig("unitframes", "group", "debuffs", "bottom") + pfUI:UpdateConfig("unitframes", "group", "debuffsize", "16") + pfUI:UpdateConfig("unitframes", "group", "txtleft", "powerperc") + pfUI:UpdateConfig("unitframes", "group", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "group", "txtright", "healthmiss") 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", "grouptarget", "portrait", "off") + pfUI:UpdateConfig("unitframes", "grouptarget", "width", "100") + pfUI:UpdateConfig("unitframes", "grouptarget", "height", "18") + pfUI:UpdateConfig("unitframes", "grouptarget", "pheight", "4") + pfUI:UpdateConfig("unitframes", "grouptarget", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "grouptarget", "buffs", "off") + pfUI:UpdateConfig("unitframes", "grouptarget", "buffsize", "16") + pfUI:UpdateConfig("unitframes", "grouptarget", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "grouptarget", "debuffsize", "16") + pfUI:UpdateConfig("unitframes", "grouptarget", "txtleft", "powerperc") + pfUI:UpdateConfig("unitframes", "grouptarget", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "grouptarget", "txtright", "healthmiss") + + pfUI:UpdateConfig("unitframes", "raid", "portrait", "off") + pfUI:UpdateConfig("unitframes", "raid", "width", "50") + pfUI:UpdateConfig("unitframes", "raid", "height", "26") + pfUI:UpdateConfig("unitframes", "raid", "pheight", "4") + pfUI:UpdateConfig("unitframes", "raid", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "raid", "buffs", "off") + pfUI:UpdateConfig("unitframes", "raid", "buffsize", "16") + pfUI:UpdateConfig("unitframes", "raid", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "raid", "debuffsize", "16") + pfUI:UpdateConfig("unitframes", "raid", "txtleft", "powerperc") + pfUI:UpdateConfig("unitframes", "raid", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "raid", "txtright", "healthmiss") + pfUI:UpdateConfig("unitframes", "raid", "invert_healthbar", "0") - pfUI:UpdateConfig("unitframes", "raid", "pspace", "-3") pfUI:UpdateConfig("unitframes", "raid", "show_missing", "0") pfUI:UpdateConfig("unitframes", "raid", "clickcast", "") pfUI:UpdateConfig("unitframes", "raid", "clickcast_shift", "") @@ -119,11 +169,31 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "debuffs_enable", "0") pfUI:UpdateConfig("unitframes", "raid", "debuffs_class", "0") - pfUI:UpdateConfig("unitframes", "ttarget", "portrait", "bar") - pfUI:UpdateConfig("unitframes", "ttarget", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "ttarget", "portrait", "bar") + pfUI:UpdateConfig("unitframes", "ttarget", "width", "100") + pfUI:UpdateConfig("unitframes", "ttarget", "height", "20") + pfUI:UpdateConfig("unitframes", "ttarget", "pheight", "3") + pfUI:UpdateConfig("unitframes", "ttarget", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "ttarget", "buffs", "off") + pfUI:UpdateConfig("unitframes", "ttarget", "buffsize", "16") + pfUI:UpdateConfig("unitframes", "ttarget", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "ttarget", "debuffsize", "16") + pfUI:UpdateConfig("unitframes", "ttarget", "txtleft", "powerperc") + pfUI:UpdateConfig("unitframes", "ttarget", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "ttarget", "txtright", "healthmiss") - pfUI:UpdateConfig("unitframes", "pet", "portrait", "bar") - pfUI:UpdateConfig("unitframes", "pet", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "pet", "portrait", "bar") + pfUI:UpdateConfig("unitframes", "pet", "width", "100") + pfUI:UpdateConfig("unitframes", "pet", "height", "16") + pfUI:UpdateConfig("unitframes", "pet", "pheight", "4") + pfUI:UpdateConfig("unitframes", "pet", "pspace", "-3") + pfUI:UpdateConfig("unitframes", "pet", "buffs", "off") + pfUI:UpdateConfig("unitframes", "pet", "buffsize", "12") + pfUI:UpdateConfig("unitframes", "pet", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "pet", "debuffsize", "12") + pfUI:UpdateConfig("unitframes", "pet", "txtleft", "powerperc") + pfUI:UpdateConfig("unitframes", "pet", "txtcenter", "healthmiss") + pfUI:UpdateConfig("unitframes", "pet", "txtright", "healthmiss") pfUI:UpdateConfig("bars", nil, "icon_size", "20") pfUI:UpdateConfig("bars", nil, "background", "1") diff --git a/api/unitframes.lua b/api/unitframes.lua index afe2e52f..23f6682a 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -1,5 +1,942 @@ pfUI.uf = CreateFrame("Frame",nil,UIParent) +local uf_defaults = { + portrait = "bar", + width = "200", + height = "50", + pheight = "10", + pspace = "-3", + buffs = "top", + buffsize = "20", + debuffs = "top", + debuffsize = "20", +} + +function pfUI.uf:CreateUnitFrame(unit, id, config, tick) + local fname + if unit == "Party" then + fname = "Group" .. (id or "") + else + fname = (unit or "") .. (id or "") + end + + local unit = strlower(unit or "") + local id = strlower(id or "") + local C = pfUI_config + local spacing = pfUI_config.unitframes.player.pspace + local default_border = pfUI_config.appearance.border.default + if pfUI_config.appearance.border.unitframes ~= "-1" then + default_border = pfUI_config.appearance.border.unitframes + end + + local f = CreateFrame("Button", "pf" .. fname, UIParent) + + f.UpdateFrameSize = pfUI.uf.UpdateFrameSize + f.GetColor = pfUI.uf.GetColor + + f.label = unit + f.id = id + f.config = config or uf_defaults + f.tick = tick + + f.hp = CreateFrame("Frame",nil, f) + f.hp:SetPoint("TOP", 0, 0) + f.hp:SetWidth(f.config.width) + f.hp:SetHeight(f.config.height) + pfUI.api.CreateBackdrop(f.hp, default_border) + + f.hp.bar = CreateFrame("StatusBar", nil, f.hp) + f.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") + f.hp.bar:SetAllPoints(f.hp) + f.hp.bar:SetMinMaxValues(0, 100) + + if pfUI_config.unitframes.custombg == "1" then + local cr, cg, cb, ca = strsplit(",", pfUI_config.unitframes.custombgcolor) + cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) + f.hp.bar.texture = f.hp.bar:CreateTexture(nil,"BACKGROUND") + f.hp.bar.texture:SetTexture(cr,cg,cb,ca) + f.hp.bar.texture:SetAllPoints(f.hp.bar) + end + + f.power = CreateFrame("Frame",nil, f) + f.power:SetPoint("BOTTOM", 0, 0) + f.power:SetWidth(f.config.width) + f.power:SetHeight(f.config.pheight) + pfUI.api.CreateBackdrop(f.power, default_border) + + f.power.bar = CreateFrame("StatusBar", nil, f.power) + f.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") + f.power.bar:SetAllPoints(f.power) + f.power.bar:SetMinMaxValues(0, 100) + + f.rightText = f:CreateFontString("Status", "OVERLAY", "GameFontNormal") + f.rightText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.rightText:ClearAllPoints() + f.rightText:SetJustifyH("RIGHT") + f.rightText:SetFontObject(GameFontWhite) + f.rightText:SetParent(f.hp.bar) + f.rightText:SetPoint("RIGHT",f.hp.bar, "RIGHT", -10, 0) + + f.leftText = f:CreateFontString("Status", "OVERLAY", "GameFontNormal") + f.leftText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.leftText:ClearAllPoints() + f.leftText:SetJustifyH("LEFT") + f.leftText:SetFontObject(GameFontWhite) + f.leftText:SetParent(f.hp.bar) + f.leftText:SetPoint("LEFT",f.hp.bar, "LEFT", 10, 0) + + f.centerText = f:CreateFontString("Status", "OVERLAY", "GameFontNormal") + f.centerText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.centerText:ClearAllPoints() + f.centerText:SetJustifyH("CENTER") + f.centerText:SetFontObject(GameFontWhite) + f.centerText:SetParent(f.hp.bar) + f.centerText:SetAllPoints(f.hp.bar) + + f:RegisterForClicks('LeftButtonUp', 'RightButtonUp', + 'MiddleButtonUp', 'Button4Up', 'Button5Up') + + f:RegisterEvent("PLAYER_ENTERING_WORLD") + + f:RegisterEvent("UNIT_DISPLAYPOWER") + f:RegisterEvent("UNIT_HEALTH") + f:RegisterEvent("UNIT_MAXHEALTH") + f:RegisterEvent("UNIT_MANA") + f:RegisterEvent("UNIT_MAXMANA") + f:RegisterEvent("UNIT_RAGE") + f:RegisterEvent("UNIT_MAXRAGE") + f:RegisterEvent("UNIT_ENERGY") + f:RegisterEvent("UNIT_MAXENERGY") + f:RegisterEvent("UNIT_FOCUS") + + f:RegisterEvent("UNIT_PORTRAIT_UPDATE") + f:RegisterEvent("UNIT_MODEL_CHANGED") + f:RegisterEvent("UNIT_AURA") -- frame=buff, frame=debuff + + f:RegisterEvent("PLAYER_AURAS_CHANGED") -- label=player && frame=buff + f:RegisterEvent("PARTY_MEMBERS_CHANGED") -- label=party, frame=leaderIcon + f:RegisterEvent("PARTY_LEADER_CHANGED") -- frame=leaderIcon + f:RegisterEvent("RAID_ROSTER_UPDATE") -- label=raid + f:RegisterEvent("PLAYER_TARGET_CHANGED") -- label=target + f:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") -- frame=lootIcon + f:RegisterEvent("RAID_TARGET_UPDATE") -- frame=raidIcon + + f:RegisterEvent("UNIT_PET") + f:RegisterEvent("UNIT_HAPPINESS") + + f:SetScript("OnShow", function () + pfUI.uf:RefreshUnit(this) + end) + f:SetScript("OnEvent", function() + if this.label == "target" and event == "PLAYER_TARGET_CHANGED" then + pfUI.uf:RefreshUnit(this, "all") + elseif ( this.label == "party" or this.label == "player" ) and event == "PARTY_MEMBERS_CHANGED" then + pfUI.uf:RefreshUnit(this, "all") + elseif this.label == "raid" and event == "RAID_ROSTER_UPDATE" then + pfUI.uf:RefreshUnit(this, "all") + elseif this.label == "player" and event == "PLAYER_AURAS_CHANGED" then + pfUI.uf:RefreshUnit(this, "aura") + elseif event == "PLAYER_ENTERING_WORLD" then + pfUI.uf:RefreshUnit(this, "all") + elseif event == "RAID_TARGET_UPDATE" then + pfUI.uf:RefreshUnit(this, "raidIcon") + elseif event == "PARTY_LOOT_METHOD_CHANGED" then + pfUI.uf:RefreshUnit(this, "lootIcon") + elseif event == "PARTY_LEADER_CHANGED" then + pfUI.uf:RefreshUnit(this, "leaderIcon") + elseif event == "UNIT_PET" and this.label == "pet" then + pfUI.uf:RefreshUnit(this) + + -- UNIT_XXX Events + elseif arg1 and arg1 == this.label .. this.id then + if event == "UNIT_PORTRAIT_UPDATE" or event == "UNIT_MODEL_CHANGED" then + pfUI.uf:RefreshUnit(this, "portrait") + elseif event == "UNIT_AURA" then + pfUI.uf:RefreshUnit(this, "aura") + else + pfUI.uf:RefreshUnit(this) + end + end + end) + + f:SetScript("OnUpdate", function() + if this.tick and not this.lastTick then this.lastTick = GetTime() + this.tick end + if this.lastTick and this.lastTick < GetTime() then + this.lastTick = GetTime() + this.tick + pfUI.uf:RefreshUnit(this, "all") + end + + if CheckInteractDistance(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then + if this:GetAlpha() ~= 1 then + this:SetAlpha(1) + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end + end + else + if this:GetAlpha() ~= .5 then + this:SetAlpha(.5) + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end + end + 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 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) + f:SetScript("OnEnter", function() + GameTooltip_SetDefaultAnchor(GameTooltip, this) + GameTooltip:SetUnit(this.label .. this.id) + GameTooltip:Show() + end) + f:SetScript("OnLeave", function() + GameTooltip:FadeOut() + end) + f:SetScript("OnClick", function () + pfUI.uf:ClickAction(arg1) + end) + + f.leaderIcon = CreateFrame("Frame", nil, f.hp.bar) + f.leaderIcon:SetWidth(10) + f.leaderIcon:SetHeight(10) + f.leaderIcon:SetPoint("CENTER", f, "TOPLEFT", 0, 0) + f.leaderIcon.texture = f.leaderIcon:CreateTexture(nil,"BACKGROUND") + f.leaderIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-LeaderIcon") + f.leaderIcon.texture:SetAllPoints(f.leaderIcon) + + f.lootIcon = CreateFrame("Frame",nil, f.hp.bar) + f.lootIcon:SetWidth(10) + f.lootIcon:SetHeight(10) + f.lootIcon:SetPoint("CENTER", f, "LEFT", 0, 0) + f.lootIcon.texture = f.lootIcon:CreateTexture(nil,"BACKGROUND") + f.lootIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-MasterLooter") + f.lootIcon.texture:SetAllPoints(f.lootIcon) + + f.raidIcon = CreateFrame("Frame", nil, f.hp.bar) + f.raidIcon:SetWidth(24) + f.raidIcon:SetHeight(24) + f.raidIcon:SetPoint("TOP", f, "TOP", 0, 6) + f.raidIcon.texture = f.raidIcon:CreateTexture(nil,"ARTWORK") + f.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") + f.raidIcon.texture:SetAllPoints(f.raidIcon) + + + if f.config.buffs ~= "off" then + f.buffs = {} + + for i=1, 16 do + local id = i + local row = 0 + if i <= 8 then row = 0 else row = 1 end + + f.buffs[i] = CreateFrame("Button", "pfUIPlayerBuff" .. i, f) + f.buffs[i]:SetID(i) + + f.buffs[i].stacks = f.buffs[i]:CreateFontString(nil, "OVERLAY", f.buffs[i]) + f.buffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.buffs[i].stacks:SetPoint("BOTTOMRIGHT", f.buffs[i], 2, -2) + f.buffs[i].stacks:SetJustifyH("LEFT") + f.buffs[i].stacks:SetShadowColor(0, 0, 0) + f.buffs[i].stacks:SetShadowOffset(0.8, -0.8) + f.buffs[i].stacks:SetTextColor(1,1,.5) + f.buffs[i].cd = f.buffs[i]:CreateFontString(nil, "OVERLAY", f.buffs[i]) + f.buffs[i].cd:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.buffs[i].cd:SetPoint("CENTER", f.buffs[i], 0, 0) + f.buffs[i].cd:SetJustifyH("LEFT") + f.buffs[i].cd:SetShadowColor(0, 0, 0) + f.buffs[i].cd:SetShadowOffset(0.8, -0.8) + f.buffs[i].cd:SetTextColor(1,1,1) + + f.buffs[i]:RegisterForClicks("RightButtonUp") + f.buffs[i]:ClearAllPoints() + + local invert, af, as + if f.config.buffs == "top" then + invert = 1 + af = "BOTTOMLEFT" + as = "TOPLEFT" + elseif f.config.buffs == "bottom" then + invert = -1 + af = "TOPLEFT" + as = "BOTTOMLEFT" + end + + f.buffs[i]:SetPoint(af, f, as, + (i-1-8*row)*((2*default_border) + C.unitframes.buff_size + 1), + invert * (row)*((2*default_border) + C.unitframes.buff_size + 1) + invert*(2*default_border + 1)) + + f.buffs[i]:SetWidth(C.unitframes.buff_size) + f.buffs[i]:SetHeight(C.unitframes.buff_size) + + f.buffs[i]:SetScript("OnEnter", function() + GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") + if this:GetParent().label == "player" then + GameTooltip:SetPlayerBuff(GetPlayerBuff(id-1,"HELPFUL")) + else + GameTooltip:SetUnitBuff(this:GetParent().label .. this:GetParent().id, id) + end + end) + + f.buffs[i]:SetScript("OnLeave", function() + GameTooltip:Hide() + end) + + f.buffs[i]:SetScript("OnClick", function() + if this:GetParent().label == "player" then + CancelPlayerBuff(GetPlayerBuff(id-1,"HELPFUL")) + end + end) + + if f.label == "player" then + f.buffs[i]:SetScript("OnUpdate", function() + local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(this:GetID()-1,"HELPFUL")) + if timeleft ~= nil and timeleft ~= 0 then + -- if there are more than 0 seconds left + if timeleft < 60 then + -- show seconds if less than 60 seconds + this.cd:SetText(ceil(timeleft)) + elseif timeleft < 3600 then + -- show minutes if less than 3600 seconds (1 hour) + this.cd:SetText(ceil(timeleft/60) .. 'm') + else + -- otherwise show hours + this.cd:SetText(ceil(timeleft/3600) .. 'h') + end + else + -- if there's no time left or not set, empty buff text + this.cd:SetText("") + end + end) + end + end + end + + if f.config.debuffs ~= "off" then + f.debuffs = {} + + for i=1, 16 do + local id = i + f.debuffs[i] = CreateFrame("Button", "pfUIPlayerDebuff" .. i, f) + f.debuffs[i]:SetID(i) + f.debuffs[i].stacks = f.debuffs[i]:CreateFontString(nil, "OVERLAY", f.debuffs[i]) + f.debuffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.debuffs[i].stacks:SetPoint("BOTTOMRIGHT", f.debuffs[i], 2, -2) + f.debuffs[i].stacks:SetJustifyH("LEFT") + f.debuffs[i].stacks:SetShadowColor(0, 0, 0) + f.debuffs[i].stacks:SetShadowOffset(0.8, -0.8) + f.debuffs[i].stacks:SetTextColor(1,1,.5) + f.debuffs[i].cd = f.debuffs[i]:CreateFontString(nil, "OVERLAY", f.debuffs[i]) + f.debuffs[i].cd:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") + f.debuffs[i].cd:SetPoint("CENTER", f.debuffs[i], 0, 0) + f.debuffs[i].cd:SetJustifyH("LEFT") + f.debuffs[i].cd:SetShadowColor(0, 0, 0) + f.debuffs[i].cd:SetShadowOffset(0.8, -0.8) + f.debuffs[i].cd:SetTextColor(1,1,1) + + f.debuffs[i]:RegisterForClicks("RightButtonUp") + f.debuffs[i]:ClearAllPoints() + f.debuffs[i]:SetWidth(C.unitframes.debuff_size) + f.debuffs[i]:SetHeight(C.unitframes.debuff_size) + f.debuffs[i]:SetNormalTexture(nil) + f.debuffs[i]:SetScript("OnEnter", function() + GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") + if this:GetParent().label == "player" then + GameTooltip:SetPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) + else + GameTooltip:SetUnitDebuff(this:GetParent().label .. this:GetParent().id, id) + end + end) + + f.debuffs[i]:SetScript("OnLeave", function() + GameTooltip:Hide() + end) + + f.debuffs[i]:SetScript("OnClick", function() + if this:GetParent().label == "player" then + CancelPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) + end + end) + + if f.label == "player" then + f.debuffs[i]:SetScript("OnUpdate", function() + local bid = GetPlayerBuff(this:GetID() - 1, "HARMFUL"); + local timeleft = GetPlayerBuffTimeLeft(bid,"HARMFUL") + + if timeleft ~= nil and timeleft ~= 0 then + -- if there are more than 0 seconds left + if timeleft < 60 then + -- show seconds if less than 60 seconds + f.debuffs[this:GetID()].cd:SetText(ceil(timeleft)) + elseif timeleft < 3600 then + -- show minutes if less than 3600 seconds (1 hour) + f.debuffs[this:GetID()].cd:SetText(ceil(timeleft/60)..'m') + else + -- otherwise show hours + f.debuffs[this:GetID()].cd:SetText(ceil(timeleft/3600) .. 'h') + end + else + -- if there's no time left or not set, empty buff text + f.debuffs[this:GetID()].cd:SetText("") + end + end) + end + end + end + + if f.config.portrait ~= "off" then + f.portrait = CreateFrame("Frame", "pfPortrait" .. f.label .. f.id, f) + f.portrait:SetFrameStrata("LOW") + f.portrait.tex = f.portrait:CreateTexture("pfPortraitTexture" .. f.label .. f.id, "OVERLAY") + f.portrait.tex:SetAllPoints(f.portrait) + f.portrait.tex:SetTexCoord(.1, .9, .1, .9) + + f.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. f.label .. f.id, f.portrait) + f.portrait.model:SetFrameStrata("LOW") + f.portrait.model:SetAllPoints(f.portrait) + f.portrait.model.next = CreateFrame("PlayerModel", nil, nil) + + if f.config.portrait == "bar" then + f.portrait:SetParent(f.hp.bar) + f.portrait:SetAllPoints(f.hp.bar) + f.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + + elseif f.config.portrait == "left" then + f.portrait:SetPoint("LEFT", f, "LEFT", 0, 0) + f.hp:ClearAllPoints() + f.hp:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, 0) + f.power:ClearAllPoints() + f.power:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 0) + pfUI.api.CreateBackdrop(f.portrait) + + elseif f.config.portrait == "right" then + f.portrait:SetPoint("RIGHT", f, "RIGHT", 0, 0) + f.hp:ClearAllPoints() + f.hp:SetPoint("TOPLEFT", f, "TOPLEFT", 0, 0) + f.power:ClearAllPoints() + f.power:SetPoint("BOTTOMLEFT", f, "BOTTOMLEFT", 0, 0) + pfUI.api.CreateBackdrop(f.portrait) + end + end + + return f +end + +function pfUI.uf:RefreshUnit(unit, component) + local component = component or "" + -- break early on misconfigured UF's + if not this.label then return end + + local default_border = pfUI_config.appearance.border.default + if pfUI_config.appearance.border.groupframes ~= "-1" then + default_border = pfUI_config.appearance.border.groupframes + end + + local C = pfUI_config + + if UnitName(this.label .. this.id) or (pfUI.gitter and pfUI.gitter:IsShown()) then + this:Show() else this:Hide() + end + + if not this.cache then unit.cache = {} end + if not unit.id then unit.id = "" end + + -- Raid Icon + if this.raidIcon and ( component == "all" or component == "raidIcon" ) then + local raidIcon = GetRaidTargetIndex(this.label .. this.id) + if raidIcon and UnitName(this.label .. this.id) then + SetRaidTargetIconTexture(this.raidIcon.texture, raidIcon) + this.raidIcon:Show() + else + this.raidIcon:Hide() + end + end + + -- Leader Icon + if this.leaderIcon and ( component == "all" or component == "leaderIcon" ) then + if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then + this.leaderIcon:Hide() + elseif UnitIsPartyLeader(this.label .. this.id) then + this.leaderIcon:Show() + else + this.leaderIcon:Hide() + end + end + + -- Loot Icon + if this.lootIcon and ( component == "all" or component == "lootIcon" ) then + local _, lootmaster = GetLootMethod() + if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then + this.lootIcon:Hide() + elseif lootmaster and ( + ( this.label == "party" and tonumber(this.id) == lootmaster ) or + ( this.label == "player" and lootmaster == 0 ) )then + this.lootIcon:Show() + else + this.lootIcon:Hide() + end + end + + -- Buffs + if this.buffs and ( component == "all" or component == "aura" ) then + for i=1, 16 do + local texture, stacks + if this.label == "player" then + stacks = GetPlayerBuffApplications(GetPlayerBuff(i-1,"HELPFUL")) + texture = GetPlayerBuffTexture(GetPlayerBuff(i-1,"HELPFUL")) + else + texture, stacks = UnitBuff(this.label .. this.id ,i) + end + + pfUI.api.CreateBackdrop(this.buffs[i], default_border) + this.buffs[i]:SetNormalTexture(texture) + for i,v in ipairs({this.buffs[i]:GetRegions()}) do + if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end + end + + if texture then + this.buffs[i]:Show() + if stacks > 1 then + this.buffs[i].stacks:SetText(stacks) + else + this.buffs[i].stacks:SetText("") + end + else + this.buffs[i]:Hide() + end + end + end + + -- Debuffs + if this.debuffs and ( component == "all" or component == "aura" ) then + for i=1, 16 do + local row = 0 + local top = 0 + if i > 8 then row = 1 end + + if this.config.buffs == this.config.debuffs then + if this.buffs[1]:IsShown() then top = top + 1 end + if this.buffs[9]:IsShown() then top = top + 1 end + end + + local invert, af, as + if this.config.debuffs == "top" then + invert = 1 + af = "BOTTOMLEFT" + as = "TOPLEFT" + elseif this.config.debuffs == "bottom" then + invert = -1 + af = "TOPLEFT" + as = "BOTTOMLEFT" + end + + this.debuffs[i]:SetPoint(af, this, as, + (i-1-8*row)*((2*default_border) + C.unitframes.debuff_size + 1), + invert * (top)*((2*default_border) + C.unitframes.buff_size + 1) + + invert * (row)*((2*default_border) + C.unitframes.debuff_size + 1) + invert*(2*default_border + 1)) + + local texture, stacks, dtype + if this.label == "player" then + texture = GetPlayerBuffTexture(GetPlayerBuff(i-1, "HARMFUL")) + stacks = GetPlayerBuffApplications(GetPlayerBuff(i-1, "HARMFUL")) + dtype = GetPlayerBuffDispelType(GetPlayerBuff(i-1, "HARMFUL")) + else + texture, stacks, dtype = UnitDebuff(this.label .. this.id ,i) + end + + pfUI.api.CreateBackdrop(this.debuffs[i], default_border) + this.debuffs[i]:SetNormalTexture(texture) + for i,v in ipairs({this.debuffs[i]:GetRegions()}) do + if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end + end + + if dtype == "Magic" then + this.debuffs[i].backdrop:SetBackdropBorderColor(0,1,1,1) + elseif dtype == "Poison" then + this.debuffs[i].backdrop:SetBackdropBorderColor(0,1,0,1) + elseif dtype == "Curse" then + this.debuffs[i].backdrop:SetBackdropBorderColor(1,0,1,1) + elseif dtype == "Disease" then + this.debuffs[i].backdrop:SetBackdropBorderColor(1,1,0,1) + else + this.debuffs[i].backdrop:SetBackdropBorderColor(1,0,0,1) + end + + if texture then + this.debuffs[i]:Show() + if stacks > 1 then + this.debuffs[i].stacks:SetText(stacks) + else + this.debuffs[i].stacks:SetText("") + end + else + this.debuffs[i]:Hide() + end + end + end + + -- portrait + if this.portrait and ( component == "all" or component == "portrait" ) then + if not UnitIsVisible(this.label .. this.id) or not UnitIsConnected(this.label .. this.id) then + if this.config.portrait == "bar" then + this.portrait.tex:Hide() + this.portrait.model:Hide() + elseif pfUI_config.unitframes.portraittexture == "1" then + this.portrait.tex:Show() + this.portrait.model:Hide() + SetPortraitTexture(this.portrait.tex, this.label .. this.id) + else + this.portrait.tex:Hide() + this.portrait.model:Show() + this.portrait.model:SetModelScale(4.25) + this.portrait.model:SetPosition(0, 0, -1) + this.portrait.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") + end + else + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end + this.portrait.tex:Hide() + this.portrait.model:Show() + this.portrait.model.next:SetUnit(this.label .. this.id) + + if this.portrait.model.lastUnit ~= UnitName(this.label .. this.id) + or this.portrait.model:GetModel() ~= this.portrait.model.next:GetModel() then + this.portrait.model:SetUnit(this.label .. this.id) + this.portrait.model.lastUnit = UnitName(this.label .. this.id) + end + this.portrait.model:SetCamera(0) + + end + end + + -- Unit HP/MP + 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) + + local color = { r = .2, g = .2, b = .2 } + if UnitIsPlayer(unit.label..unit.id) then + local _, class = UnitClass(unit.label..unit.id) + color = RAID_CLASS_COLORS[class] or color + elseif unit.label == "pet" then + local happiness = GetPetHappiness() + if happiness == 1 then + color = { r = 1, g = 0, b = 0 } + elseif happiness == 2 then + color = { r = 1, g = 1, b = 0 } + else + color = { r = 0, g = 1, b = 0 } + end + else + color = UnitReactionColor[UnitReaction(unit.label..unit.id, "player")] or color + end + + local r, g, b = .2, .2, .2 + if pfUI_config.unitframes.custom == "1" then + local cr, cg, cb, ca = pfUI.api.strsplit(",", pfUI_config.unitframes.customcolor) + cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) + unit.hp.bar:SetStatusBarColor(cr, cg, cb) + 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 + else + 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 + + 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 + unit.leftText:SetText(pfUI.uf:GetStatusValue(unit, "left")) + unit.centerText:SetText(pfUI.uf:GetStatusValue(unit, "center")) + unit.rightText:SetText(pfUI.uf:GetStatusValue(unit, "right")) + + if UnitIsTapped(unit.label .. unit.id) and not UnitIsTappedByPlayer(unit.label .. unit.id) then + unit.hp.bar:SetStatusBarColor(.5,.5,.5,.5) + end + end + + 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 +end + +function pfUI.uf.UpdateFrameSize(self) + local unit = self.label .. self.id + local default_border = pfUI_config.appearance.border.default + if pfUI_config.appearance.border.groupframes ~= "-1" then + default_border = pfUI_config.appearance.border.groupframes + end + + local spacing = self.config.pspace + local width = self.config.width + local height = self.config.height + local pheight = self.config.pheight + local real_height = height + spacing + pheight + 2*default_border + local portrait = 0 + if self.config.portrait == "left" or self.config.portrait == "right" then + self.portrait:SetWidth(real_height) + self.portrait:SetHeight(real_height) + portrait = real_height + spacing + 2*default_border + end + + self:SetWidth(width + portrait) + self:SetHeight(real_height) +end + +function pfUI.uf:ClickAction(button) + local label = this.label or "" + local id = this.id or "" + local unitstr = label .. id + + if SpellIsTargeting() and button == "RightButton" then + SpellStopTargeting() + return + end + + if SpellIsTargeting() and button == "LeftButton" then + SpellTargetUnit(unitstr) + elseif CursorHasItem() then + DropItemOnUnit(unitstr) + end + + -- dropdown menues + if button == "RightButton" then + if label == "player" then + ToggleDropDownMenu(1, nil, pfUI.uf.player.Dropdown,"cursor") + if UnitIsPartyLeader("player") then + UIDropDownMenu_AddButton({text = "Reset Instances", func = ResetInstances, notCheckable = 1}, 1) + end + elseif label == "target" then + ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor") + elseif label == "pet" then + ToggleDropDownMenu(1, nil, PetFrameDropDown, "cursor") + elseif label == "party" then + ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame" .. this.id .. "DropDown"), "cursor") + elseif 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 + else + -- drop food on petframe + if label == "pet" and CursorHasItem() then + local _, playerClass = UnitClass("player") + if playerClass == "HUNTER" then + DropItemOnUnit("pet") + return + end + end + + -- prevent TargetLastTarget if target was target + local tswitch = UnitIsUnit(unitstr, "target") + + -- 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 + + -- 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: 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: 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 + end + end + end +end + function pfUI.uf:AddIcon(frame, pos, icon) local iconsize = 10 if not frame.hp then return end @@ -168,468 +1105,135 @@ function pfUI.uf:SetupBuffFilter() end end -function pfUI.uf:ClickAction(button) - local label = this.label or "" - local id = this.id or "" - local unitstr = label .. id +function pfUI.uf:GetStatusValue(unit, pos) + if not pos or not unit then return end + local config = unit.config["txt"..pos] + local unitstr = unit.label .. unit.id + local frame = unit[pos .. "Text"] - if SpellIsTargeting() and button == "RightButton" then - SpellStopTargeting() - return + -- as a fallback, draw the name + if pos == "center" and not config then + frame:SetTextColor(pfUI.uf:GetColorUnit(unitstr)) + return UnitName(unitstr) end - if SpellIsTargeting() and button == "LeftButton" then - SpellTargetUnit(unitstr) - elseif CursorHasItem() then - DropItemOnUnit(unitstr) - end + if config == "unit" then + local level = UnitLevel(unitstr) + if level == -1 then level = "??" end - -- dropdown menues - if button == "RightButton" then - if label == "player" then - ToggleDropDownMenu(1, nil, pfUI.uf.player.Dropdown,"cursor") - if UnitIsPartyLeader("player") then - UIDropDownMenu_AddButton({text = "Reset Instances", func = ResetInstances, notCheckable = 1}, 1) - end - elseif label == "target" then - ToggleDropDownMenu(1, nil, TargetFrameDropDown, "cursor") - elseif label == "pet" then - ToggleDropDownMenu(1, nil, PetFrameDropDown, "cursor") - elseif label == "party" then - ToggleDropDownMenu(1, nil, getglobal("PartyMemberFrame" .. this.id .. "DropDown"), "cursor") - elseif label == "raid" then - ToggleDropDownMenu(1, nil, getglobal("RaidMemberFrame" .. this.id .. "DropDown"), "cursor") - FriendsDropDown.initialize = RaidFrameDropDown_Initialize - FriendsDropDown.displayMode = "MENU" - ToggleDropDownMenu(1, nil, FriendsDropDown, "cursor") + local name = UnitName(unitstr) + + local elite = UnitClassification(unitstr) + if elite == "worldboss" then + level = level .. "B" + elseif elite == "rareelite" then + level = level .. "R+" + elseif elite == "elite" then + level = level .. "+" + elseif elite == "rare" then + level = level .. "R" + end + level = this:GetColor("level") .. level + name = this:GetColor("unit") .. name + + return level .. " " .. name + + elseif config == "name" then + return this:GetColor("unit") .. UnitName(unitstr) + elseif config == "level" then + return this:GetColor("level") .. UnitLevel(unitstr) + elseif config == "class" then + return this:GetColor("class") .. UnitClass(unitstr) + + -- health + elseif config == "health" then + return this:GetColor("health") .. UnitHealth(unitstr) + elseif config == "healthmax" then + return this:GetColor("health") .. UnitHealthMax(unitstr) + elseif config == "healthperc" then + return this:GetColor("health") .. ceil(UnitHealth(unitstr) / UnitHealthMax(unitstr) * 100) + elseif config == "healthmiss" then + return this:GetColor("health") .. ceil(UnitHealth(unitstr) - UnitHealthMax(unitstr)) + elseif config == "healthdyn" then + if UnitHealth(unitstr) ~= UnitHealthMax(unitstr) then + return this:GetColor("health") .. UnitHealth(unitstr) .. " - " .. ceil(UnitHealth(unitstr) / UnitHealthMax(unitstr) * 100) .. "%" + else + return this:GetColor("health") .. UnitHealth(unitstr) + end + + -- mana/power/focus + elseif config == "power" then + return this:GetColor("power") .. UnitMana(unitstr) + elseif config == "powermax" then + return this:GetColor("power") .. UnitManaMax(unitstr) + elseif config == "powerperc" then + return this:GetColor("power") .. ceil(UnitMana(unitstr) / UnitManaMax(unitstr) * 100) + elseif config == "powermiss" then + return this:GetColor("power") .. ceil(UnitMana(unitstr) - UnitManaMax(unitstr)) + elseif config == "powerdyn" then + if UnitMana(unitstr) ~= UnitManaMax(unitstr) then + return this:GetColor("power") .. UnitMana(unitstr) .. " - " .. ceil(UnitMana(unitstr) / UnitManaMax(unitstr) * 100) .. "%" + else + return this:GetColor("power") .. UnitMana(unitstr) end else - -- drop food on petframe - if label == "pet" and CursorHasItem() then - local _, playerClass = UnitClass("player") - if playerClass == "HUNTER" then - DropItemOnUnit("pet") - return - end - end - - -- prevent TargetLastTarget if target was target - local tswitch = UnitIsUnit(unitstr, "target") - - -- 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 - - -- 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: 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: 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 - end - end + return "" 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.custom == "1" and color then - local cr, cg, cb, ca = pfUI.api.strsplit(",", pfUI_config.unitframes.customcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - unit.hp.bar:SetStatusBarColor(cr, cg, cb) - if pfUI_config.unitframes.pastel == "1" then - r, g, b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 +function pfUI.uf.GetColor(self, preset) + local unitstr = self.label .. self.id + local r, g, b = 1, 1, 1 + if preset == "unit" then + if UnitIsPlayer(unitstr) then + local _, class = UnitClass(unitstr) + r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b else - r, g, b = color.r, color.g, color.b + r, g, b = UnitReactionColor[UnitReaction(unitstr, "player")].r, UnitReactionColor[UnitReaction(unitstr, "player")].g, UnitReactionColor[UnitReaction(unitstr, "player")].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) + elseif preset == "class" then + local _, class = UnitClass(unitstr) + r = RAID_CLASS_COLORS[class].r + g = RAID_CLASS_COLORS[class].g + b = RAID_CLASS_COLORS[class].b - 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) + elseif preset == "reaction" then + r = UnitReactionColor[UnitReaction(unitstr, "player")].r + g = UnitReactionColor[UnitReaction(unitstr, "player")].g + b = UnitReactionColor[UnitReaction(unitstr, "player")].b + + elseif preset == "health" then + local perc = UnitHealth(unitstr) / UnitHealthMax(unitstr) + local r1, g1, b1, r2, g2, b2 + if perc <= 0.5 then + perc = perc * 2 + r1, g1, b1 = 1, 0, 0 + r2, g2, b2 = 1, 1, 0 else - unit.caption:SetText(UnitName(unit.label..unit.id)) - if pfUI_config.unitframes.custom ~= "1" then - unit.caption:SetTextColor(1,1,1) - end + perc = perc * 2 - 1 + r1, g1, b1 = 1, 1, 0 + r2, g2, b2 = 0, 1, 0 end - unit.caption:SetAllPoints(unit.hp.bar) + r = r1 + (r2 - r1)*perc + g = g1 + (g2 - g1)*perc + b = b1 + (b2 - b1)*perc + + elseif preset == "power" then + r = ManaBarColor[UnitPowerType(unitstr)].r + g = ManaBarColor[UnitPowerType(unitstr)].g + b = ManaBarColor[UnitPowerType(unitstr)].b + + elseif preset == "level" then + r = GetDifficultyColor(UnitLevel(unitstr)).r + g = GetDifficultyColor(UnitLevel(unitstr)).g + b = GetDifficultyColor(UnitLevel(unitstr)).b end -end - -function pfUI.uf:CreatePortrait(frame, pos, spacing) - if not frame then return end - if pos == "off" then return end - - local default_border = pfUI_config.appearance.border.default - if pfUI_config.appearance.border.unitframes ~= "-1" then - default_border = pfUI_config.appearance.border.unitframes - end - - local unit = frame.label - local id = frame.id or "" - local unitstr = unit .. id - - frame.portrait = CreateFrame("Frame", "pfPortrait" .. unitstr, frame) - frame.portrait:RegisterEvent("UNIT_PORTRAIT_UPDATE") - frame.portrait:RegisterEvent("UNIT_MODEL_CHANGED") - frame.portrait:RegisterEvent("PLAYER_ENTERING_WORLD") - frame.portrait:RegisterEvent("PLAYER_TARGET_CHANGED") - frame.portrait:RegisterEvent("PARTY_MEMBERS_CHANGED") - - frame.portrait.base = frame - frame.portrait.pos = pos - - frame.portrait.tex = frame.portrait:CreateTexture("pfPortraitTexture" .. unitstr, "OVERLAY") - frame.portrait.tex:SetAllPoints(frame.portrait) - frame.portrait.tex:SetTexCoord(.1, .9, .1, .9) - - frame.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. unitstr, frame.portrait) - frame.portrait.model:SetFrameStrata("MEDIUM") - frame.portrait.model:SetAllPoints(frame.portrait) - - frame.portrait:SetScript("OnEvent", function() - local unit = this.base.label - local id = this.base.id or "" - local unitstr = unit .. id - - if event == "PLAYER_ENTERING_WORLD" or - ( event == "PARTY_MEMBERS_CHANGED" and this.base.label and this.base.label == "party" ) or - ( unitstr == "target" and event == "PLAYER_TARGET_CHANGED" ) or - ( unitstr == "targettarget" and event == "PLAYER_TARGET_CHANGED" ) or - ( arg1 and arg1 == unitstr ) then - pfUI.uf:UpdatePortrait() - end - end) - - frame.portrait:SetScript("OnShow", function() - pfUI.uf:UpdatePortrait() - end) - - if pos == "bar" then - frame.portrait:SetParent(frame.hp.bar) - frame.portrait:SetAllPoints(frame.hp.bar) - frame.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) - elseif pos == "left" then - frame.portrait:SetWidth(frame:GetHeight()) - frame.portrait:SetHeight(frame:GetHeight()) - frame:SetWidth(frame:GetWidth() + default_border*2 + spacing + frame.portrait:GetWidth()) - frame.portrait:SetPoint("LEFT", frame, "LEFT", 0, 0) - - frame.hp:ClearAllPoints() - frame.hp:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, 0) - frame.power:ClearAllPoints() - frame.power:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 0) - - pfUI.api.CreateBackdrop(frame.portrait) - elseif pos == "right" then - frame.portrait:SetWidth(frame:GetHeight()) - frame.portrait:SetHeight(frame:GetHeight()) - frame:SetWidth(frame:GetWidth() + default_border*2 + spacing + frame.portrait:GetWidth()) - frame.portrait:SetPoint("RIGHT", frame, "RIGHT", 0, 0) - - frame.hp:ClearAllPoints() - frame.hp:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) - frame.power:ClearAllPoints() - frame.power:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 0) - - pfUI.api.CreateBackdrop(frame.portrait) - end -end - -function pfUI.uf:UpdatePortrait() - local unit = this.base.label - local id = this.base.id or "" - local unitstr = unit .. id - local name = UnitName(unitstr) or "" - - if not UnitIsVisible(unitstr) or not UnitIsConnected(unitstr) then - if this.pos == "bar" then - this.tex:Hide() - this.model:Hide() - elseif pfUI_config.unitframes.portraittexture == "1" then - this.tex:Show() - this.model:Hide() - SetPortraitTexture(this.tex, unitstr) - else - this.tex:Hide() - this.model:Show() - this.model:SetModelScale(4.25) - this.model:SetPosition(0, 0, -1) - this.model:SetModel("Interface\\Buttons\\talktomequestionmark.mdx") - end - else - this.tex:Hide() - this.model:Show() - this.model:SetUnit(unitstr) - this.model:SetCamera(0) - 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:RegisterEvent("PARTY_MEMBERS_CHANGED") - - unit:SetScript("OnShow", function () - pfUI.uf:RefreshUnit(this) - end) - - unit:SetScript("OnEvent", function () - if this.label == "party" and event == "PARTY_MEMBERS_CHANGED" then - pfUI.uf:RefreshUnit(this) - end - - if this.label == "raid" and event == "RAID_ROSTER_UPDATE" then - pfUI.uf:RefreshUnit(this) - end - - if arg1 and arg1 == this.label .. this.id then - pfUI.uf:RefreshUnit(this) - end - end) - - unit:SetScript("OnClick", function () - pfUI.uf:ClickAction(arg1) - 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) + + -- pastel + r = ( r + .75 ) * .5 + g = ( g + .75 ) * .5 + b = ( b + .75 ) * .5 + + return "|cff" .. string.format("%02x%02x%02x", r*255, g*255, b*255) end diff --git a/modules/group.lua b/modules/group.lua index 5d5800f3..9067b7eb 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -20,10 +20,6 @@ pfUI:RegisterModule("group", function () pfUI.uf.group = CreateFrame("Button","pfGroup",UIParent) pfUI.uf.group:Hide() - pfUI.uf.group:RegisterEvent("RAID_TARGET_UPDATE") - pfUI.uf.group:RegisterEvent("PARTY_LEADER_CHANGED") - pfUI.uf.group:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") - pfUI.uf.group:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.uf.group:RegisterEvent("PARTY_MEMBERS_CHANGED") pfUI.uf.group:RegisterEvent("PARTY_MEMBER_ENABLE") @@ -38,33 +34,6 @@ pfUI:RegisterModule("group", function () if C.unitframes.group.hide_in_raid == "1" and UnitInRaid("player") then pfUI.uf.group[i]:Hide() else - if event == "RAID_TARGET_UPDATE" or event == "PLAYER_ENTERING_WORLD" or event == "PARTY_MEMBERS_CHANGED" then - local raidIcon = GetRaidTargetIndex("party" .. i) - if raidIcon and UnitExists("party" .. i) then - SetRaidTargetIconTexture(pfUI.uf.group[i].hp.raidIcon.texture, raidIcon) - pfUI.uf.group[i].hp.raidIcon:Show() - else - pfUI.uf.group[i].hp.raidIcon:Hide() - end - end - - if event == "PARTY_LEADER_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PARTY_MEMBERS_CHANGED" then - if UnitIsPartyLeader("party"..i) then - pfUI.uf.group[i].hp.leaderIcon:Show() - else - pfUI.uf.group[i].hp.leaderIcon:Hide() - end - end - - if event == "PARTY_LOOT_METHOD_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PARTY_MEMBERS_CHANGED" then - local _, lootmaster = GetLootMethod() - if lootmaster and pfUI.uf.group[i].id == lootmaster then - pfUI.uf.group[i].hp.lootIcon:Show() - else - pfUI.uf.group[i].hp.lootIcon:Hide() - end - end - if GetNumPartyMembers() >= i then pfUI.uf.group[i]:Show() if UnitIsConnected("party"..i) or not UnitName("party"..i) then @@ -81,88 +50,28 @@ pfUI:RegisterModule("group", function () end end) + for i=1, 4 do - pfUI.uf.group[i] = CreateFrame("Button","pfGroup" .. i,UIParent) - - pfUI.uf.group[i]:SetWidth(175) - pfUI.uf.group[i]:SetHeight(40 + 2*default_border + spacing) - pfUI.uf.group[i]:SetPoint("TOPLEFT", 5, -5 - ((i-1)*55)) + pfUI.uf.group[i] = pfUI.uf:CreateUnitFrame("Party", i, C.unitframes.group) + pfUI.uf.group[i]:UpdateFrameSize() + pfUI.uf.group[i]:SetPoint("TOPLEFT", 5, -5 - ((i-1)*75)) 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) - pfUI.uf.group[i].hp:SetHeight(30) - pfUI.uf.group[i].hp:SetPoint("TOP", 0, 0) - CreateBackdrop(pfUI.uf.group[i].hp, default_border) - - pfUI.uf.group[i].hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.group[i].hp) - pfUI.uf.group[i].hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.group[i].hp.bar:SetAllPoints(pfUI.uf.group[i].hp) - pfUI.uf.group[i].hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.group[i].hp.bar.texture = pfUI.uf.group[i].hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.group[i].hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.group[i].hp.bar.texture:SetAllPoints(pfUI.uf.group[i].hp.bar) - end - - pfUI.uf.group[i].power = CreateFrame("Frame",nil, pfUI.uf.group[i]) - pfUI.uf.group[i].power:SetWidth(175) - pfUI.uf.group[i].power:SetHeight(10) - pfUI.uf.group[i].power:SetPoint("BOTTOM", 0, 0) - CreateBackdrop(pfUI.uf.group[i].power, default_border) - - pfUI.uf.group[i].power.bar = CreateFrame("StatusBar", nil, pfUI.uf.group[i].power) - pfUI.uf.group[i].power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.group[i].power.bar:SetAllPoints(pfUI.uf.group[i].power) - pfUI.uf.group[i].power.bar:SetMinMaxValues(0, 100) - - pfUI.uf:CreatePortrait(pfUI.uf.group[i], C.unitframes.group.portrait, spacing) - - pfUI.uf.group[i].caption = pfUI.uf.group[i]:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.group[i].caption:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.group[i].caption:ClearAllPoints() - pfUI.uf.group[i].caption:SetParent(pfUI.uf.group[i].hp.bar) - pfUI.uf.group[i].caption:SetPoint("LEFT",pfUI.uf.group[i].hp.bar, "LEFT", 10, 0) - pfUI.uf.group[i].caption:SetJustifyH("LEFT") - pfUI.uf.group[i].caption:SetFontObject(GameFontWhite) - - pfUI.uf.group[i].hp.leaderIcon = CreateFrame("Frame",nil,pfUI.uf.group[i].hp.bar) - pfUI.uf.group[i].hp.leaderIcon:SetWidth(10) - pfUI.uf.group[i].hp.leaderIcon:SetHeight(10) - pfUI.uf.group[i].hp.leaderIcon.texture = pfUI.uf.group[i].hp.leaderIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.group[i].hp.leaderIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-LeaderIcon") - pfUI.uf.group[i].hp.leaderIcon.texture:SetAllPoints(pfUI.uf.group[i].hp.leaderIcon) - pfUI.uf.group[i].hp.leaderIcon:SetPoint("TOPLEFT", pfUI.uf.group[i].hp, "TOPLEFT", -4, 4) - pfUI.uf.group[i].hp.leaderIcon:Hide() - - pfUI.uf.group[i].hp.lootIcon = CreateFrame("Frame",nil,pfUI.uf.group[i].hp.bar) - pfUI.uf.group[i].hp.lootIcon:SetWidth(10) - pfUI.uf.group[i].hp.lootIcon:SetHeight(10) - pfUI.uf.group[i].hp.lootIcon.texture = pfUI.uf.group[i].hp.lootIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.group[i].hp.lootIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-MasterLooter") - pfUI.uf.group[i].hp.lootIcon.texture:SetAllPoints(pfUI.uf.group[i].hp.lootIcon) - pfUI.uf.group[i].hp.lootIcon:SetPoint("TOPLEFT", pfUI.uf.group[i].hp, "LEFT", -4, 4) - pfUI.uf.group[i].hp.lootIcon:Hide() - - pfUI.uf.group[i].hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.group[i].hp.bar.bar) - pfUI.uf.group[i].hp.raidIcon:SetFrameStrata("HIGH") - pfUI.uf.group[i].hp.raidIcon:SetWidth(24) - pfUI.uf.group[i].hp.raidIcon:SetHeight(24) - pfUI.uf.group[i].hp.raidIcon.texture = pfUI.uf.group[i].hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.group[i].hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.group[i].hp.raidIcon.texture:SetAllPoints(pfUI.uf.group[i].hp.raidIcon) - pfUI.uf.group[i].hp.raidIcon:SetPoint("TOP", pfUI.uf.group[i].hp, "TOP", -4, 4) - pfUI.uf.group[i].hp.raidIcon:Hide() - - pfUI.uf.group[i]:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - - pfUI.uf:CreateUnit(pfUI.uf.group[i]) + pfUI.uf.group[i].target = pfUI.uf:CreateUnitFrame("Party" .. i .. "Target", nil, C.unitframes.grouptarget, 0.2) + pfUI.uf.group[i].target:UpdateFrameSize() + pfUI.uf.group[i].target:SetPoint("TOPLEFT", 180, -5 - ((i-1)*75)) + UpdateMovable(pfUI.uf.group[i].target) end + + pfUI.uf.partytargetScanner = CreateFrame("Button",nil,UIParent) + pfUI.uf.partytargetScanner:SetScript("OnUpdate", function() + for i=1, 4 do + if UnitExists("party" .. i .. "target") or (pfUI.gitter and pfUI.gitter:IsShown()) then + pfUI.uf.group[i].target:Show() + else + pfUI.uf.group[i].target:Hide() + end + end + end) + end) diff --git a/modules/gui.lua b/modules/gui.lua index 6aedcdf5..1d82f958 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -850,6 +850,9 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.appearance, "Enable Zone Text On Minimap Mouseover", C.appearance.minimap, "mouseoverzone", "checkbox") -- unit frames + local txtValues = { "unit", "name", "level", "class", "health", "healthmax", "healthperc", "healthmiss", + "power", "powermax", "powerperc", "powermiss" } + pfUI.gui.uf = pfUI.gui:CreateConfigTab("Unit Frames") pfUI.gui:CreateConfig(pfUI.gui.uf, "Disable pfUI Unit Frames", C.unitframes, "disable", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Pastel Colors", C.unitframes, "pastel", "checkbox") @@ -872,30 +875,80 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.player, "height") pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.player, "pheight") pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.player, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.player, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.player, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.player, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.player, "debuffsize") + 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) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable PvP Icon", C.unitframes.player, "showPVP", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Align PvP Icon to Minimap", C.unitframes.player, "showPVPMinimap", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.player, "buffs", "dropdown", { "top", "bottom", "hide"}) pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Energy Ticks", C.unitframes.player, "energy", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Target", nil, nil, "header") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.target, "portrait", "dropdown", { "bar", "left", "right", "off" }) pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Target Switch Animation", C.unitframes.target, "animation", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.target, "portrait", "dropdown", { "bar", "left", "right", "off" }) pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.target, "width") pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.target, "height") pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.target, "pheight") pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.target, "pspace") pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.target, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.target, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.target, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.target, "debuffsize") + 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) pfUI.gui:CreateConfig(pfUI.gui.uf, "Group", nil, nil, "header") pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.group, "portrait", "dropdown", { "bar", "left", "right", "off" }) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.group, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.group, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.group, "pheight") pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.group, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.group, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.group, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.group, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.group, "debuffsize") + 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, "Group Target", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.grouptarget, "portrait", "dropdown", { "bar", "left", "right", "off" }) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.grouptarget, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.grouptarget, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.grouptarget, "pheight") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.grouptarget, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.grouptarget, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.grouptarget, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.grouptarget, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.grouptarget, "debuffsize") + 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) + 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, "Enable Raid Frames Buff Behaviour For Group Frames", C.unitframes.group, "raid_buffs", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Enable Raid Frames Debuff Behaviour For Group Frames", C.unitframes.group, "raid_debuffs", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Raid", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.raid, "portrait", "dropdown", { "bar", "left", "right", "off" }) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.raid, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.raid, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.raid, "pheight") pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.raid, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.raid, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.raid, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.raid, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.raid, "debuffsize") + 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) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Invert Health Bar", C.unitframes.raid, "invert_healthbar", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Missing Health", C.unitframes.raid, "show_missing", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Clickcast", C.unitframes.raid, "clickcast") @@ -909,12 +962,33 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Debuff Indicators", C.unitframes.raid, "debuffs_enable", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Only Display Debuffs Of My Class", C.unitframes.raid, "debuffs_class", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Other", nil, nil, "header") - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target Of Target Portrait Position", C.unitframes.ttarget, "portrait", "dropdown", { "bar", "left", "right", "off" }) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Target Of Target Spacing", C.unitframes.ttarget, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Target of Target", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.ttarget, "portrait", "dropdown", { "bar", "left", "right", "off" }) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.ttarget, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.ttarget, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.ttarget, "pheight") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.ttarget, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.ttarget, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.ttarget, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.ttarget, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.ttarget, "debuffsize") + 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) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Pet Portrait Position", C.unitframes.pet, "portrait", "dropdown", { "bar", "left", "right", "off" }) - pfUI.gui:CreateConfig(pfUI.gui.uf, "Pet Spacing", C.unitframes.pet, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Pet", nil, nil, "header") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Portrait Position", C.unitframes.pet, "portrait", "dropdown", { "bar", "left", "right", "off" }) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Width", C.unitframes.pet, "width") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Health Bar Height", C.unitframes.pet, "height") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Power Bar Height", C.unitframes.pet, "pheight") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Spacing", C.unitframes.pet, "pspace") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Position", C.unitframes.pet, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff Size", C.unitframes.pet, "buffsize") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Position", C.unitframes.pet, "debuffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Debuff Size", C.unitframes.pet, "debuffsize") + 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) -- action bar pfUI.gui.bar = pfUI.gui:CreateConfigTab("Action Bar") diff --git a/modules/pet.lua b/modules/pet.lua index dc5c5f33..f206b091 100644 --- a/modules/pet.lua +++ b/modules/pet.lua @@ -9,336 +9,8 @@ pfUI:RegisterModule("pet", function () local spacing = C.unitframes.pet.pspace - pfUI.uf.pet = CreateFrame("Button","pfPet",UIParent) - pfUI.uf.pet.label = "pet" - pfUI.uf.pet.id = "" - pfUI.uf.pet:SetFrameStrata("LOW") - pfUI.uf.pet:SetWidth(100) - pfUI.uf.pet:SetHeight(20 + 2*default_border + spacing) - pfUI.uf.pet:ClearAllPoints() + pfUI.uf.pet = pfUI.uf:CreateUnitFrame("Pet", nil, C.unitframes.pet) + pfUI.uf.pet:UpdateFrameSize() pfUI.uf.pet:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 163) UpdateMovable(pfUI.uf.pet) - - pfUI.uf.pet:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - pfUI.uf.pet:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit(this.label .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.pet:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.pet:SetScript("OnClick", function () - pfUI.uf:ClickAction(arg1) - end) - - pfUI.uf.pet:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.uf.pet:RegisterEvent("UNIT_PET") - pfUI.uf.pet:RegisterEvent("UNIT_COMBAT") - pfUI.uf.pet:RegisterEvent("UNIT_AURA") - pfUI.uf.pet:RegisterEvent("PET_ATTACK_START") - pfUI.uf.pet:RegisterEvent("PET_ATTACK_STOP") - pfUI.uf.pet:RegisterEvent("UNIT_HAPPINESS") - - pfUI.uf.pet:RegisterEvent("UNIT_HEALTH") - pfUI.uf.pet:RegisterEvent("UNIT_MAXHEALTH") - pfUI.uf.pet:RegisterEvent("UNIT_MANA") - pfUI.uf.pet:RegisterEvent("UNIT_MAXMANA") - pfUI.uf.pet:RegisterEvent("UNIT_RAGE") - pfUI.uf.pet:RegisterEvent("UNIT_MAXRAGE") - pfUI.uf.pet:RegisterEvent("UNIT_ENERGY") - pfUI.uf.pet:RegisterEvent("UNIT_MAXENERGY") - pfUI.uf.pet:RegisterEvent("UNIT_FOCUS") - pfUI.uf.pet:RegisterEvent("UNIT_MAXFOCUS") - pfUI.uf.pet:RegisterEvent("RAID_TARGET_UPDATE") - - pfUI.uf.pet:SetScript("OnEvent", function(arg1) - if UnitExists("pet") then - pfUI.uf.pet:Show() - elseif (pfUI.gitter and pfUI.gitter:IsShown()) then - pfUI.uf.pet:Show() - return - else - pfUI.uf.pet:Hide() - end - - local raidIcon = GetRaidTargetIndex("pet") - if raidIcon then - SetRaidTargetIconTexture(pfUI.uf.pet.hp.raidIcon.texture, raidIcon) - pfUI.uf.pet.hp.raidIcon:Show() - else - pfUI.uf.pet.hp.raidIcon:Hide() - end - - local hp, hpmax = UnitHealth("pet"), UnitHealthMax("pet") - local power, powermax = UnitMana("pet"), UnitManaMax("pet") - - local happiness = GetPetHappiness() - local color = .2, .2, .2 - if happiness == 1 then - color = { r = 1, g = 0, b = 0 } - elseif happiness == 2 then - color = { r = 1, g = 1, b = 0 } - else - color = { r = 0, g = 1, b = 0 } - end - - local r, g, b = .2, .2, .2 - if C.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 - - if C.unitframes.custom == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.customcolor) - pfUI.uf.pet.hp.bar:SetStatusBarColor(tonumber(cr), tonumber(cg), tonumber(cb), hp / hpmax / 4 + .75) - else - pfUI.uf.pet.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) - end - pfUI.uf.pet.hp.text:SetTextColor(r, g, b) - - pfUI.uf.pet.hp.bar:SetMinMaxValues(0, hpmax) - pfUI.uf.pet.hp.text:SetText(UnitName("pet")) - - pfUI.uf.pet.hpReal = hp - pfUI.uf.pet.powerReal = power - - PowerColor = ManaBarColor[UnitPowerType("pet")] - pfUI.uf.pet.power.bar:SetStatusBarColor(PowerColor.r + .5, PowerColor.g +.5, PowerColor.b +.5, 1) - pfUI.uf.pet.power.bar:SetMinMaxValues(0, UnitManaMax("pet")) - end) - - pfUI.uf.pet:SetScript("OnUpdate", function() - -- animation hp - local hpDisplay = pfUI.uf.pet.hp.bar:GetValue() - local hpReal = pfUI.uf.pet.hpReal - local hpDiff = abs(hpReal - hpDisplay) - - if hpDisplay < hpReal then - pfUI.uf.pet.hp.bar:SetValue(hpDisplay + ceil(hpDiff / C.unitframes.animation_speed)) - elseif hpDisplay > hpReal then - pfUI.uf.pet.hp.bar:SetValue(hpDisplay - ceil(hpDiff / C.unitframes.animation_speed)) - else - pfUI.uf.pet.hp.bar:SetValue(hpReal) - end - - -- animation power - local powerDisplay = pfUI.uf.pet.power.bar:GetValue() - local powerReal = pfUI.uf.pet.powerReal - local powerDiff = abs(powerReal - powerDisplay) - - if powerDisplay < powerReal then - pfUI.uf.pet.power.bar:SetValue(powerDisplay + ceil(powerDiff / C.unitframes.animation_speed)) - elseif powerDisplay > powerReal then - pfUI.uf.pet.power.bar:SetValue(powerDisplay - ceil(powerDiff / C.unitframes.animation_speed)) - else - pfUI.uf.pet.power.bar:SetValue(powerReal) - end - end) - - pfUI.uf.pet.hp = CreateFrame("Frame",nil, pfUI.uf.pet) - pfUI.uf.pet.hp:SetWidth(100) - pfUI.uf.pet.hp:SetHeight(16) - pfUI.uf.pet.hp:SetPoint("TOP", 0, 0) - CreateBackdrop(pfUI.uf.pet.hp, default_border) - - pfUI.uf.pet.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.pet.hp) - pfUI.uf.pet.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.pet.hp.bar:SetAllPoints(pfUI.uf.pet.hp) - pfUI.uf.pet.hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.pet.hp.bar.texture = pfUI.uf.pet.hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.pet.hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.pet.hp.bar.texture:SetAllPoints(pfUI.uf.pet.hp.bar) - end - - pfUI.uf.pet.hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.pet.hp) - pfUI.uf.pet.hp.raidIcon:SetFrameStrata("MEDIUM") - pfUI.uf.pet.hp.raidIcon:SetParent(pfUI.uf.pet.hp.bar) - pfUI.uf.pet.hp.raidIcon:SetWidth(16) - pfUI.uf.pet.hp.raidIcon:SetHeight(16) - pfUI.uf.pet.hp.raidIcon.texture = pfUI.uf.pet.hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.pet.hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.pet.hp.raidIcon.texture:SetAllPoints(pfUI.uf.pet.hp.raidIcon) - pfUI.uf.pet.hp.raidIcon:SetPoint("TOP", pfUI.uf.pet.hp, "TOP", 0, 6) - pfUI.uf.pet.hp.raidIcon:Hide() - - pfUI.uf.pet.power = CreateFrame("Frame",nil, pfUI.uf.pet) - pfUI.uf.pet.power:SetPoint("BOTTOM", 0, 0) - pfUI.uf.pet.power:SetWidth(100) - pfUI.uf.pet.power:SetHeight(4) - CreateBackdrop(pfUI.uf.pet.power, default_border) - - pfUI.uf.pet.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.pet.power) - pfUI.uf.pet.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.pet.power.bar:SetAllPoints(pfUI.uf.pet.power) - pfUI.uf.pet.power.bar:SetMinMaxValues(0, 100) - - pfUI.uf:CreatePortrait(pfUI.uf.pet, C.unitframes.pet.portrait, spacing) - - pfUI.uf.pet.hp.text = pfUI.uf.pet.hp.bar:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.pet.hp.text:SetFont(pfUI.font_square, C.global.font_size - 2, "OUTLINE") - pfUI.uf.pet.hp.text:ClearAllPoints() - pfUI.uf.pet.hp.text:SetAllPoints(pfUI.uf.pet.hp.bar) - pfUI.uf.pet.hp.text:SetPoint("CENTER", 0, 0) - pfUI.uf.pet.hp.text:SetJustifyH("CENTER") - pfUI.uf.pet.hp.text:SetFontObject(GameFontWhite) - pfUI.uf.pet.hp.text:SetText("n/a") - - pfUI.uf.pet.buff = CreateFrame("Frame", nil) - pfUI.uf.pet.buff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.pet.buff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.pet.buff:RegisterEvent("PLAYER_TARGET_CHANGED") - pfUI.uf.pet.buff:RegisterEvent("UNIT_AURA") - pfUI.uf.pet.buff:SetScript("OnEvent", function() - pfUI.uf.pet.buff.RefreshBuffs() - end) - - pfUI.uf.pet.buff.buffs = {} - for i=1, 16 do - local id = i - local row = 0 - if i <= 8 then row = 0 else row = 1 end - local buffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 - - pfUI.uf.pet.buff.buffs[i] = CreateFrame("Button", "pfUITargetBuff" .. i, pfUI.uf.pet) - pfUI.uf.pet.buff.buffs[i].stacks = pfUI.uf.pet.buff.buffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.pet.buff.buffs[i]) - pfUI.uf.pet.buff.buffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.pet.buff.buffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.pet.buff.buffs[i], 2, -2) - pfUI.uf.pet.buff.buffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.pet.buff.buffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.pet.buff.buffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.pet.buff.buffs[i].stacks:SetTextColor(1,1,.5) - - pfUI.uf.pet.buff.buffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.pet.buff.buffs[i]:ClearAllPoints() - pfUI.uf.pet.buff.buffs[i]:SetPoint("BOTTOMLEFT", pfUI.uf.pet.hp, "TOPLEFT", - (i-1-8*row)*((2*default_border) + buffsize + 1), - (row)*((2*default_border) + buffsize + 1) + 2*default_border + 1) - pfUI.uf.pet.buff.buffs[i]:SetWidth(buffsize) - pfUI.uf.pet.buff.buffs[i]:SetHeight(buffsize) - pfUI.uf.pet.buff.buffs[i]:SetNormalTexture(nil) - pfUI.uf.pet.buff.buffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetUnitBuff("pet", id) - end) - - pfUI.uf.pet.buff.buffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - end - - function pfUI.uf.pet.buff.RefreshBuffs() - local buffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 - for i=1, 16 do - local texture, stacks = UnitBuff("pet",i) - CreateBackdrop(pfUI.uf.pet.buff.buffs[i], default_border) - pfUI.uf.pet.buff.buffs[i]:SetNormalTexture(texture) - for i,v in ipairs({pfUI.uf.pet.buff.buffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - if texture then - pfUI.uf.pet.buff.buffs[i]:Show() - if stacks > 1 then - pfUI.uf.pet.buff.buffs[i].stacks:SetText(stacks) - else - pfUI.uf.pet.buff.buffs[i].stacks:SetText("") - end - else - pfUI.uf.pet.buff.buffs[i]:Hide() - end - end - end - - pfUI.uf.pet.debuff = CreateFrame("Frame", nil) - pfUI.uf.pet.debuff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.pet.debuff:RegisterEvent("PLAYER_TARGET_CHANGED") - pfUI.uf.pet.debuff:RegisterEvent("UNIT_AURA") - pfUI.uf.pet.debuff:SetScript("OnEvent", function() - pfUI.uf.pet.debuff.RefreshBuffs() - end) - - pfUI.uf.pet.debuff.debuffs = {} - for i=1, 16 do - local id = i - local debuffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 - - pfUI.uf.pet.debuff.debuffs[i] = CreateFrame("Button", "pfUITargetDebuff" .. i, pfUI.uf.pet) - pfUI.uf.pet.debuff.debuffs[i].stacks = pfUI.uf.pet.debuff.debuffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.pet.debuff.debuffs[i]) - pfUI.uf.pet.debuff.debuffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.pet.debuff.debuffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.pet.debuff.debuffs[i], 2, -2) - pfUI.uf.pet.debuff.debuffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.pet.debuff.debuffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.pet.debuff.debuffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.pet.debuff.debuffs[i].stacks:SetTextColor(1,1,.5) - pfUI.uf.pet.debuff.debuffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.pet.debuff.debuffs[i]:ClearAllPoints() - - pfUI.uf.pet.debuff.debuffs[i]:SetWidth(debuffsize) - pfUI.uf.pet.debuff.debuffs[i]:SetHeight(debuffsize) - pfUI.uf.pet.debuff.debuffs[i]:SetNormalTexture(nil) - pfUI.uf.pet.debuff.debuffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetUnitDebuff("pet", id) - end) - pfUI.uf.pet.debuff.debuffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - pfUI.uf.pet.debuff.debuffs[i]:SetScript("OnClick", function() - CancelPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) - end) - end - - function pfUI.uf.pet.debuff.RefreshBuffs() - local debuffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 - for i=1, 16 do - local row = 0 - local top = 0 - if i > 8 then row = 1 end - if pfUI.uf.pet.buff.buffs[1]:IsShown() then top = top + 1 end - if pfUI.uf.pet.buff.buffs[9]:IsShown() then top = top + 1 end - local buffsize = pfUI.uf.pet.hp:GetWidth()/8 - 1 - - pfUI.uf.pet.debuff.debuffs[i]:SetPoint("BOTTOMLEFT", pfUI.uf.pet.hp, "TOPLEFT", - (i-1-row)*((2*default_border) + buffsize + 1), - (top)*((2*default_border) + buffsize + 1) + - (row)*((2*default_border) + buffsize + 1) + (2*default_border + 1)) - - local texture, stacks = UnitDebuff("pet",i) - CreateBackdrop(pfUI.uf.pet.debuff.debuffs[i], default_border) - pfUI.uf.pet.debuff.debuffs[i]:SetNormalTexture(texture) - for i,v in ipairs({pfUI.uf.pet.debuff.debuffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - local _,_,dtype = UnitDebuff("pet", i) - if dtype == "Magic" then - pfUI.uf.pet.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,1,1) - elseif dtype == "Poison" then - pfUI.uf.pet.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,0,1) - elseif dtype == "Curse" then - pfUI.uf.pet.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,1,1) - else - pfUI.uf.pet.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,0,1) - end - - if texture then - pfUI.uf.pet.debuff.debuffs[i]:Show() - if stacks > 1 then - pfUI.uf.pet.debuff.debuffs[i].stacks:SetText(stacks) - else - pfUI.uf.pet.debuff.debuffs[i].stacks:SetText("") - end - else - pfUI.uf.pet.debuff.debuffs[i]:Hide() - end - end - end end) diff --git a/modules/player.lua b/modules/player.lua index b4665bff..23d6b8e8 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -12,28 +12,10 @@ pfUI:RegisterModule("player", function () PlayerFrame:Hide() PlayerFrame:UnregisterAllEvents() - pfUI.uf.player = CreateFrame("Button","pfPlayer",UIParent) - pfUI.uf.player.label = "player" - pfUI.uf.player.id = "" - pfUI.uf.player:SetFrameStrata("LOW") - pfUI.uf.player:SetWidth(C.unitframes.player.width) - pfUI.uf.player:SetHeight(C.unitframes.player.height + C.unitframes.player.pheight + 2*default_border + spacing) + pfUI.uf.player = pfUI.uf:CreateUnitFrame("Player", nil, C.unitframes.player) + pfUI.uf.player:UpdateFrameSize() pfUI.uf.player:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOM", -75, 125) UpdateMovable(pfUI.uf.player) - pfUI.uf.player:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - pfUI.uf.player:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit(this.label .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.player:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.player:SetScript("OnClick", function () - pfUI.uf:ClickAction(arg1) - end) pfUI.uf.player.Dropdown = getglobal("PlayerFrameDropDown") function pfUI.uf.player.Dropdowni() @@ -45,221 +27,8 @@ pfUI:RegisterModule("player", function () end UIDropDownMenu_Initialize(pfUI.uf.player.Dropdown, pfUI.uf.player.Dropdowni, "MENU") - pfUI.uf.player:RegisterEvent("UPDATE_FACTION") - pfUI.uf.player:RegisterEvent("UNIT_FACTION") - pfUI.uf.player:RegisterEvent("RAID_TARGET_UPDATE") - pfUI.uf.player:RegisterEvent("PARTY_LEADER_CHANGED") - pfUI.uf.player:RegisterEvent("PARTY_MEMBERS_CHANGED") - pfUI.uf.player:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") - - pfUI.uf.player:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.uf.player:RegisterEvent("UNIT_DISPLAYPOWER") - - pfUI.uf.player:RegisterEvent("UNIT_HEALTH") - pfUI.uf.player:RegisterEvent("UNIT_MAXHEALTH") - pfUI.uf.player:RegisterEvent("UNIT_MANA") - pfUI.uf.player:RegisterEvent("UNIT_MAXMANA") - pfUI.uf.player:RegisterEvent("UNIT_RAGE") - pfUI.uf.player:RegisterEvent("UNIT_MAXRAGE") - pfUI.uf.player:RegisterEvent("UNIT_ENERGY") - pfUI.uf.player:RegisterEvent("UNIT_MAXENERGY") - - pfUI.uf.player:SetScript("OnEvent", function() - if event == "UPDATE_FACTION" or event == "UNIT_FACTION" then - if C.unitframes.player.showPVP == "1" and UnitIsPVP("player") then - if pfUI.uf.player.pvpicon == nil then - pfUI.uf.player.pvpicon = CreateFrame("Frame", "pfPvPIcon", UIParent) - pfUI.uf.player.pvpicon:SetFrameStrata("HIGH") - pfUI.uf.player.pvpicon.texture = pfUI.uf.player.pvpicon:CreateTexture(nil,"DIALOG") - pfUI.uf.player.pvpicon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\pvp") - pfUI.uf.player.pvpicon.texture:SetAllPoints(pfUI.uf.player.pvpicon) - end - - if C.unitframes.player.showPVPMinimap == "1" then - pfUI.uf.player.pvpicon:SetWidth(16) - pfUI.uf.player.pvpicon:SetHeight(16) - pfUI.uf.player.pvpicon:SetParent(pfUI.minimap) - pfUI.uf.player.pvpicon:SetPoint("BOTTOMRIGHT", pfUI.minimap, "BOTTOMRIGHT", -5, 5) - else - pfUI.uf.player.pvpicon:SetWidth(10) - pfUI.uf.player.pvpicon:SetHeight(10) - pfUI.uf.player.pvpicon:SetParent(pfUI.uf.player.hp.bar) - pfUI.uf.player.pvpicon:SetPoint("CENTER", pfUI.uf.player, "BOTTOMLEFT", 0,0) - end - pfUI.uf.player.pvpicon:Show() - elseif pfUI.uf.player.pvpicon then - pfUI.uf.player.pvpicon:Hide() - end - return - end - - if event == "RAID_TARGET_UPDATE" or event == "PLAYER_ENTERING_WORLD" then - local raidIcon = GetRaidTargetIndex("player") - if raidIcon then - SetRaidTargetIconTexture(pfUI.uf.player.hp.raidIcon.texture, raidIcon) - pfUI.uf.player.hp.raidIcon:Show() - else - pfUI.uf.player.hp.raidIcon:Hide() - end - if event == "RAID_TARGET_UPDATE" then return end - end - - if event == "PARTY_LEADER_CHANGED" or event == "PARTY_MEMBERS_CHANGED" or event == "PLAYER_ENTERING_WORLD" then - if UnitIsPartyLeader("player") then - pfUI.uf.player.hp.leaderIcon:Show() - else - pfUI.uf.player.hp.leaderIcon:Hide() - end - if event == "PARTY_LEADER_CHANGED" then return end - end - - if event == "PARTY_LOOT_METHOD_CHANGED" or event == "PLAYER_ENTERING_WORLD" then - local _, lootmaster = GetLootMethod() - if lootmaster and pfUI.uf.player.id == lootmaster then - pfUI.uf.player.hp.lootIcon:Show() - else - pfUI.uf.player.hp.lootIcon:Hide() - end - if event == "PARTY_LOOT_METHOD_CHANGED" then return end - end - - if (arg1 and arg1 == "player") or event == "PLAYER_ENTERING_WORLD" then - if event == "UNIT_DISPLAYPOWER" or event == "PLAYER_ENTERING_WORLD" then - pfUI.uf.player.power.bar:SetValue(0) - end - - local hp, hpmax = UnitHealth("player"), UnitHealthMax("player") - local power, powermax = UnitMana("player"), UnitManaMax("player") - _, class = UnitClass("player") - local color = RAID_CLASS_COLORS[class] - - local cr, cg, cb - if C.unitframes.custom == "1" then - local r, g, b, a = strsplit(",", C.unitframes.customcolor) - cr, cg, cb = tonumber(r), tonumber(g), tonumber(b) - elseif C.unitframes.pastel == "1" then - cr, cg, cb = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5 - else - cr, cg, cb = color.r, color.g, color.b - end - - local perc = hp / hpmax - - pfUI.uf.player.hp.bar:SetMinMaxValues(0, hpmax) - pfUI.uf.player.hp.bar:SetStatusBarColor(cr, cg, cb, hp / hpmax / 4 + .75) - - local r1, g1, b1, r2, g2, b2 - if perc <= 0.5 then - perc = perc * 2; r1, g1, b1 = .9, .5, .5; r2, g2, b2 = .9, .9, .5 - else - perc = perc * 2 - 1; r1, g1, b1 = .9, .9, .5; r2, g2, b2 = .5, .9, .5 - end - local hr, hg, hb = r1 + (r2 - r1)*perc, g1 + (g2 - g1)*perc, b1 + (b2 - b1)*perc - pfUI.uf.player.hpText:SetTextColor(hr, hg, hb,1) - - if hp ~= hpmax then - pfUI.uf.player.hpText:SetText(hp .. " - " .. ceil(hp / hpmax * 100) .. "%") - else - pfUI.uf.player.hpText:SetText(hp) - end - - PowerColor = ManaBarColor[UnitPowerType("player")] - pfUI.uf.player.power.bar:SetStatusBarColor(PowerColor.r + .5, PowerColor.g +.5, PowerColor.b +.5, 1) - pfUI.uf.player.power.bar:SetMinMaxValues(0, UnitManaMax("player")) - - pfUI.uf.player.powerText:SetTextColor(PowerColor.r + .5, PowerColor.g +.5, PowerColor.b +.5,1) - - pfUI.uf.player.powerText:SetText( UnitMana("player") ) - - pfUI.uf.player.hpReal = hp - pfUI.uf.player.powerReal = power - end - end) - - pfUI.uf.player:SetScript("OnUpdate", function() - local hpDisplay = pfUI.uf.player.hp.bar:GetValue() - local hpReal = pfUI.uf.player.hpReal - local hpDiff = abs(hpReal - hpDisplay) - - if hpDisplay < hpReal then - pfUI.uf.player.hp.bar:SetValue(hpDisplay + ceil(hpDiff / C.unitframes.animation_speed)) - elseif hpDisplay > hpReal then - pfUI.uf.player.hp.bar:SetValue(hpDisplay - ceil(hpDiff / C.unitframes.animation_speed)) - elseif hpDisplay ~= hpReal then - pfUI.uf.player.hp.bar:SetValue(hpReal) - end - - local powerDisplay = pfUI.uf.player.power.bar:GetValue() - local powerReal = pfUI.uf.player.powerReal - local powerDiff = abs(powerReal - powerDisplay) - - if powerDisplay < powerReal then - pfUI.uf.player.power.bar:SetValue(powerDisplay + ceil(powerDiff / C.unitframes.animation_speed)) - elseif powerDisplay > powerReal then - pfUI.uf.player.power.bar:SetValue(powerDisplay - ceil(powerDiff / C.unitframes.animation_speed)) - else - pfUI.uf.player.power.bar:SetValue(powerReal) - end - end) - - pfUI.uf.player.hp = CreateFrame("Frame",nil, pfUI.uf.player) - pfUI.uf.player.hp:SetPoint("TOP", 0, 0) - pfUI.uf.player.hp:SetWidth(C.unitframes.player.width) - pfUI.uf.player.hp:SetHeight(C.unitframes.player.height) - CreateBackdrop(pfUI.uf.player.hp, default_border) - - pfUI.uf.player.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.player.hp) - pfUI.uf.player.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.player.hp.bar:SetAllPoints(pfUI.uf.player.hp) - pfUI.uf.player.hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.player.hp.bar.texture = pfUI.uf.player.hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.player.hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.player.hp.bar.texture:SetAllPoints(pfUI.uf.player.hp.bar) - end - - pfUI.uf.player.hp.leaderIcon = CreateFrame("Frame",nil,pfUI.uf.player.hp.bar) - pfUI.uf.player.hp.leaderIcon:SetWidth(10) - pfUI.uf.player.hp.leaderIcon:SetHeight(10) - pfUI.uf.player.hp.leaderIcon.texture = pfUI.uf.player.hp.leaderIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.player.hp.leaderIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-LeaderIcon") - pfUI.uf.player.hp.leaderIcon.texture:SetAllPoints(pfUI.uf.player.hp.leaderIcon) - pfUI.uf.player.hp.leaderIcon:SetPoint("CENTER", pfUI.uf.player.hp, "TOPLEFT", 0, 0) - pfUI.uf.player.hp.leaderIcon:Hide() - - pfUI.uf.player.hp.lootIcon = CreateFrame("Frame",nil,pfUI.uf.player.hp.bar) - pfUI.uf.player.hp.lootIcon:SetWidth(10) - pfUI.uf.player.hp.lootIcon:SetHeight(10) - pfUI.uf.player.hp.lootIcon.texture = pfUI.uf.player.hp.lootIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.player.hp.lootIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-MasterLooter") - pfUI.uf.player.hp.lootIcon.texture:SetAllPoints(pfUI.uf.player.hp.lootIcon) - pfUI.uf.player.hp.lootIcon:SetPoint("CENTER", pfUI.uf.player.hp, "LEFT", 0, 0) - pfUI.uf.player.hp.lootIcon:Hide() - - pfUI.uf.player.hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.player.hp.bar) - pfUI.uf.player.hp.raidIcon:SetWidth(24) - pfUI.uf.player.hp.raidIcon:SetHeight(24) - pfUI.uf.player.hp.raidIcon.texture = pfUI.uf.player.hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.player.hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.player.hp.raidIcon.texture:SetAllPoints(pfUI.uf.player.hp.raidIcon) - pfUI.uf.player.hp.raidIcon:SetPoint("TOP", pfUI.uf.player.hp, "TOP", 0, 6) - pfUI.uf.player.hp.raidIcon:Hide() - - pfUI.uf.player.power = CreateFrame("Frame",nil, pfUI.uf.player) - pfUI.uf.player.power:SetPoint("BOTTOM", 0, 0) - pfUI.uf.player.power:SetWidth(C.unitframes.player.width) - pfUI.uf.player.power:SetHeight(C.unitframes.player.pheight) - CreateBackdrop(pfUI.uf.player.power, default_border) - - pfUI.uf.player.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.player.power) - pfUI.uf.player.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.player.power.bar:SetAllPoints(pfUI.uf.player.power) - pfUI.uf.player.power.bar:SetMinMaxValues(0, 100) - - pfUI.uf:CreatePortrait(pfUI.uf.player, C.unitframes.player.portrait, spacing) + pfUI.uf.player:RegisterEvent("UPDATE_FACTION") -- pvp icon + pfUI.uf.player:RegisterEvent("UNIT_FACTION") -- pvp icon if C.unitframes.player.energy == "1" then pfUI.uf.player.power.tick = CreateFrame("Frame", nil, pfUI.uf.player.power.bar) @@ -298,275 +67,4 @@ pfUI:RegisterModule("player", function () this.spark:SetPoint("LEFT", pos-((C.unitframes.player.pheight+5)/2), 0) end) end - - pfUI.uf.player.hpText = pfUI.uf.player:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.player.hpText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.hpText:ClearAllPoints() - pfUI.uf.player.hpText:SetJustifyH("RIGHT") - pfUI.uf.player.hpText:SetFontObject(GameFontWhite) - pfUI.uf.player.hpText:SetText("5000") - - pfUI.uf.player.powerText = pfUI.uf.player:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.player.powerText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.powerText:ClearAllPoints() - pfUI.uf.player.powerText:SetJustifyH("LEFT") - pfUI.uf.player.powerText:SetFontObject(GameFontWhite) - pfUI.uf.player.powerText:SetText("5000") - - pfUI.uf.player.hpText:SetParent(pfUI.uf.player.hp.bar) - pfUI.uf.player.hpText:SetPoint("RIGHT",pfUI.uf.player.hp.bar, "RIGHT", -10, 0) - pfUI.uf.player.powerText:SetParent(pfUI.uf.player.hp.bar) - pfUI.uf.player.powerText:SetPoint("LEFT",pfUI.uf.player.hp.bar, "LEFT", 10, 0) - - pfUI.uf.player.buff = CreateFrame("Frame", nil) - pfUI.uf.player.buff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.player.buff:SetScript("OnEvent", function() - pfUI.uf.player.buff.RefreshBuffs() - end) - - pfUI.uf.player.buff.buffs = {} - for i=1, 16 do - local id = i - local row = 0 - if i <= 8 then row = 0 else row = 1 end - - pfUI.uf.player.buff.buffs[i] = CreateFrame("Button", "pfUIPlayerBuff" .. i, pfUI.uf.player) - pfUI.uf.player.buff.buffs[i]:SetID(i) - - pfUI.uf.player.buff.buffs[i].stacks = pfUI.uf.player.buff.buffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.player.buff.buffs[i]) - pfUI.uf.player.buff.buffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.buff.buffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.player.buff.buffs[i], 2, -2) - pfUI.uf.player.buff.buffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.player.buff.buffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.player.buff.buffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.player.buff.buffs[i].stacks:SetTextColor(1,1,.5) - pfUI.uf.player.buff.buffs[i].cd = pfUI.uf.player.buff.buffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.player.buff.buffs[i]) - pfUI.uf.player.buff.buffs[i].cd:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.buff.buffs[i].cd:SetPoint("CENTER", pfUI.uf.player.buff.buffs[i], 0, 0) - pfUI.uf.player.buff.buffs[i].cd:SetJustifyH("LEFT") - pfUI.uf.player.buff.buffs[i].cd:SetShadowColor(0, 0, 0) - pfUI.uf.player.buff.buffs[i].cd:SetShadowOffset(0.8, -0.8) - pfUI.uf.player.buff.buffs[i].cd:SetTextColor(1,1,1) - - pfUI.uf.player.buff.buffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.player.buff.buffs[i]:ClearAllPoints() - - local invert, af, as - if C.unitframes.player.buffs == "top" then - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - elseif C.unitframes.player.buffs == "bottom" then - invert = -1 - af = "TOPLEFT" - as = "BOTTOMLEFT" - else - -- set fallback values - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - - -- disable bufs - pfUI.uf.player.buff.buffs[i]:Hide() - pfUI.uf.player.buff:UnregisterAllEvents() - end - - pfUI.uf.player.buff.buffs[i]:SetPoint(af, pfUI.uf.player, as, - (i-1-8*row)*((2*default_border) + C.unitframes.buff_size + 1), - invert * (row)*((2*default_border) + C.unitframes.buff_size + 1) + invert*(2*default_border + 1)) - pfUI.uf.player.buff.buffs[i]:SetWidth(C.unitframes.buff_size) - pfUI.uf.player.buff.buffs[i]:SetHeight(C.unitframes.buff_size) - pfUI.uf.player.buff.buffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetPlayerBuff(GetPlayerBuff(id-1,"HELPFUL")) - end) - - pfUI.uf.player.buff.buffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - - pfUI.uf.player.buff.buffs[i]:SetScript("OnClick", function() - CancelPlayerBuff(GetPlayerBuff(id-1,"HELPFUL")) - end) - - pfUI.uf.player.buff.buffs[i]:SetScript("OnUpdate", function() - local timeleft = GetPlayerBuffTimeLeft(GetPlayerBuff(this:GetID()-1,"HELPFUL")) - if timeleft ~= nil and timeleft ~= 0 then - -- if there are more than 0 seconds left - if timeleft < 60 then - -- show seconds if less than 60 seconds - this.cd:SetText(ceil(timeleft)) - elseif timeleft < 3600 then - -- show minutes if less than 3600 seconds (1 hour) - this.cd:SetText(ceil(timeleft/60) .. 'm') - else - -- otherwise show hours - this.cd:SetText(ceil(timeleft/3600) .. 'h') - end - else - -- if there's no time left or not set, empty buff text - this.cd:SetText("") - end - end) - end - - function pfUI.uf.player.buff.RefreshBuffs() - for i=1, 16 do - local stacks = GetPlayerBuffApplications(GetPlayerBuff(i-1,"HELPFUL")) - CreateBackdrop(pfUI.uf.player.buff.buffs[i], default_border) - pfUI.uf.player.buff.buffs[i]:SetNormalTexture(GetPlayerBuffTexture(GetPlayerBuff(i-1,"HELPFUL"))) - for i,v in ipairs({pfUI.uf.player.buff.buffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - if GetPlayerBuffTexture(GetPlayerBuff(i-1,"HELPFUL")) then - pfUI.uf.player.buff.buffs[i]:Show() - local stacks = GetPlayerBuffApplications(GetPlayerBuff(i-1,"HELPFUL")) - if stacks > 1 then - pfUI.uf.player.buff.buffs[i].stacks:SetText(stacks) - else - pfUI.uf.player.buff.buffs[i].stacks:SetText("") - end - else - pfUI.uf.player.buff.buffs[i]:Hide() - end - end - end - - pfUI.uf.player.debuff = CreateFrame("Frame", nil) - pfUI.uf.player.debuff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.player.debuff:SetScript("OnEvent", function() - pfUI.uf.player.debuff.RefreshBuffs() - end) - - pfUI.uf.player.debuff.debuffs = {} - for i=1, 16 do - local id = i - pfUI.uf.player.debuff.debuffs[i] = CreateFrame("Button", "pfUIPlayerDebuff" .. i, pfUI.uf.player) - pfUI.uf.player.debuff.debuffs[i]:SetID(i) - pfUI.uf.player.debuff.debuffs[i].stacks = pfUI.uf.player.debuff.debuffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.player.debuff.debuffs[i]) - pfUI.uf.player.debuff.debuffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.debuff.debuffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.player.debuff.debuffs[i], 2, -2) - pfUI.uf.player.debuff.debuffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.player.debuff.debuffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.player.debuff.debuffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.player.debuff.debuffs[i].stacks:SetTextColor(1,1,.5) - pfUI.uf.player.debuff.debuffs[i].cd = pfUI.uf.player.debuff.debuffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.player.debuff.debuffs[i]) - pfUI.uf.player.debuff.debuffs[i].cd:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.player.debuff.debuffs[i].cd:SetPoint("CENTER", pfUI.uf.player.debuff.debuffs[i], 0, 0) - pfUI.uf.player.debuff.debuffs[i].cd:SetJustifyH("LEFT") - pfUI.uf.player.debuff.debuffs[i].cd:SetShadowColor(0, 0, 0) - pfUI.uf.player.debuff.debuffs[i].cd:SetShadowOffset(0.8, -0.8) - pfUI.uf.player.debuff.debuffs[i].cd:SetTextColor(1,1,1) - - pfUI.uf.player.debuff.debuffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.player.debuff.debuffs[i]:ClearAllPoints() - pfUI.uf.player.debuff.debuffs[i]:SetWidth(C.unitframes.debuff_size) - pfUI.uf.player.debuff.debuffs[i]:SetHeight(C.unitframes.debuff_size) - pfUI.uf.player.debuff.debuffs[i]:SetNormalTexture(nil) - pfUI.uf.player.debuff.debuffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) - end) - - pfUI.uf.player.debuff.debuffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - - pfUI.uf.player.debuff.debuffs[i]:SetScript("OnClick", function() - CancelPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) - end) - - pfUI.uf.player.debuff.debuffs[i]:SetScript("OnUpdate", function() - local bid = GetPlayerBuff(this:GetID() - 1, "HARMFUL"); - local timeleft = GetPlayerBuffTimeLeft(bid,"HARMFUL") - - if timeleft ~= nil and timeleft ~= 0 then - -- if there are more than 0 seconds left - if timeleft < 60 then - -- show seconds if less than 60 seconds - pfUI.uf.player.debuff.debuffs[this:GetID()].cd:SetText(ceil(timeleft)) - elseif timeleft < 3600 then - -- show minutes if less than 3600 seconds (1 hour) - pfUI.uf.player.debuff.debuffs[this:GetID()].cd:SetText(ceil(timeleft/60)..'m') - else - -- otherwise show hours - pfUI.uf.player.debuff.debuffs[this:GetID()].cd:SetText(ceil(timeleft/3600) .. 'h') - end - else - -- if there's no time left or not set, empty buff text - pfUI.uf.player.debuff.debuffs[this:GetID()].cd:SetText("") - end - end) - - end - - function pfUI.uf.player.debuff.RefreshBuffs() - for i=1, 16 do - local row = 0 - local top = 0 - if i > 8 then row = 1 end - if pfUI.uf.player.buff.buffs[1]:IsShown() then top = top + 1 end - if pfUI.uf.player.buff.buffs[9]:IsShown() then top = top + 1 end - - - local invert, af, as - if C.unitframes.player.buffs == "top" then - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - elseif C.unitframes.player.buffs == "bottom" then - invert = -1 - af = "TOPLEFT" - as = "BOTTOMLEFT" - else - -- set fallback values - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - - -- disable bufs - pfUI.uf.player.debuff.debuffs[i]:Hide() - pfUI.uf.player.debuff:UnregisterAllEvents() - end - - pfUI.uf.player.debuff.debuffs[i]:SetPoint(af, pfUI.uf.player, as, - (i-1-8*row)*((2*default_border) + C.unitframes.debuff_size + 1), - invert * (top)*((2*default_border) + C.unitframes.buff_size + 1) + - invert * (row)*((2*default_border) + C.unitframes.debuff_size + 1) + invert*(2*default_border + 1)) - - local bid = GetPlayerBuff(i-1, "HARMFUL"); - local stacks = GetPlayerBuffApplications(bid) - CreateBackdrop(pfUI.uf.player.debuff.debuffs[i], default_border) - pfUI.uf.player.debuff.debuffs[i]:SetNormalTexture(GetPlayerBuffTexture(bid)) - for i,v in ipairs({pfUI.uf.player.debuff.debuffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - local dtype = GetPlayerBuffDispelType(bid) - if dtype == "Magic" then - pfUI.uf.player.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,1,1) - elseif dtype == "Poison" then - pfUI.uf.player.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,0,1) - elseif dtype == "Curse" then - pfUI.uf.player.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,1,1) - elseif dtype == "Disease" then - pfUI.uf.player.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,1,0,1) - else - pfUI.uf.player.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,0,1) - end - - if GetPlayerBuffTexture(bid) then - pfUI.uf.player.debuff.debuffs[i]:Show() - local stacks = GetPlayerBuffApplications(bid) - if stacks > 1 then - pfUI.uf.player.debuff.debuffs[i].stacks:SetText(stacks) - else - pfUI.uf.player.debuff.debuffs[i].stacks:SetText("") - end - else - pfUI.uf.player.debuff.debuffs[i]:Hide() - end - end - end end) diff --git a/modules/raid.lua b/modules/raid.lua index 8066e892..b761a0d0 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -8,13 +8,22 @@ pfUI:RegisterModule("raid", function () end pfUI.uf.raid = CreateFrame("Button","pfRaid",UIParent) - pfUI.uf.raid:Hide() + for r=1, 8 do + for g=1, 5 do + i = g + 5*(r-1) + pfUI.uf.raid[i] = pfUI.uf:CreateUnitFrame("Raid", i, C.unitframes.raid) + pfUI.uf.raid[i]:UpdateFrameSize() + pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1) * (54+default_border) + 5, C.chat.left.height + 10 + ((g-1)*(37+default_border))+default_border) + UpdateMovable(pfUI.uf.raid[i]) + end + end + + pfUI.uf.raid:Hide() 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 @@ -35,88 +44,4 @@ pfUI:RegisterModule("raid", function () end end end) - - for r=1, 8 do - for g=1, 5 do - i = g + 5*(r-1) - pfUI.uf.raid[i] = CreateFrame("Button","pfRaid" .. i,UIParent) - - pfUI.uf.raid[i]:SetWidth(50) - pfUI.uf.raid[i]:SetHeight(30 + 2*default_border + C.unitframes.raid.pspace) - pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1) * (54+default_border) + 5, C.chat.left.height + 10 + ((g-1)*(37+default_border))+default_border) - UpdateMovable(pfUI.uf.raid[i]) - pfUI.uf.raid[i]:Hide() - pfUI.uf.raid[i].id = 0 - - pfUI.uf.raid[i].hp = CreateFrame("Frame",nil, pfUI.uf.raid[i]) - pfUI.uf.raid[i].hp:SetPoint("TOP", 0, 0) - pfUI.uf.raid[i].hp:SetWidth(50) - pfUI.uf.raid[i].hp:SetHeight(27) - CreateBackdrop(pfUI.uf.raid[i].hp, default_border) - - pfUI.uf.raid[i].hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.raid[i].hp) - pfUI.uf.raid[i].hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.raid[i].hp.bar:SetAllPoints(pfUI.uf.raid[i].hp) - pfUI.uf.raid[i].hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.raid[i].hp.bar.texture = pfUI.uf.raid[i].hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.raid[i].hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.raid[i].hp.bar.texture:SetAllPoints(pfUI.uf.raid[i].hp.bar) - end - - pfUI.uf.raid[i].power = CreateFrame("Frame",nil, pfUI.uf.raid[i]) - pfUI.uf.raid[i].power:SetPoint("BOTTOM", 0, 0) - pfUI.uf.raid[i].power:SetWidth(50) - pfUI.uf.raid[i].power:SetHeight(3) - CreateBackdrop(pfUI.uf.raid[i].power, default_border) - - pfUI.uf.raid[i].power.bar = CreateFrame("StatusBar", nil, pfUI.uf.raid[i].power) - pfUI.uf.raid[i].power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.raid[i].power.bar:SetAllPoints(pfUI.uf.raid[i].power) - pfUI.uf.raid[i].power.bar:SetMinMaxValues(0, 100) - - pfUI.uf.raid[i].caption = pfUI.uf.raid[i]:CreateFontString("Status", "HIGH", "GameFontNormal") - pfUI.uf.raid[i].caption:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.raid[i].caption:SetAllPoints(pfUI.uf.raid[i].hp.bar) - pfUI.uf.raid[i].caption:ClearAllPoints() - pfUI.uf.raid[i].caption:SetParent(pfUI.uf.raid[i].hp.bar) - pfUI.uf.raid[i].caption:SetPoint("CENTER",pfUI.uf.raid[i].hp.bar, "CENTER", 0, 0) - pfUI.uf.raid[i].caption:SetJustifyH("CENTER") - pfUI.uf.raid[i].caption:SetFontObject(GameFontWhite) - - pfUI.uf.raid[i].hp.leaderIcon = CreateFrame("Frame",nil,pfUI.uf.raid[i].hp) - pfUI.uf.raid[i].hp.leaderIcon:SetWidth(10) - pfUI.uf.raid[i].hp.leaderIcon:SetHeight(10) - pfUI.uf.raid[i].hp.leaderIcon.texture = pfUI.uf.raid[i].hp.leaderIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.raid[i].hp.leaderIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Raid-LeaderIcon") - pfUI.uf.raid[i].hp.leaderIcon.texture:SetAllPoints(pfUI.uf.raid[i].hp.leaderIcon) - pfUI.uf.raid[i].hp.leaderIcon:SetPoint("TOPLEFT", pfUI.uf.raid[i].hp, "TOPLEFT", -4, 4) - pfUI.uf.raid[i].hp.leaderIcon:Hide() - - pfUI.uf.raid[i].hp.lootIcon = CreateFrame("Frame",nil,pfUI.uf.raid[i].hp) - pfUI.uf.raid[i].hp.lootIcon:SetWidth(10) - pfUI.uf.raid[i].hp.lootIcon:SetHeight(10) - pfUI.uf.raid[i].hp.lootIcon.texture = pfUI.uf.raid[i].hp.lootIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.raid[i].hp.lootIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Raid-MasterLooter") - pfUI.uf.raid[i].hp.lootIcon.texture:SetAllPoints(pfUI.uf.raid[i].hp.lootIcon) - pfUI.uf.raid[i].hp.lootIcon:SetPoint("TOPLEFT", pfUI.uf.raid[i].hp, "LEFT", -4, 4) - pfUI.uf.raid[i].hp.lootIcon:Hide() - - pfUI.uf.raid[i].hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.raid[i].hp.bar) - pfUI.uf.raid[i].hp.raidIcon:SetWidth(24) - pfUI.uf.raid[i].hp.raidIcon:SetHeight(24) - pfUI.uf.raid[i].hp.raidIcon.texture = pfUI.uf.raid[i].hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.raid[i].hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.raid[i].hp.raidIcon.texture:SetAllPoints(pfUI.uf.raid[i].hp.raidIcon) - pfUI.uf.raid[i].hp.raidIcon:SetPoint("TOP", pfUI.uf.raid[i].hp, "TOP", -4, 4) - pfUI.uf.raid[i].hp.raidIcon:Hide() - - pfUI.uf.raid[i]:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - - pfUI.uf:CreateUnit(pfUI.uf.raid[i]) - end - end end) diff --git a/modules/target.lua b/modules/target.lua index 34b5ca29..bededc7b 100644 --- a/modules/target.lua +++ b/modules/target.lua @@ -17,544 +17,8 @@ pfUI:RegisterModule("target", function () ComboFrame:Hide() ComboFrame:UnregisterAllEvents() - pfUI.uf.target = CreateFrame("Button","pfTarget",UIParent) - pfUI.uf.target.label = "target" - pfUI.uf.target.id = "" - pfUI.uf.target:SetFrameStrata("LOW") - pfUI.uf.target:Hide() - pfUI.uf.target:SetWidth(C.unitframes.target.width) - pfUI.uf.target:SetHeight(C.unitframes.target.height + C.unitframes.target.pheight + 2*default_border + spacing) + pfUI.uf.target = pfUI.uf:CreateUnitFrame("Target", nil, C.unitframes.target) + pfUI.uf.target:UpdateFrameSize() pfUI.uf.target:SetPoint("BOTTOMLEFT", UIParent, "BOTTOM", 75, 125) UpdateMovable(pfUI.uf.target) - pfUI.uf.target:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - pfUI.uf.target:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit(this.label .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.target:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.target:SetScript("OnHide", function() - CloseDropDownMenus() - end) - - pfUI.uf.target:SetScript("OnClick", function () - pfUI.uf:ClickAction(arg1) - end) - - pfUI.uf.target:RegisterEvent("RAID_TARGET_UPDATE") - pfUI.uf.target:RegisterEvent("PARTY_LEADER_CHANGED") - pfUI.uf.target:RegisterEvent("PARTY_MEMBERS_CHANGED") - pfUI.uf.target:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") - pfUI.uf.target:RegisterEvent("PLAYER_TARGET_CHANGED") - - pfUI.uf.target:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.uf.target:RegisterEvent("UNIT_HEALTH") - pfUI.uf.target:RegisterEvent("UNIT_MAXHEALTH") - pfUI.uf.target:RegisterEvent("UNIT_DISPLAYPOWER") - pfUI.uf.target:RegisterEvent("UNIT_MANA") - pfUI.uf.target:RegisterEvent("UNIT_MAXMANA") - pfUI.uf.target:RegisterEvent("UNIT_RAGE") - pfUI.uf.target:RegisterEvent("UNIT_MAXRAGE") - pfUI.uf.target:RegisterEvent("UNIT_ENERGY") - pfUI.uf.target:RegisterEvent("UNIT_MAXENERGY") - pfUI.uf.target:RegisterEvent("UNIT_FOCUS") - - pfUI.uf.target:SetScript("OnEvent", function() - if UnitExists("target") then - pfUI.uf.target:Show() - elseif (pfUI.gitter and pfUI.gitter:IsShown()) then - pfUI.uf.target:Show() - return - else - pfUI.uf.target:Hide() - return - end - - if event == "RAID_TARGET_UPDATE" or event == "PLAYER_TARGET_CHANGED" then - local raidIcon = GetRaidTargetIndex("target") - if raidIcon then - SetRaidTargetIconTexture(pfUI.uf.target.hp.raidIcon.texture, raidIcon) - pfUI.uf.target.hp.raidIcon:Show() - else - pfUI.uf.target.hp.raidIcon:Hide() - end - end - - if event == "PARTY_LEADER_CHANGED" or event == "PARTY_MEMBERS_CHANGED" or event == "PLAYER_TARGET_CHANGED" then - if UnitIsPartyLeader("target") then - pfUI.uf.target.hp.leaderIcon:Show() - else - pfUI.uf.target.hp.leaderIcon:Hide() - end - end - - if event == "PARTY_LOOT_METHOD_CHANGED" or event == "PLAYER_TARGET_CHANGED" then - local _, lootmaster = GetLootMethod() - if lootmaster and pfUI.uf.target.id == lootmaster then - pfUI.uf.target.hp.lootIcon:Show() - else - pfUI.uf.target.hp.lootIcon:Hide() - end - end - - if event == "PLAYER_TARGET_CHANGED" or event == "PLAYER_ENTERING_WORLD" then - pfUI.uf.target.power.bar:SetValue(0) - pfUI.uf.target.hp.bar:SetValue(0) - end - - if (arg1 and arg1 == "target") or event == "PLAYER_TARGET_CHANGED" then - local hp, hpmax - if MobHealth3 then - hp, hpmax = MobHealth3:GetUnitHealth("target") - else - hp, hpmax = UnitHealth("target"), UnitHealthMax("target") - end - local power, powermax = UnitMana("target"), UnitManaMax("target") - - if hp ~= hpmax and hpmax ~= 100 then - pfUI.uf.target.hpText:SetText( hp .. " - " .. ceil(hp / hpmax * 100) .. "%") - else - pfUI.uf.target.hpText:SetText( hp) - end - - local color = { r = 1, g = 1, b = 1 } - if UnitIsPlayer("target") then - _, class = UnitClass("target") - color = RAID_CLASS_COLORS[class] - else - color = UnitReactionColor[UnitReaction("target", "player")] - end - - local r, g, b = .2, .2, .2 - - if C.unitframes.custom == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.customcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.target.hp.bar:SetStatusBarColor(cr, cg, cb, hp / hpmax / 4 + .75) - if C.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 - else - if C.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 - pfUI.uf.target.hp.bar:SetStatusBarColor(r, g, b, hp / hpmax / 4 + .75) - end - pfUI.uf.target.powerText:SetTextColor(r, g, b, 1) - - pfUI.uf.target.hp.bar:SetMinMaxValues(0, hpmax) - - local perc = hp / hpmax - local r1, g1, b1, r2, g2, b2 - if perc <= 0.5 then - perc = perc * 2; r1, g1, b1 = .9, .5, .5; r2, g2, b2 = .9, .9, .5 - else - perc = perc * 2 - 1; r1, g1, b1 = .9, .9, .5; r2, g2, b2 = .5, .9, .5 - end - local r, g, b = r1 + (r2 - r1)*perc, g1 + (g2 - g1)*perc, b1 + (b2 - b1)*perc - pfUI.uf.target.hpText:SetTextColor(r, g, b,1) - - local levelcolor - if UnitLevel("target") < 0 then - levelcolor = "ff5555" - else - local lcol = GetDifficultyColor(UnitLevel("target")) - levelcolor = string.format("%02x%02x%02x", lcol.r*255, lcol.g*255, lcol.b*255) - end - - local name = string.sub(UnitName("target"),1,25) - if strlen(UnitName("target")) > 25 then - name = name .. "..." - end - - local level = UnitLevel("target") - if level == -1 then level = "??" end - - if UnitClassification("target") == "worldboss" then - level = level .. "B" - elseif UnitClassification("target") == "rareelite" then - level = level .. "R+" - elseif UnitClassification("target") == "elite" then - level = level .. "+" - elseif UnitClassification("target") == "rare" then - level = level .. "R" - end - - pfUI.uf.target.powerText:SetText( "|cff" .. levelcolor .. level .. "|r " .. name) - pfUI.uf.target.powerText:SetWidth(pfUI.uf.target.hp.bar:GetWidth() / pfUI.uf.target.hp.bar:GetEffectiveScale() -30 - pfUI.uf.target.hpText:GetStringWidth()) - - PowerColor = ManaBarColor[UnitPowerType("target")] - pfUI.uf.target.power.bar:SetStatusBarColor(PowerColor.r + .5, PowerColor.g +.5, PowerColor.b +.5, 1) - pfUI.uf.target.power.bar:SetMinMaxValues(0, UnitManaMax("target")) - - 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 C.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) - - pfUI.uf.target:SetScript("OnUpdate", function() - if not UnitExists("target") then return end - - local hpDisplay = pfUI.uf.target.hp.bar:GetValue() - local hpReal = pfUI.uf.target.hpReal - local hpDiff = abs(hpReal - hpDisplay) - - if hpDisplay < hpReal then - pfUI.uf.target.hp.bar:SetValue(hpDisplay + ceil(hpDiff / C.unitframes.animation_speed)) - elseif hpDisplay > hpReal then - pfUI.uf.target.hp.bar:SetValue(hpDisplay - ceil(hpDiff / C.unitframes.animation_speed)) - else - pfUI.uf.target.hp.bar:SetValue(hpReal) - end - - local powerDisplay = pfUI.uf.target.power.bar:GetValue() - local powerReal = pfUI.uf.target.powerReal - local powerDiff = abs(powerReal - powerDisplay) - - if powerDisplay < powerReal then - pfUI.uf.target.power.bar:SetValue(powerDisplay + ceil(powerDiff / C.unitframes.animation_speed)) - elseif powerDisplay > powerReal then - pfUI.uf.target.power.bar:SetValue(powerDisplay - ceil(powerDiff / C.unitframes.animation_speed)) - else - pfUI.uf.target.power.bar:SetValue(powerReal) - end - - - if not pfUI.uf.target.tapped and UnitIsTapped("target") and not UnitIsTappedByPlayer("target") then - pfUI.uf.target.hp.bar:SetStatusBarColor(.5,.5,.5,.5) - pfUI.uf.target.tapped = true - end - end) - - pfUI.uf.target.hp = CreateFrame("Frame",nil, pfUI.uf.target) - pfUI.uf.target.hp:SetWidth(C.unitframes.target.width) - pfUI.uf.target.hp:SetHeight(C.unitframes.target.height) - pfUI.uf.target.hp:SetPoint("TOP", 0, 0) - CreateBackdrop(pfUI.uf.target.hp, default_border) - - pfUI.uf.target.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.target.hp) - pfUI.uf.target.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.target.hp.bar:SetAllPoints(pfUI.uf.target.hp) - pfUI.uf.target.hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.target.hp.bar.texture = pfUI.uf.target.hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.target.hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.target.hp.bar.texture:SetAllPoints(pfUI.uf.target.hp.bar) - end - - pfUI.uf.target.hp.leaderIcon = CreateFrame("Frame",nil,pfUI.uf.target.hp.bar) - pfUI.uf.target.hp.leaderIcon:SetWidth(10) - pfUI.uf.target.hp.leaderIcon:SetHeight(10) - pfUI.uf.target.hp.leaderIcon.texture = pfUI.uf.target.hp.leaderIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.target.hp.leaderIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-LeaderIcon") - pfUI.uf.target.hp.leaderIcon.texture:SetAllPoints(pfUI.uf.target.hp.leaderIcon) - pfUI.uf.target.hp.leaderIcon:SetPoint("TOPLEFT", pfUI.uf.target.hp, "TOPLEFT", -4, 4) - pfUI.uf.target.hp.leaderIcon:Hide() - - pfUI.uf.target.hp.lootIcon = CreateFrame("Frame",nil,pfUI.uf.target.hp.bar) - pfUI.uf.target.hp.lootIcon:SetWidth(10) - pfUI.uf.target.hp.lootIcon:SetHeight(10) - pfUI.uf.target.hp.lootIcon.texture = pfUI.uf.target.hp.lootIcon:CreateTexture(nil,"BACKGROUND") - pfUI.uf.target.hp.lootIcon.texture:SetTexture("Interface\\GROUPFRAME\\UI-Group-MasterLooter") - pfUI.uf.target.hp.lootIcon.texture:SetAllPoints(pfUI.uf.target.hp.lootIcon) - pfUI.uf.target.hp.lootIcon:SetPoint("TOPLEFT", pfUI.uf.target.hp, "LEFT", -4, 4) - pfUI.uf.target.hp.lootIcon:Hide() - - pfUI.uf.target.hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.target.hp.bar) - pfUI.uf.target.hp.raidIcon:SetWidth(24) - pfUI.uf.target.hp.raidIcon:SetHeight(24) - pfUI.uf.target.hp.raidIcon.texture = pfUI.uf.target.hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.target.hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.target.hp.raidIcon.texture:SetAllPoints(pfUI.uf.target.hp.raidIcon) - pfUI.uf.target.hp.raidIcon:SetPoint("TOP", pfUI.uf.target.hp, "TOP", 0, 6) - pfUI.uf.target.hp.raidIcon:Hide() - - pfUI.uf.target.power = CreateFrame("Frame",nil, pfUI.uf.target) - pfUI.uf.target.power:SetPoint("BOTTOM", 0, 0) - pfUI.uf.target.power:SetWidth(C.unitframes.target.width) - pfUI.uf.target.power:SetHeight(C.unitframes.target.pheight) - CreateBackdrop(pfUI.uf.target.power, default_border) - - pfUI.uf.target.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.target.power) - pfUI.uf.target.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.target.power.bar:SetAllPoints(pfUI.uf.target.power) - pfUI.uf.target.power.bar:SetMinMaxValues(0, 100) - - pfUI.uf:CreatePortrait(pfUI.uf.target, C.unitframes.target.portrait, spacing) - - pfUI.uf.target.hpText = pfUI.uf.target:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.target.hpText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.target.hpText:ClearAllPoints() - pfUI.uf.target.hpText:SetParent(pfUI.uf.target.hp.bar) - pfUI.uf.target.hpText:SetPoint("RIGHT",pfUI.uf.target.hp.bar, "RIGHT", -10, 0) - pfUI.uf.target.hpText:SetJustifyH("RIGHT") - pfUI.uf.target.hpText:SetFontObject(GameFontWhite) - pfUI.uf.target.hpText:SetText("5000") - - pfUI.uf.target.powerText = pfUI.uf.target:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.target.powerText:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.target.powerText:ClearAllPoints() - pfUI.uf.target.powerText:SetParent(pfUI.uf.target.hp.bar) - pfUI.uf.target.powerText:SetPoint("LEFT",pfUI.uf.target.hp.bar, "LEFT", 10, 0) - pfUI.uf.target.powerText:SetJustifyH("LEFT") - pfUI.uf.target.powerText:SetFontObject(GameFontWhite) - pfUI.uf.target.powerText:SetHeight(C.global.font_size) - pfUI.uf.target.powerText:SetNonSpaceWrap(true) - pfUI.uf.target.powerText:SetText("5000") - - pfUI.uf.target.combopoints = CreateFrame("Frame") - - pfUI.uf.target.combopoints:RegisterEvent("UNIT_COMBO_POINTS") - pfUI.uf.target.combopoints:RegisterEvent("PLAYER_COMBO_POINTS") - pfUI.uf.target.combopoints:RegisterEvent("UNIT_DISPLAYPOWER") - pfUI.uf.target.combopoints:RegisterEvent("PLAYER_TARGET_CHANGED") - pfUI.uf.target.combopoints:RegisterEvent('UNIT_ENERGY') - pfUI.uf.target.combopoints:RegisterEvent("PLAYER_ENTERING_WORLD") - - pfUI.uf.target.combopoint1 = CreateFrame("Frame") - pfUI.uf.target.combopoint2 = CreateFrame("Frame") - pfUI.uf.target.combopoint3 = CreateFrame("Frame") - pfUI.uf.target.combopoint4 = CreateFrame("Frame") - pfUI.uf.target.combopoint5 = CreateFrame("Frame") - - pfUI.uf.target.combopoints:SetScript("OnEvent", function() - if event == "PLAYER_ENTERING_WORLD" then - for point=1, 5 do - pfUI.uf.target["combopoint" .. point]:SetFrameStrata("HIGH") - pfUI.uf.target["combopoint" .. point]:SetWidth(5) - pfUI.uf.target["combopoint" .. point]:SetHeight(5) - CreateBackdrop(pfUI.uf.target["combopoint" .. point]) - pfUI.uf.target["combopoint" .. point]:SetPoint("TOPLEFT", pfUI.uf.target, "TOPRIGHT", C.appearance.border.default*3, -(point - 1) * (5 + C.appearance.border.default*3)) - if point < 3 then - local tex = pfUI.uf.target["combopoint" .. point]:CreateTexture("OVERLAY") - tex:SetAllPoints(pfUI.uf.target["combopoint" .. point]) - tex:SetTexture(1, .3, .3, .75) - elseif point < 4 then - local tex = pfUI.uf.target["combopoint" .. point]:CreateTexture("OVERLAY") - tex:SetAllPoints(pfUI.uf.target["combopoint" .. point]) - tex:SetTexture(1, 1, .3, .75) - else - local tex = pfUI.uf.target["combopoint" .. point]:CreateTexture("OVERLAY") - tex:SetAllPoints(pfUI.uf.target["combopoint" .. point]) - tex:SetTexture(.3, 1, .3, .75) - end - pfUI.uf.target["combopoint" .. point]:Hide() - end - else - local combopoints = GetComboPoints("target") - for point=1, 5 do - pfUI.uf.target["combopoint" .. point]:Hide() - end - for point=1, combopoints do - pfUI.uf.target["combopoint" .. point]:Show() - end - end - end) - - pfUI.uf.target.buff = CreateFrame("Frame", nil) - pfUI.uf.target.buff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.target.buff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.target.buff:RegisterEvent("PLAYER_TARGET_CHANGED") - pfUI.uf.target.buff:RegisterEvent("UNIT_AURA") - pfUI.uf.target.buff:SetScript("OnEvent", function() - pfUI.uf.target.buff.RefreshBuffs() - end) - - pfUI.uf.target.buff.buffs = {} - for i=1, 16 do - local id = i - local row = 0 - if i <= 8 then row = 0 else row = 1 end - - pfUI.uf.target.buff.buffs[i] = CreateFrame("Button", "pfUITargetBuff" .. i, pfUI.uf.target) - pfUI.uf.target.buff.buffs[i].stacks = pfUI.uf.target.buff.buffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.target.buff.buffs[i]) - pfUI.uf.target.buff.buffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.target.buff.buffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.target.buff.buffs[i], 2, -2) - pfUI.uf.target.buff.buffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.target.buff.buffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.target.buff.buffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.target.buff.buffs[i].stacks:SetTextColor(1,1,.5) - - pfUI.uf.target.buff.buffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.target.buff.buffs[i]:ClearAllPoints() - - local invert, af, as - if C.unitframes.target.buffs == "top" then - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - elseif C.unitframes.target.buffs == "bottom" then - invert = -1 - af = "TOPLEFT" - as = "BOTTOMLEFT" - else - -- set fallback values - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - - -- disable bufs - pfUI.uf.target.buff.buffs[i]:Hide() - pfUI.uf.target.buff:UnregisterAllEvents() - end - - pfUI.uf.target.buff.buffs[i]:SetPoint(af, pfUI.uf.target, as, - (i-1-8*row)*((2*default_border) + C.unitframes.buff_size + 1), - invert * (row)*((2*default_border) + C.unitframes.buff_size + 1) + invert*(2*default_border + 1)) - pfUI.uf.target.buff.buffs[i]:SetWidth(C.unitframes.buff_size) - pfUI.uf.target.buff.buffs[i]:SetHeight(C.unitframes.buff_size) - pfUI.uf.target.buff.buffs[i]:SetNormalTexture(nil) - pfUI.uf.target.buff.buffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetUnitBuff("target", id) - end) - - pfUI.uf.target.buff.buffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - end - - function pfUI.uf.target.buff.RefreshBuffs() - for i=1, 16 do - local texture, stacks = UnitBuff("target",i) - CreateBackdrop(pfUI.uf.target.buff.buffs[i], default_border) - pfUI.uf.target.buff.buffs[i]:SetNormalTexture(texture) - for i,v in ipairs({pfUI.uf.target.buff.buffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - if texture then - pfUI.uf.target.buff.buffs[i]:Show() - if stacks > 1 then - pfUI.uf.target.buff.buffs[i].stacks:SetText(stacks) - else - pfUI.uf.target.buff.buffs[i].stacks:SetText("") - end - else - pfUI.uf.target.buff.buffs[i]:Hide() - end - end - end - - pfUI.uf.target.debuff = CreateFrame("Frame", nil) - pfUI.uf.target.debuff:RegisterEvent("PLAYER_AURAS_CHANGED") - pfUI.uf.target.debuff:RegisterEvent("PLAYER_TARGET_CHANGED") - pfUI.uf.target.debuff:RegisterEvent("UNIT_AURA") - pfUI.uf.target.debuff:SetScript("OnEvent", function() - pfUI.uf.target.debuff.RefreshBuffs() - end) - - pfUI.uf.target.debuff.debuffs = {} - for i=1, 16 do - local id = i - pfUI.uf.target.debuff.debuffs[i] = CreateFrame("Button", "pfUITargetDebuff" .. i, pfUI.uf.target) - pfUI.uf.target.debuff.debuffs[i].stacks = pfUI.uf.target.debuff.debuffs[i]:CreateFontString(nil, "OVERLAY", pfUI.uf.target.debuff.debuffs[i]) - pfUI.uf.target.debuff.debuffs[i].stacks:SetFont(pfUI.font_square, C.global.font_size, "OUTLINE") - pfUI.uf.target.debuff.debuffs[i].stacks:SetPoint("BOTTOMRIGHT", pfUI.uf.target.debuff.debuffs[i], 2, -2) - pfUI.uf.target.debuff.debuffs[i].stacks:SetJustifyH("LEFT") - pfUI.uf.target.debuff.debuffs[i].stacks:SetShadowColor(0, 0, 0) - pfUI.uf.target.debuff.debuffs[i].stacks:SetShadowOffset(0.8, -0.8) - pfUI.uf.target.debuff.debuffs[i].stacks:SetTextColor(1,1,.5) - pfUI.uf.target.debuff.debuffs[i]:RegisterForClicks("RightButtonUp") - pfUI.uf.target.debuff.debuffs[i]:ClearAllPoints() - - pfUI.uf.target.debuff.debuffs[i]:SetWidth(C.unitframes.debuff_size) - pfUI.uf.target.debuff.debuffs[i]:SetHeight(C.unitframes.debuff_size) - pfUI.uf.target.debuff.debuffs[i]:SetNormalTexture(nil) - pfUI.uf.target.debuff.debuffs[i]:SetScript("OnEnter", function() - GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT") - GameTooltip:SetUnitDebuff("target", id) - end) - pfUI.uf.target.debuff.debuffs[i]:SetScript("OnLeave", function() - GameTooltip:Hide() - end) - pfUI.uf.target.debuff.debuffs[i]:SetScript("OnClick", function() - CancelPlayerBuff(GetPlayerBuff(id-1,"HARMFUL")) - end) - end - - function pfUI.uf.target.debuff.RefreshBuffs() - for i=1, 16 do - local row = 0 - local top = 0 - if i > 8 then row = 1 end - if pfUI.uf.target.buff.buffs[1]:IsShown() then top = top + 1 end - if pfUI.uf.target.buff.buffs[9]:IsShown() then top = top + 1 end - - local invert, af, as - if C.unitframes.target.buffs == "top" then - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - elseif C.unitframes.target.buffs == "bottom" then - invert = -1 - af = "TOPLEFT" - as = "BOTTOMLEFT" - else - -- set fallback values - invert = 1 - af = "BOTTOMLEFT" - as = "TOPLEFT" - - -- disable bufs - pfUI.uf.target.debuff.debuffs[i]:Hide() - pfUI.uf.target.debuff:UnregisterAllEvents() - end - - pfUI.uf.target.debuff.debuffs[i]:SetPoint(af, pfUI.uf.target, as, - (i-1-8*row)*((2*default_border) + C.unitframes.debuff_size + 1), - invert * (top)*((2*default_border) + C.unitframes.buff_size + 1) + - invert * (row)*((2*default_border) + C.unitframes.debuff_size + 1) + invert * (2*default_border + 1)) - - local texture, stacks = UnitDebuff("target",i) - CreateBackdrop(pfUI.uf.target.debuff.debuffs[i], default_border) - pfUI.uf.target.debuff.debuffs[i]:SetNormalTexture(texture) - for i,v in ipairs({pfUI.uf.target.debuff.debuffs[i]:GetRegions()}) do - if v.SetTexCoord then v:SetTexCoord(.08, .92, .08, .92) end - end - - local _,_,dtype = UnitDebuff("target", i) - if dtype == "Magic" then - pfUI.uf.target.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,1,1) - elseif dtype == "Poison" then - pfUI.uf.target.debuff.debuffs[i].backdrop:SetBackdropBorderColor(0,1,0,1) - elseif dtype == "Curse" then - pfUI.uf.target.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,1,1) - elseif dtype == "Disease" then - pfUI.uf.target.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,1,0,1) - else - pfUI.uf.target.debuff.debuffs[i].backdrop:SetBackdropBorderColor(1,0,0,1) - end - - if texture then - pfUI.uf.target.debuff.debuffs[i]:Show() - if stacks > 1 then - pfUI.uf.target.debuff.debuffs[i].stacks:SetText(stacks) - else - pfUI.uf.target.debuff.debuffs[i].stacks:SetText("") - end - else - pfUI.uf.target.debuff.debuffs[i]:Hide() - end - end - end end) diff --git a/modules/targettarget.lua b/modules/targettarget.lua index 45cb3a2a..fef49ffd 100644 --- a/modules/targettarget.lua +++ b/modules/targettarget.lua @@ -2,15 +2,8 @@ pfUI:RegisterModule("targettarget", function () -- do not go further on disabled UFs if C.unitframes.disable == "1" then return end - local default_border = C.appearance.border.default - if C.appearance.border.unitframes ~= "-1" then - default_border = C.appearance.border.unitframes - end - - local spacing = C.unitframes.ttarget.pspace - - pfUI.uf.targettargetNotify = CreateFrame("Button",nil,UIParent) - pfUI.uf.targettargetNotify:SetScript("OnUpdate", function() + pfUI.uf.targettargetScanner = CreateFrame("Button",nil,UIParent) + pfUI.uf.targettargetScanner:SetScript("OnUpdate", function() if UnitExists("targettarget") or (pfUI.gitter and pfUI.gitter:IsShown()) then pfUI.uf.targettarget:Show() else @@ -18,160 +11,8 @@ pfUI:RegisterModule("targettarget", function () end end) - pfUI.uf.targettarget = CreateFrame("Button","pfTargetTarget",UIParent) - pfUI.uf.targettarget.label = "targettarget" - pfUI.uf.targettarget.id = "" - pfUI.uf.targettarget:SetFrameStrata("LOW") - pfUI.uf.targettarget:SetWidth(100) - pfUI.uf.targettarget:SetHeight(20 + 2*default_border + spacing) + pfUI.uf.targettarget = pfUI.uf:CreateUnitFrame("TargetTarget", nil, C.unitframes.ttarget, .2) + pfUI.uf.targettarget:UpdateFrameSize() pfUI.uf.targettarget:SetPoint("BOTTOM", UIParent , "BOTTOM", 0, 125) UpdateMovable(pfUI.uf.targettarget) - - pfUI.uf.targettarget:RegisterForClicks('LeftButtonUp', 'RightButtonUp', 'MiddleButtonUp', 'Button4Up', 'Button5Up') - pfUI.uf.targettarget:SetScript("OnEnter", function() - GameTooltip_SetDefaultAnchor(GameTooltip, this) - GameTooltip:SetUnit(this.label .. this.id) - GameTooltip:Show() - end) - - pfUI.uf.targettarget:SetScript("OnLeave", function() - GameTooltip:FadeOut() - end) - - pfUI.uf.targettarget:SetScript("OnClick", function () - pfUI.uf:ClickAction(arg1) - end) - - pfUI.uf.targettarget:SetScript("OnUpdate", function() - if UnitExists("targettarget") then - pfUI.uf.targettarget:Show() - elseif (pfUI.gitter and pfUI.gitter:IsShown()) then - pfUI.uf.targettarget:Show() - return - else - pfUI.uf.targettarget:Hide() - return - end - - local raidIcon = GetRaidTargetIndex("targettarget") - if raidIcon then - SetRaidTargetIconTexture(pfUI.uf.targettarget.hp.raidIcon.texture, raidIcon) - pfUI.uf.targettarget.hp.raidIcon:Show() - else - pfUI.uf.targettarget.hp.raidIcon:Hide() - end - - local color - if UnitIsPlayer("targettarget") then - _, class = UnitClass("targettarget") - color = RAID_CLASS_COLORS[class] - else - color = UnitReactionColor[UnitReaction("targettarget", "player")] - end - - pfUI.uf.targettarget.hp.bar:SetMinMaxValues(0, UnitHealthMax("targettarget")) - local r, g, b = .2, .2, .2 - if color then - if C.unitframes.custom == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.customcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.targettarget.hp.bar:SetStatusBarColor(cr, cg, cb, UnitHealth("targettarget") / UnitHealthMax("targettarget") / 4 + .75) - if C.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 - else - if C.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 - pfUI.uf.targettarget.hp.bar:SetStatusBarColor(r, g, b, UnitHealth("targettarget") / UnitHealthMax("targettarget") / 4 + .75) - end - - pfUI.uf.targettarget.hp.text:SetTextColor(r, g, b, 1) - end - pfUI.uf.targettarget.hp.text:SetText( UnitName("targettarget")) - - local display, real - display = pfUI.uf.targettarget.hp.bar:GetValue() - real = UnitHealth("targettarget") - diff = abs(real - display) - if display < real then - pfUI.uf.targettarget.hp.bar:SetValue(display + ceil(diff / C.unitframes.animation_speed)) - elseif display > real then - pfUI.uf.targettarget.hp.bar:SetValue(display - ceil(diff / C.unitframes.animation_speed)) - else - pfUI.uf.targettarget.hp.bar:SetValue(real) - end - - PowerColor = ManaBarColor[UnitPowerType("targettarget")] - pfUI.uf.targettarget.power.bar:SetStatusBarColor(PowerColor.r + .5, PowerColor.g +.5, PowerColor.b +.5, 1) - pfUI.uf.targettarget.power.bar:SetMinMaxValues(0, UnitManaMax("targettarget")) - - local display, real - display = pfUI.uf.targettarget.power.bar:GetValue() - real = UnitMana("targettarget") - diff = abs(real - display) - if display < real then - pfUI.uf.targettarget.power.bar:SetValue(display + ceil(diff / C.unitframes.animation_speed)) - elseif display > real then - pfUI.uf.targettarget.power.bar:SetValue(display - ceil(diff / C.unitframes.animation_speed)) - else - pfUI.uf.targettarget.power.bar:SetValue(real) - end - end) - - pfUI.uf.targettarget.hp = CreateFrame("Frame",nil, pfUI.uf.targettarget) - pfUI.uf.targettarget.hp:SetPoint("TOP", 0, 0) - pfUI.uf.targettarget.hp:SetWidth(100) - pfUI.uf.targettarget.hp:SetHeight(16) - CreateBackdrop(pfUI.uf.targettarget.hp, default_border) - - pfUI.uf.targettarget.hp.bar = CreateFrame("StatusBar", nil, pfUI.uf.targettarget.hp) - pfUI.uf.targettarget.hp.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.targettarget.hp.bar:SetAllPoints(pfUI.uf.targettarget.hp) - pfUI.uf.targettarget.hp.bar:SetMinMaxValues(0, 100) - - if C.unitframes.custombg == "1" then - local cr, cg, cb, ca = strsplit(",", C.unitframes.custombgcolor) - cr, cg, cb = tonumber(cr), tonumber(cg), tonumber(cb) - pfUI.uf.targettarget.hp.bar.texture = pfUI.uf.targettarget.hp.bar:CreateTexture(nil,"BACKGROUND") - pfUI.uf.targettarget.hp.bar.texture:SetTexture(cr,cg,cb,ca) - pfUI.uf.targettarget.hp.bar.texture:SetAllPoints(pfUI.uf.targettarget.hp.bar) - end - - pfUI.uf.targettarget.hp.raidIcon = CreateFrame("Frame",nil,pfUI.uf.targettarget.hp) - pfUI.uf.targettarget.hp.raidIcon:SetFrameStrata("MEDIUM") - pfUI.uf.targettarget.hp.raidIcon:SetParent(pfUI.uf.targettarget.hp.bar) - pfUI.uf.targettarget.hp.raidIcon:SetWidth(16) - pfUI.uf.targettarget.hp.raidIcon:SetHeight(16) - pfUI.uf.targettarget.hp.raidIcon.texture = pfUI.uf.targettarget.hp.raidIcon:CreateTexture(nil,"ARTWORK") - pfUI.uf.targettarget.hp.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") - pfUI.uf.targettarget.hp.raidIcon.texture:SetAllPoints(pfUI.uf.targettarget.hp.raidIcon) - pfUI.uf.targettarget.hp.raidIcon:SetPoint("TOP", pfUI.uf.targettarget.hp, "TOP", 0, 6) - pfUI.uf.targettarget.hp.raidIcon:Hide() - - pfUI.uf.targettarget.power = CreateFrame("Frame",nil, pfUI.uf.targettarget) - CreateBackdrop(pfUI.uf.targettarget.power, default_border) - pfUI.uf.targettarget.power:SetPoint("BOTTOM", 0, 0) - pfUI.uf.targettarget.power:SetWidth(100) - pfUI.uf.targettarget.power:SetHeight(4) - - pfUI.uf.targettarget.power.bar = CreateFrame("StatusBar", nil, pfUI.uf.targettarget.power) - pfUI.uf.targettarget.power.bar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar") - pfUI.uf.targettarget.power.bar:SetAllPoints(pfUI.uf.targettarget.power) - pfUI.uf.targettarget.power.bar:SetMinMaxValues(0, 100) - - pfUI.uf:CreatePortrait(pfUI.uf.targettarget, C.unitframes.ttarget.portrait, spacing) - - pfUI.uf.targettarget.hp.text = pfUI.uf.targettarget.hp.bar:CreateFontString("Status", "OVERLAY", "GameFontNormal") - pfUI.uf.targettarget.hp.text:SetFont(pfUI.font_square, C.global.font_size - 2, "OUTLINE") - pfUI.uf.targettarget.hp.text:ClearAllPoints() - pfUI.uf.targettarget.hp.text:SetAllPoints(pfUI.uf.targettarget.hp.bar) - pfUI.uf.targettarget.hp.text:SetPoint("CENTER", 0, 0) - pfUI.uf.targettarget.hp.text:SetJustifyH("CENTER") - pfUI.uf.targettarget.hp.text:SetFontObject(GameFontWhite) - pfUI.uf.targettarget.hp.text:SetText("n/a") end)