from retail
This commit is contained in:
@@ -2224,8 +2224,11 @@ Private.sound_types = {
|
|||||||
[" KitID"] = " " .. L["Sound by Kit ID"]
|
[" KitID"] = " " .. L["Sound by Kit ID"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Private.sound_file_types = {}
|
||||||
|
|
||||||
for name, path in next, LSM:HashTable("sound") do
|
for name, path in next, LSM:HashTable("sound") do
|
||||||
Private.sound_types[path] = name
|
Private.sound_types[path] = name
|
||||||
|
Private.sound_file_types[path] = name
|
||||||
end
|
end
|
||||||
|
|
||||||
LSM.RegisterCallback(WeakAuras, "LibSharedMedia_Registered", function(_, mediatype, key)
|
LSM.RegisterCallback(WeakAuras, "LibSharedMedia_Registered", function(_, mediatype, key)
|
||||||
@@ -2233,6 +2236,7 @@ LSM.RegisterCallback(WeakAuras, "LibSharedMedia_Registered", function(_, mediaty
|
|||||||
local path = LSM:Fetch(mediatype, key)
|
local path = LSM:Fetch(mediatype, key)
|
||||||
if path then
|
if path then
|
||||||
Private.sound_types[path] = key
|
Private.sound_types[path] = key
|
||||||
|
Private.sound_file_types[path] = key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -2576,6 +2580,7 @@ Private.author_option_classes = {
|
|||||||
range = "simple",
|
range = "simple",
|
||||||
color = "simple",
|
color = "simple",
|
||||||
select = "simple",
|
select = "simple",
|
||||||
|
media = "simple",
|
||||||
multiselect = "simple",
|
multiselect = "simple",
|
||||||
description = "noninteractive",
|
description = "noninteractive",
|
||||||
space = "noninteractive",
|
space = "noninteractive",
|
||||||
@@ -2593,6 +2598,7 @@ Private.author_option_types = {
|
|||||||
select = L["Dropdown Menu"],
|
select = L["Dropdown Menu"],
|
||||||
space = L["Space"],
|
space = L["Space"],
|
||||||
multiselect = L["Toggle List"],
|
multiselect = L["Toggle List"],
|
||||||
|
media = L["Media"],
|
||||||
header = L["Separator"],
|
header = L["Separator"],
|
||||||
group = L["Option Group"],
|
group = L["Option Group"],
|
||||||
}
|
}
|
||||||
@@ -2643,6 +2649,10 @@ Private.author_option_fields = {
|
|||||||
useHeight = false,
|
useHeight = false,
|
||||||
height = 1,
|
height = 1,
|
||||||
},
|
},
|
||||||
|
media = {
|
||||||
|
mediaType = "sound",
|
||||||
|
media = "Interface\\AddOns\\WeakAuras\\Media\\Sounds\\AirHorn.ogg"
|
||||||
|
},
|
||||||
multiselect = {
|
multiselect = {
|
||||||
default = {true},
|
default = {true},
|
||||||
values = {"val1"},
|
values = {"val1"},
|
||||||
@@ -2666,6 +2676,29 @@ Private.author_option_fields = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Private.shared_media_types = {
|
||||||
|
sound = L["Sound"],
|
||||||
|
font = L["Font"],
|
||||||
|
border = L["Border"],
|
||||||
|
background = L["Background"],
|
||||||
|
statusbar = L["Status Bar"]
|
||||||
|
}
|
||||||
|
|
||||||
|
Private.author_option_media_defaults = {
|
||||||
|
sound = "Interface\\AddOns\\WeakAuras\\Media\\Sounds\\AirHorn.ogg",
|
||||||
|
font = "Friz Quadrata TT",
|
||||||
|
border = "1 Pixel",
|
||||||
|
background = "None",
|
||||||
|
statusbar = "Blizzard",
|
||||||
|
}
|
||||||
|
|
||||||
|
Private.author_option_media_controls = {
|
||||||
|
statusbar = "LSM30_Statusbar",
|
||||||
|
border = "LSM30_Border",
|
||||||
|
background = "LSM30_Background",
|
||||||
|
font = "LSM30_Font"
|
||||||
|
}
|
||||||
|
|
||||||
Private.array_entry_name_types = {
|
Private.array_entry_name_types = {
|
||||||
[-1] = L["Fixed Names"],
|
[-1] = L["Fixed Names"],
|
||||||
[0] = L["Entry Order"],
|
[0] = L["Entry Order"],
|
||||||
|
|||||||
@@ -2325,7 +2325,12 @@ local function validateUserConfig(data, options, config)
|
|||||||
local optionClass = Private.author_option_classes[option.type]
|
local optionClass = Private.author_option_classes[option.type]
|
||||||
if optionClass ~= "group" then
|
if optionClass ~= "group" then
|
||||||
local option = options[authorOptionKeys[key]]
|
local option = options[authorOptionKeys[key]]
|
||||||
if type(value) ~= type(option.default) then
|
if option.type == "media" then
|
||||||
|
-- sounds can be number or string, other kinds of media can only be string
|
||||||
|
if type(value) ~= "string" and (type(value) ~= "number" or option.mediaType ~= "sound") then
|
||||||
|
config[key] = option.default
|
||||||
|
end
|
||||||
|
elseif type(value) ~= type(option.default) then
|
||||||
-- if type mismatch then we know that it can't be right
|
-- if type mismatch then we know that it can't be right
|
||||||
if type(option.default) ~= "table" then
|
if type(option.default) ~= "table" then
|
||||||
config[key] = option.default
|
config[key] = option.default
|
||||||
|
|||||||
@@ -975,6 +975,64 @@ typeControlAdders = {
|
|||||||
step = 1
|
step = 1
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
media = function(options, args, data, order, prefix, i)
|
||||||
|
local option = options[i]
|
||||||
|
args[prefix .. "mediaType"] = {
|
||||||
|
type = "select",
|
||||||
|
width = WeakAuras.normalWidth,
|
||||||
|
name = name(option, "mediaType", L["Media Type"]),
|
||||||
|
desc = desc(option, "mediaType"),
|
||||||
|
values = OptionsPrivate.Private.shared_media_types,
|
||||||
|
order = order(),
|
||||||
|
get = get(option, "mediaType"),
|
||||||
|
set = function(_, value)
|
||||||
|
for _, optionData in pairs(option.references) do
|
||||||
|
local childOption = optionData.options[optionData.index]
|
||||||
|
local childData = optionData.data
|
||||||
|
childOption.mediaType = value
|
||||||
|
childOption.default = OptionsPrivate.Private.author_option_media_defaults[value]
|
||||||
|
WeakAuras.Add(childData)
|
||||||
|
end
|
||||||
|
WeakAuras.ClearAndUpdateOptions(data.id, true)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
args[prefix .. "default"] = {
|
||||||
|
type = "select",
|
||||||
|
width = WeakAuras.doubleWidth,
|
||||||
|
name = name(option, "default", L["Default"]),
|
||||||
|
desc = desc(option, "default"),
|
||||||
|
values = function()
|
||||||
|
if option.mediaType == "sound" then
|
||||||
|
return OptionsPrivate.Private.sound_file_types
|
||||||
|
else
|
||||||
|
return AceGUIWidgetLSMlists[option.mediaType]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
sorting = function()
|
||||||
|
if option.mediaType == "sound" then
|
||||||
|
return OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_file_types)
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
dialogControl = OptionsPrivate.Private.author_option_media_controls[option.mediaType],
|
||||||
|
order = order(),
|
||||||
|
get = get(option, "default"),
|
||||||
|
set = function(_, value)
|
||||||
|
if option.mediaType == "sound" then
|
||||||
|
-- do this outside the deref loop, so we don't play the sound a million times
|
||||||
|
PlaySoundFile(value)
|
||||||
|
end
|
||||||
|
for _, optionData in pairs(option.references) do
|
||||||
|
local childOption = optionData.options[optionData.index]
|
||||||
|
local childData = optionData.data
|
||||||
|
childOption.default = value
|
||||||
|
WeakAuras.Add(childData)
|
||||||
|
end
|
||||||
|
WeakAuras.ClearAndUpdateOptions(data.id, true)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end,
|
||||||
multiselect = function(options, args, data, order, prefix, i)
|
multiselect = function(options, args, data, order, prefix, i)
|
||||||
local option = options[i]
|
local option = options[i]
|
||||||
local values = getValues(option)
|
local values = getValues(option)
|
||||||
@@ -2283,6 +2341,28 @@ local function addUserModeOption(options, args, data, order, prefix, i)
|
|||||||
end
|
end
|
||||||
WeakAuras.ClearAndUpdateOptions(data.id, true)
|
WeakAuras.ClearAndUpdateOptions(data.id, true)
|
||||||
end
|
end
|
||||||
|
elseif optionType == "media" then
|
||||||
|
userOption.type = "select"
|
||||||
|
userOption.dialogControl = OptionsPrivate.Private.author_option_media_controls[option.mediaType]
|
||||||
|
userOption.values = function()
|
||||||
|
if option.mediaType == "sound" then
|
||||||
|
return OptionsPrivate.Private.sound_file_types
|
||||||
|
else
|
||||||
|
return AceGUIWidgetLSMlists[option.mediaType]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
userOption.set = function(_, value)
|
||||||
|
if option.mediaType == "sound" then
|
||||||
|
PlaySoundFile(value)
|
||||||
|
end
|
||||||
|
for _, optionData in pairs(option.references) do
|
||||||
|
local childData = optionData.data
|
||||||
|
local childConfig = optionData.config
|
||||||
|
childConfig[option.key] = value
|
||||||
|
WeakAuras.Add(childData)
|
||||||
|
end
|
||||||
|
WeakAuras.ClearAndUpdateOptions(data.id, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif optionClass == "noninteractive" then
|
elseif optionClass == "noninteractive" then
|
||||||
if optionType == "header" then
|
if optionType == "header" then
|
||||||
@@ -2361,6 +2441,7 @@ local significantFieldsForMerge = {
|
|||||||
groupType = true,
|
groupType = true,
|
||||||
limitType = true,
|
limitType = true,
|
||||||
size = true,
|
size = true,
|
||||||
|
mediaType = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- these fields are special cases, generally reserved for when the UI displays something based on the merged options
|
-- these fields are special cases, generally reserved for when the UI displays something based on the merged options
|
||||||
|
|||||||
Reference in New Issue
Block a user