More fixes

This commit is contained in:
Tercio Jose
2024-07-11 15:43:43 -03:00
committed by andrew6180
parent d012c2c6d2
commit f7c52f821e
4 changed files with 55 additions and 2 deletions
+40
View File
@@ -1206,6 +1206,40 @@ function DF:CreateAnchorPointListGenerator(callback)
return newGenerator
end
function DF:CreateAudioListGenerator(callback)
local newGenerator = function()
local dropdownOptions = {
{
label = "--x--x--",
value = "",
onclick = callback
}
}
--fetch all audio cues from the libsharedmedia
DF.AudioCues = {}
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
for audioName, audioPath in pairs(SharedMedia:HashTable("sound")) do
DF.AudioCues[#DF.AudioCues+1] = {audioName, audioPath}
end
--sort the audio cues by name
table.sort(DF.AudioCues, function(t1, t2) return t1[1] < t2[1] end)
for i, audioInfo in ipairs(DF.AudioCues) do
table.insert(dropdownOptions, {
label = audioInfo[1],
value = audioInfo[2],
onclick = callback
})
end
return dropdownOptions
end
return newGenerator
end
---create a dropdown object with a list of fonts
---@param parent frame
---@param callback function
@@ -1240,6 +1274,12 @@ function DF:CreateAnchorPointDropDown(parent, callback, default, width, height,
return dropDownObject
end
function DF:CreateAudioDropDown(parent, callback, default, width, height, member, name, template)
local func = DF:CreateAudioListGenerator(callback)
local dropDownObject = DF:NewDropDown(parent, parent, name, member, width, height, func, default, template)
return dropDownObject
end
---create a dropdown object
---@param parent frame
---@param func function