diff --git a/WeakAuras/Media/Textures/VoiceChat-On.blp b/WeakAuras/Media/Textures/VoiceChat-On.blp new file mode 100644 index 0000000..8ed7c22 Binary files /dev/null and b/WeakAuras/Media/Textures/VoiceChat-On.blp differ diff --git a/WeakAuras/Media/Textures/VoiceChat-Speaker.blp b/WeakAuras/Media/Textures/VoiceChat-Speaker.blp new file mode 100644 index 0000000..f2e3cb7 Binary files /dev/null and b/WeakAuras/Media/Textures/VoiceChat-Speaker.blp differ diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index f798430..d3d1d58 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -2701,6 +2701,10 @@ Private.author_option_media_controls = { font = "LSM30_Font" } +Private.author_option_media_itemControls = { + sound = "WeakAurasMediaSound" +} + Private.array_entry_name_types = { [-1] = L["Fixed Names"], [0] = L["Entry Order"], diff --git a/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMediaSound.lua b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMediaSound.lua new file mode 100644 index 0000000..3a60de6 --- /dev/null +++ b/WeakAurasOptions/AceGUI-Widgets/AceGUIWidget-WeakAurasMediaSound.lua @@ -0,0 +1,98 @@ +--[[----------------------------------------------------------------------------- +WeakAurasMediaSound Widget + +This code come from https://www.curseforge.com/wow/addons/libddi-1-0 by Funkeh under "Ace3 Style BSD" licence +-------------------------------------------------------------------------------]] +local Type, Version = "WeakAurasMediaSound", 1 +local AceGUI = LibStub and LibStub("AceGUI-3.0", true) +if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then + return +end +local L = WeakAuras.L +local media = LibStub("LibSharedMedia-3.0") +local prototype = LibStub("AceGUI-3.0-DropDown-ItemBase"):GetItemBase() + +local ignore = { + [" " ..L["Custom"]] = true, + [" " ..L["Sound by Kit ID"]] = true, + [L["None"]] = true +} + +local function updateToggle(self) + if self.value then + self.check:Show() + else + self.check:Hide() + end +end + +local function updateSndButton(self) + local text = self.obj.text:GetText() + if text == nil or ignore[text] then + self.sndButton:Hide() + else + self.sndButton:Show() + end +end + +local function onRelease(self) + prototype.OnRelease(self) + self:SetValue(nil) +end + +local function onClick(frame) + local self = frame.obj + if self.disabled then return end + self.value = not self.value + if self.value then + PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON + else + PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF + end + updateToggle(self) + self:Fire("OnValueChanged", self.value) +end + +local function setValue(self, value) + self.value = value + updateToggle(self) +end + +local function getValue(self) + return self.value +end + +local function soundOnClick(self) + local snd = media:Fetch("sound", self.sound:GetText()) + if snd then PlaySoundFile(snd, "Master") end +end + +local function constructor() + local self = prototype.Create(Type) + self.frame:SetScript("OnShow", updateSndButton) + self.frame:SetScript("OnClick", onClick) + self.SetValue = setValue + self.GetValue = getValue + self.OnRelease = onRelease + local frame = self.frame + + local sndButton = CreateFrame("Button", nil, frame) + sndButton:SetWidth(16) + sndButton:SetHeight(16) + sndButton:SetPoint("RIGHT", frame, "RIGHT", -3, -1) + sndButton:SetScript("OnClick", soundOnClick) + sndButton.sound = frame.obj.text + frame.sndButton = sndButton + + local icon = sndButton:CreateTexture(nil, "BACKGROUND") + icon:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\VoiceChat-Speaker") --"Interface\\Common\\VoiceChat-Speaker" + icon:SetAllPoints(sndButton) + + local highlight = sndButton:CreateTexture(nil, "HIGHLIGHT") + highlight:SetTexture("Interface\\AddOns\\WeakAuras\\Media\\Textures\\VoiceChat-On") --"Interface\\Common\\VoiceChat-On" + highlight:SetAllPoints(sndButton) + + AceGUI:RegisterAsWidget(self) + return self +end +AceGUI:RegisterWidgetType(Type, constructor, Version) diff --git a/WeakAurasOptions/ActionOptions.lua b/WeakAurasOptions/ActionOptions.lua index 6d300ba..eb9082c 100644 --- a/WeakAurasOptions/ActionOptions.lua +++ b/WeakAurasOptions/ActionOptions.lua @@ -218,6 +218,7 @@ function OptionsPrivate.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound"], order = 8.4, + itemControl = "WeakAurasMediaSound", values = OptionsPrivate.Private.sound_types, sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types), disabled = function() return not data.actions.start.do_sound end, @@ -599,6 +600,7 @@ function OptionsPrivate.GetActionOptions(data) width = WeakAuras.normalWidth, name = L["Sound"], order = 28.1, + itemControl = "WeakAurasMediaSound", values = OptionsPrivate.Private.sound_types, sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types), disabled = function() return not data.actions.finish.do_sound end, diff --git a/WeakAurasOptions/AuthorOptions.lua b/WeakAurasOptions/AuthorOptions.lua index a0b3380..0619249 100644 --- a/WeakAurasOptions/AuthorOptions.lua +++ b/WeakAurasOptions/AuthorOptions.lua @@ -1016,6 +1016,7 @@ typeControlAdders = { end end, dialogControl = OptionsPrivate.Private.author_option_media_controls[option.mediaType], + itemControl = OptionsPrivate.Private.author_option_media_itemControls[option.mediaType], order = order(), get = get(option, "default"), set = function(_, value) @@ -2346,6 +2347,7 @@ local function addUserModeOption(options, args, data, order, prefix, i) elseif optionType == "media" then userOption.type = "select" userOption.dialogControl = OptionsPrivate.Private.author_option_media_controls[option.mediaType] + userOption.itemControl = OptionsPrivate.Private.author_option_media_itemControls[option.mediaType] userOption.values = function() if option.mediaType == "sound" then return OptionsPrivate.Private.sound_file_types diff --git a/WeakAurasOptions/ConditionOptions.lua b/WeakAurasOptions/ConditionOptions.lua index a8380f9..2e9af6f 100644 --- a/WeakAurasOptions/ConditionOptions.lua +++ b/WeakAurasOptions/ConditionOptions.lua @@ -581,6 +581,7 @@ local function addControlsForChange(args, order, data, conditionVariable, totalA width = WeakAuras.normalWidth, values = OptionsPrivate.Private.sound_types, sorting = OptionsPrivate.Private.SortOrderForValues(OptionsPrivate.Private.sound_types), + itemControl = "WeakAurasMediaSound", 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, diff --git a/WeakAurasOptions/WeakAurasOptions.toc b/WeakAurasOptions/WeakAurasOptions.toc index 89ad494..f88f087 100644 --- a/WeakAurasOptions/WeakAurasOptions.toc +++ b/WeakAurasOptions/WeakAurasOptions.toc @@ -95,3 +95,4 @@ AceGUI-Widgets\AceGUIWidget-WeakAurasSpacer.lua AceGUI-Widgets\AceGuiWidget-WeakAurasProgressBar.lua AceGUI-Widgets\AceGUIWidget-WeakAurasSpinBox.lua AceGUI-Widgets\AceGUIWidget-WeakAurasInputFocus.lua +AceGUI-Widgets\AceGUIWidget-WeakAurasMediaSound.lua