diff --git a/AuraIndicators.lua b/AuraIndicators.lua index b7f5f00..9dabfe7 100644 --- a/AuraIndicators.lua +++ b/AuraIndicators.lua @@ -202,254 +202,257 @@ function EnhancedRaidFrames:UpdateIndicators(frame, setAppearance) -- Loop over the indicators and see if we get a hit for i = 1, 9 do local buffcount = 1 + local skip = false -- If we only are to show the indicator on me, then don't bother if I'm not the unit if EnhancedRaidFrames.db.profile["me"..i] then local uName, uRealm = UnitName(unit) if uName ~= UnitName("player") or uRealm ~= nil then - break + skip = true end end if EnhancedRaidFrames.db.profile["combat"..i] and InCombatLockdown() then - break + skip = true end - -- Go through the aura strings - for _, auraNameLine in ipairs(EnhancedRaidFrames.auraStrings[i]) do -- Grab each line - if buffcount > 6 then - break - end - - local remainingTime, displayText, count, duration, expirationTime, castBy, icon, debuffType, locatedAuraIndex, auraIndex, buff - - displayText = "" - icon = "" - count = 0 - duration = 0 - expirationTime = 0 - castBy = "" - auraIndex = -1 - buff = nil - baseAuraName = "" - - for _, auraName in ipairs({strsplit(",", auraNameLine)}) do - auraName = strtrim(auraName) - if baseAuraName == "" then - baseAuraName = auraName - end - -- If we already found one of the buffs break - if locatedAuraIndex and castBy == "player" then + if not skip then + -- Go through the aura strings + for _, auraNameLine in ipairs(EnhancedRaidFrames.auraStrings[i]) do -- Grab each line + if buffcount > 6 then break end + + local remainingTime, displayText, count, duration, expirationTime, castBy, icon, debuffType, locatedAuraIndex, auraIndex, buff - -- Check if the aura exist on the unit - for j = 1, #unitBuffs[unit] do -- Check buffs - if tonumber(auraName) then -- Use spell id - if unitBuffs[unit][j].spellId == tonumber(auraName) then - locatedAuraIndex = j - end - elseif unitBuffs[unit][j].auraName == auraName then -- Hit on auraName - locatedAuraIndex = j + displayText = "" + icon = "" + count = 0 + duration = 0 + expirationTime = 0 + castBy = "" + auraIndex = -1 + buff = nil + baseAuraName = "" + + for _, auraName in ipairs({strsplit(",", auraNameLine)}) do + auraName = strtrim(auraName) + if baseAuraName == "" then + baseAuraName = auraName end - if locatedAuraIndex and unitBuffs[unit][j].castBy == "player" then -- Keep looking if it's not cast by the player + -- If we already found one of the buffs break + if locatedAuraIndex and castBy == "player" then break end - end - if locatedAuraIndex then - count = unitBuffs[unit][locatedAuraIndex].count - duration = unitBuffs[unit][locatedAuraIndex].duration - expirationTime = unitBuffs[unit][locatedAuraIndex].expirationTime - castBy = unitBuffs[unit][locatedAuraIndex].castBy - icon = unitBuffs[unit][locatedAuraIndex].icon - auraIndex = unitBuffs[unit][locatedAuraIndex].auraIndex - buff = true - else - for j = 1, #unitDebuffs[unit] do -- Check debuffs + -- Check if the aura exist on the unit + for j = 1, #unitBuffs[unit] do -- Check buffs if tonumber(auraName) then -- Use spell id - if unitDebuffs[unit][j].spellId == tonumber(auraName) then + if unitBuffs[unit][j].spellId == tonumber(auraName) then locatedAuraIndex = j end - elseif unitDebuffs[unit][j].auraName == auraName then -- Hit on auraName - locatedAuraIndex = j - elseif unitDebuffs[unit][j].debuffType == auraName then -- Hit on debufftype + elseif unitBuffs[unit][j].auraName == auraName then -- Hit on auraName locatedAuraIndex = j end - if locatedAuraIndex and unitDebuffs[unit][j].castBy == "player" then -- Keep looking if it's not cast by the player + if locatedAuraIndex and unitBuffs[unit][j].castBy == "player" then -- Keep looking if it's not cast by the player break end end if locatedAuraIndex then - count = unitDebuffs[unit][locatedAuraIndex].count - duration = unitDebuffs[unit][locatedAuraIndex].duration - expirationTime = unitDebuffs[unit][locatedAuraIndex].expirationTime - castBy = unitDebuffs[unit][locatedAuraIndex].castBy - icon = unitDebuffs[unit][locatedAuraIndex].icon - debuffType = unitDebuffs[unit][locatedAuraIndex].debuffType - auraIndex = unitDebuffs[unit][locatedAuraIndex].auraIndex - buff = false - end - end + count = unitBuffs[unit][locatedAuraIndex].count + duration = unitBuffs[unit][locatedAuraIndex].duration + expirationTime = unitBuffs[unit][locatedAuraIndex].expirationTime + castBy = unitBuffs[unit][locatedAuraIndex].castBy + icon = unitBuffs[unit][locatedAuraIndex].icon + auraIndex = unitBuffs[unit][locatedAuraIndex].auraIndex + buff = true + else + for j = 1, #unitDebuffs[unit] do -- Check debuffs + if tonumber(auraName) then -- Use spell id + if unitDebuffs[unit][j].spellId == tonumber(auraName) then + locatedAuraIndex = j + end + elseif unitDebuffs[unit][j].auraName == auraName then -- Hit on auraName + locatedAuraIndex = j + elseif unitDebuffs[unit][j].debuffType == auraName then -- Hit on debufftype + locatedAuraIndex = j + end + if locatedAuraIndex and unitDebuffs[unit][j].castBy == "player" then -- Keep looking if it's not cast by the player + break + end + end - if auraName:upper() == "PVP" then -- Check if we want to show pvp flag - if UnitIsPVP(unit) then - count = 0 - expirationTime = 0 - duration = 0 - castBy = "player" - locatedAuraIndex = -1 - - local factionGroup = UnitFactionGroup(unit) - if factionGroup then - icon = "Interface\\GroupFrame\\UI-Group-PVP-"..factionGroup + if locatedAuraIndex then + count = unitDebuffs[unit][locatedAuraIndex].count + duration = unitDebuffs[unit][locatedAuraIndex].duration + expirationTime = unitDebuffs[unit][locatedAuraIndex].expirationTime + castBy = unitDebuffs[unit][locatedAuraIndex].castBy + icon = unitDebuffs[unit][locatedAuraIndex].icon + debuffType = unitDebuffs[unit][locatedAuraIndex].debuffType + auraIndex = unitDebuffs[unit][locatedAuraIndex].auraIndex + buff = false end + end + + if auraName:upper() == "PVP" then -- Check if we want to show pvp flag + if UnitIsPVP(unit) then + count = 0 + expirationTime = 0 + duration = 0 + castBy = "player" + locatedAuraIndex = -1 + + local factionGroup = UnitFactionGroup(unit) + if factionGroup then + icon = "Interface\\GroupFrame\\UI-Group-PVP-"..factionGroup + end - auraIndex = -1 + auraIndex = -1 + end + elseif auraName:upper() == "TOT" then -- Check if we want to show ToT flag + if UnitIsUnit (unit, "targettarget") then + count = 0 + expirationTime = 0 + duration = 0 + castBy = "player" + locatedAuraIndex = -1 + icon = "Interface\\Icons\\Ability_Hunter_SniperShot" + auraIndex = -1 + end end - elseif auraName:upper() == "TOT" then -- Check if we want to show ToT flag - if UnitIsUnit (unit, "targettarget") then - count = 0 - expirationTime = 0 - duration = 0 - castBy = "player" - locatedAuraIndex = -1 - icon = "Interface\\Icons\\Ability_Hunter_SniperShot" - auraIndex = -1 + + -- If we only are to show spells cast by me, make sure the spell is + if (EnhancedRaidFrames.db.profile["mine"..i] and castBy ~= "player") then + locatedAuraIndex = nil + icon = "" end end - -- If we only are to show spells cast by me, make sure the spell is - if (EnhancedRaidFrames.db.profile["mine"..i] and castBy ~= "player") then - locatedAuraIndex = nil + -- Only show when it's missing + if EnhancedRaidFrames.db.profile["missing"..i] and locatedAuraIndex then icon = "" - end - end - - -- Only show when it's missing - if EnhancedRaidFrames.db.profile["missing"..i] and locatedAuraIndex then - icon = "" - displayText = "" - elseif EnhancedRaidFrames.db.profile["missing"..i] then - if EnhancedRaidFrames.db.profile["showIcon"..i] then - --try to find an icon - if baseAuraName then --if the string is empty do nothing - if string.lower(baseAuraName) == "poison" then - icon = 132104 - elseif string.lower(baseAuraName) == "disease" then - icon = 132099 - elseif string.lower(baseAuraName) == "curse" then - icon = 132095 - elseif string.lower(baseAuraName) == "magic" then - icon = 135894 - else - _,_,icon = GetSpellInfo(baseAuraName) - end + displayText = "" + elseif EnhancedRaidFrames.db.profile["missing"..i] then + if EnhancedRaidFrames.db.profile["showIcon"..i] then + --try to find an icon + if baseAuraName then --if the string is empty do nothing + if string.lower(baseAuraName) == "poison" then + icon = 132104 + elseif string.lower(baseAuraName) == "disease" then + icon = 132099 + elseif string.lower(baseAuraName) == "curse" then + icon = 132095 + elseif string.lower(baseAuraName) == "magic" then + icon = 135894 + else + _,_,icon = GetSpellInfo(baseAuraName) + end - if not icon then - displayText = "X" --if you can't find an icon, display an X + if not icon then + displayText = "X" --if you can't find an icon, display an X + end end + else + displayText = "X" --if we aren't showing icons, display and X end - else - displayText = "X" --if we aren't showing icons, display and X - end - elseif locatedAuraIndex then -- We found a matching spell - if not EnhancedRaidFrames.db.profile["showIcon"..i] then -- Hide icon - icon = "" - end - if expirationTime == 0 then -- No expiration time = permanent - if not EnhancedRaidFrames.db.profile["showIcon"..i] then - displayText = "■" -- Only show the blob if we don't show the icon + elseif locatedAuraIndex then -- We found a matching spell + if not EnhancedRaidFrames.db.profile["showIcon"..i] then -- Hide icon + icon = "" end - else - if EnhancedRaidFrames.db.profile["showText"..i] then - -- Pretty formatting of the remaining time text - remainingTime = expirationTime - currentTime - if remainingTime > 60 then - displayText = string.format("%.0f", (remainingTime / 60)).."m" -- Show minutes without seconds - elseif remainingTime >= 1 then - displayText = string.format("%.0f",remainingTime) -- Show seconds without decimals + if expirationTime == 0 then -- No expiration time = permanent + if not EnhancedRaidFrames.db.profile["showIcon"..i] then + displayText = "■" -- Only show the blob if we don't show the icon end else - displayText = "" - end + if EnhancedRaidFrames.db.profile["showText"..i] then + -- Pretty formatting of the remaining time text + remainingTime = expirationTime - currentTime + if remainingTime > 60 then + displayText = string.format("%.0f", (remainingTime / 60)).."m" -- Show minutes without seconds + elseif remainingTime >= 1 then + displayText = string.format("%.0f",remainingTime) -- Show seconds without decimals + end + else + displayText = "" + end - end + end - -- Add stack count - if EnhancedRaidFrames.db.profile["stack"..i] and count > 0 then - if EnhancedRaidFrames.db.profile["showText"..i] and expirationTime > 0 then - displayText = count .."-".. displayText - else - displayText = count + -- Add stack count + if EnhancedRaidFrames.db.profile["stack"..i] and count > 0 then + if EnhancedRaidFrames.db.profile["showText"..i] and expirationTime > 0 then + displayText = count .."-".. displayText + else + displayText = count + end end + else + icon = "" + displayText = "" end - else - icon = "" - displayText = "" - end - - - --set the texture or text on a frame, and show or hide the indicator frame - if baseAuraName ~= "" and (icon ~= "" or displayText ~="") and UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then - local button = f[frameName][i*4+buffcount] - buffcount = buffcount + 1 - if auraIndex then - button.auraIndex = auraIndex - end - if buff ~= nil then - button.buff = buff - end + + --set the texture or text on a frame, and show or hide the indicator frame + if baseAuraName ~= "" and (icon ~= "" or displayText ~="") and UnitIsConnected(unit) and not UnitIsDeadOrGhost(unit) then + local button = f[frameName][i*4+buffcount] + buffcount = buffcount + 1 - -- Set color - if EnhancedRaidFrames.db.profile["stackColor"..i] then -- Color by stack - if count == 1 then - button.text:SetTextColor(1,0,0,1) - elseif count == 2 then - button.text:SetTextColor(1,1,0,1) - elseif count >= 3 then - button.text:SetTextColor(0,1,0,1) - else - button.text:SetTextColor(1,1,1,1) + if auraIndex then + button.auraIndex = auraIndex + end + if buff ~= nil then + button.buff = buff end - elseif EnhancedRaidFrames.db.profile["debuffColor"..i] then -- Color by debuff type - if debuffType then - if debuffType == "Curse" then - button.text:SetTextColor(0.6,0,1,1) - elseif debuffType == "Disease" then - button.text:SetTextColor(0.6,0.4,0,1) - elseif debuffType == "Magic" then - button.text:SetTextColor(0.2,0.6,1,1) - elseif debuffType == "Poison" then - button.text:SetTextColor(0,0.6,0,1) + + -- Set color + if EnhancedRaidFrames.db.profile["stackColor"..i] then -- Color by stack + if count == 1 then + button.text:SetTextColor(1,0,0,1) + elseif count == 2 then + button.text:SetTextColor(1,1,0,1) + elseif count >= 3 then + button.text:SetTextColor(0,1,0,1) + else + button.text:SetTextColor(1,1,1,1) + end + elseif EnhancedRaidFrames.db.profile["debuffColor"..i] then -- Color by debuff type + if debuffType then + if debuffType == "Curse" then + button.text:SetTextColor(0.6,0,1,1) + elseif debuffType == "Disease" then + button.text:SetTextColor(0.6,0.4,0,1) + elseif debuffType == "Magic" then + button.text:SetTextColor(0.2,0.6,1,1) + elseif debuffType == "Poison" then + button.text:SetTextColor(0,0.6,0,1) + end + end + elseif EnhancedRaidFrames.db.profile["colorByTime"..i] then -- Color by remaining time + if remainingTime and remainingTime < 3 then + button.text:SetTextColor(1,0,0,1) + elseif remainingTime and remainingTime < 5 then + button.text:SetTextColor(1,1,0,1) + else + button.text:SetTextColor(EnhancedRaidFrames.db.profile["color"..i].r, EnhancedRaidFrames.db.profile["color"..i].g, EnhancedRaidFrames.db.profile["color"..i].b, EnhancedRaidFrames.db.profile["color"..i].a) end end - elseif EnhancedRaidFrames.db.profile["colorByTime"..i] then -- Color by remaining time - if remainingTime and remainingTime < 3 then - button.text:SetTextColor(1,0,0,1) - elseif remainingTime and remainingTime < 5 then - button.text:SetTextColor(1,1,0,1) + + -- show the frame + button:Show() + -- Show the text + button.text:SetText(displayText) + + -- Show the icon + button.icon:SetTexture(icon) + --set cooldown animation + if EnhancedRaidFrames.db.profile["showCooldownAnimation"..i] and icon~="" and button:IsShown() then + CooldownFrame_Set(button.cooldown, expirationTime - duration, duration, true, true) else - button.text:SetTextColor(EnhancedRaidFrames.db.profile["color"..i].r, EnhancedRaidFrames.db.profile["color"..i].g, EnhancedRaidFrames.db.profile["color"..i].b, EnhancedRaidFrames.db.profile["color"..i].a) + CooldownFrame_Clear(button.cooldown); end end - - -- show the frame - button:Show() - -- Show the text - button.text:SetText(displayText) - - -- Show the icon - button.icon:SetTexture(icon) - --set cooldown animation - if EnhancedRaidFrames.db.profile["showCooldownAnimation"..i] and icon~="" and button:IsShown() then - CooldownFrame_Set(button.cooldown, expirationTime - duration, duration, true, true) - else - CooldownFrame_Clear(button.cooldown); - end end end for k = buffcount, 6 do