From 1afb89790459faec706ca4c1c11c04c07d201ec8 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Thu, 28 Apr 2022 15:52:11 -0300 Subject: [PATCH] Open Raid Library update --- Libs/LibOpenRaid/Deprecated.lua | 5 + Libs/LibOpenRaid/Functions.lua | 31 ----- Libs/LibOpenRaid/LibOpenRaid.lua | 179 ++++++++++++++++++++++++--- Libs/LibOpenRaid/ThingsToMantain.lua | 46 +++++-- Libs/LibOpenRaid/docs.txt | 78 +++++++++++- boot.lua | 4 +- core/parser.lua | 5 + frames/window_cdtracker.lua | 13 ++ 8 files changed, 298 insertions(+), 63 deletions(-) diff --git a/Libs/LibOpenRaid/Deprecated.lua b/Libs/LibOpenRaid/Deprecated.lua index 2ba9ff15c..cb5c78355 100644 --- a/Libs/LibOpenRaid/Deprecated.lua +++ b/Libs/LibOpenRaid/Deprecated.lua @@ -6,6 +6,11 @@ end local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0") +--> comm prefix deprecated +openRaidLib.commPrefixDeprecated = { + +} + local spamLimit = {} local showDeprecatedMessage = function(deprecatedCall, newCall) diff --git a/Libs/LibOpenRaid/Functions.lua b/Libs/LibOpenRaid/Functions.lua index d9417a0ee..3d58c7f01 100644 --- a/Libs/LibOpenRaid/Functions.lua +++ b/Libs/LibOpenRaid/Functions.lua @@ -216,35 +216,4 @@ function openRaidLib.FilterCooldowns(unitName, allCooldowns, filters) end return resultFilters -end - ---compare the current list of spells of the player with a new spell list generated ---add or remove spells from the current list, make the cache dirt and return a table with spells removed or added -function openRaidLib.CooldownManager.CheckForSpellsAdeedOrRemoved() - local playerName = UnitName("player") - local currentCooldowns = openRaidLib.CooldownManager.UnitData[playerName] - local _, newCooldownList = openRaidLib.CooldownManager.GetPlayerCooldownList() - local spellsAdded, spellsRemoved = {}, {} - - for spellId, cooldownInfo in pairs(newCooldownList) do - if (not currentCooldowns[spellId]) then - --a spell has been added - currentCooldowns[spellId] = cooldownInfo - spellsAdded[#spellsAdded+1] = {spellId} - --mark the filter cache of this unit as dirt - openRaidLib.CooldownManager.NeedRebuildFilters[playerName] = true - end - end - - for spellId, cooldownInfo in pairs(currentCooldowns) do - if (not newCooldownList[spellId]) then - --a spell has been removed - currentCooldowns[spellId] = nil - spellsRemoved[#spellsRemoved+1] = {spellId} - --mark the filter cache of this unit as dirt - openRaidLib.CooldownManager.NeedRebuildFilters[playerName] = true - end - end - - return spellsAdded, spellsRemoved end \ No newline at end of file diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index e55e438d8..9ff53625b 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -25,11 +25,11 @@ Change Log: - player information is always available even when not in a group. TODO: - - need to finish the CheckForSpellsAdeedOrRemoved(), need to send the comm, need to create the local callbacks - - create comm to add or remove a cooldown from an unit + - (finished but not active atm) need to finish the CheckForSpellsAdeedOrRemoved(), need to send the comm, need to create the local callbacks + - (finished but not active atm) create comm to add or remove a cooldown from an unit + - make talents changes also send only cooldowns added or changed - add into gear info how many tier set parts the player has - keystone info (portion of the logic is implemented, need to share the information) - - add unit_connected through comm to know if a unit disconnected, do the lib realy need this? I don't think so - raid lockouts normal-heroic-mythic - soulbind character (covenant choise) - probably not used in 10.0 @@ -41,7 +41,7 @@ BUGS: local major = "LibOpenRaid-1.0" -local CONST_LIB_VERSION = 32 +local CONST_LIB_VERSION = 33 LIB_OPEN_RAID_CAN_LOAD = false --declae the library within the LibStub @@ -67,8 +67,7 @@ LIB_OPEN_RAID_CAN_LOAD = false local CONST_COMM_COOLDOWNUPDATE_PREFIX = "U" local CONST_COMM_COOLDOWNFULLLIST_PREFIX = "C" - local CONST_COMM_COOLDOWNADDSPELL_PREFIX = "S" - local CONST_COMM_COOLDOWNREMOVESPELL_PREFIX = "E" + local CONST_COMM_COOLDOWNCHANGES_PREFIX = "S" local CONST_COMM_GEARINFO_FULL_PREFIX = "G" local CONST_COMM_GEARINFO_DURABILITY_PREFIX = "R" @@ -125,7 +124,6 @@ LIB_OPEN_RAID_CAN_LOAD = false openRaidLib.commHandler = {} function openRaidLib.commHandler.OnReceiveComm(self, event, prefix, text, channel, sender, target, zoneChannelID, localID, name, instanceID) - --check if the data belong to us if (prefix == CONST_COMM_PREFIX) then --check if the lib can receive comms @@ -140,7 +138,7 @@ LIB_OPEN_RAID_CAN_LOAD = false if (playerName == sender) then return end - + local data = text local LibDeflate = LibStub:GetLibrary("LibDeflate") local dataCompressed = LibDeflate:DecodeForWoWAddonChannel(data) @@ -148,8 +146,18 @@ LIB_OPEN_RAID_CAN_LOAD = false --get the first byte of the data, it indicates what type of data was transmited local dataTypePrefix = data:match("^.") + if (not dataTypePrefix) then + return + elseif (openRaidLib.commPrefixDeprecated[dataTypePrefix]) then + return + end + --get the table with functions regitered for this type of data local callbackTable = openRaidLib.commHandler.commCallback[dataTypePrefix] + if (not callbackTable) then + return + end + --convert to table local dataAsTable = {strsplit(",", data)} @@ -173,6 +181,7 @@ LIB_OPEN_RAID_CAN_LOAD = false [CONST_COMM_FULLINFO_PREFIX] = {}, --update all [CONST_COMM_COOLDOWNFULLLIST_PREFIX] = {}, --all cooldowns of a player [CONST_COMM_COOLDOWNUPDATE_PREFIX] = {}, --an update of a single cooldown + [CONST_COMM_COOLDOWNCHANGES_PREFIX] = {}, --cooldowns got added or removed [CONST_COMM_GEARINFO_FULL_PREFIX] = {}, --an update of gear information [CONST_COMM_GEARINFO_DURABILITY_PREFIX] = {}, --an update of the player gear durability [CONST_COMM_PLAYER_DEAD_PREFIX] = {}, --player is dead @@ -287,6 +296,8 @@ LIB_OPEN_RAID_CAN_LOAD = false "CooldownListUpdate", "CooldownListWipe", "CooldownUpdate", + "CooldownAdded", + "CooldownRemoved", "UnitDeath", "UnitAlive", "GearListWipe", @@ -453,6 +464,9 @@ LIB_OPEN_RAID_CAN_LOAD = false ["UNIT_SPELLCAST_SUCCEEDED"] = function(...) local unitId, castGUID, spellId = ... C_Timer.After(0.1, function() + --some spells has many different spellIds, get the default + spellId = LIB_OPEN_RAID_SPELL_DEFAULT_IDS[spellId] or spellId + --trigger internal callbacks openRaidLib.internalCallback.TriggerEvent("playerCast", spellId, UnitIsUnit(unitId, "pet")) end) end, @@ -1564,15 +1578,8 @@ end end function openRaidLib.CooldownManager.OnPlayerPetChanged() - - --local spellsAdded, spellsRemoved = openRaidLib.CooldownManager.CheckForSpellsAdeedOrRemoved() - - - --and send a comm telling this player has a new spell instead of sending all the list of spells --- local dataToSend = CONST_COMM_COOLDOWNFULLLIST_PREFIX .. "," - -- openRaidLib.commHandler.SendCommData(dataToSend) - - --openRaidLib.Schedules.NewUniqueTimer(0.5, openRaidLib.CooldownManager.SendAllPlayerCooldowns, "CooldownManager", "sendAllPlayerCooldowns_Schedule") + --disabled atm + --openRaidLib.CooldownManager.CheckCooldownChanges() end openRaidLib.internalCallback.RegisterCallback("onLeaveGroup", openRaidLib.CooldownManager.OnPlayerLeaveGroup) @@ -1584,6 +1591,144 @@ end openRaidLib.internalCallback.RegisterCallback("mythicDungeonStart", openRaidLib.CooldownManager.OnMythicPlusStart) openRaidLib.internalCallback.RegisterCallback("playerPetChange", openRaidLib.CooldownManager.OnPlayerPetChanged) +--send a list through comm with cooldowns added or removed +function openRaidLib.CooldownManager.CheckCooldownChanges() + --important: CheckForSpellsAdeedOrRemoved() already change the cooldowns on the player locally + local spellsAdded, spellsRemoved = openRaidLib.CooldownManager.CheckForSpellsAdeedOrRemoved() + + --add a prefix to make things easier during unpack + if (#spellsAdded > 0) then + tinsert(spellsAdded, 1, "A") + end + + --insert the spells that has been removed at the end of the spells added table and pack the table + if (#spellsRemoved > 0) then + spellsAdded[#spellsAdded+1] = "R" + for _, spellId in ipairs(spellsRemoved) do + spellsAdded[#spellsAdded+1] = spellId + end + end + + --send a comm if has any changes + if (#spellsAdded > 0) then + --pack + local playerCooldownChangesString = openRaidLib.PackTable(spellsAdded) + local dataToSend = CONST_COMM_COOLDOWNCHANGES_PREFIX .. "," + dataToSend = dataToSend .. playerCooldownChangesString + + openRaidLib.commHandler.SendCommData(dataToSend) + diagnosticComm("CheckCooldownChanges| " .. dataToSend) --debug + end +end + +function openRaidLib.CooldownManager.OnReceiveUnitCooldownChanges(data, unitName) + local currentCooldowns = openRaidLib.CooldownManager.UnitData[unitName] + --if does not have the full list of cooldowns of this unit, ignore cooldown add/remove comms + if (not currentCooldowns or not openRaidLib.CooldownManager.HasFullCooldownList[unitName]) then + return + end + + --create a table to be ready to unpack + local addedCooldowns = {} + local removedCooldowns = {} + local isCooldownAdded = false + local isCooldownRemoved = false + + --the letters A and R separate cooldowns added and cooldowns removed + for i = 1, #data do + local thisData = data[i] + + if (thisData == "A") then + isCooldownAdded = true + elseif (thisData == "R") then + isCooldownAdded = false + isCooldownRemoved = true + end + + if (isCooldownAdded) then + thisData = tonumber(thisData) + if (thisData) then + addedCooldowns[#addedCooldowns+1] = thisData + end + elseif(isCooldownRemoved) then + local spellId = tonumber(thisData) + if (spellId) then + removedCooldowns[#removedCooldowns+1] = spellId + end + end + end + + if (#addedCooldowns > 0) then + tinsert(addedCooldowns, 1, #addedCooldowns) --amount of indexes for UnpackTable() + local cooldownsAddedUnpacked = openRaidLib.UnpackTable(addedCooldowns, 1, true, true, 5) + for spellId, cooldownInfo in pairs(cooldownsAddedUnpacked) do + --add the spell into the list of cooldowns of this unit + local timeLeft, charges, timeOffset, duration = unpack(cooldownInfo) + openRaidLib.CooldownManager.CooldownSpellUpdate(unitName, spellId, timeLeft, charges, timeOffset, duration) + --mark the filter cache of this unit as dirt + openRaidLib.CooldownManager.NeedRebuildFilters[unitName] = true + --trigger public callback + openRaidLib.publicCallback.TriggerCallback("CooldownAdded", openRaidLib.GetUnitID(unitName), spellId, cooldownInfo, openRaidLib.GetUnitCooldowns(unitName), openRaidLib.CooldownManager.UnitData) + end + end + + if (#removedCooldowns > 0) then + for _, spellId in ipairs(removedCooldowns) do + --remove the spell from this unit cooldown list + currentCooldowns[spellId] = nil + --mark the filter cache of this unit as dirt + openRaidLib.CooldownManager.NeedRebuildFilters[unitName] = true + --trigger public callback + openRaidLib.publicCallback.TriggerCallback("CooldownRemoved", openRaidLib.GetUnitID(unitName), spellId, openRaidLib.GetUnitCooldowns(unitName), openRaidLib.CooldownManager.UnitData) + end + end + +end +openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNCHANGES_PREFIX, openRaidLib.CooldownManager.OnReceiveUnitCooldownChanges) + +--compare the current list of spells of the player with a new spell list generated +--add or remove spells from the player cooldown list +--return two tables, the first has added spells and is a index table ready to pack and send to comm +--the second table is a index table with a list of spells that has been removed, also ready to pack +function openRaidLib.CooldownManager.CheckForSpellsAdeedOrRemoved() + local playerName = UnitName("player") + local currentCooldowns = openRaidLib.CooldownManager.UnitData[playerName] + local _, newCooldownList = openRaidLib.CooldownManager.GetPlayerCooldownList() + local spellsAdded, spellsRemoved = {}, {} + + for spellId, cooldownInfo in pairs(newCooldownList) do + if (not currentCooldowns[spellId]) then + --a spell has been added + local timeLeft, charges, timeOffset, duration = unpack(cooldownInfo) + openRaidLib.CooldownManager.CooldownSpellUpdate(playerName, spellId, timeLeft, charges, timeOffset, duration) + + local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId) + spellsAdded[#spellsAdded+1] = spellId + spellsAdded[#spellsAdded+1] = timeLeft + spellsAdded[#spellsAdded+1] = charges + spellsAdded[#spellsAdded+1] = startTimeOffset + spellsAdded[#spellsAdded+1] = duration + + --mark the filter cache of this unit as dirt + openRaidLib.CooldownManager.NeedRebuildFilters[playerName] = true + openRaidLib.publicCallback.TriggerCallback("CooldownAdded", "player", spellId, cooldownInfo, openRaidLib.GetUnitCooldowns("player"), openRaidLib.CooldownManager.UnitData) + end + end + + for spellId in pairs(currentCooldowns) do + if (not newCooldownList[spellId]) then + --a spell has been removed + currentCooldowns[spellId] = nil + spellsRemoved[#spellsRemoved+1] = spellId + --mark the filter cache of this unit as dirt + openRaidLib.CooldownManager.NeedRebuildFilters[playerName] = true + openRaidLib.publicCallback.TriggerCallback("CooldownRemoved", "player", spellId, openRaidLib.GetUnitCooldowns("player"), openRaidLib.CooldownManager.UnitData) + end + end + + return spellsAdded, spellsRemoved +end + --update the list of cooldowns of the player it self locally --this is called right after changes in the player cooldowns function openRaidLib.CooldownManager.UpdatePlayerCooldownsLocally(playerCooldownHash) diff --git a/Libs/LibOpenRaid/ThingsToMantain.lua b/Libs/LibOpenRaid/ThingsToMantain.lua index e27168680..0a20ec8bb 100644 --- a/Libs/LibOpenRaid/ThingsToMantain.lua +++ b/Libs/LibOpenRaid/ThingsToMantain.lua @@ -333,7 +333,7 @@ LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = { --affliction [265] = { [205180] = 1, --Summon Darkglare - [342601] = 1, --Ritual of Doom + --[342601] = 1, --Ritual of Doom [113860] = 1, --Dark Soul: Misery (talent) [104773] = 2, --Unending Resolve [108416] = 2, --Dark Pact (talent) @@ -344,7 +344,7 @@ LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = { --demonology [266] = { [265187] = 1, --Summon Demonic Tyrant - [342601] = 1, --Ritual of Doom + --[342601] = 1, --Ritual of Doom [267171] = 1, --Demonic Strength (talent) [111898] = 1, --Grimoire: Felguard (talent) [267217] = 1, --Nether Portal (talent) @@ -359,7 +359,7 @@ LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = { --destruction [267] = { [1122] = 1, --Summon Infernal - [342601] = 1, --Ritual of Doom + --[342601] = 1, --Ritual of Doom [113858] = 1, --Dark Soul: Instability (talent) [104773] = 2, --Unending Resolve [108416] = 2, --Dark Pact (talent) @@ -544,7 +544,7 @@ LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = { [22812] = 2, --Barkskin [61336] = 2, --Survival Instincts [108238] = 2, --Renewal (talent) - [77764] = 4, --Stampeding Roar + [77761] = 4, --Stampeding Roar [132469] = 5, --Typhoon [319454] = 5, --Heart of the Wild (talent) [106839] = 6, --Skull Bash (interrupt) @@ -758,7 +758,7 @@ LIB_OPEN_RAID_COOLDOWNS_INFO = { --warlock [205180] = {cooldown = 180, duration = 20, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Summon Darkglare - [342601] = {cooldown = 3600, duration = false, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Ritual of Doom + --[342601] = {cooldown = 3600, duration = false, talent = false, charges = 1, class = "WARLOCK", type = 1}, --Ritual of Doom [113860] = {cooldown = 120, duration = 20, talent = 19293, charges = 1, class = "WARLOCK", type = 1}, --Dark Soul: Misery (talent) [104773] = {cooldown = 180, duration = 8, talent = false, charges = 1, class = "WARLOCK", type = 2}, --Unending Resolve [108416] = {cooldown = 60, duration = 20, talent = 19286, charges = 1, class = "WARLOCK", type = 2}, --Dark Pact (talent) @@ -836,7 +836,6 @@ LIB_OPEN_RAID_COOLDOWNS_INFO = { [106951] = {cooldown = 180, duration = 15, talent = false, charges = 1, class = "DRUID", type = 1}, --Berserk [102543] = {cooldown = 30, duration = 180, talent = 21704, charges = 1, class = "DRUID", type = 1}, --Incarnation: King of the Jungle (talent) [61336] = {cooldown = 120, duration = 6, talent = false, charges = 2, class = "DRUID", type = 2}, --Survival Instincts (2min feral 4min guardian, same spellid) - [77764] = {cooldown = 120, duration = 8, talent = false, charges = 1, class = "DRUID", type = 4}, --Stampeding Roar (utility) [102558] = {cooldown = 180, duration = 30, talent = 22388, charges = 1, class = "DRUID", type = 2}, --Incarnation: Guardian of Ursoc (talent) [33891] = {cooldown = 180, duration = 30, talent = 22421, charges = 1, class = "DRUID", type = 2}, --Incarnation: Tree of Life (talent) [102342] = {cooldown = 60, duration = 12, talent = false, charges = 1, class = "DRUID", type = 3}, --Ironbark @@ -1016,4 +1015,37 @@ LIB_OPEN_RAID_SPELL_INTERRUPT = { [19647] = LIB_OPEN_RAID_COOLDOWNS_INFO[19647], --Spell Lock (pet felhunter ability) [89766] = LIB_OPEN_RAID_COOLDOWNS_INFO[89766], --Axe Toss (pet felguard ability) -} \ No newline at end of file +} + +LIB_OPEN_RAID_SPELL_DEFAULT_IDS = { + --stampeding roar (druid) + [106898] = 77761, + [77764] = 77761, --"Uncategorized" on wowhead, need to test if still exists + --spell lock (warlock pet) + [119910] = 19647, --"Uncategorized" on wowhead + [132409] = 19647, --"Uncategorized" on wowhead + --[115781] = 19647, --optical blast used by old talent observer, still a thing? + --[251523] = 19647, --wowhead list this spell as sibling spell + --[251922] = 19647, --wowhead list this spell as sibling spell + --axe toss (warlock pet) + [119914] = 89766, --"Uncategorized" on wowhead + [347008] = 89766, --"Uncategorized" on wowhead + --hex (shaman) + [210873] = 51514, --Compy + [211004] = 51514, --Spider + [211010] = 51514, --Snake + [211015] = 51514, --Cockroach + [269352] = 51514, --Skeletal Hatchling + [277778] = 51514, --Zandalari Tendonripper + [277784] = 51514, --Wicker Mongrel + [309328] = 51514, --Living Honey + --typhoon + --[61391] = 132469, + --metamorphosis + [191427] = 200166, + --187827 vengeance need to test these spellIds + --191427 havoc + +} + +--need to add mass dispell (32375) \ No newline at end of file diff --git a/Libs/LibOpenRaid/docs.txt b/Libs/LibOpenRaid/docs.txt index 781472d6c..aafec370a 100644 --- a/Libs/LibOpenRaid/docs.txt +++ b/Libs/LibOpenRaid/docs.txt @@ -42,10 +42,11 @@ unitCooldows = { local cooldownInfo = openRaidLib.GetUnitCooldownInfo(unitId, spellId) --get cooldown timers to use with progress bar or cooldown frames, percent are normalized (0 to 1), timeLeft is seconds, minValue/maxValue/currentValue are in GetTime() time space, amount of charges +--minValue is the same as startTime, maxValue is the same as expirationTime, currentValue is GetTime() --by using unitID and spellID -local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId) +local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId) --by using a cooldown info -local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) +local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) EQUIPMENT: @@ -110,19 +111,35 @@ function MyAddonObject.OnReceiveCooldownListUpdate(unitId, unitCooldows, allUnit --using the 'unitCooldows' table passed for the updated unit for spellId, cooldownInfo in pairs(unitCooldows) do - local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime() + local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --statusbar frame local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent) statusbar:SetMinMaxValues(minValue, maxValue) statusbar:SetValue(currentValue) + --cooldown frame + local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent) + local startTime = minValue + CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0) + --or + cooldownFrame:SetCooldown(startTime, cooldownDuration) end --this event also passes a table with all player cooldowns for unitName, unitCooldows in pairs(allUnitsCooldowns) do for spellId, cooldownInfo in pairs(unitCooldows) do - local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime() + local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --statusbar frame local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent) statusbar:SetMinMaxValues(0, 1) statusbar:SetValue(normalizedPercent) + --cooldown frame + local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent) + local startTime = minValue + CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0) + --or + cooldownFrame:SetCooldown(startTime, cooldownDuration) end end end @@ -132,7 +149,7 @@ openRaidLib.RegisterCallback(MyAddonObject, "CooldownListUpdate", "OnReceiveCool =================================================================================================================================== "CooldownUpdate": triggered when an unit in the group uses a cooldown or the timeleft of a cooldown of an unit got an update -@unitId: which unit got updated +@unitId: which unit got the update @spellId: id of the cooldown spell @cooldownInfo: a table containing information about the cooldown time @unitCooldows: list of cooldowns of the unit @@ -140,15 +157,64 @@ openRaidLib.RegisterCallback(MyAddonObject, "CooldownListUpdate", "OnReceiveCool =================================================================================================================================== function MyAddonObject.OnReceiveCooldownUpdate(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns) - local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime() + local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + --statusbar frame local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent) statusbar:SetMinMaxValues(minValue, maxValue) statusbar:SetValue(currentValue) + --cooldown frame + local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent) + local startTime = minValue + CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0) + --or + cooldownFrame:SetCooldown(startTime, cooldownDuration) end --registering the callback: openRaidLib.RegisterCallback(MyAddonObject, "CooldownUpdate", "OnReceiveCooldownUpdate") +=================================================================================================================================== +"CooldownAdded": triggered when an unit get a new cooldown +@unitId: which unit got the update +@spellId: id of the cooldown spell +@cooldownInfo: a table containing information about the cooldown time +@unitCooldows: list of cooldowns of the unit +@allUnitsCooldowns: a list of all players and their cooldowns +=================================================================================================================================== + +function MyAddonObject.OnUnitNewCooldown(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns) + --minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime() + local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo) + local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent) + statusbar:SetMinMaxValues(minValue, maxValue) + statusbar:SetValue(currentValue) + --cooldown frame + local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent) + local startTime = minValue + CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0) + --or + cooldownFrame:SetCooldown(startTime, cooldownDuration) +end + +--registering the callback: +openRaidLib.RegisterCallback(MyAddonObject, "CooldownAdded", "OnUnitNewCooldown") + +=================================================================================================================================== +"CooldownRemoved": triggered when an unit lost a cooldown spell +@unitId: which unit got the update +@spellId: id of the cooldown spell +@unitCooldows: list of cooldowns of the unit +@allUnitsCooldowns: a list of all players and their cooldowns +=================================================================================================================================== + +function MyAddonObject.OnUnitLostCooldown(unitId, spellId, unitCooldows, allUnitsCooldowns) + --the unit lost a cooldown +end + +--registering the callback: +openRaidLib.RegisterCallback(MyAddonObject, "CooldownRemoved", "OnUnitLostCooldown") + =================================================================================================================================== "CooldownListWipe": when the list of cooldowns get a wipe, usually when the player leave the group =================================================================================================================================== diff --git a/boot.lua b/boot.lua index c9e4f09f4..d1ce68255 100644 --- a/boot.lua +++ b/boot.lua @@ -6,8 +6,8 @@ local version, build, date, tocversion = GetBuildInfo() - _detalhes.build_counter = 9779 - _detalhes.alpha_build_counter = 9779 --if this is higher than the regular counter, use it instead + _detalhes.build_counter = 9780 + _detalhes.alpha_build_counter = 9780 --if this is higher than the regular counter, use it instead _detalhes.bcc_counter = 33 _detalhes.dont_open_news = true _detalhes.game_version = version diff --git a/core/parser.lua b/core/parser.lua index 56c5cb793..a649c4566 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -3716,6 +3716,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 elseif (not alvo_name) then return end + + --development honey pot for interrupt spells + if (TrackerCleuDB and TrackerCleuDB.honey_pot) then + TrackerCleuDB.honey_pot[spellid] = true + end _current_misc_container.need_refresh = true diff --git a/frames/window_cdtracker.lua b/frames/window_cdtracker.lua index f757901f7..6e6021254 100644 --- a/frames/window_cdtracker.lua +++ b/frames/window_cdtracker.lua @@ -20,6 +20,8 @@ function Details.CooldownTracking.EnableTracker() openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "OnReceiveUnitFullCooldownList") openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownUpdate", "OnReceiveSingleCooldownUpdate") openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListWipe", "OnCooldownListWipe") + openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownAdded", "OnCooldownAdded") + openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownRemoved", "OnCooldownRemoved") Details.CooldownTracking.RefreshCooldownFrames() end @@ -86,6 +88,17 @@ end Details.CooldownTracking.RefreshCooldownFrames() end + --when a cooldown has been added to an unit + function Details.CooldownTracking.OnCooldownAdded(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns) + --here could update the cooldown of the unit, but I'm too lazy so it update all units + Details.CooldownTracking.RefreshCooldownFrames() + end + + --when a cooldown has been removed from an unit + function Details.CooldownTracking.OnCooldownRemoved(unitId, spellId, unitCooldows, allUnitsCooldowns) + Details.CooldownTracking.RefreshCooldownFrames() + end + --> Frames --hide all bars created