Major update
-New feature: Arena DPS Bar, can be enabled at the Broadcaster Tools section, shows a bar in 'kamehameha' style showing which team is doing more damage in the latest 3 seconds. -Revamp on the options section for Broadcaster tools. -Added 'Icon Size Offset' under Options > Bars: General, this new option allow to adjust the size of the class/spec icon shown on each bar. -Added 'Show Faction Icon' under Options > Bars: General, with this new option, you can choose to not show the faction icon, this icon is usually shown during battlegrounds. -Added 'Faction Icon Size Offset' under Options > Bars: General, new option to adjust the size of the faction icon. -Added 'Show Arena Role Icon' under Options > Bars: General, new option to hide or show the role icon of players during an arena match. -Added 'Arena Role Icon Size Offset' under Options > Bars: General, new option which allow to control the size of the arena role icon. -Added 'Level' option to Wallpapers, the wallpaper can now be placed on different levels which solves issues where the wallpaper is too low of certain configuration. -Streamer! plugin got updates, now it is more clear to pick which mode to use. -WotLK classic compatibility (Flamanis, Daniel Henry). -Fixed the title bar text not showing when using the Custom Title Bar feature. -Role detection in classic versions got improvements. -New API: Details:GetTop5Actors(attributeId), return the top 5 actors from the selected attribute. -New API: Details:GetActorByRank(attributeId, rankIndex), return an actor from the selected attribute and rankIndex. -Major cleanup and code improvements on dropdowns for library Details! Framework. -Cleanup on NickTag library. -Removed LibGroupInSpecT, LibItemUpgradeInfo and LibCompress. These libraries got replaced by OpenRaidLib and LibDeflate.
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
|
||||
|
||||
local Details = _G.Details
|
||||
|
||||
--namespace
|
||||
Details.CurrentDps = {
|
||||
Dps = {},
|
||||
Hps = {},
|
||||
}
|
||||
|
||||
local currentDpsFrame = CreateFrame("frame", "DetailsCurrentDpsUpdaterFrame", UIParent)
|
||||
local delayTimeBetweenUpdates = 0.10
|
||||
local currentDelay = 0
|
||||
local cacheSize = 40 --4 seconds of data
|
||||
local dpsTime = delayTimeBetweenUpdates * cacheSize
|
||||
local cacheOverflowIndex = cacheSize + 1
|
||||
|
||||
currentDpsFrame.OnUpdateFunc = function(self, deltaTime)
|
||||
currentDelay = currentDelay + deltaTime
|
||||
if (currentDelay < delayTimeBetweenUpdates) then
|
||||
return
|
||||
end
|
||||
|
||||
local combatObject = Details.CurrentDps.CombatObject
|
||||
|
||||
local damageContainer = combatObject:GetContainer(DETAILS_ATTRIBUTE_DAMAGE)
|
||||
for index, actorObject in damageContainer:ListActors() do
|
||||
if (actorObject:IsPlayer()) then
|
||||
local actorTable = Details.CurrentDps.Dps[actorObject.serial]
|
||||
if (not actorTable) then
|
||||
actorTable = {
|
||||
totalDamage = 0, --hold a sum of all dps done in the latest #cacheSize delayed OnUpdate ticks
|
||||
currentDps = 0,
|
||||
latestDamageAmount = 0,
|
||||
cache = {},
|
||||
}
|
||||
Details.CurrentDps.Dps[actorObject.serial] = actorTable
|
||||
end
|
||||
|
||||
--get the damage done on this tick
|
||||
local totalDamageThisTick = actorObject.total - actorTable.latestDamageAmount
|
||||
--add the damage to the cache
|
||||
tinsert(actorTable.cache, 1, totalDamageThisTick)
|
||||
--set the latest damage amount
|
||||
actorTable.latestDamageAmount = actorObject.total
|
||||
--sum the total damage the actor inflicted
|
||||
actorTable.totalDamage = actorTable.totalDamage + totalDamageThisTick
|
||||
|
||||
--cut the damage
|
||||
local damageRemoved = tremove(actorTable.cache, cacheOverflowIndex)
|
||||
if (damageRemoved) then
|
||||
actorTable.totalDamage = actorTable.totalDamage - damageRemoved
|
||||
actorTable.totalDamage = max(0, actorTable.totalDamage) --safe guard
|
||||
end
|
||||
|
||||
actorTable.currentDps = actorTable.totalDamage / dpsTime
|
||||
if (actorObject.nome == "Ditador") then
|
||||
local formatToKFunc = Details:GetCurrentToKFunction()
|
||||
print(actorTable.totalDamage, #actorTable.cache, dpsTime, formatToKFunc(nil, actorTable.currentDps))
|
||||
end
|
||||
|
||||
if (actorObject.nome == "Ditador") then
|
||||
--print("Dps:", actorTable.currentDps)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
currentDelay = 0
|
||||
end
|
||||
|
||||
--start the proccess of updating the current dps and hps for each player
|
||||
function Details.CurrentDps.StartCurrentDpsTracker()
|
||||
Details.CurrentDps.CombatObject = Details:GetCurrentCombat()
|
||||
wipe(Details.CurrentDps.Dps)
|
||||
wipe(Details.CurrentDps.Hps)
|
||||
currentDpsFrame:SetScript("OnUpdate", currentDpsFrame.OnUpdateFunc)
|
||||
end
|
||||
--stop what the function above started
|
||||
function Details.CurrentDps.StopCurrentDpsTracker()
|
||||
currentDpsFrame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
--serial = guid
|
||||
function Details.CurrentDps.GetCurrentDps(serial)
|
||||
local actorTable = Details.CurrentDps.Dps[serial]
|
||||
if (actorTable) then
|
||||
local currentDps = actorTable.currentDps
|
||||
local formatToKFunc = Details:GetCurrentToKFunction()
|
||||
return formatToKFunc(nil, currentDps)
|
||||
end
|
||||
end
|
||||
|
||||
--handle internal details! events
|
||||
local eventListener = Details:CreateEventListener()
|
||||
eventListener:RegisterEvent("COMBAT_PLAYER_ENTER", function()
|
||||
--Details.CurrentDps.StartCurrentDpsTracker()
|
||||
end)
|
||||
eventListener:RegisterEvent("COMBAT_PLAYER_LEAVE", function()
|
||||
--Details.CurrentDps.StopCurrentDpsTracker()
|
||||
end)
|
||||
Reference in New Issue
Block a user