Skip to content

Commit

Permalink
use LSM30_Sound for action & condition sound selection
Browse files Browse the repository at this point in the history
- add play button on each line
- play button on selection doesn't work with Custom, and Sound by Kit ID
- the sound doesn't auto preview anymore when selected

The gymnastic of inverting values required by this widget sucks
It may be better to fork it, also i don't know if it's good enough as it still wouldn't play Custom & Sound by Kit ID

An other direction could be to
=> fork and don't show icon on Custom & Sound by Kit, don't show icon on selected item on top, so probably better to fork LibDDI's itemControl = "DDI-Sound"
=> add a preview button that will use correct channel and work with custom/soundkit
  • Loading branch information
mrbuds committed Jul 28, 2023
1 parent f5384be commit cf6ae01
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
6 changes: 6 additions & 0 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2690,12 +2690,18 @@ for name, path in next, LSM:HashTable("sound") do
Private.sound_file_types[path] = name
end

Private.sound_types_inverted = {}
for path, key in pairs(Private.sound_types) do
Private.sound_types_inverted[key] = path
end

LSM.RegisterCallback(WeakAuras, "LibSharedMedia_Registered", function(_, mediatype, key)
if mediatype == "sound" then
local path = LSM:Fetch(mediatype, key)
if path then
Private.sound_types[path] = key
Private.sound_file_types[path] = key
Private.sound_types_inverted[key] = path
end
end
end)
Expand Down
20 changes: 17 additions & 3 deletions WeakAurasOptions/ActionOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,15 @@ function OptionsPrivate.GetActionOptions(data)
width = WeakAuras.normalWidth,
name = L["Sound"],
order = 8.4,
values = OptionsPrivate.Private.sound_types,
sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types),
dialogControl = "LSM30_Sound",
get = function()
return data.actions.start.sound and OptionsPrivate.Private.sound_types[data.actions.start.sound]
end,
set = function(info, v)
data.actions.start.sound = v and OptionsPrivate.Private.sound_types_inverted[v]
WeakAuras.Add(data);
end,
values = OptionsPrivate.Private.sound_types_inverted,
disabled = function() return not data.actions.start.do_sound end,
},
start_sound_channel = {
Expand Down Expand Up @@ -660,7 +667,14 @@ function OptionsPrivate.GetActionOptions(data)
width = WeakAuras.normalWidth,
name = L["Sound"],
order = 28.1,
values = OptionsPrivate.Private.sound_types,
get = function()
return data.actions.finish.sound and OptionsPrivate.Private.sound_types[data.actions.finish.sound]
end,
set = function(info, v)
data.actions.finish.sound = v and OptionsPrivate.Private.sound_types_inverted[v]
WeakAuras.Add(data);
end,
values = OptionsPrivate.Private.sound_types_inverted,
sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types),
disabled = function() return not data.actions.finish.do_sound end,
},
Expand Down
15 changes: 11 additions & 4 deletions WeakAurasOptions/ConditionOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,22 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA
args["condition" .. i .. "value" .. j .. "sound"] = {
type = "select",
width = WeakAuras.normalWidth,
values = OptionsPrivate.Private.sound_types,
sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types),
dialogControl = "LSM30_Sound",
values = OptionsPrivate.Private.sound_types_inverted,
name = blueIfNoValue2(data, conditions[i].changes[j], "value", "sound", L["Differences"]),
desc = descIfNoValue2(data, conditions[i].changes[j], "value", "sound", propertyType, OptionsPrivate.Private.sound_types),
order = order,
get = function()
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.sound;
return type(conditions[i].changes[j].value) == "table" and conditions[i].changes[j].value.sound and OptionsPrivate.Private.sound_types[conditions[i].changes[j].value.sound]
end,
set = function(info, v)
if (type (conditions[i].changes[j].value) ~= "table") then
conditions[i].changes[j].value = {};
end
conditions[i].changes[j].value["sound"] = v and OptionsPrivate.Private.sound_types_inverted[v];
WeakAuras.Add(data);
WeakAuras.ClearAndUpdateOptions(data.id)
end,
set = wrapWithPlaySound(setValueComplex("sound")),
hidden = function() return not (anySoundType("Play") or anySoundType("Loop")) end
}
order = order + 1;
Expand Down

0 comments on commit cf6ae01

Please sign in to comment.