Framework and Library updates

This commit is contained in:
Tercio Jose
2022-10-01 16:39:37 -03:00
parent b758956649
commit 858cca3248
6 changed files with 996 additions and 952 deletions
+804 -809
View File
File diff suppressed because it is too large Load Diff
+113 -111
View File
@@ -1,8 +1,8 @@
local dversion = 369
local dversion = 370
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
local DF, oldminor = LibStub:NewLibrary(major, minor)
if (not DF) then
DetailsFrameworkCanLoad = false
@@ -13,8 +13,8 @@ DetailsFrameworkCanLoad = true
local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
local _
local _type = type
local _unpack = unpack
local type = type
local unpack = unpack
local upper = string.upper
local string_match = string.match
local tinsert = _G.tinsert
@@ -51,10 +51,17 @@ if (not PixelUtil) then
end
end
function DF.IsDragonflight()
function DF.IsDragonflightAndBeyond()
return select(4, GetBuildInfo()) >= 100000
end
function DF.IsDragonflight()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 110000 and buildInfo >= 100000) then
return true
end
end
function DF.IsTimewalkWoW()
local _, _, _, buildInfo = GetBuildInfo()
if (buildInfo < 40000) then
@@ -212,7 +219,6 @@ function DF.GetSpecialization()
if (GetSpecialization) then
return GetSpecialization()
end
return nil
end
@@ -220,7 +226,6 @@ function DF.GetSpecializationInfoByID (...)
if (GetSpecializationInfoByID) then
return GetSpecializationInfoByID (...)
end
return nil
end
@@ -228,7 +233,6 @@ function DF.GetSpecializationInfo (...)
if (GetSpecializationInfo) then
return GetSpecializationInfo (...)
end
return nil
end
@@ -236,7 +240,6 @@ function DF.GetSpecializationRole (...)
if (GetSpecializationRole) then
return GetSpecializationRole (...)
end
return nil
end
@@ -247,11 +250,11 @@ DF.EncounterJournal = {
EJ_GetInstanceForMap = EJ_GetInstanceForMap or function() return nil end,
EJ_GetInstanceInfo = EJ_GetInstanceInfo or function() return nil end,
EJ_SelectInstance = EJ_SelectInstance or function() return nil end,
EJ_GetEncounterInfoByIndex = EJ_GetEncounterInfoByIndex or function() return nil end,
EJ_GetEncounterInfo = EJ_GetEncounterInfo or function() return nil end,
EJ_SelectEncounter = EJ_SelectEncounter or function() return nil end,
EJ_GetSectionInfo = EJ_GetSectionInfo or function() return nil end,
EJ_GetCreatureInfo = EJ_GetCreatureInfo or function() return nil end,
EJ_SetDifficulty = EJ_SetDifficulty or function() return nil end,
@@ -259,12 +262,8 @@ DF.EncounterJournal = {
EJ_GetLootInfoByIndex = EJ_GetLootInfoByIndex or function() return nil end,
}
if (not EJ_GetCurrentInstance) then
end
--> will always give a very random name for our widgets
local init_counter = math.random (1, 1000000)
--will always give a very random name for our widgets
local init_counter = math.random(1, 1000000)
DF.LabelNameCounter = DF.LabelNameCounter or init_counter
DF.PictureNameCounter = DF.PictureNameCounter or init_counter
@@ -282,25 +281,25 @@ DF.FRAMELEVEL_BACKGROUND = 150
--/dump DetailsFramework:PrintVersion()
DF.FrameWorkVersion = tostring (dversion)
DF.FrameWorkVersion = tostring(dversion)
function DF:PrintVersion()
print ("Details! Framework Version:", DF.FrameWorkVersion)
end
--> get the working folder
--get the working folder
do
local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)fw.lua")
local path = string.match(debugstack(1, 1, 0), "AddOns\\(.+)fw.lua")
if (path) then
DF.folder = "Interface\\AddOns\\" .. path
else
--> if not found, try to use the last valid one
--if not found, try to use the last valid one
DF.folder = DF.folder or ""
end
end
DF.debug = false
_G ["DetailsFramework"] = DF
_G["DetailsFramework"] = DF
DF.embeds = DF.embeds or {}
local embed_functions = {
@@ -380,7 +379,7 @@ local embed_functions = {
}
DF.WidgetFunctions = {
GetCapsule = function (self)
GetCapsule = function(self)
return self.MyObject
end,
}
@@ -391,11 +390,11 @@ function DF:GetFrameworkFolder()
return DF.folder
end
function DF:SetFrameworkDebugState (state)
function DF:SetFrameworkDebugState(state)
DF.debug = state
end
function DF:FadeFrame (frame, t)
function DF:FadeFrame(frame, t)
if (t == 0) then
frame.hidden = false
frame.faded = false
@@ -403,7 +402,7 @@ function DF:FadeFrame (frame, t)
frame.fading_in = false
frame:Show()
frame:SetAlpha (1)
elseif (t == 1) then
frame.hidden = true
frame.faded = true
@@ -414,7 +413,7 @@ function DF:FadeFrame (frame, t)
end
end
function DF.table.find (t, value)
function DF.table.find(t, value)
for i = 1, #t do
if (t[i] == value) then
return i
@@ -422,7 +421,7 @@ function DF.table.find (t, value)
end
end
function DF.table.addunique (t, index, value)
function DF.table.addunique(t, index, value)
if (not value) then
value = index
index = #t + 1
@@ -433,16 +432,16 @@ function DF.table.addunique (t, index, value)
return false
end
end
tinsert (t, index, value)
tinsert(t, index, value)
return true
end
function DF.table.reverse (t)
function DF.table.reverse(t)
local new = {}
local index = 1
for i = #t, 1, -1 do
new [index] = t[i]
new[index] = t[i]
index = index + 1
end
return new
@@ -455,7 +454,7 @@ function DF.table.duplicate(t1, t2)
if (type(value) == "table" and table.GetObjectType and table:GetObjectType()) then
t1[key] = value
elseif (type (value) == "table") then
elseif (type(value) == "table") then
t1[key] = t1[key] or {}
DF.table.copy(t1[key], t2[key])
@@ -472,7 +471,7 @@ end
function DF.table.copy(t1, t2)
for key, value in pairs(t2) do
if (key ~= "__index" and key ~= "__newindex") then
if (type (value) == "table") then
if (type(value) == "table") then
t1[key] = t1[key] or {}
DF.table.copy(t1[key], t2[key])
else
@@ -509,11 +508,11 @@ function DF.table.append(t1, t2)
end
--> copy values that does exist on table2 but not on table1
function DF.table.deploy (t1, t2)
for key, value in pairs (t2) do
if (type (value) == "table") then
function DF.table.deploy(t1, t2)
for key, value in pairs (t2) do
if (type(value) == "table") then
t1 [key] = t1 [key] or {}
DF.table.deploy (t1 [key], t2 [key])
DF.table.deploy(t1 [key], t2 [key])
elseif (t1 [key] == nil) then
t1 [key] = value
end
@@ -521,51 +520,51 @@ function DF.table.deploy (t1, t2)
return t1
end
function DF.table.dump (t, s, deep)
s = s or ""
function DF.table.dump(t, resultString, deep)
resultString = resultString or ""
deep = deep or 0
local space = ""
for i = 1, deep do
space = space .. " "
end
for key, value in pairs (t) do
local tpe = _type (value)
if (type (key) == "function") then
for key, value in pairs(t) do
local valueType = type(value)
if (type(key) == "function") then
key = "#function#"
elseif (type (key) == "table") then
elseif (type(key) == "table") then
key = "#table#"
end
if (type (key) ~= "string" and type (key) ~= "number") then
end
if (type(key) ~= "string" and type(key) ~= "number") then
key = "unknown?"
end
if (tpe == "table") then
if (type (key) == "number") then
s = s .. space .. "[" .. key .. "] = |cFFa9ffa9 {|r\n"
if (valueType == "table") then
if (type(key) == "number") then
resultString = resultString .. space .. "[" .. key .. "] = |cFFa9ffa9 {|r\n"
else
s = s .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9 {|r\n"
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFFa9ffa9 {|r\n"
end
s = s .. DF.table.dump (value, nil, deep+1)
s = s .. space .. "|cFFa9ffa9},|r\n"
elseif (tpe == "string") then
s = s .. space .. "[\"" .. key .. "\"] = \"|cFFfff1c1" .. value .. "|r\",\n"
elseif (tpe == "number") then
s = s .. space .. "[\"" .. key .. "\"] = |cFFffc1f4" .. value .. "|r,\n"
elseif (tpe == "function") then
s = s .. space .. "[\"" .. key .. "\"] = function()end,\n"
elseif (tpe == "boolean") then
s = s .. space .. "[\"" .. key .. "\"] = |cFF99d0ff" .. (value and "true" or "false") .. "|r,\n"
resultString = resultString .. DF.table.dump (value, nil, deep+1)
resultString = resultString .. space .. "|cFFa9ffa9},|r\n"
elseif (valueType == "string") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = \"|cFFfff1c1" .. value .. "|r\",\n"
elseif (valueType == "number") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFFffc1f4" .. value .. "|r,\n"
elseif (valueType == "function") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = function()end,\n"
elseif (valueType == "boolean") then
resultString = resultString .. space .. "[\"" .. key .. "\"] = |cFF99d0ff" .. (value and "true" or "false") .. "|r,\n"
end
end
return s
return resultString
end
--grab a text and split it into lines adding each line to a indexed table
@@ -600,8 +599,10 @@ DF.www_icons = {
local symbol_1K, symbol_10K, symbol_1B
if (GetLocale() == "koKR") then
symbol_1K, symbol_10K, symbol_1B = "", "", ""
elseif (GetLocale() == "zhCN") then
symbol_1K, symbol_10K, symbol_1B = "", "", "亿"
elseif (GetLocale() == "zhTW") then
symbol_1K, symbol_10K, symbol_1B = "", "", ""
end
@@ -609,81 +610,82 @@ end
function DF:GetAsianNumberSymbols()
if (GetLocale() == "koKR") then
return "", "", ""
elseif (GetLocale() == "zhCN") then
return "", "", "亿"
elseif (GetLocale() == "zhTW") then
return "", "", ""
else
--> return korean as default (if the language is western)
--return korean as default (if the language is western)
return "", "", ""
end
end
if (symbol_1K) then
function DF.FormatNumber (numero)
if (numero > 99999999) then
return format ("%.2f", numero/100000000) .. symbol_1B
elseif (numero > 999999) then
return format ("%.2f", numero/10000) .. symbol_10K
elseif (numero > 99999) then
return floor (numero/10000) .. symbol_10K
elseif (numero > 9999) then
return format ("%.1f", (numero/10000)) .. symbol_10K
elseif (numero > 999) then
return format ("%.1f", (numero/1000)) .. symbol_1K
function DF.FormatNumber(number)
if (number > 99999999) then
return format("%.2f", number/100000000) .. symbol_1B
elseif (number > 999999) then
return format("%.2f", number/10000) .. symbol_10K
elseif (number > 99999) then
return floor (number/10000) .. symbol_10K
elseif (number > 9999) then
return format("%.1f", (number/10000)) .. symbol_10K
elseif (number > 999) then
return format("%.1f", (number/1000)) .. symbol_1K
end
return format ("%.1f", numero)
return format("%.1f", number)
end
else
function DF.FormatNumber (numero)
if (numero > 999999999) then
return format ("%.2f", numero/1000000000) .. "B"
elseif (numero > 999999) then
return format ("%.2f", numero/1000000) .. "M"
elseif (numero > 99999) then
return floor (numero/1000) .. "K"
elseif (numero > 999) then
return format ("%.1f", (numero/1000)) .. "K"
function DF.FormatNumber (number)
if (number > 999999999) then
return format("%.2f", number/1000000000) .. "B"
elseif (number > 999999) then
return format("%.2f", number/1000000) .. "M"
elseif (number > 99999) then
return floor (number/1000) .. "K"
elseif (number > 999) then
return format("%.1f", (number/1000)) .. "K"
end
return floor (numero)
return floor(number)
end
end
function DF:CommaValue (value)
if (not value) then
return "0"
function DF:CommaValue(value)
if (not value) then
return "0"
end
value = floor (value)
value = floor(value)
if (value == 0) then
return "0"
end
--source http://richard.warburton.it
local left, num, right = string_match (value, '^([^%d]*%d)(%d*)(.-)$')
return left .. (num:reverse():gsub ('(%d%d%d)','%1,'):reverse()) .. right
end
function DF:GroupIterator (func, ...)
function DF:GroupIterator(callback, ...)
if (IsInRaid()) then
for i = 1, GetNumGroupMembers() do
DF:QuickDispatch (func, "raid" .. i, ...)
DF:QuickDispatch(callback, "raid" .. i, ...)
end
elseif (IsInGroup()) then
for i = 1, GetNumGroupMembers() - 1 do
DF:QuickDispatch (func, "party" .. i, ...)
DF:QuickDispatch(callback, "party" .. i, ...)
end
DF:QuickDispatch (func, "player", ...)
DF:QuickDispatch(callback, "player", ...)
else
DF:QuickDispatch (func, "player", ...)
DF:QuickDispatch(callback, "player", ...)
end
end
function DF:IntegerToTimer (value)
return "" .. floor (value/60) .. ":" .. format ("%02.f", value%60)
function DF:IntegerToTimer(value)
return "" .. floor(value/60) .. ":" .. format("%02.f", value%60)
end
function DF:Embed (target)
@@ -1189,10 +1191,10 @@ end
--> colors
function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
assert (_type (_colorname) == "string", "NewColor: colorname must be a string.")
assert (type (_colorname) == "string", "NewColor: colorname must be a string.")
assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
if (_type (_colortable) == "table") then
if (type (_colortable) == "table") then
if (_colortable[1] and _colortable[2] and _colortable[3]) then
_colortable[4] = _colortable[4] or 1
DF.alias_text_colors [_colorname] = _colortable
+37 -9
View File
@@ -257,18 +257,46 @@ function openRaidLib.FilterCooldowns(unitName, allCooldowns, filters)
return resultFilters
end
function openRaidLib.FlaskGetBySpellId(spellId)
--use to check if a spell is a flask buff, return a table containing .tier{}
function openRaidLib.GetFlaskInfoBySpellId(spellId)
return LIB_OPEN_RAID_FLASK_BUFF[spellId]
end
function openRaidLib.FlaskGetTier(auraInfo)
local flaskTable = openRaidLib.FlaskGetBySpellId(auraInfo.spellId)
local points = auraInfo.points
for i = 1, #points do
local flaskTier = flaskTable[points[i]]
if (flaskTier) then
return flaskTier
--return a number indicating the flask tier, if the aura isn't a flask return nil
function openRaidLib.GetFlaskTierFromAura(auraInfo)
local flaskTable = openRaidLib.GetFlaskInfoBySpellId(auraInfo.spellId)
if (flaskTable) then
local points = auraInfo.points
if (points) then
for i = 1, #points do
local flaskTier = flaskTable.tier[points[i]]
if (flaskTier) then
return flaskTier
end
end
end
end
return 1
return nil
end
--use to check if a spell is a food buff, return a table containing .tier{} .status{} .localized{}
function openRaidLib.GetFoodInfoBySpellId(spellId)
return LIB_OPEN_RAID_FOOD_BUFF[spellId]
end
--return a number indicating the food tier, if the aura isn't a food return nil
function openRaidLib.GetFoodTierFromAura(auraInfo)
local foodTable = openRaidLib.GetFoodInfoBySpellId(auraInfo.spellId)
if (foodTable) then
local points = auraInfo.points
if (points) then
for i = 1, #points do
local foodTier = foodTable.tier[points[i]]
if (foodTier) then
return foodTier
end
end
end
end
return nil
end
+5
View File
@@ -15,6 +15,11 @@ Code Rules:
- Public callbacks are callbacks registered by an external addon.
Change Log:
- added:
* openRaidLib.GetFlaskInfoBySpellId(spellId)
* openRaidLib.GetFlaskTierFromAura(auraInfo)
* openRaidLib.GetFoodInfoBySpellId(spellId)
* openRaidLib.GetFoodTierFromAura(auraInfo)
- added dragonflight talents support
- ensure to register events after 'PLAYER_ENTERING_WORLD' has triggered
- added openRaidLib.RequestCooldownInfo(spellId)
+23 -23
View File
@@ -434,34 +434,34 @@ elseif (isExpansion_Dragonflight()) then
--buff spellId, the value of the food is the tier level
--use /details auras
LIB_OPEN_RAID_FOOD_BUFF = {
[382145] = 1, --Well Fed haste 220
[382146] = 1, --Well Fed crit 220
[382149] = 1, --Well Fed vers 220
[382150] = 1, --Well Fed mastery 220
[382152] = 1, --Well Fed haste + crit 130
[382153] = 1, --Well Fed haste + vers 130
[382154] = 1, --Well Fed haste + mastery 130
[382155] = 1, --Well Fed crit + vers 130
[382156] = 1, --Well Fed crit + mastery 130
[382157] = 1, --Well Fed vers + mastery 130
[382145] = {tier = {[220] = 1}, status = {"haste"}, localized = {STAT_HASTE}}, --Well Fed haste 220
[382146] = {tier = {[220] = 1}, status = {"critical"}, localized = {STAT_CRITICAL_STRIKE}}, --Well Fed crit 220
[382149] = {tier = {[220] = 1}, status = {"versatility"}, localized = {STAT_VERSATILITY}}, --Well Fed vers 220
[382150] = {tier = {[220] = 1}, status = {"mastery"}, localized = {STAT_MASTERY}}, --Well Fed mastery 220
[382152] = {tier = {[130] = 1}, status = {"haste", "critical"}, localized = {STAT_HASTE, STAT_CRITICAL_STRIKE}}, --Well Fed haste + crit 130
[382153] = {tier = {[130] = 1}, status = {"haste", "versatility"}, localized = {STAT_HASTE, STAT_VERSATILITY}}, --Well Fed haste + vers 130
[382154] = {tier = {[130] = 1}, status = {"haste", "mastery"}, localized = {STAT_HASTE, STAT_MASTERY}}, --Well Fed haste + mastery 130
[382155] = {tier = {[130] = 1}, status = {"critical", "versatility"}, localized = {STAT_CRITICAL_STRIKE, STAT_VERSATILITY}}, --Well Fed crit + vers 130
[382156] = {tier = {[130] = 1}, status = {"critical", "mastery"}, localized = {STAT_CRITICAL_STRIKE, STAT_MASTERY}}, --Well Fed crit + mastery 130
[382157] = {tier = {[130] = 1}, status = {"mastery", "versatility"}, localized = {STAT_MASTERY, STAT_VERSATILITY}}, --Well Fed vers + mastery 130
}
--use /details auras
LIB_OPEN_RAID_FLASK_BUFF = {
--phials
[371354] = {[131] = 1, [151] = 2, [174] = 3}, --Phial of the Eye in the Storm
[370652] = {[470] = 1, [541] = 2, [622] = 3}, --Phial of Static Empowerment
[371172] = {[236] = 1, [257] = 2, [279] = 3}, --Phial of Tepid Versatility
[371204] = {[8125] = 1, [9344] = 2, [10746] = 3}, --Phial of Still Air
[371036] = {[-4] = 1, [-5] = 2, [-6] = 3}, --Phial of Icy Preservation
[374000] = {[690] = 1, [752] = 2, [814] = 3}, --Iced Phial of Corrupting Rage
[371386] = {[432] = 1, [497] = 2, [572] = 3}, --Phial of Charged Isolation
[373257] = {[4603] = 2, [3949] = 1, [5365] = 3}, --Phial of Glacial Fury
[393700] = {[45] = 3, [38] = 2, [32] = 1}, --Aerated Phial of Deftness
[393717] = {[45] = 3, [38] = 2, [32] = 1}, --Steaming Phial of Finesse
[371186] = {[558] = 3, [473] = 1, [515] = 2}, --Charged Phial of Alacrity
[393714] = {[45] = 3, [38] = 2, [32] = 1}, --Crystalline Phial of Perception
[371339] = {[562] = 3, [476] = 1, [519] = 2}, --Phial of Elemental Chaos
[371354] = {tier = {[131] = 1, [151] = 2, [174] = 3}}, --Phial of the Eye in the Storm
[370652] = {tier = {[470] = 1, [541] = 2, [622] = 3}}, --Phial of Static Empowerment
[371172] = {tier = {[236] = 1, [257] = 2, [279] = 3}}, --Phial of Tepid Versatility
[371204] = {tier = {[8125] = 1, [9344] = 2, [10746] = 3}}, --Phial of Still Air
[371036] = {tier = {[-4] = 1, [-5] = 2, [-6] = 3}}, --Phial of Icy Preservation
[374000] = {tier = {[690] = 1, [752] = 2, [814] = 3}}, --Iced Phial of Corrupting Rage
[371386] = {tier = {[432] = 1, [497] = 2, [572] = 3}}, --Phial of Charged Isolation
[373257] = {tier = {[4603] = 2, [3949] = 1, [5365] = 3}}, --Phial of Glacial Fury
[393700] = {tier = {[45] = 3, [38] = 2, [32] = 1}}, --Aerated Phial of Deftness
[393717] = {tier = {[45] = 3, [38] = 2, [32] = 1}}, --Steaming Phial of Finesse
[371186] = {tier = {[558] = 3, [473] = 1, [515] = 2}}, --Charged Phial of Alacrity
[393714] = {tier = {[45] = 3, [38] = 2, [32] = 1}}, --Crystalline Phial of Perception
[371339] = {tier = {[562] = 3, [476] = 1, [519] = 2}}, --Phial of Elemental Chaos
}
--spellId of healing from potions
+14
View File
@@ -140,6 +140,20 @@ local requestSent = openRaidLib.RequestKeystoneDataFromParty()
local requestSent = openRaidLib.RequestKeystoneDataFromRaid()
FLASK and FOOD buffs
--@spellId: a regular spellId
local flaskInfo = openRaidLib.GetFlaskInfoBySpellId(spellId)
--@auraInfo: UnitAuraInfo -> https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo see C_UnitAuras.GetAuraDataBySlot()
local flaskTier = openRaidLib.GetFlaskTierFromAura(auraInfo)
--@spellId: a regular spellId
local foodInfo = openRaidLib.GetFoodInfoBySpellId(spellId)
--@auraInfo: UnitAuraInfo -> https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo see C_UnitAuras.GetAuraDataBySlot()
local foodTier = openRaidLib.GetFoodTierFromAura(auraInfo)
Callbacks:
===================================================================================================================================