Updates, please see /details news

This commit is contained in:
Tercio Jose
2022-04-22 13:30:41 -03:00
parent 7762e29d00
commit 694b52ddc4
27 changed files with 2703 additions and 1676 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 300
local dversion = 306
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
+27 -1
View File
@@ -5392,7 +5392,7 @@ DF.IconRowFunctions = {
iconFrame.spellName = spellName
--add the spell into the cache
self.AuraCache [spellId] = true
self.AuraCache [spellId or -1] = true
self.AuraCache [spellName] = true
--> show the frame
@@ -5458,6 +5458,32 @@ DF.IconRowFunctions = {
else
self.NextIcon = countStillShown + 1
table.sort (iconPool, function(i1, i2) return i1:IsShown() and not i2:IsShown() end)
-- re-anchor not hidden
for i = 1, countStillShown do
local iconFrame = iconPool[i]
local anchor = self.options.anchor
local anchorTo = i == 1 and self or self.IconPool [i - 1]
local xPadding = i == 1 and self.options.left_padding or self.options.icon_padding or 1
local growDirection = self.options.grow_direction
iconFrame:ClearAllPoints()
if (growDirection == 1) then --grow to right
if (i == 1) then
PixelUtil.SetPoint (iconFrame, "left", anchorTo, "left", xPadding, 0)
else
PixelUtil.SetPoint (iconFrame, "left", anchorTo, "right", xPadding, 0)
end
elseif (growDirection == 2) then --grow to left
if (i == 1) then
PixelUtil.SetPoint (iconFrame, "right", anchorTo, "right", xPadding, 0)
else
PixelUtil.SetPoint (iconFrame, "right", anchorTo, "left", xPadding, 0)
end
end
end
end
end,
+1
View File
@@ -623,6 +623,7 @@ if (IS_WOW_PROJECT_NOT_MAINLINE) then
DF.CooldownsBySpec[258][19242] = 5 --desperate prayer Rank 6
DF.CooldownsBySpec[258][19243] = 5 --desperate prayer Rank 7
DF.CooldownsBySpec[258][25437] = 5 --desperate prayer Rank 8
DF.CooldownsBySpec[258][15286] = 5 --vampiric embrace is a debuff in classic, not a buff
--ROGUE - 259
DF.CooldownsBySpec[259][1857] = 2 --vanish Rank 2
+68 -30
View File
@@ -51,7 +51,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
if (not value) then
return _table.statusbar:GetValue()
else
_table.div:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
_table.spark:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
return _table.statusbar:SetValue (value)
end
end
@@ -60,12 +60,12 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
if (_type (v1) == "table") then
local v = v1.statusbar:GetValue()
v = v + v2
v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
v1.spark:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
v1.statusbar:SetValue (v)
else
local v = v2.statusbar:GetValue()
v = v + v1
v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
v2.spark:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
v2.statusbar:SetValue (v)
end
end
@@ -74,12 +74,12 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
if (_type (v1) == "table") then
local v = v1.statusbar:GetValue()
v = v - v2
v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
v1.spark:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
v1.statusbar:SetValue (v)
else
local v = v2.statusbar:GetValue()
v = v - v1
v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
v2.spark:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
v2.statusbar:SetValue (v)
end
end
@@ -117,7 +117,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
end
--> right color
local gmember_rcolor = function (_object)
return _object.background.original_colors
return _object.rightTexture.original_colors
end
--> left color
local gmember_lcolor = function (_object)
@@ -218,7 +218,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
--> statusbar value
local smember_value = function (_object, _value)
_object.statusbar:SetValue (_value)
return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
return _object.spark:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
end
--> right text
local smember_rtext = function (_object, _value)
@@ -231,8 +231,8 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
--> right color
local smember_rcolor = function (_object, _value)
local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
_object.background.original_colors = {_value1, _value2, _value3, _value4}
return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
_object.rightTexture.original_colors = {_value1, _value2, _value3, _value4}
return _object.rightTexture:SetVertexColor (_value1, _value2, _value3, _value4)
end
--> left color
local smember_lcolor = function (_object, _value)
@@ -273,14 +273,14 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
if (type (_value) == "table") then
local _value1, _value2 = _unpack (_value)
_object.texture:SetTexture (_value1)
_object.background:SetTexture (_value1)
_object.rightTexture:SetTexture (_value1)
if (_value2) then
_object.texture:SetTexCoord (_unpack (_value2))
_object.background:SetTexCoord (_unpack (_value2))
_object.rightTexture:SetTexCoord (_unpack (_value2))
end
else
_object.texture:SetTexture (_value)
_object.background:SetTexture (_value)
_object.rightTexture:SetTexture (_value)
end
return
end
@@ -349,7 +349,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
return
end
self.statusbar:SetValue (value)
self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
self.spark:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
end
-- setpoint
@@ -374,9 +374,13 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
-- texture
function SplitBarMetaFunctions:SetTexture (texture)
self.background:SetTexture (texture)
self.rightTexture:SetTexture (texture)
self.texture:SetTexture (texture)
end
function SplitBarMetaFunctions:SetBackgroundTexture(texture)
self.background:SetTexture(texture)
end
-- texts
function SplitBarMetaFunctions:SetLeftText (text)
@@ -393,10 +397,24 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
self.texture.original_colors = {r, g, b, a}
end
function SplitBarMetaFunctions:SetRightColor (r, g, b, a)
r, g, b, a = DF:ParseColors (r, g, b, a)
self.rightTexture:SetVertexColor (r, g, b, a)
self.rightTexture.original_colors = {r, g, b, a}
end
function SplitBarMetaFunctions:SetBackgroundColor (r, g, b, a)
r, g, b, a = DF:ParseColors (r, g, b, a)
self.background:SetVertexColor (r, g, b, a)
self.background.original_colors = {r, g, b, a}
end
function SplitBarMetaFunctions:GetLeftColor()
return self.texture:GetVertexColor()
end
function SplitBarMetaFunctions:GetRightColor()
return self.rightTexture:GetVertexColor()
end
-- icons
function SplitBarMetaFunctions:SetLeftIcon (texture, ...)
@@ -460,17 +478,21 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
local valueChange = self.step * (deltaTime * animationMultiplier)
self.currentValue = self.currentValue - valueChange
local barWidth = self:GetWidth()
self.statusbar:SetValue(self.currentValue)
self.rightTexture:SetWidth(barWidth - barWidth*self.currentValue)
if (self.currentValue - 0.001 <= self.targetValue) then
self:SetValue(self.targetValue)
self.currentValue = self.targetValue
self.spark:Hide()
if (not self.SparkAlwaysShow) then
self.spark:Hide()
end
self.widget:SetScript("OnUpdate", nil)
return
end
self.spark:SetPoint("center", self.widget, "left", self.currentValue * self:GetWidth(), 0)
self.spark:SetPoint("center", self.widget, "left", self.currentValue * barWidth, 0)
self.spark:Show()
end
@@ -485,17 +507,22 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
local valueChange = self.step * (deltaTime * animationMultiplier)
self.currentValue = self.currentValue + valueChange
local barWidth = self:GetWidth()
self.statusbar:SetValue(self.currentValue)
local rightTextureSize = barWidth - barWidth*self.currentValue
self.rightTexture:SetWidth(rightTextureSize)
if (self.currentValue + 0.001 >= self.targetValue) then
self:SetValue(self.targetValue)
self.currentValue = self.targetValue
self.spark:Hide()
if (not self.SparkAlwaysShow) then
self.spark:Hide()
end
self.widget:SetScript("OnUpdate", nil)
return
end
self.spark:SetPoint("center", self.widget, "left", self.currentValue * self:GetWidth(), 0)
self.spark:SetPoint("center", self.widget, "left", self.currentValue * barWidth, 0)
self.spark:Show()
end
@@ -523,12 +550,13 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
self.widget:SetScript("OnUpdate", onUpdate)
self.widget:SetMinMaxValues(0, 1)
self.spark:ClearAllPoints()
self.spark:SetHeight(self:GetHeight() * 1.7)
self.spark:SetAlpha(0.6)
self.spark:SetHeight(self:GetHeight() * 2.6)
self.spark:SetAlpha(0.4)
end
self.startValue = self.currentValue
self.step = abs(value - self.currentValue)
self.targetValue = value
self.rightTexture:Show()
end
------------------------------------------------------------------------------------------------------------
@@ -540,8 +568,6 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
if (kill) then
return
end
frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 18, 0)
if (frame.MyObject.have_tooltip) then
GameCooltip2:Reset()
@@ -607,7 +633,8 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
end
local OnSizeChanged = function (statusbar)
statusbar.MyObject.div:SetPoint ("left", statusbar, "left", statusbar:GetValue() * (statusbar:GetWidth()/100) - 18, 0)
statusbar.MyObject.spark:SetPoint ("left", statusbar, "left", statusbar:GetValue() * (statusbar:GetWidth()/100) - 18, 0)
statusbar.MyObject.rightTexture:SetWidth(statusbar:GetWidth() - statusbar.MyObject.texture:GetWidth())
end
------------------------------------------------------------------------------------------------------------
@@ -615,7 +642,7 @@ local SplitBarMetaFunctions = _G[DF.GlobalWidgetControlNames ["split_bar"]]
function DetailsFrameworkSplitlBar_OnCreate (self)
self.texture.original_colors = {1, 1, 1, 1}
self.background.original_colors = {.5, .5, .5, 1}
self.rightTexture.original_colors = {.5, .5, .5, 1}
self.spark:SetPoint ("left", self, "left", self:GetValue() * (self:GetWidth()/100) - 18, 0)
return true
end
@@ -629,14 +656,27 @@ local build_statusbar = function (self)
self:SetSize (300, 14)
self.background = self:CreateTexture ("$parent_StatusBarBackground", "BACKGROUND")
self.background:SetAllPoints()
self.background:SetPoint("topright", self, "topright")
self.background:SetPoint("bottomright", self, "bottomright")
self.background:SetPoint("topleft", self, "topleft")
self.background:SetPoint("bottomleft", self, "bottomleft")
self.background:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
self.background:SetVertexColor (.5, .5, .5, 1)
self.background:SetVertexColor (.3, .3, .3, 1)
self.texture = self:CreateTexture ("$parent_StatusBarTexture", "ARTWORK")
--this is the left texture and it grows to the right, it is embed within the bar by SetStatusBarTexture
self.texture = self:CreateTexture ("$parent_StatusBarTexture", "ARTWORK", nil, 1)
self.texture:Hide()
self.texture:SetSize (300, 14)
self.texture:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
--this is the right texture and its size is the bar:GetWidth() - self.texture:GetWidth()
self.rightTexture = self:CreateTexture ("$parent_StatusBarTextureRight", "ARTWORK", nil, 2)
self.rightTexture:Hide()
self.rightTexture:SetSize (300, 14)
self.rightTexture:SetTexture ([[Interface\PaperDollInfoFrame\UI-Character-Skills-Bar]])
self.rightTexture:SetPoint("topright", self, "topright")
self.rightTexture:SetPoint("bottomright", self, "bottomright")
self.rightTexture:SetVertexColor(1, 0, 0)
self.lefticon = self:CreateTexture ("$parent_IconLeft", "OVERLAY")
self.lefticon:SetSize (14, 14)
@@ -739,9 +779,7 @@ function DF:NewSplitBar (parent, container, name, member, w, h)
SplitBarObject.background = _G [name .. "_StatusBarBackground"]
SplitBarObject.texture = _G [name .. "_StatusBarTexture"]
SplitBarObject.div = _G [name .. "_Spark"]
SplitBarObject.rightTexture = _G [name .. "_StatusBarTextureRight"]
--> hooks
SplitBarObject.HookList = {
+1 -1
View File
@@ -299,6 +299,7 @@ local OnUpdateFunc = function(self, deltaTime)
end
function TimeBarMetaFunctions:SetTimer(currentTime, startTime, endTime)
self.statusBar:Show()
if (not currentTime or currentTime == 0) then
self:StopTimer()
@@ -352,7 +353,6 @@ function TimeBarMetaFunctions:SetTimer(currentTime, startTime, endTime)
self.statusBar.hasTimer = true
self.statusBar.direction = self.direction
self.statusBar.throttle = 0
self.statusBar:Show()
self.statusBar:SetScript("OnUpdate", OnUpdateFunc)
+69
View File
@@ -0,0 +1,69 @@
if (not LIB_OPEN_RAID_CAN_LOAD) then
return
end
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
--> deprecated: 'RequestAllPlayersInfo' has been replaced by 'RequestAllData'
function openRaidLib.RequestAllPlayersInfo()
openRaidLib.DeprecatedMessage("openRaidLib.RequestAllPlayersInfo() is deprecated, please use openRaidLib.RequestAllData().")
end
--> deprecated: 'playerInfoManager' has been replaced by 'UnitInfoManager'
openRaidLib.playerInfoManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager table is deprecated, please use openRaidLib.UnitInfoManager.")
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager table is deprecated, please use openRaidLib.UnitInfoManager.")
end,
}
function openRaidLib.playerInfoManager.GetPlayerInfo()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager.GetPlayerInfo(unitName) is deprecated, please use openRaidLib.GetUnitInfo(unitId).")
end
function openRaidLib.playerInfoManager.GetAllPlayersInfo()
openRaidLib.DeprecatedMessage("openRaidLib.playerInfoManager.GetAllPlayersInfo() is deprecated, please use openRaidLib.GetAllUnitsInfo().")
end
setmetatable(openRaidLib.playerInfoManager, deprecatedMetatable)
--> deprecated: 'gearManager' has been replaced by 'GearManager'
openRaidLib.gearManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager table is deprecated, please use openRaidLib.GearManager (the G is in upper case).")
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.gearManager table is deprecated, please use openRaidLib.GearManager (the G is in upper case).")
end,
}
function openRaidLib.gearManager.GetAllPlayersGear()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager.GetAllPlayersGear() is deprecated, please use openRaidLib.GetAllUnitsGear().")
end
function openRaidLib.gearManager.GetPlayerGear()
openRaidLib.DeprecatedMessage("openRaidLib.gearManager.GetPlayerGear() is deprecated, please use openRaidLib.GetUnitGear(unitId).")
end
setmetatable(openRaidLib.gearManager, deprecatedMetatable)
--> deprecated: 'cooldownManager' has been replaced by 'CooldownManager'
openRaidLib.cooldownManager = {}
local deprecatedMetatable = {
__newindex = function()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager table is deprecated, please use openRaidLib.CooldownManager (the C is in upper case).")
return
end,
__index = function(t, key)
return rawget(t, key) or openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager table is deprecated, please use openRaidLib.CooldownManager (the C is in upper case).")
end,
}
function openRaidLib.cooldownManager.GetAllPlayersCooldown()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager.GetAllPlayersCooldown() is deprecated, please use openRaidLib.GetAllUnitsCooldown().")
end
function openRaidLib.cooldownManager.GetPlayerCooldowns()
openRaidLib.DeprecatedMessage("openRaidLib.cooldownManager.GetPlayerCooldowns() is deprecated, please use openRaidLib.GetUnitCooldowns(unitId).")
end
setmetatable(openRaidLib.cooldownManager, deprecatedMetatable)
+217
View File
@@ -0,0 +1,217 @@
--[=[
Dumping logical functions here, make the code of the main file smaller
--]=]
if (not LIB_OPEN_RAID_CAN_LOAD) then
return
end
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
local CONST_FRACTION_OF_A_SECOND = 0.01
local CONST_COOLDOWN_TYPE_OFFENSIVE = 1
local CONST_COOLDOWN_TYPE_DEFENSIVE_PERSONAL = 2
local CONST_COOLDOWN_TYPE_DEFENSIVE_TARGET = 3
local CONST_COOLDOWN_TYPE_DEFENSIVE_RAID = 4
local CONST_COOLDOWN_TYPE_UTILITY = 5
--simple non recursive table copy
function openRaidLib.TCopy(tableToReceive, tableToCopy)
if (not tableToCopy) then
print(debugstack())
end
for key, value in pairs(tableToCopy) do
tableToReceive[key] = value
end
end
--find the normalized percent of the value in the range. e.g range of 200-400 and a value of 250 result in 0.25
--from details! framework
function openRaidLib.GetRangePercent(minValue, maxValue, value)
return (value - minValue) / max((maxValue - minValue), 0.0000001)
end
--transform a table index into a string dividing values with a comma
--@table: an indexed table with unknown size
function openRaidLib.PackTable(table)
local tableSize = #table
local newString = "" .. tableSize .. ","
for i = 1, tableSize do
newString = newString .. table[i] .. ","
end
newString = newString:gsub(",$", "")
return newString
end
--return is a number is almost equal to another within a tolerance range
function openRaidLib.isNearlyEqual(value1, value2, tolerance)
tolerance = tolerance or CONST_FRACTION_OF_A_SECOND
return abs(value1 - value2) <= tolerance
end
--return true if the lib is allowed to receive comms from other players
function openRaidLib.IsCommAllowed()
return IsInGroup() or IsInRaid()
end
--stract some indexes of a table
local selectIndexes = function(table, startIndex, amountIndexes)
local values = {}
for i = startIndex, startIndex+amountIndexes do
values[#values+1] = tonumber(table[i]) or 0
end
return values
end
--transform a string table into a regular table
--@table: a table with unknown values
--@index: where in the table is the information we want
--@isPair: if true treat the table as pairs(), ipairs() otherwise
--@valueAsTable: return {value1, value2, value3}
--@amountOfValues: for the parameter above
function openRaidLib.UnpackTable(table, index, isPair, valueIsTable, amountOfValues)
local result = {}
local reservedIndexes = table[index]
if (not reservedIndexes) then
return result
end
local indexStart = index+1
local indexEnd = reservedIndexes+index
if (isPair) then
amountOfValues = amountOfValues or 2
for i = indexStart, indexEnd, amountOfValues do
if (valueIsTable) then
local key = tonumber(table[i])
local values = selectIndexes(table, i+1, max(amountOfValues-2, 1))
result[key] = values
else
local key = tonumber(table[i])
local value = tonumber(table[i+1])
result[key] = value
end
end
else
for i = indexStart, indexEnd do
local value = tonumber(table[i])
result[#result+1] = value
end
end
return result
end
--returns if the player is in group
function openRaidLib.IsInGroup()
local inParty = IsInGroup()
local inRaid = IsInRaid()
return inParty or inRaid
end
function openRaidLib.UpdateUnitIDCache()
openRaidLib.UnitIDCache = {}
if (IsInRaid()) then
for i = 1, GetNumGroupMembers() do
local unitName = UnitName("raid"..i)
if (unitName) then
openRaidLib.UnitIDCache[unitName] = "raid"..i
end
end
elseif (IsInGroup()) then
for i = 1, GetNumGroupMembers() - 1 do
local unitName = UnitName("party"..i)
if (unitName) then
openRaidLib.UnitIDCache[unitName] = "party"..i
end
end
end
openRaidLib.UnitIDCache[UnitName("player")] = "player"
end
function openRaidLib.GetUnitID(playerName)
return openRaidLib.UnitIDCache[playerName] or playerName
end
local filterStringToCooldownType = {
["defensive-raid"] = CONST_COOLDOWN_TYPE_DEFENSIVE_RAID,
["defensive-target"] = CONST_COOLDOWN_TYPE_DEFENSIVE_TARGET,
["defensive-personal"] = CONST_COOLDOWN_TYPE_DEFENSIVE_PERSONAL,
["ofensive"] = CONST_COOLDOWN_TYPE_OFFENSIVE,
["utility"] = CONST_COOLDOWN_TYPE_UTILITY
}
function openRaidLib.CooldownManager.DoesSpellPassFilter(spellId, filters)
local allCooldownsData = LIB_OPEN_RAID_COOLDOWNS_INFO
local cooldownData = allCooldownsData[spellId]
if (cooldownData) then
for filter in filters:gmatch("([^,%s]+)") do
local cooldownType = filterStringToCooldownType[filter]
if (cooldownData.type == cooldownType) then
return true
end
end
else
return false
end
end
local getCooldownsForFilter = function(unitName, allCooldowns, unitDataFilteredCache, filter)
local allCooldownsData = LIB_OPEN_RAID_COOLDOWNS_INFO
local filterTable = unitDataFilteredCache[filter]
--if the unit already sent its full list of cooldowns, the cache can be built
--when NeedRebuildFilters is true, HasFullCooldownList is always true
--bug: filterTable is nil and HasFullCooldownList is also nil, happening after leaving a grou´p internal callback
if ((not filterTable and openRaidLib.CooldownManager.HasFullCooldownList[unitName]) or openRaidLib.CooldownManager.NeedRebuildFilters[unitName]) then
filterTable = {}
unitDataFilteredCache[filter] = filterTable
for spellId, cooldownInfo in pairs(allCooldowns) do
local cooldownData = allCooldownsData[spellId]
if (cooldownData and cooldownData.type == filterStringToCooldownType[filter]) then
filterTable[spellId] = cooldownInfo
end
end
end
return filterTable
end
--@allCooldowns: all cooldowns sent by an unit, {[spellId] = cooldownInfo}
--@filters: string with filters, "defensive-raid, "defensive-personal"
function openRaidLib.FilterCooldowns(unitName, allCooldowns, filters)
local allDataFiltered = openRaidLib.CooldownManager.UnitDataFilterCache --["unitName"] = {defensive-raid = {[spellId = cooldownInfo]}}
local unitDataFilteredCache = allDataFiltered[unitName]
if (not unitDataFilteredCache) then
unitDataFilteredCache = {}
allDataFiltered[unitName] = unitDataFilteredCache
end
--before break the string into parts and build the filters, attempt to get cooldowns from the cache using the whole filter string
local filterAlreadyInCache = unitDataFilteredCache[filters]
if (filterAlreadyInCache and not openRaidLib.CooldownManager.NeedRebuildFilters[unitName]) then
return filterAlreadyInCache
end
local allCooldownsData = LIB_OPEN_RAID_COOLDOWNS_INFO
local resultFilters = {}
--break the string into pieces and filter cooldowns
for filter in filters:gmatch("([^,%s]+)") do
local filterTable = getCooldownsForFilter(unitName, allCooldowns, unitDataFilteredCache, filter)
if (filterTable) then
openRaidLib.TCopy(resultFilters, filterTable) --filter table is nil
end
end
--cache the whole filter string
if (next(resultFilters)) then
unitDataFilteredCache[filters] = resultFilters
end
return resultFilters
end
+387
View File
@@ -0,0 +1,387 @@
--[=[
This file has the functions to get player information
Dumping them here, make the code of the main file smaller
--]=]
if (not LIB_OPEN_RAID_CAN_LOAD) then
return
end
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
local isTimewalkWoW = function()
local gameVersion = GetBuildInfo()
if (gameVersion:match("%d") == "1" or gameVersion:match("%d") == "2") then
return true
end
end
--creates two tables, one with indexed talents and another with pairs values ([talentId] = true)
function openRaidLib.UnitInfoManager.GetPlayerTalentsAsPairsTable()
local talentsPairs = {}
for i = 1, 7 do
for o = 1, 3 do
local talentId, _, _, selected = GetTalentInfo(i, o, 1)
if (selected) then
talentsPairs[talentId] = true
break
end
end
end
return talentsPairs
end
function openRaidLib.UnitInfoManager.GetPlayerTalents()
local talents = {0, 0, 0, 0, 0, 0, 0}
for talentTier = 1, 7 do
for talentColumn = 1, 3 do
local talentId, name, texture, selected, available = GetTalentInfo(talentTier, talentColumn, 1)
if (selected) then
talents[talentTier] = talentId
break
end
end
end
return talents
end
function openRaidLib.UnitInfoManager.GetPlayerPvPTalents()
local talentsPvP = {0, 0, 0}
local talentList = C_SpecializationInfo.GetAllSelectedPvpTalentIDs()
for talentIndex, talentId in ipairs(talentList) do
local doesExists = GetPvpTalentInfoByID(talentId)
if (doesExists) then
talentsPvP[talentIndex] = talentId
end
end
return talentsPvP
end
--return the current specId of the player
function openRaidLib.GetPlayerSpecId()
if (isTimewalkWoW()) then
return 0
end
local spec = GetSpecialization()
if (spec) then
local specId = GetSpecializationInfo(spec)
if (specId and specId > 0) then
return specId
end
end
end
function openRaidLib.UnitInfoManager.GetPlayerConduits()
local conduits = {}
local soulbindID = C_Soulbinds.GetActiveSoulbindID()
if (soulbindID ~= 0) then
local soulbindData = C_Soulbinds.GetSoulbindData(soulbindID)
if (soulbindData ~= 0) then
local tree = soulbindData.tree
local nodes = tree.nodes
table.sort(nodes, function(t1, t2) return t1.row < t2.row end)
local C_Soulbinds_GetConduitCollectionData = C_Soulbinds.GetConduitCollectionData
for nodeId, nodeInfo in ipairs(nodes) do
--check if the node is a conduit placed by the player
if (nodeInfo.state == Enum.SoulbindNodeState.Selected) then
local conduitId = nodeInfo.conduitID
local conduitRank = nodeInfo.conduitRank
if (conduitId and conduitRank) then
--have spell id when it's a default conduit from the game
local spellId = nodeInfo.spellID
--have conduit id when is a conduid placed by the player
local conduitId = nodeInfo.conduitID
if (spellId == 0) then
--is player conduit
spellId = C_Soulbinds.GetConduitSpellID(nodeInfo.conduitID, nodeInfo.conduitRank)
conduits[#conduits+1] = spellId
local collectionData = C_Soulbinds_GetConduitCollectionData(conduitId)
conduits[#conduits+1] = collectionData and collectionData.conduitItemLevel or 0
else
--is default conduit
conduits[#conduits+1] = spellId
conduits[#conduits+1] = 0
end
end
end
end
end
end
return conduits
end
function openRaidLib.GearManager.GetPlayerItemLevel()
if (_G.GetAverageItemLevel) then
local _, _itemLevel = GetAverageItemLevel()
itemLevel = floor(_itemLevel)
else
itemLevel = 0
end
return itemLevel
end
--return an integer between zero and one hundret indicating the player gear durability
function openRaidLib.GearManager.GetPlayerGearDurability()
local durabilityTotalPercent, totalItems = 0, 0
for i = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
local durability, maxDurability = GetInventoryItemDurability(i)
if (durability and maxDurability) then
local itemDurability = durability / maxDurability * 100
durabilityTotalPercent = durabilityTotalPercent + itemDurability
totalItems = totalItems + 1
end
end
if (totalItems == 0) then
return 100
end
return floor(durabilityTotalPercent / totalItems)
end
function openRaidLib.GearManager.GetPlayerWeaponEnchant()
local weaponEnchant = 0
local _, _, _, mainHandEnchantId, _, _, _, offHandEnchantId = GetWeaponEnchantInfo()
if (LIB_OPEN_RAID_WEAPON_ENCHANT_IDS[mainHandEnchantId]) then
weaponEnchant = 1
elseif(LIB_OPEN_RAID_WEAPON_ENCHANT_IDS[offHandEnchantId]) then
weaponEnchant = 1
end
return weaponEnchant
end
function openRaidLib.GearManager.GetPlayerGemsAndEnchantInfo()
--hold equipmentSlotId of equipment with a gem socket but it's empty
local slotsWithoutGems = {}
--hold equipmentSlotId of equipments without an enchant
local slotsWithoutEnchant = {}
for equipmentSlotId = 1, 17 do
local itemLink = GetInventoryItemLink("player", equipmentSlotId)
if (itemLink) then
--get the information from the item
local _, itemId, enchantId, gemId1, gemId2, gemId3, gemId4, suffixId, uniqueId, levelOfTheItem, specId, upgradeInfo, instanceDifficultyId, numBonusIds, restLink = strsplit(":", itemLink)
local gemsIds = {gemId1, gemId2, gemId3, gemId4}
--> enchant
--check if the slot can receive enchat and if the equipment has an enchant
local enchantAttribute = LIB_OPEN_RAID_ENCHANT_SLOTS[equipmentSlotId]
if (enchantAttribute) then --this slot can receive an enchat
--check if this slot is relevant for the class, some slots can have enchants only for Agility which won't matter for Priests as an example
--if the value is an integer it points to an attribute (int, dex, str), otherwise it's true (boolean)
local slotIsRelevant = true
if (type (enchantAttribute) == "number") then
if (specMainAttribute ~= enchantAttribute) then
slotIsRelevant = false
end
end
if (slotIsRelevant) then
--does the slot has any enchant?
if (not enchantId or enchantId == "0" or enchantId == "") then
slotsWithoutEnchant[#slotsWithoutEnchant+1] = equipmentSlotId
else
--convert to integer
local enchantIdInt = tonumber(enchantId)
if (enchantIdInt) then
--does the enchant is relevent for the character?
if (not LIB_OPEN_RAID_ENCHANT_IDS[enchantIdInt]) then
slotsWithoutEnchant[#slotsWithoutEnchant+1] = equipmentSlotId
end
else
--the enchat has an invalid id
slotsWithoutEnchant[#slotsWithoutEnchant+1] = equipmentSlotId
end
end
end
end
--> gems
local itemStatsTable = {}
--fill the table above with information about the item
GetItemStats(itemLink, itemStatsTable)
--check if the item has a socket
if (itemStatsTable.EMPTY_SOCKET_PRISMATIC) then
--check if the socket is empty
for i = 1, itemStatsTable.EMPTY_SOCKET_PRISMATIC do
local gemId = tonumber(gemsIds[i])
if (not gemId or gemId == 0) then
slotsWithoutGems[#slotsWithoutGems+1] = equipmentSlotId
--check if the gem is not a valid gem (deprecated gem)
elseif (not LIB_OPEN_RAID_GEM_IDS[gemId]) then
slotsWithoutGems[#slotsWithoutGems+1] = equipmentSlotId
end
end
end
end
end
return slotsWithoutGems, slotsWithoutEnchant
end
--build a list with the local player cooldowns
--called only from SendAllPlayerCooldowns()
function openRaidLib.CooldownManager.GetPlayerCooldownList()
--get the player specId
local specId = openRaidLib.GetPlayerSpecId()
if (specId) then
--get the cooldowns for the specialization
local playerCooldowns = LIB_OPEN_RAID_COOLDOWNS_BY_SPEC[specId]
if (not playerCooldowns) then
openRaidLib.DiagnosticError("CooldownManager|GetPlayerCooldownList|can't find player cooldowns for specId:", specId)
return {}, {}
end
local cooldowns = {} --table to ship on comm
local cooldownsHash = {} --table with [spellId] = cooldownInfo
local talentsHash = openRaidLib.UnitInfoManager.GetPlayerTalentsAsPairsTable()
local timeNow = GetTime()
for cooldownSpellId, cooldownType in pairs(playerCooldowns) do
--get all the information about this cooldow
local cooldownInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[cooldownSpellId]
if (cooldownInfo) then
--does this cooldown is based on a talent?
local talentId = cooldownInfo.talent
if (talentId) then
--check if the player has the talent selected
if (talentsHash[talentId]) then
cooldowns[#cooldowns+1] = cooldownSpellId
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(cooldownSpellId)
cooldowns[#cooldowns+1] = timeLeft
cooldowns[#cooldowns+1] = charges
cooldowns[#cooldowns+1] = startTimeOffset
cooldowns[#cooldowns+1] = duration
cooldownsHash[cooldownSpellId] = {timeLeft, charges, startTimeOffset, duration, timeNow}
end
else
cooldowns[#cooldowns+1] = cooldownSpellId
local timeLeft, charges, startTimeOffset, duration = openRaidLib.CooldownManager.GetPlayerCooldownStatus(cooldownSpellId)
cooldowns[#cooldowns+1] = timeLeft
cooldowns[#cooldowns+1] = charges
cooldowns[#cooldowns+1] = startTimeOffset
cooldowns[#cooldowns+1] = duration
cooldownsHash[cooldownSpellId] = {timeLeft, charges, startTimeOffset, duration, timeNow}
end
end
end
return cooldowns, cooldownsHash
else
return {}, {}
end
end
--check if a player cooldown is ready or if is in cooldown
--@spellId: the spellId to check for cooldown
function openRaidLib.CooldownManager.GetPlayerCooldownStatus(spellId)
--check if is a charge spell
local cooldownInfo = LIB_OPEN_RAID_COOLDOWNS_INFO[spellId]
if (cooldownInfo) then
if (cooldownInfo.charges and cooldownInfo.charges > 1) then
local chargesAvailable, chargesTotal, start, duration = GetSpellCharges(spellId)
if (chargesAvailable == chargesTotal) then
return 0, chargesTotal, 0, 0 --all charges are ready to use
else
--return the time to the next charge
local timeLeft = start + duration - GetTime()
local startTimeOffset = start - GetTime()
return ceil(timeLeft), chargesAvailable, startTimeOffset, duration --time left, charges, startTime
end
else
local start, duration = GetSpellCooldown(spellId)
if (start == 0) then --cooldown is ready
return 0, 1, 0, 0 --time left, charges, startTime
else
local timeLeft = start + duration - GetTime()
local startTimeOffset = start - GetTime()
return ceil(timeLeft), 0, ceil(startTimeOffset), duration --time left, charges, startTime, duration
end
end
else
return openRaidLib.DiagnosticError("CooldownManager|GetPlayerCooldownStatus()|cooldownInfo not found|", spellId)
end
end
--which is the main attribute of each spec
--1 Intellect
--2 Agility
--3 Strenth
openRaidLib.specAttribute = {
["DEMONHUNTER"] = {
[577] = 2,
[581] = 2,
},
["DEATHKNIGHT"] = {
[250] = 3,
[251] = 3,
[252] = 3,
},
["WARRIOR"] = {
[71] = 3,
[72] = 3,
[73] = 3,
},
["MAGE"] = {
[62] = 1,
[63] = 1,
[64] = 1,
},
["ROGUE"] = {
[259] = 2,
[260] = 2,
[261] = 2,
},
["DRUID"] = {
[102] = 1,
[103] = 2,
[104] = 2,
[105] = 1,
},
["HUNTER"] = {
[253] = 2,
[254] = 2,
[255] = 2,
},
["SHAMAN"] = {
[262] = 1,
[263] = 2,
[264] = 1,
},
["PRIEST"] = {
[256] = 1,
[257] = 1,
[258] = 1,
},
["WARLOCK"] = {
[265] = 1,
[266] = 1,
[267] =1 ,
},
["PALADIN"] = {
[65] = 1,
[66] = 3,
[70] = 3,
},
["MONK"] = {
[268] = 2,
[269] = 2,
[270] = 1,
}
}
File diff suppressed because it is too large Load Diff
+31 -2
View File
@@ -276,7 +276,7 @@ LIB_OPEN_RAID_COOLDOWNS_BY_SPEC = {
[10060] = 1, --Power Infusion
[34433] = 1, --Shadowfiend
[200174] = 1, --Mindbender
[193223] = 1, --Surrender to Madness
[193223] = 1, --Surrender to Madness (talent)
[47585] = 2, --Dispersion
[15286] = 4, --Vampiric Embrace
[19236] = 5, --Desperate Prayer
@@ -954,4 +954,33 @@ else
--> shadowlands trinkets
[345020] = {name = GetSpellInfo(345020) .. " (" .. L["STRING_TRINKET"] .. ")"},
}
end
end
LIB_OPEN_RAID_SPELL_INTERRUPT = {
[6552] = {class = "WARRIOR", specs = {71, 72, 73}, cooldown = 15, silence = 4, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Pummel
[2139] = {class = "MAGE", specs = {62, 63, 64}, cooldown = 24, silence = 6, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Counterspell
[15487] = {class = "PRIEST", specs = {258}, cooldown = 45, silence = 4, talent = false, cooldownWithTalent = 30, cooldownTalentId = 23137}, --Silence (shadow) Last Word Talent to reduce cooldown in 15 seconds
[1766] = {class = "ROGUE", specs = {259, 260, 261}, cooldown = 15, silence = 5, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Kick
[96231] = {class = "PALADIN", specs = {66, 70}, cooldown = 15, silence = 4, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Rebuke (protection and retribution)
[116705] = {class = "MONK", specs = {268, 269}, cooldown = 15, silence = 4, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Spear Hand Strike (brewmaster and windwalker)
[57994] = {class = "SHAMAN", specs = {262, 263, 264}, cooldown = 12, silence = 3, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Wind Shear
[47528] = {class = "DEATHKNIGHT", specs = {250, 251, 252}, cooldown = 15, silence = 3, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Mind Freeze
[106839] = {class = "DRUID", specs = {103, 104}, cooldown = 15, silence = 4, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Skull Bash (feral, guardian)
[78675] = {class = "DRUID", specs = {102}, cooldown = 60, silence = 8, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Solar Beam (balance)
[147362] = {class = "HUNTER", specs = {253, 254}, cooldown = 24, silence = 3, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Counter Shot (beast mastery, marksmanship)
[187707] = {class = "HUNTER", specs = {255}, cooldown = 15, silence = 3, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Muzzle (survival)
[183752] = {class = "DEMONHUNTER", specs = {577, 581}, cooldown = 15, silence = 3, talent = false, cooldownWithTalent = false, cooldownTalentId = false}, --Disrupt
[19647] = {class = "WARLOCK", specs = {265, 266, 267}, cooldown = 24, silence = 6, talent = false, cooldownWithTalent = false, cooldownTalentId = false, pet = 417}, --Spell Lock (pet felhunter ability)
[89766] = {class = "WARLOCK", specs = {266}, cooldown = 30, silence = 4, talent = false, cooldownWithTalent = false, cooldownTalentId = false, pet = 17252}, --Axe Toss (pet felguard ability)
}
+166 -114
View File
@@ -14,19 +14,49 @@ With this object, you can start querying the library for information.
Functions:
local sentRequest = openRaidLib.RequestAllPlayersInfo()
Request to all players to send all data infomation: cooldowns, gear and player data.
local sentRequest = openRaidLib.RequestAllData()
Request to all players in the group to send infomation on: cooldowns, gear and player data.
Instants after calling this, expect to receive several callbacks.
COOLDOWNS:
--get all cooldowns from all units
local allUnitsCooldowns = openRaidLib.GetAllUnitsCooldown()
allUnitsCooldowns = {
["playerName1"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
["playerName2"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
["playerName3"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
}
local allPlayersGear = openRaidLib.gearManager.GetAllPlayersGear()
--get all cooldowns from a single unit
local unitCooldows = openRaidLib.GetUnitCooldowns(unitId [,filter])
@unittId: "player", "target", "party2", "raid12", ...
@filter: "defensive-raid", "defensive-target", "defensive-personal", "ofensive", "utility"
can pass more than one filter separating by comma, example: "defensive-raid, defensive-target"
unitCooldows = {
[cooldownSpellId] = cooldownInfo,
[cooldownSpellId] = cooldownInfo,
[cooldownSpellId] = cooldownInfo,
}
--get a cooldownInfo of a single spell from any unit
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
--by using unitID and spellID
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId)
--by using a cooldown info
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
EQUIPMENT:
local allPlayersGear = openRaidLib.GetAllUnitsGear()
allPlayersGear = {
["playerName1"] = playerGear,
["playerName2"] = playerGear,
["playerName3"] = playerGear,
}
local playerGear = openRaidLib.gearManager.GetPlayerGear(playerName)
local playerGear = openRaidLib.GetUnitGear(unitId)
playerGear = {
.durability = number
.ilevel = number
@@ -36,75 +66,58 @@ playerGear = {
}
local allPlayersCooldowns = openRaidLib.cooldownManager.GetAllPlayersCooldown()
allPlayersCooldowns = {
["playerName1"] = playerCooldows,
["playerName2"] = playerCooldows,
["playerName3"] = playerCooldows,
UNIT INFORMATION
local allUnitsInfo = openRaidLib.GetAllUnitsInfo()
allUnitsInfo = {
["unitName1"] = unitInfo,
["unitName2"] = unitInfo,
["unitName3"] = unitInfo,
}
local playerCooldows = openRaidLib.cooldownManager.GetPlayerCooldowns(playerName)
playerCooldows = {
[cooldownSpellId] = {
[1] = time left (number),
[2] = charges (number),
[3] = start time offset (number) - time offset from when the cooldown was used,
[4] = duration (number),
[5] = GetTime() of when the information was received
}
}
local allPlayersInfo = openRaidLib.playerInfoManager.GetAllPlayersInfo()
allPlayersInfo = {
["playerName1"] = playerInfo,
["playerName2"] = playerInfo,
["playerName3"] = playerInfo,
}
local playerInfo = openRaidLib.playerInfoManager.GetPlayerInfo(playerName)
playerInfo = {
local unitInfo = openRaidLib.GetUnitInfo(unitId)
unitInfo = {
.specId = number
.renown = number,
.covenantId = number,
.talents = {talentId},
.conduits = {spellId},
.specName = string
.role = string
.renown = number
.covenantId = number
.talents = {talentId, talentId, talentId, ...}
.pvpTalents = {talentId, talentId, talentId}
.conduits = {spellId, conduitLevel, spellId, conduitLevel, spellId, conduitLevel, ...}
.class = string class eng name 'ROGUE'
.classId = number
.className = string class localized name
.name = string name without realm
.nameFull = string name with realm 'unitName-ServerName'
}
Callbacks:
===================================================================================================================================
"CooldownListUpdate": triggers when the lib received a list of cooldowns from another player in the group.
"CooldownListUpdate": triggers when the lib received a list of cooldowns from another unit in the group.
@unitId: which unit got updated
@unitCooldows: list of cooldowns of the unit
@allUnitsCooldowns: a list of all players with their cooldowns
===================================================================================================================================
function MyAddonObject.OnReceiveCooldownListUpdate(unitName, playerCooldows, allPlayersCooldowns)
--foreach player in the cooldown table
for unitName, playerCooldows in pairs(allPlayersCooldowns) do
for spellId, cooldownInfoTable in pairs(playerCooldows) do
--time left for the cooldown be ready to use, if time left is zero, the spell is ready
local timeLeft = cooldownInfoTable[1]
--in some cases the spell is on cooldown but there's a charge to use
local charges = cooldownInfoTable[2]
--cooldown start time offset (how much time has passed since the cooldown was used)
local startTimeOffset = cooldownInfoTable[3]
--cooldown duration, e.g. 180 for 3 minutes cooldown
local totalDuration = cooldownInfoTable[4]
--time when received this information
local timeReceived = cooldownInfoTable[5]
end
function MyAddonObject.OnReceiveCooldownListUpdate(unitId, unitCooldows, allUnitsCooldowns)
--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)
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(minValue, maxValue)
statusbar:SetValue(currentValue)
end
--get the cooldowns for the unit which got the cooldown update
local playerCooldows = allPlayersCooldowns[unitName]
for spellId, cooldownInfoTable in pairs(playerCooldows) do
--time left for the cooldown be ready to use, if time left is zero, the spell is ready
local timeLeft = cooldownInfoTable[1]
--in some cases the spell is on cooldown but there's a charge to use
local charges = cooldownInfoTable[2]
--cooldown start time
local startTime = cooldownInfoTable[3]
--cooldown duration, e.g. 180 for 3 minutes cooldown
local totalDuration = cooldownInfoTable[4]
--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)
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(0, 1)
statusbar:SetValue(normalizedPercent)
end
end
end
@@ -112,51 +125,50 @@ end
openRaidLib.RegisterCallback(MyAddonObject, "CooldownListUpdate", "OnReceiveCooldownListUpdate")
===================================================================================================================================
"CooldownUpdate": triggered when any unit in the group used a cooldown or the timeleft got an update
"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
@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.OnReceiveCooldownUpdate(unitName, spellId, cooldownTimeLeft, charges, startTime, totalDuration, playerCooldows, allPlayersCooldowns)
local unitCooldowns = allPlayersCooldowns[unitName] --is the same as using just 'playerCooldows' variable
--get the cooldowns for the unit which got the cooldown update
for spellId, cooldownInfoTable in pairs(playerCooldows) do
--time left for the cooldown be ready to use, if time left is zero, the spell is ready
local timeLeft = cooldownInfoTable[1]
--in some cases the spell is on cooldown but there's a charge to use
local charges = cooldownInfoTable[2]
--cooldown start time
local startTime = cooldownInfoTable[3]
--cooldown duration, e.g. 180 for 3 minutes cooldown
local totalDuration = cooldownInfoTable[4]
end
function MyAddonObject.OnReceiveCooldownUpdate(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns)
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(minValue, maxValue)
statusbar:SetValue(currentValue)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownUpdate", "OnReceiveCooldownUpdate")
===================================================================================================================================
"CooldownListWiped": when the list of cooldowns get a wipe, usually when the player leave the group
"CooldownListWipe": when the list of cooldowns get a wipe, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnCooldownListWipe(allPlayersCooldowns)
--print ("is nil:", next(allPlayersCooldowns))
function MyAddonObject.OnCooldownListWipe(allUnitsCooldowns)
--print ("is nil:", next(allUnitsCooldowns))
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownListWiped", "OnCooldownListWipe")
openRaidLib.RegisterCallback(MyAddonObject, "CooldownListWipe", "OnCooldownListWipe")
Note: right after the wipe, player cooldowns get an update, so a callback "CooldownListUpdate" is triggered right after this event (on the same tick).
===================================================================================================================================
"GearUpdate": when received an update from a player with all information about the gear
===================================================================================================================================
function MyAddonObject.OnGearUpdate(playerName, playerGear, allPlayersGear)
local itemLevelNumber = playerGear.ilevel
local durabilityNumber = playerGear.durability
function MyAddonObject.OnGearUpdate(unitId, unitGear, allUnitsGear)
local itemLevelNumber = unitGear.ilevel
local durabilityNumber = unitGear.durability
--hasWeaponEnchant is 1 have enchant or 0 is don't
local hasWeaponEnchantNumber = playerGear.weaponEnchant
local noEnchantTable = playerGear.noEnchants
local noGemsTable = playerGear.noGems
local hasWeaponEnchantNumber = unitGear.weaponEnchant
local noEnchantTable = unitGear.noEnchants
local noGemsTable = unitGear.noGems
for index, slotIdWithoutEnchant in ipairs (noEnchantTable) do
end
@@ -172,76 +184,116 @@ openRaidLib.RegisterCallback(MyAddonObject, "GearUpdate", "OnGearUpdate")
"GearDurabilityUpdate": when the gear durability of a player in the group changes
===================================================================================================================================
function MyAddonObject.OnGearDurabilityUpdate(playerName, durability, playerGear, allPlayersGear)
--print(playerName .. " durability is now " .. durability)
function MyAddonObject.OnGearDurabilityUpdate(unitId, durability, unitGear, allUnitsGear)
--print(UnitName(unitId) .. " durability is now " .. durability)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "GearDurabilityUpdate", "OnGearDurabilityUpdate")
===================================================================================================================================
"GearListWiped": when the list of gear get a wipe, usually when the player leave the group
"GearListWipe": when the list of gear get a wipe, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnGearListWiped(allPlayersGear)
--print ("is nil:", next(allPlayersGear))
function MyAddonObject.OnGearListWiped(allUnitsGear)
--print ("is nil:", next(allUnitsGear))
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "GearListWiped", "OnGearListWiped")
openRaidLib.RegisterCallback(MyAddonObject, "GearListWipe", "OnGearListWiped")
Note: right after the wipe, player gear information get an update, so a callback "GearUpdate" is triggered right after this event (on the same tick).
===================================================================================================================================
"PlayerUpdate": received a player information about its spec, talents, etc...
"UnitInfoUpdate": a unit in the group has been updated
===================================================================================================================================
function MyAddonObject.OnPlayerUpdate(playerName, playerInfo, allPlayersInfo)
for unitName, playerInfo in pairs(allPlayersInfo) do
local specId = playerInfo.specId
local renown = playerInfo.renown
local covenantId = playerInfo.covenantId
local talents = playerInfo.talents
local conduits = playerInfo.conduits
function MyAddonObject.OnUnitUpdate(unitId, unitInfo, allUnitsInfo)
for unitName, unitInfo in pairs(allUnitsInfo) do
local specId = unitInfo.specId
local specName = unitInfo.specName
local role = unitInfo.role
local renown = unitInfo.renown
local covenantId = unitInfo.covenantId
local talents = unitInfo.talents
local pvpTalents = unitInfo.pvpTalents
local conduits = unitInfo.conduits
local class = unitInfo.class = string class eng name 'ROGUE'
local classId = unitInfo.classId = number
local className = unitInfo.className
local unitName = unitInfo.name = string name without realm
local unitNameFull = unitInfo.nameFull = string name with realm 'unitName-ServerName'
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "PlayerUpdate", "OnPlayerUpdate")
openRaidLib.RegisterCallback(MyAddonObject, "UnitInfoUpdate", "OnUnitUpdate")
===================================================================================================================================
"TalentsUpdate": when a unit changed a talent
"UnitInfoWipe": when the unit info got wipped, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnTalentUpdate(playerName, talents, playerInfo, allPlayersInfo)
function MyAddonObject.OnUnitInfoWipe()
--all unit info got wiped
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitInfoWipe", "OnUnitInfoWipe")
Note: a "UnitUpdate" callback is triggered right after this event to notify the player info is updated.
===================================================================================================================================
"TalentUpdate": when a unit changed a talent
===================================================================================================================================
function MyAddonObject.OnTalentUpdate(unitId, talents, unitInfo, allUnitsInfo)
for i = 1, 7 do
local talentId = talents[i]
local talentID, name, texture, selected, available = GetTalentInfoByID(talentId)
print(name)
local talentID, talentName, texture, selected, available = GetTalentInfoByID(talentId)
print(talentName)
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "TalentUpdate", "OnTalentUpdate")
===================================================================================================================================
"OnPlayerDeath": when a player dies
"PvPTalentUpdate": when an unit changed a pvp talent
===================================================================================================================================
function MyAddonObject.OnPlayerDeath(playerName)
print(playerName .. " died.")
function MyAddonObject.OnPvPTalentUpdate(unitId, pvpTalents, unitInfo, allUnitsInfo)
for i = 1, 3 do
local talentId = pvpTalents[i]
local talentID, talentName, icon, selected, available, spellID, unlocked, row, column, known, grantedByAura = GetPvpTalentInfoByID(talentId)
print(talentName)
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "OnPlayerDeath", "OnPlayerDeath")
openRaidLib.RegisterCallback(MyAddonObject, "PvPTalentUpdate", "OnPvPTalentUpdate")
===================================================================================================================================
"OnPlayerRess": when a player revives
"UnitDeath": when an unit died
===================================================================================================================================
function MyAddonObject.OnPlayerRess(playerName)
print(playerName .. " is alive.")
function MyAddonObject.OnUnitDeath(unitId)
print(UnitName(unitId) .. " died.")
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "OnPlayerRess", "OnPlayerRess")
openRaidLib.RegisterCallback(MyAddonObject, "UnitDeath", "OnUnitDeath")
===================================================================================================================================
"UnitAlive": when an unit revives
===================================================================================================================================
function MyAddonObject.OnUnitRess(unitId)
print(UnitName(unitId) .. " is alive.")
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitAlive", "OnUnitRess")
+3
View File
@@ -1,4 +1,7 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..\FrameXML\UI.xsd">
<Script file="LibOpenRaid.lua" />
<Script file="Functions.lua" />
<Script file="GetPlayerInformation.lua" />
<Script file="Deprecated.lua" />
<Script file="ThingsToMantain.lua" />
</Ui>