Fixed an issue with the end of m+ panel
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 560
|
||||
local dversion = 561
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary(major, minor)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ DF.Math = {}
|
||||
---@field RandomFraction fun(minValue: number, maxValue: number) : number
|
||||
---@field GetNinePoints fun(object: uiobject) : df_ninepoints
|
||||
---@field GetClosestPoint fun(ninePoints: df_ninepoints, coordinate: df_coordinate) : anchorid
|
||||
---@field GetVectorLength fun(vectorX: number, vectorY: number, vectorZ: number?) : number return the magnitude of a vector
|
||||
|
||||
---@class df_coordinate : table
|
||||
---@field x number
|
||||
@@ -122,6 +123,13 @@ function DF.Math.GetNinePoints(object)
|
||||
return ninePoints
|
||||
end
|
||||
|
||||
function DF.Math.GetVectorLength(vectorX, vectorY, vectorZ)
|
||||
if (not vectorZ) then
|
||||
return (vectorX * vectorX + vectorY * vectorY) ^ 0.5
|
||||
end
|
||||
return (vectorX * vectorX + vectorY * vectorY + vectorZ * vectorZ) ^ 0.5
|
||||
end
|
||||
|
||||
---return a random fraction between two values, example: RandomFraction(.2, .3) returns a number between .2 and .3, 0.25, 0.28, 0.21, etc
|
||||
function DF.Math.RandomFraction(minValue, maxValue)
|
||||
minValue = minValue or 0
|
||||
|
||||
+82
-49
@@ -7,8 +7,8 @@ end
|
||||
---@cast detailsFramework detailsframework
|
||||
|
||||
---pack a table into a string separating values with commas
|
||||
---the first index tells the table length, expected table: {1, 2, 3, 4, 5, 6, 7, 8, 9, ...}
|
||||
---can pack strings and numbers, returned string: "9,1,2,3,4,5,6,7,8,9", where the first number is the total size of table
|
||||
---example: table: {1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
---returned string: "9,1,2,3,4,5,6,7,8,9", where the first number is the total size of table
|
||||
---@param table table
|
||||
---@return string
|
||||
function detailsFramework.table.pack(table)
|
||||
@@ -22,50 +22,10 @@ function detailsFramework.table.pack(table)
|
||||
return newString
|
||||
end
|
||||
|
||||
---unpack a string and an array of data into a indexed table, sarting from the startIndex also returns the next index to start reading
|
||||
---expected data: "3,1,2,3,4,5,6,7,8" or {3,1,2,3,4,5,6,7,8}, with the example the returned table is: {1, 2, 3} and the next index to read is 5
|
||||
function detailsFramework.table.unpack(data, startIndex)
|
||||
local splittedTable
|
||||
|
||||
if (type(data) == "table") then
|
||||
splittedTable = data
|
||||
else
|
||||
splittedTable = {}
|
||||
for value in data:gmatch("[^,]+") do
|
||||
splittedTable[#splittedTable+1] = value
|
||||
end
|
||||
end
|
||||
|
||||
local currentIndex = startIndex or 1
|
||||
|
||||
local currentTableSize = tonumber(splittedTable[currentIndex])
|
||||
if (not currentTableSize) then
|
||||
error("Details! Framework: table.unpack: invalid table size.")
|
||||
end
|
||||
|
||||
startIndex = (startIndex and startIndex + 1) or 2
|
||||
local endIndex = currentTableSize + 1
|
||||
|
||||
local result = {}
|
||||
|
||||
for i = startIndex, endIndex do
|
||||
local value = splittedTable[i]
|
||||
local asNumber = tonumber(value)
|
||||
if (asNumber) then
|
||||
table.insert(result, asNumber)
|
||||
else
|
||||
table.insert(result, value)
|
||||
end
|
||||
end
|
||||
|
||||
return result, endIndex + 1 --return the position of the last index plus 1 to account for the table size index
|
||||
end
|
||||
|
||||
|
||||
---pack subtables into a string separating values with commas
|
||||
---the first index tells the table length of the first packed table, the index t[currentIndex+length+1] tells the length of the next table.
|
||||
---expected table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, ... }
|
||||
---can pack strings and numbers, returned string: "3,1,2,3,3,4,5,6,3,7,8,9"
|
||||
---pack subtables into a string separating values with commas, the first index tells the table length of the first packed table, the index t[currentIndex+length+1] tells the length of the next table.
|
||||
---can pack strings and numbers, example:
|
||||
---passed table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, ... }
|
||||
---returned string: "3,1,2,3,3,4,5,6,3,7,8,9" > 3 indicating the total size of the first subtable followed by the sub table data, then 3 indicating the total size of the second subtable and so on
|
||||
function detailsFramework.table.packsub(table)
|
||||
local newString = ""
|
||||
for i = 1, #table do
|
||||
@@ -76,9 +36,10 @@ function detailsFramework.table.packsub(table)
|
||||
return newString
|
||||
end
|
||||
|
||||
---merge multiple tables into a single one and pack it into a string separating values with commas
|
||||
---the first index tells the table length, expected table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, ... }
|
||||
---can pack strings and numbers, returned string: "9,1,2,3,4,5,6,7,8,9", where the first number is the total size of table
|
||||
---merge multiple tables into a single one and pack it into a string separating values with commas where the first index tells the table length
|
||||
---can pack strings and numbers, example:
|
||||
---passed table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
|
||||
---result string: "9,1,2,3,4,5,6,7,8,9" > 9 indicating the total size of the subtables following by the indexes of the subtables
|
||||
---@param table table
|
||||
---@return string
|
||||
function detailsFramework.table.packsubmerge(table)
|
||||
@@ -101,4 +62,76 @@ function detailsFramework.table.packsubmerge(table)
|
||||
|
||||
newString = newString:gsub(",$", "")
|
||||
return newString
|
||||
end
|
||||
|
||||
---unpack a string and an array of data into a indexed table, starting from the startIndex also returns the next index to start reading
|
||||
---expected data: "3,1,2,3,4,5,6,7,8" or {3,1,2,3,4,5,6,7,8}, with the example the returned table is: {1, 2, 3} and the next index to read is 5
|
||||
---@param data string|table
|
||||
---@param startIndex number?
|
||||
---@return table, number
|
||||
function detailsFramework.table.unpack(data, startIndex)
|
||||
local splittedTable
|
||||
|
||||
if (type(data) == "table") then
|
||||
splittedTable = data
|
||||
else
|
||||
splittedTable = {}
|
||||
for value in data:gmatch("[^,]+") do
|
||||
splittedTable[#splittedTable+1] = value
|
||||
end
|
||||
end
|
||||
|
||||
local currentIndex = startIndex or 1
|
||||
local currentTableSize = tonumber(splittedTable[currentIndex])
|
||||
if (not currentTableSize) then
|
||||
error("Details! Framework: table.unpack: invalid table size.")
|
||||
end
|
||||
|
||||
startIndex = (startIndex and startIndex + 1) or 2
|
||||
local endIndex = currentIndex + currentTableSize
|
||||
local result = {}
|
||||
|
||||
for i = startIndex, endIndex do
|
||||
local value = splittedTable[i]
|
||||
local asNumber = tonumber(value)
|
||||
if (asNumber) then
|
||||
table.insert(result, asNumber)
|
||||
else
|
||||
table.insert(result, value)
|
||||
end
|
||||
end
|
||||
|
||||
local nextIndex = endIndex + 1
|
||||
if (not splittedTable[nextIndex]) then
|
||||
return result, 0
|
||||
end
|
||||
|
||||
return result, endIndex + 1 --return the position of the last index plus 1 to account for the table size index
|
||||
end
|
||||
|
||||
|
||||
function detailsFramework.table.unpacksub(data, startIndex)
|
||||
startIndex = startIndex or 1
|
||||
|
||||
local splittedTable = {}
|
||||
local bIsRunning = true
|
||||
local result = {}
|
||||
|
||||
for value in data:gmatch("[^,]+") do
|
||||
splittedTable[#splittedTable+1] = value
|
||||
end
|
||||
|
||||
while (bIsRunning) do
|
||||
local unpackTable, nextIndex = detailsFramework.table.unpack(splittedTable, startIndex)
|
||||
table.insert(result, unpackTable)
|
||||
|
||||
if (nextIndex == 0) then
|
||||
bIsRunning = false
|
||||
break
|
||||
else
|
||||
startIndex = nextIndex
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
@@ -0,0 +1,56 @@
|
||||
|
||||
--this file isn't loaded, the tests need to be copied, loaded and run.
|
||||
|
||||
function PackTest()
|
||||
local table = {1, 2, 3, 4, 5}
|
||||
local packed = DetailsFramework.table.pack(table)
|
||||
print("Testing table.pack, table: {1, 2, 3, 4, 5}")
|
||||
local expected = "\"5,1,2,3,4,5\""
|
||||
print("Expected: string ", expected)
|
||||
print("Result: " .. type(packed) .. " \"" .. packed .. "\"")
|
||||
end
|
||||
|
||||
function PackSubTest()
|
||||
local table = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }
|
||||
local packed = DetailsFramework.table.packsub(table)
|
||||
print("Testing table.packsub, table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }")
|
||||
local expected = "\"3,1,2,3,3,4,5,6,3,7,8,9\""
|
||||
print("Expected: string ", expected)
|
||||
print("Result: " .. type(packed) .. " \"" .. packed .. "\"")
|
||||
end
|
||||
|
||||
function PackSubMergeTest()
|
||||
local table = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }
|
||||
local packed = DetailsFramework.table.packsubmerge(table)
|
||||
print("Testing table.packsubmerge, table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }")
|
||||
local expected = "\"9,1,2,3,4,5,6,7,8,9\""
|
||||
print("Expected: string ", expected)
|
||||
print("Result: " .. type(packed) .. " \"" .. packed .. "\"")
|
||||
end
|
||||
|
||||
function UnpackTest()
|
||||
local packed = "5,1,2,3,4,5"
|
||||
local table, nextIndex = DetailsFramework.table.unpack(packed)
|
||||
print("Testing table.unpack, data: \"5,1,2,3,4,5\"")
|
||||
local expected = "table {1, 2, 3, 4, 5}, 0"
|
||||
print("Expected:", expected)
|
||||
print("Result: " .. type(table) .. " {" .. table[1] .. ", " .. table[2] .. ", " .. table[3] .. ", " .. table[4] .. ", " .. table[5] .. "},", nextIndex)
|
||||
end
|
||||
|
||||
function UnpackSecondTest()
|
||||
local packed = "5,1,2,3,4,5,2,5,4,3,1,2,3"
|
||||
local table, nextIndex = DetailsFramework.table.unpack(packed, 7)
|
||||
print("Testing table.unpack with Idx 7, data: \"5,1,2,3,4,5,2,5,4,3,1,2,3\"")
|
||||
local expected = "table {5, 4}, 10"
|
||||
print("Expected:", expected)
|
||||
print("Result: " .. type(table) .. " {" .. table[1] .. ", " .. table[2] .. "},", nextIndex)
|
||||
end
|
||||
|
||||
function UnpackSubTest()
|
||||
local packed = "3,1,2,3,3,4,5,6,3,7,8,9"
|
||||
local tables = DetailsFramework.table.unpacksub(packed)
|
||||
print("Testing table.unpacksub, data: \"3,1,2,3,3,4,5,6,3,7,8,9\"")
|
||||
local expected = "table {table {1, 2, 3}, table {4, 5, 6}, table {7, 8, 9}}"
|
||||
print("Expected:", expected)
|
||||
print("Result: " .. type(tables) .. " {" .. type(tables[1]) .. " {" .. tables[1][1] .. ", " .. tables[1][2] .. ", " .. tables[1][3] .. "}, " .. type(tables[2]) .. " {" .. tables[2][1] .. ", " .. tables[2][2] .. ", " .. tables[2][3] .. "}, " .. type(tables[3]) .. " {" .. tables[3][1] .. ", " .. tables[3][2] .. ", " .. tables[3][3] .. "}}")
|
||||
end
|
||||
@@ -186,6 +186,9 @@ function lootFrame.UpdateUnitLoot(playerBanner)
|
||||
|
||||
local timeNow = GetTime()
|
||||
local lootCache = lootFrame.LootCache[unitName]
|
||||
if (not lootCache) then
|
||||
return
|
||||
end
|
||||
|
||||
---@type details_loot_cache[]
|
||||
local lootCandidates = {}
|
||||
|
||||
Reference in New Issue
Block a user